Is this a clean way to do templates?
Posted: 28 August 2008 02:48 AM   [ Ignore ]  
Research Assistant
RankRankRank
Total Posts:  370
Joined  07-06-2008

My new template looks cleaner, except for the first few lines that check on the segment urls. Below:

<!-- See which page we are on -->
{if segment_1 == ""}
    {assign_variable
:current_page_label="Daily Addictions"}
    {assign_variable
:second_page_label=""}
    {assign_variable
:current_page_name="daily_addictions"}
{
/if}
{if segment_1
== "blog_detail"}
    {assign_variable
:current_page_label="Daily Addictions"}
    {assign_variable
:second_page_label="{segment_2}"}
    {assign_variable
:current_page_name="blog_detail"}
{
/if}
{if segment_1
== "contact"}
    {assign_variable
:current_page_label="Contact"}
    {assign_variable
:second_page_label=""}
    {assign_variable
:current_page_name="contact"}
{
/if}
{if segment_1
== "about"}
    {assign_variable
:current_page_label="About"}
    {assign_variable
:second_page_label=""}
    {assign_variable
:current_page_name="about"}
{
/if}



{embed
="paradise_calling_embeds/html_header" current_page_label="{current_page_label}"}

<body>
            
    
{embed="paradise_calling_embeds/header" current_page_label="{current_page_label}"}
    
    
<div id="main" class="container showgrid">
        <
div class="span-24">
            
            <
div id="page1">                
                <
div id="page2">
                    
                    
{embed="paradise_calling_embeds/search"}
                    
                    {embed
="paradise_calling_embeds/breadcrumb" current_page_label="{current_page_label}" second_page_label="{second_page_label}"}
                    
                    {embed
="paradise_calling_embeds/side_panel"}
                
                                
                    
<div id="page3">
                        
                        
{embed="paradise_calling_embeds/{current_page_name}"}
                            
                    
</div>
                    <!--
page3 -->    
                    
                        <!-- List
a single blog -->
                        
{if segment_1 == "blog_detail"}
                            {embed
="paradise_calling_embeds/comments"}
                        {
/if}
                                        
                
</div>        
                <!--
page2 -->                        
            </
div>
        
            
        </
div>        
    </
div>
    
    
    
{embed="paradise_calling_embeds/footer"}


</body>
</
html>

Without the if conditions checking the segment urls, it would look like this:

{embed="paradise_calling_embeds/html_header" current_page_label="{current_page_label}"}

<body>
            
    
{embed="paradise_calling_embeds/header" current_page_label="{current_page_label}"}
    
    
<div id="main" class="container showgrid">
        <
div class="span-24">
            
            <
div id="page1">                
                <
div id="page2">
                    
                    
{embed="paradise_calling_embeds/search"}
                    
                    {embed
="paradise_calling_embeds/breadcrumb" current_page_label="{current_page_label}" second_page_label="{second_page_label}"}
                    
                    {embed
="paradise_calling_embeds/side_panel"}
                
                                
                    
<div id="page3">
                        
                        
{embed="paradise_calling_embeds/{current_page_name}"}
                            
                    
</div>
                    <!--
page3 -->    
                    
                        <!-- List
a single blog -->
                        
{if segment_1 == "blog_detail"}
                            {embed
="paradise_calling_embeds/comments"}
                        {
/if}
                                        
                
</div>        
                <!--
page2 -->                        
            </
div>
        
            
        </
div>        
    </
div>
    
    
    
{embed="paradise_calling_embeds/footer"}


</body>
</
html>

 Signature 

Live the News For a fun read on news entertainment and pop-culture

Profile
 
 
Posted: 28 August 2008 02:48 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
RankRankRank
Total Posts:  370
Joined  07-06-2008

However, my previous template looked messier without the “if conditions” checking the url segments at the beginning, instead it was checking them in middle:

{embed="paradise_calling_embeds/html_header" current_page="{current_page}"}

<body>
            
    
{embed="paradise_calling_embeds/header" current_page="{current_page}"}
    
    
<div id="main" class="container showgrid">
        <
div class="span-24">
            
            <
div id="page1">                
                <
div id="page2">
                    
                    
{embed="paradise_calling_embeds/search"}
                    
                    {embed
="paradise_calling_embeds/breadcrumb" current_page="{current_page}"}
                    
                    {embed
="paradise_calling_embeds/side_panel"}
                
                                
                    
<div id="page3">
                        
                        <!-- List
all blogs -->
                        
{if segment_1 == null}
                            {embed
="paradise_calling_embeds/blogs"}
                        
                        
<!-- List a single blog -->
                        
{if:elseif segment_1 == "blog_detail"}
                            {embed
="paradise_calling_embeds/blog_detail"}
                        
                        
<!-- Show the Contact page -->
                        
{if:elseif segment_1 == "contact"}
                            {embed
="paradise_calling_embeds/contact"}
                        
                        
<!-- Show the About page -->
                        
{if:elseif segment_1 == "about"}
                            {embed
="paradise_calling_embeds/about"}
                        
                        {
/if}
                        
                        
                    
</div>
                    <!--
page3 -->    
                    
                        <!-- List
a single blog -->
                        
{if segment_1 == "blog_detail"}
                            {embed
="paradise_calling_embeds/comments"}
                        
                        {
/if}
                                        
                
</div>        
                <!--
page2 -->                        
            </
div>
        
            
        </
div>        
    </
div>
    
    
    
{embed="paradise_calling_embeds/footer"}


</body>
</
html>

Which method looks cleaner? And is there a better / cleaner way that what I already have?
Alternatively, if you were in my shoes how would you go about this?

 Signature 

Live the News For a fun read on news entertainment and pop-culture

Profile
 
 
Posted: 28 August 2008 04:11 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
RankRankRank
Total Posts:  370
Joined  07-06-2008

Or do you have a template for each main link (i.e. contacts, about, main site, etc)?

I guess this is fine, however, once you change the style on one main layout, youll have to do it with all the others. Is this how most EE developers are doing it?

 Signature 

Live the News For a fun read on news entertainment and pop-culture

Profile
 
 
Posted: 28 August 2008 09:49 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  322
Joined  03-18-2007

I use template groups for things like this. Let EE do the work of figuring out what segment_1 is and showing the right template. Then just use embeds for the header and footer.

Profile
 
 
Posted: 31 August 2008 07:54 PM   [ Ignore ]   [ # 4 ]  
Research Assistant
RankRankRank
Total Posts:  370
Joined  07-06-2008
slapshotw - 28 August 2008 09:49 AM

I use template groups for things like this. Let EE do the work of figuring out what segment_1 is and showing the right template. Then just use embeds for the header and footer.

Can I see a code snippet of your main template that has the embeds. Im just curious

 Signature 

Live the News For a fun read on news entertainment and pop-culture

Profile
 
 
Posted: 31 August 2008 10:19 PM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  322
Joined  03-18-2007

There would be template groups for blog_detail, contact, and about. Each one of those has an index page with the code that’s in the embeds right now, and then just embed common header and footer code.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64491 Total Logged-in Users: 59
Total Topics: 81032 Total Anonymous Users: 24
Total Replies: 436054 Total Guests: 270
Total Posts: 517086    
Members ( View Memberlist )