vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   How to program nested template callups? (https://vborg.vbsupport.ru/showthread.php?t=239254)

Jaxel 03-28-2010 08:09 AM

How to program nested template callups?
 
Okay... I've changed my code in this examples to be easier to read...

In VB3, the way I would do nested template callups would be as follows:

Code:

while ($media = $vbulletin->db->fetch_array($recent_media))
{
        eval('$recentbits .= "' . fetch_template('media_browsebit') . '";');
}

eval('print_output("' . fetch_template('media_browse') . '");');

Simple, the SQL queries the database for a list of media, then pops the media in the while loop, which puts each video into the "media_browsebit" template. Then it prints out the shell template, with $recentbits being called somewhere inside. However, as we all know, these function callups like EVAL don't work in VB4 anymore. So reading this thread: https://vborg.vbsupport.ru/showthread.php?t=228078 I have been trying to figure out how to do it now. But this guide is very confusing and doesn't really go into nested templates...

Code:

while ($media = $vbulletin->db->fetch_array($recent_media))
{
        $templater = vB_Template::create('media_browsebit');
        $recentbits = $templater->render(); 
}

$templater->register('recentbits', $recentbits);
$templater = vB_Template::create('media_browse');
print_output($templater->render());

However, this doesn't seem to work for me. Right now I have 2 items being returned by the query, and the "media_browsebit" template simply outputs the word "test". So after running this script, I should get the word "testtest", but unfortunately I don't get anything. Anyone have any ideas one what I am doing wrong?

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

Okay... nevermind, I found out what the problem was. The variable register needs to be AFTER the template creator. Simply fix...

However, I am having another issue now. Inside "media_browsebit", I am trying to use certain classes that belong to the album css...

Code:

<li>
        <div class="albumthumbcontainer">
                <a href="media.php?{vb:raw session.sessionurl}mediaid={vb:raw media.mediaid}"><img src="{vb:raw media.thumbnail}" border="0"></a>
        </div>
        <h3 class="albumtitle"><a href="media.php?{vb:raw session.sessionurl}mediaid={vb:raw media.mediaid}">{vb:raw media.title}</a></h3>
</li>

I thought simply adding: <link rel="stylesheet" type="text/css" href="{vb:raw vbcsspath}album.css" /> to the headers of the main page would enable these classes... but it appears it hasn't. Does anyone know what I would need to do to get it working? My main page is currently as follows:

Code:

{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <head>
    {vb:raw headinclude}
    <link rel="stylesheet" type="text/css" href="{vb:raw vbcsspath}album.css" />
    <title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
    {vb:raw headinclude_bottom}
  </head>
  <body>
   
    {vb:raw header}
   
    {vb:raw navbar}
   
    <div id="pagetitle">
      <h1>{vb:raw pagetitle}</h1>
    </div>

        <div class="block" id="recentvideo">
                <h2 class="blockhead">Recently Uploaded Media</h2>
                <div class="blockbody floatcontainer">
                        <ul id="latestvideocontainer">
                                {vb:raw recentbits}
                        </ul>
                </div>
        </div>
   
    {vb:raw footer}
  </body>
</html>

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

It looks like "blockbody floatcontainer" isn't being called either... is that an album style?


All times are GMT. The time now is 01:06 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.01129 seconds
  • Memory Usage 1,723KB
  • 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
  • (4)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)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