Changing list field content based on another fields input

11 posts by 4 authors in: Forums > CMS Builder
Last Post: January 20, 2011   (RSS)

Re: [4cdg] Changing list field content based on another fields input

By Jason - October 1, 2010

Hi,

This can be done by using the "Get Options From MySQL Query (advnaced)" option for your sub_categories list field.

Let me know the names as well as the setup options of both of your list fields and I can take a closer look.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Changing list field content based on another fields input

By 4cdg - October 1, 2010

Categories, with sub categories after

Computers >> Laptops, Desktops, Servers, Monitors, Printers, Networking, Mixed Deals & More
Electronics >> Copiers, Presentation, TV's/Video, Cameras/Photo, Audio
Communications >> Radios, Intercom, PA, Other
Books/Curriculum
Sports >> Equipment, Weights/Training, Seating/Bleachers, Scoreboards
Playground
Music & Arts >> Instruments, Band/Choir Furniture
Science & Lab
Furniture >> Classroom, Office/Teacher, Bookshelves/Cabinets, Lockers, Presentation
Transportation >> Busses, Cars/Trucks, 4-wheelers/ATV's, Trailers, Parts
Cafeteria
HVAC & More >> Heating/Cooling, Materials, Electrical, Plumbing, Lighting Fixtures
Tools >> Electric, Hand, Metalworking, Woodworking, Construction, Generators
Janitorial >> Equipment, Materials, Laundry
Grounds
Buildings
Building Materials

The setup options I have now are just 2 basic lists, not really sure what else you are wanting to know.

Re: [4cdg] Changing list field content based on another fields input

By Chris - October 1, 2010

Hi 4cdg,

To accomplish this, your Subcategories will need to be in a Multi Record section. To simplify things, you can also keep your Categories in a section.

First, create a Multi Record section called Categories. I'll assume you'll be using the default 'title' field to fill in their names. Add a record for each category.

Next, create a Multi Record section called Subcategories. Add a List Field to it called 'Category' and set these options:

List Options: Get options from database (advanced)
Section Tablename: category
Use this field for option values: num
Use this field for option labels: title


Now, go and add records for each of your Subcategories, making sure that you select the correct Category from the dropdown for each.

Finally, in your Products section, you'll want a Category List Field (exactly like the above one) and a Subcategory List Field with these options:

List Options: Get options from MySQL query (advanced)

SELECT num, title
FROM `<?php echo $TABLE_PREFIX ?>subcategories`
WHERE category='<?php echo $ESCAPED_FILTER_VALUE ?>'


Advanced Filter: Refresh list when this field changes: category


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

Re: [chris] Changing list field content based on another fields input

By 4cdg - October 1, 2010

thanks

worked perfectly

Re: [chris] Changing list field content based on another fields input

By Djulia - January 17, 2011 - edited: January 17, 2011

Hi Chris,

Get options from MySQL query [/#333333][/#333333][/#888888][/#888888](advanced)[/#333333][/#333333] do not seem to work with Searching (Label|FieldList|searchType).

You confirm ?

Thanks !

Djulia

Re: [chris] Changing list field content based on another fields input

By Djulia - January 17, 2011 - edited: January 17, 2011

In fact, that functions if I use : WHERE field LIKE '%<?php echo $ESCAPED_FILTER_VALUE ?>%'

and does not function if I use : WHERE field = '<?php echo $ESCAPED_FILTER_VALUE ?>'

If I use LIKE, it is correct ?

Thanks for the feedback ! :)

Djulia

Re: [Djulia] Changing list field content based on another fields input

By Chris - January 17, 2011 - edited: January 17, 2011

Hi Djulia,

You'll need to use LIKE if your `field` is a multi-value list field. Actually, you should use this instead:

WHERE field LIKE '%\t<?php echo $ESCAPED_FILTER_VALUE ?>\t%'

...so that you don't get false positives.

That's correct: "Get options from MySQL query (advanced)" do not work with CMS Builder's list page search functionality. If this is important, our consulting department can write you some custom code to search any way you want. Please let me know if that's something you're interested in.

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

Re: [chris] Changing list field content based on another fields input

By Djulia - January 20, 2011

Hi Chris,

>> WHERE field LIKE '%\t<?php echo $ESCAPED_FILTER_VALUE ?>\t%'
Your proposal does not function on my server.

>> ...so that you don't get false positives.
Is that a big risk ?

Thanks !

Djulia

Re: [Djulia] Changing list field content based on another fields input

By Jason - January 20, 2011

Hi Djulia,

Could you fill out a [url http://www.interactivetools.com/support/]2nd Level Support Request[/url] so we can take a closer look at what's happening?

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/