vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Using Array in Template Problem (https://vborg.vbsupport.ru/showthread.php?t=160563)

BamaStangGuy 10-19-2007 06:12 AM

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?

Guest190829 10-19-2007 07:26 AM

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.

BamaStangGuy 10-19-2007 08:47 AM

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 :(

BamaStangGuy 10-21-2007 07:11 AM

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

Guest190829 10-21-2007 07:31 AM

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.

Adrian Schneider 10-21-2007 07:55 AM

Add a plugin to postbit_display_complete
PHP Code:

global $lyrics

The postbit template is not evaluated in global scope.

BamaStangGuy 10-21-2007 05:15 PM

Quote:

Originally Posted by Danny.VBT (Post 1364884)
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 (Post 1364891)
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 :)


All times are GMT. The time now is 09:00 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.01178 seconds
  • Memory Usage 1,740KB
  • 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
  • (1)bbcode_code_printable
  • (4)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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