Search

I have a section members with members from different states.

How do I create a data source that returns me only the states members without repeating the state?

Or the right would have the data source returning the states of the group members by state and xsl I'd get the states without repeating them?

I think if you group by state you should always have the states in order. But might depend on how you structured your section.

Also what do you exactly mean by repeating states? Usually that is fine, if you want to get XML for all members of the same state, you could leave the state in the XML and use XSLT to filter / show all members of a particular state.

Example:

from a section i have Users and States

user A - Texas.
user B - Nevada.
user C - Oregon.
user D - Nevada.
user E - Oregon.

Group users by state in data source retrieve this response:

Texas
- user A.
Nevada
- user B, user D.
Oregon
- user C, user E.

Each user is a node in xml. Imagine a section with many users. One user per state is enough. How i can retrive this response only with data sources?

Ideal xml:

Texas
- user A.
Nevada
- user B.
Oregon
- user C.

Thanks for your attention.

Hi Tigo, with xslt you can try to loop all the states, this will work only if each user is a node.

<xsl:for-each select="state">
   <xsl:value-of select="user"/> //will display the value of the first node user
</xsl:for-each>

To modify the xml, you can try a datasource chaining: output a first datasource of the states with a datasource parameter, then a second datasource of the users, filtered buy the parameter and limited to one entry.

If you have many users and just want to pull the states, I think I'd go for a custom DS, where you put in a query and output the states via xml (potentially without the users if you don't need them).

The way it's set up would be largely inefficient. I don't think you can do a 'fetch distinct states' with a standard symphony datasource. It would always fetch all of them.

Thanks Vincentd and Gunglien.

Vincentd, i understand your point but how can i return only one entry from second data source?

DS will return all users from a same states.

Do you have only one section with states + users or do you have a section with states, another with users, linked to the states with a select box link? If you have only one section what are the fields?

For datasource chaining, the ideal is to have 2 sections, one for the users, one for the states. If you have only one section, then it is probably possible if one of the field is a "tag list", for states for example (not 100% sure, but probably).

Sorry, I tried and it s not possible like that. I am wrong.

Perhaps the solution is to add a select box in the States section (not users) so you can retrieve the default user for this state. Then it will be possible to have the xml you want filtering the sate section.

I tried few things, before there was an extension for that ds_multiplier but I just tested it and it doesn't work with the latest version of symphony.

i understand your point but how can i return only one entry from second data source?

Activate pagination and select 1 entry per page.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details