Skip to content

Instantly share code, notes, and snippets.

@tux255
Created December 15, 2017 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tux255/5399dd22ec5ecb5fe42f3dd88c29fe74 to your computer and use it in GitHub Desktop.
Save tux255/5399dd22ec5ecb5fe42f3dd88c29fe74 to your computer and use it in GitHub Desktop.
Opencart add friendly URLs for other pages
<modification>
<id>seo_url_core</id>
<version>1.4.x and above</version>
<vqmver required="true">2.x.x</vqmver>
<file name="catalog/controller/common/seo_url.php">
<operation error="skip">
<search position="before" offset="0">
<![CDATA[
public function index() {
]]>
</search>
<add>
<![CDATA[
/* SEO Custom URL */
private $url_list = array (
'common/home' => '',
'checkout/cart' => 'cart',
'account/register' => 'register',
'account/wishlist' => 'wishlist',
'checkout/checkout' => 'checkout',
'account/login' => 'login',
'product/special' => 'special',
'affiliate/account' => 'affiliate',
'checkout/voucher' => 'voucher',
'product/manufacturer' => 'brand',
'account/newsletter' => 'newsletter',
'account/order' => 'order',
'account/account' => 'account',
'information/contact' => 'contact',
'account/return/insert' => 'return',
'information/sitemap' => 'sitemap',
);
/* SEO Custom URL */
]]>
</add>
</operation>
<operation error="skip">
<search position="before">
<![CDATA[
if (!isset($this->request->get['route'])) {
]]>
</search>
<add>
<![CDATA[
/* SEO Custom URL */
if ( $_s = $this->setURL($this->request->get['_route_']) ) {
$this->request->get['route'] = $_s;
}/* SEO Custom URL */
]]>
</add>
</operation>
<operation error="skip">
<search position="before" offset="3">
<![CDATA[
if ($url) {
]]>
</search>
<add>
<![CDATA[
/* SEO Custom URL */
if( $_u = $this->getURL($data['route']) ){
$url .= $_u;
unset($data[$key]);
}
/* SEO Custom URL */
]]>
</add>
</operation>
<operation error="skip">
<search position="after" index="1" offset="2">
<![CDATA[
return $link;
]]>
</search>
<add>
<![CDATA[
/* SEO Custom URL */
public function getURL($route) {
if( count($this->url_list) > 0) {
foreach ($this->url_list as $key => $value) {
if($route == $key) {
return '/'.$value;
}
}
}
return false;
}
public function setURL($_route) {
if( count($this->url_list) > 0 ){
foreach ($this->url_list as $key => $value) {
if($_route == $value) {
return $key;
}
}
}
return false;
}/* SEO Custom URL */
]]>
</add>
</operation>
</file>
</modification>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment