How to copy element's children to an other element's specific attribute with Diazo

StackOverflow https://stackoverflow.com/questions/13848577

  •  07-12-2021
  •  | 
  •  

Pregunta

How to fill properly a specific tag attribute taking the content from the original page by using Diazo in the following case?

A skeleton for new site has several meta tags like this:

<meta name="Author" content="author" />

XPATH for the author in Plone default welcome page:

//span[@class='documentAuthor']/a

XPATH for the Author meta tag in the new theme skeleton:

/html/head/meta[@name='Author']

So I would like to fill the content="author" to be like content="Admin" from the original page.

¿Fue útil?

Solución 2

The best solution I have found so far is:

<replace theme="/html/head/meta[@name='Author']">
 <xsl:variable name="auth" select="//span[@class='documentAuthor']/a" />
 <meta name="Author" content="{$auth}" />
</replace>

Otros consejos

You should not try to make this work.

This is about business things and theme should never try to do this kind of things. This depends on the page. You will have many exceptions * search page * collection * login page * sitemap

On all theses pages it doesn't make sens to have an author meta.

So you should achieve your goal by creating an addon and developing 'viewlets'.

More on viewlet: http://developer.plone.org/views/viewlets.html

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top