Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-26-2010, 06:06 AM
Masked Crusader Masked Crusader is offline
 
Join Date: Oct 2005
Location: Sacramento, CA, USA
Posts: 293
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default newthread -- template hooking before message area

Hey all.

I have finally finished my product and am trying to make sure that I am following all of the vBulletin standards prior to release. I have a template that I want to insert prior to the "messagearea" in the "newthread" template.

Here is the code I have thus far:

Code:
$newTemplate = vB_Template::create('qma'); //my custom template
$rendered =  $newTemplate->render(); 

$find = "{vb:raw messagearea}";
$vbulletin->templatecache['newthread'] = str_replace($find, $rendered . "\n" . $find, $vbulletin->templatecache['newthread']);
Now, the templatecache has the correct values and is populated. The issue is what to use for the "find". When I did a "print_r" on the templatecache for the newthread template, it shows the output for the message area part like this:

' . $message . '

So, I tried searching for that as well, and no luck. Of course, there is no pre-defined vBulletin hook in this position, so this is the only way to do it that I know of without doing actual template edits with the newthread template, which I definitely want to stay away from.

Any help on what to use for the "$find" condition would be greatly appreciated!
Reply With Quote
  #2  
Old 12-26-2010, 04:22 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What hook location are you using? And you tried just using $find = $message; ?
Reply With Quote
  #3  
Old 12-26-2010, 06:12 PM
Masked Crusader Masked Crusader is offline
 
Join Date: Oct 2005
Location: Sacramento, CA, USA
Posts: 293
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am trying to put my template ('qma') right before the message area. I want it to look like this:

http://img408.imageshack.us/i/armoryposition.png/

Right now, I actually have the HTML block of code in the 'newthread' template as I cannot figure out how to get it into that position without doing it that way. I tried searching for the message are with the following code:

Code:
global $vbulletin; 

$is_qma_enabled = false;

if($vbulletin->options['qma_onoff'] == 1){
   $forums_enabled = explode(',', $vbulletin->options['qma_forumid']);
   $is_qma_enabled = in_array($vbulletin->GPC['forumid'], $forums_enabled);
}

if($is_qma_enabled == true){
   $show['qma_enabled'] = true;
   $newTemplate = vB_Template::create('qma');

$rendered =  str_replace( "&lt;", "<", $newTemplate->render() ); 

$find = "messagearea";

$vbulletin->templatecache['newthread'] = str_replace("messagearea", "", $vbulletin->templatecache['newthread']);

$vbulletin->templatecache['newthread'] = str_replace("' . $ . '", $rendered, $vbulletin->templatecache['newthread']);
}
It works in finding the area that the template should be put (the 'qma' template also has the 'messagearea' part that I am erasing with the above str_replace), but after trying to I get an PHP runtime error:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/maskedcrusader/includes/class_core.php(4414) : eval()'d code on line 141

It is having a problem with the 'eval' for the template and I cannot seem to find any PHP errors in my code that would cause that error.
Reply With Quote
  #4  
Old 12-26-2010, 07:19 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have you tried commenting out some lines so you can narrow down exactly which one is causing the error? My guess is the last line but best to know for sure before speculating.
Reply With Quote
  #5  
Old 12-26-2010, 09:28 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I always start with something that works and then build from there. This works:
PHP Code:
global $vbulletin;

$find ' . $messagearea . '
$add '."New Text".'
   
    
$vbulletin->templatecache['newthread'] = str_replace
        
$find,
        
$add
        
$vbulletin->templatecache['newthread'
    ); 
Reply With Quote
  #6  
Old 12-27-2010, 12:38 AM
Masked Crusader Masked Crusader is offline
 
Join Date: Oct 2005
Location: Sacramento, CA, USA
Posts: 293
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Alright, I figured out where the problem is occuring, but the question is how the heck to correct it.

On this line of PHP code:

$newTemplate = vB_Template::create('qma');
$add = $newTemplate->render();

The render is causing the issue.

So, when it goes to 'eval' the template, it is causing the issue. Here is what my template code looks like:

HTML Code:
<vb:if condition="$show['qma_enabled']">

<div class="blockrow">
<label class="full">Quick Masked Armory:</label>
<div style="padding-top: 5px;">
<select id="locale" name="char_1_locale" class="primary" style="width: 75px;">
<option value="US">US</option>
<option value="EU">EU</option>
</select>
<input type="text" id="server_1" value="Server Name" name="char_1_server" size="25" class="primary textbox" />
<input type="text" id="char_name_1" value="Character Name" name="char_1_name" size="25" class="primary textbox" />
<a style="cursor: pointer;" onClick="createArmory(document.vbform.char_1_server.value, document.vbform.char_1_name.value, document.vbform.char_1_locale.value, 1);">Create</a>
</div>

<div style="padding-top: 5px; padding-bottom: 10px; display: none; color: orange;" id="char_1_error"></div>
<br/>
<div style="font-size: 11px;">Boxes above are reusable to add as many characters as you want to your post!</div>

<div style="font-size: 11px;">More Masked Armory features available at <a href="http://www.maskedarmory.com" target="_blank">MaskedArmory.com</a>. -- Copyright &copy; 2010</div>

</div>
<div class="blockrow"></div>
</vb:if>
The 'eval' issue hits on this line at the top of the template:

HTML Code:
<div class="blockrow">
Is there something wrong with my HTML or the way vB is evaluating it?
Reply With Quote
  #7  
Old 12-27-2010, 01:24 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you remove the <vb:if> conditional from the template do you still get the error?
Reply With Quote
  #8  
Old 12-27-2010, 01:47 AM
Masked Crusader Masked Crusader is offline
 
Join Date: Oct 2005
Location: Sacramento, CA, USA
Posts: 293
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I got it all fixed. Man, vB4 templating is a pain in the butt!

New question -- is there a guide on how to make template groups for installation with the product? I have a CSS file and two template files that I want to put into a template group that will install with the product hooks.

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

Figured it all out. Have a completed product that installs perfectly!
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 09:15 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.04025 seconds
  • Memory Usage 2,246KB
  • Queries Executed 11 (?)
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
  • (2)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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_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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete