vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Defining global variables in plugin. (https://vborg.vbsupport.ru/showthread.php?t=137768)

PayBas 01-28-2007 05:02 PM

Defining global variables in plugin.
 
What I need is a plugin that defines global variables, to be used for userprofilefields.


This needs to be done in a way that the variables are loaded in EVERY template. So I think it should be a plugin that uses the "global_start" hook. However I cannot get it working.
Here is an example of what code is present in some of my templates (such as postbit_legacy, memberinfo, search_resultbit etc etc).
Code:

<if condition="$pf_job"><img src="job.gif" /></if>
<if condition="$pf_employee"><img src="employee.gif" /></if>

<if condition="$pf_occu & 1"><img src="/images/1-0.gif" border="0" alt="" /></if>
<if condition="$pf_occu & 2"> <img src="/images/1-1.gif" border="0" alt=""></if>
<if condition="$pf_occu & 4"><img src="/images/2-0.gif" border="0" alt=""></if>
<if condition="$pf_occu & 8"><img src="/images/2-1.gif" border="0" alt=""></if>
<if condition="$pf_occu & 16"><img src="/images/3-0.gif" border="0" alt=""></if>
<if condition="$pf_occu & 32"><img src="/images/3-1.gif" border="0" alt=""></if>

<if condition="$pf_artpref">$pf_artpref</if>

and many more.

What I am looking for is a plugin that defines these variables (such as $pf_occu and $pf_job) as the profilefield ID's.

This is what I have so far:
PHP Code:

<plugin active="1">
<
title>Easy Config</title>
<
hookname>global_start</hookname>

<
phpcode><![CDATA[
$pf_job $post['field14'];
$pf_employee $post['field15'];
$pf_occu $post['field16'];
$pf_artpref $post['field17'];
]]></
phpcode>

</
plugin

Why is this plugin, in combination with the above posted template code, not working?

I don't want to modify the source php files, it HAS to be done in a plugin.

thx in advance.

PayBas 01-30-2007 08:37 PM

there's got to be SOMEONE who knows more about this kind of stuff :confused:

im pretty much stuck here

Paul M 01-30-2007 09:00 PM

There is no such array as $post available to the global_start hook, you would need to use $vbulletin->userinfo['field14'] etc.

PayBas 01-31-2007 01:15 AM

No luck :(

plugin hook: global_start
PHP Code:

$pf_level $vbulletin->userinfo['field8']; 

in templates:
Code:

<if condition="$pf_level">$pf_level</if>
I didn't expect this to work since $vbulletin->userinfo['field8'] is kind of a weird variable to call in a postbit template for example. But what I should do... dono.


All times are GMT. The time now is 01:10 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.01064 seconds
  • Memory Usage 1,721KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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