Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined ('_JEXEC') or die('resticted aceess');
- //Load Helix
- $helix3_path = JPATH_PLUGINS.'/system/helix3/core/helix3.php';
- if (file_exists($helix3_path)) {
- require_once($helix3_path);
- helix3::addCSS('owl.carousel.css, owl.transitions.css, slide-animate.css') // CSS Files
- ->addJS('owl.carousel.min.js, addon.lp_slider.js, jquery.prettySocial.min.js'); // JS Files
- }
- // Required pagebuilder article helper
- require_once JPATH_COMPONENT . '/helpers/articles.php';
- AddonParser::addAddon('sp_latest_post','sp_latest_posts_addon');
- function sp_latest_posts_addon($atts){
- extract(spAddonAtts(array(
- "title" => '',
- "heading_selector" => 'h3',
- "theme" => 'default',
- "art_order" => 'latest',
- "see_all" => 0,
- "item_limit" => '',
- "leading_item" => '1',
- "sub_leading_item" => '2',
- "intro_text_limit" => '100',
- "column_no" => '3',
- "category_id" => '',
- "cat_color" => '',
- "before_title" => '',
- "cat_rand_color" => 1,
- "item_shadow" => 'rand',
- "show_cat" => '1',
- "class" => '',
- ), $atts));
- $doc = JFactory::getDocument();
- $items = SppagebuilderHelperArticles::getArticles($item_limit, $art_order, $category_id);
- //variables
- // create unique class
- $uniq_class = trim(str_replace(' ', '-', strtolower($title)));
- // if before icon is icon then generate icon or title first text
- $before_title = ($before_title) ? '<i class="fa ' . $before_title . '"></i>' : $title[0];
- //start structure
- $output = '<div class="sppb-addon sppb-addon-latest-posts ' . $class . ' ' . $art_order . ' ' . $theme . ' ' . $uniq_class . '">';
- // has icon color
- $icon_color = ($cat_color) ? 'background-color:' . $cat_color . ';' : '' ;
- // generate item shadow hover style
- if ($cat_color && $item_shadow =='fixed') {
- $shadow_color = '.sppb-addon-latest-posts.img_overlay.sp-gradien-on-hover.'.$theme.'.'.$uniq_class.' .latest-posts> .sppb-row .latest-post .overlay:before{ background-image: -webkit-linear-gradient(to bottom,rgba(0,0,0,0.1) 30%, ' . $cat_color . ' 70%) !important; background-image: linear-gradient(to bottom,rgba(0,0,0,0.1) 30%,' . $cat_color . ' 70%) !important; }';
- $doc->addStyleDeclaration($shadow_color);
- }
- // title
- if ($title) {
- $output .= '<div class="sppb-section-title sppb-text-center">';
- $output .= '<' . $heading_selector . ' class="sppb-title-heading"> <span class="spns-cat-icon" style="' . $icon_color . '">' . $before_title . '</span>' . $title . '</' . $heading_selector . '>';
- $output .= '</div>'; // END :: title
- }
- //$cat_url = '';
- if ($see_all && $category_id !='all' && $category_id) {
- $cat_url = JRoute::_(ContentHelperRoute::getCategoryRoute($category_id, $category_id));
- $output .= '<div class="sppb-addon-section-right">';
- $output .= '<a href="' . $cat_url . '">' . JText::_('COM_SPPAGEBUILDER_ADDON_LP_SEE_ALL') . '</a>';
- $output .= '</div>';
- }
- $output .= '<div class="sppb-addon-content">';
- $output .= '<div class="latest-posts clearfix">';
- $i= 0;
- if ($i < ($sub_leading_item+$leading_item)){
- $art_column_no = $sub_leading_item+$leading_item;
- }else{
- $art_column_no = $column_no;
- }
- foreach(array_chunk($items, $art_column_no) as $items) {
- $output .= '<div class="sppb-row">';
- foreach ($items as $key => $item) {
- // rand color generate
- $cat_icon_colors = array('#ed1c24', '#f26522', '#2e3192', '#00c8ff', '#ed145b', '#0072bc', '#0076a3', '#00a651', '#8dc63f', '#662d91');
- $rand_color = $cat_icon_colors[array_rand($cat_icon_colors)];
- if ($cat_rand_color) {
- $rand_color = 'style="background-color: ' . $rand_color . ';"';
- }else{
- $rand_color ='';
- }
- //before title icon
- $ft_color = ($cat_color && $item_shadow =='fixed') ? 'style="background-color: ' . $cat_color . ';"' : $rand_color ;
- // if leading items then carousel
- if ( ($i == 0) && ($i < $leading_item) ) {
- $output .= '<div id="slide-art-leading" class="owl-carousel col-sm-8">';
- }
- // Leading and normal item variable load
- $art_slide = '';
- $image = '';
- if ($i < $leading_item) {
- $image = (isset($item->image_thumbnail) && $item->image_medium) ? $item->image_medium : '' ;
- //$image = $item->image_medium;
- $item_column_no = '';
- $matchheight = '';
- $item_type = 'leading_item';
- $art_slide = 'sppb-art-slide-item item';
- // sub leading
- }elseif ($i < ($sub_leading_item+$leading_item)) {
- //$image = $item->image_thumbnail;
- $image = (isset($item->image_thumbnail) && $item->image_thumbnail) ? $item->image_thumbnail : '' ;
- $item_column_no = 4;
- $item_type = 'sub_leading_item';
- $matchheight = 'match-height';
- }else{
- $matchheight = 'match-height';
- $image = (isset($item->image_thumbnail) && $item->image_thumbnail) ? $item->image_thumbnail : '' ;
- //$image = $item->image_thumbnail;
- $item_column_no = round(12/$column_no);
- $item_type = 'intro_item';
- }
- $images = json_decode($item->images);
- $no_image = '';
- $no_image_style='';
- if (isset($image) && !empty($image)) {
- $image = $image;
- }elseif (isset($images->image_intro) && !empty($images->image_intro)) {
- $image = $images->image_intro;
- } elseif (isset($images->image_fulltext) && !empty($images->image_fulltext)) {
- $image = $images->image_fulltext;
- }else{
- $no_image ='no-image';
- $no_image_style = ($cat_color) ? 'style="background-color: '. $cat_color .';"' : '' ;
- }
- $output .= '<div class="latest-post sppb-col-sm-' . $item_column_no . ' ' . $item_type . ' '. $art_slide . ' ' . $no_image . '">';
- $output .= '<div class="latest-post-inner" ' . $no_image_style . '>';
- $output .= '<div class="overlay"></div>';
- $output .= '<div class="img-wrapper ' . $matchheight . '">';
- if ($image) {
- $output .= '<img class="img-responsive latest-post-image" src="' . $image .'">';
- }
- $output .= '</div>';
- // social share
- //$social_share = '<div class="sppb-post-share-social-icon"><i class="fa fa-users"></div>';
- $output .= '<div class="sppb-post-share-social">';
- $output .= '<a href="#" data-type="facebook" data-url="'. $_SERVER['SERVER_NAME'] . $item->link .'" data-title="'. $item->title .'" data-media="' . $image .'" class="prettySocial fa fa-facebook"></a>';
- $output .= '<a href="#" data-type="twitter" data-url="'. $_SERVER['SERVER_NAME'] . $item->link .'" data-description="'. $item->title .'" data-media="' . $image .'" data-via="joomshaper" class="prettySocial fa fa-twitter"></a>';
- $output .= '<a href="#" data-type="googleplus" data-url="'. $item->link .'" data-description="'. $item->title .'" data-media="' . $image .'" class="prettySocial fa fa-google-plus"></a>';
- $output .= '<a href="#" data-type="pinterest" data-url="'. $item->link .'" data-description="'. $item->title .'" data-media="' . $image .'" class="prettySocial fa fa-pinterest"></a>';
- $output .= '<a href="#" data-type="linkedin" data-url="'. $item->link .'" data-title="'. $item->title .'" data-description="'. $item->title .'" data-via="joomshaper" data-media="" class="prettySocial fa fa-linkedin"></a>';
- $output .= '<div class="share-icon"><i class="fa fa-share-alt"></i></div>';
- $output .= '</div>';
- $output .= '<div class="latest-post-infos">';
- $item->cat_link = JRoute::_(ContentHelperRoute::getCategoryRoute($item->catid));
- if ($show_cat && ($show_cat !='')) {
- $output .='<a href="' . $item->cat_link . '">';
- $output .='<p class="spns-slide-cat"><span class="spns-cat-icon" ' . $ft_color . ' > ' . mb_substr($item->category, 0, 1) . '</span>' . $item->category . '</p>';
- $output .='</a>';
- }
- $output .= '<h4 class="entry-title"><a href="' . $item->link . '">' . $item->title . '</a></h4>';
- //$output .= '<p class="intro-text" >' . truncate($item->introtext, $length=100) . '</p>';
- //$output .= '<p class="intro-text" >' . JHtml::_('string.truncate', strip_tags($item->introtext), $intro_text_limit) . '</p>';
- //$output .= '<div class="post-author"> <span class="entry-author"> ' . JText::_('COM_SPPAGEBUILDER_ADDON_SF_POSTED_BY'). ' ' . $item->user . '</span> </div>';
- $output .= '</div>'; // .latest-post-infos
- $output .= '</div>'; //atest-post-inner
- $output .= '</div>'; //.latest-post .col-sm
- // if leading items end then carousel close
- if ( ( $i != 0 ) && ( $i == $leading_item - 1) ) {
- $output .= '</div>'; //.carousel
- }
- $i ++;
- }
- $output .= '</div>'; //.sppb-row
- }
- $output .= '</div>'; //.latest-posts
- $output .= '</div>'; //.sppb-addon-content
- $output .= '</div>'; //.sppb-addon-latest-posts
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment