11 years ago
Topic

Hi,

I need to show in a Select Dynamic field of a Category Content Type, a limited list of subcategories of a Parent Category. To do that I've followed instructions on this useful tutorial How-can-i-limit-the-category-list-to-show-just-sub-categories-of-a-parent-category-or-just-specific-categories. So I create a Select Dynamic field capable to show Subcategories of a select Category, 

setting:

  • Where: parent_id=25 and published=1

and changing the storage from: 

  • Standard ---> Article ---> catid as it is wrote in the tutorial
to 

  • Standard ---> Category ---> parent_id
And it works. I could create a SubCategory.
But now I need to create Articles in the just created SubCategory, and this method doesn't shows SUB-subcategories of the selected parent_id, unlike the standart "Category id" does. If I use the same parent_id=25 it shows only subcategories which has parent_id set to 25 and not their SUB-subcategories.

Ok probably is a little bit confused but... my question is:
Is there a way to use Select Dynamic Field also to show SUB-SubCategories (not only subcategories) of a Parent Category?

Thanks
abram

Get a Book for SEBLOD
5 Posts
mrbwt
11 years ago
1
Level 1

Hi Abram,

Not sure if there's an easier way but this is what worked for me, so hopefully will work for you too.

In the 'Select Dynamic' field, you can set the 'Query' drop down to 'Free' and add your own SQL. Paste this into the 'SQL Query' box:

SELECT CONCAT( REPEAT('-', (category.level)-1), category.title) AS text, category.id AS value  
FROM #__categories AS category
LEFT JOIN  #__categories AS parent
  ON category.lft BETWEEN parent.lft AND parent.rgt
WHERE parent.id = 25 ORDER BY category.lft

Then set the storage as 'catid'.

You can edit the SQL to remove the hypens if you don't need them, they're just there for formatting the dropdown.

Hope that helps,

MRBWT

58 Posts
rasch-dmd
10 years ago
0
Level 2
It works. Thank you a lot.
rasch
Get a Book for SEBLOD