We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36926
    • 701 Posts
    Hi I need to check if two TV have a certain value, how do i do this with a phx call.

    I’m trying

    [*phx:if=`[*TV1*]`:is=`1`:and `[*TV2*]`:is=`2`:then=`yes`:else=`no`*] 
    

    Also tried
    [*TV1:is=`1`:and `[*TV2*]`:is=`2`:then=`yes`:else=`no`*] 
    


    But no joy, it always outputs the else value.

    I’m guessing i’m getting the syntax wrong. Any help.

    Thanks

    Ben
      • 5340
      • 1,624 Posts
      I’m not sure Phx works like that.

      Try to split the call into

      [*phx:if=`[*TV1*]`:is=`1`:then=`
      
      
           [*phx:if=`[*TV2*]`:is=`2`:then=`A1`:else=`A2`*] 
      
      
      `:else=`A3`*] 


        • 36926
        • 701 Posts
        Quote from: cipa at Sep 27, 2009, 05:53 PM



        [*phx:if=`[*TV1*]`:is=`1`:then=`
        
        
             [*phx:if=`[*TV2*]`:is=`2`:then=`A1`:else=`A2`*] 
        
        
        `:else=`A3`*] 




        Thanks alot cipa, this worked. But it did make me think maybe i should be doing stuff like this directly with php. And thought it could be a good opportunity to experiment and try and learn the modx API, something i feel i should do to take my modxing to the next level. Anyone one have an good links to help with learning the API other than the wiki as would like to see some real life examples of whats doing what. Found getting the doc id easy enough but got stuck on getting pulling out a TV value from the current document. I know not a great start.

        Ben
          • 20413
          • 2,877 Posts
          The best way of learning the API IMO is to watch the code of existing add-ons and see how they do it!

          You can’t use and `something` but you can use and:if=`something` / and:ne=`something` ...etc.
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • 4310
            • 2,310 Posts
            Here’s a quick and simple example of a snippet retrieving the value of a TV for the current document :
            $tv = $modx->getTemplateVarOutput(true, $modx->documentIdentifier);
            $value=$tv['NameOfTV'];
            return $value;

            NameOfTV should be replaced with your TV’s name wink
              • 36926
              • 701 Posts
              Quote from: mrhaw at Sep 27, 2009, 09:30 PM

              The best way of learning the API IMO is to watch the code of existing add-ons and see how they do it!

              You can’t use and `something` but you can use and:if=`something` / and:ne=`something` ...etc.

              Thanks mrhaw for the and:if tip. I’ve been checking out some existing add-ons but they seem pretty complex so working out whats doing what is proving tricky, but slowly getting there.


              Quote from: bunk58 at Sep 27, 2009, 09:33 PM

              Here’s a quick and simple example of a snippet retrieving the value of a TV for the current document :
              $tv = $modx->getTemplateVarOutput(true, $modx->documentIdentifier);
              $value=$tv['NameOfTV'];
              return $value;

              NameOfTV should be replaced with your TV’s name wink

              Thanks Bunk, this is helpful.

              Also the understanding document object page that is referenced throughout the wiki is giving me a 404, has this moved?
              http://modxcms.com/the-document-object.html

              Thanks again

              Ben
                • 20413
                • 2,877 Posts
                  @hawproductions | http://mrhaw.com/

                  Infograph: MODX Advanced Install in 7 steps:
                  http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                  Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                  http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower