We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2762
    • 1,198 Posts
    Quote from: bS at Oct 24, 2006, 10:52 PM

    ...
    (Be sure to read the wiki on PHx about how to use the modifiers in templates that are internally processed by a snippet.)

    mmm... there are not modifiers in Ditto template, only paginate placeholders (next, previous..) doesn’t works , all other ditto placeholders (author, date..) works.
    Quote from: bS at Oct 24, 2006, 11:22 PM

    i did have the placeholder issue with 1.4.1 but 1.4.2 fixed it for both Ditto 1.02 and 1.1.
    At first load i didn;t see the placeholders also but I needed to empty the cache (depends on how you call Ditto) and after that it worked fine.

    empty cache and uncached pages, but still remain the issue with Dito 1.1 , I will try it again with another test site with ditto 1.1 and investigate to confirm paginate issue, now it’s too late (1:25 a.m in Italy) and I ’m very tired ..sorry smiley

    thanks again for your cool plugin wink
      Free MODx Graphic resources and Templates www.tattoocms.it
      -----------------------------------------------------

      MODx IT  www.modx.it
      -----------------------------------------------------

      bubuna.com - Web & Multimedia Design
      • 16732
      • 592 Posts
      Hi,

      I think that PHx will save my life in a lot of case but for the moment I have a problem to use it.

      I have an "imgnews" TV (file type) linked to my template and I want to put an <a> tag only when my "imgnews" TV is not empty.
      To pass the TV content to the <a> tag I have created a "LinkToFile" snippet
      return  <a href="'.$link.'">Dowload the file</a>';
      


      Now, when I put this in my template :
       [*imgnews:isnot=``:then=`[!LinkToFile? &link=`[*imgnews*]`!]`*]
      


      I have this result : see picture


      Could you help me to understand how to use this great plugin?

      Thanks

      PS: sorry for my poor english... I’m just a litle froggie wink
        • 4195
        • 398 Posts
        be sure your snippet looks like
        return '<a href="'.$link.'">Dowload the file</a>';
        


        NOTICE THE STARTING: your forgot that in your code wink
          Armand Pondman
          MODx Coding Team
          :: Jot :: PHx
          • 16732
          • 592 Posts
          Hi bs,
          Thanks for your answer, I only forgot the ’ in the forum post but not in my snippet... Could you confirm me that
          [*imgnews:isnot=``:then=`[!LinkToFile? &link=`[*imgnews*]`!]`*]

          is a valid code and that the Phx parser test the imgnews TV value and if it’s not empty call the LinkToFile snippet with the link parameter set to the imgnews value?

          I’m wondering if the second [*imgnews*] tag is well understood by the parser

            • 4195
            • 398 Posts
            this works

            [*imgvar:isnot=``:then=`[[LinkToFile? &link=`[*imgvar:*]`]]`*]
            


            notice the : behind the name ...

            this shouldn’t be necesary but i’ll will search for the error now.
              Armand Pondman
              MODx Coding Team
              :: Jot :: PHx
              • 4195
              • 398 Posts
              Another working solution is to create a custom modifier.
              Create a snippet with the following code:

              $linktext = ($options!='') ? $options : 'Download File';
              return  '<a href="'.$output.'">' . $linktext. '</a>';
              


              name it:phx:link or any other name you want (leaving the phx: as a prefix of the snippet name)

              you can now use

              [*imgvar:isnt:then=`[*imgvar:link*]`*]
              


              or any other link text if supplied like:

              [*imgvar:isnt:then=`[*imgvar:link=`My other link text`*]`*]
              


              you can also omit the =’’ after isnt cause the default value is ’’ wink
                Armand Pondman
                MODx Coding Team
                :: Jot :: PHx
                • 4195
                • 398 Posts
                Quote from: laurentc at Oct 27, 2006, 10:44 PM

                I’m wondering if the second [*imgnews*] tag is well understood by the parser

                AS i see it now the MODx parser gets first pick and replaces

                [*imgnews:isnot=``:then=`[!LinkToFile? &link=`[*imgnews*]`!]`*]

                after this the string is crippled like in your screenshot wink

                so actually it’s a little regexp ’error’ in the modx document parser.
                so use : behind the name to make sure PHx takes care of the replacements.
                  Armand Pondman
                  MODx Coding Team
                  :: Jot :: PHx
                  • 16732
                  • 592 Posts
                  Thanks for all your explanations .... I will try all of this and make you returns.

                  An other time thanks for this great plugin... I think I will use it quite a lot now grin
                    • 18436
                    • 135 Posts
                    I’ve just installed PHx 1.4.4 and noticed that it’s causing havoc with tv parsing inside another snippet.
                    I set all my templates to include actual php files from the file system instead of straight html code in the form field.
                    I’ve been using a snippet called "includeFile" with the following code:

                    <?php
                    # For example to include cutenews, you can use
                    # [[includeFile?template=nicetemplate&phpfile=cutenews/show_news.php]].
                    # You can offcourse pass any variable to the snippet to use for the included file.
                    
                    if ( !isset($phpfile) || $phpfile == "" ) return "No file specified."; //check if there's a file given.
                    
                    //Start the buffer
                    ob_start();
                    
                    //include
                    require_once $phpfile;
                    
                    //get contents from the buffer
                    $ob_contents = ob_get_contents();
                    
                    //and kill/delete the buffer
                    ob_end_clean();
                    
                    //return it to MODX.
                    return $ob_contents;
                    ?>
                    


                    In my template definition I call the function as follows: [[includeFile?&phpfile=`[*volPath*]/template.php`]]

                    The reason for this is that I need the tv: volPath to be different when a new version of my site comes out as each volume (collection of issues) retains it’s look and feel. I also use php partials for things like navigation etc.

                    Since installing PHx the "[*volPath*]" tv no longer gets parsed by the includeFile snippet. Know of any way to get around this? If there’s a way to include_once a filename string that is generated using a tv please let me know!
                      • 4195
                      • 398 Posts
                      if PHx is enabled try:

                      [[includeFile?&phpfile=`[*volPath:*]/template.php`]]
                      


                      notice the : after volPath

                      this ensures PHx gets to do the parsing.
                        Armand Pondman
                        MODx Coding Team
                        :: Jot :: PHx

                      This discussion is closed to further replies. Keep calm and carry on.