We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22019
    • 390 Posts
    Sorry, this is probably very basic (and must have been asked beofre, I can’t seem to find the right search phrase), but I think I’m misunderstanding how either TVs do or should be used. I’m using Revo - and stumped two different areas:

    I have some resources:

    Folder 16
    - Item One 28
    - Item Two 29

    I want to allow a user to populate a ’Featured resource’ TV in my article template.

    When I try @RESOURCE 28 that’s literally what turns up in the TV ’@RESOURCE 28’.
    When I try @CHUNK and a chunk that calls getResources to list all the children under item 16 I get a mahoosive array, and can’t seem to isolate pagetitle or id from that array (and so have no idea whether it will show up in the TV or not, let alone can I manipulate it later). This is probably a red herring anyway, but I include it to show my level of noobness.

    Am I going about this all wrong? (The RTFM is somewhat sparse on explanations)

      Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
      • 22019
      • 390 Posts
      Ok, it seems that there’s a bug with the @RESOURCE binding, and possibly the @CHUNK one as well that will get fixed in the patch release.

      In case it helps anyone along the way, I kinda got what I wanted by doing this:

      The TV is bound to
      @SELECT `pagetitle` AS `name`,`id` FROM `modx_revosite_content` WHERE `parent`=16 


      Which gives me a meaningful list in the dropdown for the TV. When the user selects a resource, the ID is then passed to the page. I can retrieve the other bits of the resource I need using
      [[!getResourceField? &id=`[[*productFeature]]` &field=`pagetitle`]]


      I’m not very good at manipulating IDs yet. I know there must be a ridiculously easy way to grab the full array related to a resource, but I’m taking baby steps here.
        Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
        • 22019
        • 390 Posts
        Baby steps continue. Instead of [[getResourceField]] if you use [[getResources]], give it the right parent id (in this case I know this id will be static), and then pass the TV as the id to include in &resources, then I have access to the entire resource array.

        [[!getResources? &parents=`16` &resources=`[[*productFeature]]` &tpl=`myTpl`]]


          Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
          • 22019
          • 390 Posts
          And in case anyone’s reading this other than me. (One of) the ways to get at the contents of a resource, when the id is variable but given on the page (eg from a TV) is this:

          [[getResources?  &parents=`[[!getResourceField? &id=`[[*myId]]` &field=`parent`]]` &tpl=`myTpl` &where=`{"id:=":[[*myID]]}`  &limit=`1`]]


          Seems a bit silly to have to bounce up to the parent and then down again, but I’m not up to writing snippets yet. (A simpler solution would be for getResources to work ok when &parents is null/missing - but does have either a &where or &resources (or both) _are_ specified. But that’s for another day).
            Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86