vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Register new vars in all templates (https://vborg.vbsupport.ru/showthread.php?t=313466)

MAORBARI 08-05-2014 04:48 PM

Register new vars in all templates
 
Hi,
How I register new var in all templates?

And more question:
How i can use php code on settings "Option Code"?
Thank you!

kh99 08-05-2014 07:09 PM

Quote:

Originally Posted by MAORBARI (Post 2509869)
Hi,
How I register new var in all templates?

I'm not sure what you mean, but there isn't really any way to register a variable to all templates. You should register a variable to the template or templates where you want to use it. It *is* possible to use any global variable from any template by using {vb:var GLOBAL.name}, but that's not something you really should be doing.

Scanu 08-05-2014 07:12 PM

1 I think you can't, if you find it's possible then let me know! lol

2 what you put in the option code is sorrunded by double-quotes so to use a variable you can just put this $setting[value] instead if you want to use a function then you will have to close the string in this way
PHP Code:

<b>test</b>: ".explode('-', $setting[value])."continue writing html 

and if you want to use if condition or more advanced code it's more complicated

tbworld 08-05-2014 07:34 PM

Quote:

Originally Posted by MAORBARI (Post 2509869)
Hi,
How I register new var in all templates?

And more question:
How i can use php code on settings "Option Code"?
Thank you!

What does the variable do? We might be able to give you a better suggestion. :)

MAORBARI 08-05-2014 07:37 PM

Thank you,

I need the value of the var to be on all templates.
I know how to register him to one template:
PHP Code:

vB_Template::preRegister('header',array('bit_name' => $var)); 

but I need register him in all templates, how to do it?

Thank you.

cellarius 08-05-2014 08:20 PM

Be more concrete. Why would you need a variable available on every single template? Perhaps there is another way.

MAORBARI 08-05-2014 08:42 PM

Because it a google adsense api code or more image directory, and more..

cellarius 08-05-2014 09:01 PM

Please, if you want us to help you, you really need to be a bit more forthcoming. That sentence does not make much sense and it explains nothing. Why would you need adsense code available in every single template? What would you do with an image directory in every template? Either take the time to exactly explain what you want to do, or don't. You're the one with the question, remember? Don't make us beg to help you - chances are, we won't.

MAORBARI 08-05-2014 10:36 PM

Quote:

Originally Posted by cellarius (Post 2509905)
Please, if you want us to help you, you really need to be a bit more forthcoming. That sentence does not make much sense and it explains nothing. Why would you need adsense code available in every single template? What would you do with an image directory in every template? Either take the time to exactly explain what you want to do, or don't. You're the one with the question, remember? Don't make us beg to help you - chances are, we won't.

I dont know english very much, it is very hard to explain it.
I create new style, i put all my images in other images directory thats called "new_images".
Some images have the old directory that calles "images" (Default vbulletin directory) and the others on "new_images".
So I put a lot of images from "new_images" in many templates.
Now, I open in settings a new setting, and put the name of directory because if I want change the directory name on future, it will be easy. and now I want to use this setting on templates without register each template.

Thank you!

tbworld 08-06-2014 01:04 AM

Your English is fine, and thank you. In the ACP (Admin control Panel) in debug mode (you must be in debug mode), you can create a new ACP "options" setting. If you do not know how to do this, I will try to find you a tutorial. It should be easy enough to search for one.

Create a new setting in ACP options: "acp_imagepath". It will be automatically appended to "$vBulletin->options", you will then be able to access this "acp_imagepath" variable in all your templates.

In your templates:
Code:

  {vb:raw vboptions.acp_imagepath}/  <!-- rest of your path or image -->
In summary: "vboptions" is available to all templates and is already pre-registered, whether it should be is another question. :)

This is only one method of many. It was chosen because it best fits your criteria. :)


All times are GMT. The time now is 10: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.01116 seconds
  • Memory Usage 1,739KB
  • 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
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete