different bg image image for any section

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
akronim

different bg image image for any section

Post by akronim »

hi i need a little help

i want to have a different image for avery section of the site ( i.e. for any first level  in the hierarchy)
i'm using ellnav+L menu

i've defined a tag i called bgpage that i use to change the background stile in the ellnav template 

Code: Select all

<div id="page" {bgpage}>
$p=$_GET['page'];

switch ($p) {

case La_compagnia:
echo "style=" background: #fff url(banner/08.jpg) no-repeat 200px 80px; " ";
break;

default  :
echo "style=" background: #fff url(banner/02.jpg) no-repeat 200px 80px; " ";
}
but this dont fits well to my needs, cause avery page have a different name (?alias?).

i need to know and to use the variable that  the breadcrumbs tag uses to get and generate the first level of the adress


any help??
Dan

Re: different bg image image for any section

Post by Dan »

I placed the below code into a user defined tag, and then referenced it in my template {the_name_of_my_userdefinedtag}. what it does is take the "name" of a page and determines what HTML gets writen in order to control images, nav on states, etc. once you have the name of the page, the if, elseif and else statement can control enything in the template. it saved me from having 10 versions of the nav (I needed an on state when the user was on a particular page, and to insert some javascript on the homepage only). Being able to do this saved me a ton of time.
-----------------------------------------------------------

global $gCms;
$thispage = '';
$thispage = $gCms->variables['page_name'];

if ($thispage == the_name_of_one_of_your_pages)  echo "something_you'd_like_written_to_this_page";

elseif  ($thispage == the_name_of_another_one_of_your_pages) echo "something_else_you'd_like_written_to_this_page";

else echo "something_you'd_like_written_as_your_default";
jelle

Re: different bg image image for any section

Post by jelle »

hey, this is the third spot you placed this post... are  there any more. Pimping your code a bit is ok, but wouldn't this be more efficient with a link?
Dan

Re: different bg image image for any section

Post by Dan »

jelle wrote: hey, this is the third spot you placed this post... are  there any more. Pimping your code a bit is ok, but wouldn't this be more efficient with a link?
Sorry if you see it as pimping--I won't post anything helpful here going forward. I had been looking for an example like this in the forum for a little while. Once I figured it out, I thought it might help some other people (i.e. I couldn't have been the only person looking for an example like this). Again, my apologies.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: different bg image image for any section

Post by calguy1000 »

Jette may have been a bit forward, your code is a great example of how to do things, just pleaase don't copy and paste it in lots of places.  Post it once, and if required link to it in other places.

we need all of the contributions we can get, please don't stop.
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.
jelle

Re: different bg image image for any section

Post by jelle »

@Calguy1000: are you a bit upset I omitted the '1000' in your name? :)
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: different bg image image for any section

Post by calguy1000 »

no, not at all :)
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 “Tips and Tricks”