PDA

View Full Version : main categories as a permanent menu


gio
06-04-2006, 02:52 AM
Hello my name is Giovanni and I bought PHPLD 3 yesterday.

I am trying to make some changes in main.tpl (default) (i know basic php) but I can't really manage it, this is too complicated for me.

My problem:
When you visit the first page of your phpLD site you see your main categories. I want those to be shown all the time, like a menu. So I want the main categories to be in a table to the left (and remain there no matter how many sub-sub categories the user visits).

This means when the user has not picked a main category, no subcategories are shown. I would like to put my own content there (on first page only).

I'll try to draw it for you:
-----------------
| M|''''''''''''''''''''''''''''|
| A|'''''''''''''''''''''''''''''|
| I |'''''''''''sub'''''''''''|
| N|''categories'''''|
|----------------|

I hope someone can help me. :rolleyes:

blackpepper
06-05-2006, 08:10 AM
you mean like this one? http://webresources.akipus.com/

I don't much time now but will come back later and try to help!

or maybe someone else can help you before.

blackpepper

gio
06-05-2006, 11:43 PM
blackpepper, yes exactly like that!! :)

I would love if you could help me with that! :D

blackpepper
06-10-2006, 09:21 AM
Hi,

Here are the changes you need to make to show all main categories on all pages. I'm not an expert in php or smarty so if someone else knows a better way, please say it!
This modification applies to phpld version 3.0.5!

1. Create a file and name it showmaincats.php with the following code in it and place it in the root path of all files(where index.php is placed):
<?PHP
// Trying to show main categories on homepage
$mycats = $db->GetAll("SELECT * FROM {$tables['category']['name']} WHERE STATUS=2 AND PARENT_ID = 0 ORDER BY TITLE");
$tpl->assign('mycats', $mycats);
//End of showing main categories
?>

2. Open index.php and find the code(around line 20):
require_once 'init.php';

Add this code below:
// Show main categories on all pages
require_once 'showmaincats.php';
// End of show main categories on all pages include

3. Create a tpl file and name it whatever you want (saved it in templates folder) with following code in it:

{strip}

<table width="100%" cellspacing="0" celllpading="0" border="0">
<tr><td>{l}Main Categories{/l}</td></tr>
<tr><td>
{* Calculate the number of categories per row *}
{* Display main categories on all pages *}
{foreach from=$mycats item=cat name=categs}
<h2><a href="{if $smarty.const.ENABLE_REWRITE}{$smarty.const.DOC_RO OT}/{$cat.TITLE_URL|escape}/{else}index.php?c={$cat.ID}{/if}">{$cat.TITLE|escape}</a></h2>
{/foreach}
</td></tr>
</table>
{/strip}

4. Then in main.tpl include your new tpl file wherever you want your main categories to appear. Something like this:
{include file="yourfile.tpl"}

I already tested it and it is working but if you have some trouble post it here :-)

Hope this helps you!!

P.S. The code might look weird with some spaces in it like "DOC_RO OT" . Where is the insert code button??

gio
06-10-2006, 07:32 PM
Thanks alot man!

Works great!