Zen Cart Logo
Forums / Contribution-Writing Guidelines / Gaining control over header menu

Gaining control over header menu

Locked

Views: 10,262

Results 1 to 20 of 30
This thread is locked. New replies are disabled.
20 Jun 2009, 1:26 PM
#1
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Gaining control over header menu

I am modifying my cart (v1.3.8) to add control over which top-level categories' links show in the header menu.

So far I've:

  • added a column to the categories table called 'menu_status', which will have a value of 1 or 0.
  • edited the sql query in the header that retrieves the top-level categories to build the header links menu
  • edited the admin/categories.php file to show a radio group (modeled after another radio group on that page) while action='edit_category', but they do not work yet

At this point I can manually edit the db 'menu_status' value 1 or 0 and control which categories show links in the header. :cool:

So my question - where are the sql queries for admin/categories.php that select and update a category when editing? :blink:

Thanks very much!

14 Nov 2009, 4:27 PM
#2
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: Gaining control over header menu

Got this working! I now have full control over which top-level categories display in the header menu. Control is from simple red/green buttons (like Category/Product Status) in the Categories/Products table in the ACP. If anyone is interested in this code, please PM me and I'll get you the instructions.

14 Nov 2009, 4:30 PM
#3
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Gaining control over header menu

It would be VERY NICE to see some in-depth detail here... Look at how "popular" your post is... :smile:

14 Nov 2009, 7:39 PM
#4
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: Gaining control over header menu

schoolboy:

It would be VERY NICE to see some in-depth detail here... Look at how "popular" your post is... :smile:
I'd be happy to answer any questions I can, but I don't know how 'popular' the thread is, you are the only other person to post in it! :shocking:
In the screenshot below, you can see the Header Navigation Menu, which ZC normally populates with all your top-level categories. I added a new column to the 'Categories - Top' page in the admin with buttons that control if each category will display in the header nav menu. Note that if the regular 'Category Status' is off, it will act as it did before and not display in the menu.

http://www.bassface3d.com/uploads/headercontrol.jpg
14 Nov 2009, 8:42 PM
#5
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: Gaining control over header menu

Definitely interested in this! Could you please post the step-by-step? This would be worth packaging up for the contributions section. Thanks for sharing!!

14 Nov 2009, 9:06 PM
#6
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Gaining control over header menu

I have to agree, this would make a good add-on module.

14 Nov 2009, 10:51 PM
#7
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Gaining control over header menu

BassFace:

I'd be happy to answer any questions I can, but I don't know how 'popular' the thread is, you are the only other person to post in it!

... but nearly 1000 have looked at it...

(Almost better results than an "adult" site ! )

15 Nov 2009, 6:55 PM
#8
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: Gaining control over header menu

lankeeyankee:

Definitely interested in this! Could you please post the step-by-step? This would be worth packaging up for the contributions section. Thanks for sharing!!
Working on making this a contribution; turning text into language constants and writing up install instructions. Stay tuned.... :smile:

16 Nov 2009, 9:34 PM
#9
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: Gaining control over header menu

Could someone give this a try before I submit it as a Contribution and post back here with their results?

HeaderMenuControl.zip

Thanks! :cool:

16 Nov 2009, 11:02 PM
#10
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Gaining control over header menu

BassFace:

Could someone give this a try before I submit it as a Contribution and post back here with their results?

HeaderMenuControl.zip

Thanks! :cool:

You've only provided one file to be uploaded.

