I'm creating an FAQ page that is listing an "FAQ item" as a list of child nodes.
The "FAQ item" has two RTE on it, one for the question, one for the answer. Reason being, my FAQ page is using jQuery to display the "Answer" when the "Question" is clicked. I thought of using StripHtml to get the content from the two seperate RTE's. But this, of course, strips any links I may have in the "Answer" RTE.
Can anyone suggest a better method than what I'm currently using? I want to be able to keep my links from my "Answer" RTE.
<!-- The fun starts here --> <div id="FAQs_list_container"> <ul> <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <h1 class="faq-question"> <a href="#" name="{@nodeName}"> <xsl:value-of select="umbraco.library:StripHtml(./question)" /> </a> </h1> <p class="faq-answer" id="{@nodeName}"> <xsl:value-of select="umbraco.library:StripHtml(./answer)" /> </p> </li> </xsl:for-each> </ul> </div>
</xsl:template>
</xsl:stylesheet>
PS. This is not important, but I know I could use Textbox Multiple or Textstring for the "Question" field, but wanted the "Question" and "Answer" fields to look the same in the backend. Purely from an aesthetic point of view.
I just need a method of displaying the content from the "Answer" RTE, with it's StripHtml or something else isn't important.
I tried your suggestion, however it resulted in the following:
"All external vacancies are advertised on our Currentcareer opportunities page." - Current career opportunities is supposed to be the link but as you can see it's not working correctly.
<p id="FAQ-1" class="faq-answer" style="opacity: 1; display: block;">All external vacancies are advertised on our <ahref=" title="Training and development" training-and-development.aspx="" your-benefits="" careers="">Currentcareer opportunities page.</ahref="></p>
<p>All external vacancies are advertised on our <a href="/{localLink:1543}" title="Training and development">Current career opportunities</a> page.</p>
I had to slightly alter the code wrapping that line from a <p> tag to a <div> tag. As the <p> tag was now redundant, because it is now pulling the <p> tag from the RTE.
StripHtml but keep the links
I'm creating an FAQ page that is listing an "FAQ item" as a list of child nodes.
The "FAQ item" has two RTE on it, one for the question, one for the answer. Reason being, my FAQ page is using jQuery to display the "Answer" when the "Question" is clicked. I thought of using StripHtml to get the content from the two seperate RTE's. But this, of course, strips any links I may have in the "Answer" RTE.
Can anyone suggest a better method than what I'm currently using? I want to be able to keep my links from my "Answer" RTE.
Here's my current code:
PS. This is not important, but I know I could use Textbox Multiple or Textstring for the "Question" field, but wanted the "Question" and "Answer" fields to look the same in the backend. Purely from an aesthetic point of view.
Hey JV,
I'm not sure why you need to strip the HTML?
You can just render the RTE field like this removing the first <p> tag so they are not nested
<xsl:value-of select="umbraco.library:RemoveFirstParagraphTag(./answer)" disable-output-escaping="yes"/>
Rich
Hi Rich,
I just need a method of displaying the content from the "Answer" RTE, with it's StripHtml or something else isn't important.
I tried your suggestion, however it resulted in the following:
"All external vacancies are advertised on our Currentcareer opportunities page." - Current career opportunities is supposed to be the link but as you can see it's not working correctly.
Hey JV,
There's something else going on here, can you open up an answer node and click the RTE and view the html and post it here?
Rich
Hey JV,
Your href attribute is empty? Try putting a hash in there <a href="#" title="Training and developement">Current</a>
I'm a little confused about what you are trying to achieve, but possibly Tiny MCE (the RTE) is trying to 'fix' your empty href when you save.
Rich
Sorry Rich,
That's weird it wasn't when I posted it, I'll try it again:
<p>All external vacancies are advertised on our <a href="/{localLink:1423}" title="Capabilities">Current career opportunities</a> page.</p>
What output do you get when you just try to output the rte with no striping of characters?
<xsl:value-of select="./answer" disable-output-escaping="yes"/>
Succes! Thanks for your help Rich.
I had to slightly alter the code wrapping that line from a <p> tag to a <div> tag. As the <p> tag was now redundant, because it is now pulling the <p> tag from the RTE.
Here's my final code:
is working on a reply...