Search/filter/sort functions, how?

More
15 years 4 months ago - 15 years 4 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: 15 years 4 months ago by collacocca.

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

More
15 years 4 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
15 years 4 months ago - 15 years 4 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: 15 years 4 months ago by collacocca.

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

More
15 years 4 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
15 years 4 months ago - 15 years 4 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: 15 years 4 months ago by collacocca.

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

More
15 years 4 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.

More
15 years 2 months ago #12010 by sospixs
Hi im stuck with this "Search" problem
for a week and now im just solve my problem ,
May be help any one .

Im just add php code in "models/categories.php"
Line 337
From
Code:
$where .= ' AND LOWER( i.title ) LIKE '.$this->_db->Quote( '%'.$this->_db->getEscaped( $filter, true ).'%', false );

To be
Code:
$where .= ' AND ( LOWER( i.title ) LIKE '.$this->_db->Quote( '%'.$this->_db->getEscaped( $filter, true ).'%', false ); $where .= ' OR LOWER( ie.search_index ) LIKE '.$this->_db->Quote( '%'.$this->_db->getEscaped( $filter, true ).'%', false ); $where .= ' ) ';

Caz old sql doesn't search in others field ,

BUT Still have problem when searching return more than one page , When i change page , Search result will lost . T T , In this case i can't solve.

How can i pass filter value to next page ?

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

More
15 years 2 months ago #12014 by sospixs
Hi , Im try to find how to pass filter value to pagination . I'm no luck .

In my case
I have setup category to show 10 article per page .
(I have 50 articles then result show 5 pages ) and also show search box on the top of category list.

When I submit any value in search box , such as "install" that hits around 15 articles ,absolutely show in 2 pages ,

But when i press "Next" botton of pagination to go next page, My search box is empty and result are clear , Result return 50 article again , HOW DO I CORRECT THIS ? Please HELP.

Thank you
2010-11-01
SOLVED by myself.

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

More
14 years 11 months ago #14116 by boulij

poolp wrote: Merci ! :mrgreen:
Ca marche bien ! Mais il y a une petite erreur a changer :

add into new line #33 of 'category_items.php' of your template

Code:
<script type="text/javascript" src="<?php echo JURI::base().'components/com_flexicontent/assets/js/sortable.js'?>"></script>

Encore Merci !




Hi,

I have an error message when the category opens: "Handler cannot be removed". I precise that i'm still on local.

Second question: where can I modify the head of column style. I find a CSS file but when I change something, it impacts all the links.

Thank you

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

More
14 years 11 months ago #14164 by gauthier
The filter solution works fine but I have:

A pop up error message 2 times: "Handler could not be removed" when I refresh my page.

This error is linked with the javascript but I don't have any idea of what could be the problem.

I found this in error logs of firefox:

Error: window.addEvent is not a function
Source File: http://localhost/revisedextranet/people
Line: 6


as the script still running I don't understand why it still a problem for it.

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

Moderators: vistamediajoomlacornerggppdk
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
Save