SQL query to use to find in array of flexi category ids.

More
11 years 1 month ago #46754 by dealio
Hi I'm using the custom SQL builder to populate a drop down list.

Since flexi content allows for items to be assinged to multtiple categories. Is there an array flexi category variable.


My query is
==================================
"SQL=select id as value , area as text from table_locations WHERE catid = {item->catid};"




I'd like to do an in statement since this value can be in multiple categories


Something like
====================================
"SQL=select id as value , area as text from table_locations WHERE catid IN {item->flexicatid};"

output like
SQL=select id as value , area as text from table_locations WHERE catid in ('9','5');


Thanks

version 2.1.3 r1857

Joomla 3.2.3

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #46756 by ggppdk
Hello

try this:

print_r($item->cats);

or

print_r($item->categories);


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #46781 by dealio
Hi thanks for the reply.

The more I look at it the more I'm not sure if its doable since the multi category selection is dynamic and SQL query to populated the drop down is on the page load.


I have a a top level category

and two sub categories


California (main category)
--> northern CA (sub peer cat)
--> Southern CA (sub peer cat)


If a user is filling out a form and assigns the content to "northern CA (sub peer cat)" The sql query the drop down box will return all the related cities from a table in the database. This works fine. The issue arises if the user selects both "northern CA (sub peer cat)" AND "Southern CA (sub peer cat)".

Would you have an idea of how to get this behavior to work. Should I not use categories? Maybe related drop down fields. Does FC allow for related select fields.


Drop down1
"Choose State" (multiple selection)


Drop down2
"Choose City" (filter cities based on drop down 1 slection)



Hope I make sense

Thanks

version 2.1.3 r1857

Joomla 3.2.3

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #46788 by ggppdk
Hello

so you want to show some field in item form that depends on the selected categories

1. create a custom field type 'myfieldtype': (see our FAQ article)

2. use jQuery to bind at the onChange event on form element with HTML tag ID: '#jform_cid'

3. the code that will be append will make an AJAX call that will execute your query and fetch data and populate your form field

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.289 seconds
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save