select options for template field
Hi!
I'm wondering how i could build a select out of template field data?! I know how to access the selected fields for a given item but how do i access all possible values to make a list out of them?
Thanks, Kai
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Steve Smith on 12 Jan, 2011 03:56 PM
Are you looking to build a select box on the front side of your website? There's currently no way to get a list of the 'options' for a select in the template language. What would you use this for?
3 Posted by Kai Wernicke on 12 Jan, 2011 04:02 PM
I want to add some "flags" to a persons profile, like city and profession. Then i want to display matching persons in a list based on selected criteria.
So i want to insert selected options as a class to the li and be able to display all avaiable options in the select box so that i can trigger displaying of li's via jquery.
Thanks, kai
4 Posted by Kai Wernicke on 14 Jan, 2011 09:23 AM
Anyone?
Let me clarify: I have a page. Below this page are subpages containing employees of my customer. Each emploee has some attributes like city, profession etc.
Now i want to display a list of all employees and filter this list if an item from a selectbox ist selected. For example i want to display only employees working in one city...
I know how to build the list and flag every
But to build a jquery script tro filter this list i need an array of all available options.
Thanks, Kai
5 Posted by John Nunemaker on 25 Jan, 2011 02:41 PM
Kai,
There is not a way to do what you are doing in themes. If you prefix the classes, you could easily just loop through the items with jquery and collect all the unique prefixed class names. Does that make sense?
6 Posted by Kai Wernicke on 26 Jan, 2011 09:05 AM
John,
Well, yes. Sort of :)
That's what i want to do but how do i access these options to use as a class prefix?
As far as i have seen it i can only access the options of the given item but not all available ones...
Do i have to loop over all items and build an array of options for my select list and if so how?
Thanks, Kai
7 Posted by John Nunemaker on 26 Jan, 2011 02:26 PM
You are correct, there is not access to a template's field data. The only way to access the data is through the item.
What I was trying to explain is this. Lets say you have Mishawaka, Elkhart and Holland as options for the city select. When you render the list of people, you can add the city their city as a data attribute. Something like this:
Then, you can use jquery to map all the cities uniquely into an array like this:
Does that better explain what I was thinking?
8 Posted by Kai Wernicke on 26 Jan, 2011 04:37 PM
Hi John!
Thats it! Thanks a lot!!
Cheers, Kai
Kai Wernicke closed this discussion on 26 Jan, 2011 04:37 PM.
9 Posted by John Nunemaker on 26 Jan, 2011 04:39 PM
No problem. So glad I could help!