I am working on a cms based Yii application. I have recently finished the pages of the backend and can now get the pages from a database.
The trouble begins with getting the requested url and rendering the dynamic layout.
What is the best way to go about this? Like use a start site/domain controller and how do I set it up?
The Rendering with CMenu goes well in the template. The menu shows in the frontend. Here is an example of the menu links I currently use like /home and /company/products. It uses clean urls.
<ul id="yw0">
<li class="active"><a href="/home">Home</a></li>
<li><a href="/about_us">About us</a></li>
<li><a href="/company">Company</a></li>
<ul>
<li><a href="/company/products">Products</a></li>
<li><a href="/company/services">Services</a></li>
</ul>
<li><a href="/contact">Contact</a></li>
</ul>
But this is one point ahead. The layout needs to be dynamically loaded from a specific page in the backend. Every page can have a different layout. There is a column for this in the database. So for example the url: "http://example.com/home" needs to load 'protected/views/layouts/main.php'
At the moment the links like: "http://example.com/company/products" don't go anywhere. This is obvious because the links don't exist and are dynamically created.
I am thinking I need to do two things:
- One make a startController that every request goes to and that will handle the loading of the pages and layout.
- And two some setup with clean Urls.?
That's it.
I can imagine it being not much work. But it's giving me headaches.
Especially the clean urls. They have always been abit confusing to me.
index.php?r=site/index would go to siteController and action index.
But this is not what I want. I also tried setting up the 'urlManager' but it goes to a controller and an action. Like page/default/view/id/. But I don't want to go to an action but just the start controller loading the (next) requested page(with different layout) from the database.
Do I need to setup clean urls somewhere in the config file main.php
Hope it's easy to understand what I like to achieve. Any help is greatly appreciated.