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

Add opengraph meta template

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major Major
    • 4.8.0
    • 4.1.11
    • Plugin : Web
    • None
    • 2 - Long term
    • 2 - Normal

      https://developers.facebook.com/docs/sharing/webmasters

      This is a template suggestion to add OpenGraph meta

      <!-- + 
               | OPEN GRAPH META
               + -->
      	<xsl:template name="og-meta">	
      <!-- 		<xsl:comment> -->
      			<meta property="og:url" content="{resolver:resolve('page',ametys:pageId(),false(),true())}"/>
      			<!--
      				<xsl:element name="meta"><xsl:attribute name="property">og:title</xsl:attribute><xsl:attribute name="content"><xsl:call-template name="get-title"/></xsl:attribute></xsl:element>
      			 -->
      			<xsl:choose>								
      				<xsl:when test="/cms/page/pageContents/zone[@name = 'default']/zoneItem/html/head/meta[@name = 'DC.description']">
      	                <meta name="og: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 property="og: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 property="og:image" content="{resolver:resolveImage($illustrationType, concat($illustrationPath, '?objectId=', meta[@name = 'DC.identifier']/@content), 0, 1600,false(),true())}" />
      			</xsl:for-each>			
      <!-- 		</xsl:comment> -->		
      	</xsl:template>
      

      The idea here is to have all the images of the contents.
      You may improve the description to get the DC.description of the content and if empty to get the first x chars of the content (like in content digests).

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

              Created:
              Updated: