We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20257
    • 39 Posts
    In a chunk I have this code:

    [tt]
    <h2>[+title+]</h2>
    <p><a href="[~[+id+]~]">[+template_img+]</a></p>
    <p class="se_html"><a onclick="window.open(this.href); return false;"href="[+html+]">se som HTML </a></p>
    [/tt]

    .... the last line ....href="[+html+]">se som HTML </a> give me some problems ..... sometimes there are no data in the [+html+] and then I like to hide the link ...... how do I do that?
      • 15082
      • 195 Posts
      Install PHx (http://wiki.modxcms.com/index.php/PHx) if you haven’t already.

      Use it like this:
      [+html:ne=``:then=`<a onclick="window.open(this.href); return false;"href="[+html+]">se som HTML </a>`:else=``+]


      Greetz
      JUSI
        • 20257
        • 39 Posts
        grin thanks a lot

        Can you show me how to do it with PHP?

        But again ..... thanks a lot grin
          • 15082
          • 195 Posts
          If you don’t want to use PHx, I think you can easily adopt the solution from here:
          http://modxcms.com/forums/index.php?topic=29031.0

          Greetz
          JUSI
            • 3749
            • 24,544 Posts

            Snippet (call it ShowLink):

            (untested code)
            [!ShowLink? &hLink=`[+myHtml+]` !]


            Snippet Code (untested):

            <?php
            if (empty($myHtml)) {
                $output = '';
            } else {
            
                $ouput = '<p class="se_html"><a onclick="window.open(this.href); return false;"href="' . $myHtml . '>se som HTML </a></p>';
            
            }
            return $output;
            ?>


            BTW, I would not use html as a placeholder name.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 20257
              • 39 Posts
              grin grin grin
              Thanks