• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
In the Database table for News Change

#1
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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

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

#3
(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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.