The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Writing a variable from a php page into a template.
If written code in an external file witch loads at init startup. I use the code for plugins. It loads an external html or php file and then splits the head and body from that file. The body is used in a plugin to any kind of template that and the head is added to the headinclude template {vb:raw head_include}. By doing so I can load every external file (php or html) into a template and create widgets to place them on the screen. Because the head of the external (html/php)file is written to the head include i can also load the css and javascript from the external file.
So this works fine with plugins -> template -> widget PHP Code:
PHP Code:
Is there any way to write a variable from a (cms-)php page to a template using vb:raw? |
#2
|
|||
|
|||
Hmm...seems like it should work. Have you tried two widgets to see if it's really a cms page that's the problem? Maybe it's just the second file you load that has a problem.
Also, what does your preregister() function look like? |
#3
|
|||
|
|||
There are two widget on every page active they work like a charm. The head section of the external files gets copied in the head section of vbulletin like they should.
The preregister function looks like this: PHP Code:
init_startup database_pre_fetch_array database_post_fetch_array friendlyurl_resolve_class fetch_userinfo_query fetch_musername fetch_userinfo global_bootstrap_init_start global_bootstrap_init_complete cache_permissions global_state_check global_bootstrap_complete style_fetch vbcms_phpeval_save_start database_pre_fetch_row database_post_fetch_row vbcms_collection_content_querydata vbcms_phpeval_save_end vbcms_content_querydata vbcms_phpeval_populate_start vbcms_content_populate_start vbcms_content_populate_end tag_fetchbit_complete cache_templates template_register_var parse_templates notices_check_start notifications_list process_templates_complete memberaction_dropdown vbcms_phpeval_populate_end vbcms_layout_querydata vbcms_collection_widget_querydata navbits navbits_complete vbcms_phpeval_populate_start is before parse_templates, I don't understand why the value isn'wriiten to the headinclude template on {vb:raw headinclude} |
#4
|
|||
|
|||
Well, I put a printout in parse_templates and found that it's actually being called twice, and I suppose that the list of hooks in the debug info just shows the latest call or something like that. And the first time it's called before the widget code is evaled, so that's probably the problem. I'm not exactly sure why you had it working for widgets, but I'd guess it's because the timing of the first call to parse_templates depends on what's on the page. I have a couple other test widgets and a php page, so one of them is probably triggering the call before it gets to the test widget I created with your code in it.
So I'm not sure how to get around that - I'm not an html expert, is there any reason the CSS and js has to go in the header? |
#5
|
|||
|
|||
Thanks for your help.
The reason why I want to write the head variables form the include page in to the vbulletin page is the css link. They should officially been written into the head section. Now I worked on a workaround but the php code get's fragile. I found that none of the browsers gives a problem when I write the html-head section of the included into the body of the vbulletin page. It gives a w3c error but that's all. So while it's maybe not the best coding practive I think I'm going to stick with that instead of using fragile and error prone php code. Thank you for your time and patience, |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|