[solved] Display images based on current page?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
360true
Forum Members
Forum Members
Posts: 23
Joined: Fri Jul 18, 2008 6:47 pm

[solved] Display images based on current page?

Post 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
Last edited by 360true on Tue Nov 25, 2008 1:36 am, edited 1 time in total.
alby

Re: Display images based on current page?

Post 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
nhaack

Re: Display images based on current page?

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Display images based on current page?

Post 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}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

Return to “Developers Discussion”