Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Heya guys,

My first site using Couch has been up for several months and I love it so far.
The client has decided he wants to expand the site to include different sections (pages) but wants to display a different logo image on each of these new pages.

The site is currently set up with globals.php & header.html (in snippets) as per the tutorial with the logo image in header.html pulled from globals.php.

My thoughts are to add to globals.php so the client can add/upload his image and then use an if/else statement in heater.html to display the required logo on the different pages.

My problem is I'm not sure of the best way to code the if/else into header.html
OR if there is a better way to achieve what I need.

Below is my globals.php (with new variables added) and my header.html (with new links added).....

globals.php
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Global Settings' executable='0' order='99'>
   <cms:editable name='site_name' label='Your Site\'s name' type='text' order='-3' >Aurelius</cms:editable>
   <cms:editable name='logo_image' label='Your Logo Image' desc='Upload you logo image here' type='image' order='-2' />
   <cms:editable name='site_desc' label='Your Site\'s description' type='text' order='-1' />
   
   <cms:editable name='home_caption' label='Home Caption'
       height='50'
       type='textarea' order='4'><p>&nbsp;</p>
      </cms:editable>
   <cms:editable name='about_caption' label='About Us Caption'
       height='50'
       type='textarea'> order='5'><p>&nbsp;</p>
      </cms:editable>
   <cms:editable name='gal_caption' label='Gallery Caption'
       height='50'
       type='textarea' order='8'><p>&nbsp;</p>
      </cms:editable>
   <cms:editable name='safety_caption' label='Safety Caption'
       height='50'
       type='textarea' order='6'><p>&nbsp;</p>
      </cms:editable>   
   <cms:editable name='faq_caption' label='FAQ Caption'
       height='50'
       type='textarea' order='9'><p>&nbsp;</p>
      </cms:editable>   
   <cms:editable name='contact_caption' label='Contact Us Caption'
       height='50'
       type='textarea' order='10'><p>&nbsp;</p>
      </cms:editable>   
   <cms:editable name='dt_caption' label='Dog Tales Caption'
       height='50'
       type='textarea' order='11'><p>&nbsp;</p>
      </cms:editable>   
   <cms:editable name='dts_caption' label='Dog Tales Submission Caption'
       height='50'
       type='textarea' order='12'><p>&nbsp;</p>
      </cms:editable>

      <!-- // Start Section Pages // -->

   <cms:editable name='lm_caption' label='Lawn Maintenance Caption'
       height='50'
       type='textarea' order='13'><p>&nbsp;</p>
      </cms:editable>   
   <cms:editable name='lm_logo_image' label='Your Lawn Maintenance Logo Image' desc='Upload you logo image here' type='image' order='14' />

   <cms:editable name='hm_caption' label='Handymen Caption'
       height='50'
       type='textarea' order='15'><p>&nbsp;</p>
      </cms:editable>
   <cms:editable name='hm_logo_image' label='Your Handymen Logo Image' desc='Upload you logo image here' type='image' order='16' />

   <cms:editable name='ls_caption' label='Landscaping Caption'
       height='50'
       type='textarea' order='17'><p>&nbsp;</p>
      </cms:editable>
   <cms:editable name='ls_logo_image' label='Your Landscaping Logo Image' desc='Upload you logo image here' type='image' order='18' />

   <cms:editable name='fencing_caption' label='Fencing Caption'
       height='50'
       type='textarea' order='19'><p>&nbsp;</p>
      </cms:editable>
   <cms:editable name='fencing_logo_image' label='Your Fencing Logo Image' desc='Upload you logo image here' type='image' order='20' />

   <cms:editable name='hire_caption' label='Equipment Hire Caption'
       height='50'
       type='textarea' order='21'><p>&nbsp;</p>
      </cms:editable>
   <cms:editable name='hire_logo_image' label='Your Hire Logo Image' desc='Upload you logo image here' type='image' order='22' />

</cms:template>
<?php COUCH::invoke(); ?>




header.html
Code: Select all
<a href="<cms:link 'index.php' />"><img class="grid_logo" alt="Red Heeler Industries" src="<cms:get_custom_field 'logo_image' masterpage='globals.php' />" /></a>


<!-- /* Site Nav2 */ -->
<ul id="navigation" class="grid_9">
   <li><a href="<cms:link 'hire.php' />" <cms:if k_template_name=='hire.php'>class="current"</cms:if> ><br />Hire</a></li>
   <li><a href="<cms:link 'fencing.php' />" <cms:if k_template_name=='fencing.php'>class="current"</cms:if> ><br />Fencing</a></li>
   <li><a href="<cms:link 'landscaping.php' />" <cms:if k_template_name=='landscaping.php'>class="current"</cms:if> ><br />Landscaping</a></li>
   <li><a href="<cms:link 'handymen.php' />" <cms:if k_template_name=='handymen.php'>class="current"</cms:if> ><br />Handymen</a></li>
   <li><a href="<cms:link 'lawn.php' />" <cms:if k_template_name=='lawn.php'>class="current"</cms:if> ><br />Lawn Maintenance</a></li>
   <li><a href="<cms:link 'index.php' />" <cms:if k_template_name=='index.php'>class="current"</cms:if> ><br />Home</a></li>
</ul>

