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

    I'am working on a singlepage design website so there is one template. I want to use the content, title, longtitle from the resources.
    This must be possible with getResources but i'am new with getResources.

    The resource tree look like this:
    - website
    home
    page1
    page2
    page3

    And my snippet look like this
    [[getResources? &parents=`-1` &resources=`1` &includeContent=`1` &tpl=`home`]]
          [[getResources? &parents=`-1` &resources=`2` &includeContent=`1` &tpl=`page1`]]
          [[getResources? &parents=`-1` &resources=`3` &includeContent=`1` &tpl=`page2`]]
          .....
    


    It works but not good. The title, longtitle are a messy and random output

    How can i make this correct and output al the content on de right place in the template?

    Regards
    Stefan
      • 17301
      • 932 Posts
      If it is a single page website why do you have multiple pages (resources) ? There may be a better way to do what you're trying to achieve if you explain in more depth what it is you're trying to do.
        ■ 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.
        • 36613
        • 328 Posts
        for single page application i use getResources whit this snippets:

        [[!getResources?
        &parents=`1`
        &sortby=`menuindex`
        &sortdir=`ASC`
        &depth=`0`
        &includeTVs=`1`
        &includeContent=`1`
        &limit=`0`
        &tplCondition=`alias`
        &tpl=`section_default`

        &conditionalTpls=`{
        "about":"section_about",
        "blog":"section_blog",
        "contact":"section_contact"}`
        ]] [ed. note: cristianb88 last edited this post 5 years, 6 months ago.]
          • 3749
          • 24,544 Posts
          If I'm understanding you, I think you may want to put the HTML in chunks, not separate resources.

          Then, rather than take the time to run getResources, you can just use a chunk tag to pull in their content:

          [[$chunkName]]


          As LK says, though, we could really use more information about what you're trying to do.
            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
            • 42042
            • 140 Posts
            I use separate resources as well because it's easy for the end user. For the content I use PdoResources and PdoPage.
              • 28456
              • 83 Posts
              Thanks for the answers.
              To be more clear i make a drawing of the situation.
              The website is already functional but all the content is hard coded in the template.
              I prefer to use the content from the resources.

              Stefan
                • 36613
                • 328 Posts
                Quote from: stefonline at Oct 24, 2018, 07:47 AM
                Thanks for the answers.
                To be more clear i make a drawing of the situation.
                The website is already functional but all the content is hard coded in the template.
                I prefer to use the content from the resources.

                Stefan
                I singole page application i move all sub page down home page. And i use the get resource with conditionalTpls parameters.
                Ora you can use this plugin:
                https://docs.modx.com/extras/revo/fastfield

                Home section
                [[*pagetitle]]
                [[*content]]

                ------------

                Private section

                [[#2.pagetitle]]
                [[#2.content]]


                ------


                Business section

                [[#3.pagetitle]]
                [[#3.content]]


                ------



                  • 17301
                  • 932 Posts
                  May I ask why you prefer to use content from other resources? Wouldn't it be easier for your client to be able to go to the one resource and then see different categories/sections of the page and edit the content directly? Rather than fragmenting the content across different resources. Alternatively, using FRED might be an even better way to handle the content editing of a one page website.

                  To address your issue though from memory multiple getResources calls can clash, you could try calling it uncached, but if memory serves you would need to get pdoResources for one of the calls.
                    ■ 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
                    @stefonline - I think I see what you're doing and why, but it looks like you only need one call to getResources. As Christianb88 says, make all four "section" resources children of one parent resource (by dragging them there in the Resources tree).

                    On the parent page the only content will be one getResources call with its own ID as the &parents property.

                    [[!getResources? 
                        &parents=`[[*id]]`
                        &tpl=`myTpl` 
                        &includeContent=`1`
                    ]]


                    The myTpl Tpl chunk will look like one of the sections in your diagram (but with placeholder tags), and will be used four times.

                    myTpl:

                    [[+content]]
                    [[+pagetitle]]
                    [[+longtitle]]


                    FWIW, I would have them in this order:

                    [[+pagetitle]]
                    [[+longtitle]]
                    [[+content]]
                    





                      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