I need to use this tag <rn:page_title/>
in my <meta name="description" content=""/>
tag on my template files. I need specifically for the content to read something like:
"Read more about <rn:page_title/>
on our site!"
I realize that this tag is really just a shortcut for the <rn:meta>
tag from the content that I'm sucking into my template.
How can I access the <rn:page_title/>
content while inside an HTML tag?
- Is there a way to save the results of this tag in a php variable?
- I need to make sure it renders with the page, not after, so using JavaScript to build the meta tag and injecting it after page render is not an option.
- Is there a way to dynamically retrieve the results of the
<rn:meta>
tag? Perhaps with an#rn:php:some/path/getDymanicTitle()#
statement in the content string? But I don't know how getDynamicTitle works, and I need it to work not just on answers pages, but on all pages.
After searching for several days to figure out how to do this in the most flexible way possible I came up with this snarky little piece of code:
The only caveat I will mention is that you need to use single quotes for your echo, not double, because otherwise it renders something like:
Clearly not desirable. Also, remember to escape any single quotes. So if your site is "Joe's Big Jamboree" then you would have:
And it would render: