vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   What was the point in making us register variables? (https://vborg.vbsupport.ru/showthread.php?t=231248)

BBR-APBT 12-26-2009 06:02 PM

What was the point in making us register variables?
 
What was the point in making us register variables?

To me it is nothing but a pain in the rear end.

When you want to register a variable to pull in your template you have to register it in every template that is around yours.

For instance I am trying to use
Code:

{vb:raw modcpdir}
I have to register it in my template and preregister 3 other templates to get it to show on the postbit_legacy template and it still don't want to show.

Why should it be that stupid. That is tons of extra code we shouldn't have to type.

I remember when you could just use
Code:

$modcpdir
I don't mind typing
Code:

{vb:raw modcpdir}
But for me to have to type
Code:

    $templater->register('modcpdir', $modcpdir);
and
Code:

vB_Template::preRegister('showthread',array('modcpdir' => $modcpdir));
vB_Template::preRegister('postbit_legacy',array('modcpdir' => $modcpdir));

and so on for each template that wraps around mine.

Just to return $modcpdir is totally insane.

DavidsMods 12-26-2009 08:04 PM

I think the reasons for it is security.

consolegaming 12-26-2009 10:12 PM

Nah as far as I know you don't have to register it for the outer templates. You just pre-register variables when you need to use the variable inside of that template. You don't need to go through it's hierarchy registering it for each parent template.

For example I had to pre-register my custom header template for the 'header' template. Then any custom variables I wanted to use inside my custom template I just registered directly for that. I didn't have to register them for the 'header' template too.

The thing I did find though which seemed senseless to me is that if you register your variables for the same custom template in more than one place for example I registered the code for an avatar in one plugin and the rest of my variables in another plugin. Then I found that I needed to re-register those variables. i.e. I found that because I had called the create/render lines for my template again it had unregistered the variables I had already registered. Now that certainly confused me lol.

gibigbig 12-02-2010 01:07 AM

I preregister them in my global.php file

that way you wont have to add that line to a million files

be warned though, some actions dont include the global.php


All times are GMT. The time now is 09:29 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.01072 seconds
  • Memory Usage 1,716KB
  • 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
  • (5)bbcode_code_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