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

Quickie: Any way to indent child items from a Category list when they are shown in a drop down menu elsewhere in the CMSB backend?

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

Hi J,

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("&nbsp; &nbsp; &nbsp;", @$record['depth']) ?>

I hope this helps. Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Categories in Drop Down Menu

By InHouse - January 26, 2010

Thanks Chris, but I should have been clearer. This is for use in the backend so that Admin-type users can see the categories in a menu which differentiates between the level (parentage) of the cat. item.

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

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.
All the best,
Chris

Re: [chris] Categories in Drop Down Menu

By InHouse - January 26, 2010

That's the bunny! I knew the brain trust at Interactive Tools would have a solution for we mere mortals. Works like a charm.

Many thanks Chris.

Jayme

Re: [videopixel] Categories in Drop Down Menu

By Chris - April 14, 2010

Hi videopixel,

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.
All the best,
Chris

Re: [chris] Categories in Drop Down Menu

By (Deleted User) - April 20, 2010

Ok, my request here is similar -

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

Hi Alan,

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.
All the best,
Chris

Re: [chris] Categories in Drop Down Menu

By (Deleted User) - April 21, 2010

Hi,

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