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

    I have the following getResources:

    [[!getResources? &resources=`115,322,236,129,218,137` &tpl=`home-tpl` &limit=`6` &sortby=`pagetitle` &sortdir=`AsC`]]

    But if someone deletes any of the resources, i'll get a Error 500 and the page wont even load anymore.

    I understand that if the resource is deleted, getResources cant collect the data, so do i need to do a 'snippet-check' inside the getResources to see if a page is deleted or not?
    Maybe there is a better/simpler solution to this.

    So basicly what i want to do is, to be able to show different products on the homepage.
    These products come from different parents.

    I could copy the products into a new folder so i can use &parents instead, but i dont think copy'ing data is a good idea, because you would need to change it on 2 places.

    Any ideas?

    Thank you.
      • 3749
      • 24,544 Posts
      &parents can take a comma-separated list of parent resources. Would that work for you? A main point of getResources is not having to change the tag when you create or delete resources. I'd strongly recommend setting things up so you don't have mess with it again.

      I don't think getResources can be made to work with a reference to a non-existent resource in the &resources list without hacking the code, and your changes would be overwritten whenever you upgrade getResources.

      You might try pdoResources, it may behave differently with a non-existent resource -- I've never tried it in that condition.
        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