Compressing templates from 3 to 1 using this {if} for images

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
User avatar
fearmydesign
Power Poster
Power Poster
Posts: 363
Joined: Sun Feb 28, 2010 10:54 pm

Compressing templates from 3 to 1 using this {if} for images

Post by fearmydesign »

In an effort to reduce the amount of templates that I create, I have created this {if} statement which seems to work in order to replace the top header image depending on which page it is on. Its working, but is there an easier/shorter/standard way to accomplish this same effect?

Here is my {if} calling/replacing the image according to the page its on:

Code: Select all

<div id="top-header-container">
     <div id="header-image">
           <img src="{if $page_alias == "house-cleaning-services-maryland"}uploads/images/static-banner/static_top_banner_01.jpg
             {elseif $page_alias == "cleaning-services-laurel-maryland"}uploads/images/static-banner/static_top_banner_02.jpg
             {elseif $page_alias == "house-cleaning-company-maryland"}uploads/images/static-banner/static_top_banner_03.jpg
             {else}uploads/images/static-banner/static_top_banner_01.jpg
           {/if}">
     </div>
</div>
Before this, I was creating 3 or 4 different templates and only replacing the img src file just to accomplish this same thing; to display a different header top image on different pages. Another words, I was creating different templates for each page :-\
I know, I know, but I didn't know how else to accomplish that.

Thank you for any feedback
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Compressing templates from 3 to 1 using this {if} for im

Post by Wishbone »

Another option is to use GBFilePicker in {content_module} mode and allow the user to choose which image they want (or upload another) for any page... Have it default to some image if there is no file selected.
User avatar
fearmydesign
Power Poster
Power Poster
Posts: 363
Joined: Sun Feb 28, 2010 10:54 pm

Re: Compressing templates from 3 to 1 using this {if} for im

Post by fearmydesign »

Wishbone wrote:Another option is to use GBFilePicker in {content_module} mode and allow the user to choose which image they want (or upload another) for any page... Have it default to some image if there is no file selected.
Thank you, I will be sure to look into this option as well.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Compressing templates from 3 to 1 using this {if} for im

Post by Dr.CSS »

You can also use the page image in the Options tab...
User avatar
fearmydesign
Power Poster
Power Poster
Posts: 363
Joined: Sun Feb 28, 2010 10:54 pm

Re: Compressing templates from 3 to 1 using this {if} for im

Post by fearmydesign »

Dr.CSS wrote:You can also use the page image in the Options tab...
Thank you Dr. - my only question (because I have never used this section of the options tab) is; if I select a page image from the options tab, how would it place it on the page inside the div I want it to go into?

Code: Select all

<div id="top-header-container">
     <div id="header-image">
           <img src=" ? " >
     </div>
</div>
Thank you
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am

Re: Compressing templates from 3 to 1 using this {if} for im

Post by applejack »

<img src="{$page_alias}.jpg">

Use a naming convention for your image files i.e. services.jpg
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Compressing templates from 3 to 1 using this {if} for im

Post by Dr.CSS »

Look under extensions > tags for {page_image}...
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Compressing templates from 3 to 1 using this {if} for im

Post by Rolf »

Nothing to do with images though, but the multiple use of one template.
Might be fun to read or get some inspiration :) http://forum.cmsmadesimple.org/viewtopi ... 69#p270969

grtz. Rolf
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
Gregor
Power Poster
Power Poster
Posts: 1874
Joined: Thu Mar 23, 2006 9:25 am

Re: Compressing templates from 3 to 1 using this {if} for im

Post by Gregor »

Rolf wrote:Nothing to do with images though, but the multiple use of one template.
Might be fun to read or get some inspiration :) http://forum.cmsmadesimple.org/viewtopi ... 69#p270969

grtz. Rolf
Nice answer Rolf :)

Gr. Gregor
Post Reply

Return to “Layout and Design (CSS & HTML)”