0

I have two themes for a single store view...(desktop and iphone)
I have created some subcategories under the root category for my store. Let's say those are :

  1. categoryone
  2. categorytwo
  3. categorythree
  4. categoryfour

Now I want to show only the first 3 categories(1, 2, 3) in the iphone theme..
By default it is showing all of them.. But I don't want to show the last one in the iphone theme only.

This is the code for category listing..

$_category  = $this->getCurrentCategory();
$_childCats = Mage::getModel('catalog/category')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addIsActiveFilter()
    ->addAttributeToSort('position', 'asc')
    ->addAttributeToFilter("parent_id", $_category->getId());  
 <section class="category-list">
    <ul class="ulPrdCatgAthome prmCatList">
        <?php foreach ($_childCats as $category) { ?>
            <li>
                <?php
                if ($category->getThumbnailUrl()) {
                    $imgPath = $category->getThumbnailUrl();
                } else {
                    $imgPath = $this->getSkinUrl("images/img_old/np_product_main.gif");
                }
                ?>
                <a href="<?php echo $category->getUrl($category); ?>" title="<?php echo $category->getName(); ?>">
                    <span class="img1"><span><img src="<?php echo $imgPath; ?>" alt="" /></span></span>
                    <span class="mobile_arrow"><?php echo truncateHtml($category->getName(), 40, '...', false, true); ?></span>
                    <span class="rhtindcator"><img src="<?php echo $this->getSkinUrl('images/custom/mobile-arrow-rht.png') ?>" width="100%" alt="" /></span>
                </a>
            </li>
<?php } ?>
    </ul>
</section>

Is there any way to separate categories as per the theme for a single store view ?
Could anyone, please suggest how to do this ?

  • Have you tried with different website instead of store view . Use different root category – Amit Bera Jun 6 '16 at 9:36
  • I have to create in the single website and in the same store view. – Kishore Patra Jun 6 '16 at 9:37
0
  • First, detect user agent where categories are being rendered (navigation menu, filters)
  • Second, skip the category if the user agent is iPhone.
  • Use this function to detect user agent:

    function isIpad()
    {
    
        $isiPad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');
    
        $is_andriod = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'Android');
    
        $iPhone = (bool)stripos($_SERVER['HTTP_USER_AGENT'], 'iPhone');
    
    
        if($isiPad){
    
            return "isiPad";
    
            }
    
        if($iPhone){
    
            return "iPhone";
    
        }
    
        if($is_andriod){
    
            return "is_andriod";
    
            }
    
        else {
    
            return false;
        }
    
    }
    
  • Usage: the function will return either 'iPhone' if useragent is iPhone. Enjoy :)

  • But how can I assign each category to a theme ? – Kishore Patra Jun 6 '16 at 11:42
  • In this way when I see in a mobile device, then for each category it will return mobile user agent and all the categories will be displayed. – Kishore Patra Jun 6 '16 at 13:16
  • Go to Catalog->Manage Categories. Then select your category and choose tab Custom Design -> Custom Design dropdown, then select whichever theme you want to display on the selected category. – Ahsan Horani Jun 7 '16 at 4:52
  • Custom Design dropdown will list all the themes available inside you app/design/frontend/default or base directory – Ahsan Horani Jun 7 '16 at 4:54
0

Go to Catalog -> Manage Categories and choose the category you want to assign different design. Then Choose tab Custom Design -> Custom Design dropdown select the template you wish to assign.

  • Then how to filter it for a specific theme ? – Kishore Patra Jun 6 '16 at 13:17
0

I have tried this with the existing option for the time concern Catalog -> Manage Categories. Then Choose tab Custom Design -> Custom Design dropdown. Please create the new category attribute for custom design theme and follow the below steps,

Rewrite the category helper block,

In config.xml,

<helpers>
   <catalog>
     <rewrite>
        <category>Namespace_Module_Helper_Category</category> 
     </rewrite>
   </catalog>
</helpers>

In app/code/local/Namespace/Module/Helper/Category.php

<?php
class Namespace_Module_Helper_Category extends Mage_Core_Helper_Abstract
{
  public function canShow($category)
    {
        if (is_int($category)) {
            $category = Mage::getModel('catalog/category')->load($category);
        }

        if (!$category->getId()) {
            return false;
        }

        if (!$category->getIsActive()) {
            return false;
        }
        if (!$category->isInRootCategoryList()) {
            return false;
        }

        $_designDatas = array('locale','layout','template','default','skin');
        $currentPackage = Mage::getDesign()->getPackageName();
        $categoryTheme = $category->getCustomDesign(); //Here use custom design attribute name
        if($categoryTheme)
        {
            $result = explode('/',$categoryTheme);
            if($result[0] ==  $currentPackage)
            {
                foreach($_designDatas as $_designData)
                {
                    $theme = Mage::getSingleton('core/design_package')->getTheme($_designData);
                    if($theme == $result[1])
                    {
                        return false;
                    }
                }
            }
        }

        return true;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.