template table_row_heading and the Table Sorter add-on

Permalink Browser Info Environment
Hi,
We got a customer that would like the enhanced user list. But he demands that the table is sortable. We tried to mix your add-on with the free add-on (Table Sorterhttp://www.concrete5.org/marketplace/addons/table-sorter/)... with no luck.

Do you have any suggestions?

Regards
Michael

Type: Discussion
Status: New
maar
View Replies: View Best Answer
Shotster replied on at Permalink Reply
Shotster
Hmm, that's strange. My reply (sent via email) didn't appear in this forum. I'll paste it in...


Hi Michael,

It should be doable, although perhaps not with the add-on you referenced. (I have no experience with that add-on.) First, though, I have a couple questions...

Which version of Concrete5 are you running?

Which version of my EUL add-on are you using?

Which EUL template are you using? (If a custom template, can you post it here?)

-Steve
maar replied on at Permalink Reply
maar
Using Concret5 5.5.2, stopped with 5.4 months ago.

Your EUL add-on v1.5

Template "table_row_heading_sample". We are not going to customize a template before sorting is possible.

Michael
maar replied on at Permalink Reply 1 Attachment
maar
As a bonus for you. Here is the Danish translation. Just drop the languages folder in the root of your add-on and your add-on talks Danish.

Only one issue! When showing the "Search" form the "Search" button is not translatable. I think that you have this button inside eul.min.js. This is bad for translation.

Regards
Michael
Shotster replied on at Permalink Reply
Shotster
> As a bonus for you. Here is the Danish translation. Just drop the languages
> folder in the root of your add-on and your add-on talks Danish.

Nifty! Thanks!

> Only one issue! When showing the "Search" form the "Search" button
> is not translatable.

Yeah, I might need to rethink that in a future release to allow customization and language support.

I'll let you know what I learn regarding the table sorting.

-Steve
Shotster replied on at Permalink Reply
Shotster
> We got a customer that would like the enhanced user
> list. But he demands that the table is sortable.

Ok, this is working, but I need to do a bit of clean-up as well as some testing in other browsers. I could have a fairly polished solution by the end of the week if that works for you.

-Steve
maar replied on at Permalink Reply
maar
We are not in a hurry. So take your time - better to good than fast!

Michael
Shotster replied on at Permalink Best Answer Reply 1 Attachment
Shotster
I wrote:

> Ok, this is working, but I need to do a bit of clean-up as well as
> some testing in other browsers.

Michael,

You should now be able to update to version 1.5.3 of EUL via the marketplace. I added new functionality that I consider "advanced" because it requires some JavaScript knowledge (although if you're familiar with JS, it's not really all that advanced). In other words, this new feature is not intended for end users or content editors. In a nutshell...

The PMW.fetchEUL() function (which is invoked in all EUL view templates) now accepts an optional second argument, an object that can contain two properties. Each property is a function that defines an event handler. You can define an "onStart" event handler which fires before the user list is rendered as well as an "onFinished" event handler which fires after the list has been rendered.

The latter will allow you to implement table sorting via a jQuery plugin. However, instead of using the add-on in the marketplace (which is not AJAX savvy), just install the plugin directly. To do so, proceed as follows:

1) Download the jQuery tablesorter plugin directly from here...

http://tablesorter.com/docs/#Download...

...and place it in the root "/js" directory of your C5 installation.

2) Make sure it gets loaded in your site by adding the following lines to your theme's header.php file...

$html = Loader::helper('html');
$this->addHeaderItem($html->javascript('/js/jquery.tablesorter/jquery.tablesorter.min.js'));


Please note that the above lines must come BEFORE the line that reads...

Loader::element('header_required');


3) Lastly, install the attached "sortable_table" custom template by copying the files into the "/blocks" directory at the root of your C5 installation (just as you would for any other custom block template).

4) Now just make sure you choose that template for any EUL blocks that you want to be sortable tables.

BTW, I also made the text of the "Search" button customizable via the block configuration dialog. As a result, there are some minor changes to the UI strings, so if you get a chance to send me an updated Danish language pack, I'll be sure to add it to the next update.

Let me know if this works out for you. If you have any questions or encounter any problems, let me know.

Regards,

-Steve
maar replied on at Permalink Reply 1 Attachment
maar
Good work. Works perfectly.

Attached da_DK Danish translation

