Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-9655

Add twitter card meta

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major Major
    • 4.9.0
    • 4.1.11
    • None
    • 1 - Middle term
    • 1 - Easy

      Doc : https://developer.twitter.com/en/docs/tweets/optimize-with-cards/guides/getting-started
      Tool : https://cards-dev.twitter.com/validator

      This is an example, you need to add in parameter on the site, the twitter:site and creator.

      <!-- +
               | Twitter card
               + -->
              <xsl:template name="twitter-meta">
      <!--            <xsl:comment> -->
                              <meta name="twitter:card" content="summary" />
                              <meta name="twitter:site" content="@xxxxxx" />
                              <meta name="twitter:creator" content="@xxxxxx" />
                               <xsl:choose>
                                  <xsl:when test="/cms/page/pageContents/zone[@name = 'default']/zoneItem/html/head/meta[@name = 'DC.description']">
                              		<meta name="twitter:description" content="{/cms/page/pageContents/zone[@name = 'default']/zoneItem/html/head/meta[@name = 'DC.description']/@content}"/>
      	                    	</xsl:when>
      			            </xsl:choose>
                              <!-- Title of the first content -->
                              <xsl:for-each select="/cms/page/pageContents/zone[@name = 'default']/zoneItem[information/type = 'CONTENT'][1]/html/head">
                              	<meta name="twitter:title" content="{meta[@name = 'DC.title']/@content}" />
                              </xsl:for-each>
                              <!-- Images of all contents -->
                              <xsl:for-each select="/cms/page/pageContents/zone[@name = 'default']/zoneItem[information/type = 'CONTENT']/html/head">
                                      <!-- illustration -->
                                      <xsl:variable name="illustrationType" select="meta[@name = 'illustration/image;type']/@content"/>
                              <xsl:variable name="illustrationPath" select="meta[@name = 'illustration/image;path']/@content"/>
                              <meta name="twitter:image" content="{resolver:resolveImage($illustrationType, concat($illustrationPath, '?objectId=', meta[@name = 'DC.identifier']/@content), 0, 144,false(),true())}" />
                              </xsl:for-each>
      
      <!--            </xsl:comment> -->
              </xsl:template>
      	
      

            Unassigned Unassigned
            fravetier Frederic Ravetier (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: