Search

I’m now at the stage where I need to build a sortable table of jobs, with pagination and asc/desc sorting for every column. Have any extensions/XSLT examples been posted for this? I had a search but couldn’t see anything.
I have a rough idea of how to go about it, but I don’t want to hardcode any values or limits as I want to be able to reuse the template for different tables.
I’m also not quite sure on how to work with Symphony’s pagination, but I’m sure it’s not too complicated…ish!

Has anyone built a similar table before?

I have implemented dynamic data source sorting before.

Ah ha, I see you opted to implement it around the data source itself. I’m not sure whether I’d prefer to do it that way, or dump all the records into the XML and sort/limit through XSL or jQuery. Is there a reason you chose your method?

I think it’s just a matter of query efficiency; the more pages you have, the more unneeded datasource entries you’d be sorting.

However, if it was paginated with jQuery I would think it could prove more efficient despite the bigger initial query. But then that would probably involve a larger time investment to build.
My situation is that there probably aren’t going to be an enormous amount of entries, as they have start/expiration dates, and I’m only pulling in about 5 fields per entry.
I’m also being very careful with passing anything back to the system via GET, as I’m not sure what security measures Symphony has in place.

If you go the jQuery route, you could load your DS into a javascript object wholesale, then use clientside XSLT to output your table. You might prefer JSON, but if you do try this out, I would be curious to know how it goes. Good luck!

You can also edit the DS manually (its just a PHP-file after all) and put the sorting-logic in the SQL-statement there.

I’ve found a pretty sweet jQuery table plugin. I think if I use XSLT to format all the records into one table then it’ll both degrade nicely for people browsing without Javascript enabled, and allow me to control it all without needing any Ajax. I’ll keep you posted on how it goes.

I discovered the jQuery Data Tables plugin the other day. The nicest one I’ve seen yet.

Depending on how many total entries, I’d recommend using Symphony sorting/paging. If you end up with 200 entries, it’ll be a whopping query to drop all of those into your XML and XSLT.

Pagination is very easy — include the pagination element in your XSLT and make use of the Pagination XSLT Utility :-)

I realise this is quite an old thread, but it could potentially answer a question I've had for a while. Like the original poster I have an (html) table with a single data source, currently sorted by one column, with no option to change the sort column or reverse the order.

Could anyone explain the best way to achieve this? I did look at the dynamic data source but couldn't wrap my head around it, though it does sound like it might achieve this.

I'd like to do it via changing the data source using a url such as ?p=1&c=name&o=desc since my section currently contains 2,000 records and will increase over time. I should also point out that I'm also using Nick's search function, with the keyword in the URL.

Thanks a lot

Read Carsten's post above about dynamic sorting and you'll find this has been added to Symphony from v2.0.7. If you want to use GET parameters like this:

?p=1&c=name&o=desc

Then modify your data source PHP file along the lines of:

public $dsParamSTARTPAGE = '{$url-p}';
public $dsParamORDER = '{$url-o}';
public $dsParamSORT = '{$url-c}';

Symphony's data source editor won't quite handle this properly, so you should also set the allowEditorToParse function to return FALSE so that the data source cannot be overwritten within Symphony.

I should also point out that I'm also using Nick's search function, with the keyword in the URL.

Ah, in which case this will not work. The above only works with standard Symphony data sources. The "Search Index" data source that comes with the search extension does not support sorting of any field (only the sorting options documented in the readme). However if you use the Search Index field in your section (single section search, as opposed to multi-section search afforded by the Search Index data source) then you can use the above sorting, since you will be using a standard data source.

Thanks for the reply Nick, I did take a look at that thread previously but couldn't wrap my head around it

Then modify your data source PHP file along the lines of:

Sorry to be a pain, but I'm looking at class.datasource.php (symphony 2.1) and can't figure out where to put these.

However if you use the Search Index field in your section (single section search, as opposed to multi-section search afforded by the Search Index data source) then you can use the above sorting, since you will be using a standard data source.

This is what I'm doing, rather than the multi-section search

Cheers

This is what I'm doing, rather than the multi-section search

Ah, good.

Sorry to be a pain, but I'm looking at class.datasource.php (symphony 2.1) and can't figure out where to put these.

The changes from the other thread are already in the core. To do this in your data source, modify the PHP file for your chosen data source in /workspace/data-sources.

I'm doing something very similar, but I'm stumped as to how to go about pagination. Is it possible to use Carsten's method post above with the XSLT Pagination utility?

Sure. When building the pagination URL you'll need to make sure you pass through the values of {$url-o} and {$url-c} (or whatever you name them).

How do you provide the <xsl:param name="pagination" /> element info to the pagination utility?

XPath.

<xsl:call-template name="pagination">
    <xsl:with-param name="pagination" select="/data/my-data-source/pagination" />
    <xsl:with-param name="pagination-url" select="concat('/articles/?p=$&amp;o=',$url-o,'&amp;c=',$url-c)" />
</xsl:call-template>

Okay, I'm not being helpful. Sorry. For some reason I thought Carsten was also utilizing Ajax.

I've started a new discussion.

Thanks a lot Nick, got it working - should've read the last couple of comments earlier as I just spent time working out how to integrate with pagination!

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