View Full Version : [forumid] Being Ignored
mindhunter77
05-23-2013, 07:34 PM
I'm new to this so I apologize ahead of time.
I'm trying to make a simple plugin that will just display some text based on forum id.
The plugin is almost working, but it seems that [forumid] is being ignored as it is showing across all forums, not just the forum that is listed.
Plugin Code
ob_start();
include('/media/data/vhosts/site.com/htdocs/forum/headings.php');
$cw_h2 = ob_get_contents();
ob_end_clean();
PHP FILE CONTENTS
<if condition='$thread[forumid] == 237'><div align="center"><h2>Some Text</h2></div></if>
It displays when I reference $cw_h2 in a template, but problem is it displays in all forums, not just forum 237.
I'm confused by what you posted - the second one says "php file contents" but it looks like a template. If it's not a template then you can't use <if condition=...
mindhunter77
05-23-2013, 11:28 PM
Well it's if condition not if contents=
I'm new at this so probably wrong, but the idea is just to display something on forumdisplay page.
Zachery
05-23-2013, 11:31 PM
Those are vb template if conditionals that can't be used in your PHP file.
Your PHP FILE is executed AS IS (outside of vBulletin's everything) and its output is assigned to your variable.
You don't even need a plugin for this, just plop your code into the header template. I'd change $thread to $GLOBALS though instead.
If you were going to do it in php, you'd need to do a bunch of stuff to get into vBulletin, and then you'd have to do some php:
if ($foo == bar) {echo "something stupid";}
But you're not inside of the scope of vBulletin, so you can't use vBulletin variables
Well it's if condition not if contents=
lol, you're right of course, my brain was somewhere else...
Anyway, I see now what you meant - the php file you're refering to is headings.php. As Zachery explained, you don't need the plugin, you just need to put that code in the template.
Zachery
05-23-2013, 11:46 PM
To be more clear, plop this into your header template
<if condition="$GLOBALS[forumid] == 237">
<div align="center">
<h2>Some Text</h2>
</div>
</if>
mindhunter77
05-24-2013, 04:42 PM
Yea, I was using this opportunity to see how small mods are made, but your right, I'll just stick it right in the template. I'm just concerned which way to do it would be better, as there are going to be about thirty of them lol
Simon Lloyd
05-24-2013, 05:17 PM
You could use this https://vborg.vbsupport.ru/showthread.php?t=286403 and just expand it to as many boxes (and variables) as you need, you can put all of Zacherys' code in the boxes and have it displayed wherever you put the variables :)
mindhunter77
05-24-2013, 05:22 PM
Actually I may play around with that, thanks.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.