X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   How to Add a Simple Custom Menu (https://forum.x-cart.com/showthread.php?t=19871)

vixnfox 02-10-2006 05:55 PM

How to Add a Simple Custom Menu
 
Might be worthy of a sticky considering all the requests :) *tap tap mods? *

Adding A Custom Menu
Add a basic menu tab to LH menu structure. Here is what I "created" for jewellery store.
I know the end result could have been achieved using static pages, but I needed the challenge!

I wanted a "Jewellery FAQs" Menu
Decide on names: Jewellery FAQs - Menu name
Swarovski Crystals - Menu Entry
Create:
admin Languages
lbl_faqmenu_content name FAQ Menu Content, Value Jewellery FAQs
lbl_faqmenu_swarovski name Swarovski FAQ, Value Swarovski Crystals

Create a folder "ourpages" under skin1 (just to keep all your own stuff together)

We need 4 files all up, 2 for xcart setup, then 2 for each menu entry

skin1\ourpages - faqs.tpl, faqs_menu.tpl, swarovski.tpl
xcart root - swarovski.php

( I tried putting the .php file in xcart\customer, but every time I used the link, it changed all the other menu links from "xcart\" to "\xcart\customer" until I hit the back button or clicked "Home". Any Ideas why???)

1. Files to modify:
skin1\customer\home.tpl
add this line above or below the include help.tpl line
{include file="ourpages/faqs.tpl" }

skin1\customer\home_main.tpl
add this line somewhere
{elseif $main eq "swarovski" }
{include file="./ourpages/swarovski.tpl" }

2. faqs.tpl in ourpages. This is the menu
{capture name="menu"}
{include file="ourpages/faqsmenu.tpl"}
{/capture}
{ include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_faqmenu_content menu_content=$smarty.capture.menu }



3. faqs_menu.tpl in ourpages. These are the menu entries (one here only)
{* $Id: faqs_menu.tpl *}
{$lng.lbl_faqmenu_swarovski}


4. swarovski.php in xcart root (see why above)
<?php

# $Id: swarovski.php #

require "./auth.php";
require $xcart_dir."/include/categories.php";
$smarty->assign("main","swarovski");
$location[] = array(func_get_langvar_by_name("lbl_faqmenu_swarovski", ""));
# Assign the current location line
$smarty->assign("location", $location);
func_display("customer/home.tpl",$smarty);

?>

6. swarovski.tpl in ourpages. This is the content. Good Idea to save an "Empty" one to use as a dummy template for other entries.
{* $Id: swarovski.tpl *}

{include file="page_title.tpl" title=$lng.lbl_faqmenu_swarovski}
<!-- this table just adds an image and description of the page and is optional
<TABLE cellpadding="5">
<TR>
<TD>[img]{$ImagesDir}/swarovski.jpg[/img]</TD>
<TD>
{$lng.txt_swarovskiheader}
</TD></TR>
</TABLE>
-->

{capture name=dialog}

First a link to Swarovski Crystals ---- its in German !!!</h6>
<a href = "http://www.swarovski.com/index/" target="_blank">Swarovski Crystals</a>
etc ............................

{/capture}
{include file="dialog.tpl" title=$lng.lbl_faqmenu_swarovski content=$smarty.capture.dialog extra="width=100%"}

There. I hope someone finds this information useful.

vixnfox

balinor 04-09-2006 10:09 AM

Moving to Custom Mods.

pteerapr 04-15-2006 01:41 PM

this is a good one. Somebody was going to charge me $100 for this. Thank you.

balinor 04-15-2006 05:55 PM

Wow, somebody was about to rip you off :(

vixnfox 04-16-2006 06:03 PM

You can also split your main categories menu similarly by using the
Code:

$categories[cat_num].category}
to test for the name, as I have done here:

http://ifgdesignz.com.au/home.php

I can post the details if you want.

vixnfox

pteerapr 04-17-2006 12:55 AM

Yes, Please post the detail.

vixnfox 04-17-2006 02:02 AM

Splitting the category menu
 
Following on from above:
If you follow the link, here is how I made the photography menu.
Add the category as usual using Admin, it appears in the main category menu on the left.
Exclude the Photography and Restoration menus from categories.tpl
Code:

{section name=cat_num loop=$categories}
{assign var="tmp" value = $categories[cat_num].category}
{if $tmp ne "Photography" && $tmp ne "Restoration"}
<FONT class="CategoriesList">{$categories[cat_num].category}</FONT>

{/if}
{/section}


in home.tpl find
Code:

{ include file="customer/categories.tpl" }
and add this:
Code:



{include file="ourpages/photo_menu.tpl"}



This is photomenu.tpl
Code:

* $Id: photo_menu.tpl,v 1.23 2004/06/24 09:53:29 max Exp $ *}
{capture name=menu}
{if $active_modules.Fancy_Categories ne ""}
{include file="`$fancycategories_config.modules_path`/fancy_categories.tpl"}
{else}
{if $config.General.root_categories eq "Y"}
{section name=cat_num loop=$categories}
{assign var="tmp" value=$categories[cat_num].category}
{if $tmp eq"Photography"}
<FONT class="CategoriesList">{$categories[cat_num].category}</FONT>

{elseif $tmp eq "Restoration"}
<FONT class="CategoriesList">{$categories[cat_num].category}</FONT>

{/if}
{/section}
{else} {section name=cat_num loop=$subcategories}
<FONT class="CategoriesList">{$subcategories[cat_num].category}</FONT>

{/section}
{/if}
{/if}
{/capture}
{ include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_photomenu_content menu_content=$smarty.capture.menu }

... and add the label $lng.lbl_photomenu_content using Admin languages - in this case Photography.

The restoration part is not a category as such, and is added to home_main.tpl as a static page.
Code:

{elseif $main eq "restoration"}
{include file="./ourpages/restoration.tpl"}




vixnfox

pteerapr 04-17-2006 03:52 AM

thank you very much. I have already shared this code with other newbies. We were frustrated of not being able to add things on to the menu in the beginning.

pteerapr 04-18-2006 03:19 AM

do you know how to make the menu title itself become a link?

vixnfox 04-18-2006 04:08 AM

you can make the label a link in Languages ie:

Photography

but you might want to make the <a> tag a css class and make the visited link the same colour as the link itself.

eg:
Photography

Code:

.yourlink A:link {
        COLOR: #081589; TEXT-DECORATION: none;
}
.yourlink A:visited {
        COLOR: #081589; TEXT-DECORATION: none;
}
.yourlink A:hover {
        COLOR: #FF0000; TEXT-DECORATION: underline;
}
.yourlink A:active  {
        COLOR: #081589; TEXT-DECORATION: none;
}

FYI x-cart uses skin1.css in the root of skin1

vixnfox


All times are GMT -8. The time now is 10:39 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.