Hi,
Apologies if this post is in the wrong section.
I’m evaluating EE Core to build a website, with the view of upgrading to a commercial license if all goes well.
Now, I’m used to creating php/mysql based sites using index.php as a master template with sub-templates being included into index.php based on a query string.
e.g.
www.domain.com/index.php?section=home = Homepage
www.domain.com/index.php?section=news = News Page
www.domain.com/index.php?section=news&id=12 = News Item #12
So I’m building my templates in EE at the moment, and ideally those same URLs should equate to something like:
www.domain.com/index.php/home/
www.domain.com/index.php/news/
www.domain.com/index.php/news/news_story_title
I realise that index.php/home is one template group and index.php/news is another. However, both of these template groups will contain large amounts of duplicate code.
In my main template snippet below I’ve stripped out the header/footer into sub-templates, as these are constant. However I will need to embed the correct layout template based on which page is requested.
<div id="wrapper">
{!-- Include Page Mast --}
{embed="inc/pg_mast"}
{!-- Include layout based on section (one of: home, news, ...) --}
{embed="layouts/home"}
{!-- Include Page Footer --}
{embed="inc/pg_footer"}
</div>
If I were building a normal PHP site, the embeds would be include() calls, and the layout call would be something like include(‘layouts/’.$_GET[‘section’].’.php’);
I can think of two (not very suitable) solutions to do this in EE:
1. Create the site with one master template and use query strings and php code to identify and determine sections.
2. Create duplicate templates with identical code except for the {embed=“layouts/home”} line.
I hope I’m making sense with all this? Can anyone think of a better solution?
Ideally there should be one master template which loads a dynamic sub-template based on the page requested.
