graisbeck Posted April 20, 2017 Share Posted April 20, 2017 I'm wanting to remove the announcement area from the homepage and replace it with a container where I can add content. I've tried searching for the solution, but haven't been able to find the answer. Any ideas, please? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 21, 2017 Share Posted April 21, 2017 you mean homepage.tpl ? if you just wanted to remove the announcements, then you could write a hook to null the array.... <?php # Remove Announcements From Homepage # Written by brian! add_hook("ClientAreaPageHome",1,function($vars){ return array("announcements" => ""); }); ...but replacing it with something else would likely require a template edit, e.g remove the announcement {if} block and replace with your content. I suppose it also depends what your content is and where it's coming from, e.g are you wanting to pull it from an external source etc. 0 Quote Link to comment Share on other sites More sharing options...
graisbeck Posted April 21, 2017 Author Share Posted April 21, 2017 you mean homepage.tpl ? if you just wanted to remove the announcements, then you could write a hook to null the array.... <?php # Remove Announcements From Homepage # Written by brian! add_hook("ClientAreaPageHome",1,function($vars){ return array("announcements" => ""); }); ...but replacing it with something else would likely require a template edit, e.g remove the announcement {if} block and replace with your content. I suppose it also depends what your content is and where it's coming from, e.g are you wanting to pull it from an external source etc. I only want to add an intro to my site using html, probably by coding it into the homepage.tpl. Unless, there is a way of using the announcement and removing the "News" title and date? I still want to keep the announcement page for updates etc. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 21, 2017 Share Posted April 21, 2017 I only want to add an intro to my site using html, probably by coding it into the homepage.tpl. Unless, there is a way of using the announcement and removing the "News" title and date? I still want to keep the announcement page for updates etc. I suppose you could use $announcements, but the template is expecting a date so may cause an error if you add something to the array that can't be converted to a date... for the sake of simplicity, it's probably going to be easier just to edit the template. 0 Quote Link to comment Share on other sites More sharing options...
graisbeck Posted April 25, 2017 Author Share Posted April 25, 2017 (edited) I suppose you could use $announcements, but the template is expecting a date so may cause an error if you add something to the array that can't be converted to a date... for the sake of simplicity, it's probably going to be easier just to edit the template. I tried adding my hosting products to the homepage.tpl using this smarty code but couldn't get it to display; {include file='./templates/orderforms/premium_comparison/products.tpl'} I also tried it without the ./ but still didn't work. Any ideas, please? Edited April 25, 2017 by graisbeck 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 25, 2017 Share Posted April 25, 2017 I tried adding my hosting products to the homepage.tpl using this smarty code but couldn't get it to display;I also tried it without the ./ but still didn't work. Any ideas, please? technically, I think it would be... {include file='orderforms/premium_comparison/products.tpl'} ... but out of the box, it wouldn't work because the template would have nothing to output. it works in the cart because cart.php has access to the $products and $productgroup array, e.g it has all the required product details for the products within the chosen group... to do that on the homepage, would require 1 of 2 solutions... though before that, i'd be tempted not to use an include to the template, but to copy the code to homepage.tpl itself as I suspect that you'd need to tweak it a little. 1. you'd need to recreate the $products array using an action hook - in cart.php, $products is potentially quite a large complex array, but for homepage you might simplify the query to just the information you really need (e.g product name, description, price etc). 2. instead of foreach loops in the template, hardcode it to show specific products, and then fill in the blanks using Data Feeds. https://forum.whmcs.com/showthread.php?120498-Retrieving-product-pricing-information-using-capsule&p=485706#post485706 I could give you a starting point with a modified version of the hook in that thread, but you'd still end up either needing to modify it and/or the template to make it work... for example, you'd need to calculate $product.pricing.minprice.cycle - the hook contains all the prices and setup fees, but you'd still need to work though them in sequence to find the first one greater than 0 and show that price... not technically difficult as it's just a series of {if} in either the hook or template, but the $products array in cart would be time-consuming to reproduce elsewhere and probably unnecessary too... also, the homepage doesn't store the current currency, so you'd end up hard coding it to use one (if you have multiple currencies)... I quickly threw this together in a v7.2b homepage using a hook - i'm using standard_cart instead, but even that needed some template edits as variables it was expecting to exist as one thing are called something else in my hook (or don't even exist as in minprice)... plus you can see the included file is expecting a sidebar to be shown on the left... to be honest, I think you might find it simpler to just hard code x number of products (perhaps taking layout from one of the products templates) and fill in the details using data feeds. 0 Quote Link to comment Share on other sites More sharing options...
graisbeck Posted April 25, 2017 Author Share Posted April 25, 2017 Thanks again Brian! for answering my post. Since my level of PHP knowledge is zero, I'll have a go at your simpler suggestion of hard coding the products then use data feeds to pull in the details. I hope your not planning a holiday soon as I may be requiring your assistance 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 26, 2017 Share Posted April 26, 2017 I hope your not planning a holiday soon as I may be requiring your assistance end of June I think... i'll give you the hotel switchboard number. 0 Quote Link to comment Share on other sites More sharing options...
graisbeck Posted April 26, 2017 Author Share Posted April 26, 2017 end of June I think... i'll give you the hotel switchboard number. Haha.. Great, thanks brian! 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.