PHP is a powerful server-side scripting language that has been an essential tool for web development for decades. With its ability to dynamically generate content, enhance user experience, handle security restrictions, increase interactivity or collect user data, it is a great addition to online user documentation. Thanks to the HelpNDoc help authoring tool’s powerful and versatile template system, these benefits are now easily achievable: let’s explore how incorporating PHP into online user documentation can help to improve the user experience and provide better engagement and feedback. Whether you’re a web developer, a technical writer, or someone looking to enhance their online documentation, this post will provide valuable insights and tips on how to use HelpNDoc to make the most of PHP in your online documentation.

⚡ Benefits of adding PHP code to online help resources

Unlike static HTML content, PHP-powered documentation can provide a more secure, dynamic and interactive user experience, enabling technical writers to better meet the needs of their users.

HelpNDoc's template editor with PHP code

Incorporating PHP into online user documentation offers a marked improvement compared to static HTML content produced by most help authoring software. While HTML provides a basic structure for displaying information, PHP brings dynamic functionality to the table as it allows for the generation of dynamic content, making the user experience more interactive and engaging. In contrast to static HTML, PHP-powered online user documentation can collect user data, provide secured server-side access restrictions and facilitate better feedback, enabling customization and tailoring to the user’s needs.
Incorporating PHP into online user documentation is usually a very challenging task, but with the right help authoring software, it becomes much easier: HelpNDoc stands out with its powerful and versatile template system which makes it incredibly easy to add PHP code to online user documentation.

🤔 How to create a custom HTML template to produce PHP files

The HelpNDoc help authoring software can produce multiple documentation formats out of a single project, including fully responsive static HTML web-sites. Custom templates can completely customize HelpNDoc’s HTML output to also include PHP code.

HelpNDoc's template editor with PHP code

Here are the simple steps needed to create a new template:

  1. From HelpNDoc’s Tools ribbon tab, in the Templates group, click Templates Editor to open the template editor window
  2. Click the green + button then click Create HTML template to create a new HTML template, which is initially an exact copy of the default one
  3. Choose a template name such as “PHP Template”

The new template is now created. We just need to perform a few modifications to make it work with PHP code, in the newly created template’s General settings section:

  1. Change the Default file extension to “php”
  2. Change the Link format to topics to “%helpid%.php”
  3. Change the Link format to anchors to “%helpid%.php#%anchorname%”

And that’s it! HelpNDoc can now use that template to produce a fully functional PHP website. See how you can choose a template for your builds in HelpNDoc.

😍 How to leverage PHP code to create better online help: some samples

Now that we can create a dynamic PHP website using the HelpNDoc help authoring tool, let’s leverage that powerful scripting language by adding custom PHP scripts to our online documentation.

HelpNDoc's template editor with PHP code

🔑 Password-protected documentation topics

By restricting access to sensitive or confidential topics, technical writers can ensure that this information is only seen by authorized users. This helps to maintain privacy and protect sensitive data.

PHP security password form

Now that we can produce a fully functional PHP website, let’s restrict access to some documentation pages by requesting a password first. Thanks to HelpNDoc’s library system, we can create a reusable PHP script and place it in any topics to restrict its access. Here is how this could be done:

  1. From HelpNDoc’s Home ribbon tab, in the Library group, click Add item then Add HTML code
  2. Specify a Library item name such as “Restricted Access”
  3. Enter the following HTML/PHP code:
<hr>
<div style="margin:1em">
    <?php
        if(!isset($_GET["pass"]) || $_GET["pass"]!="secret") {
    ?>
        <p>You're not allowed to access this page.</p>
        <form>
            <div class="form-group">
                <label for="pass">Password:</label>
                <input class="form-control" id='pass' name='pass'></input>
            </div>
            <button type="submit" class="btn btn-primary">Login</button>
        </form>
    <?php
            exit;
        }
    ?>
</div>
  1. Click OK: the library item is now available in the project’s library
  2. Drag and drop that library item at the top of each topic that needs to be protected

