This is a very difficult question to ask but, lets try. I am using this module for joomla i need tocreate an overide for it so that it takes the first result of
<?php foreach( $pages as $key => $list ): ?>
and places it in its own div and carries on with the statement. Please ask if any other information is needed here's the entire code for the override:
<?php
/**
* #package mod_bt_contentslider - BT ContentSlider Module
* #version 1.4
* #created Oct 2011
* #author BowThemes
* #email support#bowthems.com
* #website http://bowthemes.com
* #support Forum - http://bowthemes.com/forum/
* #copyright Copyright (C) 2012 Bowthemes. All rights reserved.
* #license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
if($modal){JHTML::_('behavior.modal');}
$document = JFactory::getDocument();
if(count($list)>0){?>
<div id="btcontentslider<?php echo $module->id; ?>" style="display:none;" class="span4 bt-cs<?php echo $moduleclass_sfx? ' bt-cs'.$params->get('moduleclass_sfx'):'';?>">
<!--CONTENT-->
<div class="slides_container" style="width:<?php echo $moduleWidth.";".$add_style;?>">
<?php foreach( $pages as $key => $list ): ?>
<div class="slide" style="width:100%;">
<?php foreach( $list as $i => $row ): ?>
<ul class="bt-row <?php if($i==0) echo 'bt-row-first'; else if($i==count($list)-1) echo 'bt-row-last' ?>" style="width:100%" >
<li class="bt-inner">
<?php if( $row->thumbnail && $align_image != "center"): ?>
<a target="<?php echo $openTarget; ?>" class="bt-image-link<?php echo $modal? ' modal':''?>" title="<?php echo $row->title;?>" href="<?php echo $modal?$row->mainImage:$row->link;?>">
<img <?php echo $imgClass ?> src="<?php echo $row->thumbnail; ?>" alt="<?php echo $row->title?>" style="width:<?php echo $thumbWidth ;?>px; float:<?php echo $align_image;?>;margin-<?php echo $align_image=="left"? "right":"left";?>:5px" title="<?php echo $row->title?>" />
</a>
<?php endif; ?>
<?php if( $showTitle ): ?>
<a class="bt-title" target="<?php echo $openTarget; ?>"
title="<?php echo $row->title; ?>"
href="<?php echo $row->link;?>"> <?php echo $row->title_cut; ?> </a><br />
<?php endif; ?>
<?php if( $row->thumbnail && $align_image == "center" ): ?>
<div class="bt-center">
<a target="<?php echo $openTarget; ?>"
class="bt-image-link<?php echo $modal? ' modal':''?>"
title="<?php echo $row->title;?>" href="<?php echo $modal?$row->mainImage:$row->link;?>">
<img <?php echo $imgClass ?> src="<?php echo $row->thumbnail; ?>" alt="<?php echo $row->title?>" style="width:<?php echo $thumbWidth ;?>px;" title="<?php echo $row->title?>" />
</a>
</div>
<?php endif ; ?>
<?php if( $show_intro ): ?>
<div class="bt-introtext">
<?php echo $row->description; ?>
</div>
<?php endif; ?>
<?php if( $showReadmore ) : ?>
<p class="readmore">
<a target="<?php echo $openTarget; ?>"
title="<?php echo $row->title;?>"
href="<?php echo $row->link;?>"> <?php echo JText::_('READ_MORE');?>
</a>
</p>
<?php endif; ?>
</li>
<!--end bt-inner -->
</ul>
<!--end bt-row -->
<!--CONTENT-->
<?php endforeach; ?>
<div style="clear: both;"></div>
</div>
<!--end bt-main-item page -->
<?php endforeach; ?>
</div>
<?php if( $next_back && $totalPages > 1 ) : ?>
<a class="prev" href="#"></a><a class="next" href="#"></a>
<?php endif; ?>
</div>
<!--end bt-container -->
<div style="clear: both;"></div>
<script type="text/javascript">
if(typeof(btcModuleIds)=='undefined'){var btcModuleIds = new Array();var btcModuleOpts = new Array();}
btcModuleIds.push(<?php echo $module->id; ?>);
btcModuleOpts.push({
slideEasing : '<?php echo $slideEasing; ?>',
fadeEasing : '<?php echo $slideEasing; ?>',
effect: '<?php echo $effect; ?>',
preloadImage: '<?php echo $preloadImg; ?>',
generatePagination: <?php echo $paging ?>,
play: <?php echo $play; ?>,
hoverPause: <?php echo $hoverPause; ?>,
slideSpeed : <?php echo $duration; ?>,
autoHeight:<?php echo $autoHeight ?>,
fadeSpeed : <?php echo $fadeSpeed ?>,
equalHeight:<?php echo $equalHeight; ?>,
width: <?php echo $moduleWidth=='auto'? "'auto'":$params->get( 'module_width', 0 ); ?>,
height: <?php echo $moduleHeight=='auto'? "'auto'":$params->get( 'module_height', 0 ); ?>,
pause: 100,
preload: true,
paginationClass: '<?php echo $butlet==1 ? 'bt_handles': 'bt_handles_num' ?>',
generateNextPrev:false,
prependPagination:true,
touchScreen:<?php echo $touchScreen ?>
});
</script>
<?php
// set position for bullet
if($butlet) {
$nav_top = (-1)*(int)$params->get( 'navigation_top', 0 );
$nav_right = (-1)*(int)$params->get( 'navigation_right', 0 )+5;
if(trim($params->get('content_title'))) $nav_top += 13;
$document->addStyleDeclaration(
$modid . ' ' . ($butlet == 1 ? '.bt_handles' : '.bt_handles_num') . '{'.
'bottom: ' . '5% !important;'.
'right: ' . '50% !important'.
'}'
);
}
// set responsive for mobile device
if($moduleWidth=='auto'){
$document->addStyleDeclaration(
'
#media screen and (max-width: 480px){.bt-cs .bt-row{width:100%!important;}}'
);
}
}
else
{
echo '<div>No result...</div>';
} ?>
Any Help Greatly apreciated.
you can do something like this. basicly, set a boolean to only do something different to the first item:
<?php $first = true; ?>
<?php foreach( $pages as $key => $list ): ?>
<?php
if($first) {
/* put this $list in its own div or whatever you need to do */
$first = false;
} else {
... //the default operation/code
?>
...
<?php } ?>
<?php endforeach; ?>
Complete Edit:
Use a counter to know which iteration it is:
<?php $c = 0; // initialize counter
foreach( $pages as $key => $list ):
if ($c++ == 0):
?>
this section will only run for the first element.
<?php endif;?>
Related
I didn't build this PHP file, but I am trying to figure out why it is giving me errors. If the "Block layout mode" ACF variable is set to "Modal" then the block works, but gives me this error. "Undefined variable $vids on line 176". If I select the "Embed & Thumbnail" mode, then none of the block is displayed and I get this error. "Call to undefined function vc_embed_layout() on line 252". I can't pin down why this is happening, and I haven't been able to find any unclosed tags or anything in my php file. This is the file in question, and I've marked the lines that trigger errors.
<?php
global $theme_text_domain;
$block_class_identifier = 'blk__vidcol';
// default variables
$block_id = $top_class = $top_style = $inner_class = $inner_style = '';
// check for custom id
$block_id .= BLOCK::set_id( get_sub_field('content_block_id') );
// set block class, $i comes from FLEX class loop and represents the block order on a page
$top_class .= BLOCK::set_standard_classes( $i );
$top_class .= BLOCK::set_custom_classes( get_sub_field('content_block_classes') );
// check for top padding adjustment
$top_class .= BLOCK::set_padding_class( get_sub_field('block_padding_adjustment') );
$top_style .= BLOCK::set_padding_style( get_sub_field('block_padding_adjustment'), get_sub_field('custom_top_padding'), get_sub_field('custom_bottom_padding'));
// check for custom color theme
$top_style .= BLOCK::set_colors( get_sub_field('color_theme'), get_sub_field('text_color'), get_sub_field('custom_background_color') );
// check for width settings
$inner_class .= BLOCK::set_width_class( get_sub_field('content_width') );
$inner_style .= BLOCK::set_width_style( get_sub_field('content_width'), get_sub_field('custom_maximum_content_width') );
$block_assets = get_stylesheet_directory_uri() . '/inc/blocks/' . basename(__FILE__, '.php') . '/assets/';
/*
CUSTOM BLOCK SPECIFIC SETUP
*/
$layout = get_sub_field('block_layout_mode');
$top_class .= ' layout-' . $layout;
// title color
$h2_style = (get_sub_field('color_theme') == 'custom') ? ' color: ' . get_sub_field('custom_title_color') . ';' : '';
/**
* outputs code for the modal version of the video collection block
* #return html output
*/
if (!function_exists('vc_modal_layout')) {
function vc_modal_layout() {
global $block_class_identifier;
$cta_label = get_sub_field('cta_label');
$counter = 0;
$cta = array(
'style' => get_sub_field('cta_style'),
'button_color' => get_sub_field('button_color'),
'button_text_color' => get_sub_field('button_color')
);
$cta_class = BLOCK::get_cta_style( $cta, '.' . $block_class_identifier . ' .button');
?>
<?php // list section ?>
<?php if( have_rows('videos') ): ?>
<div class="vid-container">
<?php while ( have_rows('videos') ) : the_row(); ?>
<?php if ($counter == 0): ?>
<div class="vid-featured">
<div class="video-wrapper">
<iframe src="https://www.youtube.com/embed/<?php echo get_sub_field('youtube_embed_code'); ?>?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
<a class="vid_overlay" data-fancybox data-src="#<?php echo $block_class_identifier; ?>_vid_0" href="javascript:;"></a>
</div>
<!-- modal -->
<div id="<?php echo $block_class_identifier; ?>_vid_0" class="modal video-modal" style="display: none;">
<div class="modal-inner">
<h3><?php echo get_sub_field('video_title'); ?></h3>
<div class="video-wrapper">
<iframe src="https://www.youtube.com/embed/<?php echo get_sub_field('youtube_embed_code'); ?>?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</div>
</div>
<div class="vid-list">
<?php else: ?>
<div class="vid-item">
<div class="item-btn">
<a class="button <?php echo $cta_class; ?>" data-fancybox data-src="#<?php echo $block_class_identifier; ?>_vid_<?php echo $counter; ?>" href="javascript:;"><?php echo $cta_label; ?></a>
</div>
<div class="item-title"><?php echo get_sub_field('video_title'); ?></div>
</div>
<!-- modal -->
<div id="<?php echo $block_class_identifier; ?>_vid_<?php echo $counter; ?>" class="modal video-modal" style="display: none;">
<div class="modal-inner">
<h3><?php echo get_sub_field('video_title'); ?></h3>
<div class="video-wrapper">
<iframe src="https://www.youtube.com/embed/<?php echo get_sub_field('youtube_embed_code'); ?>?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</div>
<?php endif; ?>
<?php $counter++; ?>
<?php endwhile; ?>
</div>
</div>
<?php else: ?>
No videos defined.
<?php endif; ?>
<?
}
}
/**
* outputs code for the embed version of the video collection block
* #return html output
*/
if (!function_exists('vc_embed_layout')) {
function vc_embed_layout($vids, $i) {
?>
<?php if ( $vids ): ?> **this is line 176**
<div class="vid-container2">
<h2 class="vid-title"><?php echo $vids[0]['video_title']; ?></h2>
<div class="vid-container2-inner">
<div class="vid-embed">
<div class="video-wrapper">
<iframe src="https://www.youtube.com/embed/<?php echo $vids[0]['youtube_embed_code']; ?>?rel=0&showinfo=0" frameborder="0" allowfullscreen onload="this.style.visibility = 'visible';"></iframe>
</div>
</div>
<div class="vid-thumbnails">
<?php foreach ($vids as $key => $vid): ?>
<?php $wrap_class = ($key == 0) ? ' tn-hide' : ''; ?>
<div class="tn-wrapper <?php echo $wrap_class; ?>" data-embed="<?php echo $vid['youtube_embed_code']; ?>" data-title="<?php echo $vid['video_title']; ?>">
<img src="https://img.youtube.com/vi/<?php echo $vid['youtube_embed_code']; ?>/mqdefault.jpg" alt="">
</div>
<?php endforeach; ?>
</div>
</div>
<script>
var vid_swap = function() {
$('.block_<?php echo $i; ?> .vid-embed').css({opacity: 1});
$('.block_<?php echo $i; ?> .tn-wrapper').on('click', function(e) {
var $this = $(this);
var embed_id = $this.attr('data-embed');
var title = $this.attr('data-title');
console.log('embed = ' + embed_id);
$('.block_<?php echo $i; ?> .vid-title').animate({opacity: 0}, 100);
$('.block_<?php echo $i; ?> .vid-embed').animate({opacity: 0}, 1000, function() {
$('.block_<?php echo $i; ?> .vid-embed, .block_<?php echo $i; ?> .vid-title').css('visiblity','hidden');
$('.block_<?php echo $i; ?> .vid-title').html( title );
$('.block_<?php echo $i; ?> .vid-embed iframe').attr('src', 'https://www.youtube.com/embed/' + embed_id);
$('.block_<?php echo $i; ?> .tn-wrapper.tn-hide').removeClass('tn-hide');
$this.addClass('tn-hide');
$('.block_<?php echo $i; ?> .vid-title').css('visiblity','visible').delay(500).animate({opacity: 1}, 500);
$('.block_<?php echo $i; ?> .vid-embed').delay(500).animate({opacity: 1}, 1000);
});
});
}
jQuery(document).on('block_init', vid_swap);
</script>
</div>
<?php else: ?>
No videos defined.
<?php endif; ?>
<?php
}
}
?>
<section id="<?php echo $block_id; ?>" class="<?php echo $block_class_identifier; ?> <?php echo $top_class; ?>" style="<?php echo $top_style; ?>">
<div class="inner <?php echo $inner_class; ?>" style="<?php echo $inner_style; ?>">
<?php // title section ?>
<?php if (get_sub_field('title')): ?>
<h2 style="<?php echo $h2_style; ?>"><?php echo get_sub_field('title'); ?></h2>
<?php endif; ?>
<?php $vids = get_sub_field('videos'); ?>
<?php if ($layout == 'modal') vc_modal_layout($vids); ?>
<?php if ($layout == 'embed') vc_embed_layout($vids, $i); ?> **This is line 252**
</div>
</section>
You're not accepting any arguments in vc_modal_layout() function declaration.
if (!function_exists('vc_embed_layout')) {
function vc_embed_layout() {
needs to have parameters in order to accept arguments.
something like this is what you're looking for:
if (!function_exists('vc_embed_layout')) {
function vc_embed_layout($vids=[], $i=0) {
And it's the same idea with vc_modal_layout, the function needs to be able to accept the variables from outside it.
When we call a function, the function needs to be able to accept all arguments passed to it. And all variables we use need to be defined, if there's a risk of them being undefined or empty arrays, we can check them with if(!empty($var)) or if(isset($var))
An alternative to passing the variable to the function is to access it as a global. But it's generally better to pass the variable to the function because when we pass the variable to a function in PHP it works with a copy of the variable's value inside the function. When we do something like this:
$var = 10;
function doIt(){
global $var;
$var++;
}
doit();
echo $var;
we could overcomplicate things..
let's have a closer look here:
if ($layout == 'modal') vc_modal_layout($vids);
if ($layout == 'embed') vc_embed_layout($vids, $i); ?> **This is line 252**
function vc_modal_layout(){ ... }
// should be:
function vc_modal_layout($vids){ ... }
function vc_embed_layout($vids, $i)
// looks good.
Aside from that, nothing stands out as really unusual & I'd want to have a look at the actual site to tinker with this problem further.
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
I am getting this error
Parse error: syntax error, unexpected 'endforeach' (T_ENDFOREACH),
expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) in
/var/www/html/app/design/frontend/nego/nego_default/Magento_Catalog/templates/product/list.phtml
on line 130
list.phtml shows this:
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\App\Action\Action;
// #codingStandardsIgnoreFile
?>
<?php
/**
* Product list template
*
* #var $block \Magento\Catalog\Block\Product\ListProduct
*/
?>
<?php
$_productCollection = $block->getLoadedProductCollection();
$_helper = $this->helper('Magento\Catalog\Helper\Output');
?>
<?php if (!$_productCollection->count()): ?>
<div class="message info empty"><div><?php /* #escapeNotVerified */ echo __('We can\'t find products matching the selection.') ?></div></div>
<?php else: ?>
<?php echo $block->getToolbarHtml() ?>
<?php echo $block->getAdditionalHtml() ?>
<?php
if ($block->getMode() == 'grid') {
$viewMode = 'grid';
$image = 'category_page_grid';
$showDescription = false;
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
} else {
$viewMode = 'list';
$image = 'category_page_list';
$showDescription = true;
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::FULL_VIEW;
}
/**
* Position for actions regarding image size changing in vde if needed
*/
$pos = $block->getPositioned();
?>
<div class="products wrapper <?php /* #escapeNotVerified */ echo $viewMode; ?> products-<?php /* #escapeNotVerified */ echo $viewMode; ?>">
<?php $iterator = 1; ?>
<ol class="products list items product-items">
<?php /** #var $_product \Magento\Catalog\Model\Product */ ?>
<?php foreach ($_productCollection as $_product): ?>
<?php /* #escapeNotVerified */ echo($iterator++ == 1) ? '<li class="item product product-item">' : '</li><li class="item product product-item">' ?>
<div class="product-item-info" data-container="product-grid">
<div class=" product-item-images">
<?php
$newFromDate = $_product->getNewsFromDate();
$newToDate = $_product->getNewsToDate();
$now = date("Y-m-d H:m:s");
// Get the Special Price
$specialprice = $_product->getSpecialPrice();
// Get the Special Price FROM date
$specialPriceFromDate = $_product->getSpecialFromDate();
// Get the Special Price TO date
$specialPriceToDate = $_product->getSpecialToDate();
// Get Current date
if ($specialprice&&(($specialPriceFromDate <= $now && $specialPriceToDate >= $now) || (($specialPriceFromDate <= $now && $specialPriceFromDate != NULL) && $specialPriceToDate == ''))){
$_savePercent = 100 - round(($_product->getSpecialPrice() / $_product->getPrice())*100);
echo "<span class='hot-sale'>-".$_savePercent."%</span>";
}else{
if((($newFromDate <= $now && $newToDate >= $now) || (($newFromDate <= $now && $newFromDate != NULL) && $newToDate == NULL))) {
?>
<div class="label-pro-new"><span><?php echo __('new!') ?></span></div>
<?php
}
}
?>
<?php
$productImage = $block->getImage($_product, $image);
if ($pos != null) {
$position = ' style="left:' . $productImage->getWidth() . 'px;'
. 'top:' . $productImage->getHeight() . 'px;"';
}
?>
<?php // Product Image ?>
<a href="<?php /* #escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">
<?php echo $productImage->toHtml(); ?>
</a>
</div>
<div class="product-item-details">
<?php
$_productNameStripped = $block->stripTags($_product->getName(), null, true);
?>
<strong class="product name product-item-name">
<a class="product-item-link"
href="<?php /* #escapeNotVerified */ echo $_product->getProductUrl() ?>">
<?php /* #escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
</a>
</strong>
<?php echo $block->getReviewsSummaryHtml($_product, $templateType); ?>
<?php /* #escapeNotVerified */ echo $block->getProductPrice($_product) ?>
<?php echo $block->getProductDetailsHtml($_product); ?>
<?php if ($showDescription):?>
<div class="product description product-item-description">
<?php /* #escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<a href="<?php /* #escapeNotVerified */ echo $_product->getProductUrl() ?>" title="<?php /* #escapeNotVerified */ echo $_productNameStripped ?>"
class="action more"><?php /* #escapeNotVerified */ echo __('Learn More') ?></a>
</div>
<?php endif; ?>
<div class="product-item-actions"<?php echo strpos($pos, $viewMode . '-actions') ? $position : ''; ?>>
<div class="add-to-cart-primary"<?php echo strpos($pos, $viewMode . '-primary') ? $position : ''; ?>>
<?php if ($_product->isSaleable()): ?>
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
<form data-role="tocart-form" action="<?php /* #escapeNotVerified */ echo $postParams['action']; ?>" method="post">
<input type="hidden" name="product" value="<?php /* #escapeNotVerified */ echo $postParams['data']['product']; ?>">
<input type="hidden" name="<?php /* #escapeNotVerified */ echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php /* #escapeNotVerified */ echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
<?php echo $block->getBlockHtml('formkey')?>
<button type="submit"
title="<?php echo $block->escapeHtml(__('Add to Cart')); ?>"
class="tocart">
<span><?php /* #escapeNotVerified */ echo __('Add to Cart') ?></span>
</button>
</form>
</div>
</div>
</div>
</div>
<?php echo($iterator == count($_productCollection)+1) ? '</li>' : '' ?>
<?php endforeach; ?>
</ol>
</div>
<?php echo $block->getToolbarHtml() ?>
<?php if (!$block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">
{
"[data-role=tocart-form], .form.map.checkout": {
"catalogAddToCart": {}
}
}
</script>
<?php endif; ?>
<?php endif; ?>
All other pages works. But the category pages shows error.
You didn't close "if" statement started in line 111. Just add it after line 123.
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\App\Action\Action;
// #codingStandardsIgnoreFile
?>
<?php
/**
* Product list template
*
* #var $block \Magento\Catalog\Block\Product\ListProduct
*/
?>
<?php
$_productCollection = $block->getLoadedProductCollection();
$_helper = $this->helper('Magento\Catalog\Helper\Output');
?>
<?php if (!$_productCollection->count()): ?>
<div class="message info empty"><div><?php /* #escapeNotVerified */ echo __('We can\'t find products matching the selection.') ?></div></div>
<?php else: ?>
<?php echo $block->getToolbarHtml() ?>
<?php echo $block->getAdditionalHtml() ?>
<?php
if ($block->getMode() == 'grid') {
$viewMode = 'grid';
$image = 'category_page_grid';
$showDescription = false;
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
} else {
$viewMode = 'list';
$image = 'category_page_list';
$showDescription = true;
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::FULL_VIEW;
}
/**
* Position for actions regarding image size changing in vde if needed
*/
$pos = $block->getPositioned();
?>
<div class="products wrapper <?php /* #escapeNotVerified */ echo $viewMode; ?> products-<?php /* #escapeNotVerified */ echo $viewMode; ?>">
<?php $iterator = 1; ?>
<ol class="products list items product-items">
<?php /** #var $_product \Magento\Catalog\Model\Product */ ?>
<?php foreach ($_productCollection as $_product): ?>
<?php /* #escapeNotVerified */ echo($iterator++ == 1) ? '<li class="item product product-item">' : '</li><li class="item product product-item">' ?>
<div class="product-item-info" data-container="product-grid">
<div class=" product-item-images">
<?php
$newFromDate = $_product->getNewsFromDate();
$newToDate = $_product->getNewsToDate();
$now = date("Y-m-d H:m:s");
// Get the Special Price
$specialprice = $_product->getSpecialPrice();
// Get the Special Price FROM date
$specialPriceFromDate = $_product->getSpecialFromDate();
// Get the Special Price TO date
$specialPriceToDate = $_product->getSpecialToDate();
// Get Current date
if ($specialprice&&(($specialPriceFromDate <= $now && $specialPriceToDate >= $now) || (($specialPriceFromDate <= $now && $specialPriceFromDate != NULL) && $specialPriceToDate == ''))){
$_savePercent = 100 - round(($_product->getSpecialPrice() / $_product->getPrice())*100);
echo "<span class='hot-sale'>-".$_savePercent."%</span>";
}else{
if((($newFromDate <= $now && $newToDate >= $now) || (($newFromDate <= $now && $newFromDate != NULL) && $newToDate == NULL))) {
?>
<div class="label-pro-new"><span><?php echo __('new!') ?></span></div>
<?php
}
}
?>
<?php
$productImage = $block->getImage($_product, $image);
if ($pos != null) {
$position = ' style="left:' . $productImage->getWidth() . 'px;'
. 'top:' . $productImage->getHeight() . 'px;"';
}
?>
<?php // Product Image ?>
<a href="<?php /* #escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">
<?php echo $productImage->toHtml(); ?>
</a>
</div>
<div class="product-item-details">
<?php
$_productNameStripped = $block->stripTags($_product->getName(), null, true);
?>
<strong class="product name product-item-name">
<a class="product-item-link"
href="<?php /* #escapeNotVerified */ echo $_product->getProductUrl() ?>">
<?php /* #escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
</a>
</strong>
<?php echo $block->getReviewsSummaryHtml($_product, $templateType); ?>
<?php /* #escapeNotVerified */ echo $block->getProductPrice($_product) ?>
<?php echo $block->getProductDetailsHtml($_product); ?>
<?php if ($showDescription):?>
<div class="product description product-item-description">
<?php /* #escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<a href="<?php /* #escapeNotVerified */ echo $_product->getProductUrl() ?>" title="<?php /* #escapeNotVerified */ echo $_productNameStripped ?>"
class="action more"><?php /* #escapeNotVerified */ echo __('Learn More') ?></a>
</div>
<?php endif; ?>
<div class="product-item-actions"<?php echo strpos($pos, $viewMode . '-actions') ? $position : ''; ?>>
<div class="add-to-cart-primary"<?php echo strpos($pos, $viewMode . '-primary') ? $position : ''; ?>>
<?php if ($_product->isSaleable()): ?>
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
<form data-role="tocart-form" action="<?php /* #escapeNotVerified */ echo $postParams['action']; ?>" method="post">
<input type="hidden" name="product" value="<?php /* #escapeNotVerified */ echo $postParams['data']['product']; ?>">
<input type="hidden" name="<?php /* #escapeNotVerified */ echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php /* #escapeNotVerified */ echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
<?php echo $block->getBlockHtml('formkey')?>
<button type="submit"
title="<?php echo $block->escapeHtml(__('Add to Cart')); ?>"
class="tocart">
<span><?php /* #escapeNotVerified */ echo __('Add to Cart') ?></span>
</button>
</form>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php echo($iterator == count($_productCollection)+1) ? '</li>' : '' ?>
<?php endforeach; ?>
</ol>
</div>
<?php echo $block->getToolbarHtml() ?>
<?php if (!$block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">
{
"[data-role=tocart-form], .form.map.checkout": {
"catalogAddToCart": {}
}
}
</script>
<?php endif; ?>
<?php endif; ?>
How To Show "Shop By" left sidebar attribute list in "Dropdown" like as "Sort By" Toolbar?
I want to show attribute list same as "Sort By" Toolbar as Dropdown list.
my toolbar.phtml code is
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license#magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* #category design
* #package base_default
* #copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* #license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
/**
* Product list toolbar
*
* #see Mage_Catalog_Block_Product_List_Toolbar
*/
?>
<?php
/**
* - Pager moved after sorter. Show pager only if there are pages.
* - Amount and limiter moved inside sorter
* - Changed order of the main elements
*/
?>
<?php if($this->getCollection()->getSize()): ?>
<div class="toolbar">
<?php if( $this->isExpanded() ): ?>
<div class="sorter">
<p class="amount">
<?php if($this->getLastPageNum()>1): ?>
<?php echo $this->__('Items %s to %s of %s total', $this->getFirstNum(), $this->getLastNum(), $this->getTotalNum()) ?>
<?php else: ?>
<strong><?php echo $this->__('%s Item(s)', $this->getTotalNum()) ?></strong>
<?php endif; ?>
</p>
<div class="sort-by">
<label><?php echo $this->__('Sort By') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
<?php echo $this->__($_order) ?>
</option>
<?php endforeach; ?>
</select>
<?php if($this->getCurrentDirection() == 'desc'): ?>
<a class="category-desc ic ic-arrow-up" href="<?php echo $this->getOrderUrl(null, 'asc') ?>" title="<?php echo $this->__('Set Ascending Direction') ?>"></a>
<?php else: ?>
<a class="category-asc ic ic-arrow-down" href="<?php echo $this->getOrderUrl(null, 'desc') ?>" title="<?php echo $this->__('Set Descending Direction') ?>"></a>
<?php endif; ?>
</div>
<div class="sort-by">
<label><?php echo $this->__('Sort By') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
<?php echo $this->__($_order) ?>
</option>
<?php endforeach; ?>
</select>
<?php if($this->getCurrentDirection() == 'desc'): ?>
<a class="category-desc ic ic-arrow-up" href="<?php echo $this->getOrderUrl(null, 'asc') ?>" title="<?php echo $this->__('Set Ascending Direction') ?>"></a>
<?php else: ?>
<a class="category-asc ic ic-arrow-down" href="<?php echo $this->getOrderUrl(null, 'desc') ?>" title="<?php echo $this->__('Set Descending Direction') ?>"></a>
<?php endif; ?>
</div>
<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach ($this->getAvailableLimit() as $_key=>$_limit): ?>
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
<?php echo $_limit ?>
</option>
<?php endforeach; ?>
</select><span class="per-page"> <?php echo $this->__('per page'); ?></span>
</div>
<?php if( $this->isEnabledViewSwitcher() ): ?>
<p class="view-mode">
<?php $_modes = $this->getModes(); ?>
<?php if($_modes && count($_modes)>1): ?>
<label><?php echo $this->__('View as') ?>:</label>
<?php //Removed spaces from the foreach loop to improve layout of the buttons ?>
<?php foreach ($this->getModes() as $_code=>$_label): ?><?php $codeToLower = strtolower($_code); if($this->isModeActive($_code)): ?><span title="<?php echo $_label ?>" class="<?php echo $codeToLower; ?> ic ic-<?php echo $codeToLower; ?>"></span><?php else: ?><?php endif; ?><?php endforeach; ?>
<?php endif; ?>
</p>
<?php endif; ?>
</div> <!-- end: sorter -->
<?php endif; ?>
<?php //Show pager only if there are pages ?>
<?php if ($pagerHtml = trim($this->getPagerHtml())): ?>
<div class="pager">
<?php echo $pagerHtml; ?>
</div>
<?php endif; ?>
</div>
<?php endif ?>
list.phtml code is
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license#magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* #category design
* #package base_default
* #copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
* #license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
/**
* Product list template
*
* #see Mage_Catalog_Block_Product_List
*/
?>
<?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');
$helpLabels = $this->helper('ultimo/labels');
$helpTemplate = $this->helper('ultimo/template');
$helpImg = $this->helper('infortis/image');
//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
//Hide toolbar
$hideToolbar = false;
if ($this->getHideToolbar())
{
$hideToolbar = true;
}
?>
<div class="category-products">
<?php if (!$hideToolbar): ?>
<?php echo $this->getToolbarHtml() ?>
<?php endif; ?>
<?php if($this->getMode()!='grid'): //List mode ?>
<?php
//Get list configuration array
$lc = $theme->getCfgGroup('category_list');
//List classes
$listClasses = '';
if ($lc['hover_effect'])
$listClasses = ' hover-effect';
?>
<?php $_iterator = 0; ?>
<ul 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 ?>
<div class="product-image-wrapper grid12-4 mobile-grid-half">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" style="max-width:<?php echo $imgWidth; ?>px;">
<img src="<?php echo $helpImg->getImg($_product, $imgWidth, $imgHeight, 'small_image'); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<?php if ($theme->getCfg('category/alt_image')): ?>
<?php echo $theme->getAltImgHtml($_product, $imgWidth, $imgHeight); ?>
<?php endif; ?>
<?php echo $helpLabels->getLabels($_product); //Product labels ?>
</a>
</div> <!-- end: product-image-wrapper -->
<?php //Product description ?>
<div class="product-shop grid12-5 mobile-grid-half">
<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 mobile-grid-half">
<?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 ($lc['addtolinks_simple'])
echo $helpTemplate->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product), 'addto-gaps-right');
else
echo $helpTemplate->getCategoryAddtoLinksComplex($_product, $this->getAddToCompareUrl($_product), 'addto-gaps-right');
?>
</div>
</li>
<?php endforeach; ?>
</ul>
<script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
<?php else: //Grid mode ?>
<?php
//Get grid configuration array
$gc = $theme->getCfgGroup('category_grid');
//Get number of columns (from parameter or from theme config)
$columnCount = 3;
if ($this->getGridColumnCount())
{
$columnCount = $this->getGridColumnCount();
}
else
{
$columnCount = $gc['column_count'];
}
//Grid classes
$gridClasses = '';
$productNameClasses = '';
if ($gc['display_name'] == 2 && $gc['display_name_single_line'] == true)
$gridClasses .= ' single-line-name';
if ($gc['display_name'] == 1)
$productNameClasses .= ' display-onhover';
if ($gc['centered'])
$gridClasses .= ' centered';
if ($gc['hover_effect'])
$gridClasses .= ' hover-effect';
if ($gc['equal_height'])
$gridClasses .= ' equal-height';
//Size of grid elements
if ($gc['elements_size'])
{
$gridClasses .= ' size-' . $gc['elements_size'];
}
else
{
//Calculate size based on number of columns
if ($columnCount >= 6)
{
$gridClasses .= ' size-xs';
}
elseif ($columnCount >= 4)
{
$gridClasses .= ' size-s';
}
}
//Container "actions" at the bottom of the grid item stores button and add-to links
//If at least one of those elements was set as "Display on hover" but no element was set as "Display":
//apply appropriate classes to the container.
$actionsClasses = '';
if ($gc['display_addtocart'] == 1 || ($gc['display_addtolinks'] == 1 && !$gc['addtolinks_simple']))
{
$actionsClasses = ' display-onhover';
}
if ($gc['display_addtocart'] == 2 || ($gc['display_addtolinks'] == 2 && !$gc['addtolinks_simple']))
{
$actionsClasses = '';
}
?>
<ul class="products-grid category-products-grid itemgrid itemgrid-adaptive itemgrid-<?php echo $columnCount; ?>col<?php if($gridClasses) echo $gridClasses; ?>">
<?php foreach ($_productCollection as $_product): ?>
<li class="item">
<div class="product-image-wrapper" style="max-width:<?php echo $imgWidth; ?>px;">
<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 $helpImg->getImg($_product, $imgWidth, $imgHeight, 'small_image'); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true); ?>" />
<?php if ($theme->getCfg('category/alt_image')): ?>
<?php echo $theme->getAltImgHtml($_product, $imgWidth, $imgHeight); ?>
<?php endif; ?>
<?php echo $helpLabels->getLabels($_product); //Product labels ?>
</a>
<?php //Add-to links
if ($gc['display_addtolinks'] != 0 && $gc['addtolinks_simple'])
{
if ($gc['display_addtolinks'] == 1) //Display on hover
echo $helpTemplate->getCategoryAddtoLinksIcons($_product, $this->getAddToCompareUrl($_product), 'addto-links-icons addto-onimage display-onhover');
else //Always display
echo $helpTemplate->getCategoryAddtoLinksIcons($_product, $this->getAddToCompareUrl($_product), 'addto-links-icons addto-onimage');
}
?>
</div> <!-- end: product-image-wrapper -->
<?php if ($gc['display_name'] != 0): ?>
<h2 class="product-name<?php echo $productNameClasses; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h2>
<?php endif; ?>
<?php if ($_product->getRatingSummary()): ?>
<?php if ($gc['display_rating'] == 1): //Display on hover ?>
<div class="display-onhover ratings-wrapper"><?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 if ($gc['display_price'] == 1): //Display on hover ?>
<div class="display-onhover"><?php echo $this->getPriceHtml($_product, true); ?></div>
<?php elseif ($gc['display_price'] == 2): //Always display ?>
<?php echo $this->getPriceHtml($_product, true); ?>
<?php endif; ?>
<?php
//If at least one element was set as "Display on hover" but no element was set as "Display":
//aggregate classes from those elements and apply them to the "actions" container.
$actionsClasses = '';
if ($gc['display_addtocart'] == 1 || ($gc['display_addtolinks'] == 1 && !$gc['addtolinks_simple']))
{
$actionsClasses = ' display-onhover';
}
if ($gc['display_addtocart'] == 2 || ($gc['display_addtolinks'] == 2 && !$gc['addtolinks_simple']))
{
$actionsClasses = '';
}
?>
<div class="actions clearer<?php echo $actionsClasses; ?>">
<?php //Cart button ?>
<?php if ($gc['display_addtocart'] != 0): ?>
<?php if ($_product->isSaleable()): ?>
<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>
<?php else: ?>
<p class="availability out-of-stock"><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'])
{
echo $helpTemplate->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product), 'addto-gaps-right');
}
?>
</div> <!-- end: actions -->
</li>
<?php endforeach; ?>
</ul>
<?php endif; //end: if grid mode ?>
<?php if (!$hideToolbar): ?>
<div class="toolbar-bottom">
<?php echo $this->getToolbarHtml() ?>
</div>
<?php endif; ?>
</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; ?>
I have the following code but it is not working.
Basically I want it so if the field movie_title_2 is empty I want it to add the , but if it is not empty to show just . I am using wordpress and Advanced Custom Fields plugin. Thanks!
<div class="homepage-opacity">
<div class="movie-container">
<?php if (get_field('movie_title_2') && get_field('movie_title_2') != "") { ?>
<div class="movie-area alone">
<div class="movie-poster">
<?php if ( get_field('movie_image_poster') ) : ?>
<img src="<?php the_field('movie_image_poster'); ?>" alt="<?php the_field('movie_image_poster'); ?>}">
<?php endif; ?>
</div>
<div class="movie-info">
<?php
if(get_field('movie_title'))
{
echo '<h1 class="movie-title">' . get_field('movie_title') . '</h1>';
}
?>
<?php
if(get_field('movie_dates_&_times'))
{
echo '<p class="movie-times">' . get_field('movie_dates_&_times') . '</p>';
}
?>
<?php if ( get_field('trailer_link') ) : ?>
<a class="movie-trailer" href="<?php the_field('trailer_link'); ?>" target="_blank">View the Trailer</a>
<?php endif; ?>
</div>
</div>
<?php } ?>
<?php if (get_field('movie_title_2') && get_field('movie_title_2') == "") { ?>
<div class="movie-area">
<div class="movie-poster">
<?php if ( get_field('movie_image_poster') ) : ?>
<img src="<?php the_field('movie_image_poster'); ?>" alt="<?php the_field('movie_image_poster'); ?>}">
<?php endif; ?>
</div>
<div class="movie-info">
<?php
if(get_field('movie_title'))
{
echo '<h1 class="movie-title">' . get_field('movie_title') . '</h1>';
}
?>
<?php
if(get_field('movie_dates_&_times'))
{
echo '<p class="movie-times">' . get_field('movie_dates_&_times') . '</p>';
}
?>
<?php if ( get_field('trailer_link') ) : ?>
<a class="movie-trailer" href="<?php the_field('trailer_link'); ?>" target="_blank">View the Trailer</a>
<?php endif; ?>
</div>
</div>
<div class="movie-area">
<div class="movie-poster">
<?php if ( get_field('movie_image_poster_2') ) : ?>
<img src="<?php the_field('movie_image_poster_2'); ?>" alt="<?php the_field('movie_image_poster_2'); ?>}">
<?php endif; ?>
</div>
<div class="movie-info">
<?php
if(get_field('movie_title_2'))
{
echo '<h1 class="movie-title">' . get_field('movie_title_2') . '</h1>';
}
?>
<?php
if(get_field('movie_dates_&_times_2'))
{
echo '<p class="movie-times">' . get_field('movie_dates_&_times_2') . '</p>';
}
?>
<?php if ( get_field('trailer_link_2') ) : ?>
<a class="movie-trailer" href="<?php the_field('trailer_link_2'); ?>" target="_blank">View the Trailer</a>
<?php endif; ?>
</div>
</div>
<?php } ?>
</div>
</div>
try:
<?php
$variable = get_field('movie_title_2');
if ($variable) { ?>
<h1>Add html just like you would normally do</h1>
<?php } else { ?>
<h1>Add different html here when the variable is empty</h1>
<?php } ?>
Hi guys I am trying to integrate CSS3 Mashmenu onto my Magento store http://www.mybloggerlab.com/2012/07/mashable-drop-down-navigation-menu-for.html
I would like to setup the menu to show product categories which when hovered over show product thumbnails with short description for each product in that category.
The prodblem I am having is setting this up so it is dynamic as I would prefer to have the menu be controllable via admin.
If someone could tell me where I am going wrong I would be very grateful as the current code isn't working.
<div id="pageContainer">
<div class="mashmenu">
<div class="fnav"><?php echo $this->__('BROWSE PRODUCTS'); ?>+
<div class="allContent">
<?php foreach ($_categories as $_category): ?>
<?php if($_category->getIsActive()): ?>
<div class="snav"><a href="#" class="slink">
<a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="current"<?php endif; ?>><?php echo $this->htmlEscape($_category->getName()) ?></a> (<?php echo $_category->getProductCount() ?>)</a>
<?php $collection = $_category->getProductCollection()->addAttributeToSort('name', 'asc'); ?>
<?php foreach ($collection as $_product) : ?>
<div class="insideContent">
<a href="<?php echo $this->getProductUrl($_product) ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(75) ?>" width="75" height="75" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" />
</a>
<span> <?php $sdesc = $_product->getShortDescription();
$sdesc = trim($sdesc);
$limit = 170;
if (strlen($sdesc) > $limit) {
$sdesc = substr($sdesc, 0, strrpos(substr($sdesc, 0, $limit), ' '));
} ?>
<?php echo $sdesc."..."; ?></span>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php endforeach; ?>
<!-- end insideContent -->
</div>
</div>
</div>
</div>
<script>
$j(document).ready(function(){
$j('div.mashmenu img').css({"width":"100px","height":"60px"});
$j('div.mashmenu').find('.allContent').css({"top":"38px"});
$j('div.mashmenu').mouseleave(function(){
$j('div.mashmenu .allContent').show('50');
$j('div.mashmenu .insideContent').fadeOut('50');
});
$j('.flink').mouseenter(function(){
$j('div.mashmenu .allContent').show('50');
$j(this).parent('.fnav').children('.allContent').show(200);
});
$j('.slink').mouseenter(function(){
if($j(this).parent('.snav').children('.insideContent').find('a').size() != 0 )
$j(this).parents('.allContent').css({"width":"640px","height":"500px"});
else $j(this).parents('.allContent').css({"width":"auto","height":"auto"});
$j('div.mashmenu .insideContent').fadeOut('50');
$j(this).parent('.snav').children('.insideContent').fadeIn(200);
});
$j('.snav').mouseleave(function(){
$j(this).parents('.allContent').css({"width":"auto","height":"auto"});
});
$j('.snav').mouseenter(function(){
$j(this).children('.insideContent').css({"display":"block","position":"absolute","width":"auto","height":"450px"});
});
});
</script>
<?php endif; ?>
<div class="insideContent">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(75) ?>" width="75" height="75" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" /> <span> <?php $sdesc = $_product->getShortDescription();
$sdesc = trim($sdesc);
$limit = 170;
if (strlen($sdesc) > $limit) {
$sdesc = substr($sdesc, 0, strrpos(substr($sdesc, 0, $limit), ' '));
} ?>
<?php echo $sdesc."..."; ?></span>
</div>
Your $_product is undefined here, moreover you'll have only one product per category so which one to show ?
replace this by something like :
<?php $collection = Mage::getModel('catalog/product')->getCollection()->addCategoryFilter($_category)->setPageSize(4);
<div class="insideContent">
<?php foreach ($collection as $_product) { ?>
//Your product here, copy your code
<?php } /*end foreach*/ ?>
</div>
It should work better like this.