Forum

Thread tagged as: Question, Problem, Error

Attributes Type Select

I'm creating a select option for my schema product rating, so i wish to select a number from 1-5 then use this within the schema markup but output a star rating otherwise.

this is what i have so far, as part of my template:

        <div class="rating" itemprop="reviewRating" itemscope itemtype="https://schema.org/Rating">
                        <meta itemprop="worstRating" content="0"><meta itemprop="ratingValue" content="<perch:content id="ratingValue" type="select" label="Rating Value" options="1, 2, 3, 4, 5" allowempty="false" required="true" />"><meta itemprop="bestRating" content="5">


                        <perch:content id="ratingValue" type="select" options="1, 2, 3, 4, 5|<span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span>" />


                      </div>

But i get this output, its striping the opening <span>:


<div class="rating" itemprop="reviewRating" itemscope itemtype="https://schema.org/Rating"> <meta itemprop="worstRating" content="0"><meta itemprop="ratingValue" content="5"><meta itemprop="bestRating" content="5"> ☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span>" /> </div>

I guess i'm doing something wrong so any pointers be great.

Dan

Steve Forbes

Steve Forbes 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can't put HTML inside a tag attribute. I think this should work:

<perch:if id="ratingValue" match="eq" value="1">★☆☆☆☆</perch:if>
<perch:if id="ratingValue" match="eq" value="2">★★☆☆☆</perch:if>
<perch:if id="ratingValue" match="eq" value="3">★★★☆☆</perch:if>
<perch:if id="ratingValue" match="eq" value="4">★★★★☆</perch:if>
<perch:if id="ratingValue" match="eq" value="5">★★★★★</perch:if>

cheers Drew