roxcoder

Untitled

Jan 18th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.67 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * @package Onepage
  5.  * @author JoomShaper http://www.joomshaper.com
  6.  * @copyright Copyright (c) 2010 - 2016 JoomShaper
  7.  * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
  8.  */
  9. //no direct accees
  10. defined('_JEXEC') or die('resticted aceess');
  11.  
  12. require_once JPATH_ROOT . '/components/com_sppagebuilder/helpers/articles.php';
  13.  
  14. class SppagebuilderAddonLatest_post extends SppagebuilderAddons {
  15.  
  16.     public function render() {
  17.         $class = (isset($this->addon->settings->class) && $this->addon->settings->class) ? $this->addon->settings->class : '';
  18.         $title = (isset($this->addon->settings->title) && $this->addon->settings->title) ? $this->addon->settings->title : '';
  19.         $heading_selector = (isset($this->addon->settings->heading_selector) && $this->addon->settings->heading_selector) ? $this->addon->settings->heading_selector : 'h3';
  20.  
  21.         $item_limit = (isset($this->addon->settings->item_limit) && $this->addon->settings->item_limit) ? $this->addon->settings->item_limit : '';
  22.         $ordering = (isset($this->addon->settings->ordering) && $this->addon->settings->ordering) ? $this->addon->settings->ordering : 'latest';
  23.         $post_type = (isset($this->addon->settings->post_type) && $this->addon->settings->post_type) ? $this->addon->settings->post_type : '';
  24.         $catid = (isset($this->addon->settings->category) && $this->addon->settings->category) ? $this->addon->settings->category : '';
  25.  
  26.         $items = SppagebuilderHelperArticles::getArticles($item_limit, $ordering, $catid, TRUE, $post_type);
  27.  
  28.  
  29.         //start output
  30.         $output = '<div class="sppb-addon sppb-addon-latest-posts ' . $class . '">';
  31.         $output .= '<div class="sppb-addon-content">';
  32.         $output .= '<div class="latest-posts clearfix">';
  33.  
  34.         foreach (array_chunk($items, 2) as $items) {
  35.             $output .='<div class="sppb-row">';
  36.  
  37.             foreach ($items as $item) {
  38.  
  39.                 $image = '';
  40.                 //image
  41.                 if (isset($item->image_thumbnail) && $item->image_thumbnail) {
  42.                     $image = JURI::root() . $item->image_thumbnail;
  43.                 } elseif (isset($images->image_intro) && !empty($images->image_intro)) {
  44.                     $image = $images->image_intro;
  45.                 } elseif (isset($images->image_fulltext) && !empty($images->image_fulltext)) {
  46.                     $image = $images->image_fulltext;
  47.                 }
  48.  
  49.                 $output .= '<div class="latest-post sppb-column sppb-col-sm-6" >';
  50.  
  51.                 $output .= '<div class="latest-post-inner">';
  52.  
  53.                 $output .= '<a href="' . $item->link . '">';
  54.                 if ($image) {
  55.                     $output .= '<div class="img-hexagon">';
  56.                     $output .= '<div>';
  57.                     $output .= '<div style="background-image: url(\'' . $image . '\')"></div>';
  58.                     $output .= '</div>';
  59.                     $output .= '</div>'; // /.img-hexagon
  60.                 }
  61.                 $output .= '</a>';
  62.  
  63.                 $output .= '<h4 class="entry-title"><a href="' . $item->link . '">' . $item->title . '</a></h4>';
  64.                 $output .= '<div class="entry-meta"><span class="entry-date"> ' . JHtml::_('date', $item->created, 'DATE_FORMAT_LC3') . '</span></div>';
  65.  
  66.                 $output .= '</div>';
  67.  
  68.                 $output .= '</div>';
  69.             } // END:: items foreach
  70.  
  71.             $output .= '</div>'; // END:: row
  72.         } // END:: array_chunk
  73.  
  74.         $output .= '</div>'; // /.latest-posts
  75.         $output .= '</div>'; // /.sppb-addon-content
  76.         $output .= '</div>'; // /.sppb-addon-latest-posts
  77.  
  78.         return $output;
  79.     }
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment