Sybille Posted August 8, 2016 Share Posted August 8, 2016 Hi, Is there a possibility to get the variable for “Group Features” available on the “product.tpl“? Kind regards Sybille 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 8, 2016 Share Posted August 8, 2016 you'll have to use an action hook to query the database because that information is not available to the templates by default. even when it is partially available, e.g in "Cloud Slider", it's being pulled via the Class method for the current chosen product group... whereas, you need all the features of all the product groups. 0 Quote Link to comment Share on other sites More sharing options...
Sybille Posted August 9, 2016 Author Share Posted August 9, 2016 Hi Brian, Thanks for your help. Do you know where I get a hook like this? I haven't got the knowledge to write something like this. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 9, 2016 Share Posted August 9, 2016 Thanks for your help. Do you know where I get a hook like this? I haven't got the knowledge to write something like this. it's not going to be a million miles away from the hook I wrote for you previously for product bundles... http://forum.whmcs.com/showthread.php?116082-separate-Page-for-Product-Categories&p=469819#post469819 you could use a similar hook to create an array containing a list of group features of all groups, and then use the template to show them under the appropriate product group - now it's not the most efficient way, but it's going to work and avoids the need for joining tables on a Tuesday morning! <?php use Illuminate\Database\Capsule\Manager as Capsule; function group_features_hook($vars) { $features = Capsule::table('tblproduct_group_features') ->select('product_group_id','feature') ->orderby('product_group_id','asc') ->orderby('order','asc') ->get(); $encodedata = json_encode($features); $decodedata = json_decode($encodedata, true); return array("groupfeatures" => $decodedata); } add_hook("ClientAreaPageCart", 1, "group_features_hook"); ?> and then in your products.tpl do something like below - remembering that you'll need to add all your <div>, css etc for layout... {foreach $productgroups as $group} {$group.name} {foreach $groupfeatures as $gpfeatures} {if $gpfeatures.product_group_id eq $group.gid} <li>{$gpfeatures.feature}</li> {/if} {/foreach} {/foreach} 0 Quote Link to comment Share on other sites More sharing options...
Sybille Posted August 11, 2016 Author Share Posted August 11, 2016 Many Thanks! It's great! 0 Quote Link to comment Share on other sites More sharing options...
Sybille Posted August 17, 2016 Author Share Posted August 17, 2016 As I just realised, my code doesn't work properly. Either the layout Looks correct (product groups are displayed and their Features if they have some), but then the value gid is empty and nothing happens, when you click on a category or to get forwarded if you click on a category works, but, the group features from one group will be shown in every category. My code: <div class="row"> {if $productgroup.name !== 'Bundles'} {foreach key=num item=productgroup from=$productgroups} <div class="col-md-3"> <div class="category"> <a href="cart.php?gid={$productgroup.gid}">{$productgroup.name}</a> {foreach $groupfeatures as $gpfeatures} {foreach $productgroups as $group} {if $gpfeatures.product_group_id eq $group.gid} <li><ul>{$gpfeatures.feature}</ul></li> {/if} {/foreach} {/foreach} </div> </div> {/foreach} {/if} </div> How it looks like: I guess for you it's a simple mistake but I'm note aware of PHP that much... Thanks in advanced for your inputs. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 17, 2016 Share Posted August 17, 2016 try this instead... <div class="row"> {foreach $productgroups as $productgroup} {if $productgroup.name neq 'Bundles'} <div class="col-md-3"> <div class="category"> <a href="cart.php?gid={$productgroup.gid}">{$productgroup.name}</a> {foreach $groupfeatures as $gpfeatures} {if $gpfeatures.product_group_id eq $productgroup.gid} <li style="margin-left:30px;">{$gpfeatures.feature}</li> {/if} {/foreach} </div> </div> {/if} {/foreach} </div> you can remove the style from the <li> tag and replace with proper css - I just added that for my testing locally. 0 Quote Link to comment Share on other sites More sharing options...
Sybille Posted August 18, 2016 Author Share Posted August 18, 2016 Hi brian! Your script works as usually perfectly. Many thanks one more! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.