Categories in Drop Down Menu
13 posts by 4 authors in: Forums > CMS Builder
Last Post: April 24, 2010 (RSS)
By InHouse - January 22, 2010
Failing that, can we limit the options displayed in the drop down menu to, say, 1st Child level items only and exclude the Parent items?
If not, I think this might be a "wish list" item.
J.
Re: [InHouse] Categories in Drop Down Menu
By Chris - January 25, 2010 - edited: January 25, 2010
If you're using getCategories (as opposed to getRecords) then either of these requirements are possible.
To indent child items, you can get the "depth" of the current record (which will be a number,) and use it to repeat a string. This is how the CMSB backend does it, and you can do it the same way:
<?php echo str_repeat(" ", @$record['depth']) ?>
I hope this helps. Please let me know if you have any questions.
Chris
Re: [chris] Categories in Drop Down Menu
By InHouse - January 26, 2010
This info will be useful however when we come to expose some of this site on the front-end.
J.
Re: [InHouse] Categories in Drop Down Menu
By Chris - January 26, 2010
If you set this field option:
Use this field for option labels: breadcrumb
your dropdowns will differentiate parentage like this:
fruits
fruits : apples
fruits : oranges
This works best with short category names.
I hope this helps! Please let me know if you have any questions.
Chris
Re: [chris] Categories in Drop Down Menu
By InHouse - January 26, 2010
Many thanks Chris.
Jayme
Re: [chris] Categories in Drop Down Menu
By videopixel - April 13, 2010
Hi J,
If you set this field option:Use this field for option labels: breadcrumb
your dropdowns will differentiate parentage like this:fruits
fruits : apples
fruits : oranges
This works best with short category names.
I hope this helps! Please let me know if you have any questions.
True! But in my case i have alot of categories with subs and i want only to see the fruits categories in the back-end, how to approach that?
Re: [videopixel] Categories in Drop Down Menu
By Chris - April 14, 2010
Would it suffice to move your fruits category to the top so that users see it first?
If that won't do, you can set List Options to "Get options from MySQL query (advanced)", then use a query like this:
SELECT num, name
FROM `<?php echo $TABLE_PREFIX ?>tableName`
WHERE lineage LIKE ':123:%'
...substituting in the value field, label field, table name, and the record number of the (top-level) category of your fruits category (all respectively in red above.) To figure out a record's record number, modify it and look in your address bar -- the num will be at the end like this:
http://example.com/cmsAdmin/admin.php?menu=tableName&action=edit&num=123
I hope this helps. Please let me know if you have any questions.
Chris
Re: [chris] Categories in Drop Down Menu
By (Deleted User) - April 20, 2010
In category list I would have
TYPE 1
TYPE 1 : ITEM 1
TYPE 1 : ITEM 2
TYPE 1 : ITEM 3
TYPE 2
TYPE 2 : ITEM 1
TYPE 2 : ITEM 2
TYPE 2 : ITEM 3
Any way to get the admin drop down on the back end to shop the following to users:
TYPE 1 : ITEM 1
TYPE 1 : ITEM 2
TYPE 1 : ITEM 3
TYPE 2 : ITEM 1
TYPE 2 : ITEM 2
TYPE 2 : ITEM 3
?
Re: [AlanMacDonald] Categories in Drop Down Menu
By Chris - April 20, 2010 - edited: April 20, 2010
Try this:
SELECT num, name
FROM `<?php echo $TABLE_PREFIX ?>tableName`
WHERE depth > 0
I hope this helps. Please let me know if you have any questions.
Chris
Re: [chris] Categories in Drop Down Menu
By (Deleted User) - April 21, 2010
Unfortunately, that shows:
ITEM 1
ITEM 2
ITEM 3
ITEM 1
ITEM 2
ITEM 3
instead of
TYPE 1 : ITEM 1
TYPE 1 : ITEM 2
TYPE 1 : ITEM 3
TYPE 2 : ITEM 1
TYPE 2 : ITEM 2
TYPE 2 : ITEM 3
i.e., the prefix is lost. Since some items are duplicated, that means we have duplicate entries on the list :(
rgds
Alan