Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @package Joomla.Site
- * @subpackage mod_intercode_leading_items
- *
- * @copyright
- * @license GNU/Public
- */
- defined('_JEXEC') or die;
- $baseurl = JUri::base();
- $app = JFactory::getApplication();
- // Obtém o Item de Menu atualmente ativo
- $currentMenuItem = $app->getMenu()->getActive();
- // Obtém os parâmetros do Item de Menu atualmente ativo
- $menuparams = $currentMenuItem->params;
- // Agora você pode pegar um parâmetro em particular
- // pega todas as subcategorias
- $currentCategory = $currentMenuItem->query['id'];
- $categories = JCategories::getInstance('Article', $options);
- $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
- $model->getState();
- // Set application parameters in model
- $app = JFactory::getApplication();
- $appParams = $app->getParams();
- $model->setState('params', $appParams);
- // Set the filters based on the module params
- $model->setState('list.start', 0);
- $model->setState('list.limit', $menuparams->get('num_leading_articles'));
- $model->setState('filter.category_id', $currentCategory);
- $model->setState('filter.published', 1);
- $model->setState('filter.subcategories', true);
- $subCategoryLevels = $menuparams->get('maxLevel') == '0' ? '-1' : '';
- $model->setState('filter.max_category_levels', $subCategoryLevels);
- // Permissions
- $access = !JComponentHelper::getParams('com_content')->get('show_noauth');
- $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
- $model->setState('filter.access', $access);
- // Featured Item
- // Get article from featured set
- if ($params->get('featured') == '1'){
- $model->setState('filter.featured', 'only');
- }
- // Ordering
- $orderDate = $menuparams->get('order_date') ;
- if ($menuparams->get('order_date') == 'published'){
- $orderDate = 'a.publish_up';
- }
- $model->setState('list.ordering', $orderDate);
- $model->setState('list.direction', 'DESC');
- $items = $model->getItems();
- ?>
- <div class="lead-items intercode-leading-items intercode-leading-items<?php echo $moduleclass_sfx ?> row">
- <?php foreach ($items as $item) :?>
- <div class="lead-item col-md-4">
- <?php
- $images = json_decode($item->images);
- $intromage = $images->image_intro;
- ?>
- <?php if ($intromage) :?>
- <div class="item-image">
- <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($item->id)); ?>">
- <img src="<?php echo JUri::base().$intromage;?>" />
- </a>
- </div>
- <?php endif;?>
- <div class="article-info">
- <div class="category">
- <a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($item->catid)); ?>">
- <?php
- $category = JTable::getInstance('category');
- $category->load($item->catid);
- echo $category->title;?>
- </a>
- </div>
- </div>
- <div class="page-header">
- <h2 itemprop="name" class="lead-title">
- <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($item->id)); ?>">
- <?php echo $item->title;?>
- </a>
- </h2>
- </div>
- <div class="lead-text">
- <?php
- //Limite de caracteres
- $maxLimit = $params->get('max_chars');
- $text = $item->introtext.$item->textfull;
- $text = preg_replace("/\r\n|\r|\n/", " ", $text);
- // Em seguida, troca os marcadores <br /> com \n
- $text = preg_replace("/<BR[^>]*>/i", " ", $text);
- // Troca os marcadores <p> com \n\n
- $text = preg_replace("/<P[^>]*>/i", " ", $text);
- // Remove todos os marcadores
- $text = strip_tags($text);
- // Trunca o texto pelo limite de caracteres
- $text = substr($text, 0, $maxLimit);
- //$text = String::truncate($text, $maxLimit, '...', true);
- // Deixa visível a última palavra que, no caso, foi cortada no meio
- $text = preg_replace("/[.,!?:;]? [^ ]*$/", " ", $text);
- // Adiciona reticências ao fim do texto
- $text = trim($text) . '...' ;
- // Troca \n com <br />
- $text = str_replace("\n", " ", $text);
- echo $text;
- ?>
- </div>
- </div>
- <?php endforeach;?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement