Announcement

Collapse
No announcement yet.

Adding Content (include) to Topic Page

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    The paths are incorrect. Your files are in /help/random directory.
    FileName should be
    Code:
    /help/random/random.html
    And the jquery
    Code:
    $('#random-post').load('/help/random/random.php');
    Add before the return line. This should print the values of the variables at the top of the screen.
    Code:
    var_dump($FileName);
    var_dump($contents);


    Comment


    • #17
      Have you tried using a PHP module with this code?

      PHP Code:
      //enable error reporting for debugging purposes
      error_reporting(E_ALL);

      $FileName "web-pages.html"//the path should be relative to the forum root directory

      if ( file_exists($FileName) ) {

          
      // Get content as an array
          
      $contents explode(":::",file_get_contents($FileName));

          
      // Remove last blank entry
          
      unset($contents[count($contents) - 1]);

          
      // Randomize the content
          
      shuffle($contents);

          
      // Output First Entry
          
      echo $contents[0];
      }
      else {
         echo 
      'File does not exist.';

      In your code, you used # as comments which is incorrect. There should also be no opening/closing PHP tags <? ?>.

      GIPHY for vB5 AutoLinker Auto-Create Flag Report Topic Social Icons in Postbit Clear Cache Cron DragDrop Upload Topic AJAX AutoUpdate Custom Avatars Selector Stop Links in Posts...and more!

      Comment


      • #18
        Thanks for the # catch Glenn. That's why I couldn't get the PHP module to work. I didn't even notice the # comments since I'm used to scripting in the bash shell. Worked like a charm. robinantill , Glenn's method in the previous post is the best way to accomplish what you're trying to do.


        Comment


        • #19
          Hi Replicant,
          Thanks for that. I've managed to get my forum pages working as I wanted. Massive big thank you and Glenn for helping me out.
          Regards,
          Robin

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...
          X