PDA

View Full Version : Adding/accessing a forum database field


weinstoc
10-19-2007, 12:58 AM
I'm new to VBulletin programming. I've been searching through what documentation I could find, but a lot of it is cryptic to me (probably because I don't understand the programming structure of VBulletin).

I would like to add a field to the forum database (say "X") and be able to access $foruminfo[X] in a conditional such (i.e., <if condition="$forum[X] == Something">
Do something
</if>

Can someone walk me through the best way to accomplish this?

Thanks,

Chuck

Eikinskjaldi
10-19-2007, 06:06 AM
I'm new to VBulletin programming. I've been searching through what documentation I could find, but a lot of it is cryptic to me (probably because I don't understand the programming structure of VBulletin).

I would like to add a field to the forum database (say "X") and be able to access $foruminfo[X] in a conditional such (i.e., <if condition="$forum[X] == Something">
Do something
</if>

Can someone walk me through the best way to accomplish this?

Thanks,

Chuck

You will have to alter the forum table with a mysql command

alter table forum add column column definition

the new field will be available in $foruminfo, which itself is set when you call global.php

Of course populating said field is another matter entirely.

I am not a big fan of modifying core vb tables. I always set up a second table in my own db which keys on forumid (or whatever key is appropriate), then store/fetch to that table as needed.

weinstoc
10-19-2007, 10:13 AM
Thanks. I actually tried that before I posted my question but putting $foruminfo[x] in the header text did not yield the populated value. Are other changes necessary?

I would prefer to create my own table but have no idea how to access the values from within the header text.

Thanks again,

Chuck

Eikinskjaldi
10-19-2007, 10:41 PM
Thanks. I actually tried that before I posted my question but putting $foruminfo[x] in the header text did not yield the populated value. Are other changes necessary?

I would prefer to create my own table but have no idea how to access the values from within the header text.

Thanks again,

Chuck

Did you try $foruminfo[field you know exists]


at any rate, $foruminfo needs to be scoped (a global$foruminfo) before the call to the template, and you have to use the correct syntax in the template, which may involve playing around with what is quoted.

weinstoc
10-20-2007, 12:56 AM
Did you try $foruminfo[field you know exists]


at any rate, $foruminfo needs to be scoped (a global$foruminfo) before the call to the template, and you have to use the correct syntax in the template, which may involve playing around with what is quoted.

Yes, I did. If I put $foruminfo[title_clean] for instance, it prints the title on the page. So I assume the globals $foruminfo must be there. But when I do $foruminfo[X] I get nothing.

Thanks for your help.

Best,

Chuck

weinstoc
10-21-2007, 02:42 AM
More information: if I force $usecache to false in fetch_foruminfo $foruminfo[X] exists. If I let it remain true $foruminfo[X] does not exist.

I'm not sure what this means though.

--------------- Added 1192938289 at 1192938289 ---------------

Immediately after typing the above I put together the name "forumcache" with the fact that one has to save the display order after an import. When I did that it cached the field and now I have what I need. I'm sorry for the wasted bandwidth.