templates/my_template/html/layouts/joomla/content/info_block/publish_date.php
require_once JPATH_THEMES . '/my_teplate/helper.php'; // подключаю файл с функцией
<span uk-icon="icon: calendar"></span>
<time datetime="<?php echo JHtml::_('date', $art_publish_date, 'c'); ?>" itemprop="datePublished">
<?php echo publish_date ($art_publish_date); ?>
</time>
templates/my_template/helper.php
function publish_date($timestamp) {
$current_time = time();
$publish_time = strtotime($timestamp);
$time_diff = $current_time - $publish_time;
$seconds = $time_diff;
$minutes = round($seconds / 60); // 60 секунд. Минуты в UNIX формате даты
$days = JHtml::_('date', $current_time, 'd') - JHtml::_('date', $publish_time, 'd');
$minutes_interval = $minutes >= 2 && $minutes <= 4 || $minutes >= 22 && $minutes <= 24 || $minutes >= 32 && $minutes <= 34 || $minutes >= 42 && $minutes <= 44 || $minutes >= 52 && $minutes <= 54;
$minut_interval = $minutes == 0 || $minutes >= 5 && $minutes <= 20 || $minutes >= 25 && $minutes <= 30 || $minutes >= 35 && $minutes <= 40 || $minutes >= 45 && $minutes <= 50 || $minutes >= 55 && $minutes <= 60;
$minuta_interval = $minutes == 1 | $minutes == 21 || $minutes == 31 || $minutes == 41 || $minutes == 51;
if ($seconds <= 60) {
return "<span>" . JText::_('COM_CCK_JUST_NOW') . "</span>";
} else if ($minutes <= 59) {
if ($minutes == 1) {
return "<span>" . JText::_('COM_CCK_JUST_NOW') . "</span>";
} else if ($minutes_interval) {
return "<span>" . $minutes . " " . JText::_('COM_CCK_MINUTES') . " " . JText::_('COM_CCK_AGO') . "</span>";
} else if ($minut_interval) {
return "<span>" . $minutes . " " . JText::_('COM_CCK_MINUT') . " " . JText::_('COM_CCK_AGO') . "</span>";
} else if ($minuta_interval) {
return "<span>" . $minutes . " " . JText::_('COM_CCK_MINUTE') . " " . JText::_('COM_CCK_AGO') . "</span>";
}
} else if ($days == 0) {
return "<span>" . JText::_('COM_CCK_TODAY_AT') . " " . JHtml::_('date', $timestamp, JText::_('DATE_FORMAT_LC12')) . "</span>";
}else if ($days == 1) {
return "<span>" . JText::_('COM_CCK_YESTERDAY_IN') . " " . JHtml::_('date', $timestamp, JText::_('DATE_FORMAT_LC12')) . "</span>";
} else {
return "<span>" . JHtml::_('date', $timestamp, JText::_('DATE_FORMAT_LC2')) . "</span>";
}
}
my_site\language\overrides\ru-RU.override.ini
DATE_FORMAT_LC12="H:i"
COM_CCK_JUST_NOW="опубликовано только что"
COM_CCK_MINUT="минут"
COM_CCK_MINUTE="минута"
COM_CCK_MINUTES="минуты"
COM_CCK_AGO="назад"
templates/my_template/html/layouts/joomla/content/info_block
<?php defined('JPATH_BASE') or die;
echo $this->escape($displayData['item']->category_title);
?>
<?php defined('JPATH_BASE') or die;
echo JHtml::_('date', $displayData['item']->publish_up, JText::_('DATE_FORMAT_LC2'));
?>
$cat_name = JLayoutHelper::render('joomla.content.info_block.category_title', array('item' => $this->item));
$art_publish_date = JLayoutHelper::render('joomla.content.info_block.publish_date_no_html', array('item' => $this->item));
JRequest::setVar('cat_name', $cat_name, 'post'); //задаем глобальную переменную
JRequest::setVar('art_publish_date', $art_publish_date, 'post'); //задаем глобальную переменную
$cat_name = JRequest::getVar('cat_name', '', 'post'); //считываем глобальную переменную
$art_publish_date = JRequest::getVar('art_publish_date', '', 'post'); //считываем глобальную переменную
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>
$myarr = array_slice($this->intro_items, 3);
$this->intro_items
$myarr
<?php
$myarr = array_slice($this->intro_items, 3);
foreach ($myarr_items as $key => &$item) :
?>
<?php if (!empty($this->intro_items)) :
$myarr = array_slice($this->intro_items, 0, 3);
foreach ($myarr as $key => &$item) :
$this->item = &$item;
echo $this->loadTemplate('item');
endforeach;
endif; ?>
echo $this->loadTemplate('item');
templates/my_template/html/com_content/category