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.