Magento Insert Sub Category Navigation before breadcrumbs - layout

I am trying to create a sub navigation of the main navigation in Magento and insert it before the breadcrumbs module. So when you navigate to the root catalogue a sub menu of its main child categories appears as a navigation bar above the breadcrumbs but below the root navigation. In the catalogue you click the root category and all main categories under the root category appear as a horizontal navigation bar below it.
I am only able to insert it under the category title but not above the breadcrums module. I created app/design/frontend/theme/template/catalog/navigation/topsub.phtml and entered the following code:
<?php
//get all sub categories for current category
$_category = $this->getCurrentCategory();
$_category_children = $_category->getChildren();
$catIds = explode(',',$_category_children);
$categories = array();
foreach($catIds as $catId) {
$category = Mage::getModel('catalog/category')->load($catId);
$categories[$category->getName()] = array(
'url' => $category->getUrl(),
'img' => $category->getImageUrl()
);
}
?>
<ul class="subnav">
<?php if($category->getIsActive()): ?>
<?php foreach($categories as $name => $data): ?>
<li>
<a href="<?php echo $data['url']; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>">
<img src="<?php echo $data['img']; ?>" />
<div class="category-title"><?php echo $name; ?></div>
</a>
<span>/ </span>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
In my local.xml I have entered
<reference name="mtopsub">
<block type="catalog/navigation" name="topsub" as="topsub" template="catalog/navigation/topsub.phtml"/>
</reference>
In my template file I have called it
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
<head>
<?php echo $this->getChildHtml('head') ?>
</head>
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
<?php echo $this->getChildHtml('after_body_start') ?>
<div class="wrapper">
<?php echo $this->getChildHtml('global_notices') ?>
<div class="page">
<?php echo $this->getChildHtml('header') ?>
<div class="main-container col1-layout">
<div class="main">
<div class="msubnav">
<?php echo $this->getChildHtml('mtopsub') ?>
</div>
<?php echo $this->getChildHtml('breadcrumbs') ?>
<div class="col-main">
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('content') ?>
</div>
</div>
</div>
<?php echo $this->getChildHtml('footer') ?>
<?php echo $this->getChildHtml('before_body_end') ?>
</div>
</div>
<?php echo $this->getAbsoluteFooter() ?>
</body>
</html>
Now until this point nothing appears. If I create a static block and enter the following code to it:
<p>{{block type="catalog/navigation" name="catalog.navigation" template="catalog/navigation/topsub.phtml"}}</p>
The sub navigation menu appears as it should but in the wrong position. Instead of appearing above the breadcrumbs module it appears below it and below the Category page Title.
I am sure I am missing something, if anyone can point me in the right direction I would greatly appreciate it.

You're almost there :-)
As you're adding code into the layout template view, you need to modify you layout XML to add your block as a child of the root element:
layout/page.xml (or local.xml)
<reference name="root">
<block type="catalog/navigation" name="mtopsub" as="mtopsub"
template="catalog/navigation/topsub.phtml" />
</reference>
Now when you call:
<?php echo $this->getChildHtml('mtopsub') ?>
inside your layout template, the block will be available and should render correctly.

Related

How do I rewrite string query url when a form is submitted using .htacess

I have a form like this that after submitting url is like localhost/Direct-Link/product-details?details-id=173
I want it to be like: localhost/Direct-Link/product/173
<form action="product" method="get">
<input type="hidden" name="detail-id" id="detail-id" value="<?php echo $row['product_id']; ?>">
<a onclick="javascript:this.parentNode.submit();">
<img src="<?php echo $string_to_array[0]; ?>" alt="<?php echo $string_to_array[0]; ?>">
<div class="card-title mt-2">
<p id="big"><strong>
<?php echo $row['product_title']; ?>
</strong></p>
<p id="big"><b>
<?php echo 'Ksh. ' . $row['product_price']; ?>
</b></p>
<p>
<?php echo $row['product_keywords']; ?>
</p>
<?php if (!empty($row['stock_needed'])) { ?>
<p class='w-100 m-0 p-0'>
<?php echo 'Stock needed. ' . $row['stock_available']; ?>
</p>
<?php
} ?>
<p><i class="fa-solid fa-location-dot"></i>
<?php echo 'Location: ' . $row['specific_location']; ?>
</p>
</div>
</a>
</form>
I had tried RewriteRule ^product/([0-9]+)$ product-details?detail-id=$1 but never worked. Most people on the internet are showing this when they are using links with query url in their href like this example '<a href="category.php?category-id=' . $category_value . ''

Osclass Drop-down selection for city at search insted of category selection

the script is osclasss
This is the original code
?php if ( osc_count_categories() ) { ?>
<div class="cell selector">
<?php osc_categories_select('sCategory', null, __('Select a category', 'bender')) ; ?>
</div>
<div class="cell reset-padding">
<?php } else { ?>
<div class="cell">
<?php } ?>
<button class="ui-button ui-button-big js-submit"><?php _e("Search", 'bender');?></button>
</div>
How can I edit this code to make the user select a city for search not a category ?
Thank you everyone.
I found the solution =)
Thanks to https://stackoverflow.com/users/3465265/key
Just add this code
<?php $aCities = City::newInstance()->listAll(); ?>
<?php if(count($aCities) > 0 ) { ?>
<select name="sCity" id="sCity">
<option value=""><?php _e('Select a city...')?></option>
<?php foreach($aCities as $city) { ?>
<option value="<?php echo $city['s_name'] ; ?>"><?php echo $city['s_name'] ; ?></option>
<?php } ?>
</select>
<?php } ?>

How to add a custom wordpress isotope project portfolio pagination

How can I add a pagination to my isotope portfolio page?
I want each filter work with a max item of 8 and use pagination to check next 8 items.
Below is my custom Template Name: Portfolio
<?php $t =& peTheme(); ?>
<?php $title = get_the_title(); ?>
<?php $pcontent = get_the_content(); ?>
<?php $pcontent = apply_filters( 'the_content', $pcontent ); ?>
<?php $project =& $t->project; ?>
<?php list($portfolio) = $t->template->data(); ?>
<?php $content =& $t->content; ?>
<div class="container">
<div class="row">
<div class="span12">
<h1><?php echo $title; ?></h1>
</div>
</div>
<div class="row">
<div class="span12">
<nav class="portfolio-filter clearfix">
<ul>
<?php $project->filter('',"keyword"); ?>
</ul>
</nav>
</div>
<hr class="main-hr-sm">
<?php echo $pcontent; ?>
</div>
<div class="row portfolio-container">
<?php while ($content->looping()):
$meta =& $content->meta(); ?>
<div class="span3 portfolio-item <?php $project->filterClasses(); ?>">
<a href="<?php echo $t->image->resizedImgUrl($content->get_origImage(),1000,1000); ?>" class="fancybox" data-portfolio="<?php $content->slug(); ?>">
<img src="<?php echo $t->image->resizedImgUrl($content->get_origImage(),460,300); ?>" alt="<?php echo esc_html(get_the_content()); ?>">
</a>
<div class="caption">
<?php $content->content(); ?>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
Pagination isn't built into Isotope so you'd have to build it from the ground up. Here is a good tutorial on how to do that with Wordpress and Isotope v1. Keep in mind the tutorial is using Isotope v1 so you'll have to change it if you want to use Isotope v2 but the general concepts in the tutorial should still be very helpful.

Zend Paginator parameters

I'm building a site with Zend 2.3 and what I want to do is to paginate the results using
Zend Paginator. I don't get any error, in fact I can see every link correctly, however they don't work properly.
When I want to paginate the news within a category, Paginator generates the following links:
........./index/categories/1
........./index/categories/2
........./index/categories/3
............................
Instead the links I want (i.e category 2) should be like:
............/index/categories/2/1
............/index/categories/2/2
............/index/categories/2/3
This is my module.config:
'index'=>array(
'type'=>'Segment',
'options'=>array(
'route' => '/index[/[:action][/:id][/:id2]]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index'
),
),
),
I've already tried passing $cat_id from controller to URL helper ('id'=>$this->id) but it doesn't work. Only it seems to work when I hardcode the id value, for example:
First
This doesn't work:
First
So my question is, How can I do it work passing vars to Paginator?
Thanks
It's hard to create an example with such limited information but generally you'd follow this:
This would be in your controller
// This is some array of data that you've pulled from a data source
$arrayOfYourData = array();
$paginator = new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\ArrayAdapter($arrayOfYourData));
$paginator->setItemCountPerPage(25);
$paginator->setCurrentPageNumber((int) $this->params()->fromQuery('page',1));
// now return $paginator to your view by assigning it to ViewModel, etc
Then in your view you would have something like this example
<?php echo $this->paginationControl($paginator, 'Sliding', 'your-namespace/pagination_control.phtml', array('route'=>'some/route', 'routeOptions'=>array('action'=>'some-action')); ?>
and then you should have a views/your-namespace/pagination_control.phtml as such:
<?php if ($this->pageCount): ?>
<div class="paginationControl">
<?php echo $this->firstItemNumber; ?> - <?php echo $this->lastItemNumber; ?>
of <?php echo $this->totalItemCount; ?>
<!-- First page link -->
<?php if (isset($this->previous)): ?>
<a href="<?php echo $this->url($this->route, array('page' => $this->first)); ?>">
First
</a> |
<?php else: ?>
<span class="disabled">First</span> |
<?php endif; ?>
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<a href="<?php echo $this->url($this->route, array('page' => $this->previous)); ?>">
< Previous
</a> |
<?php else: ?>
<span class="disabled">< Previous</span> |
<?php endif; ?>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
<a href="<?php echo $this->url($this->route, array('page' => $this->next)); ?>">
Next >
</a> |
<?php else: ?>
<span class="disabled">Next ></span> |
<?php endif; ?>
<!-- Last page link -->
<?php if (isset($this->next)): ?>
<a href="<?php echo $this->url($this->route, array('page' => $this->last)); ?>">
Last
</a>
<?php else: ?>
<span class="disabled">Last</span>
<?php endif; ?>
</div>
<?php endif; ?>

Magento product view page quantity box always adds 1 to the cart issue

I'm developing a magento store and in the product view page/details page i have added a jquery quantity box.It works fine.But when click on the add to cart button always add "1" to the cart although i changed the quantity amount in the quantity box.I searched this issue in every place possible sites.But still no luck.And i have placed the input quantity box at the correct place.That means inside the form.I can't figure it out the issue.Hope a help.And my Magento version is 1.8.
This works with form tag... you can edit your default/theme/template/catalog/product/view/addtocart.phtml like this.
<form>
<?php $_product = $this->getProduct(); ?>
<?php $buttonTitle = $this->__('Add to Cart'); ?>
<?php if($_product->isSaleable()): ?>
<div class="add-to-cart">
<?php if(!$_product->isGrouped()): ?>
<label class="qty_label" for="qty"><?php echo $this->__('Quantity') ?>:</label>
<div class="qty_pan">
<input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
</div>
<?php endif; ?>
<button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
<?php echo $this->getChildHtml('', true, true) ?>
</div>
<?php endif; ?>
</form>
From Magento version 1.8 onwards, you need to add formkey value inside your form.
If formkey is not set in the form, then always the default qty 1 will be added to cart.
Also, if you try to update the qty from cart page, it will not get updated and will always be set to 1.
To solve this issue, add the following code inside the <form > tag:
<?php echo $this->getBlockHtml('formkey'); ?>
This code is similar to:
<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
Porduct View Page
app/design/frontend/YOUR_PACKAGE/YOUR_THEME/catalog/product/view.phtml
<form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form">
<?php echo $this->getBlockHtml('formkey'); ?>
Shopping Cart Page
app/design/frontend/YOUR_PACKAGE/YOUR_THEME/checkout/cart.phtml
<form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">
<?php echo $this->getBlockHtml('formkey'); ?>

Resources