We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    Snippet cached perhaps?
      • 14536
      • 22 Posts
      Snippet:
      [!MoxieCart? &type=`show` &display=`tags` &search=`new`!]


      Turned page caching off, as well. I am super confused.
        • 22303 MODX Staff
        • 10,725 Posts
        Me too; it works great for me. Are you sure you authored your plugin correctly and you are using sendForward() ? Can you post the code of your plugin?
          • 14536
          • 22 Posts
          Plugin Code:
          <?php
          /**
           * Plugin for various moxiecart needs.
           *
           * @package default
           * @author John Sheeley
           **/
          class Plugin
          {
          	
          	/**
          	 * undocumented function
          	 *
          	 * @return void
          	 * @author John Sheeley
          	 **/
          	function __construct($moxieCart = null){
          		$this->modx = $moxieCart->modx;
          		$this->moxieCart = $moxieCart;
          	}
          	
          	function direct(){  
          		switch($this->modx->event->name) {  
          			case 'OnPageNotFound':  
          				$this->redirectFriendlyURL();
                  	break;  
          			case 'OnWebPagePrerender':  
          				/* FUTURE: ? */  
          			break;
          	   }
          	}
          	
          	private function redirectFriendlyURL(){
          		//redirect to store pages based on friendly url
          		$requestURI = trim($_SERVER['REQUEST_URI'], '/');
          		//get the location of the store page, e.g. store/
          		$storeLocation = trim(str_replace($this->modx->config['friendly_url_suffix'], '', $this->modx->makeUrl($this->moxieCart->_settings['storePage'])), '/');
          		
          		if (substr($requestURI, 0, strlen($storeLocation)) == $storeLocation) {
          			//page is in store directory
          			$process = true;
          			//remove store directory from path
          			$location = substr($requestURI,strlen($storeLocation));
          			//get the rest of the path into parts
          			$requestParts = explode('/', $location);
          			if($requestParts[1] == 'tags'){
          				//looking for tags
          				array_shift($requestParts);
          				$getData = array(
          					'needle' => $requestParts,
          					'haystack' => 'tags'
          				);
          			} elseif(count($requestParts) == 1) {
          				//looking for category
          				$getData = array(
          					'needle' => urldecode($requestParts[0]),
          					'haystack' => 'category'
          				);
          			} elseif(strpos(end($requestParts), $this->modx->config['friendly_url_suffix'])){
          				//looking for a product
          				$getData = array(
          					'mode' => 'single',
          					'product' => str_replace($this->modx->config['friendly_url_suffix'], '', urldecode(array_pop($requestParts))),
          					'category' => urldecode(array_pop($requestParts))
          				);
          			} else {
          				$process = false;
          			}
          			
          			if($process){
          				//set data
          				//TODO
          				foreach($getData as $key => $value){
          					$_GET[$key] = $value;
          				}
          				
          				//forward page
          				$this->modx->sendForward($this->moxieCart->_settings['storePage']);
          			}
          		}
          	}
          	
          } // END class 
          ?>


          Thanks for staying with me through this. Oh, and I wound up using database searches that were going to be performed anyhow, rather than use an alias table/column.
            • 22303 MODX Staff
            • 10,725 Posts
            From what I can tell, the code looks ok, but this may be a problem:
            $this->modx = $moxieCart->modx;

            This is making a copy of the modx object, which a) doubles the memory usage each time you do, and b) is now a separate object from the global $modx variable. Make sure you use references when doing this:
            $this->modx =& $moxieCart->modx;

            And make sure the $moxieCart->modx is assigned in the same way.

            Try correcting that and see if that corrects the issue; if not we’ll explore other possibilities...
              • 14536
              • 22 Posts
              Thanks for making me notice that... Updated it, but it didn’t affect the way things are working. I’m getting the same output for $_GET.
                • 14536
                • 22 Posts
                I copied the code to another file, and removed the class. The logic remained the same, but a few changes were made to variables ($this->modx became $modx, etc). For some reason it worked that way, but the $_GET vars are still not going through when using the class. Any idea why the class would be affecting it?

                Edit: I believe it’s the way I’m using my class. Perhaps.
                  • 11650
                  • 15 Posts
                  Ugh, Looks like it’s still having issues.

                  http://etb.pxside.com/events-in-bruce-county/forestry-series.php

                  If you go to that address, you’ll notice the links and images all have "events-in-bruce-county/" in their paths now.

                  Any way that I can make the plugin not do that, or do I have to code all the URLS with the [site_url] command?
                    • 21257 MODX Staff
                    • 730 Posts
                    It’s generally a good idea to put the following in the <head></head> of your Templates:
                    For Evolution:
                    <base href="[(site_url)]" />
                    


                    For Revolution:
                    <base href="[[++site_url]]" />
                    


                    It’s either that, or as you suggested, use site_url all over the place for links and other media (css, js, images).

                    Quote from: Haiasi at Jun 28, 2010, 04:33 PM

                    Ugh, Looks like it’s still having issues.

                    http://etb.pxside.com/events-in-bruce-county/forestry-series.php

                    If you go to that address, you’ll notice the links and images all have "events-in-bruce-county/" in their paths now.

                    Any way that I can make the plugin not do that, or do I have to code all the URLS with the [site_url] command?
                      Mike Schell
                      Lead Developer, MODX Cloud
                      Email: [email protected]
                      GitHub: https://github.com/netProphET/
                      Twitter: @mkschell
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Actually that should be
                      <base href="[(site_url)]" />
                        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