Search/filter/sort functions, how?

More
13 years 7 months ago - 13 years 7 months ago #10276 by collacocca
OK a q&d solution to give an idea how to adjust the date sort function to other formats.
We use a single field for date+time the european way - 'dd.mm.yy - HH:MM Uhr' - looks like 31.12.10 - 23:59 Uhr

Change the regex pattern in line #119, 120 of sortable.js to -
Code:
if (itm.match(/^(\d{2}?)[\/\.\-]\s?([a-zA-z]{2,9}?)[\/\.\-]\s?(\d{2,4}?).*$/)){sortfn = ts_sort_date;} if (itm.match(/^(\d{2}?)[\/\.\-](\d{2}?)[\/\.\-](\d{2,4}?).*/)){sortfn = ts_sort_date;}
…just to be a bit more flexible

…append an additional 'else if' block to line #238 -
//we use the date/time separating dash in our format as anchor. Adjust it to whatever you need
Code:
} else if (date.substr(9,1) == '-') { // we use the date/time separating dash in our format as anchor if (europeandate == false) { // yyyy.mm.dd - HH:MM:SS dt = date.substr(6,4)+date.substr(0,2)+date.substr(3,2)+date.substr(13,2)+date.substr(16,2)+date.substr(19,2); return dt; } else { // 31.12.10 - 23:59 Uhr => 1012312359 dt = date.substr(6,2)+date.substr(3,2)+date.substr(0,2)+date.substr(11,2)+date.substr(14,2); return dt; }

and now combined date+time fields can be sorted the right way :D

Somewhere over the drain flows…
Last edit: 13 years 7 months ago by collacocca.

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #10355 by Vogglz
Beautiful tip for sorting the category tables, thanks!

But, the initial problem this poster has with not being able to search field other than the Title field is still not solved...

There seem to be more user having this issue, and I have posted the problem again here: www.flexicontent.org/forum/index.php?f=20&t=2263&rb_v=viewtopic

Please please please developers, have a look at this. It is a basic feature that should be working, but with some of your users, it simply isn't...

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago - 13 years 7 months ago #10401 by collacocca
Ok another q&d solution -

copy the following javascript function into the 'category_items.php' of your flexicontent template (around line #32) -
Code:
function filter_table( phrase, _id ) { var words = phrase.value.toLowerCase().split(" "); var table = document.getElementById(_id); var ele; for (var r = 1; r < table.rows.length; r++){ ele = table.rows[r].innerHTML.replace(/<[^>]+>/g,""); var displayStyle = 'none'; for (var i = 0; i < words.length; i++) { if (ele.toLowerCase().indexOf(words[i])>=0) { displayStyle = ''; } else { displayStyle = 'none'; break; } } table.rows[r].style.display = displayStyle; } }

change the <div class="fc_fleft"> - block to
Code:
<div class="fc_fleft"> <input name="filter" id="filtr" onkeyup="filter_table(this, 'flexitable', 1)" type="text"> <!--// <input type="text" name="filter" id="filter" value="<?php echo $this->lists['filter'];?>" class="text_area" onchange="document.getElementById('adminForm').submit();" />--> <!--// <button onclick="document.getElementById('adminForm').submit();"><?php echo JText::_( 'FLEXI_GO' ); ?></button>--> <!--// <button onclick="document.getElementById('filter').value='';document.getElementById('adminForm').submit();"><?php echo JText::_( 'FLEXI_RESET' ); ?></button>--> <label for="filtr">Search</label> </div>
(we keep the original code because you never know)
et voilà - you can even use more than one keyword (AND)

And don't forget to activate the search field in your category params

The javascript is from www.vonloesch.de/node/23
Give him the credits, the honour and your recognition. Me the money 'nd love :D
And here is an extension leparlement.org/filterTable
Someone out there who brings in the 'string OR string' function?

Somewhere over the drain flows…
Last edit: 13 years 7 months ago by collacocca.

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #10469 by Vogglz
Wow collacocca,

this is not a q&d solution, it is magnificent in all its simplicity! :mrgreen:

Even better than what I asked for, this should be in Flexicontent core! Thanks a million! :D

By the way, there is 1 too many brackets ( } ) at the end, wouldn't work at first.

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago - 13 years 7 months ago #10476 by collacocca
Yes, you're definitely right. There was a bracket too much! And it's readjusted.
Anyway - important is you like it and it brings you forward… :D
Hope you'll bring in the urgently needed 'string OR string' pattern.

Somewhere over the drain flows…
Last edit: 13 years 7 months ago by collacocca.

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #10481 by Vogglz
Haha, you are right - that is what matters and I salute you for it, sir. :)

The bracket correction was merely to save other users some time figuring it out...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.313 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline