We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 594
    • 15 Posts
    I’ve tried searching the forums for this, and either I just didn’t look hard enough, or I’m still tired. So here’s the deal:

    I’m trying to write a conditional snippet that will hide a TV’s output if it is left empty, but will show it if there is content entered into it. I spent a good while trying to figure out all the stuff in the TV API functions, but no luck whatsoever. I’ve had a hard time trying to figure out exactly how the TV functions work, but no cigar yet. If anyone can help by showing me a way to conditionally show/hide a TV, please let me know. Thanks a million!
      Top Dead Center Design, LLC
      Design, Develop, Manage
      http://tdcdesign.com/
      • 594
      • 15 Posts
      Nevermind, I figured it out.
        Top Dead Center Design, LLC
        Design, Develop, Manage
        http://tdcdesign.com/
        • 18397
        • 3,250 Posts
        If a tv is left blank then the output will be bank. But, I’m assuming you are talking about hiding more than the just the tv. So here is an example (not using the API):

        $tbl = $modx->getFullTableName('site_tmplvar_contentvalues');
        $id = $modx->documentObject['id'];
        $tv = $modx->db->getValue('SELECT `value` FROM '.$tbl.' WHERE `tmplvarid` = IDOFTEMPLATE VARIABLE AND `contentid` = '.$id .'');
        
          • 6726
          • 7,075 Posts
          Quote from: afkuz at Nov 16, 2005, 03:50 PM

          Nevermind, I figured it out.

          When you do, it’s cool to tell us how, so that we don’t struggle ourselves smiley

          More on the topic : it’s good to know
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l'outil id
            • 32241
            • 1,495 Posts
            Quote from: Mark at Nov 16, 2005, 04:06 PM

            If a tv is left blank then the output will be bank. But, I’m assuming you are talking about hiding more than the just the tv. So here is an example (not using the API):

            $tbl = $modx->getFullTableName('site_tmplvar_contentvalues');
            $id = $modx->documentObject['id'];
            $tv = $modx->db->getValue('SELECT `value` FROM '.$tbl.' WHERE `tmplvarid` = IDOFTEMPLATE VARIABLE AND `contentid` = '.$id .'');
            


            What is the IDOFTEMPLATE VARIABLE did in MySql syntax? Never heard that kinda syntax yet.

            As far as I understand, the getFullTableName will append the right prefix to the table name, right? Same thing with documentObject, but where should I use this code? I mean, is it snippets or what? I’m really new, but I’m interested in learning more.

            If I setup a TV to a template, can I use snippet to access the TV, like the one shown in the quote? Is it possible to modify it and apply some logic come up with something, instead of using widget? Or is it hard and possible to make a widget?

            Thanks in advance for every reply.

            Sincerely,
            Wendy Novianto
              Wendy Novianto
              [font=Verdana]PT DJAMOER Technology Media
              [font=Verdana]Xituz Media
            • Quote from: wendy at Nov 19, 2005, 05:34 AM

              What is the IDOFTEMPLATE VARIABLE did in MySql syntax? Never heard that kinda syntax yet.

              You would replace that with the actual ID of the template variable in question.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 32241
                • 1,495 Posts
                Thanks,

                I really never thought of that. All I need to do is call this on a snippets right? Is it possible to call it using plugin? In which event that it’s possible to use this? I mean, the first event is oninit right?, so does the document id had been setup during that time? I saw a plugin for redirecting user based on domain/subdomain to a different doc/dir id as set by the default. From what I can see on that plugin, the event oninit had already contain documentid, am I right?

                Can I still make my own widget? Or is it restricted as being build inside the core system?

                One other thing, this might not be related to the topic, why modX CMS being called as Tech Preview, and when it was released it’s being called TP3.3 or modX CMS 9.0. Which one should I follow, if somebody don’t mind explaining it in detailed about the naming and versioning style in modX for me.

                Thank you
                  Wendy Novianto
                  [font=Verdana]PT DJAMOER Technology Media
                  [font=Verdana]Xituz Media
                  • 34162
                  • 1 Posts
                  It was a Tech Preview then it was released as MODx 0.9 and going forward it will be 0.9.x then 1.0 etc.