[!MoxieCart? &type=`show` &display=`tags` &search=`new`!]
<?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
?>$this->modx = $moxieCart->modx;
$this->modx =& $moxieCart->modx;
<base href="[(site_url)]" />
<base href="[[++site_url]]" />
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?