As a general rule you should provide ALL the files necessary for the mod to work.

  • admin/categories.php
  • admin/includes/modules/category_product_listing.php
  • admin/includes/languages/english/extra_definitions/header_menu_control.php
  • includes/modules/categories_tabs.php
    (Just make sure you've add comments to the changed files where you made the edits:
    //BOF header menu control

//EOF header menu control

provide the necessary sql file (header_menu_control.sql)

Make sure you note in the readme.txt file that the mod does overwrite 3 core files.

Make sure you include an install.txt file with the mod. (this is in addition to the html files

16 Nov 2009, 11:08 PM
#11
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: Gaining control over header menu

clydejones:

You've only provided one file to be uploaded.

As a general rule you should provide ALL the files necessary for the mod to work.

  • admin/categories.php
  • admin/includes/modules/category_product_listing.php
  • admin/includes/languages/english/extra_definitions/header_menu_control.php
  • includes/modules/categories_tabs.php

(Just make sure you've add comments to the changed files where you made the edits:
//BOF header menu control

//EOF header menu control

provide the necessary sql file (header_menu_control.sql)

Make sure you note in the readme.txt file that the mod does overwrite 3 core files.

Make sure you include an install.txt file with the mod. (this is in addition to the html files

OK, I'll make those changes and package it up agian. I'm used to doing MOD work for phpbb3, and followed their packaging guidelines, (and borrowed their xml/xsl form for install files, too LOL). :blush:

16 Nov 2009, 11:23 PM
#12
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Gaining control over header menu

BassFace:

OK, I'll make those changes and package it up agian. I'm used to doing MOD work for phpbb3, and followed their packaging guidelines, (and borrowed their xml/xsl form for install files, too LOL). :blush:

Check this article in the Tutorials/FAQ section

www.zen-cart.com/tutorials/index.php?article=11

16 Nov 2009, 11:28 PM
#13
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: Gaining control over header menu

clydejones:

Just make sure you've add comments to the changed files where you made the edits:
//BOF header menu control

//EOF header menu control

How should I comment replaced code? ie. a sql select statement in category_product_listing.php is changed from

$categories = $db->Execute("select c.categories_id, cd.categories_name, cd.categories_description, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.categories_status
```to this
```php
$categories = $db->Execute("select c.categories_id, cd.categories_name, cd.categories_description, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.categories_status, c.menu_status

Should I comment out the entire original code block and then add mine in with the //BOF...//EOF comments?

Thanks for your help, by the way! :smile:

17 Nov 2009, 1:30 AM
#14
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Gaining control over header menu

BassFace:

How should I comment replaced code? ie. a sql select statement in category_product_listing.php is changed from

$categories = $db->Execute("select c.categories_id, cd.categories_name, cd.categories_description, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.categories_status

> ```php
$categories = $db->Execute("select c.categories_id, cd.categories_name, cd.categories_description, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.categories_status, c.menu_status

Should I comment out the entire original code block and then add mine in with the //BOF...//EOF comments?

Thanks for your help, by the way! :smile:

I'd just do this

//Header Control Menu changed 11/16/2009
$categories = $db->Execute("select c.categories_id, cd.categories_name, cd.categories_description, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.categories_status, c.menu_status  
//Header Control Menu
17 Nov 2009, 2:43 PM
#15
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: Gaining control over header menu

clydejones:

Check this article in the Tutorials/FAQ section

www.zen-cart.com/tutorials/index.php?article=11

Wow, compared to phpBB3, those are some pretty sparse requirements, LOL. :lamo:

17 Nov 2009, 3:57 PM
#16
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: Gaining control over header menu

OK, I've repackaged the mod files, in the manner clydejones suggested. Thanks again!

HeaderMenuControl.zip

17 Nov 2009, 6:06 PM
#17
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Gaining control over header menu

BassFace:

OK, I've repackaged the mod files, in the manner clydejones suggested. Thanks again!

HeaderMenuControl.zip

This is much better.

The mod works just fine. I set it up on my local server without problems.

One thing to change in the "install.txt"

Change this:

#-----[ SQL ]------------------------------------------

Run the header_menu_control.sql file in the SQL window of your database manager.

To This:

run the header_menu_control.sql file using the Zen-Cart Sql Patches tool

(admin -> tools -> install sql patches)

For best results, copy-and-paste the code into the query field and press 'Send'.

18 Nov 2009, 1:24 AM
#18
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: Gaining control over header menu

clydejones:

This is much better.

The mod works just fine. I set it up on my local server without problems.

One thing to change in the "install.txt"

Change this:

#-----[ SQL ]------------------------------------------

Run the header_menu_control.sql file in the SQL window of your database manager.

To This:

run the header_menu_control.sql file using the Zen-Cart Sql Patches tool

(admin -> tools -> install sql patches)

For best results, copy-and-paste the code into the query field and press 'Send'.

Cool, I'll make that change and submit the contribution. Glad it installed and worked easily for you. Thank you for trying it out. Nice to see another Colorado resident here, too. :cool:

18 Nov 2009, 3:21 AM
#19
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Gaining control over header menu

BassFace:

Cool, I'll make that change and submit the contribution. Glad it installed and worked easily for you. Thank you for trying it out. Nice to see another Colorado resident here, too. :cool:

There are several Coloradons on the forum.

One thing you also might want to point out in the install.txt in exactly where the header menu option is located and that you only need to click the red/green button to enable/disable it.

18 Nov 2009, 2:47 PM
#20
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: Gaining control over header menu

Ya know, I just realized I'm using your Cold Steel template on a site! :bigups: