CodeIgniter Forums
In the Database table for News Change - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: In the Database table for News Change (/showthread.php?tid=71786)



In the Database table for News Change - InsiteFX - 09-24-2018

The Database news table:

Code:
CREATE TABLE news (
       id int(11) NOT NULL AUTO_INCREMENT,
       title varchar(128) NOT NULL,
       slug varchar(128) NOT NULL,
       text text NOT NULL, <----------> This should be changed to body, text is a MySQL reserved word.
       PRIMARY KEY (id),
       KEY slug (slug)
);
The view:
PHP Code:
<h2><?= $title ?></h2>

<?php if (! empty($news) && is_array($news)) : ?>

        <?php foreach ($news as $news_item): ?>

                <h3><?= $news_item['title'?></h3>

                <div class="main">
                        <?= $news_item['text'?> <--------> Change to body.
                </div>
                <p><a href="<?= '/news/'.$news_item['slug'?>">View article</a></p>

        <?php endforeach; ?>

<?php else : ?>

        <h3>No News</h3>

        <p>Unable to find any news for you.</p>

<?php endif ?>
Also there is an error in the controlllers view method.
PHP Code:
if (empty($data['news']))
{
 
   throw new \CodeIgniter\PageNotFoundException('Cannot find the page: '$slug);
}

// Should be

if (empty($data['news']))
{
 
   throw new \CodeIgniter\Exceptions\PageNotFoundException('Cannot find the page: '$slug);

view.php
Code:
<?php
echo '<h2>'.$news['title'].'</h2>';
echo $news['text']; <--------------------> Should be body
Also it seems that none of the News Routes are working at all just getting 404's

If I change the routes from the get to the add then they work.


RE: In the Database table for News Change - ciadmin - 09-24-2018

Notes, thanks. I see you have raised a bug report on the repo, and we will fix this Undecided


RE: In the Database table for News Change - InsiteFX - 09-25-2018

(09-24-2018, 12:41 PM)ciadmin Wrote: Notes, thanks. I see you have raised a bug report on the repo, and we will fix this Undecided

Thanks.