Skip to content

Instantly share code, notes, and snippets.

@uzielweb
Last active November 11, 2017 13:10
Show Gist options
  • Save uzielweb/66f81f76de5dd48810cf75d32c43a238 to your computer and use it in GitHub Desktop.
Save uzielweb/66f81f76de5dd48810cf75d32c43a238 to your computer and use it in GitHub Desktop.
Joomla Latest Articles Module with Youtube and VIMEO custom fields and ADD XML FIELDS plugin - put this file in templates/YOURTEMPLATE/html/mod_articles_latest
<?php
/**
* @package Joomla.Site
* @subpackage mod_articles_latest
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/*
Joomla Latest Articles Module with Youtube and VIMEO custom fields and ADD XML FIELDS plugin.
Put this fille in templates/YOURTEMPLATE/html/mod_articles_latest
The 'readmore' button is managed by ADD XML FIELDS plugin (visit my GITHUB to see more: https://github.com/uzielweb/add_xml_fields).
The following code load the params to shou readmore button with menu item
<?php $menuid = $params->get('mymenuitem', '2'); ?>
<a href="<?php echo JRoute::_('index.php?Itemid='.$menuid); ?>" class="readmore"><?php echo JText::_('COM_CONTENT_READ_MORE');?></a>
The Following code turns possible to limit video content articles quantity (please put a crazy number of articles to show before in the module, like this: 100 or 150 )
<?php $setlimit = $params->get('limit_articles', '6'); ?>
<?php if ($counter <= $setlimit) : ?>
*/
defined('_JEXEC') or die;
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
$menuid = $params->get('mymenuitem', '2');
$setlimit = $params->get('limit_articles', '6');
?>
<ul class="allvideos latesvideos<?php echo $moduleclass_sfx; ?>">
<?php $i = "1"; ?>
<?php foreach ($list as $counter => $item) : ?>
<?php
$itemFields = FieldsHelper::getFields('com_content.article', $item, true);
?>
<?php foreach ($itemFields as $k => $itemField) : ?>
<?php if (($itemField->type == 'youtube') and ($itemField->value != '') or ($itemField->type == 'vimeo') and ($itemField->value != '')) : ?>
<?php $videocount = $i++; ?>
<?php if ($videocount <= $setlimit) : ?>
<li class="row videolist" itemscope itemtype="https://schema.org/Article">
<div class="video col-md-4">
<?php
echo $itemField->value;
?>
</div>
<div class="text col-md-8">
<div class="category"> <a href="<?php echo JRoute::_('index.php?option=com_content&view=category&layout=blog&id=' . $item->catid); ?>"><?php echo $item->category_title; ?></a></div>
<a href="<?php echo $item->link; ?>" itemprop="url">
<h4 class="videocategory" itemprop="name">
<?php echo $item->title; ?>
</h4>
</a>
<?php echo $item->introtext; ?>
<div class="footertext">
<i class="fa fa-clock-o"></i><span class="date-and-time"><?php echo JHtml::date($item->publish_up, 'd M Y'); ?></span><i class="fa fa-eye"></i><span class="hits-counter"><?php echo $item->hits; ?></span>
</div>
</div>
</li>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endforeach; ?>
</ul>
<a href="<?php echo JRoute::_('index.php?Itemid=' . $menuid); ?>" class="readmore"><?php echo JText::_('COM_CONTENT_READ_MORE'); ?></a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment