Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-19-2007, 06:12 AM
BamaStangGuy's Avatar
BamaStangGuy BamaStangGuy is offline
 
Join Date: Mar 2004
Location: Alabama
Posts: 521
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Using Array in Template Problem

I am trying to get this to work right.

Code:
<if condition="$thread['forumid'] == 32"><div style="margin-top: 7px;"><a href="http://www.exposethemusic.com/forums/t$lyrics[threadid]/">$lyrics[title] Lyrics</a></div></if>
PHP Code:
if ($foruminfo['forumid'] == 32)
{
$lyrics '';
$lyrics $db->query_first("SELECT * FROM " TABLE_PREFIX "thread WHERE forumid = 34 AND title = '" $threadinfo['title'] . "'");

Using showthread_start query

If I use a print_r on $lyrics it spits out the array at the top of the page. So I know the query works.

print_r($lyrics['title']); spits out the correct title to.

What isn't working is when I use the variable in the template. It just shows up blank where the variable output is suppose to be.

Any idea why?
Reply With Quote
  #2  
Old 10-19-2007, 07:26 AM
Guest190829
Guest
 
Posts: n/a
Default

What template are you using it in? And you should have to query the thread table, as this is already done and the info is put in $thread array.
Reply With Quote
  #3  
Old 10-19-2007, 08:47 AM
BamaStangGuy's Avatar
BamaStangGuy BamaStangGuy is offline
 
Join Date: Mar 2004
Location: Alabama
Posts: 521
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

postbit

I'm not sure how I would compare the post title of one forum with the post title of another one to make sure they are the same based on the thread you are in without a query. It very well could be possible but I have no idea how.

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

Anyone else have any idea? Like I said, the query works fine and the variable has the array in it but it won't work when used in a template
Reply With Quote
  #4  
Old 10-21-2007, 07:11 AM
BamaStangGuy's Avatar
BamaStangGuy BamaStangGuy is offline
 
Join Date: Mar 2004
Location: Alabama
Posts: 521
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
if ($foruminfo['forumid'] == 32)
{
    
$lyrics '';
    
$lyrics $vbulletin->db->query_first_slave("
        SELECT * 
        FROM " 
TABLE_PREFIX "thread 
        WHERE forumid = 34 AND title = '" 
mysql_escape_string($threadinfo['title']) . "' LIMIT 1
    "
);

I am guessing the variable scope is preventing me from using $lyrics within the postbit template? I have tried adding global $lyrics; to the above plugin and add it as a seperate plugin in global start but it still won't work.

I've tried $GLOBALS[lyrics] in the template but no luck either.

What am I missing here? All I want to do is use $lyrics within postbit
Reply With Quote
  #5  
Old 10-21-2007, 07:31 AM
Guest190829
Guest
 
Posts: n/a
Default

I am not really sure what you are doing. The thread you are pulling is different then the one you that the post belongs too? It seems you like you have some issues with database normalization, if that is the case.

I am just trying to get this efficient as possible for you.
Reply With Quote
  #6  
Old 10-21-2007, 07:55 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Add a plugin to postbit_display_complete
PHP Code:
global $lyrics
The postbit template is not evaluated in global scope.
Reply With Quote
  #7  
Old 10-21-2007, 05:15 PM
BamaStangGuy's Avatar
BamaStangGuy BamaStangGuy is offline
 
Join Date: Mar 2004
Location: Alabama
Posts: 521
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Danny.VBT View Post
I am not really sure what you are doing. The thread you are pulling is different then the one you that the post belongs too? It seems you like you have some issues with database normalization, if that is the case.

I am just trying to get this efficient as possible for you.
http://www.exposethemusic.com/forums/t648/
http://www.exposethemusic.com/forums/t644/

Those two threads are the same. What I am trying to do is if you are in f32 I am taking the thread title of the thread you are in and searching f34 to see if the exact same thread exists. If it does then I want to link to that thread.

Quote:
Originally Posted by SirAdrian View Post
Add a plugin to postbit_display_complete
PHP Code:
global $lyrics
The postbit template is not evaluated in global scope.
Giving this a shot

Thanks this worked
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:55 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.05478 seconds
  • Memory Usage 2,231KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (4)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (5)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete