enonic / cms-stk

11 stars 4 forks source link

meta keywords convert newlines to commas #9

Open enonicnorway opened 12 years ago

enonicnorway commented 12 years ago

In the head.xsl file, it outputs the keywords exactly as written. But some people put each keyword on a new line (in the page properties tab) instead of making a comma separated list. This causes the output to look like this myeloid leukaemia leukemi instead of myeloid leukaemia,leukemi,

translate($stk:head.meta-keywords, ' ', ',')

Line 61

  <xsl:if test="normalize-space($keywords) or normalize-space($stk:head.meta-keywords)">
     <meta name="keywords" content="{if (normalize-space($keywords)) then $keywords else translate($stk:head.meta-keywords, '&#xD;&#xA;', ',')}"/>
  </xsl:if>
Michael-Lazell commented 12 years ago

We should also account for new-lines in the description that will also break validation. Here I just added normalize-space() to the description output and added translate() for the keywords to turn newlines into commas.

  <xsl:if test="normalize-space($description) or normalize-space($stk:head.meta-description)">
     <meta name="description" content="{if (normalize-space($description)) then normalize-space($description) else normalize-space($stk:head.meta-description)}"/>
  </xsl:if>

  <xsl:if test="normalize-space($keywords) or normalize-space($stk:head.meta-keywords)">
     <meta name="keywords" content="{if (normalize-space($keywords)) then translate($keywords, '&#xD;&#xA;', ',') else translate($stk:head.meta-keywords, '&#xD;&#xA;', ',')}"/>
  </xsl:if>