We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38141
    • 7 Posts
    F.e. I have a string
    <meta name="keywords" content="[[*keywords]]" />

    in my header chunk. How to make a condition to show this string only if content is not empty?
    Same for description
    <meta name="description" content="[[*description]]" />

    Btw if it's matters description is a basic description field and keywords is custom TV parameter.
      • 3109 ☆ A M B ☆
      • 894 Posts
      Try using

      
      <meta name="keywords" content="[[*keywords:default=`[[*content]]`]]" />
      
      


      What this does is if the keywords TV is empty it will use the content TV as its value.

      You can do this TV's, Placeholders and System/Context Settings as well.

      Hope that helps. [ed. note: benmarte last edited this post 14 years, 7 months ago.]
        Benjamin Marte
        Interactive Media Developer
        Follow Me on Twitter | Visit my site | Learn MODX
        • 1343 ☆ A M B ☆
        • 2,213 Posts
        You might be better of with something like:

        [[*keywords:notempty=`<meta name="keywords" content="[[*keywords]]" />`]]

        This would hide the keywords meta if none are present vs dumping the content into the keywords field which may hurt more than it helps.

        If you look at MetaX 2.0 it takes an approach more along these lines.
          Patrick | Server Wrangler
          About Me: Website | Tweets |  MODX Hosting
          • 38141
          • 7 Posts
          I want to show metatag if field is not empty and show nothing if field has no content.
          PHP analogue
          <?php
          if (!empty($keywords)) {
          	echo '<meta name="keywords" content="'.$keywords.'" />';
          }
          ?>