burakco Posted July 3, 2012 Share Posted July 3, 2012 hi everybody, i need to get only one attribute group on product page. i used this code but it doesnt working. <div id="color_picker"> <p>{l s='Numara Seçin:' js=1}</p> <div class="clear"></div> <ul id="color_to_pick_list"> {foreach from=$group.attributes key=id_attribute item=group_attribute} <li><a id="{$id_attribute|intval}" class="color_pick" style="background: #FFF;" onclick="javascript:findCombination();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if};" title="{$id_attribute|intval}">{$id_attribute|intval}</a></li> {/foreach} </ul> <div class="clear"></div> </div> i need to get one attribute group called "Numara" and it's ID is 4. i want to list this group's attributes Link to comment Share on other sites More sharing options...
olea Posted July 3, 2012 Share Posted July 3, 2012 Here it is : http://www.smarty.net/docs/en/language.function.foreach.tpl Link to comment Share on other sites More sharing options...
burakco Posted July 3, 2012 Author Share Posted July 3, 2012 thanks olea, i fixed my problem with this code: <div id="color_picker"> <p>{l s='Numara Seçin:' js=1}</p> <div class="clear"></div> <ul id="color_to_pick_list"> {foreach from=$groups key=id_attribute_group item=group} {if $id_attribute_group==4} {foreach from=$group.attributes key=id_attribute item=group_attribute} <li><a id="{$id_attribute|intval}" class="color_pick" style="background: #FFF;" onclick="javascript:findCombination();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if};" title="{$group_attribute|escape:'htmlall':'UTF-8'}">{$group_attribute|escape:'htmlall':'UTF-8'}</a></li> {/foreach} {/if} {/foreach} </ul> <div class="clear"></div> </div> but now, onclick function doesnt work. could you help me for this? Link to comment Share on other sites More sharing options...
burakco Posted July 4, 2012 Author Share Posted July 4, 2012 (edited) i used this code and it is working : <div id="color_picker"> {foreach from=$groups key=id_attribute_group item=group} {if $group.attributes|@count} <p>{$group.name|escape:'htmlall':'UTF-8'} :</p> {assign var="groupName" value="group_$id_attribute_group"} <div class="clear"></div> <ul id="color_to_pick_list"> {foreach from=$group.attributes key=id_attribute item=group_attribute} <li> <label><div class="color_pick" {if file_exists($col_img_dir|cat:$id_attribute|cat:'.jpg')}style="background:url({$img_col_dir}{$id_attribute}.jpg"{/if} ><input type="radio" name="{$groupName}" value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} checked="checked"{/if} id="group_{$id_attribute_group|intval}" onchange="javascript:findCombination();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if};" title="{$group_attribute|escape:'htmlall':'UTF-8'}" style="display:none;" />{if !file_exists($col_img_dir|cat:$id_attribute|cat:'.jpg')}{$group_attribute|escape:'htmlall':'UTF-8'}{/if}</div></label> </li> {/foreach} </ul> <div class="clear"></div> {/if} {/foreach} </div> now i need to show only available sizes for colors, anybody can help me for this? Edited July 4, 2012 by burakco (see edit history) Link to comment Share on other sites More sharing options...
threeopus3 Posted May 10, 2013 Share Posted May 10, 2013 Does anybody know what the equivalent {for each} syntax is for placement in a .php file? I'm trying to update a module that calls and displays info from within the .php file, not the smarty .tpl file, and I am trying to call and display feature information there. Is it possible to use {for each} in php? Link to comment Share on other sites More sharing options...
olea Posted May 10, 2013 Share Posted May 10, 2013 On 5/10/2013 at 2:58 PM, threeopus3 said: Does anybody know what the equivalent {for each} syntax is for placement in a .php file? I'm trying to update a module that calls and displays info from within the .php file, not the smarty .tpl file, and I am trying to call and display feature information there. Is it possible to use {for each} in php? See http://fr2.php.net/manual/fr/control-structures.foreach.php Link to comment Share on other sites More sharing options...
NemoPS Posted May 10, 2013 Share Posted May 10, 2013 On 5/10/2013 at 2:58 PM, threeopus3 said: Does anybody know what the equivalent {for each} syntax is for placement in a .php file? I'm trying to update a module that calls and displays info from within the .php file, not the smarty .tpl file, and I am trying to call and display feature information there. Is it possible to use {for each} in php? Yes indeed, it's foreach ($items as $key => $value) { // the content goes here } Have a look at net.tutsplus.com, they have some wonderrful base PHP tuts! Link to comment Share on other sites More sharing options...
threeopus3 Posted May 10, 2013 Share Posted May 10, 2013 Thanks for the replies, people. FYI, for the sake of any newbies like me who might be reading this, I was also able to get the info that I needed lieke this: $features=$products[$i]['features']; foreach ($features as $value) { if($value['name']=="Name of Feature"){ $nameOfMyFeature = $value['value']; } Link to comment Share on other sites More sharing options...
Recommended Posts