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

pteerapr 04-18-2006 04:35 AM

thank you

pteerapr 04-20-2006 05:36 PM

How can you make the file under new category menu which is photography, appear in the admin area so that it can be delete and rename just like the menu item under the first main menu.

vixnfox 04-21-2006 01:17 AM

I dont know what you mean by that. Photography appears in Admin on my xcart just like any other category.

vixnfox

liquorsruz 05-08-2006 01:24 PM

Could this method be used in the regular categories menu? I recently installed Fancy Categories and it isn't working properly. I even tried it on 2 different servers with the same results.

I just want the site to have a simple + and - categories menu.

So could I use the code here in the categories.tpl somewhere?

Thank You,

Alex
4.1 Gold

vixnfox 05-09-2006 05:16 PM

Hi Alex,
I am not an expert by any means when it comes to the innards of X-cart. I made this menu because I needed it. However, there is no reason why you cannot "filter" any category in any menu by testing for the value $categories[cat_num].category or categoryid for EXclusion, and testing for INclusion in your own menu as I did in photomenu.tpl
Apart from this suggestion, Im sorry I cannot be of more help.

vixnfox

liquorsruz 05-10-2006 11:19 AM

thank you vixnfox.

Alex

ecommerce 08-04-2006 09:27 PM

good job vix! im glad u came to share it

laurieblake 08-31-2006 04:01 PM

Re: How to Add a Simple Custom Menu
 
Hey vixnfox, who is hosting your website it is really fast, and looks good too. Mine is as slow as a decade of sundays. Have you done anything special to speed it up? I am down under like you and confused about who else hosts IN AUS.

Thanx
laurieblake

vixnfox 08-31-2006 04:41 PM

Re: How to Add a Simple Custom Menu
 
Hi laurie
it is hosted through
http://www.netregistry.com.au/
they are based in melbourne I think. Nothing special has been done, AND at the moment its running as php based. You get a top quality support team, phpMyAdmin and all sorts of goodies. I simply FTPd the shop from home as is, changed config.php and there it is. Glad you like the speed. The layout and colours were modded by me.

vixnfox

laurieblake 08-31-2006 04:53 PM

Re: How to Add a Simple Custom Menu
 
Wow vinfox, that is who is hosting mine! I resell their hosting packages & my client's websites run quite well on their hosting but my shop is just sooo sloooow. They just shrug and blame x-cart for being so slow. But yours is many times faster than mine. My site is reasonable between 11pm and 7am. Then obviously it is over utilised to the extent that it is unusable. That is even following all the recommended optimisations and even with just a blank shop with no images and one product.
I'll keep working on them to move me onto another box.

Thanks for your reply.
Laurie

vixnfox 08-31-2006 05:20 PM

Re: How to Add a Simple Custom Menu
 
well bugger me!!! Thats bizarre. Perhaps its slow from your PC like mine is. Whats the URL, Ill see if its slow from my puter.

vixnfox

laurieblake 08-31-2006 06:21 PM

Re: How to Add a Simple Custom Menu
 
Quote:

Originally Posted by vixnfox
well bugger me!!! Thats bizarre. Perhaps its slow from your PC like mine is. Whats the URL, Ill see if its slow from my puter.

vixnfox

it is www.iconnect.com.au/shop/home.php?shopkey=test

I have a 24Mbit ADSL and its pretty fast connection.
please have a go and let me know.

Cheers
laurieblake

vixnfox 08-31-2006 08:59 PM

Re: How to Add a Simple Custom Menu
 
Had a look, closed and re-entered to make sure any cache was present, still took around 28secs.....same when using back button on browser(Firefox). Site looks nice tho!!!! Did you mod all the templates yourself?

vixnfox

vipstore 09-01-2006 12:18 AM

Re: How to Add a Simple Custom Menu
 
Quote:

Originally Posted by vixnfox
Might be worthy of a sticky considering all the requests :) *tap tap mods? *

[...]



Say you wanted to list all the products for that category (the one your FAQ is referencing) on that page. Any idea on how that would be done?

laurieblake 09-01-2006 12:29 AM

Re: How to Add a Simple Custom Menu
 
Quote:

Originally Posted by vixnfox
Had a look, closed and re-entered to make sure any cache was present, still took around 28secs.....same when using back button on browser(Firefox). Site looks nice tho!!!! Did you mod all the templates yourself?

vixnfox


Thank you. Can't claim i did. The look is from Crystal Blue Skins (compliments of the addon i puchased from x-cart) and the theme is "education". I am not sure who is educating who but it looks OK. I really didn't like the standard skin. But still, the shop required a lot of buggerising around with templates to add all the other mods i had to do. And x-cart has changed something with the code syntax like with embedding images etc. I haven't uploaded all changes yet as i am using uniform server and a copy of the shop on a local machine because it was just too slow to work with the real site. I am now trying to figure out how to do all my updates by ODBC. It is so much faster than the CSV import. Thanks again NetRegistry. I would have not bothered, cut my losses and run if i had to do all the work on the live site. Still thinking of doing that anyway.

I noticed in the manual that RRF is saying x-cart is open source. Makes it very interesting.

Cheers,

laurieblake

vixnfox 09-01-2006 01:04 AM

Re: How to Add a Simple Custom Menu
 
vipstore.....
not quite sure what you mean
"list all the products for that category (the one your FAQ is referencing) on that page"
The FAQ menu pages are just php pages. The components/findings menus on the other hand is actual caregories. Did you want to know how eg the Swarovski products were generated in that menu?

vixnfox

vipstore 09-01-2006 01:37 AM

Re: How to Add a Simple Custom Menu
 
Quote:

Originally Posted by vixnfox
vipstore.....
not quite sure what you mean
"list all the products for that category (the one your FAQ is referencing) on that page"
The FAQ menu pages are just php pages. The components/findings menus on the other hand is actual caregories. Did you want to know how eg the Swarovski products were generated in that menu?

vixnfox


guess my question wasn't framed right...

let's say you wanted to display actual products on your faq (for instance) page (pulled from a particular category), & not just the category names...am wondering how that might be done on a static page such as this...

nice site, though!

vixnfox 09-01-2006 04:00 AM

Re: How to Add a Simple Custom Menu
 
hmmmmm..... ill have a look and get back later

Cambo 09-04-2006 09:44 PM

Re: How to Add a Simple Custom Menu
 
Can somebody please explain this little bit?

how/where do I create admin languages?

Quote:

Originally Posted by vixnfox
Create:
admin Languages
lbl_faqmenu_content name FAQ Menu Content, Value Jewellery FAQs
lbl_faqmenu_swarovski name Swarovski FAQ, Value Swarovski Crystals

vixnfox


vipstore 09-05-2006 03:41 AM

Re: How to Add a Simple Custom Menu
 
Quote:

Originally Posted by Cambo
Can somebody please explain this little bit?

how/where do I create admin languages?


in the admin section >> languages...

Cambo 09-05-2006 04:05 AM

Re: How to Add a Simple Custom Menu
 
Quote:

Originally Posted by laurieblake
I am down under like you and confused about who else hosts IN AUS.
laurieblake


You could try Grant at The Web Factory <http://www.webfactory.com.au/> he hosts my X-Carts and the speed is good.

vixnfox 09-05-2006 04:12 PM

Re: How to Add a Simple Custom Menu
 
vipstore....
the products page is generated using numerous variables such as products per page as set in your store settings. While there probably is a way to put a product on a static page so it behaves like any other product from your normal categories. Im thinking you could create your own customer/main products.tpl and product.tpl templates and hijack the loop.categories and loop.products much the same way as filtering the categories for the custom menu. Its a good idea tho - custom product pages.

vixnfox

Cambo 09-09-2006 10:27 PM

Re: How to Add a Simple Custom Menu
 
When I add the admin > languages > english > add new entry > select topic > languages > variable : lbl_faqmenu_content

I get the following error message "The label name contains a restricted character. Please choose a different name."

X-Cart 4.1.3 this time

vixnfox 09-09-2006 10:56 PM

Re: How to Add a Simple Custom Menu
 
ok you dont select "languages" from your "select Topic". You want it to be either a label or text. The text option allows you to write quite lengthy HTML eg:
Select Topic -> Text
variable name = txt_yourname, Value = " <font color ="red"> Welcome to my nightmare</font><br><h4>Hope you enjoy the view</h4><br>

labels are a little more restrictive since they are meant more for item descriptors.eg

Select Topic->Label
variable name = lbl_mymenuname, value ="X-Rated Videos"

try that

vixnfox

Cambo 09-09-2006 11:15 PM

Re: How to Add a Simple Custom Menu
 
Thanks vixnfox, It turns out the invalid character was a space, I was including everything up to th word "value" as the "variable" but more correctly it is

"Select topic" > label (or text I guess)

"Variable" > lbl_faqmenu_swarovski

"Value" > name Swarovski FAQ, Value Swarovski Crystals

cheers,

Cambo 09-10-2006 12:19 AM

Re: How to Add a Simple Custom Menu
 
I may be getting a bit lost here.

I managed to create the new menu <http://joe.webfactory.com.au/xcart/home.php> it is now called "new equipment" under "used equipment" .

I don't know where the category listing swarovski crystals has gone :-(

Now, how do I get some of the categories currently residing under used equipment to move down and be automatically listed under new equipment?

Alternatively, how do I assign product categories to the "New Equipment" menu? They currently all list under used equipment (which used to be called "categories") in the admin.

vixnfox 09-10-2006 02:29 AM

Re: How to Add a Simple Custom Menu
 
Hi Cambo,
First of all, since I wrote this I have learned a bit more about how x-cart works, and I have simplified the process. If you notice on my page
http://ifgdesignz.com.au
I have added a category menu also. Lets use your example to create a custom menu. This is a pure categories menu. Note: I have put created files in skin1\customer
Firstly, lets create your "New Equipment Menu" - which you have already done:
1. skin1\customer\home.tpl

{if $categories ne "" and ($active_modules.Fancy_Categories ne "" or $config.General.root_categories eq "Y" or $subcategories ne "")}
{ include file="customer/categories.tpl" } {* This is x-carts category menu *}

<br>
{include file="customer/new_equipment.tpl" } {* this is your new menu *}

2. new_equipment.tpl

{* $Id: new_equipment.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].categoryid}
{if $tmp > 500}
<FONT class="CategoriesList"><A href="home.php?cat={$categories[cat_num].categoryid}" class="VertMenuItems">{$categories[cat_num].category}</A></FONT><BR>

{/if}
{/section}
{else} {section name=cat_num loop=$subcategories}
<FONT class="CategoriesList"><A href="home.php?cat={$subcategories[cat_num].categoryid}" class="VertMenuItems">{$subcategories[cat_num].category}</A></FONT><BR>
{/section}
{/if}
{/if}
{/capture}
{ include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_new_equipment menu_content=$smarty.capture.menu }

Note that this is essentially the same as categories.tpl except for the lines:
Code:

{assign var="tmp" value=$categories[cat_num].categoryid}
{if $tmp >500}
<FONT class="CategoriesList"><A href="home.php?cat={$categories[cat_num].categoryid}" class="VertMenuItems">{$categories[cat_num].category}</A></FONT><BR>
{/if}


3. and in Categories.tpl
Code:

{assign var="tmp" value=$categories[cat_num].categoryid}
{if $tmp < 501}
<FONT class="CategoriesList"><A href="home.php?cat={$categories[cat_num].categoryid}" class="VertMenuItems">{$categories[cat_num].category}</A></FONT><BR>
{/if}