<!-- Navigation Menu -->
<ul id="nav2" class="grid_9">
   <li><a href="<cms:link 'contact.php' />" <cms:if k_template_name=='contact.php'>class="current"</cms:if> ><br />Contact Us</a></li>
   <li><a href="<cms:link 'faq.php' />" <cms:if k_template_name=='faq.php'>class="current"</cms:if> ><br />FAQ</a></li>
   <li><a href="<cms:link 'gallery.php' />" <cms:if k_template_name=='gallery.php'>class="current"</cms:if> ><br />Gallery</a></li>
   <li><a href="<cms:link 'safety.php' />" <cms:if k_template_name=='safety.php'>class="current"</cms:if> ><br />Safety</a></li>
   <li><a href="<cms:link 'about.php' />" <cms:if k_template_name=='about.php'>class="current"</cms:if> ><br />About Us</a></li>
   <li><a href="<cms:link 'dogtales.php' />" <cms:if k_template_name=='dogtales.php'>class="current"</cms:if> ><br />Dog Tales</a></li>
</ul>


The 5 "Section Pages" in globals.php and the "Site Nav2" links in header.html are the relevant pages.

Any help appreciated, Cheers 8-)
Update:
I actually got it working using the following code in header.html...

Code: Select all
<a href="<cms:link 'index.php' />">
         <cms:if k_template_name=='hire.php'><img class="grid_logo" alt="Red Heeler Industries" src="<cms:get_custom_field 'hire_logo_image' masterpage='globals.php' />" /></a>
         <cms:else />
         <cms:if k_template_name=='fencing.php'><img class="grid_logo" alt="Red Heeler Industries" src="<cms:get_custom_field 'fencing_logo_image' masterpage='globals.php' />" /></a>
         <cms:else />
         <cms:if k_template_name=='landscaping.php'><img class="grid_logo" alt="Red Heeler Industries" src="<cms:get_custom_field 'ls_logo_image' masterpage='globals.php' />" /></a>
         <cms:else />
         <cms:if k_template_name=='handymen.php'><img class="grid_logo" alt="Red Heeler Industries" src="<cms:get_custom_field 'hm_logo_image' masterpage='globals.php' />" /></a>
         <cms:else />
         <cms:if k_template_name=='lawn.php'><img class="grid_logo" alt="Red Heeler Industries" src="<cms:get_custom_field 'lm_logo_image' masterpage='globals.php' />" /></a>
         <cms:else />
         <img class="grid_logo" alt="Red Heeler Industries" src="<cms:get_custom_field 'logo_image' masterpage='globals.php' />" /></a>
            </cms:if>
         </cms:if>
      </cms:if>
   </cms:if>
</cms:if>

<!-- /* Site Nav2 */ -->
<ul id="navigation" class="grid_9">
   <li><a href="<cms:link 'hire.php' />" <cms:if k_template_name=='hire.php'>class="current"</cms:if> ><br />Hire</a></li>
   <li><a href="<cms:link 'fencing.php' />" <cms:if k_template_name=='fencing.php'>class="current"</cms:if> ><br />Fencing</a></li>
   <li><a href="<cms:link 'landscaping.php' />" <cms:if k_template_name=='landscaping.php'>class="current"</cms:if> ><br />Landscaping</a></li>
   <li><a href="<cms:link 'handymen.php' />" <cms:if k_template_name=='handymen.php'>class="current"</cms:if> ><br />Handymen</a></li>
   <li><a href="<cms:link 'lawn.php' />" <cms:if k_template_name=='lawn.php'>class="current"</cms:if> ><br />Lawn Maintenance</a></li>
   <li><a href="<cms:link 'index.php' />" <cms:if k_template_name=='index.php'>class="current"</cms:if> ><br />Home</a></li>
</ul>

<!-- Navigation Menu -->
<ul id="nav2" class="grid_9">
   <li><a href="<cms:link 'contact.php' />" <cms:if k_template_name=='contact.php'>class="current"</cms:if> ><br />Contact Us</a></li>
   <li><a href="<cms:link 'faq.php' />" <cms:if k_template_name=='faq.php'>class="current"</cms:if> ><br />FAQ</a></li>
   <li><a href="<cms:link 'gallery.php' />" <cms:if k_template_name=='gallery.php'>class="current"</cms:if> ><br />Gallery</a></li>
<!-- <li><a href="<cms:link 'feedback.php' />" <cms:if k_template_name=='feedback.php'>class="current"</cms:if> ><br />Feedback</a></li> -->
   <li><a href="<cms:link 'safety.php' />" <cms:if k_template_name=='safety.php'>class="current"</cms:if> ><br />Safety</a></li>
   <li><a href="<cms:link 'about.php' />" <cms:if k_template_name=='about.php'>class="current"</cms:if> ><br />About Us</a></li>
   <li><a href="<cms:link 'dogtales.php' />" <cms:if k_template_name=='dogtales.php'>class="current"</cms:if> ><br />Dog Tales</a></li>
</ul>


I'm sure there's a better/cleaner way to achieve this and I'd be happy to hear it, but for now it at least works this way.

Cheers, 8-)
Another take on this would be creating an editable inside each template with logo.
Then you will be able to automatically get the right image.
Like
Code: Select all
<cms:set current_template=k_template name />
<cms:templates show_hidden='0' >
   
<cms:if k_template_name=current_template>
<cms:show logo_image />
</cms:if>

</cms:templates>

This is a basic idea, if you get it - you can show anything from your other templates.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
trendoman wrote: Another take on this would be creating an editable inside each template with logo.
Then you will be able to automatically get the right image.
Like
Code: Select all
<cms:set current_template=k_template name />
<cms:templates show_hidden='0' >
   
<cms:if k_template_name=current_template>
<cms:show logo_image />
</cms:if>

</cms:templates>

This is a basic idea, if you get it - you can show anything from your other templates.



Thanks for the reply trendoman, I did look at doing it this way originally but prefer the idea of only having the one file (header.html) to edit.

Cheers, 8-)
4 posts Page 1 of 1