We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5340
    • 1,624 Posts
    Hi,

    Is there a port of the Anchors Away plugin for Evo? http://modxcms.com/forums/index.php/topic,15753.20.html

    Thanks
      • 3749
      • 24,544 Posts
      I think it would just be a plugin with this code, tied to OnWebPagePrerender:


      <?php
      $output =& $modx->resource->_output;
      
      if($modx->resource->get('id')  != $modx->getOption('site_start') )  {
      
          $output = str_replace('href="#', 'href="' . $_SERVER['REQUEST_URI'] . '#', $output);
      
      }
      


      Let us know if it works. wink
        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
        • 5340
        • 1,624 Posts
        Hi Bob,

        I ended up with this:

        <?php
        
        /* 
        
        Anchors Away Plugin for MODX Revolution 
        Thanks to BobRay and OpenGeek
        
        Properties
        	
        	onTemplates [Texfield] [Comma separated list of template IDs] - property to specify the templates you want to run this plugin on
        
        System Events (please check)
        
        	OnWebPagePrerender
        
        */
        
        $output =& $modx->resource->_output;
        
        if($modx->resource->get('id')  != $modx->getOption('site_start') )  {
        
            if($onTemplates){
            	//configured templates
            	$ids = explode(',',$onTemplates);
            	
            	foreach($ids as $id){
        	    
        	    	if(intval(trim($id)) == $modx->resource->get('template')){
        	    		$output = str_replace('href="#', 'href="' . $_SERVER['REQUEST_URI'] . '#', $output);
        	    	}
        	    	
        	    }
        	    
            }else{
            	//all templates
            	$output = str_replace('href="#', 'href="' . $_SERVER['REQUEST_URI'] . '#', $output);
            	
            }
        
        }



        Looking to build this into my first MODx Revolution Package. Any pointers


        Thank you
          • 1343 ☆ A M B ☆
          • 2,213 Posts
          Cipa, check out Packman, it should do all the heavy lifting for you smiley
            Patrick | Server Wrangler
            About Me: Website | Tweets |  MODX Hosting
            • 3749
            • 24,544 Posts
            Nice. cool (You might change my name to BobRay, since there are a lot of Bobs around wink ).

            If the package will be more extensive, you might want to look at MyComponent: https://github.com/BobRay/MyComponent.

            It’s designed so that you can modify it to make your own build script and handles almost everything you might want to do. It’s serious overkill, though, if the package will just contain the one plugin.

            It should be released soon as the GetMyComponent package.
              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
              • 5340
              • 1,624 Posts
              I tried PackMan, I have a package. Now what?
              Solved. -> Uploading the file manually to core/packages/, and then clicking "Add New Package" and selecting the "Search Locally for Packages" option

              Does PackMan get the property sets or do I have to do it manually?

              It does


              To BobRay: What are the main differences between PackMan and MyComponent

              Thanks
                • 5340
                • 1,624 Posts
                For anyone interested in this go to https://github.com/Cipa/AnchorsAway
                Until this is moved to the official repository I provided dual install instruction.
                  • 3749
                  • 24,544 Posts
                  Quote from: cipa at Feb 17, 2011, 08:12 AM

                  To BobRay: What are the main differences between PackMan and MyComponent

                  PackMan is a quick way to package up existing components that are already installed on a MODx site. It’s great for simple snippets, templates, and plugins, but for more complex packages, you run into its limitations. All your resources and elements are in the DB so you have to edit them in the Manager (or cut and paste them from a code editor) and there’s no way to put them up at GitHub as files or use version control on them. It doesn’t do resources or custom manager pages and there’s no way to create or set system settings or set properties based on the user’s environment. At present, it doesn’t include changelogs and there’s no way to interact with the user during the install or run validators before the install or resolvers afterwards. You also can’t control what happens when a user upgrades or uninstalls the component. It’s also cumbersome to internationalize the component with language strings for messages and for property descriptions, though it can be done. So it limits the ways you can improve your add-on, and if the add-on changes over time, it can make it difficult to work on it.

                  As an example, the SPForm install asks the user for their email address and lets them determine if they want the contact resource installed or not. The latest version moves the banlist from a file to a chunk, and for users who are upgrading, it backs up their banlist file, copies its contents to the chunk, and deletes the banlist file. During the install, SPForm properties are set for the email and for the IDs of the newly created Contact and Thank You pages. For another example, the Captcha package install checks for the necessary GD and FreeType functions and aborts the install with a message to the user if they’re not there. None of that could be done with PackMan.

                  MyComponent is a monster package with over 70 files that has examples of almost everything you might want to do in a build script. As installed, its build script will create a full transport package that creates snippets, chunks, resources, plugins, plugin events, template variables, templates, resources, system settings, properties, other packages, etc. -- all with appropriate language strings -- and it copies files to both the core/components/mycomponent and assets/components/mycomponent directories. It connects the plugin events to their plugins and the template variables to their templates. It also includes readme.txt, changelog.txt, and license.text files in the package and includes a readme.md file for GitHub.

                  Best of all, it’s designed so that you can plug your own code in in the existing files, rename them, set variables to exclude the stuff you don’t need, do some global search-and-replace operations, and build your own package.

                  None of this is meant to discredit PackMan, which is a really impressive add-on that allows people, even those with limited skills, to create transport packages for Revolution.
                    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