Michael
maar replied on at Permalink Reply
maar
OK, I was a little fast about it all works OK. We have seen that the Jquery-tablesorter java script fails if we are on singlepages like the login page (only if we activate custom theme for single pages in /config/site_theme_paths.php.

What about incorporate the Jquery-tablesorter in to your package some how. Right now I have this code in my header to exclude tablesorter from single pages:

<?php if ($c->getCollectionTypeHandle() == '') { ?>
   <!-- if $c->getCollectionTypeHandle() contains nothing we are on a single page -->
<?php } else { ?>
    <?php $this->addHeaderItem($html->javascript('/js/__jquery.tablesorter/jquery.tablesorter.min.js')); ?>            
<?php } ?>
<?php Loader::element('header_required'); ?>


But it gives much less flexibility.

Any ideas?

Michael
Shotster replied on at Permalink Reply
Shotster
Hi Michael,

> We have seen that the Jquery-tablesorter java script fails if we are on single pages
> like the login page...

I'm a little unclear about what you're trying to do. Do you have an EUL list on the login page that you want to be sortable? If so, then do as you mention below and override the system page. That's precisely how you "theme" a system page.

> (only if we activate custom theme for single pages in /config/site_theme_paths.php.

Yes, that's the correct way to get C5 to use a custom theme for ANY system page. That's the way C5 is designed.

> What about incorporate the Jquery-tablesorter in to your package some how.

I'm not considering any type of "built-in" per-page table sorting functionality at this time. I have no interest in designing my add-on around or supporting just one particular 3rd-party jQuery plugin. The solution I came up with is intentionally more general purpose and flexible.

The significant upside to my solution is that it provides a "hook" that does not restrict you to a single plugin. In other words, you aren't limited to using just one particular table sorting plugin. In fact, you aren't limited to using a table sorting plugin at all. You can trigger any post-render event you want (even if it has nothing to do with sorting tables).

> Right now I have this code in my header to exclude tablesorter from single pages:
>
<?php if ($c->getCollectionTypeHandle() == '') { ?>
<!-- if $c->getCollectionTypeHandle() contains nothing we are on a single page -->
<?php } else { ?>
<?php $this->addHeaderItem($html->javascript('/js/__jquery.tablesorter/jquery.tablesorter.min.js')); ?>
<?php } ?>
<?php Loader::element('header_required'); ?>
>
> But it gives much less flexibility.
>
> Any ideas?

I guess I'm a little unclear about what you're trying to accomplish. If you can clarify the following, I might be able to provide further guidance:

* Do you want to put an EUL on the login page or other system single page?

* If you are putting an EUL on the login page, can you tell me how you are doing so?

I guess I'm a little confused because you initially seemed to indicate that you wanted a sortable table on a system page, but then you put in code to specifically prevent it from happening.

Thanks for any clarification you can provide,

-Steve
Shotster replied on at Permalink Reply
Shotster
> We have seen that the Jquery-tablesorter java script fails if we are on single pages
> like the login page...

It just occurred to me that perhaps you mean that you are getting a server-side error. In other words, you're getting a C5 (PHP) error when the single page attempts to invoke the addHeaderItem() function.

If that's the case, there should be a simple solution. I might have misunderstood your statement above to mean that the error itself was a JS (client-side) error.

-Steve
Shotster replied on at Permalink Reply
Shotster
> We have seen that the Jquery-tablesorter java script fails if we are on single pages
> like the login page...

Aha, I think I understand the problem! If I'm right, it's a trivial thing to fix! Just add the following line...

$html = Loader::helper('html');


...BEFORE the line that reads...

$this->addHeaderItem($html->javascript('/js/jquery.tablesorter/jquery.tablesorter.min.js'));


That should do it. The problem is that the html helper object isn't loaded automatically for single pages like it is for "regular" pages; so you simply have to load it explicitly. That should solve the problem.

If it doesn't, or if I'm still not understanding the issue, let me know.

-Steve

P.S. I've amended my original reply to include the omitted line.
maar replied on at Permalink Reply
maar
That did the trick. Thanks...

Next time you come out with an update. Then PM me and we will return a new translation file for you!

Michael
Shotster replied on at Permalink Reply
Shotster
> Next time you come out with an update. Then PM me and
> we will return a new translation file for you!

Thanks, I appreciate that.

(Sorry for being so dense about the issue you were having.)

-Steve
maar replied on at Permalink Reply
maar
Just to clarify.

I did the "if" statement in the header because I wanted to be sure that the js tablesorter did not load on single pages. That was my way to get rid of the server side error.

Your ($html = Loader::helper('html');) did the trick, so I do not need the "if" statement any more.

But thanks for your fast support.

And frankly, when talking to add-on developers I usually get a lot of "dense" remarks. The problem with me is that we have customers that have certain demands and I try to supply solutions for these demands.

If I began to make corrections to the add-on code my self (I have done that before because of developers lack of interest in selling his add-on). Then my customers would kiss goodbye to the possibility to update his add-on to new version. So I have to convince the add-on developers every time. I just had one huge problem with time conversion AM/PM to 24h from a add-on developer (he did not want to make his add-on work outside US). So he just missed a huge sale in Denmark (and probably in the rest of Europe too) We then decided to correct all his code just to see if it could be done correctly (it could).....

But you have to understand that I have a huge respect to the developers. A lot of the add-ons in the marketplace is cheap and thought through. So just keep up the good work.

One last thing. We can not sell any add-on in Denmark that is not fully translatable. And this is where we can help you to get more customers.

Michael

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.