PDA

View Full Version : Conditional Templates


cmedic101
07-31-2008, 04:51 AM
Good Day,

I am trying to display a different Header logo in a single forum. Could this be done using the conditionals commands? Would this be done in the forums Display Template?

I tryed using the entry below but it failed to work..

<if condition="($forumid,== 32))"><scr="images/Mustanglogo.jpg"
</if>

any help would be great

Regards,

Cmedic101

MoT3rror
07-31-2008, 06:08 AM
Try

<if condition="THIS_SCRIPT = 'forumdisplay' AND $forumid == 32">
<image scr="images/Mustanglogo.jpg" />
<else />
<image src="linktosecondimage" />
</if>

Dismounted
07-31-2008, 06:53 AM
<if condition="$foruminfo['forumid'] == 32"><img scr="images/Mustanglogo.jpg" border="0" /></if>

cmedic101
07-31-2008, 07:07 AM
Try

<if condition="THIS_SCRIPT = 'forumdisplay' AND $forumid == 32">
<image scr="images/Mustanglogo.jpg" />
<else />
<image src="linktosecondimage" />
</if>

Thanks for the reply... after using the entry I am getting the folowing error

The following error occurred when attempting to evaluate this template:

Parse error: parse error, unexpected '=' in /vb/includes/adminfunctions_template.php(3716) : eval()'d code on line 15

cmedic101
07-31-2008, 07:38 AM
<if condition="$foruminfo['forumid'] == 32"><img scr="images/Mustanglogo.jpg" border="0" /></if>

Thanks for the reply.. After using the above code I can see the image block above the default header logo graphic. I am thinking that maybe I need to do something in the header template to cancel the default logo when this fourm is called on.

any ideas?


thanks for your help

cmedic101

Dismounted
07-31-2008, 07:42 AM
<if condition="$foruminfo['forumid'] == 32"><img scr="images/Mustanglogo.jpg" border="0" /><else />YOUR DEFAULT CODE HERE</if>

cmedic101
07-31-2008, 08:39 AM
<if condition="$foruminfo['forumid'] == 32"><img scr="images/Mustanglogo.jpg" border="0" /><else />YOUR DEFAULT CODE HERE</if>

I tryed the above code in forum display template and I still get the missing graphic box.

should I be putting the code in another tepmplate?


thank you

cmedic101

Opserty
07-31-2008, 09:00 AM
The missing graphics box means its a problem with your HTML not the condition or anything like that. Check the image is there e.t.c.

You have the condition now, so just look into the HTML code and see why it is not working. ;)

cmedic101
07-31-2008, 09:10 AM
The missing graphics box means its a problem with your HTML not the condition or anything like that. Check the image is there e.t.c.

You have the condition now, so just look into the HTML code and see why it is not working. ;)

I checked the graphics and even re-uploaded them to be sure. The are there and working..

when i click properties there is no information avilable regarding an image path

thank you
cmedic101

Opserty
07-31-2008, 09:24 AM
Whats the code you are using? (Copy and paste it from your template)

cmedic101
07-31-2008, 09:49 AM
Whats the code you are using? (Copy and paste it from your template)

Here is my Forum Display

$stylevar[htmldoctype]
<html xmlns="http://www.w3.org/1999/xhtml" dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude
<title>$foruminfo[title_clean]<if condition="$pagenumber>1"> - <phrase 1="$pagenumber">$vbphrase[page_x]</phrase></if> - $vboptions[bbtitle]</title>
<if condition="$show['inlinemod']"><script type="text/javascript" src="clientscript/vbulletin_inlinemod.js?v=$vboptions[simpleversion]"></script></if>
</head>
<body>
<if condition="$foruminfo['forumid'] == 32"><img scr="images/mustanglogo.gif" border="0" /><else />scr="images/storm/misc/stormlogo.gif"</if>
$header$navbar
<if condition="in_array($forumid, array(50,51))"><center><SCRIPT LANGUAGE="JavaScript1.2" src="http://www.codeamber.org/js/hcodea.js">
</script></center>
</P>
</if>

I could not copy the the full template because of restrictions

Dismounted
07-31-2008, 09:53 AM
It should be:
<img src="<if condition="$foruminfo['forumid'] == 32">images/mustanglogo.gif<else />images/storm/misc/stormlogo.gif</if>" border="0" />

Opserty
07-31-2008, 09:58 AM
src not scr

Dismounted
07-31-2008, 10:00 AM
Oops, fixed. Was copied and pasted from cmedic101's template :p.

cmedic101
07-31-2008, 10:07 AM
It should be:
<img src="<if condition="$foruminfo['forumid'] == 32">images/mustanglogo.gif<else />images/storm/misc/stormlogo.gif</if>" border="0" />

src not scr

Thank you so much for your help!

After I placed that entry in Forum display it was showing both header logos.. I move it to the Header template and it works perfect!


Thank you again

Regards,

Cmedic101

cmedic101
08-02-2008, 10:49 AM
Ok... This is working great. Now the next question is how can I have a different graphic for all of my forums by to this command listed below but keep the origional forum home logo in place.

<img src="<if condition="$foruminfo['forumid'] == 32">images/mustanglogo.gif<else />images/storm/misc/stormlogo.gif</if>" border="0" />

thanks in advance

cmedic101

Dismounted
08-02-2008, 11:09 AM
<img src="<if condition="$foruminfo['forumid'] == 32">images/mustanglogo.gif<else /><if condition="$foruminfo['forumid'] == X">images/storm/misc/randomlogo.gif<else />images/storm/misc/stormlogo.gif</if></if>" border="0" />
Basically, keep nesting the conditionals (ugly - I know).

cmedic101
08-02-2008, 12:12 PM
Wow... that worked real well... thanks for your help and very quick reply


Sincerely,

cmedic101:up:

scoyote
08-28-2008, 03:27 AM
OK, can I break in here too?

I want to do the same thing but I can't figure out how to leave the default header/logo in place because I don't know where to find that information.

(I'm not a programmer, I had someone install and load banners etc....)

But, I need to display a different header/logo for one of my forums.

Dismounted
08-28-2008, 07:37 AM
The code caters for that.

scoyote
08-28-2008, 01:08 PM
I'm not sure what you mean?

What code would I need to display a separate logo/header on forum ID=11 and leave the default logo/header on the rest of the forums?

Sorry if I'm not understanding, you're gonna need to dumb it down for me ;-)

--------------- Added 1219985639 at 1219985639 ---------------

How do I make it display a different logo on one page and leave the default on the rest of the pages?

<img src="<if condition="$foruminfo['forumid'] == 11">images/misc/muskiecentral.png

(here is where I get goofed up, if I put the following in there it shows two logos because one is hard coded in there.)

<else />images/misc/headerlogo.png</if>" border="0" />





Since the default is hard coded somewhere.....I can't seem to make this work.

This doesn't work:

<img src="<if condition="$foruminfo['forumid'] == 11">images/misc/muskiecentral.png</if>"

That shows the muskiecentral.png and the headerlogo.png at the same time.

Dismounted
08-29-2008, 07:36 AM
<img src="<if condition="$foruminfo['forumid'] == 11">images/misc/muskiecentral.png<else />images/misc/headerlogo.png</if>" border="0" />

scoyote
08-29-2008, 03:03 PM
Thanks for the reply but that still shows both banners.

https://vborg.vbsupport.ru/external/2008/08/8.jpg

Dismounted
08-30-2008, 05:53 AM
Post your template.

scoyote
08-30-2008, 02:29 PM
This is the FORUM DISPLAY template, is that the one?
I can't post the entire template, it's longer than allowed.

Dismounted
08-31-2008, 05:44 AM
This is the FORUM DISPLAY template, is that the one?
The template where you are using the code...

scoyote
09-08-2008, 02:21 AM
I'm sorry for the delayed response, I was out of town for a week.

That is the problem, I don't know where that is.

I had a programmer do it for me and he has not returned my emails so I'm guessing he's not available so I am trying to figure this out.

Where do you think he MIGHT have put that so it displays on every page?

I'm no programmer......as you can tell ;-)

scoyote
09-09-2008, 07:55 PM
Here is the Header code....possibly it's in here?

<!-- logo -->
<a name="top"></a>

<table border="0" width="$stylevar[outertablewidth]" cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF" <!--background="images/misc/topback.png"-->

<tr>
<td align="$stylevar[left]"><a href="$vboptions[forumhome].php$session[sessionurl_q]"><img src="$stylevar[titleimage]"

border="0" alt="$vboptions[bbtitle]" /></a></td>
<td align="$stylevar[right]" id="header_right_cell">
<if condition="$ad_location['ad_header_logo']">$ad_location[ad_header_logo]<else />&nbsp;</if>
</td>
</tr>
</table>
<!-- /logo -->

<!-- content table -->
$spacer_open

$_phpinclude_output

$ad_location[ad_header_end]

nando99
09-10-2008, 12:39 PM
Just found this thread and figured it a good place to get additional help...

I'm using the following code in template postbit_attachmentthumbnail


<if condition="$forumid != 103">

<img src="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;stc=1&amp;d=$attachment[dateline]" border="0" alt="" style="display:none;"/>
<div style="float:left; display:block; width:111px; height:111px; text-align:center;">
<table cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle" height="111" width="111" style="margin:0px; padding:0px;">
<a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;d=$attachment[dateline]" rel="Lightbox" id="attachment$attachment[attachmentid]"<if condition="$show['newwindow']"> target="_blank"</if>><img class="thumbnail" src="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;stc=1&amp;thumb=1&amp;d=$attachment[thumbnail_dateline]" border="0" alt="Click for a bigger size image." align="middle" style="border: solid 3px #cccccc;"/></a></td></tr></table>
</div>

<else />

<div align="center"><img src="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;stc=1&amp;d=$attachment[dateline]" border="0" alt=""/>
</div>

</if>



You can see a post from forum 103 here: http://www.fatboymagazine.com/showthread.php?t=33215 as you can see its not working - its still showing the thumb. I'd like to show thumbnails for attached images on most forums, but on a specific forum (id 103) I'd like to show the full attached image.

I tried both <if condition="$forumid != 103"> and <if condition="!in_array($forumid, array(103))"> and neither worked.

Anyone have any ideas?

scoyote
09-15-2008, 01:15 AM
Any help....anyone?
I'm still trying to get more than one banner showing.

Dismounted
09-15-2008, 05:37 AM
@scoyote:
<!-- logo -->
<a name="top"></a>

<table border="0" width="$stylevar[outertablewidth]" cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF" <!--background="images/misc/topback.png"-->

<tr>
<td align="$stylevar[left]"><a href="$vboptions[forumhome].php$session[sessionurl_q]"><img src="<if condition="$foruminfo['forumid'] == 11">images/misc/muskiecentral.png<else />$stylevar[titleimage]</if>" border="0" alt="$vboptions[bbtitle]" /></a></td>
<td align="$stylevar[right]" id="header_right_cell">
<if condition="$ad_location['ad_header_logo']">$ad_location[ad_header_logo]<else />&nbsp;</if>
</td>
</tr>
</table>
<!-- /logo -->

<!-- content table -->
$spacer_open

$_phpinclude_output

$ad_location[ad_header_end]
@nando99: The forum ID variable actually doesn't exist at the point where the template is called. You would have to create a plugin and bring $forum into focus.

scoyote
09-15-2008, 11:49 AM
Sigh......I'm not really sure what you just said.

I'm guessing that something is wrong with the way my logo is being called and I cannot show a different logo on one of the forums?

Dismounted
09-15-2008, 12:43 PM
I just posted an edited version of your header template. Disregard what I'm saying to nando99.

nando99
09-15-2008, 02:39 PM
@nando99: The forum ID variable actually doesn't exist at the point where the template is called. You would have to create a plugin and bring $forum into focus.

Yeah... I had to use $GLOBALS[forumid] and it worked fine. Thanks.

scoyote
09-15-2008, 08:00 PM
Dismounted.....thank you very much.
That is working perfectly.....!

I almost hate to ask this question....but....

Now, if I want to add another logo for forum ID 9

Do I need to enter that whole line again or add a comma and the other forum id????

if condition="$foruminfo['forumid'] == 11">images/misc/muskiecentral.png,
if condition="$foruminfo['forumid'] == 9">images/misc/ftm.png
<else />$stylevar[titleimage]</if>

Does it work like that?

Dismounted
09-16-2008, 04:59 AM
<!-- logo -->
<a name="top"></a>

<table border="0" width="$stylevar[outertablewidth]" cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF" <!--background="images/misc/topback.png"-->

<tr>
<td align="$stylevar[left]"><a href="$vboptions[forumhome].php$session[sessionurl_q]"><img src="<if condition="$foruminfo['forumid'] == 11">images/misc/muskiecentral.png<else /><if condition="$foruminfo['forumid'] == 9">images/misc/ftm.png<else />$stylevar[titleimage]</if></if>" border="0" alt="$vboptions[bbtitle]" /></a></td>
<td align="$stylevar[right]" id="header_right_cell">
<if condition="$ad_location['ad_header_logo']">$ad_location[ad_header_logo]<else />&nbsp;</if>
</td>
</tr>
</table>
<!-- /logo -->

<!-- content table -->
$spacer_open

$_phpinclude_output

$ad_location[ad_header_end]

scoyote
01-29-2009, 02:28 PM
OK....just never satisfied I guess ;-)

Now, my customer wants that logo to be linked to his website so he can click it to go directly there.

Can that logo be linked?

If so....can someone give me an example or is it just normal HTML code?

Lynne
01-29-2009, 02:47 PM
Making a logo clickable is basic html - the basic structure:

<a href="whatever.php"><img src="logo.jpg"></a>

scoyote
01-29-2009, 03:58 PM
Then I'm doing it wrong?

I tried that and it didn't work for me.

Here is where I'm trying to do it:

<img src="<if condition="$foruminfo['forumid'] == 11">images/misc/muskiecentral.png<else /><if condition="$foruminfo['forumid'] == 9">images/misc/ftm.png<else />

So...where do you put that code inside there?

Dismounted
01-30-2009, 03:46 AM
Before it, put:
<a href="whatever.php">
After it, put:
</a>

scoyote
01-30-2009, 01:12 PM
OK, you are dealing with a computer dummy.

Is this what you mean?

<img src="<if condition="$foruminfo['forumid'] == 11">
<a href="http://www.muskiecentral.com">images/misc/muskiecentral.png</a>

<else /><if condition="$foruminfo['forumid'] == 9">
<a href="http://www.fishingthemidwest.com">images/misc/ftm.png</a>

<else />

Dismounted
01-31-2009, 02:25 AM
There's more code than that, it looks like you've chopped off the end...

scoyote
01-31-2009, 02:35 AM
Yes, there is more code, I cut that out of the middle.

Here is the complete code, it's what you helped me with before ;-)

And...thanks for the help again.....it is very much appreciated.

-----------------------code below----------------------------------------

<!-- logo -->
<a name="top"></a>

<table border="0" width="$stylevar[outertablewidth]" cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF" <!--background="images/misc/topback.png"-->

<tr>
<td align="$stylevar[left]"><a href="$vboptions[forumhome].php$session[sessionurl_q]"><img src="<if condition="$foruminfo['forumid'] == 11">images/misc/muskiecentral.png<else /><if condition="$foruminfo['forumid'] == 9">images/misc/ftm.png<else />$stylevar[titleimage]</if></if>" border="0" alt="$vboptions[bbtitle]" /></a></td>
<td align="$stylevar[right]" id="header_right_cell">
<if condition="$ad_location['ad_header_logo']">$ad_location[ad_header_logo]<else />&nbsp;</if>
</td>
</tr>
</table>
<!-- /logo -->

<!-- content table -->
$spacer_open

$_phpinclude_output

$ad_location[ad_header_end]

Dismounted
01-31-2009, 03:06 AM
Find this:
<a href="$vboptions[forumhome].php$session[sessionurl_q]">
And change the URL to whatever.

scoyote
01-31-2009, 03:34 AM
Please excuse me if I'm asking dumb questions, but wont' that make all the logos go to one URL?

I'm trying to make each logo to to a specific URL.

I'm displaying 3 logos and each of them on different forums.

The main logo is no problem, I don't need it to go anywhere since that is already where they are.

But, I want to click the on the Muskie Central logo (images/misc/muskiecentral.png) to go to the Muskie Central website and click the Fishing The Midwest logo (images/misc/ftm.png) so it goes to that website.

Is that possible?

Dismounted
01-31-2009, 04:45 AM
Find:
<a href="$vboptions[forumhome].php$session[sessionurl_q]"><img src="<if condition="$foruminfo['forumid'] == 11">images/misc/muskiecentral.png<else /><if condition="$foruminfo['forumid'] == 9">images/misc/ftm.png<else />$stylevar[titleimage]</if></if>" border="0" alt="$vboptions[bbtitle]" /></a>
Replace With:
<if condition="$foruminfo['forumid'] == 11">
<a href="MUSIECENTRAL"><img src="images/misc/muskiecentral.png" border="0" alt="$vboptions[bbtitle]" />
<else /><if condition="$foruminfo['forumid'] == 9">
<a href="FTM"><img src="images/misc/ftm.png" border="0" alt="$vboptions[bbtitle]" />
<else />
<a href="$vboptions[forumhome].php$session[sessionurl_q]"><img src="$stylevar[titleimage]" border="0" alt="$vboptions[bbtitle]" />
</if></if></a>

scoyote
02-03-2009, 12:44 AM
Thanks! That works perfectly.

It still amazes me that people are willing to take time out of their day to help total strangers for free.

Thank you very much....all of you

It is appreciated.

BRotondi
03-30-2010, 11:23 AM
Thanks for this thread here!

Is there a possibility to check an array of forum IDs? e.g.
<if condition="$foruminfo['forumid'] IN (4,7,9)">It would be a great help too, if I could check not the forumid but the first breadcrumb (since I want different logos not for every subforum).

Possible?

Thanks for your help!
Bruno

Edit 1:
Just found this one (Vbulletin Conditionals (http://www.vbulletin.com/forum/showthread.php?t=200894))
<if condition="in_array($bbuserinfo[userid], array(X,Y,Z))">... should work also here...

Edit 2:
For vB4 this solution does not work any more... I started a new thread:https://vborg.vbsupport.ru/external/2010/03/2.gif Different Logo for different Forums? (Solution for 3.8 does not work any more) (https://vborg.vbsupport.ru/showthread.php?t=239407)

kjsmith84
05-20-2010, 04:28 PM
ok I used the code but am wanting the logo to be in more then one forum ID.

there a possibility to check an array of forum IDs?

I have 6 different logos that each one has about 50 subforums each one needs to go in.


<!-- logo -->


<a name="top"></a>
<table border="0" height="118" width="$stylevar[outertablewidth]" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="$stylevar[left]"><a href="http://www.mysite.com/">
<img src="
<if condition="$foruminfo['forumid'] == 1,?,?,?,?,?">images/evid_blue/gradients/SXS411.PNG<else />
<if condition="$foruminfo['forumid'] == 2,?,?,?,?">images/evid_blue/gradients/Teryx411.PNG<else />
<if condition="$foruminfo['forumid'] == 3,?,?,?,?">images/evid_blue/gradients/RZR411.PNG<else />
<if condition="$foruminfo['forumid'] == 4,?,?,?,?">images/evid_blue/gradients/Prowler411.PNG<else />
<if condition="$foruminfo['forumid'] == 5,?,?,?,?">images/evid_blue/gradients/Commander411.PNG<else />
<if condition="$foruminfo['forumid'] == 6,?,?,?,?">images/evid_blue/gradients/BigRed411.PNG<else />
$stylevar[titleimage]</if></if>" border="0" alt="$vboptions[bbtitle]" /></a></td>

BRotondi
05-20-2010, 05:32 PM
? Seen the last post before yours ? ;)

kjsmith84
05-20-2010, 07:38 PM
? Seen the last post before yours ? ;)

tried that and it didnt work.

tried it again and seems to work now- must have missed something

<if condition="in_array($foruminfo['forumid'], array(110,149,150))">images/evid_blue/gradients/SXS411.PNG<else />

BRotondi
05-20-2010, 08:33 PM
He he. It also happens often to me: Try, try, try... ask... then it works and I never get, what went wrong before :).

Nice it works now!

carolc
02-02-2012, 02:45 PM
Glad I found this thread as it should get me part of the way there.

How can I show a different logo based on the date? (kind of like what Google does on holidays). So if the date = July 4th show one banner, else if the month = October show another banner, etc. I don't want to hardcode the years, though, since I'd like this code to work year after year. Is this too resource intensive?

Also a general php question for those who also know C/C++/C#... does php have Case statements?

Thanks

kh99
02-02-2012, 03:01 PM
Glad I found this thread as it should get me part of the way there.

How can I show a different logo based on the date? (kind of like what Google does on holidays). So if the date = July 4th show one banner, else if the month = October show another banner, etc. I don't want to hardcode the years, though, since I'd like this code to work year after year. Is this too resource intensive?


I don't think an 'if' on the date would be resource-intensive. But I don't believe there's a variable that includes just the date, and you are limited in which php functions you can call in a condition (https://www.vbulletin.com/docs/html/main/functions_in_conditionals), so you'd probably need a plugin.

Also a general php question for those who also know C/C++/C#... does php have Case statements?


Yes, it's called switch. http://us2.php.net/manual/en/control-structures.switch.php

carolc
02-02-2012, 04:22 PM
I don't think an 'if' on the date would be resource-intensive. But I don't believe there's a variable that includes just the date, and you are limited in which php functions you can call in a condition (https://www.vbulletin.com/docs/html/main/functions_in_conditionals), so you'd probably need a plugin.

Thank you, I will go do some research on writing plugins. Would you know what hook location I might need to use? I'm sure having that as a keyword will help me get better search results.


Yes, it's called switch. http://us2.php.net/manual/en/control-structures.switch.php

Awesome... It's nice to see something familiar (as I struggle to learn php). Could switch/case have been used for some of the earlier examples in this thread (if they wanted more if/else conditions) or can it not be used in templates?

kh99
02-02-2012, 04:46 PM
Thank you, I will go do some research on writing plugins. Would you know what hook location I might need to use? I'm sure having that as a keyword will help me get better search results.

If the logo is in the header template then you probably want to use the parse_templates hook. The best thing to do when deciding on a hook is to look in the code. It helps to have the code on your location computer and set it up so that you can search across all files. Then you can search for a hook location, for instance, and look to see what can be dome at that location and which variables are available.


Awesome... It's nice to see something familiar (as I struggle to learn php). Could switch/case have been used for some of the earlier examples in this thread (if they wanted more if/else conditions) or can it not be used in templates?

You pretty much only have 'if' available in a template.