PDA

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


kall
27 Dec 2009, 19:17
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
27 Dec 2009, 19:47
It should be <vb:else /> not <vb:else/> Other than that, I don't see anything wrong.

kall
27 Dec 2009, 20:11
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
27 Dec 2009, 22:07
I really don't know as I never use the ad templates.

kall
27 Dec 2009, 23:28
OK.. replace that template name with 'navbar' then. :)

Lynne
28 Dec 2009, 04:52
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
28 Dec 2009, 06:47
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
28 Dec 2009, 15:19
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
30 Mar 2010, 11:41
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
30 Mar 2010, 14:32
<vb:if condition="$threadinfo['threadid'] == '12345'">
Specific Ad for Thread #12345
<vb:else />
Generic Ad
</vb:if>

tintin74
30 Mar 2010, 15:36
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
30 Mar 2010, 22:14
Yes, this forums is for vB 4, hehe.

prawn_86
26 Aug 2012, 03:31
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
26 Aug 2012, 03:36
Is the $thread variable registered for use in that template? Try using $GLOBALS instead.

prawn_86
26 Aug 2012, 03:43
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
01 Dec 2018, 05:47
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)