vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Plugin Help Please (https://vborg.vbsupport.ru/showthread.php?t=247783)

TheSupportForum 08-02-2010 06:27 AM

Plugin Help Please
 
please can someone provide support with the plugin system

i wish to add a template condition in the header using $find, the code i iwsh to insert is

Code:


<vb:if condition="$vboptions['ie6fix_onoff']">
{vb:rawphrase ie6fix_english}
</vb:if>

i would like this template condition to be placed before

Code:

<div class="above_body"> <!-- closing tag is in template navbar -->
in the header template

Lynne 08-02-2010 02:25 PM

You will need to do your condition first. Then spit the results into a variable, like $add_before. Then do something like this:

PHP Code:

$find '<div class="above_body">';
$output str_replace($find,$add_before.$find$output); 

If you do a search on str_replace here, or in google, you'll find several examples or how to use that.

TheSupportForum 08-02-2010 03:46 PM

this is how far i have got and hope it worked, but i have done something wrong but dont now where

Code:

if ($vbulletin->options['ie6fix_onoff']){
$ie6fix = '<vb:if condition="$vboptions['ie6fix_onoff']">
{vb:rawphrase ie6fix_english}
</vb:if>';
$find = '<div class="above_body">';
$add_before = "$ie6fix". PHP_EOL;
$output = str_replace($find,$add_before.$find, $output);
}

i get this message

Parse error: syntax error, unexpected T_STRING in /home/ereptalk/public_html/includes/functions.php(6851) : eval()'d code on line 8

i know its my plugin but dont understand where it is wrong

Lynne 08-03-2010 03:45 AM

If you are testing for whether the option is true already, then why are you wanting to test it again in the template? You should only need to test it in the plugin. And $output was just my example of a variable name, you probably want to use $vbulletin->templatecache['templatename'] instead.

TheSupportForum 08-03-2010 05:25 AM

Quote:

Originally Posted by Lynne (Post 2078417)
If you are testing for whether the option is true already, then why are you wanting to test it again in the template? You should only need to test it in the plugin. And $output was just my example of a variable name, you probably want to use $vbulletin->templatecache['templatename'] instead.

i dont understand, what do u mean

Boofo 08-03-2010 07:12 AM

This:

Code:

$add_before = "$ie6fix". PHP_EOL;

should be:

Code:

$add_before = '"$ie6fix". PHP_EOL';

TheSupportForum 08-03-2010 10:09 AM

Quote:

Originally Posted by Boofo (Post 2078466)
This:

Code:

$add_before = "$ie6fix". PHP_EOL;

should be:

Code:

$add_before = '"$ie6fix". PHP_EOL';

i still get this message
Parse error: syntax error, unexpected T_STRING in /home/ereptalk/public_html/includes/functions.php(6851) : eval()'d code on line 8


what i want to try do is create a customer template then insert this template into the headr do you know how to do that ?

Boofo 08-03-2010 10:40 AM

raw phrases don't work with str_replaces like it did in vb 3. It would have to be done a whole different way.

TheSupportForum 08-03-2010 12:14 PM

Quote:

Originally Posted by Boofo (Post 2078516)
raw phrases don't work with str_replaces like it did in vb 3. It would have to be done a whole different way.

what i really need to do is now use an existing template in another template
i would like to call the template inside another

Boofo 08-03-2010 12:16 PM

You would have to preregister the template you wanted to call.

Lynne 08-03-2010 03:06 PM

Quote:

Originally Posted by simonhind (Post 2078443)
i dont understand, what do u mean

You have the condition in here twice:
Code:

if ($vbulletin->options['ie6fix_onoff']){
$ie6fix = '<vb:if condition="$vboptions['ie6fix_onoff']">
{vb:rawphrase ie6fix_english}
</vb:if>';
$find = '<div class="above_body">';
$add_before = "$ie6fix". PHP_EOL;
$output = str_replace($find,$add_before.$find, $output);
}

You only need it once and $output needs to be replaced with the template name (something like below, but enter the templatename):
Code:

if ($vbulletin->options['ie6fix_onoff']){
$ie6fix = '$vbphrase[ie6fix_english]';
$find = '<div class="above_body">';
$add_before = "$ie6fix". PHP_EOL;
$vbulletin->templatecache['templatename'] = str_replace($find,$add_before.$find, $vbulletin->templatecache['templatename']);
}


TheSupportForum 08-03-2010 03:34 PM

Quote:

Originally Posted by Lynne (Post 2078605)
You have the condition in here twice:
Code:

if ($vbulletin->options['ie6fix_onoff']){
$ie6fix = '<vb:if condition="$vboptions['ie6fix_onoff']">
{vb:rawphrase ie6fix_english}
</vb:if>';
$find = '<div class="above_body">';
$add_before = "$ie6fix". PHP_EOL;
$output = str_replace($find,$add_before.$find, $output);
}

You only need it once and $output needs to be replaced with the template name (something like below, but enter the templatename):
Code:

if ($vbulletin->options['ie6fix_onoff']){
$ie6fix = '$vbphrase[ie6fix_english]';
$find = '<div class="above_body">';
$add_before = "$ie6fix". PHP_EOL;
$vbulletin->templatecache['templatename'] = str_replace($find,$add_before.$find, $vbulletin->templatecache['templatename']);
}




thank so far so good, however its not showing yet, my mistake i hope

i am using global_start hook in the plugin, i may have this wrong please help

Lynne 08-03-2010 10:31 PM

If something isn't working, then you need to post the exact code you are using (and the exact hook location).


All times are GMT. The time now is 10:50 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.01191 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
  • (11)bbcode_code_printable
  • (1)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (13)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete