10 years ago
7
Topic

Hi, is it possible to use Selct Dynamic Cascade Field with Categories?

Select Category Level 1 --> Show Categoeries Level 2 --> Select Level 2 ---> Show Level 3

Or is it possible in an other way?

Get a Book for SEBLOD
4229 Posts
Kadministrator
10 years ago
1
Level 1

Yes, this is possible. Categories table has parent_id column, so e.g. for level 1 you would select all categories that have some fixed top category e.g. with id 5 as parent. Then in next level you would set parent_id as "parent" field, connection this select with previous one, the same in next select etc.

10 years ago
0
Level 2

Hi Klas,

I am using this method for the user to choose the article category, but the category is not saved.

What I'm doing, to be precise, is a Cascade Select Dynamic Field to the parent category, and currently are 5 subcategories conditioned that appear in Select Dynamic Cascade Field too. The conditions say that when the Select Field Dynamic Cascade the parent category has the indicated value (eg 5) then the Select Dynamic Cascade Field 5 Field subcategory appears, getting the "visible" and "active" options if the parent field becomes with the value equal to 5, if the parent field is different from 5 gets the "hidden", "disable" and "empty" options.

Something that I think I am doing wrong is that all fields are guarding the "catid" (normal || article || catid).

Would greatly appreciate the help, 

I'm posting here because it seems a pertinent question for the topic, but if I need to open another topic, just say so. ;)

Thanks in advance,
BN

4229 Posts
Kadministrator
10 years ago
1
Level 1

Hi,

if your purpose is to store only last level category then only that select should have standard-article-catid as storage (the same storage as it is in article category field), otherwise selcts will be overwritting each other.

10 years ago
0
Level 2

Hi Klass,

That makes sense, but if the user select only the first level because it does not know which sub-category or subcategory does not have to choose, I need to save the first value. Ie catid will always be the last level filled.

For example, imagine this scenario:
- products
- Cars
--- bMW
--- toyota
--- ford


Given these categories, imagine that the user has a toyota car, then selects (lv1-cars) and (lv2-toyota), the category of the article is toyota.

A second user has a opel car, then selects (lv1-cars) but does not select any lv2 because the category of your article does not exist, then the category is to keep the (lv1-cars).

I do not know if I'm dreaming big, but I hope it is possible to do.

BN

10 years ago
0
Level 1

Hello everybody.

After talking with Klas, I had an idea that worked flawlessly.

The solution is actually quite simple.

Explaining what I did:

Cascade Select Dynamic Field for all categories.

Storing each in the database as (normal || article || [fieldname]).

Cascade Select Dynamic Field of the parent category is always visible, then just play with the conditions of the Cascade Select Dynamic Field of subcategories to appear and disappear depending on the chosen option of the parent category option.

The trick is an extra text field where the category is calculated.

For it to work, I made changes in subcategories value, where you set the value to "id", simply decrement the value of the parent category.

In other words, if the subcategoriaA appears when the parent category is 58, then the value of subcategoriaA is "id-58".

The text field is calculated by the sum of all categories (Category + SubcategoriaA + ... + SubcategoriaZ) and save it in the database as (normal || article || catid).

Hope this helps anyone who has the same problem.

And thank you for your time and help Klas.

cya,
BN

10 years ago
1
Level 1

Hi BN,

Thank you for your last post.

If you can, next time, to set as solved a topic when you find a solution.

Regards,
Mehdi.

10 years ago
0
Level 2

Hi Mehdi,

Sorry, I didn't know that I could mark it as solved when the topic isn't mine.

Cya,

BN

Get a Book for SEBLOD