Note carefully the filter for the category ID numbers. This was a bit tricky to do. If you go into phpmyadmin and look at the xcart_categories table you can easily retrieve the category ID numbers for your filter. Unfortunately, If you add a new category, xcart assigns the next highest number for the category ID and this can stuff things up. You have two choices, and unchecking autoincrement is not the wisest. Here is what I suggest.
Find the highest category id number in your xcart_categories table, lets say its 200.
To add your new category to your new menu, create a new category, go into phpmy admin and find it then change its category id to, say 501 BEFORE you add any products. Can you see where this is going? Then you simply filter:
{if $tmp < 501} in categories.tpl and
{if $tmp > 500} in new_equipment.tpl
To add another category to your main menu, just follow the same steps and pick a number < 501 that hasnt already been used. You can have as many menus as you like, and although there is probably a far better way to do it, this way costs you nothing.

For information, the category ID is used in the following xcart tables:
xcart_categories
xcart_products_categories
xcart_categories_subcount
but im pretty sure that the other two table entries are not filled in until you add a product to the menu. BTW xcart will increment the highest number when you add a category, so if your new menu is the one you add a category to, it will have an ID of 502.

If you can follow all of this, then the
Quote:

Now, how do I get some of the categories currently residing under used equipment to move down and be automatically listed under new equipment?
problem should be solved.

Note also that if you already have products in a category you want to move to another menu (in your case probably) you WILL have to find and replace the category ID in the THREE tables or create categories with a slightly different name, change the ID and re-assign the products to the new category, delete the old one and rename it back to what you want. errrrrr. That might have confused you now sorry, but thats actually how I did it, lucky I didnt have too products yet.

I dont know if this is allowed, but I have started a new thread with this reply for further discussion, find it here

http://forum.x-cart.com/showthread.php?t=24790

vixnfox

vixnfox 09-11-2006 06:29 PM

Re: How to Add a Simple Custom Menu
 
CODE REWORKED NEW BETTER METHOD POSTED

http://forum.x-cart.com/showthread.php?t=24790


vixnfox

fmoses 01-06-2009 04:38 PM

Re: How to Add a Simple Custom Menu
 
I can't seem to get this to work, I got the added box, but i just can't get the links to come through. see www.anythingindian.biz the free stuff section. Basically I'm trying to move the created pages from the help section to this new section that i wanted to create. I'm not very experienced and just work by trial and error with a lot of backing up of files. But what i'v enoticed is that it doesn't seem to link or acccess the indiannews.php, or indiannews.php and make it a viable link. I can totally omit those two files, and it doesn't affect the look or the function. Now under the lbl though in languages i remove Indian News and place the line <a href = "http://www.anythingindian.biz/store/news-from-india-pg-28.html" target="_blank">Indian News</a> it becomes a link again. I'm not sure if this is the correct way of doing it. Also if this is the method, how do i add more menu items to that box, as i'd like to move many of the items from the help menu to this box. I added another label and added it to the frestuffmenu.tpl file and it shows it right next to the previous link not below it. Also the distance of the text from the left doesn't match the other boxes. How do i correct that as well.

These are the contents of the files i have, and i made the labels, and edited the two files accordingly.

indiannews.php
<?php

# $Id: indiannews.php #

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

?>


freestuffmenu.tpl
{* $Id: freestuffmenu.tpl *}
{$lng.lbl_freestuffmenu_indiannews}

indiannews.tpl
{* $Id: indiannews.tpl *}

{include file="page_title.tpl" title=$lng.lbl_freestuffmenu_indiannews}
{capture name=dialog}
<a href = "http://www.anythingindian.biz/store/news-from-india-pg-28.html" target="_blank">Indian News</a>
{/capture}
{include file="dialog.tpl" title=$lng.lbl_freestuffmenu_indiannews content=$smarty.capture.dialog extra="width=100%"}

Not sure where i went wrong, if anyone can show me, thanks.

fmoses 01-13-2009 11:27 PM

Re: How to Add a Simple Custom Menu
 
It's cool got it too work, used the following article

http://forum.x-cart.com/showthread.php?t=24054&highlight=creating+a+new+me nu+for+static+pages

and worked perfectly for what i needed. I wish they had a better search in this forum cause it's really tough to find things some times.


All times are GMT -8. The time now is 03:00 PM.

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