Magento sidebar parent curent category and subcategory permanent - magento

I want to add to sidebar the CURENT category and subcategory of the products, but to be the same even if i am entering a subcategory. Right now i have this script for left menu ( sidebar )
<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div class="block block-menu-navleft">
<div class="block-title">
<strong><span><?php echo $this->__('Category') ?></span></strong>
</div>
<div class="block-content">
<ul id="nav1" class="menu-left">
<?php echo $_menu ?>
</ul>
</div>
</div>
<?php endif ?>
<script type="text/javascript">
var lis=$$('#nav1 li.parent');
lis.each(function(li) {
var dt = new Element('dt');
var dd = new Element('dd');
var a = li.down(0);
var ul = li.down(2);
dt.insert(a);
dd.insert(ul);
li.insert(dt,{position:top});
li.insert(dd);
});
jQuery('#nav1 li.parent dd ul ').hide();
jQuery('#nav1 dt a').click(function() {
jQuery('.td_active').removeClass('td_active');
var string = jQuery(this).parent().parent().parent().parent().parent().attr('class');
if(string.indexOf('parent')!=-1)
{
jQuery(this).parent().parent().parent().parent().parent().addClass('td_active');
jQuery(this).parent().parent().parent().css("display","block");
jQuery(this).parent().parent().find('ul').slideUp('slow');
}
else
{
jQuery('#nav1 li.parent dd ul:visible').slideUp('slow');
}
jQuery(this).parent().parent().addClass('td_active').next().slideDown('fast');
if(jQuery(this).parent().parent().find('ul').css('display')=='block')
{
jQuery(this).parent().parent().removeClass('td_active');
}
jQuery(this).parent().parent().children().children(':first-child').css("display","block");
return false;
});
</script>
This script works fine but it shows me ALL FATHER CATEGORIES and SUBCATEGORIES. I want to show me just the CURENT CATEGORY AND SUBCATEGORY.
!example image1

Use this :
$menu = $this->drawItem(Mage::registry('current_category'),Mage::registry('current_category')->getLevel());
instead of
$_menu = $this->renderCategoriesMenuHtml(0,'level-top')
To handle all case you should consider do something like :
$menu = (isset(Mage::registry('current_category'))?$this->drawItem(Mage::registry('current_category'),Mage::registry('current_category')->getLevel()):$this->renderCategoriesMenuHtml(0,'level-top');

Related

Display message is Not working for out of stock products

please visit link1 , you can see there is option to find shipping is available or not for particular zip code : image1
here shipping charges are working for instock products but not for out-of -stock products.
Form.phtml
app/design/frontend/default/default/template/webdevlopers/productpageshipping/estimate/form.phtml
<?php if ($this->isFieldVisible('postcode')): ?>
<li class="item">
<label for="search"<?php if ($this->isFieldRequired('postcode')):?> class="required" <?php endif;?>>
<?php if ($this->isFieldRequired('postcode')):?>
<em>*</em>
<?php endif;?>
<?php echo Mage::helper('webdevlopers_productpageshipping')->__('') ?>
</label>
<div class="search">
<input placeholder="Enter your PIN Code"
class="input-text validate-postcode<?php if ($this->isFieldRequired('postcode')):?> required-entry<?php endif;?>"
type="text" id="estimate_postcode"
name="estimate[postcode]"
value="<?php echo $this->htmlEscape($this->getFieldValue('postcode')) ?>"
onkeydown="if (event.keyCode == 13) { return false;}" />
</div>
</li>
<?php endif; ?>
Script
<script type="text/javascript">
var $ = jQuery.noConflict();
(function($) {
$(document).ready(function(){
$('#estimate_postcode').keydown(function(e){
var items = $$(['.shipping-estimation-form input',
'.shipping-estimation-form select',
'#product_addtocart_form input',
'#product_addtocart_form select']);
var estimationUrl = '<?php echo $this->jsQuoteEscape($this->getEstimateUrl());?>';
var parameters = Form.serializeElements(items, true);
console.log("zipcode onkeypress worked");
if (!e) e = window.event;
var keyCode = e.keyCode || e.which;
if (keyCode == '13'){
//disable default enter action
e.preventDefault();
console.log("Enter button was pressed");
$('#shipping-estimate-loading-message').show();
$('#shipping-estimate-results').hide();
new Ajax.Updater('shipping-estimate-results', estimationUrl, {
parameters: parameters,
onComplete: function() {
console.log("ajax updater worked");
$('#shipping-estimate-loading-message').hide();
$('#shipping-estimate-results').show();
$('#unique_id').hide();
//$('unique_id').hide();
$('estimate_postcode').val()
}
});
};
});
});
}) ( jQuery );
function estimateProductShipping()
{
var estimationUrl = '<?php echo $this->jsQuoteEscape($this->getEstimateUrl());?>';
var items = $$(['.shipping-estimation-form input',
'.shipping-estimation-form select',
'#product_addtocart_form input',
'#product_addtocart_form select']);
var validationResult = true;
// Check the valid input
if (!items.map(Validation.validate).all()) {
return;
}
var parameters = Form.serializeElements(items, true);
$('shipping-estimate-loading-message').show();
$('shipping-estimate-results').hide();
new Ajax.Updater('shipping-estimate-results', estimationUrl, {
parameters: parameters,
onComplete: function() {
console.log("ajax updater worked");
$('shipping-estimate-loading-message').hide();
$('shipping-estimate-results').show();
// $('#unique_id').hide();
$('unique_id').hide();
$('estimate_postcode').val()
}
});
}
//]]>
</script>
complete code of the file : https://gist.github.com/anonymous/ebe868508b2c21e9c032
result.phtml
app/design/frontend/default/default/template/webdevlopers/productpageshipping/estimate/result.phtml
<div class="block block-shipping-estimate block-shipping-results">
<div class="block-title">
<strong><span>
<?php echo Mage::helper('webdevlopers_productpageshipping')->getShiptitle(); ?>
</span></strong>
</div>
<div class="block-content">
<?php if ($this->getResult()):?>
<dl>
<?php foreach ($this->getResult() as $code => $_rates): ?>
<dt><?php echo $this->getCarrierName($code) ?></dt>
<dd>
<ul>
<?php foreach ($_rates as $_rate): ?>
<li<?php if ($_rate->getErrorMessage()) echo ' class="error-msg"';?>>
<?php if ($_rate->getErrorMessage()): ?>
<?php echo $_rate->getErrorMessage() ?>
<?php else: ?>
<?php
// echo $_rate->getMethodTitle()
?>
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
<!-- sat -->
<p>
<?php echo "Shipping is available";?>
</p>
<p class="vship1">
<?php echo "Selling Price + " . str_replace('.00','',$_excl) . " Delivery ";?>
</p>
<!-- sat -->
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
(<?php echo Mage::helper('webdevlopers_productpageshipping')->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
<?php endif; ?>
<?php endif ?>
</li>
<?php endforeach; ?>
</ul>
</dd>
<?php endforeach; ?>
</dl>
<?php else: ?>
<?php //echo $this->getMessagesBlock()->toHtml(); ?>
<?php echo Mage::helper('webdevlopers_productpageshipping')->getResult(); ?>
<?php endif;?>
</div>
</div>
app/code/community/webdevolopers/productpageshiping/Block/estimate/ Result.php
<?php
class WebDevlopers_ProductPageShipping_Block_Estimate_Result extends WebDevlopers_ProductPageShipping_Block_Estimate_Abstract
{
public function getResult()
{
return $this->getEstimate()->getResult();
}
public function hasResult()
{
return $this->getResult() !== null;
}
public function getCarrierName($code)
{
$carrier = Mage::getSingleton('shipping/config')->getCarrierInstance($code);
if ($carrier) {
return $carrier->getConfigData('title');
}
return null;
}
public function getShippingPrice($price, $flag)
{
return $this->formatPrice(
$this->helper('tax')->getShippingPrice(
$price,
$flag,
$this->getEstimate()
->getQuote()
->getShippingAddress()
)
);
}
public function formatPrice($price)
{
return $this->getEstimate()
->getQuote()
->getStore()
->convertPrice($price, true);
}
}
changing the settings in System > Config > Inventory
Easiest way to do this is select all products you want to allow to be backordered, then select Update attributes from the actions drop down and click submit. then shipping problem will not be problem.

session destrioyed on add to cart in laravel

I am using laravel5. I need to add the product into cart. when i add a new product it is add into cart item as 1. but when refresh the page or move to next page my cart item count destroyed. Here i attach my coding. Please help me what is my mistake. i am new to laravel
Controller:
public function cart($request)
{
$quick=Mainpage::get_quick(5);
$logo = Mainpage::get_image();
$result_cart = Mainpage::get_add_to_cart_details();
$session_result = '';
// if(Session::get('cus_id'))
// {
// $navbar = View::make('layout.header');
// }
// else
// {
// $navbar = View::make('layout.header');
// }
return view('cart', ['logo' => $logo, 'quick' =>$quick,'session_result'=>$session_result,'result_cart'=>$result_cart]);
}
Model:
public static function get_add_to_cart_details()
{
$get_pro_dea = "";
if(isset($_SESSION['cart'])){
$max=count($_SESSION['cart']);
for($i=0;$i<$max;$i++){
$pid=$_SESSION['cart'][$i]['product_id'];
//$pname="Have to get";
$get_pro_dea[$pid] = DB::table('le_product')->where('product_id',$pid)->get();
}
}
else
{
$get_pro_dea[0] = array();
}
return $get_pro_dea;
}
View:(header.blade.php):
<div class="col-sm-4" style="margin-top:17px">
<div class="cart box_1 pull-right">
<a href="<?php echo url('cart'); ?>">
<?php if(isset($_SESSION['cart']))
{
$item_count_header1 = count($_SESSION['cart']);
}
else {
$item_count_header1 = 0;
}
$item_count_header = $item_count_header1;
if($item_count_header != 0)
{
?>
<img src='<?php echo url(); ?>/assets/images/shopping-cart.png' alt=''><span style='color:black;
'> ( <?php echo $item_count_header; ?> Items) </span>
<?php
}
else
{ ?>
<img src="<?php echo url(); ?>/assets/images/shopping-cart.png" alt=""><span style="color:black;"> (card empty)</span>
<?php }
?>
</strong>
</a>
</div>
</div>
</div>
<?php } ?>
</div>

i'm using the loop + jQuery below to load in the next set of pages but it's showing only 2 pages but i have 20 post and i'm showing 4 post perpage

<?php $new_query = new WP_Query();
$new_query->query('showposts=4'.'&paged='.$paged);?>
<?php while ($new_query->have_posts()) : $new_query->the_post(); ?>
<li>
<?php the_title();?>
</li>
<?php endwhile; ?>
<div id="pagination">
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
<div class="alignleft">
<?php next_posts_link('« Older Entries') ?>
</div>
<div class="alignright">
<?php previous_posts_link('Newer Entries »') ?>
</div>
<?php
} ?>
</div>
it's working but only showing 2 pages but i have 20 posts and i'm showing 4 posts per page
<script>
jQuery(function($) {
$('ul.govtjobs').on('click', '#pagination a', function(e){
e.preventDefault();
var link = $(this).attr('href');
$('ul.govtjobs').fadeOut(100, function(){
$(this).load(link + ' ul.govtjobs', function() {
$(this).fadeIn(100);
});
});
});
});
</script>
and i'm using this script for go to next page
Try this:
<?php
$args = array(
'posts_per_page' => 4,
'paged' => $paged,
);
$new_query = new WP_Query($args);
It is recommended to use posts_per_page.

Display Dynamic SKU on configurable product view Magento

I have this script to show the dynamic sku on select option, but i cannot get working.
Is loading the correct sku, but on select nothing happen.
This code get list of sku on Javascript and update a div on select option for product on configurable product view.
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl>
<?php foreach($_attributes as $_attribute): ?>
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select" onchange="return changeSku(this);">
<option><?php echo $this->__('Choose an Option...') ?></option>
</select>
</div>
</dd>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
</script>
<?php endif;?>
<?php
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product);
$col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
echo '<script type="text/javascript">';
echo '
document.observe("dom:loaded", function() {
$("sku-container").update("<strong>Product Id: </strong> Select an option to display Product Id");
});
';
echo ' function changeSku(sel){';
$itemId = array();
foreach($col as $simple_product){
$itemId[] = array($simple_product->getSelectLabel() => $simple_product->getSku());
}
//echo "<pre>";
//print_r($itemId);
//echo "</pre>";
foreach($itemId as $val){
foreach($val as $k => $v){
echo "\n".'if(sel.options[sel.selectedIndex].value == "'.$k.'"){'."\n";
echo '$("sku-container").update("<strong>Product Id: </strong>'.$v.'");'. "\n";
echo '}';
}
}
echo "\n".'if(sel.options[sel.selectedIndex].value == ""){'."\n";
echo '$("sku-container").update("<strong>Product Id: </strong> Select an option to display Product Id");'. "\n";
echo '}';
echo "}";
echo "\n</script>";
?>
I appreciate any help.
Thanks
The script is almost correct except for $simple_product->getSelectLabel() being a wrong key. No such method/property exists in a simple product model. In order to make the script work, this key should be replaced with a right one - a Product Id. Utilizing product id, it is possible to find the sku of the product being selected.
So, first of all you need to reorganize itemId array to make it a "productId => productSku" map:
$productMap = array();
foreach($col as $simpleProduct){
$productMap[$simpleProduct->getId()] = $simpleProduct->getSku();
}
Then you need to change the "onchange" function call to pass Configurable's attribute id to the changeSku() function. Thus the underlying logic is able to search appropriate simple product's attributes.
onchange="return changeSku(<?php echo $_attribute->getAttributeId() ?>, this);">
And after that you need utilize configurable's config in order to map selected simple product's attribute id to the product id selected:
function changeSku(confAttributeId, sel) {
var productMap = <?php echo Mage::helper('core')->jsonEncode($productMap);?>;
var selectedAttributeId = sel.options[sel.selectedIndex].value;
if (selectedAttributeId) {
var options = spConfig.config.attributes[confAttributeId].options;
var productId = options.find(function (option) {return option.id == selectedAttributeId}).products[0]
$("sku-container").update("<strong>Product Id: </strong>" + productMap[productId]);
} else {
$("sku-container").update("<strong>Product Id: </strong> Select an option to display Product Id");
}
}
For your reference, below is the summary of how the whole template looks like (I've beautified it a little):
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl>
<?php foreach($_attributes as $_attribute): ?>
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select"
onchange="return changeSku(<?php echo $_attribute->getAttributeId() ?>, this);">
<option><?php echo $this->__('Choose an Option...') ?></option>
</select>
</div>
</dd>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
</script>
<?php endif;?>
<div id="sku-container"></div>
<?php
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product);
$col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
$productMap = array();
foreach($col as $simpleProduct){
$productMap[$simpleProduct->getId()] = $simpleProduct->getSku();
}
?>
<script type="text/javascript">
document.observe("dom:loaded", function() {
$("sku-container").update("<strong>Product Id: </strong> Select an option to display Product Id");
});
function changeSku(confAttributeId, sel) {
var productMap = <?php echo Mage::helper('core')->jsonEncode($productMap);?>;
var selectedAttributeId = sel.options[sel.selectedIndex].value;
if (selectedAttributeId) {
var options = spConfig.config.attributes[confAttributeId].options;
var productId = options.find(function (option) {return option.id == selectedAttributeId}).products[0]
$("sku-container").update("<strong>Product Id: </strong>" + productMap[productId]);
} else {
$("sku-container").update("<strong>Product Id: </strong> Select an option to display Product Id");
}
}
</script>
This will do the task you originally needed.
Also note the following
Your approach won't work for a configurable product with two or more configurable attributes. For that product a final simple product is not known until a user selects values for all the select inputs. So an approach should be changed to check all the selects before outputting SKU.
The code doesn't consider a case, when user edits product configuration, rather than specifying configuration for a new product. You can go to editing mode from the Shopping Cart clicking the Edit link. In such a case all the select inputs will be pre-filled with previously chosen values. But the text will say "Select an option to display Product Id". The script might also produce other Javascript errors in Edit mode. The code should be slightly modified in order to support Edit mode as well.
The template is overfilled with logic. A Magento template should have only simple prints and foreach-iterations. All the methods like $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions() are better to be moved to block. This reduces code complexity.
Hope it helps.

Codeigniter multiple views for nested tab setup

I am struggling with nested tab markup generated via Codeigniter model calls and would welcome any insightful comments. The difficulty is that the markup generated has unwanted repetitions of blocks of project data. The use of multiple views which are not straightforwardly inter-connected is probably where the problems lie.
Here's the controller:
function projects() {
$this->load->model('msm_projects');
$data['cats']=$this->msm_projects->catid()->result_array();
$this->load->view('vup_projects', $data);
foreach ( $data['cats'] as $item )
{
$data2['projects']=$this->msm_projects->catproj($item['catid'])->result_array();
$this->load->view('vup_projects2', $data2);
}
}
The model:
function catid() {
return $this->db->query("SELECT DISTINCT catid, cat FROM category INNER JOIN projects ON catid = projcat WHERE projpub=1 ORDER BY catid ASC");
}
function catproj($catid) {
return $this->db->query("SELECT catid, cat, projcat, projid, projtit FROM projects INNER JOIN category ON projcat = catid WHERE projcat = $catid AND projpub=1 ORDER BY catid ASC");
}
Here are the views which are in two parts. I suspect this is where it's all going wrong. There's an imperfect join between the two views which I am having a hard time thinking about.
view 1 called 'vup_projects'
<div id="wrapper">
<div class="yui3-g">
<div class="yui3-u-1"><div id="topbloc"><img src="http://localhost/getop/base-images/topbloc.gif" width="800" height="50" align="middle"></div></div>
<div class="yui3-u-1">
<div id="navbloc">
<div id="linx">
<ul >
<li id="about"><?php echo anchor('cu_tya/about', 'about'); ?></li>
<li id="ourwork"><?php echo anchor('cu_projects/projects', 'projects'); ?></li>
<li id="contact"><?php echo anchor('cu_tya/contact', 'contact'); ?></li>
<li id="member"><?php echo anchor('cu_sites/pager', 'your page'); ?></li>
</ul>
</div>
</div>
</div>
<div class="yui3-u-1">
<div id="container">
<ul>
<?php
foreach ( $cats as $item ) // top tabs
{
echo '<li><a href=#fragment-'.$item['catid'].'><span>'.$item['cat'].'</span></a></li>';
}
?>
</ul>
And the second view vup_projects2
<?php foreach ( $cats as $item ) { ?> <!-- main divs -->
<div id="fragment-<?php echo $item['catid'];?>">
<ul>
<?php foreach ( $projects as $project )
{ ?>
<li>
<span><?php echo $project['projtit'];?></span></li>
<?php } ?>
</ul>
<?php foreach ( $projects as $project )
{ ?>
<div id="fragment-<?php echo $project['projid'];?>a" >
<?php echo $project['projtit'].' hooray';?>
</div>
<?php } ?>
</div>
<?php } ?>
</div> <!-- container -->
</div> <!-- YUI-UNIT-1-->
</div> <!-- YUI-GRID -->
</div> <!-- wrapper -->
foreach ( $data['cats'] as $item )
{
$data2['projects']=$this->msm_projects->catproj($item['catid'])->result_array();
$this->load->view('vup_projects2', $data2);
}
is your problem, you're looping the views for every item in $data['cats']... you're also doing a query for every $item. You should do one query and then loop through the results accordingly. But to fix your problem, try this:
foreach ( $data['cats'] as $item )
{
$data2['projects'][$item['catid']] = $this->msm_projects->catproj($item['catid'])
->result_array();
}
$this->load->view('vup_projects2', $data2);
then change your second view to
<?php foreach ( $cats as $item ) { ?> <!-- main divs -->
<div id="fragment-<?php echo $item['catid'];?>">
<ul>
<?php foreach ( $projects[$item['catid']] as $project )
{ ?>
<li>
<span><?php echo $project['projtit'];?></span></li>
<?php } ?>
</ul>
<?php foreach ( $projects[$item['cat_id']] as $project )
{ ?>
<div id="fragment-<?php echo $project['projid'];?>a" >
<?php echo $project['projtit'].' hooray';?>
</div>
<?php } ?>
</div> <!-- container -->
</div> <!-- YUI-UNIT-1-->
</div> <!-- YUI-GRID -->
</div> <!-- wrapper -->
So I took a closer look at what your trying to accomplish and I think I consolidated it into a single query and a single view. Maybe this will help
Controller:
class Projects extends CI_Controller {
function __construct(){
parent::__construct();
}
function projects() {
$cats = array(); // Unique cateogires
$projects = array(); // Projects that will go underneath
$this->load->model('msm_projects');
$query = $this->msm_projects->get_all();
// Make sure there are results
if ($query !== FALSE)
{
// Loop through once to find distinct categories for tabs
foreach ($query as $k => $v)
{
if ( ! array_key_exists($v['catid'], $tabs))
{
$tabs[$v['catid']] = $v['cat'];
}
}
// Loop through all of the results and group the items
// into arrays by their categories
foreach ($query as $k => $v)
{
$projects[$v['catid']][] = $v;
}
$data = array(
'cats' => $cats,
'projects' => $projects
);
$this->load->view('main', $data);
}
else
{
echo 'No results';
}
}
}
Model:
class Msm_projects extends CI_Model {
/* Returns everything you need */
function get_all()
{
$q = $this->db->select('c.catid, c.cat, p.projcat, p.projid, p.projtit')
->join('projects as p', 'c.catid = p.projcat', 'INNER')
->where('projpub = 1')
->order_by('c.catid')
->get('category as c');
if ($q->num_rows > 0)
{
return $q->result_array();
}
else
{
return FALSE;
}
}
}
View:
<div id="wrapper">
<div class="yui3-g">
<div class="yui3-u-1">
<div id="topbloc">
<img src="<?=base_url() /* Good not to hardcode url's if you can avoid it */;?>getop/base-images/topbloc.gif" width="800" height="50" align="middle" />
</div>
</div>
<div class="yui3-u-1">
<div id="navbloc">
<div id="linx">
<ul >
<li id="about"><?php echo anchor('cu_tya/about', 'about'); ?></li>
<li id="ourwork"><?php echo anchor('cu_projects/projects', 'projects'); ?></li>
<li id="contact"><?php echo anchor('cu_tya/contact', 'contact'); ?></li>
<li id="member"><?php echo anchor('cu_sites/pager', 'your page'); ?></li>
</ul>
</div>
</div>
</div>
<div class="yui3-u-1">
<div id="container">
<ul>
<?php foreach($cats as $id => $cat){ ?>
<li><span><?=$cat['cat'];?></span></li>
<?php } ?>
</ul>
<?php foreach ($cats as $id => $cat ) { ?> <!-- main divs -->
<div id="fragment-<?php echo $id;?>">
<ul>
<?php foreach($projects[$id] as $project){ ?>
<li>
<span><?php echo $project['projtit'];?></span>
</li>
<?php } ?>
</ul>
<?php foreach ($projects[$id] as $project) { ?>
<div id="fragment-<?php echo $project['projid'];?>a" >
<?php echo $project['projtit'].' hooray';?>
</div>
<?php } ?>
</div>
<?php } ?>
There are a lot of tricks to learn about optimizing the MVC process in CI, a lot of which I wish I learned earlier. Hopefully this helps some, let me know if you have questions. As for the pagination, try doing something similar to what i did in the foreach loop to get the main categories, and then subsequently pulling the pages out of the result array which are == to the category you're looking for.

Resources