Support Forums

Putting Catagories in nav menu

This is a discussion on Putting Catagories in nav menu within the Templates, HTML, CSS, and Design Help forums, part of the General category; Hi, I've been tryin to put the main catagories into my navigation. here how far i've gotten. I openend home.tpl ...


Go Back   68 Classifieds Forums > General > Templates, HTML, CSS, and Design Help

Reply
 
Thread Tools Display Modes
Old 04-04-2006, 05:28 PM   #1
Junior Member
 
Join Date: Apr 2006
Posts: 7
Rep Power: 0
Forge is on a distinguished road
Default Putting Catagories in nav menu

Hi,

Quote:
I've been tryin to put the main catagories into my navigation. here how far i've gotten.

I openend home.tpl en copied :

PHP Code:
{html_table_adv loop=$data cols=$cols table_attr='width="100%"'} [[name]] ([[total]]) 
[[
subcats]] {/html_table_adv
Into layout.tpl. which gave me this :

PHP Code:
{$smarty.const.LANG_TPL_NAVIGATION}

{
html_table_adv loop=$data cols=$cols table_attr='width="100%"'} [[name]] ([[total]]) 
[[
subcats]] {/html_table_adv

{
$smarty.const.LANG_TPL_HOME}

{foreach 
from=$templatepages item="entry"} {/foreach} {* This if statement checks for username and if it isnt found then displays the else *} {if $smarty.session.username<>'' || $smarty.cookies.username<>""} {if $canSaveFavorites=="Y"} {/if} {else} {/if} 
Then i removed
Quote:
[[subcats]]
to show only the main catagories and not the subcatagories.

I opened the index page and the catagories showed where i wanted them.

However, when clicking on one of the catagories an error was produced.

Quote:
Warning: Smarty error: html_table_adv: missing 'loop' parameter in /home/httpd/vhosts/surimarkt.com/httpdocs/includes/template/Smarty.class.php on line 1095

Warning: Smarty error: html_table_adv: missing 'loop' parameter in /home/httpd/vhosts/surimarkt.com/httpdocs/includes/template/Smarty.class.php on line 1095
[/quote]
Here's where i'm stuck. I've been over and over it and can't find what the "loop" parameter is.

Can anyone help me?
Forge is offline   Reply With Quote
Old 04-04-2006, 05:42 PM   #2
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Since the categories are only build through the index page here is a workaround.

Create a new file named: function.list_cats.php and insert this:
PHP Code:
function smarty_function_list_cats($params, &$smarty)
{
    global 
$db;
$output='<table><tr>';
    
$sSQL "SELECT id,name,image,description  FROM ".PREFIX."categories WHERE parent_id = 0 AND display<>'N' ORDER BY cOrder";
    
$result=$db->query($sSQL);
    
$i=1;
    while(
$row $result->fetch())
    {
        
$row['name']=safeStripSlashes($row['name']);
$output.='<td><a href="category.php?type='.$row['id'].'">'.$row['name'].'</a></td>';
    }
$output='</td></table>';
    return 
$output;

Then upload this file to includes/template/plugins/ directory.

Next in your layout file where you want it to appear call it like this:
{function_list_cats}

I think that should work. But I haven't tested it.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 04-04-2006, 06:29 PM   #3
Junior Member
 
Join Date: Apr 2006
Posts: 7
Rep Power: 0
Forge is on a distinguished road
Default

Thanks for a quick reply.

I followed your instructions.

The result generated this :

http://www.surimarkt.com

So all this code was..well nothing. Except screwing up the layout. The cats now appear beneath the nav menu.

i placed {list_cats} where {$smarty.const.LANG_TPL_SEARCH} was. You can see the cell beneath the "home"link is empty.

Oh, and {function_list_cats} did not not work. I went through some of the other vars and figured out that you should not include "function". So the variable to call it is : {list_cats}

I probably don't to tell you this but it might help someone else

Last edited by Forge; 04-04-2006 at 06:44 PM.
Forge is offline   Reply With Quote
Old 04-04-2006, 07:30 PM   #4
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Ok I see I thought you wanted it to go across the top.

Anyway replace the code above with this:
PHP Code:
function smarty_function_list_cats($params, &$smarty)
{
    global 
$db;
$output='';
    
$sSQL "SELECT id,name,image,description  FROM ".PREFIX."categories WHERE parent_id = 0 AND display<>'N' ORDER BY cOrder";
    
$result=$db->query($sSQL);
    
$i=1;
    while(
$row $result->fetch())
    {
        
$row['name']=safeStripSlashes($row['name']);
$output.='<td class="navlist"><img src="images/bullet.gif" alt="" /><a href="category.php?type='.$row['id'].'">'.$row['name'].'</a></td>';
    }
    return 
$output;

</span>
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 04-05-2006, 02:13 AM   #5
Junior Member
 
Join Date: Apr 2006
Posts: 7
Rep Power: 0
Forge is on a distinguished road
Default

yes, we're getting there.

Al that is needed now is to get it in a vertical position.

This is the result of your code : http://www.surimarkt.com

I tried removing
Quote:
<img src="images/bullet.gif" alt="" />
from the code and the result was that all the cats got bucnhed up. I'm guessing

table properties, but i'm not shure.
Forge is offline   Reply With Quote
Old 04-05-2006, 08:34 AM   #6
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

change this portion:
PHP Code:
$output.='<td class="navlist"><img src="images/bullet.gif" alt="" /><a href="category.php?type='.$row['id'].'">'.$row['name'].'</a></td>'
To:
PHP Code:
$output.='<tr><td class="navlist"><img src="images/bullet.gif" alt="" /><a href="category.php?type='.$row['id'].'">'.$row['name'].'</a></td></tr>'
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 04-05-2006, 03:11 PM   #7
Junior Member
 
Join Date: Apr 2006
Posts: 7
Rep Power: 0
Forge is on a distinguished road
Post

You're a genius. Thanks, that did it.

Here's the code for future reference for whoever is in need of something similar :

Create a new PHP file called function.list_cats.php

insert the following :

Quote:
<?php
function smarty_function_list_cats($params, &$smarty)
{
global $db;
$output='';
$sSQL = "SELECT id,name,image,description FROM ".PREFIX."categories WHERE parent_id = 0 AND display<>'N' ORDER BY cOrder";
$result=$db->query($sSQL);
$i=1;
while($row = $result->fetch())
{
$row['name']=safeStripSlashes($row['name']);
$output.='<tr><td class="navlist"><img src="images/bullet.gif" alt="" /><a href="category.php?type='.$row['id'].'">'.$row['name'].'</a></td></tr>';
}
return $output;
}
?>
Save the file and upload to includes/templates/plugins

add the variable :
Quote:
{list_cats}
somewhere in layout.tpl


Thanks to suzkaw
Forge is offline   Reply With Quote
Old 04-05-2006, 08:59 PM   #8
Senior Member
 
garysmith's Avatar
 
Join Date: Mar 2006
Location: Jackson, Mississippi
Posts: 70
Rep Power: 24
garysmith is on a distinguished road
Default

Quote:
<!-- // Top Bar // -->
<!-- // Top Bar // -->
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><img src="templates/default/images/leftcorner.gif" class="image" width="8" height="20" align="left"></td>
<td width="33%" bgcolor="#003366">  <span class="white">Welcome:  {if $smarty.session.username<>"" || $smarty.cookies.username<>""}{$smarty.session.user name}{else}Guest{/if}</span></td>
<td width="33%" bgcolor="#003366"><span class="white"><script language="javascript">
ourDate = new Date();
document.write(ourDate.toLocaleString());
</script></span></td>
<td width="33%" bgcolor="#003366" align="right"><span class="white">zFreeAds Member? <a href="userjoin.php" class="white">Join Now!</a></span>  </td>
<td><img src="templates/default/images/rightcorner.gif" class="image" width="9" height="20" align="right"></td>
</tr>
</table>
<!-- // Top Bar // -->
<table width="100%" class="tableWhite">
<tr>
<td width="148" valign="top">
<!-- // Navigation // -->
<table border="0" cellpadding="0" cellspacing="0" class="navigation">
<tr>
<td class="leftcol_top">{$smarty.const.LANG_TPL_NAVIGA TION}</td>
</tr>
<tr>
<td class="navlist"><img src="templates/default/images/bullet.gif" alt="" /> <a href="{$smarty.const.URL}/toplistings.php?pg=featured">Featured Ads</a></td>
</tr>
<tr>
<td class="navlist"><img src="templates/default/images/bullet.gif" alt="" /> <a href="{$smarty.const.URL}/toplistings.php?pg=new">{$smarty.const.LANG_TPL_NE W}</a></td>
</tr>
<tr>
<td class="navlist"><img src="templates/default/images/bullet.gif" alt="" /> <a href="{$smarty.const.URL}/toplistings.php?pg=top">{$smarty.const.LANG_TPL_TO P}</a></td>
</tr>
{foreach from=$templatepages item="entry"}
<tr>
<td class="navlist"><img src="templates/default/images/bullet.gif" alt="" /> <a href="{$smarty.const.URL}/pages.php?page={$entry.pageID}">{$entry.pPageTitle }</a></td>
</tr>
{/foreach}
<tr>
<td class="leftcol_nbb"><img src="templates/default/images/bullet.gif" alt="" /> <a href="{$smarty.const.URL}/contactus.php">{$smarty.const.LANG_TPL_CONTACT}</a></td>
</tr>
<tr>
<td class="leftcol_middle">{$smarty.const.LANG_TPL_MEM BER_OPTIONS}</td>
</tr>
{* This if statement checks for username and if it isnt found then displays the else *}
{if $smarty.session.username<>'' || $smarty.cookies.username<>""}
<tr>
<td class="navlist"><img src="templates/default/images/bullet.gif" alt="" /> <a href="{$smarty.const.URLS}/useraccountmodify.php">Modify My Account</a></td>
</tr>
{if $canSaveFavorites=="Y"}
<tr>
<td class="navlist"><img src="templates/default/images/bullet.gif" alt="" /> <a href="{$smarty.const.URLS}/userfavorites.php">{$smarty.const.LANG_TPL_VIEW_FA VORITES}</a></td>
</tr>
{/if}
<tr>
<td class="navlist"><img src="templates/default/images/bullet.gif" alt="" /> <a href="{$smarty.const.URLS}/usercheckout.php">{$smarty.const.LANG_TPL_PLACE_AD }</a></td>
</tr>
<tr>
<td class="navlist"><img src="templates/default/images/bullet.gif" alt="" /> <a href="{$smarty.const.URLS}/userbrowselistings.php">{$smarty.const.LANG_TPL_MO DIFY_AD}</a></td>
</tr>
<tr>
<td class="navlist"><img src="templates/default/images/bullet.gif" alt="" /> <a href="{$smarty.const.URLS}/userstore.php">{$smarty.const.LANG_USER_STORE}</a></td>
</tr>
<tr>
<td class="leftcol_nbb"><img src="templates/default/images/bullet.gif" alt="" /> <a href="logout.php">{$smarty.const.LANG_TPL_LOGOUT}</a></td>
</tr>
{else}
<tr>
<td class="navlist"><img src="templates/default/images/bullet.gif" alt="" /> <a href="{$smarty.const.URLS}/userjoin.php">{$smarty.const.LANG_TPL_REGISTER}</a></td>
</tr>
<tr>
<td class="navlist"><img src="templates/default/images/bullet.gif" alt="" /> <a href="{$smarty.const.URLS}/userlogin.php">{$smarty.const.LANG_TPL_LOGIN}</a></td>
</tr>
<tr>
<td class="navlist"><img src="templates/default/images/bullet.gif" alt="" /> <a href="{$smarty.const.URLS}/usercheckout.php">{$smarty.const.LANG_TPL_PLACE_AD }</a></td>
</tr>
{/if}
<tr>
<td class="leftcol_bottom"> </td>
</tr>
<a href="<A href="http://www.zfreeads.com/pages.php?page=16"><div">http://www.zfreeads.com/pages.php?page=16"><div align="center"><img src="http://zfreeads.com/templates/defaul...info125x60.gif" width="125" height="60" border="0" alt="$25.00/ Month or $225.00/Year" /></a><br>
<br>
</table>

{list_cats}

<!-- Left Banner Ad Loction -->
<a href="<A href="http://www.zfreeads.com/pages.php?page=16"><div">http://www.zfreeads.com/pages.php?page=16"><div align="center"><img src="http://zfreeads.com/templates/defaul...nfo125x125.gif" width="125" height="125" border="0" alt="$18.00/Month or $180.00/Year" /></a><br>
<br>
<a href="http://www.alfsbo.com"><div align="center"><img src="http://zfreeads.com/templates/defaul.../alfsbo125.gif" width="125" height="125" border="1" alt="Moving to Alabama?" /></a><br>
<!-- // Navigation // --></td>
<td width="100%" valign="top" class="padding">
<!-- // Content // -->

{* This includes the content portion *}
Above is portion of layout.tpl.php on my site

I followed instructions:
1)made .php file
2)uploaded to plugins
3)attempted to place {list_cats} and it stacked everything on my site into in one column?

can someone recommend?

I wanted the placement to be just above the left hand banner images or/and just under the left nav bar at : www.zfreeads.com

(i inserted red...see above) and it didn't turn out?

thank you!

gsmith
__________________
As a Man Think-ith, So is He.
www.zFreeAds.com
www.ms-fsbo.com
garysmith is offline   Reply With Quote
Old 04-05-2006, 11:17 PM   #9
Moderator
 
Chaslie's Avatar
 
Join Date: Mar 2006
Location: Great Ocean Road - Australia
Posts: 723
Rep Power: 37
Chaslie will become famous soon enough
Default

Try this .....


Change this:
Code:
</tr>
<a href="<A href="http://www.zfreeads.com/pages.php?page=16"><div">http://www.zfreeads.com/pages.php?page=16"><div align="center"><img src="http://zfreeads.com/templates/defaul...info125x60.gif" width="125" height="60" border="0" alt="$25.00/ Month or $225.00/Year" /></a><br>
<br> 
</table>
{list_cats}
to this:

Code:
</tr>
<TR><TD>
<a href="<A href="http://www.zfreeads.com/pages.php?page=16"><div">http://www.zfreeads.com/pages.php?page=16"><div align="center"><img src="http://zfreeads.com/templates/defaul...info125x60.gif" width="125" height="60" border="0" alt="$25.00/ Month or $225.00/Year" /></a><br>
<br> 
</TD></TR>
<TR><TD>
{list_cats}
</TD></TR>
</table>

For future reference, the 'content' in a 'table' should only go between <TD> and </TD> and nowhere else.

To learn more about building tables, check this out: http://www.w3schools.com/html/tryit....tryhtml_tables


BTW, the code for your banner ad looks a bit crook! It might pay to remove it for the present if you are still having trouble.
__________________
Chaslie


68 Classifieds Important Links
Customer Area | Issue Tracker | User Manuals & Documentation

HTML Help
W3 Schools
Chaslie is offline   Reply With Quote
Old 04-06-2006, 10:05 AM   #10
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Also with that function I posted it only includes <tr><td>content</td></tr> meaning it was built to fit into the original side navigation. You would need to add an opening and closing table tags.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Internal Navigation Menu sleepy Templates, HTML, CSS, and Design Help 1 04-13-2006 09:12 AM
Adding another Heading to the Navigational Menu sporthorsebreeder Templates, HTML, CSS, and Design Help 6 04-06-2006 05:48 AM
Terms & Conditions missing from Navagation Menu sporthorsebreeder Templates, HTML, CSS, and Design Help 6 04-05-2006 06:03 PM


All times are GMT -4. The time now is 09:40 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0