Getting topic count as a JavaScript variable in WebHelp output
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 31
- Joined: Sat Jan 17, 2015 6:21 pm
Getting topic count as a JavaScript variable in WebHelp output
Hi,
I'm trying to get the topic count in a map with a custom WebHelp (responsive) publishing template.
I added the markup below to the bottom of the footer template; which I took from
https://github.com/oxygenxml/dita-ot-we ... tom-footer
I tried a couple of variations on the @select value but I always get 0 or 1 totalPages.
I did look into the temp folder but did not find which element I could count().
Can I get the total @topicref in the map from within this template?
What would be the proper @select value?
Thank you,
Raymond
I'm trying to get the topic count in a map with a custom WebHelp (responsive) publishing template.
I added the markup below to the bottom of the footer template; which I took from
https://github.com/oxygenxml/dita-ot-we ... tom-footer
Code: Select all
<script>
totalPages = <xsl:value-of select="count(//*[contains(@class, ' topic/topic ')])"/>;
console.log("totalPages = " + totalPages);
</script>
I did look into the temp folder but did not find which element I could count().
Can I get the total @topicref in the map from within this template?
What would be the proper @select value?
Thank you,
Raymond
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: Getting topic count as a JavaScript variable in WebHelp output
Hello,
You can use the map-xpath WebHelp Macro to execute an XPath expression on the DITA map and count all the topicrefs.
You can contribute your custom content using an HTML Fragment file, like the one below:
You can find a sample Publishing Template here: https://github.com/oxygenxml/oxygen-pub ... opic-count
Regards,
Alin
You can use the map-xpath WebHelp Macro to execute an XPath expression on the DITA map and count all the topicrefs.
You can contribute your custom content using an HTML Fragment file, like the one below:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<div xmlns:whc="http://www.oxygenxml.com/webhelp/components">
<script>
var totalPages = <whc:macro value="${map-xpath(count(//*[contains(@class, 'map/topicref')]))}"/>;
console.log("totalPages: ", totalPages);
</script>
</div>
Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service