Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fancy URL: http://domain/cat1/cat2/page
#1
Hi!

At the moment I'm developing a website for a client using GetSimple. I really got to love the system, but didn't like not having my second category depth displayed in the URL structure... I searched the forum and didn't find a solution... therefore I tried hacking it myself and it seems, I was successful!! Smile

I18N Base is necessary for the hack to work, because the hack is written in i18n_base/frontend.class.php

Look for the function public static function getURL($slug, $slugparent, $language=null, $type='full') and add the following code after global $url, $parent, $PERMALINK, $PERMALINK_ORIG;

PHP Code:
    $data self::getPageData($slugparent);
    if(
$data) {
        
$parentparent $data->parent;
        if(
$parentparent != "") {
            
$slugparent $parentparent."/".$slugparent;
        }
    } 

At least for me it worked and now I do not have
http://domain.com/cat1/cat2/ followed by http://domain.com/cat2/page
but http://domain.com/cat1/cat2/page

Therefore I hope, this small hack can be of help for others as well Smile

Best,
Anke
Reply
#2
What version of GetSimple and I18N are you using?

Tried this hack and didn't work Sad Had the same issue - slugs will display their parent, but not their grandparents, great grand parents, etc. in the URL to allow proper SEO - very annoying.
Reply
#3
I'm using GetSimple 3.2.1 and the newest version of I18N, too...
Maybe it works only in combination with I18N Navigation? I use their navigations, maybe that is it?

I'm not sure about the great grand parents, as my website only has up to two levels, but I guess then it would be sth like this:
PHP Code:
$data self::getPageData($slugparent);
if(
$data) {
  
$parentparent $data->parent;
  if(
$parentparent != "") {
    
$data self::getPageData($parentparent);
    
$greatparentparent $data->parent;
    if(
$greatparentparent != "") {
      
$slugparent $greatparentparent ."/".$parentparent."/".$slugparent;
    } else {
      
$slugparent $parentparent."/".$slugparent;
    }
  }

... but that is only an idea, didn't try that^^
Reply
#4
Not using the most recent version but also using I18N Navigation - probably part of my issue. To update, I would have to go through another Certification and Accreditation to use to be able to use on my network with Information Assurance approval.

That would work from just looking at your code - should be a recursive function to support all levels - some pseduo code - might need globals without looking at getSimpleCode:
Code:
function getParents($slug) {
   $data = self::getPageData($slug);
   if ($data->parent != "") {
      $array[] = getParents($slug);  //Capture the parent via recursion
   }
   return (isset($array) ? $array : false);
}
Reply
#5
I18N version 3.2 now supports the placeholder %parents% for "hierarchical" URLs.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#6
(2013-05-06, 03:26:42)mvlcek Wrote: I18N version 3.2 now supports the placeholder %parents% for "hierarchical" URLs.
Awesome! Glad to hear this.
Reply
#7
(2013-05-06, 03:26:42)mvlcek Wrote: I18N version 3.2 now supports the placeholder %parents% for "hierarchical" URLs.

I tried using it, but I have a problem with sitemap.xml and
component Sidebar (
<?php get_i18n_search_results(array('tags'=>'_catalogSidebar', 'i18n'=>0, 'showDate'=>0, 'DATE_FORMAT'=>'%d.%m.%Y', 'numWords'=>'0', 'order'=>'created','showPaging'=>0,'HEADER'=>'')); ?>
).
How do all parents in getsimple ?
Reply




Users browsing this thread: 2 Guest(s)