Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-07-2012, 04:20 AM
Preech Preech is offline
 
Join Date: Aug 2002
Location: Fort Campbell
Posts: 325
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help show more than one result.

So I'm working on creating a mod for music base sites. I am trying to show the output for all of the latest mixtapes that was posted. I can get the one to show. But the rest doesn't show. Maybe I messed up some where in the code. Here is what I got.

PHP Code:
// ###### YOUR CUSTOM CODE GOES HERE #####
$musicalbum =  $db->query_read("
SELECT al.alid, al.alname, al.arid, al.added, al.cvrsaved, ar.arname FROM " 
TABLE_PREFIX" album al
LEFT JOIN artist ar ON ar.arid=al.arid  
ORDER BY al.alid DESC LIMIT 5
"
);

    
    while (
$musical =$db->fetch_array($musicalbum))
    {
    
$malbumid $musical['alid'];
    
$malbumname $musical['alname'];
    
$malbumarname $musical['arname'];
    
$malbumarid $musical['arid'];
    
$mcvrsaved $musical['cvrsaved'];
    }
      


$musicstat $db->query_read("SELECT nr_artists, nr_albums,nr_tracks FROM " TABLE_PREFIX ." stats");
while (
$music_stat $db->fetch_array($musicstat))
{
$statar $music_stat['nr_artists'];
$statal $music_stat['nr_albums'];
$statt $music_stat['nr_tracks'];
}
    


    
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

$templater vB_Template::create('vbmusic');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('malbumid'$malbumid);
$templater->register('malbumname'$malbumname);
$templater->register('malbumarname'$malbumarname);
$templater->register('malbumarid'$malbumarid);
$templater->register('cvrsaved'$cvrsaved);
$templater->register('statar'$statar);
$templater->register('statal'$statal);
$templater->register('statt'$statt);
$templater->register('mar1'$mar1);
$templater->register('vbmusic_latest'$vbmusic_latest);  
print_output($templater->render()); 
this is my template.
PHP Code:
<div class="audio_body2">
<
span class="column">
 <
div class="box">
<
center>
<
vb:if condition="$my_variable == yes">
    <
img src="./audio/covers/{vb:raw cvrsaved}/jpg" width="130px" border="0" ">
<vb:else />
    <img src="
./audio/covers/no_cover.jpg" width="130px" border="0" ">
</
vb:if>
</
center>
</
div>
<
hr style="height: 1;
 border-style: dashed;
 border-width: 1px 0 0 0;
 border-color:rgb(255, 255, 255) url(images/gradients/grey-up.png) repeat-x left bottom;"
>
  <
div class="box">Album:&nbsp <a href="./vbmusic_album.php?id=".$row1['alid']."\">{vb:raw malbumname}</a></div>
  <div class="
box">Artist:&nbsp<a href="./artist.php?id={vb:raw malbumarid}">{vb:raw malbumarname}</a></div>
</span>
</div> 
and this is the code I'm using to pull this template into my main template.
PHP Code:
{vb:raw vbmusic_latest
Please point me in the right direction.
Reply With Quote
  #2  
Old 04-07-2012, 04:42 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to register your template for use in another template: https://vborg.vbsupport.ru/showthread.php?t=228078

Save your template into a variable then preregister that variable into the main template. The variable will contain the HTML and parsed template syntax ready for use in the main template.

Btw: You should wrap:
PHP Code:
if ($db->num_rows($result))
{
    
// while here

Prevents errors on empty results.
Reply With Quote
  #3  
Old 04-07-2012, 04:44 AM
Preech Preech is offline
 
Join Date: Aug 2002
Location: Fort Campbell
Posts: 325
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Am I putting this before my while statment, or would it be smarter to try using the foreach. I'm guessing my issue is all in my php page.
Reply With Quote
  #4  
Old 04-07-2012, 04:55 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think I've mistaken what you're trying to do.

You want: {vb:raw vbmusic_latest}

To contain the contents of the HTML you posted in your first post? Assuming it's a template,

PHP Code:
$templater vB_Template::create('YOURTEMPLATE');
$templater->register('malbumid'$malbumid);
$templater->register('malbumname'$malbumname);
$templater->register('malbumarname'$malbumarname);
$templater->register('malbumarid'$malbumarid); 
$vbmusic_latest $templater->render(); 
Reply With Quote
  #5  
Old 04-07-2012, 05:03 AM
Preech Preech is offline
 
Join Date: Aug 2002
Location: Fort Campbell
Posts: 325
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, {vb:raw vbmusic_latest} contains all of the html.
Negative on showing up though. I'm guessing I have to do a foreach statement.
Reply With Quote
  #6  
Old 04-07-2012, 05:18 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lol no.

Are you sure $vbmusic_latest contains the proper HTML?

PHP Code:
var_dump($vbmusic_latest); die; 
Put this right above where your template gets rendered. What do you see?
Reply With Quote
  #7  
Old 04-07-2012, 05:35 AM
Preech Preech is offline
 
Join Date: Aug 2002
Location: Fort Campbell
Posts: 325
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

after pasting this. I see NULL. No I know some where I'm messing up with registering the template to show.
Reply With Quote
  #8  
Old 04-07-2012, 05:46 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your code doesn't show $vbmusic_latest being registered at all.
Reply With Quote
  #9  
Old 04-07-2012, 05:54 AM
Preech Preech is offline
 
Join Date: Aug 2002
Location: Fort Campbell
Posts: 325
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$musicalbum =  $db->query_read("
SELECT al.alid, al.alname, al.arid, al.added, al.cvrsaved, ar.arname FROM " 
TABLE_PREFIX" album al
LEFT JOIN artist ar ON ar.arid=al.arid  
ORDER BY al.alid DESC LIMIT 5
"
);
if (
$db->num_rows($musicalbum))
{
    while (
$musical =$db->fetch_array($musicalbum))
    {
    
$malbumid $musical['alid'];
    
$malbumname $musical['alname'];
    
$malbumarname $musical['arname'];
    
$malbumarid $musical['arid'];
    
$mcvrsaved $musical['cvrsaved'];
    }





}

$musicstat $db->query_read("SELECT nr_artists, nr_albums,nr_tracks FROM " TABLE_PREFIX ." stats");
while (
$music_stat $db->fetch_array($musicstat))
{
$statar $music_stat['nr_artists'];
$statal $music_stat['nr_albums'];
$statt $music_stat['nr_tracks'];
}
    



// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

$templater vB_Template::create('vbmusic');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('malbumid'$malbumid);
$templater->register('malbumname'$malbumname);
$templater->register('malbumarname'$malbumarname);
$templater->register('malbumarid'$malbumarid);
$templater->register('vbmusic_latest'$vbmusic_latest);
$templater->register('cvrsaved'$cvrsaved);
$templater->register('statar'$statar);
$templater->register('statal'$statal);
$templater->register('statt'$statt);
$vbmusic_latest $templater->render();
print_output($templater->render()); 
First off I appreciate all of the help. This is the php page.
1. The vbmusic_latest template still doesn't show.
2. For each album id, I want to display that album. I've looked through the original vb files. The closest would be foreach, but I'm lost now.
Reply With Quote
  #10  
Old 04-07-2012, 07:00 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1) Let's work on getting you to actually show your template first.

You really should look at that article I posted, because you're still doing it all wrong.

PHP Code:
$templater vB_Template::create('vbmusic');
    
$templater->register('malbumid'$malbumid);
    
$templater->register('malbumname'$malbumname);
    
$templater->register('malbumarname'$malbumarname);
    
$templater->register('malbumarid'$malbumarid); 
$vbmusic_latest $templater->render();  

$templater vB_Template::create('GENERIC_SHELL');
    
$templater->register_page_templates(); 
    
$templater->register('navbar'$navbar);
    
$templater->register('vbmusic_latest'$vbmusic_latest);
    
$templater->register('cvrsaved'$cvrsaved);
    
$templater->register('statar'$statar);
    
$templater->register('statal'$statal);
    
$templater->register('statt'$statt);
print_output($templater->render()); 
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 01:59 AM.


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.05364 seconds
  • Memory Usage 2,316KB
  • Queries Executed 11 (?)
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
  • (8)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete