Jump to content

Using code instead of hook for module?


Recommended Posts

Is it okay to use the code from the tpl in a module in the product.tpl:

 

{if isset($nbComments) && $nbComments > 0}
<div class="comments_note" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<div class="star_content clearfix">
{section name="i" start=0 loop=5 step=1}
{if $averageTotal le $smarty.section.i.index}
<div class="star"></div>
{else}
<div class="star star_on"></div>
{/if}
{/section}
<meta itemprop="worstRating" content = "0" />
<meta itemprop="ratingValue" content = "2" />
<meta itemprop="bestRating" content = "5" />
</div>
<span class="nb-comments">{l s='%s Review(s)'|sprintf:$nbComments mod='productcomments'}</span>
</div>
{/if}
 
I couldn't hook the module to a high enough hook. So I did it this way, but is it bad to do so?
 
 
  • Like 1
Link to comment
Share on other sites

Taking module's logic out and adding it to simple core is not that good as it is harder to update both module and the system later.

 

Make sure to gather and pass all information in overriden Product controller at least. Do not modify /root/classes, all the changes to core should be done in /root/override/classess or /root/override/controllers based on which you are editing.

Link to comment
Share on other sites

I forgot about the updates when I was taking the lazy-route yesterday after a long day.. :P I would love to call the overall rating-function from the product comments with something like this:

 

{hook h='displayProductListReviews' product=$product} (from this thread)

 

But it doesn't work. I also tried {hook h='displayProductComments' product=$product}

 

Do you know how I should write it?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...