I am trying to apply delete function on selected record in my application. the problem is that the record are displayed in pagination ie 3,4 rows, i am able to delete record from the first page but when i move to the second page and select few records, the delete record buton doesn't work. any adivise will really help.
I am looking for replies
here is my code for listings
public function index($offset=0)
{
if ( $this->session->userdata('u_name') == FALSE )
{
$data['page_title']="Admin Login";
redirect('admin/login',"refresh",$data);
}
$this->load->model('candidate_model');
$limit=4;
$results=$this->candidate_model->get_all_Candidate($limit,$offset);
$data['candidates']=$results['rows'];
$offset = $this->uri->segment(3, 0);
$data['num_results']=$results['num_rows'];
$this->load->library('pagination');
$config=array();
$config['first_url'] = 'candidateList/index';
$config['base_url']=site_url('candidateList/index');
$config['total_rows']=$data['num_results'];
$config['per_page']=$limit;
$config['uri_segment']=3;
$config['first_link'] = '>';
$config['first_tag_open'] = '<div>';
$config['first_tag_close'] = '</div>';
$this->pagination->initialize($config);
$data['page_title']="Candidate List";
$this->load->view('manageCandidate',$data);
}
my code for delete function is bellow
if($this->input->post('Delete')=='Delete')
{
for($i=0;$i<count($_POST['checkbox']);$i++)
{
$candidate_id = $_POST['checkbox'][$i];
$this->candidate_model->deleteCandidate($candidate_id);
$this->session->set_flashdata('deleteSelected','Selected Candidate has been deleted.');
}
$data['page_title']="Candidate List";
redirect('candidateList',$data);
}
Delete function is here:
public function candidate()
{
if ( $this->session->userdata('u_name') == FALSE )
{
$data['page_title']="Admin Login";
redirect('admin/login',"refresh",$data);
}
$checkList=$this->input->post('checkbox');
$this->load->model('candidate_model');
if($checkList!=NULL)
{
if($this->input->post('Delete')=='Delete')
{
for($i=0;$i<count($_POST['checkbox']);$i++)
{
$candidate_id = $_POST['checkbox'][$i];
$this->candidate_model->deleteCandidate($candidate_id);
$this->session->set_flashdata('deleteSelected','Selected Candidate has been deleted.');
}
$data['page_title']="Candidate List";
redirect('candidateList',$data);
}
else if($this->input->post('Email')=='Email')
{
for($i=0;$i<count($_POST['checkbox']);$i++)
{
$admin_id = $_POST['checkbox'][$i];
$email_to[$i] = $_POST['checkbox'][$i];
$data['email_to'] = $email_to;
}
$data['page_title']='Send Mail';
$this->load->view('admin/sendmail4',$data);
}
}
else
{
$this->session->set_flashdata('deleteSelect','Please Select at-least one Candidate.');
$data['page_title']="Candidate List";
redirect('candidateList',$data);
}
}
ManageCandidate code:
<?php
$this->load->view('includes/template3');
?>
<?php
$this->load->view('includes/superAdminMenu');
?>
<div class="dashboard">
Add Candidate
<?php if($this->session->flashdata('deleteCandidate')) : ?>
<p class="successMsg"><?php echo $this->session->flashdata('deleteCandidate')?></p>
<?php endif; ?>
<?php if($this->session->flashdata('editCandidate')) : ?>
<p class="successMsg"><?php echo $this->session->flashdata('editCandidate')?></p>
<?php endif; ?>
<?php if($this->session->flashdata('deleteSelected')) : ?>
<p class="successMsg"><?php echo $this->session->flashdata('deleteSelected')?></p>
<?php endif; ?>
<?php if($this->session->flashdata('deleteSelect')) : ?>
<p class="noRows"><?php echo $this->session->flashdata('deleteSelect')?></p>
<?php endif; ?>
<?php if($this->session->flashdata('msgSent')) : ?>
<p class="successMsg"><?php echo $this->session->flashdata('msgSent')?></p>
<?php endif; ?>
<?php
if($num_results==0)
{ ?>
<p class="noRows"><?php echo "You have not added any Candidate.";?></p>
<?php }
else
if($num_results>0)
{ ?>
<form action="candidateList/candidate" method="post" name="sendMail" class="addformClass" id="candidateList1">
<!-- Script by hscripts.com -->
<!-- copyright of HIOX INDIA -->
<!-- Free javascripts # http://www.hscripts.com -->
<script type="text/javascript">
checked=false;
function checkedAll (candidateList1) {
var aa= document.getElementById('candidateList1');
if (checked == false)
{
checked = true
}
else
{
checked = false
}
for (var i =0; i < aa.elements.length; i++)
{
aa.elements[i].checked = checked;
}
}
</script>
<!-- Script by hscripts.com -->
<?php if(isset($candidates)) { ?>
<div class="candidateTable">
<div class="candidateRowHeading">
<div class="candidateHeadingChkBox">
<h4><input type='checkbox' name='checkall' onclick='checkedAll(candidateList1);'>
</h4>
</div><!--END candidateHeadingChkBox-->
<div class="candidateColHeading1">
<h4>Candidate Name</h4>
</div><!--END candidateColHeading1-->
<div class="candidateColHeading3">
<h4>Email</h4>
</div><!--END candidateColHeading3-->
<div class="candidateColHeading4" style="display:none">
<h4>Status</h4>
</div><!--END candidateColHeading4-->
<div class="candidateColHeading6">
<h4>Recruiter Assigned</h4>
</div><!--END candidateColHeading6-->
<div class="candidateColHeading5">
<h4>Action</h4>
</div><!--END candidateColHeading5-->
</div><!--END candidateRowHeading-->
<?php $count=0; ?>
<?php foreach ($candidates as $candidate) { ?>
<div class="candidateRowData">
<div class="candidateColChkBox">
<input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $candidate->candidate_id; ?>">
</div><!--END candidateColChkBox-->
<div class="candidateColData1">
<?php echo anchor('admin/viewCandidate/'.$candidate->candidate_id, $candidate->first_name." ".$candidate->last_name); ?>
</div><!--END candidateColData1-->
<div class="candidateColData3">
<h4><?php echo $candidate->email; ?></h4>
</div><!--END candidateColData3-->
<div class="candidateColData4" style="display:none">
<h4><?php echo $candidate->lead_status; ?></h4>
</div><!--END candidateColData4-->
<div class="candidateColData6">
<h4>
<?php if($candidate->recruiter_id_fk!=0) { ?>
<?php echo get_recruiterFirstName($candidate->recruiter_id_fk); ?>
<?php echo get_recruiterLastName($candidate->recruiter_id_fk); ?>
<?php echo " (<strong>"; ?>
<?php echo get_recruiterLogin($candidate->recruiter_id_fk); ?>
<?php echo "</strong>) "; ?>
<?php }
else if($candidate->recruiter_id_fk==0) { ?>
<?php echo "Not Assigned"; ?>
<?php } ?>
</h4>
</div><!--END candidateColData6-->
<div class="candidateColData5">
<?php echo anchor('admin/editCandidate/'.$candidate->candidate_id,'Edit'); ?>
<?php echo anchor('admin/deleteCandidate/'.$candidate->candidate_id,'Delete'); ?>
</div><!--END candidateColData5-->
</div><!--END candidateRowData-->
<?php $count++; } ?>
</div><!--END candidateTableCom-->
<?php } ?>
<?php } ?>
<?php if(isset($candidates)) { ?>
<div id="pageNum">
<?php echo $this->pagination->create_links(); ?>
</div>
<?php } ?>
<?php
if($num_results>0) {
echo '<input type="submit" name="Delete" class="emailAllBtn" value="Delete" />';
echo '<input type="submit" name="Email" class="emailAllBtn" value="Email" />';
echo "</form>";
} ?>
</div>
<?php
$this->load->view('includes/footer2');
?>
<?php
function get_recruiterFirstName($id)
{
$CI =& get_instance();
$mod = $CI->load->model('recruiter_model');
$count = $CI->recruiter_model->get_recruiterFirstName($id);
return $count;
}
?>
<?php
function get_recruiterLastName($id)
{
$CI =& get_instance();
$mod = $CI->load->model('recruiter_model');
$count = $CI->recruiter_model->get_recruiterLastName($id);
return $count;
}
?>
<?php
function get_recruiterLogin($id)
{
$CI =& get_instance();
$mod = $CI->load->model('recruiter_model');
$count = $CI->recruiter_model->get_recruiterLogin($id);
return $count;
}
?>
Small mistake exist in your pagination code offset value correct it
public function index($offset=0)
{
if ( $this->session->userdata('u_name') == FALSE )
{
$data['page_title']="Admin Login";
redirect('admin/login',"refresh",$data);
}
$this->load->model('candidate_model');
$limit=4;
//whenever you are calling this pagination offset value you need to fetch it from URL
$offset_url = $offset = $this->uri->segment(3, 0);
//if it's not exist take the default value
$offset = is_numeric($offset_url)?$offset_url:$offset;
$results=$this->candidate_model->get_all_Candidate($limit,$offset);
$data['candidates']=$results['rows'];
..............
}
Related
first off, I'm extremely new to PHP.
I'm using Conrete5, and I have a new template to an image slider. This is what I'm using:
http://codepen.io/altitudems/pen/KdgGLG
There's a placeholder image, which I'm trying to replace by grabbing the first image set in the block itself. Here is my view file from the actual block:
<?php defined('C5_EXECUTE') or die("Access Denied.");
$navigationTypeText = ($navigationType == 0) ? 'arrows' : 'pages';
$c = Page::getCurrentPage();
if ($c->isEditMode()) { ?>
<div class="ccm-edit-mode-disabled-item" style="width: <?php echo $width; ?>; height: <?php echo $height; ?>">
<div style="padding: 40px 0px 40px 0px"><?php echo t('Image Slider disabled in edit mode.')?></div>
</div>
<?php } else { ?>
<script>
$(document).ready(function(){
$(function () {
$("#ccm-image-slider-<?php echo $bID ?>").responsiveSlides({
prevText: "", // String: Text for the "previous" button
nextText: "",
<?php if($navigationType == 0) { ?>
nav:true
<?php } else { ?>
pager: true
<?php } ?>
});
});
});
</script>
<div class="ccm-image-slider-container ccm-block-image-slider-<?php echo $navigationTypeText?>" >
<div class="ccm-image-slider">
<div class="ccm-image-slider-inner">
<?php if(count($rows) > 0) { ?>
<ul class="rslides" id="ccm-image-slider-<?php echo $bID ?>">
<?php foreach($rows as $row) { ?>
<li>
<?php if($row['linkURL']) { ?>
<?php } ?>
<?php
$f = File::getByID($row['fID'])
?>
<?php if(is_object($f)) {
$tag = Core::make('html/image', array($f, false))->getTag();
if($row['title']) {
$tag->alt($row['title']);
}else{
$tag->alt("slide");
}
print $tag; ?>
<?php } ?>
<div class="ccm-image-slider-text">
<?php if($row['title']) { ?>
<h1 class="ccm-image-slider-title"><?php echo $row['title'] ?></h1>
<?php } ?>
<?php echo $row['description'] ?>
</div>
</li>
<?php } ?>
</ul>
<?php } else { ?>
<div class="ccm-image-slider-placeholder">
<p><?php echo t('No Slides Entered.'); ?></p>
</div>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
Here is my gallery view file:
<a class="gallery-launcher" href="#gallery1"> // Location of the image
<div class="overlay">
<div class="overlay-content">
<button class="btn btn-default">Open Gallery</button>
</div>
</div>
</a>
<div class="gallery inactive" id="gallery1">
<div class="gallery-item">
//Fullscreen gallery code here
</div>
</div>
Where it says // Location of the image is where I need to have the first image set. I can't figure out what I'd put there? Any help will be appreciated.
You could use the concrete5 file helper to get the file path, like this for example:
$f = File::getByID($row['fID']);
$relpath = $f->getRelativePath();
In general I suggest that you read more about the concrete5 file functions to understand more how it works:
I have a Wordpress site that is using Wp-Property and the pagination isn't working, can anyone help fix this please. Please see below the pagination part from the function page.
<?php if($use_pagination) { ?>
if(!wpp_pagination_<?php echo $unique_hash; ?>) {
jQuery("#wpp_shortcode_<?php echo $unique_hash; ?> .wpp_pagination_slider_wrapper").each(function() {
var this_parent = this;
/* Slider */
jQuery('.wpp_pagination_slider', this).slider({
value:1,
min: 1,
max: <?php echo $pages; ?>,
step: 1,
slide: function( event, ui ) {
/* Update page counter - we do it here because we want it to be instant */
jQuery("#wpp_shortcode_<?php echo $unique_hash; ?> .wpp_current_page_count").text(ui.value);
jQuery("#wpp_shortcode_<?php echo $unique_hash; ?> .wpp_pagination_slider .slider_page_info .val").text(ui.value);
},
stop: function(event, ui) {
wpp_query_<?php echo $unique_hash; ?> = changeAddressValue(ui.value, wpp_query_<?php echo $unique_hash; ?>);
}
});
/* Fix slider width based on button width */
var slider_width = (jQuery(this_parent).width() - jQuery(".wpp_pagination_back", this_parent).outerWidth() - jQuery(".wpp_pagination_forward", this_parent).outerWidth() - 30);
jQuery(".wpp_pagination_slider", this_parent).css('width', slider_width);
jQuery('.wpp_pagination_slider .ui-slider-handle', this).append('<div class="slider_page_info"><div class="val">1</div><div class="arrow"></div></div>');
});
wpp_pagination_<?php echo $unique_hash; ?> = true;
}
<?php } ?>
});
</script>
<?php
$js_result = ob_get_contents();
ob_end_clean();
ob_start(); ?>
<div class="properties_pagination <?php echo $settings['class']; ?> wpp_slider_pagination" id="properties_pagination_<?php echo $unique_hash; ?>">
<div class="wpp_pagination_slider_status">
<?php
if(function_exists('WPPFL_getNumberOfFavorites')) {
$num_of_favorites = WPPFL_getNumberOfFavorites();
} else{
$num_of_favorites = 0;
}
$currentTemplate = "";
if (isset($wpp_query['template'])) {
$currentTemplate = $wpp_query['template'];
}
?>
<?php if ($currentTemplate==TEMPLATEPATH . "/list-my-property-content.php") { ?>
<div class="wppcs-sub-menu">
<?php global $post;
$post_name = $post->post_name; ?>
<?php $class='class="active"'; ?>
<ul>
<li <?php if($post_name == 'list-my-property') { echo $class; } ?>>
<a href="<?php echo get_bloginfo('url'); ?>/list-my-property/">
View Listed Properties
</a>
</li>
<li <?php if($post_name == 'add-new-property') { echo $class; } ?>>
<a href="<?php echo get_bloginfo('url'); ?>/list-my-property/add-new-property/">
Add New Property
</a>
</li>
</ul>
</div>
<?php } else { ?>
<ul class="top_part">
<li><a>Search results</a></li>
<li class="favor">My Favourites(<span class="number_of_favorites"><?php echo $num_of_favorites; ?></span>)</li>
</ul>
<?php } ?>
<div class="clear"></div>
</div>
<?php if($use_pagination) { ?>
<div class="wpp_pagination_slider_wrapper">
<div class="wpp_page_numbers_block">
<span class="numbers-title">Pages</span>
<?php
if ($pages < 10) {
for($i=1; $i<=$pages; $i++) {
echo '<span class="page_numbers" data-value="'.$i.'">'.$i.'</span>';
}
} else {
for($i=1; $i<=$pages; $i++) {
if (($i < 4) || ($i>$pages-3)) {
echo '<span class="page_numbers" data-value="'.$i.'">'.$i.'</span>';
}
if ($i==4) {
echo '<span class="middle-pages"><span class="dotted-separator">...</span></span>';
}
}
}?>
</div>
<div class="wpp_pagination_back wpp_pagination_button"><?php _e('Prev', 'wpp'); ?></div>
<div class="wpp_pagination_forward wpp_pagination_button"><?php _e('Next', 'wpp'); ?></div>
<div class="wpp_pagination_slider"></div>
</div>
<?php } ?>
</div>
<div class="ajax_loader"></div>
<?php
$html_result = ob_get_contents();
ob_end_clean();
Thank you in anticaption.
The first thing which can cause your issue is some of third party plugins or your theme. So try firstly to deactivate third party plugins and switch theme to default one to be sure that issue doesn't relate to any of them.
Such request you can also send here
https://wordpress.org/support/plugin/wp-property
or on our site
https://usabilitydynamics.com/contact-us/
Regards.
Usability Dynamics Support
I have a problem using codeigniter pagination. The problem is when I open the 2nd page during paging it is showing the error 404 page not found. I do not know why but for the 1st page it is working.
Model:
public function home($limit='',$segment=''){
$data = array();
$this->db->where(array('produk.status_produk'=>'1'))->limit($limit,$segment);
$i=0;
foreach ($this->get_all() as $item){
$data[$i] = $item;
$this->db->where(array('produk_id'=>$item->id_produk,'default'=>'1'));
if($this->db->get('foto_produk')->num_rows() > 0){
$this->db->where(array('produk_id'=>$item->id_produk,'default'=>'1'));
$foto = $this->db->get('foto_produk')->result();
foreach ($foto as $pic) {
$data[$i]->image = $pic->image;
$data[$i]->thumb = $pic->thumb;
}
} else {
$data[$i]->image = '';
$data[$i]->thumb = '';
}
$i++;
}
return $data;
}
Controller:
$cari = $this->input->post('search');
$this->db->like('deskripsi_produk', $cari);
$this->db->or_like('nama_produk', $cari);
$this->db->order_by('id_produk','desc');
$t = $this->produk_m->home();
$this->data->search = $this->input->post('search');
$this->load->library('pagination');
$perPage = 2;
$uri_segment = 2;
$total = count($t);
$config['base_url'] = site_url('search');
$config['total_rows'] = $total;
$config['per_page'] = $perPage;
$config['num_links'] = '2';
$config['uri_segment'] = $uri_segment;
$this->pagination->initialize($config);
$this->data->pagination = $this->pagination->create_links();
$this->db->like('deskripsi_produk', $cari);
$this->db->or_like('nama_produk', $cari);
$this->db->order_by('id_produk','desc');
$this->data->produk = $this->produk_m->home($config['per_page'],$this->uri->segment(2));
$this->template->set_judul('PT Bintang Sriwijaya')
->set_css('style')
->set_parsial('sidebar','sidebar_view',$this->data)
->set_parsial('topmenu','top_view',$this->data)
->render('search',$this->data);
}
View:
<h2>Hasil Pencarian</h2><br />
<?php if($produk):?>
<h3><center><?php echo $pagination;?></center></h3><br />
<?php foreach($produk as $item): ?>
<div class="produk-wrap">
<div class="image-wrap">
<div class="image-iner">
<a href="<?php echo base_url().'index.php/produk/'.$item->nama_kategori.'/'.$item->url_produk;?>">
<?php if($item->thumb == ''): ?>
<div class="no-image">
<span>Belum ada Gambar</span>
</div>
<?php else: ?>
<img src="<?php echo base_url().$item->thumb ?>" />
<?php endif; ?>
<?php if ($item->stok == 0): ?>
<div class="trans">
<span>Stok Habis</span>
</div>
<?php endif; ?>
</div>
</div>
<div class="produk-name">
<?php echo $item->nama_produk;?>
</div>
<?php if($item->harga_baru != 0): ?>
<div class="harga-lama">
Rp. <?php echo $this->cart->format_number($item->harga_jual) ?>
</div>
<div class="harga-jual">
Rp. <?php echo $this->cart->format_number($item->harga_baru) ?>
</div>
<?php else: ?>
<div class="harga-jual">
Rp. <?php echo $this->cart->format_number($item->harga_jual) ?>
</div>
<?php endif; ?>
</a>
</div>
<?php endforeach; ?>
<?php else:
echo "Data yang dicari belum ada";
endif;?>
please change these lines
$uri_segment = 2;
to
$uri_segment = 3;
and
$this->data->produk = $this->produk_m->home($config['per_page'],$this->uri->segment(2));
to
$this->data->produk = $this->produk_m->home($config['per_page'],$this->uri->segment(3));
and try beacause segment 1 is for controller, and 2 for methods in it, 3 may be the pagination element.
When building a new grouped product using already created and in stock simple products the finished grouped product not show the table listing the product titles and prices on the right side column when using my custom template.
When the custom template is turned off and the default Magento template is in use the template displays the titles and prices correctly.
There is an issue with the grouped product template code that is preventing this portion of information from being displayed but the code of /app/design/frontend/mytemplate/default/template/catalog/product/view/type/grouped.phtml is the same as the default template of Magento.
Any one know how to resolve this?
It's hard to tell, but perhaps the template file isn't used. You could check if the layout file in your template has a block that refers to grouped.phtml in the PRODUCT_TYPE_grouped node. Also check if the view.phtml makes a call like
<?php echo $this->getChildHtml('product_type_data') ?>
to refer to the block.
Compare your template files to:
app\design\frontend\base\default\template\catalog\product\view.phtml
app\design\frontend\base\default\layout\catalog.xml
to see what I mean.
<form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
<?php echo $this->getBlockHtml('formkey'); ?>
<div class="no-display">
<input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
<input type="hidden" name="related_product" id="related-products-field" value="" />
</div>
<?php
//Product collaterals
$section = array();
//Related products. $section['related'] is set only if related products (or replacement) exist
$replaceRelated = $theme->getCfg('product_page/replace_related');
if ($replaceRelated == 1) //don't replace with static block
{
if ($tmpHtml = trim($this->getChildHtml('catalog.product.related')))
$section['related'] = $tmpHtml;
//$section['related'] = trim($this->getChildHtml('catalog.product.related'));
}
elseif ($replaceRelated == 2) //if related is empty, replace with static block
{
if ($tmpHtml = trim($this->getChildHtml('catalog.product.related')))
$section['related'] = $tmpHtml;
else //related empty
if ($tmpHtml = $this->getChildHtml('block_product_replace_related'))
$section['related'] = '<div class="block_product_replace_related">'. $tmpHtml .'</div>';
}
elseif ($replaceRelated == 3) //replace with static block
{
if ($tmpHtml = $this->getChildHtml('block_product_replace_related'))
$section['related'] = '<div class="block_product_replace_related">'. $tmpHtml .'</div>';
}
//Up-sell products. $section['upsell'] is set only if up-sell products (or replacement) exist
$replaceUpsell = $theme->getCfg('product_page/replace_upsell');
if ($replaceUpsell == 1) //don't replace with static block
{
if ($tmpHtml = trim($this->getChildHtml('upsell_products')))
$section['upsell'] = $tmpHtml;
//$section['upsell'] = $this->getChildHtml('upsell_products');
}
elseif ($replaceUpsell == 2) //if upsell is empty, replace with static block
{
if ($tmpHtml = trim($this->getChildHtml('upsell_products')))
$section['upsell'] = $tmpHtml;
else //upsell empty
if ($tmpHtml = $this->getChildHtml('block_product_replace_upsell'))
$section['upsell'] = '<div class="block_product_replace_upsell">'. $tmpHtml .'</div>';
}
elseif ($replaceUpsell == 3) //replace with static block
{
if ($tmpHtml = $this->getChildHtml('block_product_replace_upsell'))
$section['upsell'] = '<div class="block_product_replace_upsell">'. $tmpHtml .'</div>';
}
//Assign related products to selected position
if (isset($section['related']))
{
$relatedPosition = $theme->getCfg('product_page/related_position');
//TODO:remove: $relatedPosition = 11;
switch ($relatedPosition)
{
case 10:
$p['secondaryCol'][0] = $section['related'];
break;
case 11:
$p['secondaryCol'][1] = $section['related'];
break;
case 20:
$p['collatSecondaryCol'] = $section['related'];
break;
}
}
//Width (in grid units) of product page sections
$imgColUnits = $theme->getCfg('product_page/image_column');
$primaryColUnits = $theme->getCfg('product_page/primary_column');
$secondaryColUnits = $theme->getCfg('product_page/secondary_column');
$container2ColUnits = $imgColUnits + $primaryColUnits;
$collatPrimaryColUnits = $imgColUnits + $primaryColUnits;
$collatSecondaryColUnits = $secondaryColUnits;
//If no secondary column
if (empty($secondaryColUnits))
{
$primaryColUnits += 12 - ($imgColUnits + $primaryColUnits);
$container2ColUnits = $imgColUnits + $primaryColUnits;
$collatPrimaryColUnits = 9;
$collatSecondaryColUnits = 3;
}
//If no related products, stretch collateral primary column
if (!isset($section['related']))
{
$container2ColUnits = 12;
$collatPrimaryColUnits = 12;
$collatSecondaryColUnits = 0;
}
elseif (!isset($p['secondaryCol']))
{
$container2ColUnits = 12;
}
//Grid classes
$imgColGridClass = 'grid12-' . $imgColUnits;
$primaryColGridClass = 'grid12-' . $primaryColUnits;
$secondaryColGridClass = 'grid12-' . $secondaryColUnits;
$container2ColGridClass = 'grid12-' . $container2ColUnits;
$collatPrimaryColGridClass = 'grid12-' . $collatPrimaryColUnits;
$collatSecondaryColGridClass = 'grid12-' . $collatSecondaryColUnits;
if (empty($secondaryColUnits))
{
$secondaryColGridClass = '';
}
?>
<div class="product-img-column <?php echo $imgColGridClass; ?>">
<?php echo $this->getChildHtml('media') ?>
<?php //Product labels
echo $this->helper('ultimo/labels')->getLabels($_product);
?>
</div>
<div class="product-shop <?php echo $primaryColGridClass; ?>">
<div class="product-name">
<h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
</div>
<?php echo $this->getReviewsSummaryHtml($_product, false, true); //reviews ?>
<?php if ($_product->getShortDescription()): ?>
<div class="short-description">
<div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
</div>
<?php endif;?>
<?php if ($theme->getCfg('product_page/sku')): ?>
<div class="sku"><span><?php echo $this->__('SKU'); ?>: </span><?php echo $_product->getSku(); ?></div>
<?php endif; ?>
<?php if ($extrahint_html = $this->getChildHtml('extrahint')): //qty increments ?>
<div class="extrahint-wrapper"><?php echo $extrahint_html; ?></div>
<?php endif; ?>
<div class="product-type-data<?php echo $productTypeClasses; ?>"><?php echo $this->getChildHtml('product_type_data'); ?></div>
<?php echo $this->getTierPriceHtml(); //tier prices ?>
<?php if (!$this->hasOptions()): //add to cart when no options ?>
<?php if($_product->isSaleable()): ?>
<div class="add-to-box">
<?php echo $this->getChildHtml('addtocart') ?>
</div>
<?php endif; ?>
<?php echo $this->getChildHtml('extra_buttons') ?>
<?php endif; ?>
<?php if ($_product->isSaleable() && $this->hasOptions()): ?>
<?php if ($container1_html = $this->getChildChildHtml('container1', '', true, true)): ?>
<div class="container1-wrapper"><?php echo $container1_html; ?></div>
<?php endif; ?>
<?php endif;?>
<?php if ($addtoLinksHtml = $this->getChildHtml('addto')): //compare, wishlist, to friend ?>
<div class="action-box clearer">
<?php echo $addtoLinksHtml; ?>
</div>
<?php endif; ?>
<?php echo $this->getChildHtml('alert_urls'); //alerts ?>
<?php echo $this->getChildHtml('other'); ?>
<?php if ($tmpHtml = $this->getChildHtml('block_product_primary_bottom')): ?>
<div class="feature-wrapper top-border block_product_primary_bottom"><?php echo $tmpHtml; ?></div>
<?php endif; ?>
<?php if ($tmpHtml = $this->getChildHtml('product_primary_bottom_placeholder')): //Placeholder for extensions ?>
<div class="feature-wrapper top-border"><?php echo $tmpHtml; ?></div>
<?php endif; ?>
</div> <!-- end: product-shop -->
<?php if ($secondaryColUnits): //(!empty($secondaryColUnits)): ?>
<div class="product-secondary-column <?php echo $secondaryColGridClass; ?> custom-sidebar-right">
<div class="inner">
<?php //Placeholder for extensions ?>
<?php if ($tmpHtml = $this->getChildHtml('product_secondary_top_placeholder')): //Placeholder for extensions ?>
<div class="margin-bottom"><?php echo $tmpHtml; ?></div>
<?php endif; ?>
<?php if (isset($p['secondaryCol'][0])): ?>
<?php echo $p['secondaryCol'][0]; ?>
<?php endif; ?>
<?php if ($tmpHtml = $this->getChildHtml('block_product_secondary_bottom')): ?>
<div class="feature-wrapper top-border block_product_secondary_bottom"><?php echo $tmpHtml; ?></div>
<?php endif; ?>
<?php if (isset($p['secondaryCol'][1])): ?>
<div class="margin-top"><?php echo $p['secondaryCol'][1]; ?></div>
<?php endif; ?>
<?php /*?>
<?php if (isset($section['related'])): ?>
<div class="margin-top"><?php echo $section['related']; ?></div>
<?php endif; ?>
<?php */?>
</div>
</div> <!-- end: product-secondary-column -->
<?php endif; ?>
<?php if ($_product->isSaleable() && $this->hasOptions()): ?>
<?php if ($container2_html = $this->getChildChildHtml('container2', '', true, true)): ?>
<div class="box-additional <?php echo $container2ColGridClass; ?>">
<div class="container2-wrapper"><?php echo $container2_html; ?></div>
</div>
<?php endif; ?>
<?php endif; ?>
</form>
I would add each two result one div class
<?php while ($fetch = $db->fetch($query)) { ?>
<?php echo $fetch['title']; ?>
<?php } ?>
Output should be like this
<div class="one">
<div class="two">
<article>Title</article>
<article>Title</article>
</div>
</div>
<div class="one">
<div class="two">
<article>Title</article>
<article>Title</article>
</div>
</div>>
<?php
$i=0;
while ($fetch = $db->fetch($query)) { ?>
<?php if ($i%2==0) { ?>
<div class="one">
<div class="two">
<?php } ?>
<article><?php echo $fetch['title']; ?></article>
<?php if ($i++%2==1) { ?>
</div>
</div>
<?php } ?>
<?php } ?>
//Also is a good idea to verify if the <div> tags are closed
<?php if ($i%2==1) { ?>
</div>
</div>
<?php } ?>
$count = 0;
while ($fetch = $db->fetch($query))
{
if ($count == 0)
echo '<div class="one"><div class="two">';
if ($count < 2)
echo '<article>'.$fetch['title'].'</article>';
if ($count == 2)
{
echo '</div></div>';
$count = 0;
}
$count++;
}