CS Cart - Show Three Level of Categories on Catalog and Top Category Page - cs-cart

For CS-Cart Multivendor, Version 4.15.2
How can we display 6 Sub-Categories-Level-1 and 3 Sub-Categories-Level-2 on mydomain.com/catalog page, similar to https://my.indiamart.com/ or https://dir.indiamart.com/
Then how to display 5 Sub-Categories-Level-1 image and name as displayed on https://dir.indiamart.com/
How can we display All Sub-Categories-Level-1 and 5 SubCategories-Level-2 on individual Category Page like below along with Level-1 and Level-2 Images
https://dir.indiamart.com/industry/builders-hardware.html
Finally Display SubCatetory-Level-2 and All Sub-Category-Level3 like
enter link description here
I think there is some modification required in views\categories\catalog.tpl and categories\components\subcategories.tpl.
Also some HTML and css related help is highly appreciated for user friendly view on all devices.
Thanks.
categories_multicolumns.tpl
{split data=$categories size=$columns|default:"3" assign="splitted_categories"}
{strip}
{foreach from=$splitted_categories item="scats"}
{foreach from=$scats item="category"}
{if $category}
{$href=$category|fn_form_dropdown_object_link:$block.type}
{if $category.main_pair}
{include file="common/image.tpl"
show_detailed_link=false
images=$category.main_pair
no_ids=true
image_id="category_image"
image_width=$settings.Thumbnails.category_lists_thumbnail_width
image_height=$settings.Thumbnails.category_lists_thumbnail_height
class="ty-subcategories-img"
}
{/if}
{$category.category}
{/if}
{/foreach}
{/foreach}
{/strip}
{capture name="mainbox_title"}{$title}{/capture}
subcategories.tpl
{if $subcategories}
{math equation="ceil(n/c)" assign="rows" n=$subcategories|count c=$columns|default:"3"}
{split data=$subcategories size=$rows assign="splitted_subcategories"}
<ul class="subcategories clearfix">
{hook name="categories:view_subcategories"}
{foreach from=$splitted_subcategories item="ssubcateg"}
{foreach from=$ssubcateg item=category name="ssubcateg"}
{if $category}
<li class="ty-subcategories__item">
<a href="{"categories.view?category_id=`$category.category_id`"|fn_url}">
{if $category.main_pair}
{include file="common/image.tpl"
show_detailed_link=false
images=$category.main_pair
no_ids=true
image_id="category_image"
image_width=$settings.Thumbnails.category_lists_thumbnail_width
image_height=$settings.Thumbnails.category_lists_thumbnail_height
class="ty-subcategories-img"
}
{/if}
<span {live_edit name="category:category:{$category.category_id}"}>{$category.category}</span>
</a>
</li>
{/if}
{/foreach}
{/foreach}
{/hook}
</ul>
{/if}

Related

Hide display if empty data

I'd like to display info when there is info in my description.
I need to hide the whole thing when there's no info
{if !empty($product.description-short) }
<span class="label" style="text-decoration:underline">
{l s='Information:' d='Shop.Theme.Catalog'}</span>
{$product.description_short nofilter}
{/if}
Problem : Even when there are info, nothing will display
In your if statement you check for description-short and try to display description_short.
Should be:
{if !empty($product.description_short) }
<span class="label" style="text-decoration:underline">
{l s='Information:' d='Shop.Theme.Catalog'}</span>
{$product.description_short nofilter}
{/if}

Stack items when mobile with Magento 1.9 and RWD theme

I just found a lot of posts but none of them show a clear answer that works: how can I display 3 items in a row when user is desktop and stack them vertically when in mobile?
I see this is possible with no hacking for product grid (but products are shown two by row), probably I can use the something similar for the same result.
I have created this sample which is able to show 3 items when desktop and show 2 in a row and 1 in another. That's close to what I want:
<ul class="products-grid products-grid--max-4-col first last odd">
<li><img alt="" src="http://192.241.128.153/media/wysiwyg/index/pencil.jpg" />
<div class="product-info" style="min-height: 167px;">
<h2>Assine</h2>
</div>
</li>
<li><img alt="" src="http://192.241.128.153/media/wysiwyg/index/pencil.jpg" />
<div class="product-info" style="min-height: 167px;">
<h2>Vote</h2>
</div>
</li>
<li><img alt="" src="http://192.241.128.153/media/wysiwyg/index/pencil.jpg" />
<div class="product-info" style="min-height: 148px;">
<h2>Receba</h2>
</div>
</li>
</ul>
Thanks!
You can achieve this using a media query in your CSS such as..
#media only screen and (max-width: 770px) {
.products-grid li {
width: 100%;
}
}
Don't forget the product list version too.

