Step 5.2 – Administer static pages for our multilanguage CMS – editing the pages

(created at: April 02, 2015; last update: April 05, 2015)
We’ve created multilanguage pages, we’ve listed them, but what about editing them?

For this we will create a new method named edit(), which will receive the language slug and the page id.

We don’t have to worry about being lost in translations. Our method will first ask page_translation_model if there is a translation of the page in that particular language. If there is such a translation, the method will also make sure that there exists a page that the translation pretends it belongs to by asking the page_model.

After we’ve made all the checks, we will pass all the needed data to the edit_view view:

As you can see, we’ve also interrogated the slug_model that we’ve created in a previous tutorial. So ,let’s make sure it is loaded inside the controller’s constructor:

Now, let’s get the rules and render the edit_view view if those rules are not respected:

But we didn’t define the rules, so let’s return to our Page_model and update them:

Now we create edit_view.php inside the views/admin/pages directory (which looks almost like the create_view.php, but with a few changes):

Once we did that, we return to our edit() method and see what we can do after the validation was passed.

First of all we need to make sure we have a translation that needs updated. After that, we pass all POST data to variables and then do the necessary update:

Let’s see the whole controller again:

And that’s it… Next we will do our delete() method….

0 thoughts on “Step 5.2 – Administer static pages for our multilanguage CMS – editing the pages

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

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