We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29774
    • 386 Posts
    Sure thing! When I get a minute I’ll add them to the wiki.
      Snippets: GoogleMap | FileDetails | Related Plugin: SSL
      • 20289
      • 958 Posts
      therebechips, Nice trick.
        [img]http://i10.tinypic.com/52c4eir.gif[/img][/td]
        [td][Wiki] [Persian support forum]
        [SVN] [RTL SVN Branch] [bugs] [FishEye+Crucible] [Learn MODx!] | [My Google Code]
        [font=tahoma][برای دسترسی به راهنمای فارسی به [url=http://www.modxcms.ir]
      • Before MODx I was doing everything from scratch in PHP. It’s common practice to have a file which contains system settings, which is included into every page of the site. It would contain system-level stuff like database connection info, SMTP server connection info, paths to libraries but also application-level stuff like destination email addresses or how many photos to show on a gallery page and so on.

        MODx system-level settings are already in a file of course. I wouldn’t want to hack that file to add my application-level stuff, so I was looking for a place to put these settings that would make them easy to edit and easy to utilize.

        Evolution.

        The solution I have ended up using in Evolution is simple. It’s a plugin where I just create placeholders which act as the settings I need in my application.
        An example:

        $e = &$modx->Event;
        switch ($e->name) {
                // don't forget to check off OnWebPageInit in the System Events tab
        	case 'OnWebPageInit':
        
        		// how many articles to summarize on News Index pages?
        		$modx->setPlaceholder('numNewsIndexSummaries', 5);
        		// how many articles to summarize per page on News Archive pages?
        		$modx->setPlaceholder('numNewsArchiveSummaries', 10);
        
        		// rss
        		$modx->setPlaceholder('numRSS', 20);
        
        		// email
        		$modx->setPlaceholder('someoneToSendSpamTo', '[email protected]');
        
        		break;
        }
        


        Then, say I have a Ditto call in the site that summarizes news articles on an archives page, I can just do this:
        [[Ditto? &extenders=`request,dateFilter` &start=`[+numNewsIndexSummaries+]` &summarize=`[+numNewsArchiveSummaries+]` ...
        


        It may not appear all that useful at first, until you have 11 unique Ditto calls sharing certain parameters, but differing in other ways. Then it’s a lifesaver when it comes to testing and implementation activities.

        Revolution.

        In Revolution, it’s already baked in! Context Settings. Right-click on your context (e.g. web) and select Edit Context. In the Context Settings grid, click Create New and you’re on your way. The "Key" is what determines the modx tag name, and Value is obvious.

        To "migrate" my above Evo plugin/placeholder settings, I would just create Context Settings with keys like numNewsIndexSummaries, numNewsArchiveSummaries and so on, and give them the values that I want. Happily, Revo’s new tag syntax makes using these settings a no-brainer:
        [[Ditto? &extenders=`request,dateFilter` &start=`[++numNewsIndexSummaries]` &summarize=`[++numNewsArchiveSummaries]` ...
        




        Examples used in this post are fictional. Any similarities to actual persons, places or things is purely coincidental.
          Mike Schell
          Lead Developer, MODX Cloud
          Email: [email protected]
          GitHub: https://github.com/netProphET/
          Twitter: @mkschell
          • 20413
          • 2,877 Posts
          Ay Caramba!! cool That is coool, I’ve been doing this: http://modxcms.com/forums/index.php/topic,30626.0.html
          Now there is 2 ways of being a modx super-admin! smiley

          ...or 3 ways!? http://modxcms.com/forums/index.php/topic,42802.0.html
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
          • Doh - Revolution has user-defined System Settings as well. System menu > System Settings. This is better if you want a setting to apply throughout an entire site, in all Contexts, as a Context Setting only applies to one Context.
              Mike Schell
              Lead Developer, MODX Cloud
              Email: [email protected]
              GitHub: https://github.com/netProphET/
              Twitter: @mkschell
            • An AJAX tip:
              MODx evals snippet while creating document output, so if a snippet breaks all PHP actions and leave the MODx parser, nothing will be returned.
              I create my ajax scripts as a snippet, call it in page but use echo to return data AND use exit at the end of codes to return. "echo" takes data to javascript and "exit" leaves MODx parser and doesn’t allow MODx to change the page.

              For custom ajax scripts, this way is better than creating a blank document.
              In that way, you should modify the js codes for each MODx site because the ID of blank page will changed.
                God loves me. 【ツ】


                MODX.ir (Persian Support)

                Boplo.ir/modx/ (Persian)
                • 9130
                • 171 Posts
                Quote from: AHHP at Mar 19, 2009, 11:23 PM

                An AJAX tip:
                MODx evals snippet while creating document output, so if a snippet breaks all PHP actions and leave the MODx parser, nothing will be returned.
                I create my ajax scripts as a snippet, call it in page but use echo to return data AND use exit at the end of codes to return. "echo" takes data to javascript and "exit" leaves MODx parser and doesn’t allow MODx to change the page.

                For custom ajax scripts, this way is better than creating a blank document.
                In that way, you should modify the js codes for each MODx site because the ID of blank page will changed.
                If the ajax snippet(s) are on page, how do you call them from js and how do you prevent them from breaking the page when you want the page to be rendered?
                • I run ajax actions by a special query like &ajax. so check for this query and then run script.
                  if($_GET['ajax'] == 1)
                  {
                       .....
                  }


                  The snippet has called on current page so js should call current page url:
                  httpRequest.open("GET", document.URL + "&ajax=1", true);
                    God loves me. 【ツ】


                    MODX.ir (Persian Support)

                    Boplo.ir/modx/ (Persian)
                    • 3604
                    • 13 Posts
                    I’m not sure if this is all too unique, but I use chunks in my templates, for easy editing, and if its a site with multiple themes available for it, I go even further, and use a template variable with @ Bindings to reference several different choices for chunks.

                    For example, for the content chunk, I could make it a template variable that can either reference a 1, 2 or 3 column layout, by referencing chunks via @ Bindings.

                    This is also useful for making it possible to switch the stylesheet on one theme - simply put a TV in where the stylesheet is linked, and make it a dropdown referencing a few different choices.
                      • 20413
                      • 2,877 Posts
                      This is why MODx rocks! smiley

                      You can be=`superCreative` and have it setup exactly as how you want it! Then Ka-boom you install
                      ManagerManager --> shocked --> kiss

                      //EDIT
                      This might need to be added here: http://modxcms.com/forums/index.php/topic,5814.msg232384.html#msg232384
                        @hawproductions | http://mrhaw.com/

                        Infograph: MODX Advanced Install in 7 steps:
                        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower