3

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.

user918176
  • 1,770
  • 13
  • 34

2 Answers2

1

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

toutpt
  • 5,145
  • 5
  • 38
  • 45
  • I have been thinking about this and you are incorrect. The meta tag is used for assisting search engines and other applications. If you have generic pages (ie. collections, login page), they might after customization have problems or also some content(ish) material. Without meta information pointing to for instance "mycorp.com intranet team" you couldn't query properly against that information. Or, you could leave the meta field empty - both are easy conditional rules. – user918176 Dec 19 '12 at 18:30
  • The point is: Those exceptions are to be expected and can be handled much easier than developing a viewlet. Also, having only one author is probably preferrable because the content production ui refers to the logic of having principal creator. In any case, you should provide something for every page, and the exceptions can be handled by one simple extra rule. – user918176 Dec 19 '12 at 18:32
  • I think what toutpt tries to say is, that you should not put this functionality in a theme, as it is actually business logic and has nothing to do with presentation, which is actually a fair point. – romanofski Dec 21 '12 at 02:19
  • It is not business logic. Either the page has already author information or it doesn't. Based on that you either copy the information or remove it from the resultant page. There isn't really any "business logic" involved. IF that is business logic then everything made in rules.xml is business logic, you shouldn't use it and you should just hack everything by using viewlets. – user918176 Dec 21 '12 at 13:14
0

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>
user918176
  • 1,770
  • 13
  • 34
  • IMHO this is the best solution with it's draw backs: e.g. it always picks the first match or creates the meta tag with an empty content attribute if it can't match. – romanofski Dec 18 '12 at 00:07
  • it will not work. author is related to the content, what happens for collection of content from different author, search page, login page, ... you will have author every where. – toutpt Dec 18 '12 at 12:24