We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22815
    • 1,097 Posts
    It means by end Sunday, or basically within 34 hours of the datestamp of this post, so an internal RC on Monday would be ace.

    The template switcher - personally I think it’s a confusing feature. I believe that the intention is that it’s per visitor, but it doesn’t work with caching at all, which is why there was the "disable caching" plugin. Personally I feel the clearer solution is to take out the template switcher and just have a page for each example template.
      No, I don't know what OpenGeek's saying half the time either.
      MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
      Forum: Where to post threads about add-ons | Forum Rules
      Like MODx? donate (and/or share your resources)
      Like me? See my Amazon wishlist
      MODx "Most Promising CMS" - so appropriate!
      • 25663 MODX Staff
      • 12,272 Posts
      Quote from: PaulGregory at Oct 28, 2006, 08:46 AM

      It means by end Sunday, or basically within 34 hours of the datestamp of this post, so an internal RC on Monday would be ace.

      The template switcher - personally I think it’s a confusing feature. I believe that the intention is that it’s per visitor, but it doesn’t work with caching at all, which is why there was the "disable caching" plugin. Personally I feel the clearer solution is to take out the template switcher and just have a page for each example template.
      I completely agree with that. This should be revisited in the future and implemented properly.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 25663 MODX Staff
        • 12,272 Posts
        File Manager vs Resource Browser (MCPuck or whatever it’s called)
        I was looking at the Configuration Screens, and am not clear on the organization between the Interface & Editor page and the Resource Browser (or is it Manager if you read the description ... or does it refer to File Mangager). I’m thinking we should split the Resource Browser (MCPUCK) to a different page, and the File Manager to the Interface Page ... and make it really clear in the description what the differences are.

        Revisiting it, I think we just need to update the order of the options (file manager types are co-mingled with the Resource Browser Types. Which one does the file upload size apply to? We might also need to rearrange the last two tabs a bit under Configuration.

        Thoughts?


        1854
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Yes, setting the "cacheable" to 0 is necessary to keep a cache file with this template from being saved, but it also needs to delete any existing cache files for this document before the parser goes looking for it.
            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
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            The "Resource Browser" (mcpuck or whatever it’s called) is connected to the RTE. If it were a stand-alone feature, I could see your point. But as it is, it’s a totally separate thing from the MODx File Manager. I think the Resource browser should stay right where it is, along with its configuration. Perhaps the wording could be changed to make it clearer exactly what it is.

            update: committed 1854
              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
              • 30223
              • 1,010 Posts
              I just noticed a styling bug where the system alert DIV is only partly visible in manager, but I couldn’t really find where the cause is. Have filed the details in the bug tracker (#620).

              Easily reproduced - for example:
              1. Creating a php error in a plugin and set theOnSnipFormRender
              2. Edit any snippet.

              (tested in IE and FF)


              Fixed and in SVN near 1852
                • 10487 MODX Staff
                • 1,535 Posts
                Quote from: rthrash at Oct 28, 2006, 08:28 AM

                I don’t actually understand what the point of "Close Doc Manager" is. No other screen has this, although they do have "Cancel". In other screens, "Cancel" takes you to home/welcome page (although Polls Module goes to the Manage Modules screen). So, it would seem that the most consistent thing is "Cancel" > home/welcome.
                Fair enough and convinced. Let’s make it consistent across the board though... and remove the close button if possible (but there may be a reason for it?).
                The reason it says ’Close’ and not ’Cancel’ is that there are parts of the Doc Manager where ’Cancel’ would indicate going back a step (ie. when sorting the menu) and not exiting the module. And, going back to ’Manage Modules’ page is consistent with such processes such as editing a snippet or plugin and being returned to the ’Manage Resources’ page.

                Feel free to make the change but I’m not convinced and won’t be making the change myself.

                Quote from: sottwell at Oct 28, 2006, 09:19 AM

                Yes, setting the "cacheable" to 0 is necessary to keep a cache file with this template from being saved, but it also needs to delete any existing cache files for this document before the parser goes looking for it.
                If there were cache files present, yes, the plugin would need to nuke ’em before running. But, from what I can tell, in all instances of this plugin running there are no pageCache files that need nuking - if running after an install, the cache is regenerated meaning there would be no pageCache files and if manually activating at a later date, then the cache is cleared on the plugin changes being saved.

                So, with no cache files and the plugin disabling any pages affected by the plugin from being saved - there are no worries about pages being pulled from the cache.

                But, if we’re looking for a double insurance policy on this, then here’s a quick change to the plugin that I’ve done that will nuke any existing pageCache file when the page is called - it needs to run off the ’OnWebPageInit’ event as well as the ’OnLoadWebDocument’ event.

                // TemplateSwitcher - plugin for MODx
                // [email protected]
                // released to the Public Domain
                // uses OnLoadWebDocument event
                // stores template choice in cookie
                // add the usecookie argument to the Configuration
                // &usecookie=Use Cookie;list;no,yes;no
                // default is 'no'
                // set Configuration to 'yes' to use cookie
                // place an HTML comment <!-- donotswitch --> in the content of pages you don't want switched
                // add template=templatename to the URL
                
                if (!function_exists('clearDocCache')) {
                	function clearDocCache($docId) {
                		global $modx;
                		$basepath = $modx->config["base_path"] . "assets/cache";
                		if (@ $handle = opendir($basepath)) {
                			while (false !== ($file = readdir($handle))) {
                				if ($file != "." && $file != "..") {
                					if (preg_match("/docid_" . $docId . "\.pageCache\.php/", $file)) {
                						unlink($basepath . "/" . $file);
                					}
                				}
                			}
                			closedir($handle);
                			return true;
                		} else {
                			return false;
                		}
                	}
                }
                
                // Get a reference to the event
                $e = & $modx->Event;
                
                // Event Actions
                switch ($e->name) {
                	case 'OnWebPageInit' :
                		clearDocCache($modx->documentIdentifier);
                		break;
                	case 'OnLoadWebDocument' :
                		if (!strstr($modx->documentContent, "donotswitch")) { // this page is not switchable
                			$modx->documentObject['cacheable'] = 0;
                			if (isset ($_GET['template'])) {
                				$overrideTemplate = $_GET['template'];
                			} else
                				if (isset ($_COOKIE['template']) && $usecookie == 'yes') {
                					$overrideTemplate = $_COOKIE['template'];
                				}
                			if (isset ($overrideTemplate)) {
                				$table = $modx->getFullTableName("site_templates");
                				$result = $modx->db->select("id, content", $table, "templatename = '" . $overrideTemplate . "'");
                				if ($modx->db->getRecordCount($result) == 1) {
                					$row = $modx->db->getRow($result);
                					$modx->documentObject['template'] = $row['id'];
                					$modx->documentContent = $row['content'];
                				} else {
                					$this->messageQuit("Error retrieving template.");
                				}
                				if ($usecookie == 'yes') {
                					setcookie("template", $overrideTemplate, time() + 604800, "/", "", 0);
                				}
                			}
                		} // end if page is switchable
                		break;
                	default :
                		break;
                }
                
                  Garry Nutting
                  Senior Developer
                  MODX, LLC

                  Email: [email protected]
                  Twitter: @garryn
                  Web: modx.com
                  • 33337
                  • 3,975 Posts
                  Quote from: garryn at Oct 28, 2006, 02:20 PM

                  Quote from: rthrash at Oct 28, 2006, 08:28 AM

                  I don’t actually understand what the point of "Close Doc Manager" is. No other screen has this, although they do have "Cancel". In other screens, "Cancel" takes you to home/welcome page (although Polls Module goes to the Manage Modules screen). So, it would seem that the most consistent thing is "Cancel" > home/welcome.
                  Fair enough and convinced. Let’s make it consistent across the board though... and remove the close button if possible (but there may be a reason for it?).
                  The reason it says ’Close’ and not ’Cancel’ is that there are parts of the Doc Manager where ’Cancel’ would indicate going back a step (ie. when sorting the menu) and not exiting the module. And, going back to ’Manage Modules’ page is consistent with such processes such as editing a snippet or plugin and being returned to the ’Manage Resources’ page.

                  Feel free to make the change but I’m not convinced and won’t be making the change myself.

                  Garry, since I raised the issue.. well actually a suggestion, but your point is valid IMO. Thanks for clarification.

                  regards.

                  zi

                    Zaigham R - MODX Professional | Skype | Email | Twitter

                    Digging the interwebs for #MODX gems and bringing it to you. modx.link
                    • 22303 MODX Staff
                    • 10,725 Posts
                    Quote from: PaulGregory at Oct 28, 2006, 08:06 AM

                    Getting template switching to work would be very very cool. This is a very MODx thing. It would also make it easier to have a parallel mobile/PSP/webTV site from the same document data.

                    But the caching is also crucial to MODx. So... simple idea.. don’t know how easy it is to code, but it seems the logical solution:

                    Change the caching to save out on a per-document AND per-template basis. Parser looks for a cached version of that document/template combination; if it’s there, uses it, if it’s not, parses and saves. Simple. Logical. What people might expect. I can’t really see any point expending energy on any bundled solution that isn’t this.

                    (I know that’s a fairly major change to the core, but it would open up a few things, not least simplifying my upcoming PDF plugin).
                    Here’s a couple of ideas of how we can proceed with making a proper template switcher without any changes to the core, in current or development versions...

                    [*] (possible now) Use the OnLoadWebPageCache event with the TemplateSwitcher plugin to replace the $modx->documentContent with that of the requested template; this will handle cases where it is cached with a particular template, though it would be good to make sure somehow that the default template is the only one that gets cached (this should also be easily doable by watching the OnBeforeSaveWebPageCache event).
                    [*] (possible in 0.9.7) Make use of the new idea of contexts. A resource/document can exist in many contexts and a simple plugin can auto-determine a context by session, user preferences, and/or request parameter. You could use a context to represent each switchable template and use a variation of the next technique except the snippet call would not have to be non-cacheable, since each context has it’s own cache.
                    [*] (possible now) Create a template that simply pulls in content from another template via a non-cacheable snippet. Then use this template for any resource that would be switchable.

                    I don’t think deleting the cache file is a proper solution. Might as well disable the cache...
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      @rthrash: I don’t follow you. In the Interface and Editor tab, you have all the settings for the Resource Browser and the Rich Text editors. Then in the File Manager tab you have all the settings for File manager. Did I miss something along the way?

                      [Edit] Ah, I see your point, in the File Manager tab the explanations of the various file types refer to the Resource Manager (Browser?)! Yes, this is confusing.


                      update: fixed as of 1854-ish
                        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

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