We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I’m not even gonna try to mask this: I’m questioning the legitimacy of this plugin. What can this plugin do that can’t be done in a more sustainable (and architecturally sound) way using other plugins, TVs, or Snippets?

    In my opinion, one of the strongest points of MODx architecturally speaking is its use of templates. The templates contain no logic, so they can’t break. This not true with many other CMS’s -- most CMS’s put loops and if statements and actual code in their templates (!!!) making it MUCH easier to breaks things and MUCH easier to destroy any illusion of separation between display and logic.

    I’ve cleaned up enough badly codes sites (most of them were not MODx sites) where logic had crept into the display layers, or where display chunks were strewn throughout the logic portions of the code. In short, that approach destroys the site’s maintainability... in a word, it kills everything that’s good about the MVC architecture pattern.

    Now, I think there probably are some legitimate uses for PHx, but after looking through a number of sites that use it, I think it’s just too easily abused. It’s like crack cocaine: it’s simple, it’s easily used, but in the end it destroys you.

    Whereas before your template was something simple like
    <html>
    [*content*]
    </html>


    with maybe a few Template Variables, with PHx, that simple content becomes a dizzing mess of if/elses. In short, it’s a mess. No designer wants to touch the template anymore because it’s got code in it. No coders want to touch it because it’s got HTML/CSS in it. It’s the worst of both worlds.

    I might get flamed for this post, but I’m standing my ground: destroying the MVC pattern destroys a site’s maintainability, and PHx lets you do that far too easily. Use it with extreme caution.
      • 28215
      • 4,149 Posts
      Agreed. Logic functionality should be done in the controllers, not the view.

      PHx is only good for formatting constraints; the logic filters cause more problems than they fix.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
      • I do believe that originally its intent was to format placeholder output. Then it sort of got out of control. I’ve only used it to limit Ditto placeholder output. I spend enough time learning about PHP and MySQL without learning another custom scripting language, which is what this has become. Much of what I see in the forums about its use should be handled in the database query or the initial processing of the result set.
          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
        • Simple snippets to control logic are indeed the preferred form, but as noted you can do it with PHx. PHx filters and formatting however are great.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • I’ve bent PHx into some interesting shapes from a lack of programming knowledge but would entirely agree that a snippet is far more efficient and ideal for conditional heavy lifting.

              Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. BlogTwitterLinkedInGitHub
            • Amen brother Everett. I have been preaching about keeping logic out of the presentation layer since PHx was first introduced. Nice to have some supporting words of wisdom from another perspective.

              Cheers!
                • 34017
                • 898 Posts
                I agree that business logic should stay out of the views. However, simple if/else seems valid in views.

                Simple if/else gives the designer the ability to say if logged in ’show username’, else ’show register box’. I think this is very reasonable and handy for designers.
                  Chuck the Trukk
                  ProWebscape.com :: Nashville-WebDesign.com
                  - - - - - - - -
                  What are TV's? Here's some info below.
                  http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
                  http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
                • Sure, but it still should be a snippet however, like any other logic in MODx, and not bloating the core of the product on every request. A simple If snippet is a very simple and handy thing; I’ll release the one I wrote for Revolution today as an example...
                    • 27330
                    • 884 Posts
                    I agree with the concept of keeping design separated from logic but since I don’t know how to code I find phx as the #1 coder-wanna-be alternative for custom snippets.
                      • 34017
                      • 898 Posts
                      We can kindly disagree here. I feel simple if/else and formatting items are very helpful for practical development. I think Django templating is almost perfect as an example- which is why i use h2o for most of my templating needs.
                        Chuck the Trukk
                        ProWebscape.com :: Nashville-WebDesign.com
                        - - - - - - - -
                        What are TV's? Here's some info below.
                        http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
                        http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008