WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Bakery Shop => Topic started by: D72 on July 19, 2012, 10:30:07 PM

Title: Number of products in menu
Post by: D72 on July 19, 2012, 10:30:07 PM
Simple question, maybe a difficult feature...
Does anyone know if it's possible to create the number of products behind the menu item?

Code: [Select]
ATB (19)
Crossroad (13)
Electric bikes (136)
Hybride bikes (85)
Kids bikes (273)
Mother bikes (19)
Track bikes (27)
Specials (23)
Title: Re: Number of products in menu
Post by: Ruud on July 20, 2012, 02:46:04 PM
Simple question, maybe a difficult feature...
Does anyone know if it's possible to create the number of products behind the menu item?

A fun challenge :)

create the following droplet, and name it something like "count":

Code: (droplet) [Select]
<?php
if(!isset($p)) return true;
global 
$database;
$data $database->get_one("select count(page_id) from ".TABLE_PREFIX."mod_bakery_items where `page_id` = '$p' group by `page_id`");
if(
$data) return ' ('.$data.')';
return 
true;

Next modify your show_menu2 call to something like:
Code: [Select]
<?php show_menu2(1SM2_ROOTSM2_START+1SM2_ALL'[li][a][menu_title] [[count?p=[page_id]]]</a>');?>
Especially the part
Code: [Select]
'[li][a][menu_title] [[count?p=[page_id]]]</a>' is where the droplet is inserted in the menu output.

If the link is a bakery-page, it should now add the itemcount to the menu.

Have fun...
Title: Re: Number of products in menu
Post by: Stefek on July 20, 2012, 03:43:05 PM
Very usefull, even adaptable for the news Module and others!

Regards,
Stefek
Title: Re: Number of products in menu
Post by: D72 on October 22, 2012, 12:03:10 PM
Ruud, never took the time to reply on this topic.
But your droplet works amazing! Besides me, the customer i really happy with it.
All credits to you. Thank you!