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

Reply
 
Thread Tools Display Modes
  #1  
Old 03-28-2010, 08:09 AM
Jaxel Jaxel is offline
 
Join Date: Sep 2005
Posts: 1,160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
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 06:51 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05840 seconds
  • Memory Usage 2,169KB
  • 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
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)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