Using rn:page_title in the Meta Description Tag with Oracle RightNow

139 Views Asked by At

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.
1

There are 1 best solutions below

0
On

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:

<?php echo '<meta name="description" content="Read more about '; ?><rn:page_title/><?php echo 'on our site!">'; ?>

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:

<meta name="description" content="Read more about PAGE TITLE" on our site!"/> 

Clearly not desirable. Also, remember to escape any single quotes. So if your site is "Joe's Big Jamboree" then you would have:

<?php echo '<meta name="description" content="Read more about '; ?><rn:page_title/><?php echo '. Only at Joe\'s Big Jamboree!">'; ?>

And it would render:

<meta name="description" content="Read more about PAGE TITLE. Only at Joe's Big Jamboree!"/>