Bug found in mod_sobi2simplefeatured v2.0.6
Problem DescriptionWhen configuring mod_sobi2simplefeatured with;
Output Controls - Sorting Order - Output Entries sorted by = Date created: most recent first
Output Controls - Sorting Order - Output Entries sorted by = Date created: most recent last
mod_sobi2simplefeatured actually sorts by SOBI2 itemid (ascending and descending), not SOBI2 Entry Creation Date.
Problem first reported
"Published"-date changed, not recognised by ModuleSolution(1) Download the zip file attached to this posting, (this patch only fixes this reported problem).
(Download only visible to registered and logged in Forum Users)
(2) extract the file 'helper.php' from 'helper.zip'
(3) Replace the file;
MyJoomlaInstallation/modules/mod_sobi2simplefeatured/helper.php
with the file ''helper.php' extracted from 'helper.zip'
Alternatively
(1) Edit the file
MyJoomlaInstallation/modules/mod_sobi2simplefeatured/helper.php
(2) Find the PHP Code beginning around Line 218 and change
From
# Define database Fields needed for Entry Selection and/or 'standard data' sorting
$fields='item.'.$db->nameQuote('itemid');
$fields.=', item.'.$db->nameQuote('title');
$fields.=', item.'.$db->nameQuote('icon');
$fields.=', item.'.$db->nameQuote('image');
$fields.=', item.'.$db->nameQuote('hits');
$fields.=', item.'.$db->nameQuote('last_update'); # for Sorting only
$fields.=', cf_itemid.'.$db->nameQuote('itemid');
To
# Define database Fields needed for Entry Selection and/or 'standard data' sorting
$fields='item.'.$db->nameQuote('itemid');
$fields.=', item.'.$db->nameQuote('title');
$fields.=', item.'.$db->nameQuote('icon');
$fields.=', item.'.$db->nameQuote('image');
$fields.=', item.'.$db->nameQuote('hits');
$fields.=', item.'.$db->nameQuote('publish_up'); # for Sorting only
$fields.=', item.'.$db->nameQuote('last_update'); # for Sorting only
$fields.=', cf_itemid.'.$db->nameQuote('itemid');
(3) Find the PHP Code beginning around Line 262 and change
From
# Define Sorting Order statement
$sort=NULL;
if ($this->params->get('sortOrder')=='Random'){$sort=' ORDER BY RAND()';}
elseif ($this->params->get('sortOrder')=='ItemidAsc'){$sort=' ORDER BY item.'.$db->nameQuote('itemid').' ASC';}
elseif ($this->params->get('sortOrder')=='ItemidDesc'){$sort=' ORDER BY item.'.$db->nameQuote('itemid').' DESC';}
To
# Define Sorting Order statement
$sort=NULL;
if ($this->params->get('sortOrder')=='Random'){$sort=' ORDER BY RAND()';}
elseif ($this->params->get('sortOrder')=='ItemidAsc'){$sort=' ORDER BY item.'.$db->nameQuote('publish_up').' ASC';}
elseif ($this->params->get('sortOrder')=='ItemidDesc'){$sort=' ORDER BY item.'.$db->nameQuote('publish_up').' DESC';}
This fix will be included in mod_sobi2simplefeatured v2.0.7
ExplanationWhen configuring mod_sobi2simplefeatured with;
Output Controls - Sorting Order - Output Entries sorted by = Date created: most recent first
Output Controls - Sorting Order - Output Entries sorted by = Date created: most recent last
mod_sobi2simplefeatured actually sorts by by SOBI2 itemid, because under 'normal' situations the SOBI2 Entry creation date (publish_up) and the SOBI2 itemid number sequencing should produce the same sort results.
However, while it is not possible for a SOBI2 Administrator to change a SOBI2 itemid, it is possible for a SOBI2 Administrator to change a SOBI2 Entry creation date, and hence the Sorting by 'Date created" options produce the wrong results.
For mod_sobi2simplefeatured v2.0.7
I need to;
(1) Add the option to rename the Sort by Creation Date to Sort by Sobi2 itemid and add the option to Sort by Creation Date by;
(a) Change mod_sobi2simplefeatured.xml
From
<!-- Start Output Controls - Sort Order -->
<param type="spacer" default="GROUP:OUTPUT-CONTROL-SORT-ORDER" />
<param name="sortOrder" type="list" default="Random" label="LABEL:SORT-ORDER" description="DESC:SORT-ORDER">
<option value="Random">OPTION:SORT-RANDOM</option>
<option value="ItemidDesc">OPTION:SORT-ITEMID-DESC</option>
<option value="ItemidAsc">OPTION:SORT-ITEMID-ASC</option>
<option value="EditDesc">OPTION:SORT-EDIT-DESC</option>
<option value="EditAsc">OPTION:SORT-EDIT-ASC</option>
To
<!-- Start Output Controls - Sort Order -->
<param type="spacer" default="GROUP:OUTPUT-CONTROL-SORT-ORDER" />
<param name="sortOrder" type="list" default="Random" label="LABEL:SORT-ORDER" description="DESC:SORT-ORDER">
<option value="Random">OPTION:SORT-RANDOM</option>
<option value="ItemidDesc">OPTION:SORT-ITEMID-DESC</option>
<option value="ItemidAsc">OPTION:SORT-ITEMID-ASC</option>
<option value="CreateDesc">OPTION:SORT-CREATE-DESC</option>
<option value="CreateAsc">OPTION:SORT-CREATE-ASC</option>
<option value="EditDesc">OPTION:SORT-EDIT-DESC</option>
<option value="EditAsc">OPTION:SORT-EDIT-ASC</option>
(b) Change en-GB.mod_sobi2simplefeatured.ini
From
SPACER:SORTING = <span style='color:#0B55C4;'>Output Control - Sort Order</span>
LABEL:SORT-ORDER = Output Entries sorted by
DESC:SORT-ORDER = Select the order in which each Entry should be output.
OPTION:SORT-RANDOM = Random
OPTION:SORT-ITEMID-ASC = Date created: most recent last
OPTION:SORT-ITEMID-DESC = Date created: most recent first
OPTION:SORT-EDIT-ASC = Date edited: most recent last
OPTION:SORT-EDIT-DESC = Date edited: most recent first
To
SPACER:SORTING = <span style='color:#0B55C4;'>Output Control - Sort Order</span>
LABEL:SORT-ORDER = Output Entries sorted by
DESC:SORT-ORDER = Select the order in which each Entry should be output.
OPTION:SORT-RANDOM = Random
OPTION:SORT-ITEMID-ASC = Sobi2 itemid: most recent last
OPTION:SORT-ITEMID-DESC = Sobi2 itemid: most recent first
OPTION:SORT-CREATE-ASC = Date created: most recent last
OPTION:SORT-CREATE-DESC = Date created: most recent first
OPTION:SORT-EDIT-ASC = Date edited: most recent last
OPTION:SORT-EDIT-DESC = Date edited: most recent first
(c) Change helper.php
From
# Define database Fields needed for Entry Selection and/or 'standard data' sorting
$fields='item.'.$db->nameQuote('itemid');
$fields.=', item.'.$db->nameQuote('title');
$fields.=', item.'.$db->nameQuote('icon');
$fields.=', item.'.$db->nameQuote('image');
$fields.=', item.'.$db->nameQuote('hits');
$fields.=', item.'.$db->nameQuote('last_update'); # for Sorting only
$fields.=', cf_itemid.'.$db->nameQuote('itemid');
To
# Define database Fields needed for Entry Selection and/or 'standard data' sorting
$fields='item.'.$db->nameQuote('itemid');
$fields.=', item.'.$db->nameQuote('title');
$fields.=', item.'.$db->nameQuote('icon');
$fields.=', item.'.$db->nameQuote('image');
$fields.=', item.'.$db->nameQuote('hits');
$fields.=', item.'.$db->nameQuote('publish_up'); # for Sorting only
$fields.=', item.'.$db->nameQuote('last_update'); # for Sorting only
$fields.=', cf_itemid.'.$db->nameQuote('itemid');
and
From
# Define Sorting Order statement
$sort=NULL;
if ($this->params->get('sortOrder')=='Random'){$sort=' ORDER BY RAND()';}
elseif ($this->params->get('sortOrder')=='ItemidAsc'){$sort=' ORDER BY item.'.$db->nameQuote('itemid').' ASC';}
elseif ($this->params->get('sortOrder')=='ItemidDesc'){$sort=' ORDER BY item.'.$db->nameQuote('itemid').' DESC';}
elseif ($this->params->get('sortOrder')=='EditAsc'){$sort=' ORDER BY item.'.$db->nameQuote('last_update').' ASC';}
elseif ($this->params->get('sortOrder')=='EditDesc'){$sort=' ORDER BY item.'.$db->nameQuote('last_update').' DESC';}
To
# Define Sorting Order statement
$sort=NULL;
if ($this->params->get('sortOrder')=='Random'){$sort=' ORDER BY RAND()';}
elseif ($this->params->get('sortOrder')=='ItemidAsc'){$sort=' ORDER BY item.'.$db->nameQuote('itemid').' ASC';}
elseif ($this->params->get('sortOrder')=='ItemidDesc'){$sort=' ORDER BY item.'.$db->nameQuote('itemid').' DESC';}
elseif ($this->params->get('sortOrder')=='CreateAsc'){$sort=' ORDER BY item.'.$db->nameQuote('publish_up').' ASC';}
elseif ($this->params->get('sortOrder')=='CreateDesc'){$sort=' ORDER BY item.'.$db->nameQuote('publish_up').' DESC';}
elseif ($this->params->get('sortOrder')=='EditAsc'){$sort=' ORDER BY item.'.$db->nameQuote('last_update').' ASC';}
elseif ($this->params->get('sortOrder')=='EditDesc'){$sort=' ORDER BY item.'.$db->nameQuote('last_update').' DESC';}
(2) and perhaps also investigate of adding sorting by SOBI2 Entry Expiration Date (publish_down), which will be a little more complicated as the default value for publish_down is 0000-00-00 00:00:00 (for never expires), otherwise it is set to an actual y-m-d h:i:s date value.
Regards - Mark