Step 5.3 – Administer static pages for our multilanguage CMS – deleting the pages

Created at: April 2, 2015; Last update: April 4, 2015

OK…

Let’s delete all. Not really… but we need to create the delete() method. This method will receive the language slug and the page id. Further more, if the language slug will have “all” as value (I sure hope you won’t choose “all” as language slug in the future…), this will delete the whole page with it’s translations. And let’s not forget about the slugs. We delete them too.

I guess that if you got here then no more explanation is necessary about what I am going to do. But if you have questions, you can at any time approach me with a comment on my posts.

So, let me show you the method:

Also, let’s make sure that the users will be asked again if they are sure they want to delete the pages/translations by appending to the delete links an onclick event:

More on this onclick event you can find in an older tutorial of mine: Confirm box in javascript: Are you sure you want to delete?

Let’s see our index_view view again:

Now, let’s see the Pages controller again:

Hope you liked it…

4 thoughts on “Step 5.3 – Administer static pages for our multilanguage CMS – deleting the pages

  1. one name

    Hi, I’m a bit confused right now – everything works fine, I can create, edit and delete static pages with this CMS tool – but how can I access the static page as a normal user (as a user who did not login and who would just like to see the content of the page? What is the URL to the created static page?)

    Reply
    1. avenirer Post author

      Hello. Sorry for the time passed. I was in vacation. If you’ve followed the tutorial from start to end, you should simply access the page by writing the slug you’ve set up for the page at the end of your domain name. For example if you’ve saved a page with the slug “a-new-page”, you should see it by writing “http://localhost/a-new-page”

      Reply
  2. Trung

    Hi there! Anyone can help me out?
    I’ve got this error and didnt know how to fix it.
    Severity: Notice
    Message: Undefined property: Pages::$user_id
    Filename: admin/Pages.php
    Column ‘created_by’ cannot be null
    INSERT INTO slugs (content_type, content_id, translation_id, language_slug, url, created_by, created_at) VALUES (‘page’, 4, 5, ‘en’, ‘man-love-woman’, NULL, ‘2017-01-04 04:31:03’)
    Filename: F:/WEBROOT/cms_admin_ci3/application/core/MY_Model.php

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

No spam? * Time limit is exhausted. Please reload CAPTCHA.