248 Posts
Giuse
8 years ago
6
Topic

Hi, does select dynamic cascade support dynamically setting the table from which retrieving the values? I mean, instead of typing the name of the table, typing a select that retrieves the name of the table.

Imagine for example an inventory of product. Each product type is stored in its table (and is a different content type): when using a select dynamic cascade to first select the type of product and then the product item, since product items are stored in different tables according to types, the select dynamic cascade should pick up values from different tables, so the source table parameter is the result of a query that retrieves the table name in another table of product types <=> products tables.

Is it supported?

thanks

Giuse

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

Hi,

this is not possible directly, but you can do it in a different way - use normal select (or select dynamic) to show product types, then using conditionals show the right select dynamic to pick items - create one for each product type.

248 Posts
Giuse
8 years ago
0
Level 2

Hi, thanks, I knew it could be done like that but it is feasible just for a small number of product type. Can it be added as a feature request? It should not be that cumplicated (launching the select before for the FROM clause), it may be a good enhancement for this very useful plugin.

thanks

cheers

Giuse

4229 Posts
Kadministrator
8 years ago
2
Level 1

Actually, you can already do this I think - using free query mode you could do sth like this in the second select if you have a table that holds all your content types names and ids (the same as you would need for the first select) - you jsust need a subquery in FROM (and perhaps also a concat to add #__ )

SELECT pi.name as text, pi.id as value FROM (SELECT ct.name FROM #content_types_table AS at WHERE ct.id=[parent]) AS pi
248 Posts
Giuse
8 years ago
1
Level 2

Hi, I made a few tests without success, trying to debug the problem I found that in the freeform

SELECT pi.name as text, pi.id as value FROM #table_name AS pi

works, while just

SELECT pi.name as text, pi.id as value FROM (#table_name) AS pi

adding parentheses does not work..., so it is not possible to put a sub-SELECT inside...?

thanks

Giuse

248 Posts
Giuse
8 years ago
0
Level 3

Hi, just kindly bumping: are parentheses supported in free form...? Seems not from my tests but maybe I am doing something wrong

thanks!

Giuse

4229 Posts
Kadministrator
8 years ago
0
Level 1

Free mode just runs mysql query (with few replacements like [parent] which gets replaced by value from previous cascade). So whatever works in mysql works in there.This is why

value FROM (#table_name) 

won't work as #table_name is not valid subquery.

http://dev.mysql.com/doc/refman/5.7/en/subqueries.html

So example I gave you should work unless there is some problem with regexes, here is mysql manual on subqueries in FROM, you can Google fro more tutorials

https://dev.mysql.com/doc/refman/5.7/en/from-clause-subqueries.html

Get a Book for SEBLOD