We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2328
    • 39 Posts
    Hi folks,

    Just looking for a (hopefully) simple solution to an apparently simple problem:

    I’ve been writing a simple bulletin board snippet that basically provides one forum (like this "General Support" forum) with posting and so forth.

    My page layout includes a breadcrumb trail, and I would like to extend this breadcrumb trail into the forum’s virtual pages, such as for each topic and the posting page etc.

    The problem is that this breadcrumb trail is separate from the forum snippet on the page. No problem, thinks I, I can use a placeholder and output the value to that.

    However, I would like to use the same template for both forum and non-forum pages, and output the normal breadcrumb trail to the non-forum pages.

    So... is there a way to set a default value (with a call to the breadcrumbs snippet) for the basic page, and replace it with the modified one for the forum when the forum is present? Template variables and @bindings seem approrpriate but I can’t get them to work sad

    I’ve hunted through the forums and documentation but no joy yet! Thanks in advance for any answers!

    Jon
      • 7923
      • 4,213 Posts
      Use a snippet for this, eg.

      <?php
      $output = $modx->runSnippet("BreadCrumbs", array("parameter1" => "value1", "parameter2" => "value2"));
      if (something == something) {
          $output .= //do something else to add the forum "virtual page" to the trail too..
      }
      return $output;
      ?>
      


      And then call that snippet in your template where you want the pagetrail..


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 2328
        • 39 Posts
        Thanks for that, Doze.

        Unfortunately, it wouldn’t quite work as the main aim was to have the forum snippet generate the forum breadcrumb trail.

        I did have another look at the snippet idea, and I think I have it now:

        I’ve created one to send the default breadcrumb snippet code to the placeholder, and then I have the forum snippet override it when it’s there - that didn’t work until I made sure both snippets were uncached. This makes a certain amount of sense, as the forum snippet has to be uncached, so the breadcrumb snippet also has to be to know when to override it!

        So, thanks indirectly wink

        Jon