Advanced custom fields if true do this else - php

I have a tickbox for in my advanced custom fields that when ticked it puts the image above the text, I have it working but I think it can be done better than I have it. Here is what I have in my template:
<?php if( $image_two = get_sub_field('image-two') ): ?>
<a href="<?php echo $image_link_two; ?>">
<img src="<?php echo $image_two; ?>" class="col-image"></a>
<?php endif; ?>
<?php if( $header_two = get_sub_field('header-two') ): ?>
<h2 style="color: <?php echo $text_colour_two; ?>"><?php echo $header_two; ?></h2>
<?php endif; ?>
<?php if( $subtext_two = get_sub_field('sub-text-two') ): ?>
<span class="subtext" style="color: <?php echo $text_colour_two; ?>"><?php echo $subtext_two; ?></span>
<?php endif; ?>
<?php if( $button_text_two = get_sub_field('button-text-two') ): ?>
<button class="btn-text" style="color: <?php echo $button_text_colour_two; ?>; background-color: <?php echo $button_background_two; ?>"><?php echo $button_text_two ?></button>
<?php endif; ?>
<?php else: ?>
<?php if( $header_two = get_sub_field('header-two') ): ?>
<h2 style="color: <?php echo $text_colour_two; ?>"><?php echo $header_two; ?></h2>
<?php endif; ?>
<?php if( $subtext_two = get_sub_field('sub-text-two') ): ?>
<span class="subtext" style="color: <?php echo $text_colour_two; ?>"><?php echo $subtext_two; ?></span>
<?php endif; ?>
<?php if( $image_two = get_sub_field('image-two') ): ?>
<img src="<?php echo $image_two; ?>" class="col-image">
<?php endif; ?>
<?php if( $button_text_two = get_sub_field('button-text-two') ): ?>
<button class="btn-text" style="color: <?php echo $button_text_colour_two; ?>; background-color: <?php echo $button_background_two; ?>"><?php echo $button_text_two ?></button>
<?php endif; ?>
<?php endif; ?>
So I'm wondering if there is a way of not having to write in the div structures twice...one with the image above the text and one with the image below the text, is there a cleaner way of doing this?

Create four functions, one for each if. Call the functions in the order you prefer. So, let's suppose you have these functions:
imageTwo, headerTwo, subtextTwo, buttonTwo
Example:
function imageTwo() {
<?php if( $image_two = get_sub_field('image-two') ) { ?>
<a href="<?php echo $image_link_two; ?>">
<img src="<?php echo $image_two; ?>" class="col-image"></a>
<php
}
}
and then call the functions whenever you need them in the order of your preference.

Related

hide div if two conditions are true

If either one of $image and $content are not empty .section-intro should be output to the page. i.e if both are empty .section-intro should not output. For some reason my code isn't outputting anything to page despite at least one of the fields not being empty. Any pointers as to what I'm doing wrong would be greatly appreciated.
<?php if(have_rows('image_slideshow')):
$image = get_sub_field('image');
$content = get_sub_field('centered_text');
?>
<?php if(!empty($image) || !empty($content)): ?>
<div class="section-intro">
<div class="slides">
<?php while( have_rows('image_slideshow') ): the_row(); ?>
<div class="slide intro">
<?php if(!empty($image)): ?>
<img src="<?php echo $image['url']; ?>">
<?php endif; ?>
<?php echo $content; ?>
</div>
<?php endwhile; ?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
construction code show be continuos like this
<?php if(have_rows('image_slideshow')):
$image = get_sub_field('image');
$content = get_sub_field('centered_text');
if(!empty($image) || !empty($content)){
echo "<div class='section-intro'> <div class='slides'>";
while( have_rows('image_slideshow') )
the_row();
echo " <div class='slide intro'> ";
if(!empty($image))
echo "<img src= $image['url'] >";
echo $content;
?>
</div>
</div>
</div>
Use AND instand of OR
<?php if(!empty($image) && !empty($content)): ?>
Also, your full code must be like this
<?php
if(have_rows('image_slideshow')):
$image = get_sub_field('image');
$content = get_sub_field('centered_text');
?>
<?php if(!empty($image) && !empty($content)): ?>
<div class="section-intro">
<div class="slides">
<?php while( have_rows('image_slideshow') ): the_row(); ?>
<div class="slide intro">
<?php if(!empty($image)): ?>
<img src="<?php echo $image['url']; ?>">
<?php endif; ?>
<?php echo $content; ?>
</div>
<?php endwhile; ?>
</div>
</div>
<?php endif ?>
Use && instead of ||
<?php if(have_rows('image_slideshow')):
$image = get_sub_field('image');
$content = get_sub_field('centered_text');
?>
<?php if(!empty($image) && !empty($content)): ?>
<div class="section-intro">
<div class="slides">
<?php while( have_rows('image_slideshow') ): the_row(); ?>
<div class="slide intro">
<?php if(!empty($image)): ?>
<img src="<?php echo $image['url']; ?>">
<?php endif; ?>
<?php echo $content; ?>
</div>
<?php endwhile; ?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>

PHP code within IF statement

I'm after a bit of help as I'm having a bit of difficulty trying to put php code in an IF statement:
I have the following code:
<aside class="sidebar top">
<?php if(get_field('quote-text')): ?>
<div id="sidebar-testimonials">
<div class="quote-image">
<?php
$image = get_field('quote_image');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
</div>
<div id="quote-text">
"<?php the_field('quote-text'); ?>"
</div>
<span>
<?php the_field('quote-name'); ?>
</span>
</div>
<?php endif; ?>
</aside>
I'm trying to put the above code in the below code, where it says "Testimonial off" but not in the "Testimonial On" section.
<?php
$values = get_field( "display_testimonial" );
if ( $values ) {
echo "Testimonial Off";
} else {
echo "Testimonial On";
}
?>
Every time I try I'm getting PHP errors, can anyone help me out?
I have tried to merge the two codes together but I can get the sidebar to show in the else statement now:
<?php
$values = get_field( "display_testimonial" );
if ( $values ) {
?>
<aside class="sidebar top">
<?php dynamic_sidebar( 'About-Sidebar' ); ?>
<?php if(get_field('quote-text')): ?>
<div id="sidebar-testimonials">
<div class="quote-image">
<?php
$image = get_field('quote_image');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
</div>
<div id="quote-text">
"<?php the_field('quote-text'); ?>"
</div>
<span>
<?php the_field('quote-name'); ?>
</span>
</div>
<?php endif; ?>
</aside>
<?php
} else {
("<?php dynamic_sidebar( 'About-Sidebar' ); ?>");
}
?>
Thanks for your help
You have to be aware of correct opening and closing php tags:
<?php
$values = get_field( "display_testimonial" );
if ( $values ) {
// ADDED CLOSING PHP TAG
?>
<aside class="sidebar top">
<?php if(get_field('quote-text')): ?>
<div id="sidebar-testimonials">
<div class="quote-image">
<?php
$image = get_field('quote_image');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
</div>
<div id="quote-text">
"<?php the_field('quote-text'); ?>"
</div>
<span>
<?php the_field('quote-name'); ?>
</span>
</div>
<?php endif; ?>
</aside>
<?php
// ADDED OPENING PHP TAG
} else {
echo "Testimonial On";
}
?>
You have error in else part. Replace :
"Testimonial On"
to
echo "Testimonial On";
I managed to get it to work by doing the below:
<?php
$values = get_field( "display_testimonial" );
if ( $values ) {
?>
<aside class="sidebar top">
<?php dynamic_sidebar( 'About-Sidebar' ); ?>
<?php if(get_field('quote-text')): ?>
<div id="sidebar-testimonials">
<div class="quote-image">
<?php
$image = get_field('quote_image');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
</div>
<div id="quote-text">
"<?php the_field('quote-text'); ?>"
</div>
<span>
<?php the_field('quote-name'); ?>
</span>
</div>
<?php endif; ?>
</aside>
<?php
} else {
echo "<aside class='sidebar top'>";
dynamic_sidebar( 'About-Sidebar' );
echo "</aside>";
}
?>

Wordpress: Ultimate Posts Widget display post in columns

I'd love to have the option to have my posts displayed in multiple columns/rows (so that I could have several thumbnails/posts horizontally laid out next to each other, instead of only being posted below one another).
I tried changing the layout but sadly nothing happened
can you suggest something?
Thank you guys :D
<?php
/**
* Legacy template for compatibility with versions prior to 2.0.0
*
* #version 2.0.0
*/
?>
<?php if ($instance['before_posts']) : ?>
<div class="upw-before">
<?php echo wpautop($instance['before_posts']); ?>
</div>
<?php endif; ?>
<?php if ($upw_query->have_posts()) : ?>
<table class="table table-bordered">
<?php while ($upw_query->have_posts()) : $upw_query->the_post(); ?>
<tr>
<?php $current_post = ($post->ID == $current_post_id && is_single()) ? 'current-post-item' : ''; ?>
<li class="<?php echo ($post->ID == $current_post_id && is_single())?'current-post-item':'' ?>">
<?php if (current_theme_supports('post-thumbnails') && $instance['show_thumbnail'] && has_post_thumbnail()) : ?>
<td>
<div class="upw-content">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail($instance['thumb_size']); ?>
</a>
<?php endif; ?>
<?php if (get_the_title() && $instance['show_title']) : ?>
<p class="post-title">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a>
</p>
<?php endif; ?>
</td>
</tr>
<?php if ($instance['show_date']) : ?>
<p class="post-date">
<?php the_time($instance['date_format']); ?>
</p>
<?php endif; ?>
<?php if ($instance['show_author']) : ?>
<p class="post-author">
<span class="post-author-label"><?php _e('By', 'upw'); ?>:</span>
<?php the_author_posts_link(); ?>
</p>
<?php endif; ?>
<?php if ($instance['show_comments']) : ?>
<p class="post-comments">
<?php comments_number(__('No responses', 'upw'), __('One response', 'upw'), __('% responses', 'upw')); ?>
</p>
<?php endif; ?>
<?php if ($instance['show_excerpt']) : ?>
<?php
$linkmore = '';
if ($instance['show_readmore']) {
$linkmore = ' '.$excerpt_readmore.'';
}
?>
<p class="post-excerpt"><?php echo get_the_excerpt() . $linkmore; ?></p>
<?php endif; ?>
<?php if ($instance['show_content']) : ?>
<p class="post-content"><?php the_content() ?></p>
<?php endif; ?>
<?php
$categories = get_the_term_list($post->ID, 'category', '', ', ');
if ($instance['show_cats'] && $categories) :
?>
<p class="post-cats">
<span class="post-cats-label"><?php _e('Categories', 'upw'); ?>:</span>
<span class="post-cats-list"><?php echo $categories; ?></span>
</p>
<?php endif; ?>
<?php
$tags = get_the_term_list($post->ID, 'post_tag', '', ', ');
if ($instance['show_tags'] && $tags) :
?>
<p class="post-tags">
<span class="post-tags-label"><?php _e('Tags', 'upw'); ?>:</span>
<span class="post-tags-list"><?php echo $tags; ?></span>
</p>
<?php endif; ?>
<?php if ($custom_fields) {
$custom_field_name = explode(',', $custom_fields);
foreach ($custom_field_name as $name) {
$name = trim($name);
$custom_field_values = get_post_meta($post->ID, $name, true);
if ($custom_field_values) {
echo '<p class="post-meta post-meta-'.$name.'">';
if (!is_array($custom_field_values)) {
echo $custom_field_values;
} else {
$last_value = end($custom_field_values);
foreach ($custom_field_values as $value) {
echo $value;
if ($value != $last_value) echo ', ';
}
}
echo '</p>';
}
}
} ?>
</div>
</td>
</tr>
<tr>
<td>
<?php endwhile; ?>
</td></tr>
</table>
<?php else : ?>
<p><?php _e('No posts found.', 'upw'); ?></p>
<?php endif; ?>
<?php if ($instance['after_posts']) : ?>
<div class="upw-after">
<?php echo wpautop($instance['after_posts']); ?>
</div>
<?php endif; ?>

Product Name not found in Magento Category Page

I have this following code for the category page display in list.phtml placed at the location app\design\frontend\ultimo\default\template\catalog\product
The line productAttribute($_product, $_product->getName(), 'name'); ?> does not output the name of the product. Please help.
The entire code has been pasted below for reference.
<?php
$_productCollection=$this->getLoadedProductCollection();
$_collectionSize = $_productCollection->count();
?>
<?php if ($_collectionSize && $tmpHtml = $this->getChildHtml('block_category_above_collection')): ?>
<div class="block_category_above_collection std"><?php echo $tmpHtml; ?></div>
<?php endif; ?>
<?php if(!$_collectionSize): ?>
<?php if ($tmpHtml = $this->getChildHtml('block_category_above_empty_collection')): ?>
<div class="block_category_above_empty_collection std"><?php echo $tmpHtml; ?></div>
<?php else: ?>
<p class="note-msg empty-catalog"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php endif; ?>
<?php else: ?>
<?php
$_helper = $this->helper('catalog/output');
$theme = $this->helper('ultimo');
$labelsHelper = $this->helper('ultimo/labels');
$templateHelper = $this->helper('ultimo/template');
//Default image size
$imgWidth = 295;
$imgHeight = 295;
//Aspect ratio settings
if ($theme->getCfg('category/aspect_ratio'))
$imgHeight = 0; //Height will be computed automatically (based on width) to keep the aspect ratio
?>
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php //List mode specific settings
$listClasses = $theme->getCfg('category_list/hover_effect') ? ' hover-effect' : '';
//Check if "Add to" links are displayed as simple icons
$isListAddtoSimple = $theme->getCfg('category_list/addtolinks_simple');
?>
<?php $_iterator = 0; ?>
<ol class="products-list<?php if($listClasses) echo $listClasses; ?>" id="products-list">
<?php foreach ($_productCollection as $_product): ?>
<li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
<?php // Product Image ?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image grid12-4 persistent-grid2-1">
<img src="<?php echo $theme->getImgUrl($this, $_product, $imgWidth, $imgHeight, 'small_image'); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<?php //Product labels
echo $labelsHelper->getLabels($_product); ?>
</a>
<?php // Product description ?>
<div class="product-shop grid12-5 persistent-grid2-1">
<div class="product-shop-inner">
<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
<h2 class="product-name"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?></h2>
<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php endif; ?>
<div class="desc std">
<?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<?php echo $this->__('Learn More') ?>
</div>
</div>
</div>
<div class="right-column grid12-3 persistent-grid2-1">
<?php echo $this->getPriceHtml($_product, true) ?>
<?php if($_product->isSaleable()): ?>
<p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<?php
if ($isListAddtoSimple)
echo $templateHelper->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product));
else
echo $templateHelper->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product), 'addto-textlink');
?>
</div>
</li>
<?php endforeach; ?>
</ol>
<script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
<?php else: ?>
<?php // Grid Mode ?>
<?php //Grid mode specific settings
//Get grid configuration array
$gc = $theme->getCfgGroup('category_grid');
//General grid classes
$gridClasses = $gc['hover_effect'] ? ' hover-effect' : '';
if ($gc['equal_height'])
$gridClasses .= ' equal-height';
?>
<ul class="products-grid category-products-grid itemgrid itemgrid-<?php echo $gc['column_count']; ?>cols<?php if($gridClasses) echo $gridClasses; ?>">
<?php foreach ($_productCollection as $_product): ?>
<li class="item">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true); ?>" class="product-image">
<img src="<?php echo $theme->getImgUrl($this, $_product, $imgWidth, $imgHeight, 'small_image'); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true); ?>" />
<?php //Product labels
echo $labelsHelper->getLabels($_product); ?>
</a>
<?php //Add-to links
if ($gc['display_addtolinks'] != 0 && $gc['addtolinks_simple'])
{
if ($gc['display_addtolinks'] == 1) //Display on hover
echo $templateHelper->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product), 'addto-onimage display-onhover');
else //Always display
echo $templateHelper->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product), 'addto-onimage');
}
?>
<h2 class="product-name">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>">
<?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?>
</a>
</h2>
<?php if($_product->getRatingSummary()): ?>
<?php if ($gc['display_rating'] == 1): //Display on hover ?>
<div class="display-onhover"><?php echo $this->getReviewsSummaryHtml($_product, 'short') ?></div>
<?php elseif ($gc['display_rating'] == 2): //Always display ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php endif; ?>
<?php endif; ?>
<?php echo $this->getPriceHtml($_product, true) ?>
<div class="actions clearer">
<?php if ($gc['display_addtocart'] != 0): ?>
<?php $btnClass = ($gc['display_addtocart'] == 1) ? ' display-onhover' : ''; ?>
<?php if ($_product->isSaleable()): ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart<?php echo $btnClass; ?>" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<?php else: ?>
<p class="availability out-of-stock<?php echo $btnClass; ?>"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<?php endif; ?>
<?php //Add-to links
if ($gc['display_addtolinks'] != 0 && !$gc['addtolinks_simple'])
{
if ($gc['display_addtolinks'] == 1) //Display on hover
echo $templateHelper->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product), 'addto-textlink display-onhover');
else //Always display
echo $templateHelper->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product), 'addto-textlink');
}
?>
</div> <!-- end: actions -->
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<div class="toolbar-bottom">
<?php echo $this->getToolbarHtml() ?>
</div>
</div>
<?php endif; ?>
<?php if ($_collectionSize && $tmpHtml = $this->getChildHtml('block_category_below_collection')): ?>
<div class="block_category_below_collection std"><?php echo $tmpHtml; ?></div>
<?php endif; ?>