And that’s it! Generate your documentation again and test it on a PHP server: visitors won’t be able to access restricted pages without entering the “secret” password.

💬 Collect user feedback to improve documentation

By gathering insights from actual users, technical writers can gain a better understanding of the strengths and weaknesses of their documentation, as well as areas that need improvement.

PHP feedback form

It’s nice to be able to add custom PHP code to only certain pages, but it would be even better to be able to automatically add PHP code to all pages. Let’s update our template to do just that, and include a feedback system at the bottom of each topic:

  1. From HelpNDoc’s Tools ribbon tab, in the Templates group, click Templates Editor to open the template editor window
  2. Select your PHP template in the list
  3. Navigate to the Script files section
  4. Select the “topics.pas.html” script file and click Edit Script to open HelpNDoc’s built-in script editor
  5. Locate the <footer> string in that file, and add the following code right before it:
<hr>
<div style="margin:1em">
    <?php
        if(isset($_POST["feedback"])) {	
            $from = "support@example.com";
            $to = "support@example.com";
            $headers = "From: $from";
            $subject = "New feedback";
            $message = "New feedback for topic: <% print(aTopicList[nCurTopic].caption); %>\n\n" . $_POST["feedback"];
            mail($to,$subject,$message,$headers);
            echo("<p>Thank you for your feedback!</p>");
        }
        else {
    ?>
            <form method="POST">
                <div class="form-group">
                    <label for="feedback">Feedback:</label>	
                    <textarea class="form-control" id="feedback" name="feedback" rows="3"></textarea>
                    <small class="form-text text-muted">Let us know if you have any feedback about this topic</small>
                </div>
                <button type="submit" class="btn btn-primary">Submit feedback</button>
            </form>
    <?php
        }
    ?>
</div>

Generate your documentation and test it: it now includes a basic yet functional feedback system! 🤯

Want to create great documentations?

HelpNDoc is free, fully functional, and easy to use.
Produce your first multi-format documentation in the next minute or so.

Adding PHP code to online user documentation can bring a wealth of benefits, including the ability to add dynamic content, password protect sensitive topics, and collect user feedback. The HelpNDoc help authoring tool’s powerful and versatile template system makes it easy to achieve these goals, enabling technical writers to create high-quality, engaging documentation that meets the needs of their users. Whether you’re looking to improve the overall user experience, streamline processes, or protect sensitive information, downloading the free personal edition of HelpNDoc is the first step towards realizing the many benefits that PHP can bring to your documentation. So take advantage of this opportunity and start making the most of your online user documentation today!

HelpNDoc can generate multiple documentation formats

See also...

HelpNDoc's character analyzer illustration [illustration] [Featured]
Tech Writers' Secret Weapon: The Unique Advantages of Using HelpNDoc's Characters Analyzer

HelpNDoc has been a go-to solution for professionals seeking to create high-quality, engaging, and user-friendly documentation. However, it’s not just its user-friendly interface or its versatile …

Read More →
Happy technical writer using HelpNDoc [happy] [Featured]
Making the Most of HelpNDoc: How the "Keep Temporary Files" Feature Can Benefit Technical Writers

When working on technical documentation, every tool and feature at our disposal can make a big difference in productivity and efficiency. One such feature in HelpNDoc, often underutilized, is the …

Read More →
Converting Legacy WinHelp HLP to Modern Documentation [converting] [Featured]
Revitalize Your Help Files: Converting Legacy WinHelp HLP to Modern Documentation with HelpNDoc

In an age where information is consumed on a plethora of devices and platforms, the classic WinHelp HLP files — once the standard in Windows-based help documentation — are now relics of a bygone era. …

Read More →
HelpNDoc vs WordPress [versus] [Featured]
Mastering Multi-Channel Publishing: Why HelpNDoc Leaves WordPress in the Dust

In today’s interconnected digital world, the concept of multi-channel publishing has become more critical than ever. As audiences seek information through various platforms and formats, content …

Read More →

Categories: articles