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

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

Damn, that was simple. I see where I went wrong.
I never put this in the code at all.
PHP Code:
$templater vB_Template::create('vbmusic'); 
I still one get the one album to show. I will send you a pm of the link of what I"m trying to do.

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

I read the article, I guess I just wasn't pay attention to it.
I really do appreciate it. I've sent you a link to see what I'm trying to accomplish over-all.
Just by seeing how it's done, I learned alot faster on how to accomplish this. Now I'm just trying to figure out the foreach statement.

I figured I could use the vb:each statement in the template, but that didn't work.
Reply With Quote
  #12  
Old 04-07-2012, 07:27 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm going to focus on your second problem now:

PHP Code:
while ($musical =$db->fetch_array($musicalbum))
    {
    
$malbumid $musical['alid'];
    
$malbumname $musical['alname'];
    
$malbumarname $musical['arname'];
    
$malbumarid $musical['arid'];
    
$mcvrsaved $musical['cvrsaved'];
    } 
You're only going to get one value doing that because you're overwriting the variable each time.

PHP Code:
$musicals = array();
if (
$db->num_rows($musicalbum))
{
    while (
$musical $db->fetch_array($musicalbum))
    {
        
$musicals[] = $musical;
    }
}
$db->free_result($musicalbum); 
Now we're cooking.

I've replace your unnecessary variables with an array and, furthermore, I've made sure each row gets it own place in the array.

PHP Code:
$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'];

Think you can figure out how to fix this?

Now replace all that ugliness in your first template render with:
PHP Code:
$templater->register('musicals'$musicals); 
Now you have an array of all the albums ready for display.

I'd recommend using {vb:each [, ]} to loop through that array and do that.

Read my article, it should help you get the basics down: https://vborg.vbsupport.ru/showthread.php?t=280880
Reply With Quote
  #13  
Old 04-07-2012, 07:34 AM
Preech Preech is offline
 
Join Date: Aug 2002
Location: Fort Campbell
Posts: 325
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Appreciate it so much. Just some free time during this deployment. I will read this article one more.

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

I've been trying for hours. I've search on google, and read through your article. I'm assuming that I am making a mistake as to where I'm suppose to put the php code foreach.
Reply With Quote
  #14  
Old 04-08-2012, 05:17 PM
Preech Preech is offline
 
Join Date: Aug 2002
Location: Fort Campbell
Posts: 325
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yo, I am seriously lost.
This is my code in the template
PHP Code:
<vb:each from="musicals"  value="value">
    {
vb:raw vbmusic_latest}
</
vb:each
This is my php code.
PHP Code:
$musicals = array('alid','alname','arid','cvrsaved','arname');

if (
$db->num_rows($musicalbum))
{
    while (
$musical $db->fetch_array($musicalbum))
    {
  
       
$musicals[] = $musical;  
       
$malbumid $musical['alid'];
    
$malbumname $musical['alname'];
    
//$malbumarname = $musical['arname'];
    //$malbumarid = $musical['arid'];
    //$mcvrsaved = $musical['cvrsaved'];
    
}
foreach (
$musicals AS $value)
{
    
$value $vbmusic_latest;
}

I am trying to get the template to show for each album, but I can not get it to show. I can get it to show without being in the foreach.
Reply With Quote
  #15  
Old 04-08-2012, 05:29 PM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What are you doing? The code I gave you is what you should be using! What you're doing won't work. vb:each replicates the foreach function, so you shouldn't be using an actual foreach in your php code!

HTML Code:
<vb:each from="musicals"  key="key" value="musical">
    {vb:raw musical.nr_artists}
    {vb:raw musical.nr_albums}
etc.,.
</vb:each>
Reply With Quote
  #16  
Old 04-08-2012, 05:56 PM
Preech Preech is offline
 
Join Date: Aug 2002
Location: Fort Campbell
Posts: 325
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, so I put the php code just like you shown, and I've put the vb:each in just like you just posted. Nothing shows.
I've been reading alot of articles.
Reply With Quote
  #17  
Old 04-08-2012, 07:18 PM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Post your complete PHP code and template code.
Reply With Quote
  #18  
Old 04-09-2012, 03:36 AM
Preech Preech is offline
 
Join Date: Aug 2002
Location: Fort Campbell
Posts: 325
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Php Code
PHP Code:
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT''vbmusic');
define('CSRF_PROTECTION'true);  
// change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('vbmusic','vbmusic_latest'
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits construct_navbits(array('' => 'Music'));
$navbar render_navbar_template($navbits);



// ###### 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
"
);

$musicals = array();

if (
$db->num_rows($musicalbum))
{
    while (
$musical $db->fetch_array($musicalbum))
    {
        
$musicals[] = $musical;  
 
    }
 

}
$db->free_result($musicalbum);  
  
 



$templater vB_Template::create('vbmusic_latest');
$templater->register('musicals'$musicals);
   
// $templater->register('malbumid', $malbumid);
   // $templater->register('malbumname', $malbumname);
    //$templater->register('malbumarname', $malbumarname);
   // $templater->register('malbumarid', $malbumarid); 
$vbmusic_latest $templater->render(); 


    
//$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('vbmusic_latest'$vbmusic_latest);
    
$templater->register('cvrsaved'$cvrsaved);
    
$templater->register('statar'$statar);
    
$templater->register('statal'$statal);
    
$templater->register('statt'$statt);
print_output($templater->render());



?>
PHP Code:
{vb:stylevar htmldoctype}
<
html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <
head>
    <
title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
    {
vb:raw headinclude}
    {
vb:raw headinclude_bottom}
  </
head>
  <
body>
    
    {
vb:raw header}
    
    {
vb:raw navbar}


<
br /><br /><br />
    
<
div class="colmask leftmenu">
    <
div class="colleft">
        <
div class="col1">
            <!-- 
Column 1 start -->



<
div class="audio_head">Newest Mixtapes</div>
<
div class="audio_body">

<
vb:each from="musicals" value="musical">

    {
vb:raw musical.alid}
    {
vb:raw musical.alname}

</
vb:each>
<!--{
vb:raw vbmusic_latest}-->
    </
div>


            <!-- 
Column 1 end -->
        </
div>
        <
div class="col2">
            <!-- 
Column 2 start -->
<
div class="audio_head">Menu</div>
<
div class="audio_body">
        <
table align="center" cellspacing="0" cellpadding="0" width="100%" 
 <
tr
  <
td valign="top" align="center">
   <
table align="center" cellspacing="5" cellpadding="0" width="100%"
    <
tr
     <
td align="left"><a href="vbmusic.php" title="" alt="">- Music Home</a></td>
    </
tr>
    <
tr
     <
td align=\"left\"><a href=\"browse.php?typ=artist\" title=\"\" alt=\"\">- Browse Artist</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"browse.php?typ=album\" title=\"\" alt=\"\">- Browse Albums</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"browse.php?typ=genre\" title=\"\" alt=\"\">- Browse Genre</a></td>
    </tr>

 <tr> 
     <td align=\"left\"><a href=\"import.php\" title=\"\" alt=\"\">- Import Albums</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"config.php\" title=\"\" alt=\"\">- Config Settings</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"usr_list.php\" title=\"\" alt=\"\">- Userlist</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"showlog.php\" title=\"\" alt=\"\">- Show Log</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"stats.php\" title=\"\" alt=\"\">- Statistics</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"create_artist.php\" title=\"\" alt=\"\">- Create artist</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"del_artist.php\" title=\"\" alt=\"\">- Delete artist</a></td>
    </tr>


</table>
  </td>
 </tr>
</table>
        </div><br />
<div class="
audio_head">Statistics</div>
<div class="
audio_body">
<table align="
center" cellspacing="0" cellpadding="0" width="100%"> 
 <tr> 
  <td valign="
top" align="center">
   <table align="
center" cellspacing="0" cellpadding="0" width="90%">
    <tr>
     <td class="
data3" align="left"><b>Albums  </b>&nbsp</td>
     <td class="
data1" align="left">{vb:raw statal}</td></tr>
     <tr><td class="
data3" align="left"><b>Artists  </b>&nbsp</td>
     <td class="
data1" align="left">{vb:raw statar}</td></tr>
     <tr><td class="
data3" align="left"><b>Songs  </b>&nbsp</td>
     <td class="
data1" align="left">{vb:raw stats}</td></tr>
   </table>
  </td>
 </tr>
</table>
</div>
    

            
            <!-- Column 2 end -->
        </div>
    </div>
</div>
    {vb:raw footer}
  </body>
</html> 
Reply With Quote
  #19  
Old 04-09-2012, 04:55 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is the HTML you're showing me from template: vbmusic_latest, or from template: vbmusic

If it's from template: vbmusic, then you need to add: $templater->register('musicals', $musicals); to the register in that template.
Reply With Quote
  #20  
Old 04-09-2012, 05:24 AM
Preech Preech is offline
 
Join Date: Aug 2002
Location: Fort Campbell
Posts: 325
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well god damn, I knew it was something simple that I was over looking. That was it.

I see that your site is music related as well. I'm currently deployed to Afghanistan right now. If it's not to much, can I continue to ask you for help from time to time. I get about six hours of free time each day. If possible how may I contact you.
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 03:46 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.08057 seconds
  • Memory Usage 2,338KB
  • 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
  • (1)bbcode_html
  • (9)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