Skip to content

Instantly share code, notes, and snippets.

@jaredhoyt
Created September 7, 2010 19:17
Show Gist options
  • Save jaredhoyt/568891 to your computer and use it in GitHub Desktop.
Save jaredhoyt/568891 to your computer and use it in GitHub Desktop.
Toggle default prefix functionality within Helper::url()
<?php
class AppHelper extends Helper {
var $maintainPrefix = false;
function url($url = null, $full = false, $maintain = false) {
if (is_array($url) && !$this->maintainPrefix && !$maintain) {
$routing = Configure::read('Routing');
if (!empty($routing['prefixes'])) {
$prefixes = array_diff_key(array_flip($routing['prefixes']), $url);
$url = array_merge($url, array_fill_keys(array_keys($prefixes), false));
}
}
return parent::url($url, $full);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment