vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   [HOW TO - vB4] Create your own vBulletin page (https://vborg.vbsupport.ru/showthread.php?t=228112)

Dave-ahfb 06-01-2012 03:44 PM

How can we get custom pages to pull a custom child style?

Lynne 06-01-2012 03:48 PM

Quote:

Originally Posted by Dave-ahfb (Post 2335472)
How can we get custom pages to pull a custom child style?

I don't understand what you mean. You want a certain style on your custom page? Then write that in the PHP of your page.

Dave-ahfb 06-01-2012 04:27 PM

Quote:

Originally Posted by Lynne (Post 2335476)
Then write that in the PHP of your page.

I should have thought of that....oh, I did. When I realized that I did not know how, I posted here.

Each forum section on my site uses its own template set, I would like to utilize the different styles in the respected off forum sections.

green widget forum= green widget style= I want to use this style in my green widgets tutorials which are integrated using the methods explained in this thread.

red

blue

yellow

kh99 06-01-2012 05:01 PM

Quote:

Originally Posted by Dave-ahfb (Post 2335495)
Each forum section on my site uses its own template set, I would like to utilize the different styles in the respected off forum sections.


I looked in to this and can't find a really good way to do it. You could create a plugin using hook global_bootstrap_init_start, check for your value of THIS_SCRIPT and call $bootstrap->force_styleid(); (passing it the id of the style you want to use). I know, it seems strange that you shoudl have to have a plugin when you're writing your own script, but the problem is that the style is decided on and loaded all within global.php.

I suppose another method would be to be to copy the code from global.php instead of including it, then you can insert a call to force_styleid(). But then you might have to update your scripts if global.php changes in a later version.

A style can be specified in the parameter "styleid", so you might be able to do something like set $_REQUEST['styleid'] before global.php is included, but I notice that that sets a cookie with that style value, and I'm not sure if that will affect other pages or not.

Dave-ahfb 06-01-2012 05:38 PM

Quote:

Originally Posted by kh99 (Post 2335512)
I looked in to this and can't find a really good way to do it. You could create a plugin using hook global_bootstrap_init_start, check for your value of THIS_SCRIPT and call $bootstrap->force_styleid(); (passing it the id of the style you want to use). I know, it seems strange that you shoudl have to have a plugin when you're writing your own script, but the problem is that the style is decided on and loaded all within global.php.

I suppose another method would be to be to copy the code from global.php instead of including it, then you can insert a call to force_styleid(). But then you might have to update your scripts if global.php changes in a later version.

A style can be specified in the parameter "styleid", so you might be able to do something like set $_REQUEST['styleid'] before global.php is included, but I notice that that sets a cookie with that style value, and I'm not sure if that will affect other pages or not.

Now I am beginning to understand.

I should be able to create globalgreenwidget.php, specify $bootstrap->force_styleid(); and of course change the custom page call to global to globalgreenwidget.php.

The downfall as mentioned above, is having to maually fix this with every upgrade.

cellarius 06-01-2012 05:41 PM

AFAIR, the GET-method will set the style cookie. The best and easiest option really is to go with the plugin, in my opinion. Just have one plugin for all your custom pages, supply them with a unique THIS_SCRIPT or a unique constant of your choice, and switch it.

--------------- Added [DATE]1338576139[/DATE] at [TIME]1338576139[/TIME] ---------------

Our posts crossed. You cannot use $bootstrap->force_styleid() in your own php page. You need to create a plugin, jsut as kh99 explained. Then there's no problem on updates.

Dave-ahfb 06-01-2012 05:47 PM

Can you give me an example?

cellarius 06-01-2012 05:57 PM

Well, it's everything there, really.

In your own page, do something like this:
After "define('THIS_SCRIPT', 'test');", add
PHP Code:

$force_my_style 5

where 5 needs to be replaced with the styleid of the style you want to use on that page.

Then create a plugin at global_bootstrap_init_start
PHP Code:

if ($force_my_style)
{
     
$bootstrap->force_styleid($force_my_style)


Not tested, should work.

Dave-ahfb 06-01-2012 08:13 PM

not working, even tried registering $force_my_style on the custom page, still the parent style

kh99 06-01-2012 08:27 PM

That's my fault - [S]try using hook global_bootstrap_init_complete.[/S]

Sorry...one more time. This time I tested it: use hook global_bootstrap_complete and change the code to:

Code:

global $force_my_style;
if ($force_my_style)
{
    $this->force_styleid($force_my_style);
}


BTW, nice solution, cellarius. Maybe this should be added to the article.


All times are GMT. The time now is 05:44 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02473 seconds
  • Memory Usage 1,747KB
  • 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
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (3)pagenav_pagelinkrel
  • (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