THELIA Forum

Welcome to the THELIA support and discusssion forum

Announcement

Rejoignez la communauté sur le Discord Thelia : https://discord.gg/YgwpYEE3y3

Offline

#1 Balisage données rating

(03-01-2021 19:32:53)


Bonjour,
et bonne année à tous!

J'utilise le module comment.
Voila j'essaie de mettre en place les données structurées pour review et compagnie sur la fiche product,
voila ce que j'ai commencé à faire, dans le foreach en bas de la fiche produit :

						{$rating={meta meta="COMMENT_RATING" key="product" id="$ID"}}
                        {if $rating}
                            rating: {$rating}
                        {/if}
                        <div itemprop="aggregateRating" itemtype="http://schema.org/AggregateRating" itemscope>
                            <meta itemprop="reviewCount" content=" {count type="comment" ref="{$ref}" ref_id="{$ref_id}" id="$PRODUCT_ID" status="1" }" />
                            <meta itemprop="ratingValue" content="{$rating}" />
                            <meta itemprop="itemreviewed" content="$TITLE"/> 
                            </div>
                            <div itemprop="review" itemtype="http://schema.org/Review" itemscope>
                            <div itemprop="author" itemtype="http://schema.org/Person" itemscope>
                              <meta itemprop="name" content=""Fred Benson"{$username}" />
                                      <meta itemprop="ratingValue" content="{$rating}" />
                            
                            </div>
                            <div itemprop="reviewRating" itemtype="http://schema.org/Rating" itemscope>
                              <meta itemprop="ratingValue" content="{$rating}" />
                              <meta itemprop="bestRating" content="5" />
                            </div>

Le problème que je n'ai pas pu résoudre, c'est que reviewcount me compte tous les avis du site,
pas uniquement ceux du produit concerné.

Merci

Offline

#2 Re: Balisage données rating

(04-01-2021 09:13:36)


{$rating={meta meta="COMMENT_RATING" key="product" id="$ID"}}

Il y a quoi dans $ID ?


OpenStudio Toulouse

Offline

#3 Re: Balisage données rating

(08-01-2021 18:17:41)


En effet, $ID étant vide, je l'ai remplacé par $product_id.

Bon j'ai bien avancé, je pense être ok mais ne pas hésiter à me corriger. Si jamais le code est bon, il pourra peut être servir à quelqu'un, c'est un peu chiant les données structurées. wink

Mon fichier ajax-comments.html me semble correct.

Le seul truc que je n'arrive toujours pas à faire, c'est le comptage correct des avis dans le fichier product.html
J'ai essayé de modifier le count de plein de manières sans succès, je vais laisser mon cerveau refroidir ...

Dans product.html :

			{$rating={meta meta="COMMENT_RATING" key="product" id="$product_id"}}
						
                        {if $rating}
                        <div itemprop="aggregateRating" itemtype="http://schema.org/AggregateRating" itemscope>
                            <meta itemprop="reviewCount" content="{count type="comment" ref="{$ref}" ref_id="{$ref_id}" id="{$product_id}" status="1" }" />
                            <meta itemprop="ratingValue" content="{$rating}" />
                            <meta itemprop="itemreviewed" content="{$TITLE}"/> 
                            </div>
                            <div itemprop="review" itemtype="http://schema.org/Review" itemscope>
                            <div itemprop="author" itemtype="http://schema.org/Person" itemscope>
                              <meta itemprop="name" content="{$username}" />
                                      <meta itemprop="ratingValue" content="{$rating}" />
                            
                            </div>
                            <div itemprop="reviewRating" itemtype="http://schema.org/Rating" itemscope>
                              <meta itemprop="ratingValue" content="{$rating}" />
                              <meta itemprop="bestRating" content="5" />
                            </div>
                        {/if}

Le fichier ajax-comments.html

{$locale={lang attr="locale"}}
{$customer_id={customer attr="id"}}

{$rating2={meta meta="COMMENT_RATING" key="product" id="$ref_id"}}
<div itemprop="aggregateRating" itemtype="http://schema.org/AggregateRating" itemscope>
<meta itemprop="reviewCount" content="{count type="comment" ref="{$ref}" ref_id="{$ref_id}" id="{$PRODUCT_ID}" status="1" }" />
<meta itemprop="ratingValue" content="{$rating2}" />
<meta itemprop="itemreviewed" content="{$TITLE}"/> 
</div>

