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

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

  •  07-12-2021
  •  | 
  •  

문제

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.

도움이 되었습니까?

해결책 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>

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top