Search

Hi All,

I am new to symphony and so far I am really loving the experience of building an ensemble. However, I am stuck with a problem now. Following is what I am trying to achieve:

Artists Page

  • Artist One
  • -- Image 1
  • -- Image 2
  • -- Image 3
  • ---- see all for artist one
  • Artist Two
  • -- Image 1
  • -- Image 2
  • -- Image 3
  • ---- see all for artist two

... and so on...

So basically I am trying to create a page which shows list of artists with their 3 items and then selecting see all will go to a page dedicated to the artist.

What I did was :

  1. Created a Section for Images and another section for Artists
  2. Linked the Images to Artists with a 'select box link'
  3. Created Data sources for both
  4. Add both data sources to page
  5. Filtered Images data source with "{ds-artists}"

This will worked correctly, it fetches the images for artists. Problem is pagination. Every artist can have many images, I want to just show 3 for each artist in the 'artists' page and then show a paginated list of images for artist's dedicated page (12 images in one dedicated page).

How best to achieve this? When I set pagination in Images Datasource to include 3 images, it outputs only 3 images (for the first artist), however, if first artist has 2 images only, then it includes one image from the second artist. In short it is fetching total 3 images whereas I want 3 for each (filtered by the artists which are present on the page)

note - the artists page itself will include paginated list of artists.

As far as I'm aware, the standard datasource does not limit on a per-group basis...

I'd suggest that you limit to 3 images using XSLT. Assuming you grouped by artist your xPath for the image selection/loop would look like this

/data/images/artist[@linkid=current()/@id]/entry[position<4]

The above would obviously part of the xsl inside each artist, to match the current artist id.

Thanks @gunglien.

Doing it in XSLT will work but it will load all the data and not an ideal solution. I will do it only if there is no other efficient way.

Last night I found about writing a custom data source. I have my sql query ready for a different database, I will see I can migrate that to a custom datasource and then my issue will be resolved.

yes if you're comfortable with php; that's a possible way to go.

You should just need to run the query using Symphony::database->fetch($query) and then output XML, shouldn't be too complex especially if you already have a query.

That's good to know, thanks, otherwise I was going to use mysql_query :-)

I am studying some of the auto generated data sources to see the correct way to do it.

@dexterous - could you post your solution if you have it finished?

I could need a similar custom datasource for a project I'm currently working on and would definitely have an easier start with an example from someone who is experience with mysql. Thanks in advance!

@roman,

Some other high priority things have come up so I did not work on the custom data source. But I did give it a few hours and it looked quite possible to achieve.

Basically, you create a new data source from the admin interface and the php class will be generated for you, then you just have to modify the implementation to suit your needs, You will need to override the 'execute' method. The important thing to know is the relationship between tables and fields. Once you have the knowledge about the DB then you can query and get anything what you want by using the method which gunglien mentioned above.

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