{ifloop rel="comments"}

    {function name=comment_stars empty=1}
        {$star='<span class="glyphicon glyphicon-star"></span>'}
        {$star_empty='<span class="glyphicon glyphicon-star-empty"></span>'}

        {for $foo=0 to 4}
            {if $value > $foo}
                {$star nofilter}
            {elseif $empty == 1}
                {$star_empty nofilter}
            {/if}
        {/for}
    {/function}

    {loop name="comments" type="comment" ref="{$ref}" ref_id="{$ref_id}" status="1" order="created_reverse"
        offset="{$start}" limit="{$count}" }

    {if $CUSTOMER_ID}
        {loop name="customer" type="customer" id="{$CUSTOMER_ID}" current="false" limit="1"}
            {$username="{$FIRSTNAME} {$LASTNAME|truncate:2:"...":false}"}
            {$image="http://www.gravatar.com/avatar/{$EMAIL|trim|strtolower|md5}?d=mm&s=64"}
        {/loop}
        {elseloop rel="customer"}
            {$username={intl d="comment.fo.default" l="Anonymous"} }
            {$image={image file='assets/img/avatar.png'}}
        {/elseloop}
    {else}
        {$username=$USERNAME}
        {$image="http://www.gravatar.com/avatar/{$EMAIL|trim|strtolower|md5}?d=mm&s=64"}
    {/if}

    <div id="comment-customer-{counter}" class="comment-item media">
        <div itemprop="review" itemscope itemtype="http://schema.org/Review">
             <meta itemprop="author" content="{$username}" />

            <img src="{$image}" alt="" class="pull-left" />
            <div class="media-body" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
                <meta itemprop="ratingValue" content="{$RATING}" />
    
                <p>
                    {intl d="comment.fo.default" l="By <strong>%username</strong>" username={$username}}
                    {if $RATING}<span class="text-primary">{comment_stars value=$RATING}</span>{/if}
                </p>
                <h3 class="comment-title media-heading" itemprop="name">{$TITLE}</h3>
    
                <p itemprop="reviewBody" class="comment-message">{$CONTENT}</p>
                <div class="comment-alert alert hidden"></div>
                <ul class="comment-extra list-inline">
                    <li class="comment-date">{format_date date="{$CREATED}" output="date"}</li>
                    {if $VERIFIED}
                    <li class="comment-verified comment--is-verified">{intl d="comment.fo.default" l="Verified"}</li>
                    {else}
                    <li class="comment-verified">{intl d="comment.fo.default" l="Verified"}</li>
                    {/if}
                    {if $customer_id && $customer_id == $CUSTOMER_ID}
                    <li><a href="{url path="/comment/delete/{$ID}"}" class="delete-trigger" data-id="{$ID}" data-message="{intl d="comment.fo.default" l="Are you sure ?"}">{intl d="comment.fo.default" l="Delete"}</a></li>
                    {else}
                    <li class="comment-abuse">
                        {form name="comment.abuse.form"}
                        <form id="form-add-comment-{$ID}" action="{url path="/comment/abuse"}" method="post" novalidate>
                        {form_hidden_fields form=$form}
                        {form_field form=$form field="id"}
                        <input type="hidden" name="{$name}" value="{$ID}" />
                        <a href="#" class="abuse-trigger">{intl d="comment.fo.default" l="Mark as inappropriate"}</a>
                        {/form_field}
                        </form>
                        {/form}
                    </li>
                    {/if}
                </ul>
          
            </div>
        </div>
    </div>

    {/loop}

    {if {count type="comment" ref="{$ref}" ref_id="{$ref_id}" status="1" } > $start + $count }
    <div class="comments-more">
        <a href="#" class="comments-more-link">{intl d="comment.fo.default" l="Load more comments..."}</a>
    </div>
    {/if}
{/ifloop}
{elseloop rel="comments"}
    <div class="alert alert-info">
        {if $start == 0 }
        {intl d="comment.fo.default" l="There are no comments yet"}
        {else}
        {intl d="comment.fo.default" l="No more comments"}
        {/if}
    </div>
{/elseloop}

Offline

#4 Re: Balisage données rating

(09-01-2021 22:42:07)


Bon tout le code que j'ai posté au dessus est un tissu de co....ries ...
A ne pas utiliser comme ça.

Je vais me repencher dessus calmement ...

Last edited by vz777 (09-01-2021 22:42:36)

Offline

#5 Re: Balisage données rating

(13-01-2021 14:54:46)


Bien, alors j'ai étudié le truc, j'ai l'impression qu'il faudrait faire ça :
- modifs dans le foreach en bas de product.html

Au niveau du module comment :
- modifs dans ajax-comment.html pour le balisage review et reviewrating
- modifs dans comment.html pour le balisage aggregaterating notamment à la ligne 120 :
                   

 {intl d="comment.fo.default" l="rating:"} {comment_stars value=$rating} 

Merci de m'indiquer simplement si je suis dans le juste ou si je fais fausse route !


Par contre, je rencontre un souci pour le calcul de la note moyenne,
les 5 étoiles restent noires, la fameuse ligne 120 de comment.html ne semble pas faire le job.
Est ce que ça fonctionne chez les autres ? Si oui une idée de pourquoi ça ne marche pas chez moi ?