joomla/k2 php template overrides

Really need some help after many hours of banging head against a brick wall!
Basically I have a Joomla News page made in the K2 component. The page would have the top story, the next two, then the next four and the next four after that all with their own class so they can be styled differently for emphasis (like most news websites).
So there would be one row of one column - main news (with items image and text cut off after about 150 words with a 'read more')
second row - two columns - next two news pieces (with items image and text cut off after about 150 words with a 'read more')
third row - four columns - next four news pieces (with items image and text cut off after about 150 words with a 'read more')
fourth row - one column of eight links (no image just the title linked)
This is the file I'm trying to amend:
<?php
// no direct access
defined('_JEXEC') or die;
$selectedFilters=$params->get('extraFieldsSelect'); //get selected fields in module params
?>
<div id="k2ModuleBox<?php echo $module->id; ?> k2FiltrifyContainer" class="k2Filtrify k2ItemsBlock<?php if($params->get('moduleclass_sfx')) echo ' '.$params->get('moduleclass_sfx'); ?>">
<?php if($params->get('itemPreText')): ?>
<p class="modulePretext"><?php echo $params->get('itemPreText'); ?></p>
<?php endif; ?>
<!--Filtrify Placeholder-->
<div id="k2FiltrifyPlaceHolder"></div>
<?php //set placeholder, if LEGEND is the selected callback method
if($placeholder == 'legend'): ?>
<!--Filtrify legend placeholder-->
<div id="legend"><i><?php echo JText::_('K2_VIEWING_ALL'); ?></i></div>
<?php endif; ?>
<?php //set placeholder, if PAGINATION is the selected callback method
if($placeholder == 'pagination'): ?>
<!--Filtrify pagination placeholder-->
<div id="pagination"></div>
<?php endif; ?>
<?php if(count($items)): //Filtrify Container?>
<ul id="k2FiltrifyContainer">
<p>
<?php foreach ($items as $keyItem=>$item): ?>
<?php
// Define a CSS class for the last container on each row
if( (($keyItem+1)%($params->get('num_columns'))==0) || count($items)<$params->get('num_columns') )
$lastContainer= ' itemContainerLast';
else
$lastContainer='';
?>
<li class="itemContainer<?php echo $lastContainer; ?>" <?php echo (count($items)==1) ? '' : ' style="width:'.number_format(100/$params->get('num_columns'), 1).'%;"'; ?>
<?php
if( count($item->extra_fields) && $selectedFilters != ''): //check if there are extrafields and selected fields?>
<?php foreach ($item->extra_fields as $key=>$extraField): //adding extrafields as data parameter?>
<?php if(in_array($extraField->id,(array)$selectedFilters, TRUE)) : ?>
data-<?php echo preg_replace("/[^A-Za-zA-yA-y0-9а-яА-Яa-zA-Z?-??-?sctzlldSCTZLD]/ui", "_", $extraField->name); ?>="<?php echo $extraField->value; //set the values, and remove special chars?>"
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php if($params->get('showCatFilter')==1): //check for param - show category filter?>
data-<?php echo preg_replace("/[^A-Za-zA-yA-y0-9а-яА-Яá-źÁ-ŹΑ-Ωα-ωščťžľĺďŠČŤŽĹĎ]/ui", "_", JText::_('K2_CATEGORIES')); ?>="<?php echo $item->categoryname;?>"
<?php endif; ?>
<?php if($params->get('showTagFilter')==1): //check for param - show tag filter?>
data-<?php echo preg_replace("/[^A-Za-zA-yA-y0-9а-яА-Яá-źÁ-ŹΑ-Ωα-ωščťžľĺďŠČŤŽĹĎ]/ui", "_", JText::_('K2_TAGS')); ?>="<?php foreach ($item->tags as $tag): ?><?php echo $tag->name; ?>, <?php endforeach; ?>"
<?php endif; ?>
>
</p>
<p>
<?php if(isset($item->event->BeforeDisplay)): ?>
<!-- Plugins: BeforeDisplay -->
<?php echo $item->event->BeforeDisplay; ?>
<?php endif; ?>
<!-- K2 Plugins: K2BeforeDisplay -->
<?php echo $item->event->K2BeforeDisplay; ?>
<?php if($params->get('itemAuthorAvatar')): ?>
<a class="k2Avatar moduleItemAuthorAvatar" rel="author" href="<?php echo $item->authorLink; ?>">
<img src="<?php echo $item->authorAvatar; ?>" alt="<?php echo K2HelperUtilities::cleanHtml($item->author); ?>" style="width:<?php echo $avatarWidth; ?>px;height:auto;" />
</a>
<?php endif; ?>
<?php if($params->get('itemTitle')): ?>
<a class="moduleItemTitle" href="<?php echo $item->link; ?>"><?php echo $item->title; ?></a>
<?php endif; ?>
<?php if($params->get('itemAuthor')): ?>
</p>
<div class="moduleItemAuthor">
<?php echo K2HelperUtilities::writtenBy($item->authorGender); ?>
<?php if(isset($item->authorLink)): ?>
<a rel="author" title="<?php echo K2HelperUtilities::cleanHtml($item->author); ?>" href="<?php echo $item->authorLink; ?>"><?php echo $item->author; ?></a>
<?php else: ?>
<?php echo $item->author; ?>
<?php endif; ?>
<?php if($params->get('userDescription')): ?>
<?php echo $item->authorDescription; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if(isset($item->event->AfterDisplayTitle)): ?>
<!-- Plugins: AfterDisplayTitle -->
<?php echo $item->event->AfterDisplayTitle; ?>
<?php endif; ?>
<!-- K2 Plugins: K2AfterDisplayTitle -->
<?php echo $item->event->K2AfterDisplayTitle; ?>
<?php if(isset($item->event->BeforeDisplayContent)): ?>
<!-- Plugins: BeforeDisplayContent -->
<?php echo $item->event->BeforeDisplayContent; ?>
<?php endif; ?>
<!-- K2 Plugins: K2BeforeDisplayContent -->
<?php echo $item->event->K2BeforeDisplayContent; ?>
<?php if($params->get('itemImage') || $params->get('itemIntroText')): ?>
<div class="moduleItemIntrotext">
<?php if($params->get('itemImage') && isset($item->image)): ?>
<a class="moduleItemImage" href="<?php echo $item->link; ?>" title="<?php echo JText::_('K2_CONTINUE_READING'); ?> "<?php echo K2HelperUtilities::cleanHtml($item->title); ?>"">
<img src="<?php echo $item->image; ?>" alt="<?php echo K2HelperUtilities::cleanHtml($item->title); ?>"/>
</a>
<?php endif; ?>
<?php if($params->get('itemIntroText')): ?>
<?php echo $item->introtext; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="clr"></div>
<?php if($params->get('itemExtraFields') && count($item->extra_fields)): ?>
<div class="moduleItemExtraFields">
<b><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></b>
<ul>
<?php foreach ($item->extra_fields as $extraField): ?>
<?php if($extraField->value): ?>
<li class="type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<span class="moduleItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>
<span class="moduleItemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<div class="clr"></div>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<div class="clr"></div>
<?php if($params->get('itemVideo')): ?>
<div class="moduleItemVideo">
<?php echo $item->video ; ?>
<span class="moduleItemVideoCaption"><?php echo $item->video_caption ; ?></span>
<span class="moduleItemVideoCredits"><?php echo $item->video_credits ; ?></span>
</div>
<?php endif; ?>
<div class="clr"></div>
<?php if(isset($item->event->AfterDisplayContent)): ?>
<!-- Plugins: AfterDisplayContent -->
<?php echo $item->event->AfterDisplayContent; ?>
<?php endif; ?>
<!-- K2 Plugins: K2AfterDisplayContent -->
<?php echo $item->event->K2AfterDisplayContent; ?>
<?php if($params->get('itemDateCreated')): ?>
<span class="moduleItemDateCreated"><?php echo JText::_('K2_WRITTEN_ON') ; ?> <?php echo JHTML::_('date', $item->created, JText::_('K2_DATE_FORMAT_LC2')); ?></span>
<?php endif; ?>
<?php if($params->get('itemCategory')): ?>
<?php echo JText::_('K2_IN') ; ?> <a class="moduleItemCategory" href="<?php echo $item->categoryLink; ?>"><?php echo $item->categoryname; ?></a>
<?php endif; ?>
<?php if($params->get('itemTags') && count($item->tags)>0): ?>
<div class="moduleItemTags">
<b><?php echo JText::_('K2_TAGS'); ?>:</b>
<?php foreach ($item->tags as $tag): ?>
<?php echo $tag->name; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if($params->get('itemAttachments') && count($item->attachments)): ?>
<div class="moduleAttachments">
<?php foreach ($item->attachments as $attachment): ?>
<a title="<?php echo K2HelperUtilities::cleanHtml($attachment->titleAttribute); ?>" href="<?php echo $attachment->link; ?>"><?php echo $attachment->title; ?></a>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if($params->get('itemCommentsCounter') && $componentParams->get('comments')): ?>
<?php if(!empty($item->event->K2CommentsCounter)): ?>
<!-- K2 Plugins: K2CommentsCounter -->
<?php echo $item->event->K2CommentsCounter; ?>
<?php else: ?>
<?php if($item->numOfComments>0): ?>
<a class="moduleItemComments" href="<?php echo $item->link.'#itemCommentsAnchor'; ?>">
<?php echo $item->numOfComments; ?> <?php if($item->numOfComments>1) echo JText::_('K2_COMMENTS'); else echo JText::_('K2_COMMENT'); ?>
</a>
<?php else: ?>
<a class="moduleItemComments" href="<?php echo $item->link.'#itemCommentsAnchor'; ?>">
<?php echo JText::_('K2_BE_THE_FIRST_TO_COMMENT'); ?>
</a>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<?php if($params->get('itemHits')): ?>
<span class="moduleItemHits">
<?php echo JText::_('K2_READ'); ?> <?php echo $item->hits; ?> <?php echo JText::_('K2_TIMES'); ?>
</span>
<?php endif; ?>
<?php if($params->get('itemReadMore') && $item->fulltext): ?>
<a class="moduleItemReadMore" href="<?php echo $item->link; ?>">
<?php echo JText::_('K2_READ_MORE'); ?>
</a>
<?php endif; ?>
<?php if(isset($item->event->AfterDisplay)): ?>
<!-- Plugins: AfterDisplayContent -->
<?php echo $item->event->AfterDisplay; ?>
<?php endif; ?>
<!-- K2 Plugins: K2AfterDisplay -->
<?php echo $item->event->K2AfterDisplay; ?>
<div class="clr"></div>
</li>
<?php if((($keyItem+1)%($params->get('num_columns'))==0) && (($placeholder != 'pagination'))) : ?>
<div class="clr"></div>
<?php endif; ?>
<?php endforeach; ?>
<li class="clearList"></li>
</ul>
<?php endif; ?>
<?php if($params->get('itemCustomLink')): ?>
<a class="moduleCustomLink" href="<?php echo $params->get('itemCustomLinkURL'); ?>" title="<?php echo K2HelperUtilities::cleanHtml($itemCustomLinkTitle); ?>"><?php echo $itemCustomLinkTitle; ?></a>
<?php endif; ?>
<?php if($params->get('feed')): ?>
<div class="k2FeedIcon">
<a href="<?php echo JRoute::_('index.php?option=com_k2&view=itemlist&format=feed&moduleID='.$module->id); ?>" title="<?php echo JText::_('K2_SUBSCRIBE_TO_THIS_RSS_FEED'); ?>">
<span><?php echo JText::_('K2_SUBSCRIBE_TO_THIS_RSS_FEED'); ?></span>
</a>
<div class="clr"></div>
</div>
<?php endif; ?>
</div>
Like I say, I've tried and tried to make this template work, but have got nowhere!
You try it with wrong file! This file belongs to Filtrify Module!
You must:
set as template for category "default"
edit K2 native category settings,
edit K2 native category item settings,
edit K2 native
item settings,
After you set all native K2 parameters, you must clone your default k2 template. Do it so:
go into components/com_k2/templates.
Copy all, what you see, locally.
Then create in you templates/your-template/html folder named com_k2.
Copy into it all, what you got befor from components/com_k2/templates.
Then duplicate folder named "default" and give them own name. This will be your K2 template for overrides.
Then go into K2 administration and change template of you category, which you set up befor, from default to the new name. Just now you can begin with template overrides, but ONLY inside of templates/your template/html/com_k2/your-k2-template. The files you need to override are category-item.php for category view and item.php for single item view.

Categories