Default page for missing topics
Description
I'd like WWHelp to display a particular page when a topic or context is missing.
Contents
Implementation
From wwp-users http://tech.groups.yahoo.com/group/wwp-users/message/33440
We had the same issue with out help: we wanted the WebWorks Help 5.0- based help system to redirect to a generic page when the application called for a topic that no longer exists.
I fixed this by making a change in the help.js file.
In the help.js file -- in either your help output or the format template -- locate the WWHHelp_ProcessTopicResult function. It looks like this:
function WWHHelp_ProcessTopicResult(ParamTopicURL) { if (ParamTopicURL != null) { this.mDocumentURL = this.mBaseURL + this.mContextDir + ParamTopicURL; } }
Add an else to the if statement to direct the help system to a default page in case the topic alias cannot be found. The modified function looks like this:
function WWHHelp_ProcessTopicResult(ParamTopicURL) { if (ParamTopicURL != null) { this.mDocumentURL = this.mBaseURL + this.mContextDir + ParamTopicURL; } else { this.mDocumentURL = this.mBaseURL + this.mContextDir + "page_to_appear_when_alias_does_not_exist.html"; } }
-- where page_to_appear_when_alias_does_not_exist is the filename of the topic you want to appear when the application calls for a topic that does not exist in the help (for the filename extension, be sure to use what is specified in your format as the filename extension for topic file). In our help system, this page contains instructions on how to use the Contents, Index, and Search tabs to search the help for information.
In the FrameMaker source files, create the page that you want to appear here and use a Filename marker to set the page_to_appear_when_alias_does_not_exist filename.
If you want to redirect to a webpage, change the line in the else statement to this --
else { this.mDocumentURL = "http://www.example.com"; }
-- where www.example.com is your address. The page will appear in the help topic pane.
With a little more twiddling in the JavaScript files, I'm sure I could have a generic page appear in the help topic pane and the redirect landing page appear in a new browser window, but I've not tried that out.
Problem
Here's my file with the changes implemented. Perhaps the problem is not my code, but how I'm testing/validating?
Feedback
Angela, your file appears to be correct syntactically, yet, I'm not sure about the redirect location you've specified:
function WWHHelp_ProcessTopicResult(ParamTopicURL) { if (ParamTopicURL != null) { this.mDocumentURL = this.mBaseURL + this.mContextDir + ParamTopicURL; } // Redirect "Page Not Found" to splash page, or to another page if desired. // else { this.mDocumentURL = this.mBaseURL + this.mContextDir + "Welcome.html"; } }
I'm guessing the file lives at a slightly different path.
Please upload a .zip of your output for review.
-- BenAllums
Example Output
My output is pretty large. Is there no limit to file size in this wiki? I guess I'll know when I try. (By the way, I've since changed the file marker so that file name is now Welcome.html. I'll upload new help.js.) --AngelaAkridge
Here's my output--AngelaAkridge
Context Issue
Angela, I think I see the problem.
function WWHHelp_ProcessTopicResult(ParamTopicURL) { if (ParamTopicURL != null) { this.mDocumentURL = this.mBaseURL + this.mContextDir + ParamTopicURL; } // Redirect "Page Not Found" to splash page, or to another page if desired. // else { this.mDocumentURL = this.mBaseURL + this.mContextDir + "Welcome.html"; } }
See the reference to this.mContextDir? It doesn't contain a "Welcome.html" file.
So, either you can place this all of your directories or you need to hard code the context directory. In your case, something like:
function WWHHelp_ProcessTopicResult(ParamTopicURL) { if (ParamTopicURL != null) { this.mDocumentURL = this.mBaseURL + this.mContextDir + ParamTopicURL; } // Redirect "Page Not Found" to splash page, or to another page if desired. // else { this.mDocumentURL = this.mBaseURL + "Introduction/" + "Welcome.html"; } }
Testing with this change seems to make everything work.