PDA

View Full Version : can't get variable to output?


Mickie D
09-15-2012, 07:23 PM
Hi,

I am having an issue with a variable I want to call.


$adss = "CHECK THIS OUT";

vB_Template::preRegister('navbar',array('adss' => $adss));


Nothing shows up using

{vb:raw adss}

in the navbar template.

To be honest I did this just to test the variable, which I am sure should display??

I really wanted to call a custom code from the database using the forumid, but I guess I should get it outputting first

Thank you for any advice

Regards
Mick

kh99
09-15-2012, 07:38 PM
Your code looks right, but where did you put it? If it's in a plugin using a hook that is called after the navbar is constructed then that might be the problem.

Mickie D
09-15-2012, 07:41 PM
ahhh its in the showthread complete hook.

I wanted to pull data from the database (forum table) and output it in the navbar.

I have unique data for each forum (forum.un_data), I wanted to display this on the navbar?

Would that be possible?

Thank you very much for your help.

Mick

Scanu
09-15-2012, 07:46 PM
showthread_complete is too late

--------------- Added 1347742066 at 1347742066 ---------------

I don't know if it's possible but you can try to use this on navbar

{vb:raw global.forumid} (is it correct Kevin?)

kh99
09-15-2012, 07:53 PM
Yeah, showthread_getinfo looks like a good one, it's after a lot of checks that might send the user somewhere else, but it's before the navbar is made. And you can use $threadinfo['forumid'] to know which forum you're in.

Mickie D
09-15-2012, 08:01 PM
KH99 you are the man!!

Thank you, I am going to try and pull the data from my custom forum info table.

I was thinking something simple like


$adss = $forum['un_data'];

vB_Template::preRegister('navbar',array('adss' => $adss));


But was wondering if I would need to make my table (forum.un_data) preregistered ?

Thanks again Kevin you are a really big help.

Mick

kh99
09-15-2012, 08:10 PM
Oh, I see now, you already have the forum data available. Anyway, I'm not quite sure what you're asking but I think the answer is no, if you use the code you're showing there it should work without registering anything else.

Mickie D
09-15-2012, 08:20 PM
Hi Kevin,

I am trying to pull data onto the navbar from a custom field in the forum table.

I have created a field called un_data

I can enter different data into each forum.un_data.

I will have a go, thanks for your help.

Mick

--------------- Added 1347749920 at 1347749920 ---------------

Hi all,

I have been working on outputting my code.


$results = $vbulletin->db->query_read("SELECT adss FROM ".TABLE_PREFIX."forum WHERE forumid = $forumid");

$adss = $results;

vB_Template::preRegister('navbar',array('adss' => $adss));


The code just outputs
RESOURCE ID 52

Its not taking the data from adss in the database?

thanks again for all the help.

Mick

--------------- Added 1347790989 at 1347790989 ---------------

I got this working!

It has been a long time since I messed with mysql, and you need to do something with the data lol (mysql_fetch_row - etc), it was stuck in a resource and I forgot to add the code to deal with the array.

Thanks
Mick