Jaxel
03-28-2010, 08:09 AM
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:
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...
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 1269768297 at 1269768297 ---------------
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...
<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:
{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 1269769701 at 1269769701 ---------------
It looks like "blockbody floatcontainer" isn't being called either... is that an album style?
In VB3, the way I would do nested template callups would be as follows:
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...
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 1269768297 at 1269768297 ---------------
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...
<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:
{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 1269769701 at 1269769701 ---------------
It looks like "blockbody floatcontainer" isn't being called either... is that an album style?