PDA

View Full Version : threadid conditional - Not working the same?


kall
12-27-2009, 06:17 PM
Scenario: I want to display ads on all showthread pages (preferably in postbit), with specific ads for specific threads, and general ads for the rest.

In vB3, this was a matter of using this code wherever the ad was, and it would replace the generic ad with the specified one.

<if condition="$thread['threadid'] == '12345'">Specific Ad for Thread #12345
<else/>
Generic Ad
</if>

Now, using the new syntax below, the threadid condition is never true, no matter what template I stick it in:
<vb:if condition="$thread['threadid'] == '12345'">Specific Ad for Thread #12345
<vb:else/>
Generic Ad
</vb:if>

I've tried $thread['threadid'], $threadinfo['threadid'], $post['threadid'], and all without the '' inside the []. I'm beginning to lose it. Please help.

Lynne
12-27-2009, 06:47 PM
It should be <vb:else /> not <vb:else/> Other than that, I don't see anything wrong.

kall
12-27-2009, 07:11 PM
Ahh.

Thanks Lynne. :)

Should it work in ad_global_below_navbar? If not, what variable am I meant to be checking for if I want to use that template?

Lynne
12-27-2009, 09:07 PM
I really don't know as I never use the ad templates.

kall
12-27-2009, 10:28 PM
OK.. replace that template name with 'navbar' then. :)

Lynne
12-28-2009, 03:52 AM
If you look at the functions.php page where the navbar is rendered, the thread variable is not registered. So, you would have to preregister it if you want to use it there.

kall
12-28-2009, 05:47 AM
Any chance you can help with that?

I can preregister my own custom variables, but preregistering $threadid for use on showthread.php seems to be difficult.

Lynne
12-28-2009, 02:19 PM
I would guess something like this:

vB_Template::preRegister('navbar', array('thread => $thread));

Take a look in the code for where the navbar is rendered and make sure you pick a hook location that is executed before that.

tintin74
03-30-2010, 09:41 AM
Hello, I'm running vb 3.7 and I've used this code to display specific ads for specific thread:

<if condition="$thread['threadid'] == '12345'">Specific Ad for Thread #12345
<else/>
Generic Ad
</if>

but if I use this conditional into the SHOWTHREAD template everything works well.

I need to get work thi conditional into a custom template called by SHOWTHREAD template,

so I've inserted into SHOWTHREAD template this:

$specads

, I've create the "showthread_specads" custom template,

and this plugin:

Product:Vbulletin
Name: showthread_specads
Code:
eval('$specads = "' . fetch_template('showthread_specads') . '";');

My custom template is called normally by showthread but if I insert into it the same conditional I've used for SHOWTHREAD template, the conditional don't work .

I suppose there 's something to change here :

<if condition="$thread['threadid'] == '12345'">Specific Ad for Thread #12345
<else/>
Generic Ad
</if>

but I don't know what.

Does anyone could help me ,please?

ForumsMods
03-30-2010, 12:32 PM
<vb:if condition="$threadinfo['threadid'] == '12345'">
Specific Ad for Thread #12345
<vb:else />
Generic Ad
</vb:if>

tintin74
03-30-2010, 01:36 PM
Hello , vB Style,

I think this sintax <vb:if> </vb:if> works for vb4.0 version.

But the rest is OK!

Thank you very much! :up:

ForumsMods
03-30-2010, 08:14 PM
Yes, this forums is for vB 4, hehe.

prawn_86
08-26-2012, 01:31 AM
I am having the same issue. Have just upgraded to VB4 and am trying to put the following code into the ad_showthread_firstpost template:

<vb:if condition="$thread['threadid'] == 87">
<center>

<b>This thread is brought to you by:</b>
<br>
<center>
<a href="http://..../
" target="_blank">wording here
</a>
</center>
<br>
</vb:if>

Can anyone see what i am doing wrong?

Lynne
08-26-2012, 01:36 AM
Is the $thread variable registered for use in that template? Try using $GLOBALS instead.

prawn_86
08-26-2012, 01:43 AM
Is the $thread variable registered for use in that template? Try using $GLOBALS instead.
Sorry Lynne i am very green at this, do i replace $thread with $GLOBALS and leave the rest?

I have tryied a few different variations on your suggestion but still cannot get it working

--------------- Added 1345954389 at 1345954389 ---------------

Just as a side note, putting the code into the ad_showthread_firstpost_start template works when i replace thread with global.

I still can't figure out how to get it showing between the 1st and 2nd post on each page

malmazan
12-01-2018, 04:47 AM
In case I save somebody the time to do the research:

<vb:if condition="$threadinfo['threadid'] > '1234'">

This worked for me on the SHOWTHREAD template out of the box. I have used for the href tag to to keep the Facebook likes on old threads after going from http to https (SSL)

For CMS articles I used:
<vb:elseif condition="$vbulletin->nodeid < 123" /> on the facebook_likebutton template and the vbcms_content_staticpage_page template if you use static pages)