vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   The most annoying thing about VB ... (https://vborg.vbsupport.ru/showthread.php?t=218612)

Powlo 07-15-2009 03:58 AM

The most annoying thing about VB ...
 
Why is it that some variables are global and some are not? I understand that you may think
that a particular variable will not be used within a certain template but that kind of limits vb's
well know customisability. Well for those that cant write plugins.. like me.

I just want to make the simplest of changes but find that i cant because the variable does not
work within the template i am using. Ive come across this problem time and time again, i
hope there will be a simple solution to this in the near future or at the very least an easy to
follow guide to making a variable global.

Just in case you were wondering wich variable im having an issue with...

i want to use $thread[views] within the postbit_attachment template.

Link14716 07-15-2009 08:10 AM

When a template is called by a function or a class or both, it's in the local scope of that function or class. Variables created outside of that scope aren't usable without using a global call.

My first suggestion is to make a plugin on the hook 'postbit_display_start' containing the following:

PHP Code:

global $thread


Marco van Herwaarden 07-15-2009 11:54 AM

Try $threadinfo.

Powlo 07-15-2009 02:51 PM

Thank you link for your advise about using a plugin but unfortunatly i have no clue where to start with creating a plugin, i can istall them without issue but actually making them is another thing.

Thank you Marco for your suggestion to use $threadinfo but im afraid that didnt work.. i got nothing at all.

This is the point im making.. i apreciate what link said about globals and im sure to a select few that may have made alot of sense but to non coders (with little free time to learn) it makes doing the simplest of thing sometimes very tricky and often costing money to get someone else to do it.

Perhaps sometime in the future there might be a way around this for the elderly members ;)

Gio~Logist 07-15-2009 03:47 PM

Link: That won't work because $thread is already globalized in postbit, just not in postbit attachments.

Also, the variable is indeed $thread and not $threadinfo

Your best bet is globalizing the variable in the post attachments bit hook. postbit_attachment

And from there you can use good old
PHP Code:

global $thread


Powlo 07-15-2009 04:00 PM

hI Giovanni and thankyou for your input.. but... I know.. that you know.. that i know... nothing about writing plugins :erm:

So sadly im still at square one.

Is globalising a variable an easy operation? Can this be used for all variables?


All times are GMT. The time now is 12:41 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.01349 seconds
  • Memory Usage 1,728KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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