vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Convert template conditional into plugin code (https://vborg.vbsupport.ru/showthread.php?t=207609)

Mark.B 03-07-2009 12:25 PM

Convert template conditional into plugin code
 
Hi

I have the following template conditional, variants upon which I use quite a lot:
Code:

<if condition="!in_array($foruminfo['forumid'], array(1,2,3,4))">
I can work out how to format most conditionals if they are needed in php plugin code rather than in a template. However, I am unsure how to do this for the in_array stuff.

How would I format the above conditional to make it apply to a block of plugin code? (Assuming it's at a hook where $foruminfo is available).

Lynne 03-07-2009 04:00 PM

Actually, that one if pretty much the same in php:

Code:

if (!in_array($foruminfo['forumid'], array(1,2,3,4)))
(Sometimes you need to change $foruminfo to $forum or $thread or $threadinfo, depending. Sometimes you can even just use $forumid instead of $foruminfo['forumid'])

Mark.B 03-07-2009 04:27 PM

Thanks Lynne....I needed that as previously I was using something like
Code:

if ($forum['forumid'] != 1 AND $forum['forumid'] != 2 AND $forum['forumid'] != 3 AND $forum['forumid'] != 4)
Not sure if that's the exact syntax as I've just typed it from memory, I've deleted it now. But you get the idea.

It was working but I felt it was ridiculously long winded, and I had read somewhere it used marginally more resources doing it that way.

Dismounted 03-08-2009 04:46 AM

Quote:

Originally Posted by Mark.B (Post 1762592)
It was working but I felt it was ridiculously long winded, and I had read somewhere it used marginally more resources doing it that way.

The difference would be negligible, unless you're processing a lot of comparisons.


All times are GMT. The time now is 10:26 AM.

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.01046 seconds
  • Memory Usage 1,719KB
  • 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_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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