EdgarNotPoe's picture
write a code for Joomla 6.x template which copy Headspace app
e07769f verified
<?php
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Content\Site\Helper\RouteHelper;
HTMLHelper::addIncludePath(JPATH_COMPONENT . '/helpers');
HTMLHelper::_('behavior.caption');
$app = Factory::getApplication();
// Create shortcuts to some properties.
$params = $this->item->params;
$images = json_decode($this->item->images);
$urls = json_decode($this->item->urls);
$canEdit = $params->get('access-edit');
$user = Factory::getUser();
$info = $params->get('info_block_position', 0);
$attribs = json_decode($this->item->attribs);
?>
<div class="item-page<?php echo $this->pageclass_sfx; ?>" itemscope itemtype="https://schema.org/Article">
<meta itemprop="inLanguage" content="<?php echo ($this->item->language === '*' ? Factory::getApplication()->get('language') : $this->item->language); ?>">
<?php if ($this->params->get('show_page_heading')) : ?>
<div class="page-header">
<h1> <?php echo $this->escape($this->params->get('page_heading')); ?> </h1>
</div>
<?php endif; ?>
<?php if (!empty($this->item->pagination) && !$this->item->paginationposition && $this->item->paginationrelative) {
echo $this->item->pagination;
} ?>
<?php if ($params->get('show_title')) : ?>
<div class="page-header">
<h2 itemprop="headline">
<?php echo $this->escape($this->item->title); ?>
</h2>
<?php if ($this->item->state == 0) : ?>
<span class="label label-warning"><?php echo Text::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
<?php if (strtotime($this->item->publish_up) > strtotime(Factory::getDate())) : ?>
<span class="label label-warning"><?php echo Text::_('JNOTPUBLISHEDYET'); ?></span>
<?php endif; ?>
<?php echo $this->item->event->afterDisplayTitle; ?>
</div>
<?php endif; ?>
<?php if ($canEdit) : ?>
<div class="mb-4 flex gap-2">
<?php echo HTMLHelper::_('icon.edit', $this->item, $params); ?>
<?php echo HTMLHelper::_('icon.print_popup', $this->item, $params); ?>
<?php echo HTMLHelper::_('icon.email', $this->item, $params); ?>
</div>
<?php endif; ?>
<?php // Content is generated by content plugin event "onContentAfterTitle" ?>
<?php echo $this->item->event->afterDisplayTitle; ?>
<?php if ($params->get('show_tags') && !empty($this->item->tags->itemTags)) : ?>
<?php $this->item->tagLayout = new FileLayout('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
<?php endif; ?>
<?php // Content is generated by content plugin event "onContentBeforeDisplay" ?>
<?php echo $this->item->event->beforeDisplayContent; ?>
<?php if (isset($urls) && ((!empty($urls->urls_position) && ($urls->urls_position == '0')) || ($params->get('urls_position') == '0' && empty($urls->urls_position))) || (empty($urls->urls_position) && (!$params->get('urls_position')))) : ?>
<?php echo $this->loadTemplate('links'); ?>
<?php endif; ?>
<?php if ($params->get('access-view')) : ?>
<?php
if (!empty($this->item->pagination) && !$this->item->paginationposition && $this->item->paginationrelative) {
echo $this->item->pagination;
}
?>
<?php if (isset($images->image_fulltext) && !empty($images->image_fulltext)) : ?>
<?php $imgfloat = empty($images->float_fulltext) ? $params->get('float_fulltext') : $images->float_fulltext; ?>
<figure class="mb-6 overflow-hidden rounded-2xl">
<img<?php if ($images->image_fulltext_caption) : ?> class="w-full h-auto object-cover"<?php endif; ?> src="<?php echo htmlspecialchars($images->image_fulltext, ENT_COMPAT, 'UTF-8'); ?>" alt="<?php echo htmlspecialchars($images->image_fulltext_alt, ENT_COMPAT, 'UTF-8'); ?>" itemprop="image"/>
<?php if ($images->image_fulltext_caption) : ?>
<figcaption class="text-sm text-gray-500 mt-2 text-center bg-orange-50 p-2 rounded-b-2xl">
<?php echo htmlspecialchars($images->image_fulltext_caption, ENT_COMPAT, 'UTF-8'); ?>
</figcaption>
<?php endif; ?>
</figure>
<?php endif; ?>
<div itemprop="articleBody" class="prose prose-orange max-w-none">
<?php echo $this->item->text; ?>
</div>
<?php if ($info == 1 || $info == 2) : ?>
<?php if ($useDefList) : ?>
<div class="bg-orange-50 rounded-xl p-4 mt-6 text-sm text-gray-600">
<?php // Note: Not exists edit and edit-state in Joomla 4 ?>
<?php echo LayoutHelper::render('joomla.content.info_block', array('item' => $this->item, 'params' => $params, 'position' => 'above')); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if (!empty($this->item->pagination) && $this->item->pagination && $this->item->paginationposition && !$this->item->paginationrelative) : ?>
<?php echo $this->item->pagination; ?>
<?php endif; ?>
<?php if (isset($urls) && ((!empty($urls->urls_position) && ($urls->urls_position == '1')) || ($params->get('urls_position') == '1'))) : ?>
<?php echo $this->loadTemplate('links'); ?>
<?php endif; ?>
<?php // Optional teaser intro text for guests ?>
<?php elseif ($params->get('show_noauth') == true && $user->get('guest')) : ?>
<?php echo LayoutHelper::render('joomla.content.intro_image', $this->item); ?>
<?php echo HTMLHelper::_('content.prepare', $this->item->introtext); ?>
<?php // Optional link to let them register to see the whole article. ?>
<?php if ($params->get('show_readmore') && $this->item->fulltext != null) : ?>
<?php $menu = Factory::getApplication()->getMenu(); ?>
<?php $active = $menu->getActive(); ?>
<?php $itemId = $active->id; ?>
<?php $link = new Uri(Route::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false)); ?>
<?php $link->setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language))); ?>
<p class="readmore">
<a href="<?php echo $link; ?>" class="btn btn-secondary">
<?php $attribs = json_decode($this->item->attribs); ?>
<?php if ($attribs->alternative_readmore == null) : ?>
<?php echo Text::_('COM_CONTENT_REGISTER_TO_READ_MORE'); ?>
<?php elseif ($readmore = $attribs->alternative_readmore) : ?>
<?php echo $readmore; ?>
<?php if ($params->get('show_readmore_title', 0) != 0) : ?>
<?php echo HTMLHelper::_('string.truncate', $this->item->title, $params->get('readmore_limit')); ?>
<?php endif; ?>
<?php elseif ($params->get('show_readmore_title', 0) == 0) : ?>
<?php echo Text::sprintf('COM_CONTENT_READ_MORE_TITLE'); ?>
<?php else : ?>
<?php echo Text::_('COM_CONTENT_READ_MORE'); ?>
<?php echo HTMLHelper::_('string.truncate', $this->item->title, $params->get('readmore_limit')); ?>
<?php endif; ?>
</a>
</p>
<?php endif; ?>
<?php endif; ?>
<?php // Content is generated by content plugin event "onContentAfterDisplay" ?>
<?php echo $this->item->event->afterDisplayContent; ?>
</div>