Page 1 of 1
[Solved]What kind of User Defined Tag do I need?
Posted: Tue Feb 03, 2009 12:03 pm
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.

Re: What kind of User Defined Tag do I need?
Posted: Tue Feb 03, 2009 10:17 pm
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.
Re: What kind of User Defined Tag do I need?
Posted: Wed Feb 04, 2009 6:46 am
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?

Re: What kind of User Defined Tag do I need?
Posted: Wed Feb 04, 2009 10:57 am
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?

Re: What kind of User Defined Tag do I need?
Posted: Thu Feb 05, 2009 12:39 pm
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.
Re: What kind of User Defined Tag do I need?
Posted: Thu Feb 05, 2009 6:04 pm
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.
Re: What kind of User Defined Tag do I need?
Posted: Thu Feb 05, 2009 7:10 pm
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!

Together with your other answer it does work now.
