Search

I’d like to revive an old thread regarding creating a datasource to get the next/previous entry-id. Since Symphony has evolved quite a bit I’m posting my current requirements, which are similar but not totally the same as in the old thread. Here we go:

I have a list of entries which can be quite substantial (up to ~20,000 Entries in a specific category) that is filtered by a set of categories. It’s no problem to create a paginated overview DS. But using this for a next/previous navigation will not work as soon as the pagination limit is reached in detail view.

My imagination how an ideal DS for this would work would be using the beforementioned DS as a stating point, removing pagination, but somehow limit the output to the previous and next id from the current one.

Hope I am being clear, please let me know if this is gibberish :) Is there a way to do this more easily now we have 2.3?

Did Josh's approachnot work for filtering Next/Prev or have I misunderstood the complexity of this question with Categories added to the mix?

http://getsymphony.com/discuss/thread/256/2/#position-37

Thanks for pointing me to this Andrew! When trying Josh’s approach I get this:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ': value > 673) ORDER BY `e`.`id`DESC' at line 10

I have no clue about mySQL, so I’m not sure if this is only a syntax problem or something worse.

What field type is it you're trying to filter on?

On the System-ID. (MySQL Version is 5.1)

I was assuming it needs to be the id. I get the desperate feeling I’m doing something very basic very wrong … I’d very much appreciate any hint!

Can you screen grab your DS editor screen? and do you have order_entries extension installed?

Sorry about being so dim in this matter … is this method only working when sorting by the order_entries extensions sort order? I would eventually need a method to work with multiple sort orders.

I think I am beginning to grasp how this works and starting to suspect it’s a dead-end. In order to get the next and previous entries via the sql-filter I need to select the field I want to sort by. The thing is, I’d need the entry-ids, and if I use sql >< on a list of ids (if at all possible), it would always be sorted by the id-number and not by the sort order selected elsewhere in the DS, right?

Alexander, I'm not sure if anyone besides yourself is able to follow what you are doing right now. It's quite vague :)

What have you done so far?
Anything you can show us?

I’m sorry. Thanks for bearing with me. I’ll try being more clear:

I’m working on a Photo database. Photo-entries are linked to provenances, collections, photographers, streets and topics via subsection managers.

I have an overview-datasource that filters the photo-entries by a published-checkbox, plus the above mentioned categories. The entries are sorted by system creation date, but I want to make the sort order dynamic later on (as mentioned in this thread). The datasource is paginated since eventually there might be as many as 18.000 entries in a specific collection.

For the detail photo-page I have created a next/previous entry navigation. I’ve used the overview-datasource mentioned above to grab the ids of the next and previous entry via following/preceding-sibling xpath, and this works fine with the few test-photos I have so far.

However this would obviously not work as soon as I have more entries as the pagination limit, so I would need an unpaginated list of all entries sorted and filtered the same way as the overview-datasource. This in turn becomes impractical as soon as there are thousands of entries in a collection or provenance, etc. since there would have to be a massive ammount of queried in order to return the two ids actually needed.

Therefore I thought the ideal thing would be to have a copy of the overview-datasource without the pagination, but limited to the current, next and previous entries (or only the two latter for that matter). But I have no idea how to do this.

Does this make sense?

overview-datasource

Attachments:
overview-datasource.jpg

Why don't you just use the id of your current entry and create two other Data Sources that either fetch the next lower or next higher id? You would get any problems with pagination limits as these two Data Sources would have a limit of 1 and return a result based on your current id.

By the way, I think the system creation date can be filtered like an normal date fields so you should be able to use later than {$current-id} and earlier than {$current-id} to create the next and previous Data Sources (you need to create the current-id param somewhere first of course).

But I have to admit that I haven't used the system creation date for filtering so far.

@nils many thanks for your replies!

Your first entry makes sense, I think Allen suggested something like this in the thread I mentioned. I didn’t manage to make this work. If you paginate and limit to 1 entry per page and filter by the current id, how exactly do you get the DS to output the next id? It’s probably very simple, but I have no idea how to do that.

The second entry sounds like it would work (as long as I don’t have a DS with a dynamical sort order). Will give it a try in the meantime.

If you paginate and limit to 1 entry per page and filter by the current id, how exactly do you get the DS to output the next id?

You have to limit the output to 1 entry and set the start page to 2. It depends on your sort order, if you get the next or previous entry in this context.

The second entry sounds like it would work (as long as I don’t have a DS with a dynamical sort order).

What does dynamic sort mean? If you know what you are sorting on, you can adjust your next and previous Data Sources accordingly.

Thanks Nils, I didn’t set the start page to 2, which made it kind of pointless … m( that’s obviously why I never understood how this should work. Sorry for being so stupid.

By dynamic sorting i was referring to something like this. I’d love to use a single DS (plus nav-DSes) for several pages in order not to have 6 or 8 datasources that only differ by sort order.

By dynamic sorting i was referring to something like this. I’d love to use a single DS (plus nav-DSes) for several pages in order not to have 6 or 8 datasources that only differ by sort order.

In this case you should write your DS by hand.

In this case you should write your DS by hand.

Yeah, but my PHP skills suck, and SQL-skills are non-existent. :)

I think this will get me along, thanks again!

Yeah, but my PHP skills suck, and SQL-skills are non-existent.

In this case I'd opt for multiple Data Sources for the different scenarios. You can make sure that only the needed ones are processed with Conditionalizer.

Brilliant! I haven’t come across this one. Looks very good.

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