FatalErrorException: syntax error, unexpected end of file - php

Dear stackoverflow member PHP developers. Despite all the coding in a project, I am getting the following error persistently. It gives a syntax error on line 102, the last line. I get the error "syntax error, unexpected end of file". I've been trying for 3 days but I couldn't find the error. Thank you very much if you help.
<?php foreach($entrysquizquest as $key => $entry): ?>
<section class="entry quizquestion selectableQuest" id="section_<?php echo e($entry->order); ?>" data-entry="<?php echo e($entry->id); ?>">
<?php if($entry->title): ?>
<h2 class="sub-title" >
<?php echo e($entry->title); ?>
</h2>
<?php endif; ?>
<div class="media">
<div class="sharemedia">
<?php echo $__env->make('._particles.others.entrysharebuttons', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
</div>
<a id="" class="gif-icon-a"><img class="img-responsive" style="display: block;width:100%" alt="<?php echo e($entry->title); ?>" src="<?php echo e(makepreview($entry->image, null, 'entries')); ?>"></a>
<small><?php echo $entry->source; ?></small>
</div>
<p>
<?php echo $entry->body; ?>
</p>
<div class="clear"></div>
<div class="answer" style="margin-left:-15px;">
<?php $sitep = $post->entry()->where('type', 'answer')->where('source', $entry->id)->get(); ?>
<ol class="option-selection <?php if($entry->video == '1'): ?>thdefault <?php else: ?> <?php echo e($entry->video == "2" ? 'thlarge' : 'thlist'); ?><?php endif; ?>">
<?php foreach($sitep as $keya => $answers): ?>
<?php $keya=$keya+1;?>
<li>
<a class="" href="javascript:" data-answer="<?php echo e($answers->id); ?>" data-result="<?php echo e($answers->video); ?>" >
<div class="answer-cover">
<?php if($entry->video!='3'): ?>
<img class="responsive-img" alt="<?php echo e($answers->title); ?>" src="<?php echo e(makepreview($answers->image, null, 'answers')); ?>">
<?php endif; ?>
<h4 class="option-sel" >
<i class="fa fa-square-o answer-check"></i>
<span class="option-text">
<?php echo $answers->title > "" ? $answers->title : '<br>'; ?>
</span>
</h4>
</div>
</a>
<div class="clear"></div>
</li>
<?php if(($keya%3)==0 and $entry->video=='1' or ($keya%2)==0 and $entry->video=='2' ): ?>
</ol><div class="clear"></div> <ol class="option-selection <?php if($entry->video == '1'): ?>thdefault <?php else: ?> <?php echo e($entry->video == "2" ? 'thlarge' : 'thlist'); ?><?php endif; ?>">
<?php endif; ?>
<?php endforeach; ?>
</ol>
</div>
<div class="clear"></div>
</section>
<section class="entry results" id="quiz_result" data-popup="<?php echo e(getcong('BuzzyQuizzesPopup')); ?>">
<div class="quiz_result_area">
<h2 class="post-title"><?php echo e($post->title); ?></h2>
<ol>
<?php foreach($entrysquizresults as $keyp => $entry): ?>
<li class="quiz_result" data-order="<?php echo e($keyp); ?>" data-result="<?php echo e($entry->id); ?>" data-link="<?php echo e(Request::url()); ?>" data-name="<?php echo e(trans('buzzyquiz.yougot', ['title'=> $entry->title])); ?>" data-iname="<?php echo e(trans('buzzyquiz.igot', ['title'=> $entry->title, 'posttitle'=> $post->title])); ?>" data-itname="<?php echo e(trans('buzzyquiz.igotfortweet', ['title'=> $entry->title])); ?>" data-description="<?php echo e(strip_tags($entry->body)); ?>" data-picture="<?php echo e($entry->image > "" ? makepreview($entry->image, null, 'entries') : makepreview($post->thumb, 'b', 'posts')); ?>">
<h2 class="quiz_headline">
<?php echo e(trans('buzzyquiz.yougot', ['title'=> $entry->title])); ?>
</h2>
<div class="clear"></div>
<div class="quiz_text" <?php echo e($entry->image == '' ? 'style=width:100%' :''); ?><?php echo $entry->body; ?></div>
<div class="quiz_img <?php echo e($entry->image == '' ? 'hide' :''); ?>" >
<img class="responsive_img" style=" float: right;" src="data:image/gif;base64,R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==">
</div>
</li>
<?php endforeach; ?>
</ol>
</div>
<div class="clear"></div>
<div class="quiz_result_share">
<h2 class="bold share_title"><?php echo e(trans('buzzyquiz.shareresult')); ?></h2>
<div class="external-sign-in">
<?php echo e(trans('index.sharefacebook')); ?>
<?php echo e(trans('index.sharetweet')); ?>
<?php echo e(trans('index.sharepinterest')); ?>
<?php echo e(trans('index.sharegoogle')); ?>
</div>
<div class="clear"></div>
</div>
</section>

in line 57 add
<?php endforeach; ?>
you forget end foreach

Check for syntax error on a debugger. For instance, you have two > :
<?php echo ($entry->image == '' ? 'style=width:100%' :''); ?>><?php echo

Related

How to sort replies by date - latest reply show first

first i want to apologize for my bad english, but i want to ask:
I have a ticketing system and i want to sort my replies by latest reply. Now the sorting is from oldest and now i want to sort by newest
I am using CodeIgniter as framework, and Perfex CRM as script
That's a part of my code, i don't know what can i do for sorting>
<div class="panel-footer">
<?php echo _l('ticket_posted',_dt($ticket->date)); ?>
</div>
</div>
<?php foreach($ticket_replies as $reply){ ?>
<div class="panel_s">
<div class="panel-body <?php if($reply['admin'] == NULL){echo 'client-reply';} ?>">
<div class="row">
<div class="col-md-3 border-right ticket-submitter-info">
<p>
<?php if($reply['admin'] == NULL || $reply['admin'] == 0){ ?>
<?php if($reply['userid'] != 0){ ?>
<?php echo $reply['submitter']; ?>
<?php } else { ?>
<?php echo $reply['submitter']; ?>
<br />
<?php echo $reply['reply_email']; ?>
<?php } ?>
<?php } else { ?>
<?php echo $reply['submitter']; ?>
<?php } ?>
</p>
<p class="text-muted">
<?php if($reply['admin'] !== NULL || $reply['admin'] != 0){
echo _l('ticket_staff_string');
} else {
if($reply['userid'] != 0){
echo _l('ticket_client_string');
}
}
?>
</p>
<hr />
<?php echo _l('delete_ticket_reply'); ?>
<div class="clearfix"></div>
<?php if(has_permission('tasks','','create')){ ?>
<a href="#" class="pull-left btn btn-default mtop5 btn-xs" onclick="convert_ticket_to_task(<?php echo $reply['id']; ?>,'reply'); return false;"><?php echo _l('convert_to_task'); ?>
</a>
<div class="clearfix"></div>
<?php } ?>
</div>
<div class="col-md-9">
<div class="row">
<div class="col-md-12 text-right">
<?php if(!empty($reply['message'])) { ?>
<i class="fa fa-print"></i>
<?php } ?>
<i class="fa fa-pencil-square-o"></i>
</div>
</div>
<div class="clearfix"></div>
<div data-reply-id="<?php echo $reply['id']; ?>" class="tc-content">
<?php echo check_for_links($reply['message']); ?>
</div>
<?php if(count($reply['attachments']) > 0){
echo '<hr />';
foreach($reply['attachments'] as $attachment){
$path = get_upload_path_by_type('ticket').$ticket->ticketid.'/'.$attachment['file_name'];
$is_image = is_image($path);
if($is_image){
echo '<div class="preview_image">';
}
?>
<a href="<?php echo site_url('download/file/ticket/'. $attachment['id']); ?>" class="display-block mbot5"<?php if($is_image){ ?> data-lightbox="attachment-reply-<?php echo $reply['id']; ?>" <?php } ?>>
<i class="<?php echo get_mime_class($attachment['filetype']); ?>"></i> <?php echo $attachment['file_name']; ?>
<?php if($is_image){ ?>
<img class="mtop5" src="<?php echo site_url('download/preview_image?path='.protected_file_url_by_path($path).'&type='.$attachment['filetype']); ?>">
<?php } ?>
</a>
<?php if($is_image){
echo '</div>';
}
if(is_admin() || (!is_admin() && get_option('allow_non_admin_staff_to_delete_ticket_attachments') == '1')){
echo ''._l('delete').'';
}
echo '<hr />';
}
} ?>
</div>
</div>
</div>
<div class="panel-footer">
<span><?php echo _l('ticket_posted',_dt($reply['date'])); ?></span>
</div>
</div>
<?php } ?>
</div>
</div>
<div class="btn-bottom-pusher"></div>
<?php if(count($ticket_replies) > 1){ ?>
↑
↓
<?php } ?>
</div>
</div>
In the 5th line of this snippet
<?php foreach($ticket_replies as $reply)
$ticket_replies is the result of some query (which is not pasted here). Also from this line
<span><?php echo _l('ticket_posted',_dt($reply['date'])); ?></span>
it can be seen that there is a 'date' column. As already mentioned in the comment above add 'ascending' or 'descending' order by clause to the query.

How to access a custom attribute I've created in Magento? (in PHP)

I'd like to include an IF statement into my highlights.phtml file where I can check if my custom attribute (named preorder) has been selected or not. As the name indicates, this custom attribute can be set on a product to signify if it can be pre-ordered. How can I access this variable/attribute in the highlights slider code, below? It doesn't seem to be part of the $products array?
<?php $products = $this->getHighlightedProducts() ?>
<?php if (is_array($products) && count($products)): ?>
<div class="block block-related">
<div class="block-title">
<h2><?php echo $this->__('Highlighted Products') ?></h2>
</div>
<div class="block-content">
<div class="product-carousel">
<div class="product-carousel">
<ul class="highlighted-products-slider slider">
<?php $limit = 6; ?>
<?php foreach ($products as $product): ?>
<li class="item">
<div class="product" >
<a class="product-image" href="<?php echo $this->escapeHtml($product['url']) ?>">
<img src="<?php echo $this->escapeHtml($product['image']) ?>">
</a>
<div class="product-details">
<p class="product-name">
<?php echo $this->escapeHtml($product['name']) ?>
</p>
<?php echo $product['price'] ?>
</div>
<div class="actions">
<a href="<?php echo $this->escapeHtml($product['add_to_cart_url']) ?>">
<button class="button btn-cart"><?php echo $this->__('Add to Cart') ?></button>
</a>
</div>
</div>
</li>
<?php
if(++$ct >= $limit)
break;
?>
<?php endforeach ?>
<?php endif ?>
</ul>
</div>
</div>
</div>
</div>
Get the attribute with the code i added, then use it for your logic. What you want to do with the attribute, you can do now. But $product['id'] has to exist!
You need the product id for this to work, else maybe the SKU.
Hope to help.
<?php $products = $this->getHighlightedProducts() ?>
<?php if (is_array($products) && count($products)): ?>
<div class="block block-related">
<div class="block-title">
<h2><?php echo $this->__('Highlighted Products') ?></h2>
</div>
<div class="block-content">
<div class="product-carousel">
<div class="product-carousel">
<ul class="highlighted-products-slider slider">
<?php $limit = 6; ?>
<?php foreach ($products as $product): ?>
<?php
$productToCheck= Mage::getModel('catalog/product')->load($product['id']);
//use this variable
$variable = $productToCheck->getData('preorder');
//use this variable when attribute is a dropdown
$variableIfItsADropdown = $product->getAttributeText('preorder');
?>
<li class="item">
<div class="product" >
<a class="product-image" href="<?php echo $this->escapeHtml($product['url']) ?>">
<img src="<?php echo $this->escapeHtml($product['image']) ?>">
</a>
<div class="product-details">
<p class="product-name">
<?php echo $this->escapeHtml($product['name']) ?>
</p>
<?php echo $product['price'] ?>
</div>
<div class="actions">
<a href="<?php echo $this->escapeHtml($product['add_to_cart_url']) ?>">
<button class="button btn-cart"><?php echo $this->__('Add to Cart') ?></button>
</a>
</div>
</div>
</li>
<?php
if(++$ct >= $limit)
break;
?>
<?php endforeach ?>
<?php endif ?>
</ul>
</div>
</div>
</div>
</div>

Shortcode is moving the_content outside of the article container in WordPress

I've made a shortcode function that returns some Advanced Custom Fields depending on which repeater field is chosen. It displays correctly and in the right order however any content typed underneath the shortcode is moved outside of its <article> container element.
Here is the code:
function boxes_shortcode($atts, $content = null) {
ob_start(); ?>
<div id="boxes">
<div class="box-gutter"></div>
<div class="box-sizer"></div>
<?php while( have_rows('box_repeater') ): the_row();
$image_id = get_sub_field('link_image');
$image_size = 'box-thumbnail';
$image_array = wp_get_attachment_image_src($image_id, $image_size);
$linkImage = $image_array[0]; ?>
<?php if(get_sub_field('box_type') == "box-link"): ?>
<div class="box">
<div class="link-box">
<img src="<?php echo $linkImage; ?>" alt="<?php echo $linkImage['alt']; ?>" />
<a class="caption-wrapper" href="http://www.google.com">
<span id="link-box-content" style="background:<?php the_sub_field('link_background_colour'); ?>">
<h6 style="color:<?php the_sub_field('link_title_colour'); ?>"><?php the_sub_field('link_title'); ?></h6>
<h4 style="color:<?php the_sub_field('link_text_colour'); ?>"><?php the_sub_field('link_text'); ?></h4>
<p style="color:<?php the_sub_field('link_text_colour'); ?>" href="<?php the_sub_field('link_url'); ?>"><?php the_sub_field('link_url_text'); ?> ></p>
</span>
</a>
</div>
</div>
<?php endif;
if(get_sub_field('box_type') == "box-quote"): ?>
<div class="box">
<div class="quote-box">
<div class="quotation-mark"></div>
<h4><?php the_sub_field('quote'); ?></h2>
<p><?php the_sub_field('quote_source'); ?></p>
<?php the_sub_field('quote_link_text'); ?> >
</div>
</div>
<?php endif;
if(get_sub_field('box_type') == "box-twitter"): ?>
<div class="box">
<div class="twitter">
<a class="twitter-timeline" href="<?php the_sub_field('twitter_url'); ?>" data-widget-id="<?php the_sub_field('twitter_widget_id'); ?>" data-chrome="noheader noscrollbar nofooter noborders transparent" data-tweet-limit="<?php the_sub_field('number_of_tweets'); ?>"></a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<a class="twitter-badge" href="<?php the_sub_field('twitter_url'); ?>"></a>
<div class="twitter-bottom">See more ></div>
</div>
</div>
<?php endif;
endwhile;?>
</div>
</div>
</div>
<?php
/* Get the buffered content into a var */
$sc = ob_get_contents();
ob_end_clean();
return $sc;
}
add_shortcode('boxes', 'boxes_shortcode');
Can anyone help solve this mystery? Many thanks.
You have two extra closing <div>'s in your code.
Try this:
function boxes_shortcode($atts, $content = null) {
ob_start(); ?>
<div id="boxes">
<div class="box-gutter"></div>
<div class="box-sizer"></div>
<?php while( have_rows('box_repeater') ): the_row();
$image_id = get_sub_field('link_image');
$image_size = 'box-thumbnail';
$image_array = wp_get_attachment_image_src($image_id, $image_size);
$linkImage = $image_array[0]; ?>
<?php if(get_sub_field('box_type') == "box-link"): ?>
<div class="box">
<div class="link-box">
<img src="<?php echo $linkImage; ?>" alt="<?php echo $linkImage['alt']; ?>" />
<a class="caption-wrapper" href="http://www.google.com">
<span id="link-box-content" style="background:<?php the_sub_field('link_background_colour'); ?>">
<h6 style="color:<?php the_sub_field('link_title_colour'); ?>"><?php the_sub_field('link_title'); ?></h6>
<h4 style="color:<?php the_sub_field('link_text_colour'); ?>"><?php the_sub_field('link_text'); ?></h4>
<p style="color:<?php the_sub_field('link_text_colour'); ?>" href="<?php the_sub_field('link_url'); ?>"><?php the_sub_field('link_url_text'); ?> ></p>
</span>
</a>
</div>
</div>
<?php endif;
if(get_sub_field('box_type') == "box-quote"): ?>
<div class="box">
<div class="quote-box">
<div class="quotation-mark"></div>
<h4><?php the_sub_field('quote'); ?></h2>
<p><?php the_sub_field('quote_source'); ?></p>
<?php the_sub_field('quote_link_text'); ?> >
</div>
</div>
<?php endif;
if(get_sub_field('box_type') == "box-twitter"): ?>
<div class="box">
<div class="twitter">
<a class="twitter-timeline" href="<?php the_sub_field('twitter_url'); ?>" data-widget-id="<?php the_sub_field('twitter_widget_id'); ?>" data-chrome="noheader noscrollbar nofooter noborders transparent" data-tweet-limit="<?php the_sub_field('number_of_tweets'); ?>"></a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<a class="twitter-badge" href="<?php the_sub_field('twitter_url'); ?>"></a>
<div class="twitter-bottom">See more ></div>
</div>
</div>
<?php endif;
endwhile;?>
</div>
<!--/div>
</div-->
<?php
/* Get the buffered content into a var */
$sc = ob_get_contents();
ob_end_clean();
return $sc;
}
add_shortcode('boxes', 'boxes_shortcode');

Foreach is only calling the last item in the list

I don't really think knowledge of OpenCart would help too much with answering this question, but maybe I am wrong.
I am using OpenCart to make a shop. I am making edits to my categories.tpl page, and everything was looking good. I only had one product when I was doing the edits so it was normal that it was only showing one product. Before I did the edits, I did check the same page with many of the products you start with and it was working fine.
Here is my code right now, which is only calling the last product (I'm guessing item in an array or in a SQL sheet)
<?php echo $header; ?>
<div class="container">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<?php } ?>
<div class="row"><?php echo $column_left; ?>
<?php if ($column_left && $column_right) { ?>
<?php $class = 'col-sm-6'; ?>
<?php } elseif ($column_left || $column_right) { ?>
<?php $class = 'col-sm-9'; ?>
<?php } else { ?>
<?php $class = 'col-sm-12'; ?>
<?php } ?>
<div id="content" class="<?php echo $class; ?>"><?php echo $content_top; ?>
<?php if ($thumb || $description) { ?>
<div class="row">
<?php if ($thumb) { ?>
<?php } ?>
<?php if ($description) { ?><?php } ?>
</div>
<hr>
<?php } ?>
<?php if ($categories) { ?>
<h3><?php echo $text_refine; ?></h3>
<?php if (count($categories) <= 5) { ?>
<div class="row">
<div class="col-sm-3">
</div>
<?php }
?>
<?php } ?>
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-2 text-right">
</div>
<div class="col-md-3 text-right">
<button type="button" id="grid-view" style="display: none;"></button>
</div>
</div><br />
<div class="row">
<?php foreach ($products as $product) { ?>
<div class="product-layout product-list col-xs-12">
<div class="product-thumb">
<div class="image"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-responsive" /></div>
<div>
<div class="caption">
<h4><?php echo $product['name']; ?></h4>
<p><?php echo $product['description']; ?></p>
<?php if ($product['rating']) { ?>
<div class="rating">
<?php for ($i = 1; $i <= 5; $i++) { ?>
<?php if ($product['rating'] < $i) { ?>
<span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span>
<?php } else { ?>
<span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i><i class="fa fa-star-o fa-stack-2x"></i></span>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
<?php if ($product['price']) { ?>
<p class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
</p>
<?php } ?>
</div>
<div class="button-group">
<button style="width:100%;" type="button" onclick="cart.add('<?php echo $product['product_id']; ?>', '<?php echo $product['minimum']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 text-left"><?php echo $pagination; ?></div>
<div class="col-sm-6 text-right"><?php echo $results; ?></div>
</div>
<?php } ?>
<?php if (!$categories && !$products) { ?>
<p><?php echo $text_empty; ?></p>
<div class="buttons">
<div class="pull-right"><?php echo $button_continue; ?></div>
</div>
<?php } ?>
<?php echo $content_bottom; ?></div>
<?php echo $column_right; ?></div>
</div>
<?php echo $footer; ?>
And here is the code I started with, which worked correctly.
<?php echo $header; ?>
<div class="container">
<ul class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<li><?php echo $breadcrumb['text']; ?></li>
<?php } ?>
</ul>
<div class="row"><?php echo $column_left; ?>
<?php if ($column_left && $column_right) { ?>
<?php $class = 'col-sm-6'; ?>
<?php } elseif ($column_left || $column_right) { ?>
<?php $class = 'col-sm-9'; ?>
<?php } else { ?>
<?php $class = 'col-sm-12'; ?>
<?php } ?>
<div id="content" class="<?php echo $class; ?>"><?php echo $content_top; ?>
<h2><?php echo $heading_title; ?></h2>
<?php if ($thumb || $description) { ?>
<div class="row">
<?php if ($thumb) { ?>
<div class="col-sm-2"><img src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?>" title="<?php echo $heading_title; ?>" class="img-thumbnail" /></div>
<?php } ?>
<?php if ($description) { ?>
<div class="col-sm-10"><?php echo $description; ?></div>
<?php } ?>
</div>
<hr>
<?php } ?>
<?php if ($categories) { ?>
<h3><?php echo $text_refine; ?></h3>
<?php if (count($categories) <= 5) { ?>
<div class="row">
<div class="col-sm-3">
<ul>
<?php foreach ($categories as $category) { ?>
<li><?php echo $category['name']; ?></li>
<?php } ?>
</ul>
</div>
</div>
<?php } else { ?>
<div class="row">
<?php foreach (array_chunk($categories, ceil(count($categories) / 4)) as $categories) { ?>
<div class="col-sm-3">
<ul>
<?php foreach ($categories as $category) { ?>
<li><?php echo $category['name']; ?></li>
<?php } ?>
</ul>
</div>
<?php } ?>
</div>
<?php } ?>
<?php } ?>
<?php if ($products) { ?>
<p><?php echo $text_compare; ?></p>
<div class="row">
<div class="col-md-4">
<div class="btn-group hidden-xs">
<button type="button" id="list-view" class="btn btn-default" data-toggle="tooltip" title="<?php echo $button_list; ?>"><i class="fa fa-th-list"></i></button>
<button type="button" id="grid-view" class="btn btn-default" data-toggle="tooltip" title="<?php echo $button_grid; ?>"><i class="fa fa-th"></i></button>
</div>
</div>
<div class="col-md-2 text-right">
<label class="control-label" for="input-sort"><?php echo $text_sort; ?></label>
</div>
<div class="col-md-3 text-right">
<select id="input-sort" class="form-control" onchange="location = this.value;">
<?php foreach ($sorts as $sorts) { ?>
<?php if ($sorts['value'] == $sort . '-' . $order) { ?>
<option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
<?php } else { ?>
<option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="col-md-1 text-right">
<label class="control-label" for="input-limit"><?php echo $text_limit; ?></label>
</div>
<div class="col-md-2 text-right">
<select id="input-limit" class="form-control" onchange="location = this.value;">
<?php foreach ($limits as $limits) { ?>
<?php if ($limits['value'] == $limit) { ?>
<option value="<?php echo $limits['href']; ?>" selected="selected"><?php echo $limits['text']; ?></option>
<?php } else { ?>
<option value="<?php echo $limits['href']; ?>"><?php echo $limits['text']; ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
</div>
<br />
<div class="row">
<?php foreach ($products as $product) { ?>
<div class="product-layout product-list col-xs-12">
<div class="product-thumb">
<div class="image"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-responsive" /></div>
<div>
<div class="caption">
<h4><?php echo $product['name']; ?></h4>
<p><?php echo $product['description']; ?></p>
<?php if ($product['rating']) { ?>
<div class="rating">
<?php for ($i = 1; $i <= 5; $i++) { ?>
<?php if ($product['rating'] < $i) { ?>
<span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span>
<?php } else { ?>
<span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i><i class="fa fa-star-o fa-stack-2x"></i></span>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
<?php if ($product['price']) { ?>
<p class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
<?php if ($product['tax']) { ?>
<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
<?php } ?>
</p>
<?php } ?>
</div>
<div class="button-group">
<button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>', '<?php echo $product['minimum']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button>
<button type="button" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-heart"></i></button>
<button type="button" data-toggle="tooltip" title="<?php echo $button_compare; ?>" onclick="compare.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-exchange"></i></button>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
<div class="row">
<div class="col-sm-6 text-left"><?php echo $pagination; ?></div>
<div class="col-sm-6 text-right"><?php echo $results; ?></div>
</div>
<?php } ?>
<?php if (!$categories && !$products) { ?>
<p><?php echo $text_empty; ?></p>
<div class="buttons">
<div class="pull-right"><?php echo $button_continue; ?></div>
</div>
<?php } ?>
<?php echo $content_bottom; ?></div>
<?php echo $column_right; ?></div>
</div>
<?php echo $footer; ?>
Thanks in advance for anyone who could try and figure out why it is not working.
Here, have not add properly close tag for foreach php loop.
Try following code in your editing file.
<?php echo $header; ?>
<div class="container">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<?php } ?>
<div class="row"><?php echo $column_left; ?>
<?php if ($column_left && $column_right) { ?>
<?php $class = 'col-sm-6'; ?>
<?php } elseif ($column_left || $column_right) { ?>
<?php $class = 'col-sm-9'; ?>
<?php } else { ?>
<?php $class = 'col-sm-12'; ?>
<?php } ?>
<div id="content" class="<?php echo $class; ?>"><?php echo $content_top; ?>
<?php if ($categories) { ?>
<h3><?php echo $text_refine; ?></h3>
<?php } ?>
<br />
<div>
<?php foreach ($products as $product) { ?>
<div class="product-layout product-list col-xs-12">
<div class="product-thumb">
<div class="image"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-responsive" /></div>
<div>
<div class="caption">
<h4><?php echo $product['name']; ?></h4>
<p><?php echo $product['description']; ?></p>
<?php if ($product['rating']) { ?>
<div class="rating">
<?php for ($i = 1; $i <= 5; $i++) { ?>
<?php if ($product['rating'] < $i) { ?>
<span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span>
<?php } else { ?>
<span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i><i class="fa fa-star-o fa-stack-2x"></i></span>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
<?php if ($product['price']) { ?>
<p class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
</p>
<?php } ?>
</div>
<div class="button-group">
<button style="width:100%;" type="button" onclick="cart.add('<?php echo $product['product_id']; ?>', '<?php echo $product['minimum']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button>
</div>
</div>
</div>
</div><?php } ?>
</div>
<div class="row">
<div class="col-sm-6 text-left"><?php echo $pagination; ?></div>
<div class="col-sm-6 text-right"><?php echo $results; ?></div>
</div>
<?php if (!$categories && !$products) { ?>
<p><?php echo $text_empty; ?></p>
<div class="buttons">
<div class="pull-right"><?php echo $button_continue; ?></div>
</div>
<?php } ?>
<?php echo $content_bottom; ?></div>
<?php echo $column_right; ?></div>
</div>
<?php echo $footer; ?>

How to filter related.phtml by in-stock products only in magento

How would one go about filtering magento's related products block to show only in stock products?
<?php foreach($this->getItems() as $_item): ?>
<li class="item">
<?php if(!$_item->isComposite() && $_item->isSaleable()): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<input type="checkbox" class="checkbox related-checkbox" id="related-checkbox<?php echo $_item->getId() ?>" name="related_products[]" value="<?php echo $_item->getId() ?>" />
<?php endif; ?>
<?php endif; ?>
<div class="product">
<img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(50) ?>" width="50" height="50" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" />
<div class="product-details">
<p class="product-name"><?php echo $this->htmlEscape($_item->getName()) ?></p>
<?php echo $this->getPriceHtml($_item, true, '-related') ?>
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<?php echo $this->__('Add to Wishlist') ?>
<?php endif; ?>
</div>
</div>
</li>
<?php endforeach ?>
I've uploaded my current iteration of magentos realted.phtml to github:
https://gist.github.com/anonymous/6126772
Wrap the <li> in <?php if ($_item->isSaleable()): ?> . . . <?php endif; ?>.

Categories