WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Number of products in menu
  • Print
Pages: [1]   Go Down

Author Topic: Number of products in menu  (Read 4195 times)

Offline D72

  • Posts: 295
  • Gender: Male
Number of products in menu
« 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)
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Number of products in menu
« Reply #1 on: July 20, 2012, 02:46:04 PM »
Quote from: 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?

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(1, SM2_ROOT, SM2_START+1, SM2_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...
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Number of products in menu
« Reply #2 on: July 20, 2012, 03:43:05 PM »
Very usefull, even adaptable for the news Module and others!

Regards,
Stefek
Logged
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline D72

  • Posts: 295
  • Gender: Male
Re: Number of products in menu
« Reply #3 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!
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Number of products in menu
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2