Jump to content

Remove 'Announcements' from home page


graisbeck

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. :idea:

Link to comment
Share on other sites

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. :idea:

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 by graisbeck
Link to comment
Share on other sites

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...

 

DSNP9U9.png

 

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.

Link to comment
Share on other sites

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 :lol:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated