We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49354
    • 2 Posts
    Hello I am new in the modx. I want to ask how can I check whether the TV element is empty or not. Means whether admin enters in any value in TV element or not because on front end I want to check whether this TV is empty or not.

    I also want to ask where to use that code or script which anyone here will share.

    Here is my chunk code:
    <script>
      var tag = document.createElement('script');
      tag.src = "http://www.youtube.com/player_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
      var player;
      function onYouTubePlayerAPIReady() {
    	player = new YT.Player('video', {
    	  playerVars: { 'autoplay': 1, 'controls': 1,'autohide':1,'wmode':'opaque' },
    	  videoId: '[[*video]]',
    	  events: {
    		'onReady': onPlayerReady}
    	});
      }
    
      function onPlayerReady(event) {
    	event.target.mute();
      }
    </script>
    <div id="video" style="float: left;margin-top: 10px;width:327px !important;height:200px !important;"><iframe width="327" height="200" src="//www.youtube.com/embed/[[*video]]" frameborder="0" allowfullscreen></iframe></div>


    I want to check if
    [[*video]]
    that is my dynamic TV element, is empty. So that above code will not execute.

    Please help.

    Thanks.

    This question has been answered by absent42. See the first response.

    • discuss.answer
      • 42046
      • 436 Posts
      You can use an output modifier:

      [[*video:notempty=`yourcode`]]
        • 49354
        • 2 Posts
        Thank You Dan. You are my man. This code really works for me. [ed. note: mohsin last edited this post 9 years, 5 months ago.]