Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Simple Custom Menu Revisited - Categorymenu

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 09-10-2006, 02:46 AM
 
vixnfox vixnfox is offline
 

Advanced Member
  
Join Date: Feb 2006
Location: Adelaide, South Australia
Posts: 82
 

Default Simple Custom Menu Revisited - Categorymenu

I have updated the procedure which may be of use to others.
It was inspired by a post from member Cambo re moving categories between menus .... well Im using the code posted below myself. Thanks for the idea cambo

See below
__________________
V 4.3.1 Live:

Developing on
PHP 5.3.0
MySQL server 5.0.75-community-log
MySQL client 5.1.36
Web server Apache/2.2.11 (Unix) mod_ssl/2.2.11
Windows 7 64bit on a Toshiba Satellite P500

ADELAIDE, SOUTH AUSTRALIA
Reply With Quote
  #2  
Old 09-14-2006, 06:12 PM
 
vixnfox vixnfox is offline
 

Advanced Member
  
Join Date: Feb 2006
Location: Adelaide, South Australia
Posts: 82
 

Default Re: Simple Custom Menu Revisited - Categorymenu

This is the revamped version. It requires you use phpmyadmin dont be afraid

Lets say you have a shop that sells cars, spare parts and tyres. You would like to have the spare parts and tyre categories

in their own menus, so you need a Spares menu and a Tyres menu, and be able to move your Spares and Tyres

categories to the new menus - without messing up your xcart!!!!.

PLEASE BACK UP YOUR DATA FIRST AND MAKE COPIES OF MODIFIED FILES

1. In Admin->Languages, create two new labels
lbl_spares_menu, Spare Parts, Spare Parts
lbl_tyres_menu, Tyres, Tyres

2. Start up phpMyAdmin and click your xcart_categories table.

Select the Structure tab. About half way down you will see an "Add fields" section.
We want to Add 1 Field AFTER categoryidpath. Click Go button.
In the Field box type in catmenu
In the Type Box select VARCHAR
In the Length/Values type 12 - if you want longer menu names feel free but they might wrap
you can ignore collation and attributes fields, Null should be "not null".
In the Default box type in a name for your main menu, this is currently THE menu you already have.
I chose default. Click on "save".

All your categories now have a field called catmenu with a value of default

3. Create Two New Menus
In skin1\customer, make two copies of categories.tpl. Rename one to spareparts.tpl, the other to tyres.tpl.

Open categoroes.tpl for editing and look for this code:

{section name=cat_num loop=$categories}

<FONT class="CategoriesList"><A href="home.php?cat={$categories[cat_num].categoryid}"

class="VertMenuItems">{$categories[cat_num].category}</A></FONT><BR>

{/section}

Replace it with this code:
Code:
{section name=cat_num loop=$categories} {if $categories[cat_num].catmenu =="default"} <FONT class="CategoriesList"><A href="home.php?cat={$categories[cat_num].categoryid}" class="VertMenuItems">{$categories[cat_num].category}</A></FONT><BR> {/if} {/section}


In your two menus, replace the line

{if $categories[cat_num].catmenu =="default"}
with
{if $categories[cat_num].catmenu =="spares"}
and
{if $categories[cat_num].catmenu =="tyres"}

You may wish to change the first line of comment code in each menu to reflect the new menu name.
Also, the last line of categories.tpl is
{include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_NEWcategories

menu_content=$smarty.capture.menu }

So you need to replace the
menu_title=$lng.lbl_NEWcategories with your previousley created labels.

If you have done everything correctly to this point, your shop will function as before, since all your categories have a

catmenu value of default.

4. Open up skin1\customer\home.tpl

After the line
{ include file="customer/categories.tpl" }

add this:
Code:
<br> {include file="spareparts.tpl"} <br> {include file="tyres.tpl"} <br>

5. Open the file skin1\admin\main\category_modify.tpl

Around line 75 is this line:
<TD height="10"><INPUT type="text" name="order_by" size="5" value="{if $category_error ne ""}{$smarty.post.order_by}{elseif

$mode ne "add"}{$current_category.order_by}{/if}">
</td>
</tr>

Directly after the </tr> tag paste this code:
Code:
{* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *} <TR> <TD height="10" class="FormButton" nowrap>Category Menu:</TD> <TD width="10" height="10"><FONT class="FormButtonOrange"></FONT></TD> <TD height="10"> <SELECT name="cat_menu"> <OPTION value="">{$current_category.catmenu}</OPTION> {section name=mn loop=$allcategories} <OPTION value="{$allcategories[mn].catmenu}">{$allcategories[mn].catmenu escape:"html"}</OPTION> {/section} </SELECT> </td></tr> <tr> <TD height="10" class="FormButton" nowrap>New Category Menu:</TD> <TD width="10" height="10"><FONT class="FormButtonOrange"></FONT></TD> <TD height="10"> <INPUT type="text" name="newcatmenu" maxlength="12" size="15" value="default"> </TD> </TR> {* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *}

6. Open the file admin\category.modify.php
Note: This is under the Root (shop, store whatever), NOT skin1\admin !!!

Around line 132 you will see this:
# Update general data of category
#
db_query("UPDATE $sql_tbl[categories] SET category= .... etc


Above the db_query line paste this code:
Code:
$cat_menu = $_POST['cat_menu']; if ($cat_menu == "") { $cat_menu=$_POST['newcatmenu']; }
and in the just mentioned db_query line:

db_query("UPDATE $sql_tbl[categories] SET category='$category_name', description='$description' etc

insert catmenu='$cat_menu' so it now looks like:


db_query("UPDATE $sql_tbl[categories] SET category='$category_name',catmenu= '$cat_menu', description='$description' etc


7. Last one - open, again from Root, include\categories.php

Around line 76 look for:

$to_search =

"$sql_tbl[categories].categoryid,$sql_tbl[categories].parentid,$sql_tbl[categories].categoryid_path, etc

right after $sql_tbl[categories].categoryid_path, add $sql_tbl[categories].catmenu,

Your shop should still function as before if you have got it all right

Log into admin and select a category to modify. You should see a drop-down right after "position" called "Category Menu".
There should be One entry - "default".

You now have two choices, you can go into phpmyadmin and manually enter the names "spares" or "tyres" in the catmenu field for their respective categories, this is probably the fastest. If you do, then the dropdown will have 3 different menu names "default", "spares" and "tyres". At the moment, all categories under the same menu will have an entry, so if there are 6 categories under"spares" there will be 6 entries called "spares" in the dropdown. If I were smarter I would create a new table with catmenuid and catmenu fields and use this, but I havent got that far yet. Perhaps someone else could do it and tell me?

Your other choice is to add a new category from admin, this time you will see a "New Category Menu" dropdown below the "category Menu" box. If you enter a new name - and it needs to be a valid menu - spares or tyres, or any other menu you have created - or you will get no output - your new category will appear in that menu.

Now, if you modify any category, you can seleect which menu you want it to show up in from this screen.

I hope people can follow this - enjoy

vixnfox

********ADDED THIS BIT OMITTED BEFORE*****************

In root, init.php look for the sql_table=array and add

"memberships_lng" => "xcart_memberships_lng",
Code:
"menus" => "xcart_menu",
"modules" => "xcart_modules",

and most important, in the category_modify php, just before the closing ?> tag add this
Code:
$smarty->assign("mymenu", $mymenu);

PS You can also manually change the names in PHPMyadmin in the xcart_categories table catmenu fields.
__________________
V 4.3.1 Live:

Developing on
PHP 5.3.0
MySQL server 5.0.75-community-log
MySQL client 5.1.36
Web server Apache/2.2.11 (Unix) mod_ssl/2.2.11
Windows 7 64bit on a Toshiba Satellite P500

ADELAIDE, SOUTH AUSTRALIA
Reply With Quote
  #3  
Old 11-08-2006, 05:06 AM
 
x-online x-online is offline
 

Senior Member
  
Join Date: Apr 2004
Location: Australia, Sydney
Posts: 189
 

Default Re: Simple Custom Menu Revisited - Categorymenu

Hi Vixnfox,

Thanks for coding it out and simplify it.
Would you have a sample website?

Thanks in advance
__________________
X-Cart version 4.x (Most likely will be the latest version)
Reply With Quote
  #4  
Old 11-08-2006, 01:52 PM
 
vixnfox vixnfox is offline
 

Advanced Member
  
Join Date: Feb 2006
Location: Adelaide, South Australia
Posts: 82
 

Default Re: Simple Custom Menu Revisited - Categorymenu

My website is at
http://ifgdesignz.com.au

Its a tad slow loading - not sure if its me or the hosting company (Netregistry)


vixnfox

PS I have added a bit to the end of the post, pls read it
__________________
V 4.3.1 Live:

Developing on
PHP 5.3.0
MySQL server 5.0.75-community-log
MySQL client 5.1.36
Web server Apache/2.2.11 (Unix) mod_ssl/2.2.11
Windows 7 64bit on a Toshiba Satellite P500

ADELAIDE, SOUTH AUSTRALIA
Reply With Quote
  #5  
Old 10-13-2007, 09:29 PM
 
sunset sunset is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 94
 

Default Re: Simple Custom Menu Revisited - Categorymenu

Hi there
I need a bit of help as i would love to implement this mod. I need another menu on my side bar home page.
Firstly, I am very new to html/website design etc.
So sorry for the silly question, but where is myphpadmin?
And secondly, before i go chopping and changing things (i have backed up)...will this mod be compatible with my store design, as i have horizontal categories?
My site is: http://www.sunsetcrystals.com.au/home.php?shopkey=1234
Thanks so much.
__________________
Sunset
X-Cart Gold v4.1.8
Reply With Quote
  #6  
Old 10-14-2007, 02:02 AM
  mitash's Avatar 
mitash mitash is offline
 

X-Adept
  
Join Date: Jan 2006
Location: Australia
Posts: 450
 

Default Re: Simple Custom Menu Revisited - Categorymenu

Netregistry is super slow....

I get many customers contating me who host with netregistry and find it very slow...



Quote:
Originally Posted by vixnfox
My website is at
http://ifgdesignz.com.au

Its a tad slow loading - not sure if its me or the hosting company (Netregistry)


vixnfox

PS I have added a bit to the end of the post, pls read it
__________________
eCommerce - Strategy / Design / Development / Marketing / Maintenance

Call within Australia:
Phone: 1300 648 274 | Mobile: 0417 241 950
Call outside Australia:
+61 417 241 950 |

Email:
results@mitash.com | Skype: mitashau | Web: www.mitash.com
Reply With Quote
  #7  
Old 10-17-2007, 07:51 AM
 
sunset sunset is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 94
 

Default Re: Simple Custom Menu Revisited - Categorymenu

If possible, could someone help me out re post #5? Many thanks.
__________________
Sunset
X-Cart Gold v4.1.8
Reply With Quote
  #8  
Old 10-20-2007, 08:23 AM
 
dsoong dsoong is offline
 

Advanced Member
  
Join Date: Jan 2007
Posts: 94
 

Default Re: Simple Custom Menu Revisited - Categorymenu

There is an alternative to this approach. Code the custom menu in static html and put it in categories.tpl. This will simply midification steps once it is set up and you do not need to mess around database. It will also not slow down xcart like has been reported by people having large amount of sub-categories.
Reply With Quote
  #9  
Old 10-20-2007, 08:41 AM
 
sunset sunset is offline
 

Advanced Member
  
Join Date: Jul 2007
Posts: 94
 

Default Re: Simple Custom Menu Revisited - Categorymenu

Thanks so much for your help, dsoong...i shall try that. Sounds alot easier too.
Cheers, Paula
__________________
Sunset
X-Cart Gold v4.1.8
Reply With Quote
  #10  
Old 11-05-2007, 05:22 AM
 
parekh81 parekh81 is offline
 

Senior Member
  
Join Date: Nov 2007
Posts: 191
 

Question Re: Simple Custom Menu Revisited - Categorymenu

Has anyone tried this out for version 4.1.9.

I am stuck at step 3. This line of code doesn't exist in customers/categories.tpl

{section name=cat_num loop=$categories}

----------------------------------------------------------------------
(my categories.tpl looks like this)

{* $Id: categories.tpl,v 1.26 2005/11/17 06:55:37 max Exp $ *}
{capture name=menu}
{if $active_modules.Fancy_Categories ne ""}
{include file="modules/Fancy_Categories/categories.tpl"}
{assign var="fc_cellpadding" value="0"}
{else}
{if $config.General.root_categories eq "Y"}
{foreach from=$categories item=c}
<font class="CategoriesList"><a href="home.php?cat={$c.categoryid}" class="VertMenuItems">{$c.category}</a></font><br />
{/foreach}
{else} {foreach from=$subcategories item=c key=catid}
<font class="CategoriesList"><a href="home.php?cat={$catid}" class="VertMenuItems">{$c.category}</a></font><br />
{/foreach}
{/if}
{/if}
{/capture}
{ include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_categories menu_content=$smarty.capture.menu cellpadding=$fc_cellpadding}

----------------------------------------------------------------------

What should I doooooo????

Thanks in advance.
__________________
Gold 4.4.2 with 'some' customisation
Site review: http://forum.x-cart.com/showthread.php?t=63075
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:55 PM.

   

 
X-Cart forums © 2001-2020