Filtering date interval

More
12 years 1 week ago #44706 by fgossart
Replied by fgossart on topic Filtering date interval
In templates files (artisteer) I found
$content = preg_replace('/<button[^>]*id="(.*)"><i class="icon-calendar"><\/i><\/button>/',
'<img src="' . JURI::base(true) . '/media/system/images/calendar.png" alt="Calendar" class="calendar" id="$1">', $content);

I'm not familiar with this code, but it's inside this preg_replace that first calendar button is replace with a calendar, and second is not... but the question is why ?

So my curiosity is to modify fleixcontent.fields.php (in classes) where filter as rendered

I just modify this line
$filter->html .= '<span class="fc_range">
(and insert a new line here)
</span>';
And now all is fine...
I hope you can soon give me a right answer
Pregreplace could not parse and replace the other string becauase too long and just adding a new line is html string is enough ?

Another question about date filtering
You wrote
about filtering you can use current date +days , -days, +months, -months

I found some tips using d for curdate but not working when adding + or - x days
ex : initial filters date range
50##d---5 d
display in frontend 2014-02-03 and 1970-01-01
so it seems increase or decresae some days or any other value is not possible in a category view.

Anyway when I debug the SQL where is
( DATE_FORMAT(rel.value, "%Y-%m-%d") >= DATE_FORMAT('d', "%Y-%m-%d") ) AND ( DATE_FORMAT(rel.value, "%Y-%m-%d") <= DATE_FORMAT('-2 d', "%Y-%m-%d") ))
I don't think it's correct.

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

More
12 years 1 week ago #44711 by fgossart
Replied by fgossart on topic Filtering date interval
Hello I can add some comments on my latest reply.
I try to parse/debug code and I don't understand how it could works.
You call JTML::('date
in flexicontent.fields.php
Firstly in this source code
Code:
static function createCalendarField($value, $date_allowtime, $fieldname, $elementid, $attribs='', $skip_on_invalid=false, $timezone=false) { // 'false' timezone means ==> use server setting (=joomla site configured TIMEZONE), // in J1.5 this must be null for using server setting (=joomla site configured OFFSET) $timezone = ($timezone === false && !FLEXI_J16GE) ? null : $timezone; @list($date, $time) = preg_split('#\s+#', $value, $limit=2); $time = ($date_allowtime==2 && !$time) ? '00:00' : $time; try { if ( !$value ) { $date = ''; } else if (!$date_allowtime || !$time) { $date = JHTML::_('date', $date, JText::_( FLEXI_J16GE ? 'Y-m-d' : '%Y-%m-%d' ), $timezone); } else { $date = JHTML::_('date', $value, JText::_( FLEXI_J16GE ? 'Y-m-d H:i' : '%Y-%m-%d %H:%M' ), $timezone); } } catch ( Exception $e ) { if (!$skip_on_invalid) return ''; else $date = ''; }
I think the second argument $date is not possible. It should be $value ?

And if date function says same args than strtotime but spaces (3 day) are args function separator and so when I entere in GetDate I have the '3' only (day is ignored)
So I really can't understand

In the module there is a new class datetime.php but not in a view with initial filters

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

More
12 years 1 week ago #44720 by ggppdk
Replied by ggppdk on topic Filtering date interval

I found some tips using d for curdate but not working when adding + or - x days
ex : initial filters date range
50##d---5 d


Hello
- as i said above,
this is not supported by initial OR persistent(=locked) filter values

-- i said that referring to current date is supported by module DATE SCOPE



-- about artisteer code, since you found it, then put this replacement command into comments !

it is just meant to add ARTISTEER styling to the calendar so , just don't use it (since you found it ;) )

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

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

More
12 years 1 week ago #44724 by fgossart
Replied by fgossart on topic Filtering date interval
About date scope I understand now. I thought you said that it was already done like universal module.
Really it's not possible now... ok.
I'll try to do it with universal module coding for my own usage

About date button, it's not really what you think
If I comment artisteer code, I only have the 2 buttons but not the calendar img.
So the <img > string seems to be provided by artisteer replacement, not by your code... or it has been already replaced before ;-)
I can just say that I solved this problem by cutting the long fields generated string (by your code described in my latest comments, just insert a new line somewhere. If not sure see before where I put it with success.
I think this mod will not change anything else in Flexicontent so you could put it in next beta or release ?

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

More
12 years 1 week ago #44725 by ggppdk
Replied by ggppdk on topic Filtering date interval
Hello

maybe also send a bug report to artisteer, showcasing the bad / misaligned HTML tags for calendar field ?


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

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

More
12 years 1 week ago #44726 by fgossart
Replied by fgossart on topic Filtering date interval
The bug is NOT in artisteer or I'm getting mad :-)
I use latest FC beta (daily build) with latest joomla 3.2

I try again a date range filter with the standard protostar template and there are no date calendar icons just blue buttons.

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

More
12 years 1 week ago #44730 by fgossart
Replied by fgossart on topic Filtering date interval
I put a mod (or hack) to accept filter scope values
in com_flexicontent/models/category.php
I add
Code:
defined( '_JEXEC' ) or die( 'Restricted access' ); require_once (JPATH_SITE.DS.'modules'.DS.'mod_flexicontent'.DS.'classes'.DS.'datetime.php');
And then in function _buildFilterWhere()
i add some lines
Code:
$filtervalue = JRequest::getVar('filter_'.$filtre->id, '', ''); // Skip filters without value $empty_filtervalue_array = is_array($filtervalue) && !strlen(trim(implode('',$filtervalue))); $empty_filtervalue_string = !is_array($filtervalue) && !strlen(trim($filtervalue)); //here some new line to replace initial scope filters if ($filtre->field_type=='date' && !$empty_filtervalue_array && !$empty_filtervalue_string) { date_time::replace_scope_category_filters($filtervalue); JRequest::setVar('filter_'.$filtre->id, $filtervalue); }

and in mod_flexicontent_classes/datetime.php I add a new function
Code:
function replace_scope_category_filters(&$filtervalue) { $search = array(); if (!is_array($filtervalue)) $search[1]=$filtervalue; else $search=$filtervalue; foreach ($search as $filterv_key=>$filterv_val) { $pattern = '/d|m|Y|H|i|s/'; if (preg_match($pattern, $filterv_val)) // is not a DATE but a SCOPE { $edate=explode(' ',$filterv_val); $new_date=''; if (count($edate)!=2) $new_date=date_time::shift_dates($new_date, '', $edate[0]); else $new_date=date_time::shift_dates($new_date, $edate[0], $edate[1]); $search[$filterv_key]=$new_date; } } if (!is_array($filtervalue)) $filtervalue=$search[1]; else $filtervalue=$search; }

It's just a first "hack" and works fine now for me if I put in initial (or probably permanent) filter some values like filter_id##d---15 d
Not tested with m Y but should work too.

I hope now you can soon add this enhancement so that I will not have to hack everytime

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

More
11 years 11 months ago #45735 by fgossart
Replied by fgossart on topic Filtering date interval
Could you confirm this new feature described above could be add for next release ?
There is no compatibility problems with other features, so it's an enhancement (I hope :)

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

More
11 years 11 months ago #45751 by ggppdk
Replied by ggppdk on topic Filtering date interval
Hello

this feature is nice, just it must have a little more strict regular expression to avoid problems

can you open a bug issue here:
code.google.com/p/flexicontent/issues/list

i will mark it as enhancement and accept it


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

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

More
10 years 3 months ago #58123 by fgossart
Replied by fgossart on topic Filtering date interval
It's an old topic and now I put a 3.xx release of FC and my feature you accepted is not present ..
So my work is broken again.
Shame.

I will have again to search into you code to put theses features.

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