Page 1 of 1

[solved] Display images based on current page?

Posted: Mon Oct 27, 2008 2:57 pm
by 360true
Thanks for all the effort. I rewrote and reposted this query several weeks later and the response was the cleanes ever. Worked like a charm. Thanks Zoorlat!

His/her solution: http://forum.cmsmadesimple.org/index.ph ... icseen#new

- 360true

*****************
Looking to include a header image based upon the current page.

If menu structure is:

Department One
- Page 1.1
- Page 1.2

Department Two
- Page 2.1
- Page 2.2

I'd like to dynamically display one header for Department One and all children, a different Header for Department Two and their kids.

I know I can create a separate template for each department, but looking for a "slicker",  more efficient way.

I am a noob and appreciate any thoughts.
The working site is http://69.13.130.134 and I am looking to replace either a)the entire header image or b) just the Section Category name which currently is a separate text div.

Thanks.
360true

Re: Display images based on current page?

Posted: Mon Oct 27, 2008 4:59 pm
by alby
360true wrote: Department One
- Page 1.1
- Page 1.2

Department Two
- Page 2.1
- Page 2.2

I'd like to dynamically display one header for Department One and all children, a different Header for Department Two and their kids.
Install CGSimpleSmarty and look help for a function that get root of current page and use alias of these for filename.jpg

Alby

Re: Display images based on current page?

Posted: Tue Oct 28, 2008 1:36 pm
by nhaack
You could do it without an extra module I guess. Just use the UDT described here:

http://wiki.cmsmadesimple.org/index.php/Share_your_tags_here#Get_a_page.27s_root_parent.27s_alias

Then, as alby suggested, use this alias for the images name. E.g.

Code: Select all


{get_root_page_alias assign="root_page_alias"}
<img src="{$root_page_alias}.jpg" />

If you want to use the alias as a switch to display more different stuff, you can do something like:

Code: Select all


{get_root_page_alias assign="root_page_alias"}
{if $root_page_alias == "cat1"} my header stuff {/if}
{if $root_page_alias == "cat2"} my other header stuff {/if}

However, if you are just looking to use the root name somewhere in your template, you can alter the UDT to display the name instead of the alias.

Propably a general question, is it better to stick to a module or use more lightweight UDT/Plug-ins?

Best
Nils

Re: Display images based on current page?

Posted: Tue Oct 28, 2008 2:02 pm
by calguy1000
This is simple:

a) use the cgsimplesmarty module
b) in the head part your page template add something like this (after the styhesheet call)

Code: Select all

{$cgsimple->get_root_alias('',$root)}
{literal}
<style type='text/css'>
#header h1 a { background: #385C72 url(uploads/images/{/literal}{$root}{literal}.jpg) no-repeat 0 12px; }
</style>
{/literal}