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

    I’ve got a fairly complicated subnav on a site that I’m working on and after looking around here I found the following:

    [!Wayfinder?startId=`[[UltimateParent]]`!]

    This works great, but I would like to display the page title of the parent as a header above the nav. I’m planning on duplicating and then modifying the UltimateParent snippet to output the pagetitle instead of the id, but I don’t know how to achieve this.

    Can anyone help? Thanks.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Why not just use a TV with @INHERIT, put it just above your Wayfinder snippet tags, and in the parent page’s TV editing field, put the title you want.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 19741
        • 90 Posts
        Hi,

        or try the snippet GetParent (you need "docAPI library" also!).

        And then use
        [[GetParent?field=`pagetitle`]]

        in your template.
          Bye,
          Mithrandir
          • 5697
          • 2 Posts
          Quote from: sottwell at Mar 11, 2007, 03:04 AM

          Why not just use a TV with @INHERIT, put it just above your Wayfinder snippet tags, and in the parent page’s TV editing field, put the title you want.

          Thanks! That worked perfectly.

          On a side note, is there anywhere to get some more examples of how the @ bindings work? I checked the wiki but couldn’t find anything.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 6726
              • 7,075 Posts
              There is always various methods to do things in MODx but the method I prefer is use the GetField snippet.
              In your case :

              [!GetField? &parent=`1` &parentLevel=`1` &field=`pagetitle`!]


              That should do the trick smiley

              I don’t know about performance compared to the other method but I am an avid GetField user so I went this way...
                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l'outil id
                • 9053
                • 18 Posts
                Hi. I have a little trouble with displaying link on material’s parent in Ditto news block.

                I was using GetField for defining href (<a class="ditto_parent" href="[(site_url)]index.php?id=[[GetField? &field=`id` &docid=`[+id+]`]]">) and pagetitle of parent ([[GetField? &parent=`1` &docid=`[+id+]`]]).

                Such usage added 100+ DB requests, and it wasn’t very nice thing. A bit later I swiched on FURLs, and here the problem occured - how to get link on parent now? FURL-like link, I mean. I could get document alias with GetField, but what if document is placed inside 3 folders? I tried to call Breadcrumbs snippet inside Ditto template, but with no luck. Same with GetParent snippet.

                If anyone have an idea how to put a link on parent with FURL enabled, please share smiley


                  "Sorry for my english"
                  • 6726
                  • 7,075 Posts
                  As I said, performance can be an issue... I have a decent dedicated box hosting few websites thus I can afford to use this kind of "lazy" solutions... about FURLs, it should be doable but using multiple GetField calls to build URLs requires good naming conventions and a bit of logic to work.

                  I have recently done something of the kind to build a product catalog. I wanted dynamically generated "permalinks" to switch between different views of data for the same product.

                  It looks like this (sorry data is in french wink ) :

                  <h3 class="produit">[!GetField? &parent=`1` &parentLevel=`1` &field=`pagetitle`!]
                  <span class="liens_fiche"><a href="[(site_url)]produits/catalogue_des_produits/[!GetField? &parent=`1` &parentLevel=`2` &field=`alias`!]/[!GetField? &parent=`1` &parentLevel=`1` &field=`alias`!].html">Fiche Produit</a> | <a href="[~[*id*]~]" style="font-weight: bold; color: black;">Fiche Pratique</a> | <a href="[(site_url)]produits/catalogue_des_produits/[!GetField? &parent=`1` &parentLevel=`2` &field=`alias`!]/[!GetField? &parent=`1` &parentLevel=`1` &field=`alias`!]/fiche-technique.html">Fiche Technique</a></span></h3>
                  


                  It changes each time for each of the 3 "permalinks".
                  As I said, it works only because I have a strict naming convention and also I have set up a model document for each product that the client duplicates (thus the sub-documents have the right alias). But it’s not for everyone...

                  I sure would like to find another alternative, but since it works I currently have no time to find a better way...
                  Anyone ?


                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l&#39;outil id
                    • 10487 MODX Staff
                    • 1,535 Posts
                    @Errant: If I’m understanding correctly then you could avoid the DB altogether (if you’re using MODx 0.9.5+) because you could utilise the $modx->getParentIds() method.

                    Then access the $modx->aliasListing array to find out what the alias (and path if using Alias Paths) are for that ID, or probably better, use $modx->makeUrl(). That would give you enough information to construct the FURL link. And not a DB query in sight!
                      Garry Nutting
                      Senior Developer
                      MODX, LLC

                      Email: [email protected]
                      Twitter: @garryn
                      Web: modx.com
                      • 6726
                      • 7,075 Posts
                      Thanks for the pointer Garry, hopefully when I finish the 2 projects I am working on, I’ll have the time to dig this and try it out smiley
                        .: COO - Commerce Guys - Community Driven Innovation :.


                        MODx est l&#39;outil id