View Full Version : Plugin Help Please
TheSupportForum
08-02-2010, 06:27 AM
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
<vb:if condition="$vboptions['ie6fix_onoff']">
{vb:rawphrase ie6fix_english}
</vb:if>
i would like this template condition to be placed before
<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:
$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
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
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:
$add_before = "$ie6fix". PHP_EOL;
should be:
$add_before = '"$ie6fix". PHP_EOL';
TheSupportForum
08-03-2010, 10:09 AM
This:
$add_before = "$ie6fix". PHP_EOL;
should be:
$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
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
i dont understand, what do u mean
You have the condition in here twice:
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):
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
You have the condition in here twice:
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):
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).
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.