I am trying to adjust some boxes on a site using smarty.
three sections populate data to the boxes all three sections share the same class. I am trying to figure out where to go to add a new classes or remove them if necessary but this is gibberish to me.
If someone can make sense of this I would appreciate it.
this file seems to be calling all the classes that makes sense to me. Now how to change them beats me.
classifieds.tpl
{if count($from)}
<div class="classifieds">
<div class="list">
{foreach from=$from item=item key=key name=tmp}
{if $item.featured}<div class="featured">{/if}
<div class="listItemDiv">
<div class="listRowDiv">
{if $item.photo}<div class="image">
<div class="photo-photo">
<div>
{html_image file="$url/photos/`$item.photo`"}
</div>
</div>
</div>{/if}
<div class="title">{$item.title}</div>
<div class="description">{$item.description}</div>
{include file="$theme_template_root/items/actions.tpl"}
</div>
</div>
{if $item.featured}</div>{/if}
{/foreach}
</div></div>
{else}
<div class="centerText">{$language.nothing_found}</div>
{/if}
This file seems to add the heading of each section but then call a function? maybe? To populate the box with the correct data?
<div class="columnSmall">
{if $tip_message}
{include file="boxes/tip.tpl" tip=$tip_message}
{/if}
{include file="boxes/greyTop/open.tpl" secheader=$language.quick_search}
<div class="quickSearchForm">{include file="forms/simple.tpl" form="classifieds_qsearch"}</div>
{include file="boxes/greyTop/close.tpl"}
{if $banners.3}
<div class="banner-side">{banner area="3"}</div>
{/if}
</div>
<div class="columnWide">
{include file="boxes/white/open.tpl"}
<h2>{$language.featured_classifieds}</h2>
{include file="lists/classifieds.tpl" from=$featured.cards}
<h2>{$language.popular_classifieds}</h2>
{include file="lists/classifieds.tpl" from=$popular.cards}
<h2>{$language.new_classifieds}</h2>
{include file="lists/classifieds.tpl" from=$new_classifieds.cards}
{include file="boxes/white/close.tpl"}
</div>
Related
I am blocking on PHP / Smarty logic.
I am looking to do from an array of products this:
<div class="products" itemscope="" itemtype="http://schema.org/ItemList">
<div class="row">
<article></article>
<article></article>
<article></article>
</div>
<div class="row">
<article></article>
<article></article>
</div>
<div class="row">
<article></article>
<article></article>
<article></article>
</div>
<div class="row">
<article></article>
<article></article>
</div>
....
</div>
I would like to have the possibility of creating a row of 3 lines then a row of 2 lines etc ...
This is what my smarty looks like:
<div class="products{if !empty($cssClass)} {$cssClass}{/if}" itemscope itemtype="http://schema.org/ItemList">
{foreach name="products" from=$products item="product" key="position"}
{include file="catalog/_partials/miniatures/product.tpl" product=$product position=$position}
{/foreach}
</div>
Do you have any idea how I could do this please?
Thanks for your help.
You probably want to control the row opening/closing and column counting in the foreach loop. You don't want that kind of logic in a template dedicated to displaying a single item.
To do this, we need a variable to determine how many columns to display - we'll toggle this from 2 to 3 for each row. We will also need a counter that we can reset at the end of each row to keep track of how many columns have been rendered within the current row. Lastly, we need to make sure we close the current row when we reach the end of the products array regardless of the column count.
<div class="products{if !empty($cssClass)} {$cssClass}{/if}" itemscope itemtype="http://schema.org/ItemList">
{* Assign a column limit *}
{assign var=colLimit value=3}
{* Create a counter for our columns *}
{counter start=0 name=colCounter assign=colCount print=false}
{foreach name="products" from=$products item="product" key="position"}
{* Open a row when the column count is zero *}
{if $colCount==0}
<div class="row">
{/if}
{* Increment the counter *}
{counter name=colCounter}
{*
Include the product template.
We can either pass the column count or $product#index/$product#iteration to the position arg,
or this may not be needed after implementing column logic in the loop
*}
{include file="catalog/_partials/miniatures/product.tpl" product=$product position=$colCount}
{* If this is the last column to display in the row or the last product in the array, close the row *}
{if $colCount==$colLimit || $product#last}
</div>
{* Toggle the column limit *}
{if $colLimit==3}
{assign var=colLimit value=2}
{else}
{assign var=colLimit value=3}
{/if}
{* Reset the counter *}
{counter start=0 name=colCounter assign=colCount print=false}
{/if}
{/foreach}
</div>
I have a Prestashop module built that enable me upload additional images for each product. By using hook, The image is displayed on the product page using the hook {hook h='displayProductAdditionalInfo' product=$product}. See the module tpl code below:
{if $images}
{foreach from=$images item=image}
{if $image.type ==1}
<img src="{$this_path}uploads/{$image.image}" width="">
{else}
<img src="{$this_path}uploads/{$image.image}" width="">
{/if}
{/foreach}
{/if}
The challenge I have is that I want to use one of this image as background image for a section my poduct.tpl file. For example, using the code below:
<div class="uk-background-cover uk-panel" style="background-image: url(...);">
{block name='page_header'}
<h1 class="h1" itemprop="name">{block name='page_title'}{$product.name}
{/block}</h1>
{/block}
</div>
I thought of using {assign var=bgpath value="{hook='displayProductAdditionalInfo'}"} and then using it {$bgpath} inside style="background-image: url({$bgpath}); but it brought errror.
I also tried below so that I can use style="background-image: url({$bgpath});:
{if $images}
{foreach from=$images item=image}
{if $image.type ==1}
{assign var=bgpath value="{$this_path}uploads/{$image.image}"
{/if}
{/foreach}
{/if}
It didn't work because this variables are not available in product.tpl but in the module.tpl
I read that we may use controller override but I am not sure if it will work or how to implement it.
You can use style tag instead of style attribute in your tpl file.
{if $images}
{foreach from=$images item=image}
{if $image.type ==1}
{assign var=bgpath value="{$this_path}uploads/{$image.image}"
{/if}
{/foreach}
<style>
div.uk-background-cover {
background-image: url({$bgpath});
}
</style>
{/if}
This code shows me all selections I have made.
How can I filter this and only show the selection of a specific Group?
For example {if $sConfigurator.groupID == 113}
{$configurator = $sArticle.sConfigurator}
{foreach $configurator as $configuratorGroup}
{foreach $configuratorGroup.values as $option}
{if $option.selected}
<div class="selected">
<div class="group">{$configuratorGroup.groupname}</div>
<div class="option">{$option.optionname}</div>
</div>
{/if}
{/foreach}
{/foreach}
I'm also not sure what you mean or what configurator your code is about...
Maybe just add the condition to the if?
{if $option.selected && $configuratorGroup.id == 113}
<div class="selected">
<div class="group">{$configuratorGroup.groupname}</div>
<div class="option">{$option.optionname}</div>
</div>
{/if}
after reinstalling cs-cart 4.2.4 we wanted to list the categories with it's subcategories in a block on the fronted.
We had this code to do this:
<div class="cat-blocks">
{foreach from=$items item="category"}
<li class="cat-blocks-item-li">
<div class="cat-blocks-item-li-wrapper">
<div class="cat-blocks-item-li-image">
<a href="{"categories.view?category_id=`$category.more.category_id`"|fn_url}" class="ty-subcategories-block__a">
{if $category.more.main_pair}
{include file="common/image.tpl"
show_detailed_link=false
images=$category.more.main_pair
no_ids=true
image_id="category_image"
image_width=235
image_height=220
class="cat-blocks-item-img"
}
{/if}
</a>
</div>
<div class="cat-blocks-item-li-name">
<h3> <a href="{"categories.view?category_id=`$category.more.category_id`"|fn_url}" class="cat-blocks-item-li-name__a">
{$category.more.category}</a></h3>
{if $category.sub}
<div class="cat-blocks-item-li-subcategories">
{foreach from=$category.sub item="sub"}
<a href="{"categories.view?category_id=`$sub.category_id`"|fn_url}" class="cat-blocks-item-li-sub__a">
{$sub.category}
</a>
{/foreach}
</div>
{/if}
</div>
</div>
</li>
{/foreach}
</div>
After reinstalling the website although the css is ok the block is totally empty and all we are see in firebug is
<a href="http://www.example.com/index.php?dispatch=categories.view&category_id=" class="ty-subcategories-block__a"`>
What am I missing.
Can anyone please help ?
Thank you
Please remove .more from all variables (category_id, category, main_pair )
before
{$category.more.category}
after
{$category.category}
Please add
{$items|fn_print_r}
before this line of code:
{foreach from=$items item="category"}
Then clear cache and check the result. You will see the content of the $items array. Please make sure that each element of this array contains the "category", "category_id" and "main_pair" values.
I have the categories & subcategories. I want to select the all parent categories & subcategories. But want to show only 3-4 subcategories under each parent category.
My Php Code
/******Start Categories********/
$ca=mysql_query('select * from category where parent_id=0');
while($ca1 = mysql_fetch_array($ca))
{
$ca2[]=$ca1;
}
$smarty->assign('ca2',$ca2);
/******End Categories********/
/******Start SubCategories********/
$sub=mysql_query('select * from category where parent_id!=0 ');
while($sub1 = mysql_fetch_array($sub))
{
$sub2[]=$sub1;
}
$smarty->assign('sub2',$sub2);
/******End SubCategories********/
And Tpl Code:
<div id="sub_ltcol">
{section name=loopc loop=$ca2}
<div id="gr_design">
<div id="gr_head">
<h4>{$ca2[loopc].category_name}</h4>
</div>
{section name=loops loop=$sub2}
{if $ca2[loopc].category_id eq $sub2[loops].parent_id}
<div id="gr_body">
<ul>
<li>
<div class="arw_icon"><img src="images/arw_icon.png"></div>
{$sub2[loops].category_name}
</li>
<div class="dotted_line"></div>
</ul>
</div>{/if}
{/section}
</div>
{/section}
</div>
I want to show the <li> tag only 3-4 times.
You can try
{section name=loops loop=$sub2}
{if $ca2[loopc].category_id eq $sub2[loops].parent_id AND $smarty.section.loops.iteration <= 4}
...
{/if}
{/section}
You can use this method:
<div id="sub_ltcol">
{section name=loopc loop=$ca2}
<div id="gr_design">
<div id="gr_head">
<h4>{$ca2[loopc].category_name}</h4>
</div>
{section name=loops loop=$sub2}
{if $ca2[loopc].category_id eq $sub2[loops].parent_id}
{if $smarty.foreach.loops.index lte 3}
<div id="gr_body">
<ul>
<li>
<div class="arw_icon"><img src="images/arw_icon.png"></div>
{$sub2[loops].category_name}
</li>
<div class="dotted_line"></div>
</ul>
</div>{/if}
{/if}
{/section}
</div>
{/section}
</div>
if you will require to show only 3 subcategories, take only this much from DB and show it.
you can use limit attribute for same
/******Start SubCategories********/
$sub=mysql_query('select * from category where parent_id!=0 limit 3');
it help to improve page loading performance also.