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='http://www2.blogger.com/email-post.g?blogID=591744930960839717&postID=1676954542643567733'    
     title='Email Post'>
    <span class='email-post-icon'> </span>
  <</a>
</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'
       expr:title='data:top.emailPostMsg'>
      <span class='email-post-icon'> </span>
    </a>
  </span>
</b:if>

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

expr:href='"http://www2.blogger.com/email-post.g?blogID=59174493096083971&amp;amp;postID=" + data:post.id'

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='"http://www2.blogger.com/email-post.g?blogID=" + data:blogid + "&amp;amp;postID=" + data:post.id'

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=" + data:post.id'

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

0 comments :