Saturday, April 7, 2007

Wellformed link for 'Email Post'

pencil icon, that"s clickable to start editing the post

My earlier post Valid XHTML - the layout tags gave an example of a layout tag that produces invalid xhtml (not wellformed XML). Another example is the Email Post, but contrary to the archive example the Email Post one can be worked around.

The following markup fragment shows what's produced by default:

<span class='item-action'>
  <a href=''    
     title='Email Post'>
    <span class='email-post-icon'> </span>

The problem is that the & should be &amp;. The corresponding template fragment looks like:

<!-- email post links -->
<b:if cond='data:post.emailPostUrl'>
  <span class='item-action'>
    <a expr:href='data:post.emailPostUrl'
      <span class='email-post-icon'> </span>

the problem comes from the expr:href='data:post.emailPostUrl' part, but that can be replaced (rewritten) with:

expr:href='";amp;postID=" +'

with a hardcoded blogid for my blog, but to make it work on any blog the blogid should be accessed by a data tag:

expr:href='"" + data:blogid + "&amp;amp;postID=" +'

or even smarter if the virutal hosting also evaluated the other functions, then it could have been some thing like (if using custom URL):

expr:href='data:homepageUrl + "/email-post.g?postID=" +'

There's a related article in help section called How do I change the Email-This-Post icon? based on the classic template.