vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Registering variables via plugin? (https://vborg.vbsupport.ru/showthread.php?t=262868)

HMBeaty 04-29-2011 08:51 PM

Registering variables via plugin?
 
For vBulletin 4+

Not sure if this can be done or not, but is it possible to register variables via a plugin? Or maybe there's something I'm missing in my code. This is the code I'm using atm:
PHP Code:

$fbimg $vbulletin->options['usml_navnet_fbimg'];
$twitterimg $vbulletin->options['usml_navnet_twitterimage'];
$rssimg $vbulletin->options['usml_navnet_rssimage'];
$skypeimg $vbulletin->options['usml_navnet_skypeimage'];
$ytimg $vbulletin->options['usml_navnet_ytimage'];

$template_hook['navtab_end'] .= '
<a target="_blank" href="mysite1.com"><img style="margin:-2px 4px 6px 10px" src="/{vb:raw fbimg}" alt="" /></a>
<a target="_blank" href="mysite2.com"><img style="margin:-2px 4px 0 0" src="/{vb:raw twitterimg}" alt="" /></a>
<a target="_blank" href="mysite3.com"><img style="margin:-2px 4px 9px 0" src="/{vb:raw rssimg}" alt="" /></a>
<a target="_blank" href="mysite4.com"><img style="margin:-2px 4px 0 0" src="/{vb:raw skypeimg}" alt="" /></a>
<a target="_blank" href="mysite5.com"><img style="margin:-2px 4px 4px 0" src="/{vb:raw ytimg}" alt="" /></a>'


But the images aren't showing. The links are there, but no images. So I'm guessing $fbimg, $twitterimg, $rssimg, $skypeimg and $ytimg still need to be registered in order for them to show...

TheLastSuperman 04-29-2011 09:06 PM

<a href="https://vborg.vbsupport.ru/showthread.php?t=228078" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=228078</a>

I thought you figured this out a while back.. I swear that browsed it a while back...

HMBeaty 04-29-2011 09:12 PM

This is something different, but that tutorial is for doing it via php files. I tried adding:
PHP Code:

$templater->register('fbimg'$fbimg); 

to the plugin, but didn't seem to work....

Boofo 04-29-2011 09:31 PM

You need to pre-register the variables in the template you need to use them:

Code:

vB_Template::preRegister('navbar', array(
'fbimg' => $fbimg,
'twitterimg' => $twitterimg,
'rssimg' => $rssimg,
'skypeimg' => $skypeimg,
'ytimg' => $ytimg,
));


Okay, now I'm tired.

HMBeaty 04-29-2011 09:51 PM

Getting the same results as before with:
PHP Code:

$fbimg $vbulletin->options['usml_navnet_fbimg'];
$twitterimg $vbulletin->options['usml_navnet_twitterimage'];
$rssimg $vbulletin->options['usml_navnet_rssimage'];
$skypeimg $vbulletin->options['usml_navnet_skypeimage'];
$ytimg $vbulletin->options['usml_navnet_ytimage'];

$fbimg $templater->render();
$twitterimg $templater->render();
$rssimg $templater->render();
$skypeimg $templater->render();
$ytimg $templater->render();
vB_Template::preRegister('navbar',array(
     
'fbimg' => $fbimg,
     
'twitterimg' => $twitterimg,
     
'rssimg' => $rssimg,
     
'skypeimg' => $skypeimg,
     
'ytimg' => $ytimg
));

$template_hook['navtab_end'] .= '
<a target="_blank" href="mysite1.com"><img style="margin:-2px 4px 6px 10px" src="/{vb:raw fbimg}" alt="" /></a>
<a target="_blank" href="mysite2.com"><img style="margin:-2px 4px 0 0" src="/{vb:raw twitterimg}" alt="" /></a>
<a target="_blank" href="mysite3.com"><img style="margin:-2px 4px 9px 0" src="/{vb:raw rssimg}" alt="" /></a>
<a target="_blank" href="mysite4.com"><img style="margin:-2px 4px 0 0" src="/{vb:raw skypeimg}" alt="" /></a>
<a target="_blank" href="mysite5.com"><img style="margin:-2px 4px 4px 0" src="/{vb:raw ytimg}" alt="" /></a>'


EDIT: Not even entirely sure if:
PHP Code:

$fbimg $templater->render();
$twitterimg $templater->render();
$rssimg $templater->render();
$skypeimg $templater->render();
$ytimg $templater->render(); 

Needs to be in there or not

Boofo 04-29-2011 10:08 PM

No, as you are not rendering any templates, just settings variable. What are in each of those variables?

Okay, I see what you are doing and it is never gonna fly. You're trying to pass an image in the variables, right?

HMBeaty 04-29-2011 10:11 PM

Quote:

Originally Posted by Boofo (Post 2190152)
No, as you are not rendering any templates, just settings variable. What are in each of those variables?

Ok, didn't think so. For example though
PHP Code:

$fbimg 

should be printing out what's in
PHP Code:

$vbulletin->options['usml_navnet_fbimg'

which at the moment is facebook.png, and if I replaced
PHP Code:

src="/{vb:raw fbimg}" 

with
PHP Code:

src="/facebook.png" 

the image shows as it should.

Boofo 04-29-2011 10:11 PM

Try this:

Code:

$template_hook['navtab_end'] .= '
<a target="_blank" href="mysite1.com"><img style="margin:-2px 4px 6px 10px" src="{vb:raw fbimg}" alt="" /></a>
<a target="_blank" href="mysite2.com"><img style="margin:-2px 4px 0 0" src="{vb:raw twitterimg}" alt="" /></a>
<a target="_blank" href="mysite3.com"><img style="margin:-2px 4px 9px 0" src="{vb:raw rssimg}" alt="" /></a>
<a target="_blank" href="mysite4.com"><img style="margin:-2px 4px 0 0" src="{vb:raw skypeimg}" alt="" /></a>
<a target="_blank" href="mysite5.com"><img style="margin:-2px 4px 4px 0" src="{vb:raw ytimg}" alt="" /></a>'

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

Maybe

images/misc/facebook.png

the path relevant to your forums dir. And no / before the raw variable

HMBeaty 04-29-2011 10:17 PM

That didn't work either lol

Lynne 04-29-2011 10:32 PM

No need to (pre)register the variables when you are using them right there in the plugin.

HTML Code:

$template_hook['navtab_end'] .= ' <a target="_blank" href="mysite1.com"><img style="margin:-2px 4px 6px 10px" src="'.$fbimg.'" alt="" /></a>';


All times are GMT. The time now is 10:12 AM.

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.02071 seconds
  • Memory Usage 1,764KB
  • 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
  • (2)bbcode_code_printable
  • (1)bbcode_html_printable
  • (8)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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