We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53588
    • 5 Posts
    Hi, i'm new in Modx and i don't know how i can send href to specific resource.

    Actually i have this in header chunk:
    <ul>
       <li><a href="" title="News Blog" class="">xxxx</a></li>
       <li><a href="/fulfilment" title="" class="">Fulfilment</a></li>
       <li><a href="/return-service" title="" class="">Return Service</a></li>
       <li><a href="/blog-preview" title="" class="">Blog</a></li>
       <li><a href="/contact-de" title="" class="">CONTACT</a></li>
    </ul>
    


    How can i get the id of the every resource for the href? I have one resource for fulfiment, one resource for return-service, etc. I tried to add [[~[[+id]]]] but i get nothing. And the same for the text, i tried [[+title]] but i get nothing.

    Thanks

    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      • 17301
      • 932 Posts
      Hi gerard9,

      Welcome to the MODX forums!

      You can link to resources by inserting [[~id]] and replacing id with the resource id number. So for example if your fulfilment resource has an id number of 5 then you could link to it by using
      href="[[~5]]" 


      If you're trying to create a dynamic menu so that when you add resources to the backend it automatically feeds onto the front end then you should take a look at the wayfinder or pdomenu extra, both of which are really well documented.
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 3749
        • 24,544 Posts
        +1 for what LK said.

        In case you're wondering why this didn't work:

        [[~[[+id]]]]


        The inner tag is a placeholder tag. It won't work without something to set the placeholder value.

        It would work fine in a Tpl chunk used with Wayfinder, pdoMenu, or getResources, because those snippets would set the placeholder value each time they processed a new resource. Just putting it in a header chunk, though, won't work because there's no snippet that would set the +id placeholders.

        FYI, pdoMenu is part of the pdoTools extra.
          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
          • 53588
          • 5 Posts
          Quote from: lkfranklin at Jul 07, 2017, 11:08 PM
          Hi gerard9,

          Welcome to the MODX forums!

          You can link to resources by inserting [[~id]] and replacing id with the resource id number. So for example if your fulfilment resource has an id number of 5 then you could link to it by using
          href="[[~5]]" 


          If you're trying to create a dynamic menu so that when you add resources to the backend it automatically feeds onto the front end then you should take a look at the wayfinder or pdomenu extra, both of which are really well documented.

          Oh, thanks, i started to working with modx since few days a go for work, we have a wayfinder but for now we can not use it because we are remodeling a website and picks up the menus currently published, not the new ones.

          Thanks for quick response laugh

          But last question, now i put the [[~id]] and it's working, but how can I get the title of the resource that i'm calling through the id?
          • discuss.answer
            • 17301
            • 932 Posts
            You can check 'hide from menus' on the current menu items that you don't want wayfinder to pull through. Alternatively you could also exclude the resources you don't want to show with the &excludeDocs property in your wayFinder call.

            If neither of those options are any good you could also create a new folder called 'menu' and create weblink resources within it just for the purpose of pulling it through whilst you're remodelling and set the startId to the new menu id.

            In MODX there are many ways of doing the same thing smiley

              ■ email: [email protected] | ■ website: https://alienbuild.uk

              The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
            • discuss.answer
              • 3749
              • 24,544 Posts
              The only practical way to get the the pagetitle (without writing custom PHP code) is to use Wayfinder, pdoMenu, getResources, or something similar.

              Wayfinder just shows the resources as they appear in the Resources tree on the left side of the Manager. As LK says, you can hide them by checking the "Hide from Menus" checkbox, or you can drag them somewhere else in the tree so they're not under the parent (or parents) you specified in Wayfinder's &startId property in the Wayfinder tag.

              By default, Wayfinder uses the ID of the current page as the startId and shows documents under it, but if you use the &startId property, you can select the parent used for the menu.

              This would show resources under resource 12 in the tree:

              [[!Wayfinder? &startId=`12`]]


              Since you're almost certainly going to use Wayfinder or something similar eventually, I'd recommend using it now. The sooner you get to understand it the better.

              Welcome to MODX. smiley

                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
                • 53588
                • 5 Posts
                Quote from: lkfranklin at Jul 08, 2017, 12:49 PM
                You can check 'hide from menus' on the current menu items that you don't want wayfinder to pull through. Alternatively you could also exclude the resources you don't want to show with the &excludeDocs property in your wayFinder call.

                If neither of those options are any good you could also create a new folder called 'menu' and create weblink resources within it just for the purpose of pulling it through whilst you're remodelling and set the startId to the new menu id.

                In MODX there are many ways of doing the same thing smiley


                Quote from: BobRay at Jul 09, 2017, 03:52 AM
                The only practical way to get the the pagetitle (without writing custom PHP code) is to use Wayfinder, pdoMenu, getResources, or something similar.

                Wayfinder just shows the resources as they appear in the Resources tree on the left side of the Manager. As LK says, you can hide them by checking the "Hide from Menus" checkbox, or you can drag them somewhere else in the tree so they're not under the parent (or parents) you specified in Wayfinder's &startId property in the Wayfinder tag.

                By default, Wayfinder uses the ID of the current page as the startId and shows documents under it, but if you use the &startId property, you can select the parent used for the menu.

                This would show resources under resource 12 in the tree:

                [[!Wayfinder? &startId=`12`]]


                Since you're almost certainly going to use Wayfinder or something similar eventually, I'd recommend using it now. The sooner you get to understand it the better.

                Welcome to MODX. smiley


                Thanks a lot, it's working with new folder with weblink resources and excluding the id of the new resource in the other menu. Next question, now when I click in some menu link in the url shows something like: www.aaaa.com/menu/resource. It's possible to hide the /menu/ ?

                Thanks a lot for all the help, maybe it's silly questions but I'm new. Thanks again for the welcome and the help provided laugh

                  • 17301
                  • 932 Posts
                  No worries.

                  It is possible by turning off friendly alias paths in the system settings, but I don't advise doing this on a live site as any SEO 'juice' that your exisiting pages have will be lost when Google reindexes your site and treats everything as new pages. If you also have resources with the same alias paths there may also be conflictions.

                  If you're restructing your site then I do advise that you don't do this on the live site anyway and to consider setting up a dev envrionment/staging server to make these changes. Then when you/your client is happy push the changes to the live site. Taking this kind of approach will ensure that there will be no distruption on the live site and it'll also prevent users stumbling across pages or errors that you'd rather they don't. If it's also duplicated content on the new resources then you should also take extra measures to prevent these pages being indexed by SERPS and being penalised (There's actually a nice plugin called SEO Tab where you can do this in the manager). Again taking the dev envrionment approach will save you a lot of troubles going forwards.
                    ■ email: [email protected] | ■ website: https://alienbuild.uk

                    The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.