vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   [forumid] Being Ignored (https://vborg.vbsupport.ru/showthread.php?t=298408)

mindhunter77 05-23-2013 07:34 PM

[forumid] Being Ignored
 
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
Code:

ob_start();
include('/media/data/vhosts/site.com/htdocs/forum/headings.php');
$cw_h2 = ob_get_contents();
ob_end_clean();

PHP FILE CONTENTS
Code:

<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.

kh99 05-23-2013 10:47 PM

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:

PHP Code:

if ($foo == bar) {echo "something stupid";} 

But you're not inside of the scope of vBulletin, so you can't use vBulletin variables

kh99 05-23-2013 11:38 PM

Quote:

Originally Posted by mindhunter77 (Post 2423811)
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


Code:

<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.


All times are GMT. The time now is 03:09 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00992 seconds
  • Memory Usage 1,732KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete