We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I have a problem in my modx 2.2.4 (advanced) with TVs inside a TV. Please see this example:

    Example resource with id 1 has some TVs like:

    eventdate: "any date"
    eventguests: "24"
    eventdescription: "Hey guys please join my on [[*eventdate]] with [[*eventguests]]."


    Now I have an other resource where I display one of those event resources (like the one above) with getResources and a getResources template like:

    This event is on [[+eventdate]] and has [[+eventguests]] guests.
    The description is: [[+eventdescription]]


    Well, what happens is that [[+eventdescription]] is not processed as expected (for me). I thought the "[[*eventdate]]" inside the eventdescription would become the value of resource 1, but it becomes the default TV value...(like it's processed for the resource with getResources)

    I tried to replace [[+eventdescription]] with the getResourceField snippet and &processTV=`1`. But same result.

    Any ideas how I could get the eventdescription with TV values from resource 1?
      chsmedien - Digital Marketing Agency
      MODX Professional & Ambassador

      http://chsmedien.com | http://twitter.com/christianseel
    • Can you post your full gR call?

      Otherwise, do you have &tvPrefix=`` (empty) somewhere in the call? Also, if those resources you're pulling are hidden, ensure you have &showHidden=`1`
        Sal Baldovinos
        SEO & DIGITAL MARKETING

        ARIEL DIGITAL | Maximize Your Potential
        www.arieldigitalmarketing.com
        • 36926
        • 701 Posts
        and your getResource template
        • I previously had tvPrefix empty, after a tweet by @gallenkamp I changed it to `tv.` but no change - TVs are still wrong.

          @mayhemchaos: requested resources are not hidden. I get them correct, only the TVs in the eventdescription TV are not processed as expected.

          Here is my gR call:
          [[!getResources?
          &parents=`2`
          &where=`{"template:=":2}`
          &tvFilters=`eventpushtofb==0,eventdateend>>[[!currentTime? &strftime=`%Y-%m-%d %H:%M:%S`]]||eventpushtofb==1,eventfbid>=1,eventdateend>>[[!currentTime? &strftime=`%Y-%m-%d %H:%M:%S`]]`
          &limit=`0`
          &sortbyTV=`eventdate`
          &sortdirTV=`ASC`
          &hideContainers=`1`
          &includeContent=`1`
          &includeTVs=`1`
          &processTVs=`1`
          &tvPrefix=`tv.`
          &tpl=`api-event`
          ]]


          And my template "api-event":
          {
            "id":"[[+id]]"
            ,"pagetitle":"[[+pagetitle:prepareforjson]]"
            ,"longtitle":"[[+longtitle:prepareforjson]]"
            ,"link":"[[~[[+id]]:prepareforjson]]"
            ,"eventdate":"[[+tv.eventdate:strtotime:prepareforjson]]"
            ,"eventdateend":"[[+tv.eventdateend:strtotime:prepareforjson]]"
            ,"eventpushtofb":"[[+tv.eventpushtofb:prepareforjson]]"
            ,"eventdescription":"[[+tv.eventdescription:prepareforjson]]"
          }
          prepareforjson is just a snippet to escape some chars for json...

          The default value of the TV "eventdescription" is something like:
          This Event is on [[*eventdate]]. Please join us!
          {{some custom text for each event}}


          For each event-resource the {{some custom text for each event}} is replaced by some individual text.
          When I call a resource with gR the TV is displayed with the custom text, only the TVs inside are not processed for the requested resource (they are actually empty or have the default value of the tv).
            chsmedien - Digital Marketing Agency
            MODX Professional & Ambassador

            http://chsmedien.com | http://twitter.com/christianseel
            • 36926
            • 701 Posts
            Sorry not 100% sure exactly what your do. But if the eventdescription TV is containing a TV in the value that should also be displayed by the gR then:
            This Event is on [[*eventdate]]. Please join us!
            {{some custom text for each event}}
            

            should be
            This Event is on [[+eventdate]]. Please join us!
            {{some custom text for each event}}
            
            • Oh yes, sure. BUT:
              I also display the event-resource itself as a page. Where the resource content also contains those TVs (eventdescription). And there I need to call TVs like eventdate as a TV (with *).

              So it's not possible for me to change that in the eventdescription TV. What could I do?

              Some kind of preprocessing where I change all "*" to "+" ?

              Or I could use a snippet at the event resource to bring the resource TVs as a placeholder. But is that the best way? [ed. note: christianseel last edited this post 11 years, 7 months ago.]
                chsmedien - Digital Marketing Agency
                MODX Professional & Ambassador

                http://chsmedien.com | http://twitter.com/christianseel
                • 36926
                • 701 Posts
                Ah ok. Interesting one.

                Thinking output/input filter maybe the way to go. Do they use different templates as you could test for that.
                [[*template:is=`1`:then=`[[*eventdate]]`:else=`[[+eventdate]]`]]
                

                Where 1 is the id of the template being used to display the event resource itself.

                Or
                Suppose you could have 2 TVs and a plugin or something that sets them to the same value on save.

                There maybe a better way, if anything else comes to mind i'll let you know. [ed. note: bennyb last edited this post 11 years, 7 months ago.]
                • I really like the
                  [[*template=`1`:then=`[[*eventdate]]`:else=`[[+eventdate]]`]]
                  idea! Is simple and quick to change.

                  Big thanks for your help! smiley
                    chsmedien - Digital Marketing Agency
                    MODX Professional & Ambassador

                    http://chsmedien.com | http://twitter.com/christianseel
                  • Just for others who read this... of course it needs to be:
                    [[*template:is=`1`:then=`[[*eventdate]]`:else=`[[+eventdate]]`]]
                      chsmedien - Digital Marketing Agency
                      MODX Professional & Ambassador

                      http://chsmedien.com | http://twitter.com/christianseel
                      • 36926
                      • 701 Posts
                      Opps yeah my mistake, was writing from memory. I've change original comment with correct syntax.