View Full Version : Module Conversion Woes
Fargo
11-13-2004, 09:45 AM
Im getting closer to exactly what I need, however...now im encountering 2 more problems...
First one:
I have a layout template and a detail template. The layout template is simply the container for the data. The detail template contains the results of the query. Problem im having is that the layout template is being eval'd AFTER the detail - although it works exactly as it should as an individual file.
Supposed to be
---------------
BLOCK HEADER |
---------------
DATA |
DATA |
DATA |
DATA |
----------------
But its being displayed like this:
---------------
DATA |
DATA |
DATA |
DATA |
----------------
BLOCK HEADER |
----------------
Thats the least of my problems..but ill stick with 1 question at a time.
memobug
11-14-2004, 01:41 AM
Without seeing the code and templates it might be hard to tell. If you mess up a table by skipping a closing </td> or </tr> it may throw that row to the top or bottom of the table.
If it's not an HTML problem? Are you assembling the results of the DATA and storing it in a variable? Does that variable name appear in the Block Header template? Did you preview the template in the Style Manager to see if it looks right?
What's question #2?
Regards,
Matt
Fargo
11-14-2004, 02:11 AM
Here is all the info you should need:
Template: navsite. This is the container for the data. Contains the block header.
<!-- Left Nav Block -->
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<tr>
<td background="$stylevar[imgdir_misc]/header/content_bg_heading.gif"><img src="$stylevar[imgdir_misc]/clear.gif" width="11" alt=" " border="0" /><span class="smallfont"><strong>$vba_options[portal_blockbullet] Navigation</strong></span>
</td>
</tr>
$links
</table>
<!-- End Left Nav Block -->
Template: sitenavdetail. This is where the data is placed.
<tr>
<td class="tborder" background="$stylevar[imgdir_misc]/header/content_bg_$link[itembgcode].gif">
<img src="$stylevar[imgdir_misc]/clear.gif" width="11" alt=" " border="0" /><span class="smallfont"><strong><if condition="$link[uselink]=1"><a href="$link[itemurl]"></if>$vba_options[portal_blockbullet] $link[itemtext]</strong><if condition="$link[uselink]"></a></if></span>
</td>
</tr>
Module: site_nav_main.php. Does all the work...
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'site_nav_main'); // 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(
'sitenav','sitenavdetail',
);
// pre-cache templates used by specific actions
$actiontemplates = array(
);
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
$getlinks = $DB_site->query("SELECT * FROM site_nav_main");
while($link = $DB_site->fetch_array($getlinks))
{
eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('sitenavdetail') . '";');
}
eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('sitenav') . '";');
?>
As for question #2, I posted that in the troubleshooting forums - however I believe I may have finally found my problem with that - but the table layout problem shows up there too, so whatever issue you find with the above code will help me out on several different areas.
If you have any more questions, feel free to ask. I appreciate your interest in my prob :)
-Mark
memobug
11-14-2004, 03:28 AM
I didn't get much further than halfway through the first template before the in-my-head compiler generated an error.
It looks like you have an HTML problem of the type I described in an earlier post, the $links is not within any table element!
</tr>
$links
</table>
Get that $links into properly formatted html, and it should be fine.
P.S. You didn't click PREVIEW did you? It would have looked like this:
$links
http://www.$stylevar[imgdir_misc]/clear.gif$vba_options[portal_blockbullet] Navigation
Fargo
11-14-2004, 08:24 AM
ahhhh, but it is! After you call $links, it looks at template sitenavdetail which is this:
<tr>
<td class="tborder" background="$stylevar[imgdir_misc]/header/content_bg_$link[itembgcode].gif">
<img src="$stylevar[imgdir_misc]/clear.gif" width="11" alt=" " border="0" /><span class="smallfont"><strong><if condition="$link[uselink]=1"><a href="$link[itemurl]"></if>$vba_options[portal_blockbullet] $link[itemtext]</strong><if condition="$link[uselink]"></a></if></span>
</td>
</tr>
each item in the $links array has a new <tr> <td> and corresponding closing tags. After these items are outputted, it goes back to the sitenav template and closes up the table.
The problem im having is indeed an HTML one - its completely ignoring the code in the 1st template until AFTER it outputs the 2nd template, though you can see examples of what im doing in several other of the CMPS templates. Take a look at this snippit from (my modified) adv_portal_poll template:
<tr>
<td class="alt2" background="$stylevar[imgdir_misc]/header/content_bg_alt2.gif" align="center">
<table width="100%" cellSpacing="3">
$pollbits
</table>
although here $polllbits has been called within a TABLE element, the particular template called is expected to start with the expected <tr><td> elements, which is exactly what im doing as well.
By cheating, I can generate an unbroken page by wrapping the entire 2nd template around a table element, however, either way, it screws up my design because now ive got the extra padding and spacing around my rows, which is far from desirable. I can get by with the above code being a static HTML block, but it dont fly with my dynamic information that MUST be pulled from the database.
Fargo
11-14-2004, 10:24 PM
been tryin to figure it out but no luck.
I really need to get this workin though :(
memobug
11-15-2004, 12:18 AM
your second eval appends the compiled table result onto the end of the links detail. I don't think you ever assigned it anywhere that it could be inserted into the container template. You sent it to output.
eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('sitenav') . '";');
Once you've already sent it to content you can't fetch it back. So you need to store it in a variable for use in your summary template instead of sending it for output.
Try this instead:
while($link = $DB_site->fetch_array($getlinks))
{
eval('$links .= "' . fetch_template('sitenavdetail') . '";');
}
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('sitenav') . '";');
Note: there is no .= on the final assignment.
Fargo
11-15-2004, 07:31 AM
Thank you soooooo very much, memobug! That worked PERFECTLY!
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.