View Full Version : Centering categories layout
golfhomeconnect
08-29-2005, 05:14 PM
I've centered my directory listings, but consequently the categories are on either margin.
example:
/Computers/
Any ideas on how to fix this.
Thank as always.
kickass
08-29-2005, 09:34 PM
I just peeked at your source code. There are major problems with the html being generated, which tells me you put something in the wrong place via the template. There should not be a td tag BEFORE the table tag (this is RIGHT after the body tag)
I suggest you paste your header template code (and possibly the main.tpl too) in here and let us take a look. Something's very wrong.
golfhomeconnect
08-29-2005, 11:46 PM
Yeah you are right.... I'm ashamed to admit that I took this artfully css driven script and inserted tables and the like since i don't know sh... about css. Basically, I created 3 tables and inserted the 3 sections of code and then centered the tables.
Here's the Main.tpl which is causing the problems.
Thanks for your help, Bob
{* Calculate title from path *}
{capture name="title"}
{if count($path)>1} - {/if}
{foreach from=$path item=category name=path}
{if $smarty.foreach.path.iteration gt 2}
>
{/if}
{if not $smarty.foreach.path.first}
{$category.TITLE}
{/if}
{/foreach}
{/capture}
{strip}
{assign var="in_page_title" value=$category.TITLE}
{assign var="description" value=$category.DESCRIPTION}
{include file="header.tpl"}
{include file="top_bar.tpl"}
{* Calculate the number of categories per row *}
{php}
$this->assign('cats_per_col', ceil(count($this->get_template_vars('categs'))/ CATS_PER_ROW));
{/php}
{* Display categories heading if not on homepage *}
{if $category.ID gt 0 and count($categs) gt 0}
<table width="800" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td> <h3>{l}Categories{/l}</h3>
{/if} {* Categories *}
</td>
</tr>
</table>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#FFFFFF">
<tr>
{foreach from=$categs item=cat name=categs}
{if ($smarty.foreach.categs.iteration mod $cats_per_col eq 1 and $cats_per_col gt 1) or $smarty.foreach.categs.first}<td>{/if}
<h2>{$cat.TITLE} ({if $smarty.const.ENABLE_REWRITE}{$cat.TITLE_URL}/{else}index.php?c={$cat.ID}{/if}){if $smarty.const.CATS_COUNT} <span class="count">({$cat.COUNT})</span>{/if}</h2>
{* Display subcategories *}
<p class="subcats">
{if $cat.SUBCATS}
{foreach from=$cat.SUBCATS item=scat name=scategs}
<a href="{if $smarty.const.ENABLE_REWRITE}{$cat.TITLE_URL}/{$scat.TITLE_URL}/{else}index.php?c={$scat.ID}{/if}">
{$scat.TITLE}</a>, {/foreach} ...
{/if}
</p>
{if ($smarty.foreach.categs.iteration mod $cats_per_col eq 0 and $cats_per_col gt 1) or $smarty.foreach.categs.last}</td>{/if}
{/foreach}
</tr>
<tr>
<td>
{if $smarty.const.FTR_ENABLE==1 and count($feat_links) gt 0}
<h3>{l}Featured Links{/l}</h3>
{foreach from=$feat_links item=link name=links}
{include file="link.tpl" link=$link}
{/foreach}
{/if}
{* Links heading and sorting*}
{if ($qu or $category.ID gt 0 or $p) and count($links) gt 0}
<h3>{l}Links{/l} {if not $p}<span class="small" style="margin-left: 50px">{l}Sort by{/l}:
{if $smarty.const.ENABLE_PAGERANK and $smarty.const.SHOW_PAGERANK}{if $sort eq 'P'}<span class="sort"> {l}PageRank{/l}</span>{else} {l}PageRank{/l} (?s=P{if not $smarty.const.ENABLE_REWRITE}&c={$category.ID}{/if}{if $qu}&q={$qu}{/if}){/if} |{/if}
{if $sort eq 'H'} <span class="sort">{l}Hits{/l}</span>{else} {l}Hits{/l} (?s=H{if not $smarty.const.ENABLE_REWRITE}&c={$category.ID}{/if}{if $qu}&q={$qu}{/if}){/if}
{if $sort eq 'A'} | <span class="sort">{l}Alphabetical{/l}</span>{else} | {l}Alphabetical{/l} (?s=A{if not $smarty.const.ENABLE_REWRITE}&c={$category.ID}{/if}{if $qu}&q={$qu}{/if}){/if}
</span>{/if}</h3>
<div id="links">
{foreach from=$links item=link name=links}
{include file="link.tpl" link=$link}
{/foreach}
</div>
{/if}
{* Javascript for tracking link clicks *}
<script>
var root = '{$smarty.const.DOC_ROOT}';
{literal}
var a = document.getElementsByTagName("a");
for(i=0; i<a.length; i++)if(a[i].id != '')
a[i].onclick = count_link;
function count_link(){
i = new Image();
i.src= root+'/cl.php?id='+this.id;
return true;
}
{/literal}
</script></td>
</tr>
</table>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td>{include file="footer.tpl"}
{/strip}</td>
</tr>
</table>
vBulletin® v3.8.0, Copyright ©2000-2012, Jelsoft Enterprises Ltd.