[Solved]What kind of User Defined Tag do I need?

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
libralion
Forum Members
Forum Members
Posts: 191
Joined: Fri Jul 11, 2008 4:11 pm

[Solved]What kind of User Defined Tag do I need?

Post by libralion »

Hi everybody,
I have a design that has 3 colums; col1, col2(is the center) and col3.
I have 6 pages and I want on all pages a different image in the left sidebar(=col1)
I found that I can do that by making a User defined tag(UDT) and put a code in the template.
But what exactly do I put in that UDT?

Lets say I put the code {random} in the template, where the image should be.
What kind of UDT do I have to make to get different images on for instance the Home, Contactpage?
I assume I have to make a couple of UDT? For every page that has a different image?
I can't figure out what kind of code should be in the UDT. ???
Last edited by libralion on Thu Feb 05, 2009 7:10 pm, edited 1 time in total.
User avatar
tophers
Forum Members
Forum Members
Posts: 218
Joined: Thu Jun 07, 2007 7:25 pm

Re: What kind of User Defined Tag do I need?

Post by tophers »

There's probably an easier solution. Install Calguy's CGSimplySmarty (you may need CGExtensions too, I can never remember). Once installed, add this to your template (right after the tag):

Code: Select all

{$cgsimple->get_root_alias('','root_alias')}
</__body class="{$root_alias}">
Then add something like this to your stylesheet:

Code: Select all

body.home #leftsidebar {background: #fff url(../uploads/images/hdr_home.jpg) no-repeat 0 0; }
body.contact #leftsidebar {background: #fff url(../uploads/images/hdr_contact.jpg) no-repeat 0 0;}
This way your template stays the same, but the unique class on the tag will pull in an image specific to that section.
libralion
Forum Members
Forum Members
Posts: 191
Joined: Fri Jul 11, 2008 4:11 pm

Re: What kind of User Defined Tag do I need?

Post by libralion »

tophers wrote: There's probably an easier solution. Install Calguy's CGSimplySmarty (you may need CGExtensions too, I can never remember). Once installed, add this to your template (right after the tag):

Code: Select all

{$cgsimple->get_root_alias('','root_alias')}
</__body class="{$root_alias}">
Then add something like this to your stylesheet:

Code: Select all

body.home #leftsidebar {background: #fff url(../uploads/images/hdr_home.jpg) no-repeat 0 0; }
body.contact #leftsidebar {background: #fff url(../uploads/images/hdr_contact.jpg) no-repeat 0 0;}
This way your template stays the same, but the unique class on the tag will pull in an image specific to that section.
Hi Tophers,

Thanks, but if I understand your code right, the image will appear as background in the leftsidebar and I just want a normal image to appear there. I also want to put it where I want it, so I think it has to be done with an UDT.
Of course I can make a different template for each page. That will do it too, but there must be an easier way.
Somebody knows how? ???
libralion
Forum Members
Forum Members
Posts: 191
Joined: Fri Jul 11, 2008 4:11 pm

Re: What kind of User Defined Tag do I need?

Post by libralion »

I found this thread, describing what I want: http://forum.cmsmadesimple.org/index.php/topic,24761.0.html

But I don't understand what to put in the code.
This is the code they are speaking off:
I use this in my template {random} where the picture must be.

And I created this "user defined tag"


$page = $_GET["page"];

if($page=="example") {

echo "example";

}

else {

$rand = rand(1, 7);
echo $rand;

}
But how do I modify that? I put the random tag in my template in the col1(=left sidebar) piece.
But how do I modify the above code?
What to put in the "example" bit? And what is the "rand" thing with the 1,7 behind it.
I just don't understand. Can somebody enlighten me? ???
libralion
Forum Members
Forum Members
Posts: 191
Joined: Fri Jul 11, 2008 4:11 pm

Re: What kind of User Defined Tag do I need?

Post by libralion »

Ia there nobody that can help me with this? There must be a lot of people that have the same setup on their website as I have with the 3 colums.
User avatar
tophers
Forum Members
Forum Members
Posts: 218
Joined: Thu Jun 07, 2007 7:25 pm

Re: What kind of User Defined Tag do I need?

Post by tophers »

It might help if we could see a sample of your site. The method I described will work - you can easily shift it to a regular image, rather than a background image, by calling something like this (either in your template, or in a content block):

Code: Select all

<div id="col1">
<img src="uploads/images/sidebars/{$root_alias}.jpg" alt="" width="200" height="600" />
</div>
That would insert an image with the same name as the current section (home, contact, etc) into the div. If this isn't what you're looking for please post a sample page or some more info so we can give you a more specific answer or example. Sometimes this form of communication can be misinterpreted, so be patient - we'll do the best we can to assist you.
libralion
Forum Members
Forum Members
Posts: 191
Joined: Fri Jul 11, 2008 4:11 pm

Re: What kind of User Defined Tag do I need?

Post by libralion »

tophers wrote: It might help if we could see a sample of your site. The method I described will work - you can easily shift it to a regular image, rather than a background image, by calling something like this (either in your template, or in a content block):

Code: Select all

<div id="col1">
<img src="uploads/images/sidebars/{$root_alias}.jpg" alt="" width="200" height="600" />
</div>
That would insert an image with the same name as the current section (home, contact, etc) into the div. If this isn't what you're looking for please post a sample page or some more info so we can give you a more specific answer or example. Sometimes this form of communication can be misinterpreted, so be patient - we'll do the best we can to assist you.
Thanks! ;D Together with your other answer it does work now. :)
Post Reply

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