Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Design and Graphics Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-14-2011, 06:53 PM
asdfadrian asdfadrian is offline
 
Join Date: May 2011
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Using Custom Template from FORUMDISPLAY

I am having issues trying to display a modified version of the FORUMDISPLAY style in my custom displayresources style. I then defined the variable named $displayresources. What I am trying to achieve is a custom Forumdisplay for a particular forumid for a particular forum that matches the condition if forumids equaled x.

I have defined the custom template in a variable as below using the Global_Start hook:
Code:
eval('$displayresources = "' . fetch_template('displayresources') . '";');
I proceeded using the condition:
PHP Code:
<if condition="$forumid == 35">
$GLOBALS[displayresources]
<else />
**** Default 
FORUMDISPLAY Coding ****
</if>

$footer
etc
.... 
*Check the displayresources.txt attachment for the "displayresources" custom template.
*Check the FORUMDISPLAY.txt attachment for the FORUMDISPLAY modification.

So to sum things up, I basically took the forum content from forumdisplay and pasted it in my displayresources template, but it doesnt show for some reason.

For further display, you can see the custom forum display not properly showing in this link. Make sure the skin is set to WC3 Night Elf.

Someone please help me.
Attached Files
File Type: txt FORUMDISPLAY.txt (26.4 KB, 14 views)
File Type: txt displayresources.txt (25.4 KB, 10 views)
Reply With Quote
  #2  
Old 05-15-2011, 03:44 AM
asdfadrian asdfadrian is offline
 
Join Date: May 2011
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I found out that I needed to define the forumslist variable, but how? I tested the one below and it shows the forums but, it doesnt use the displayforuim.php variables and conditions.

PHP Code:
$show[forumslist] = true;
eval(
'$displayresources = "' fetch_template('displayresources') . '";'); 
so then I try to include the forumdisplay.php like below:
PHP Code:
require_once("forumdisplay.php");

eval(
'$displayresources = "' fetch_template('displayresources') . '";'
And yet still nothing. Can someone explain why I cant just include the .php file? I resumed and search the forumdisplay.php and found all the includes so then I tried the below as well:
PHP Code:
require_once("forumdisplay.php");
require_once(
'./global.php');
require_once(
DIR '/includes/functions_forumlist.php');
require_once(
DIR '/includes/functions_bigthree.php');
require_once(
DIR '/includes/functions_forumdisplay.php');
require_once(
DIR '/includes/functions_prefix.php');

eval(
'$displayresources = "' fetch_template('displayresources') . '";'
Yet still, it showed nothing.
Reply With Quote
  #3  
Old 05-15-2011, 06:51 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try using hook location forumdisplay_complete instead of global_start, and go back to your original code (except you don't need $GLOBALS[displayresources], just use $displayresources).

A hook location is a place in the code. If you open the file global.php and search for global_start, you can see what a hook location looks like. It basically just inserts the plugin code at that point. The reason global_start didn't work is that it's a location that doesn't have the variables defined that you need, and it's not the right place to include a file like forumdisplay.php (in fact forumdisplay.php includes global.php, so that couldn't really work).

Also, you defined the $show['forumdisplay'] correctly, but if it's just going to be defined as 'true' always, then you don't really need it, you could just remove that condition from the template instead.
Reply With Quote
  #4  
Old 05-15-2011, 07:06 AM
asdfadrian asdfadrian is offline
 
Join Date: May 2011
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wow, after several days of searching and looking up how to use Hooks, I think that it makes sense now. Since the forumdisplay.php includes the globals.php and is not the globals itself, I would have to use the forumdisplay_complete hook.

It works perfectly now! May I ask how exactly I can determine which hook to use in the future? I somewhat understand, but I just dont know entirely how to completely determine. Theres so many hooks.

Also if I wanted to display my customized forumdisplay I would do the condition like below?
PHP Code:
<if condition="in_array($foruminfo['forumid'], array(35,36,12,15))">
</if> 
Also if I wanted to make a customized display, lets say forumbit, I would do the same method except for the hook I would use the forumbit_complete?
Reply With Quote
  #5  
Old 05-15-2011, 10:18 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
May I ask how exactly I can determine which hook to use in the future?
It's possible to guess at a hook location that might work for a given purpose, but I think the only sure way to choose a hook location is to look at the php code, understand a little about what's going on, and find one that's in the place you want. For example, you needed one where the variables on the forumdisplay page had all been set, but before the FORUMDISPLAY template is used (because you need $displayresources defined before that happens). So I looked in forumdisplay.php. In this case it wasn't too hard, there happens to be a hook location right before the FORUMDISPLAY template is fetched and eval()ed. I remember when I started out this seemed counterintuitive because I figured if I wanted my changes to show up near the top of the page, it should be somewhere near the top of the php file, but it doesn't work that way in vb.

Quote:
Also if I wanted to display my customized forumdisplay I would do the condition like below?
I'm not sure what you're asking, but yeah, you could put what you have there in the FORUMDISPLAY template around $displaysources, or you could do something like this in your plugin:

Code:
if (in_array($foruminfo['forumid'], array(35,36,12,15)))
   eval('$displayresources = "' . fetch_template('displayresources') . '";');
else
   $displayresources = '';
Then $displayresources would just be blank in other forums.

Quote:
Also if I wanted to make a customized display, lets say forumbit, I would do the same method except for the hook I would use the forumbit_complete?
What I would do is find where the forumbit templates are used, then look around the code for a convenient hook. You could also guess that forumbit_complete sounds like a likely candidate (assuming there is a hook of that name), find it in the code, and see what's going on around it. I realize this is often difficult for a non-programmer. I see a lot of people posting to ask what hook they should use, which is another good way to do it.

BTW, having an editor or other program that lets you search a set of files (on your local computer) helps immensely. Also, I use this site a lot for PHP reference: http://us2.php.net/tut.php
Reply With Quote
  #6  
Old 05-16-2011, 11:56 PM
asdfadrian asdfadrian is offline
 
Join Date: May 2011
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you that helped a lot!

Also I realized that I can just look at the forumdisplay.php or any .php file and search for the "Eval Hooks" used for different templates
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:29 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.06211 seconds
  • Memory Usage 2,255KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (5)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (2)postbit_attachment
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete