I want to show the published date inside a module, how can I do that? I will make of course a module override and use the changes inside the default.php
Thank you
I want to show the published date inside a module, how can I do that? I will make of course a module override and use the changes inside the default.php
Thank you
The following should work for what it sounds like you are trying to achieve. If you are on an article page, it displays the published date of that article or else shows nothing.
// FIRSTLY CHECK THAT THE PAGE THE MODULE APPEARS ON IS AN ARTICLE
$nameofcomponent = JRequest::getVar('option');
$viewofcomponent = JRequest::getVar('view');
if ($nameofcomponent=="com_content" && $viewofcomponent=="article" ) {
// IT IS AN ARTICLE, SO GET THE ID OF THE ARTICLE
$idofarticle = JRequest::getInt('id');
// LOAD THE MODEL OF COM_CONTENT
$model = JModelLegacy::getInstance('Article', 'ContentModel');
// USE THE GETITEM FUNCTION OF THE MODEL TO RETURN THE DETAILS
$article = $model->getItem($idofarticle);
// FORMAT AND PRINT THE DATE TO THE SCREEN
$date = new JDate($article->created);
echo $date->format('j M Y');
}
If this is what you are trying to do, however, then it sounds like there may be a design issue - I can't imagine a usibility reason why you'd want to show this information in a module rather than the component area.
The module has to support this - meaning that it has first to fetch and have available these data in its content items object/array through whatever method it uses to call the articles.
Usually if it supports that, then it should have the relative options in its backend.
If it doesn't support this, then either look for another module - there are plenty articles display modules available in JED - or develop your own.
Note: maybe I have mis-understood your question though.
You can use the Module from: https://db8.eu/ to display article creating, updated Date to any module position