We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37557
    • 25 Posts
    I'm using breadcrumbs addon in Revolution and I'm using a dynamic page. What I wan't is to create the Breadcrumb with a custom title (in my case the Author or the Book). The site gets its variable over GET:
    book.html?bookid=4 and I have a php snippet that fetches me the content related to the ID from a custom-db. how could I achieve this. I failed to find a document how to do this.
    Thank you
      • 3749
      • 24,544 Posts
      I don't see any easy way to do it without rewriting the Breadcrumbs code or using a plugin. As far as I can tell, Breadcrumbs uses no external Tpl chunks, so there's nothing there before it runs and after it runs, the placeholders are all gone, so setting one would have no effect. I could be wrong.

      I think I would try editing the Breadcrumbs class (after backing it up) and commenting out the part(s) that replace the [ [+resource]] placeholder, then set that placeholder in your custom snippet.

      $modx->setPlaceholder('resource', $author);



      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODx info for everyone: http://bobsguides.com/MODx.html [ed. note: BobRay last edited this post 14 years, 9 months ago.]
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 37557
        • 25 Posts
        Hi BobRay,
        thank you again for the help. I choosed another way cause I couldn't figure it out properly:
        Javascript
        It's ugly but works. For Reference I post my How to here:

        1. I used a modified version from this howto
        http://www.randomsnippets.com/2008/03/07/how-to-find-and-replace-text-dynamically-via-javascript/
        <script type="text/javascript">
        var needle ="";
        var replacement ="";
        var haystackText = "";
        function findMyText(needle, replacement) {
             if (haystackText.length == 0) {
                 haystackText = document.getElementById("replacebo").innerHTML;
             }
             var match = new RegExp(needle, "ig");     
             var replaced = "";
             if (replacement.length > 0) {
                 replaced = haystackText.replace(match, replacement);
             } 
             document.getElementById("replacebo").innerHTML = replaced;
        }
        </script>

        2. adding id="replacebo" in: core/components/breadcrumbs/model/breadcrumbs/breadcrumbs.class.php (after backup)
        ...
        'bcTplCrumbCurrent' => '<li itemscope="itemscope" class="B_currentCrumb" itemtype="http://data-vocabulary.org/Breadcrumb" id="replacebo">[[+text]]</li>',
        ...


        3. created a chunk(bcJS)
        <script type="text/javascript">
           var needle;
           var replacement;
           var needle="[[*pagetitle]]";
           var replacement="[[+title]]";
           findMyText(needle,replacement);
        </script>


        4. loading the chunk via my snippet
        $output .= $modx->getChunk('bcJS',$fields);


        Maybe that's a feature for next version of Breadcrumbs implementing a template system

        I know it's ugly but I probably didn't mention I'm a coding noob laugh

        edit. typo
          • 3749
          • 24,544 Posts
          I'm glad you got it working.

          I may be misunderstanding your code, but I think you could do it with a plugin connected to OnParseDocument with this one line of code (or preg_replace if there might be other pagetitle tags on the page):


          $modx->resource->_output = str_replace('[[*pagetitle]]', '[[+title]]', $modx->resource->_output);


          ---------------------------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
          MODx info for everyone: http://bobsguides.com/MODx.html
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting