I got asked to show the published date instead of creation date on my view item on front end.
Here is the way I did it on 2.0.0 RC9a (r1549) if it can help somebody.
(I put my message on general support on purpose for letting flexi team decide if it has a value or not).
So, what you have to do:
1. Create a new field in the field list in flexi back office with the exact name "publish_up" (it's the db name for the publishing date); link it to your content type (for example :"Article") and put access to "Public".
2. Edit your database : table xxx_flexicontent_fields and modify the line of your "publish_up" item with the following value :
`field_type` : 'publishup'
`iscore` : 1
`attribs` :
display_label=1
date_format=DATE_FORMAT_LC1
custom_date=
pretext=
posttext=
3. Add graphically your new field in the template via the "templates" section in flexicontent back office.
4. Edit flexicontent sources :
Warning : following code came from a diff
the lines to add starts with +
the lines to remove starts with -
components/com_flexicontent/classes/flexicontent.fields.php ; line 179 :
Code:
$item->modified = ($item->modified != $db->getNulldate()) ? $item->modified : $item->created;
+ $item->publish_up = ($item->publish_up != $db->getNulldate()) ? $item->publish_up : $item->modified;
$item->creator = @$author->alias ? $author->alias : (@$author->name ? $author->name : '') ;
components/com_flexicontent/classes/flexicontent.helper.php lines 1644-1724
Be careful : my item was id 15, you must change this value in the following code to your.
Code:
function getJCoreFields($ffield=NULL, $map_maintext_to_introtext=false, $reverse=false) {
if(!$reverse) // MAPPING core fields NAMEs => core field TYPEs
{
$flexifield = array(
'title'=>'title',
'categories'=>'categories',
'tags'=>'tags',
'text'=>'maintext',
'created'=>'created',
'created_by'=>'createdby',
'modified'=>'modified',
'modified_by'=>'modifiedby',
'hits'=>'hits',
'document_type'=>'type',
'version'=>'version',
- 'state'=>'state'
+ 'state'=>'state',
+ 'publish_up'=>'publishup'
);
if ($map_maintext_to_introtext)
{
$flexifield['introtext'] = 'maintext';
}
}
else // MAPPING core field TYPEs => core fields NAMEs
{
$flexifield = array(
'title'=>'title',
'categories'=>'categories',
'tags'=>'tags',
'maintext'=>'text',
'created'=>'created',
'createdby'=>'created_by',
'modified'=>'modified',
'modifiedby'=>'modified_by',
'hits'=>'hits',
'type'=>'document_type',
'version'=>'version',
- 'state'=>'state'
+ 'state'=>'state',
+ 'publishup'=>'publish_up'
);
if ($map_maintext_to_introtext)
{
$flexifield['maintext'] = 'introtext';
}
}
if($ffield===NULL) return $flexifield;
return isset($flexifield[$ffield])?$flexifield[$ffield]:NULL;
}
function getFlexiFieldId($jfield=NULL) {
$flexifields = array(
'introtext'=>1,
'text'=>1,
'created'=>2,
'created_by'=>3,
'modified'=>4,
'modified_by'=>5,
'title'=>6,
'hits'=>7,
'version'=>9,
'state'=>10,
- 'catid'=>13
+ 'catid'=>13,
+ 'publish_up'=>15
);
if($jfield===NULL) return $flexifields;
return isset($flexifields[$jfield])?$flexifields[$jfield]:0;
}
function getFlexiField($jfield=NULL) {
$flexifields = array(
'introtext'=>'text',
'fulltext'=>'text',
'created'=>'created',
'created_by'=>'createdby',
'modified'=>'modified',
'modified_by'=>'modifiedby',
'title'=>'title',
'hits'=>'hits',
'version'=>'version',
- 'state'=>'state',
+ 'state'=>'state',
+ 'publish_up'=>'publishup'
);
if($jfield===NULL) return $flexifields;
return isset($flexifields[$jfield])?$flexifields[$jfield]:0;
}
plugins/flexicontent_fields/core/core.php; line 107 :
Code:
+ case 'publishup': // publish_up
+ $field->value[] = $item->publish_up;
+ $dateformat = $dateformat ? $dateformat : $customdate;
+ $field->display = $pretext.JHTML::_( 'date', $item->publish_up, JText::_($dateformat) ).$posttext;
+ break;
case 'title': // title
I got some problem first because of caching but it seems to be enough to work.