I need some expert eyes to help me to sort my issue if possible
I'm going to explain the goal and what I did.
I use in a content page the plugin to call filelist.
The goal here is to limit the file shown in a page with the file created in the last 60 days.
I have tried several method, but the best method is to add some code in the Phocadownload plugin.
In the article, I have added a tag "day" like this :
{phocadownload view=filelist|id=51|day=60}
At the end, I have then "day=60".
The number 60 is not used right now but maybe in the future to chose the number of days (I will have to work more on this as I'm beginning on SQL and so .
Ok, in the phoca plugin file, i have add these code on line 122 in the part "Get plugin parameters from article" :
Code: Select all
else if($values[0]=='url') {$url = $values[1];}
else if($values[0]=='day') {$day = $values[1];}
}
Ok, now on lines 252+, I can see the case "Filelist" with the query.
To add my filtering here, I just add a condition and my query to limit only to the 60 last days of creation (i dont even check the value $day, just if the value is not empty) :
Code: Select all
case 'filelist':
$fileOrdering = PhocaDownloadOrdering::getOrderingText($ordering, 3);
if ($day !='') {
$query = 'SELECT a.id, a.title, a.alias, a.filename_play, a.filename_preview, a.link_external, a.image_filename, a.filename, a.date as date, c.id as catid, a.confirm_license, c.title as cattitle, c.alias as catalias'
. ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug,'
. ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as catslug'
. ' FROM #__phocadownload AS a'
. ' LEFT JOIN #__phocadownload_categories AS c ON a.catid = c.id'
. ' WHERE date BETWEEN DATE_SUB(NOW(), INTERVAL 60 DAY) AND NOW()';
} else {
$query = 'SELECT a.id, a.title, a.alias, a.filename_play, a.filename_preview, a.link_external, a.image_filename, a.filename, c.id as catid, a.confirm_license, c.title as cattitle, c.alias as catalias,'
. ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug,'
. ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as catslug'
. ' FROM #__phocadownload AS a'
. ' LEFT JOIN #__phocadownload_categories AS c ON a.catid = c.id';
}
But then, Mysql throw me an error...
Code: Select all
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(':', a.id, a.alias) ELSE a.id END ' at line 1
- To achieve what I want, Is this the good way ? (I know, if I update the extension, I will lose my changes
- What is going wrong in my query ?
A big thanks in advance to all for the help
Xavier