Cs-cart category menu descriptions

I am trying to show category description in category menu. Under each category link i would like to display a short description that is added through admin when creating the category.
This is the code in the tpl that displays the category menu:
{hook name="blocks:sidebox_dropdown"}{strip}
{assign var="foreach_name" value="item_`$iid`"}
{foreach from=$items item="item" name=$foreach_name}
{hook name="blocks:sidebox_dropdown_element"}
<li class="{if $separated && !$smarty.foreach.$foreach_name.last}b-border {/if}{if $item.$childs}dir{/if}{if $item.active || $item|fn_check_is_active_menu_item:$block.type} cm-active{/if}">
{if $item.$childs}
{hook name="blocks:sidebox_dropdown_childs"}
<div class="hide-border"> </div>
<ul>
{include file="blocks/sidebox_dropdown_chiled.tpl" items=$item.$childs separated=true submenu=true iid=$item.$item_id}
</ul>
{/hook}
{/if}
{assign var="item_url" value=$item|fn_form_dropdown_object_link:$block.type}
<a{if $item_url} href="{$item_url}"{/if} {if $item.new_window}target="_blank"{/if} class="my_main_navlinks">{$item.$name}</a>
</li>
{/hook}
{/foreach}
{/strip}{/hook}
It is not a right way to change the sidebox_dropdown.tpl file, because this file is used everywhere.
The right way is to create a new block template for categories.
Open this folder: /design/themes/[YOUR_SKIN]/templates/blocks/categories/
You will find (basically) 4 files:
categories_dropdown_horizontal.tpl
categories_dropdown_vertical.tpl
categories_multicolumn_list.tpl
categories_text_links.tpl
Create a new one and add any code you need. Put the sidebox_dropdown.tpl code inside your new file too.
After that just open Admin area -> Design -> Layouts. Open properties of the categories block and select your new file.

How to show content of a a specific URL in Smarty template?

Following is my code snippet from smarty template :
<div id="entrancelist">
<h2 class="heading">My Packages</h2>
{if $user_study_test_packages.test}
<ul class="entrancelist">
{foreach from=$user_study_test_packages.test item="user_test_packages" key=key}
<li>
<h4>{$user_test_packages.pack_name|capitalize:true}</h4>
{if $user_test_packages.pack_expiry_date1 >= $current_date }
<div class="fr"><span class="expiry">Expiry : {$user_test_packages.pack_expiry_date}</span></div>
{else}
<div class="fr"><span class="expiry_dt">This package is expired on {$user_test_packages.pack_expiry_date}.</span></div>
{/if}
<p class="descp">{$user_test_packages.test_pack_desc}</p>
<div class="srtest"> </div>
</li>
{/foreach}
</ol>
{else}
You haven't bought any online test packages
{/if}
</div>
Now what I want to do is reaplace the text "You haven't bought any online test packages" with the content of different URL say www.google.com But I'm not understanding how should I achieve this. Can anyone help me out in this issue? Thanks in advance.
Why not keep PHP separate from the template?
Maybe do this in your php code,
<?php
$gcontent = file_get_contents('http://www.google.com');
$smarty->assign('gcontent',$gcontent);
?>
Then you can use {$gcontent} in your template.
You can even use query string parameters with the URL if you wanted to. More info on the php function.
http://www.w3schools.com/php/func_filesystem_file_get_contents.asp
Something like this works for me in Smarty 3, but some might not consider it very elegant:
...
{else}
{file_get_contents('http://www.google.com/')}
{/if}

Smarty Templates - Multiple Classes

Here is my template code:
<li class="{$product.name}" {if $product.name == $filter_product.name}class=active{/if}">
I want to be able to set the $product.name as the class, and when the $product.name is the active filter also add the class "active"
You can only have one class attribute, but it can contain more than one class - separate them using a space. So in your example:
<li class="{$product.name}{if $product.name == $filter_product.name} active{/if}">
Found the answer myself:
{if $product.name == $filter_product.name}
<li class="active {$product.name}">
{else}
<li class="{$product.name}">
{/if}

Resources