• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Clean urls (hack)
PostPosted: Sat Jan 07, 2006 12:04 pm 
Offline
Power Poster
Power Poster

Joined: Tue Dec 13, 2005 10:50 pm
Posts: 1408
Location: Finland
Clean url by default doesnt take into account the hierarchy of the links, here is a hack to have urls like "http://www.domain.tld/parent1/parent2/parentN/page.html"

in lib/misc.functions.php add

Code:
 
function clean_urls($my_ID) {
  global $gCms;
  global $config;

  $thispage = $page;

  $thispage = $my_ID;


  $trail = "";
  $delimiter = "/";

#Make an array for all pages
  $allcontent = array();

#Load current content
  $onecontent = ContentManager::LoadContentFromId($thispage, false);

  if ($onecontent !== FALSE)
    {
      array_push($allcontent, $onecontent);

#Grab all parents and put them into the array as well
      while ($onecontent->ParentId() > 0)
        {
          $onecontent = ContentManager::LoadContentFromId($onecontent->ParentId(), false);
          // tdh add / modify next 5 lines
          if (isset($params['root']))
            {
              if (strtolower($onecontent->Alias()) != strtolower($params['root']))
                {
                                        array_push($allcontent, $onecontent);
                }
            }
          else
            {
              array_push($allcontent, $onecontent);
            }
        }

#Pull them one by one in reverse order to construct a breadcrumb list
      $first=1;
      while ($onecontent = array_pop($allcontent))
        {
          if($first) {
            $trail = $onecontent->getURL();
            $strip = count_chars($config["page_extension"]);
            $trail = substr($trail, 0, -5);
            $trail .= $delimiter;
            $first=0;
          } else {
            $trail .= $onecontent->MenuText() . $delimiter;
          }
        }
      $trail = substr($trail, 0, -1);
      $trail .= $config["page_extension"];
      return $trail;
    }
}
 


before ?> at the end

in modules/CSSMenu/CSSMenu.module.php edit lines
Code:
                        if ($onecontent->Id() == $gCms->variables['content_id'])
                        {
                               $menu .= "<li class=\"menuactive\"><a href=\"".$onecontent->GetURL()."\"";
                        }
                        else
                        {
                               $menu .= "<li><a href=\"".$onecontent->GetURL()."\"";
                        }




to read
Code:
                        if ($onecontent->Id() == $gCms->variables['content_id'])
                        {
#                               $menu .= "<li class=\"menuactive\"><a href=\"".$onecontent->GetURL()."\"";
                                $menu .= "<li class=\"menuactive\"><a href=\"".clean_urls($onecontent->Id())."\"";
                        }
                        else
                        {
#                               $menu .= "<li><a href=\"".$onecontent->GetURL()."\"";
                                $menu .= "<li><a href=\"".clean_urls($onecontent->Id())."\"";
                        }



new .htaccess file

Code:
RewriteEngine On
#Rewrites anything/page.shtml as index.php?page
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.*/)?([a-zA-Z0-9\.]+)\.html$ index.php?page=$2 [QSA]


in config change
$config['page_extension'] = '.html';
$config['assume_mod_rewrite'] = true;


try it, tested with news module and it should fallback to "messyURL"  ???

thanks go to breadcrumbs, most of the function is copy paste from there  ;)


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Clean urls (hack)
PostPosted: Sun Jan 08, 2006 7:51 am 
tsw wrote:
Clean url by default doesnt take into account the hierarchy of the links, here is a hack to have urls like "http://www.domain.tld/parent1/parent2/parentN/page.html"


I am just discovering CMSMS and I haven't tested this hack yet and the poblem you mention with modules. But your hack seems very interesting. From a usability point of view, such "clean URLs" seem much better than the existing one.

We could imagine that such clean URLs could be an option for CMSMS (the 2 other options would be: 1) no clean URL, 2) the existing clean URLs system).

@mitiés

Philippe (phdm)


Top
   
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Clean urls (hack)
PostPosted: Fri Jan 20, 2006 3:17 pm 
THIS is exactly what i'm looking for... but it doesn't seem to be playing nice...

I have a brand new fresh install, with nothing but the default content in and once I implement each of the steps here, I get 404 errors off the home page.

only about 1/2 the main links work, and none of the 2nd level pages work at all.

Clean urls were working fine with the fresh install, but I really want this type of hierarchy in the links.

Is this working with the latest release of CMSMS? Any help would be appreciated.


Top
   
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Clean urls (hack)
PostPosted: Tue Apr 11, 2006 5:23 pm 
I've just installed CMSMS for the first time - is it safe to try using the hack above?

I'm also very keen to make the urls more (search-engine) friendly....

Cheers


Top
   
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Clean urls (hack)
PostPosted: Wed Apr 12, 2006 12:49 pm 
Offline
Power Poster
Power Poster

Joined: Tue Dec 13, 2005 10:50 pm
Posts: 1408
Location: Finland
actually that hack is kind of old and Im trying to push new way for this in future relase..


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Clean urls (hack)
PostPosted: Mon Apr 24, 2006 9:17 am 
Offline
Power Poster
Power Poster

Joined: Wed Sep 08, 2004 3:32 pm
Posts: 520
No more need for hacks guys: 0.13beta1 is out and takes care of all these things. Congratulations, Ted! If you'd like to know how to use Clean URLs (pretty urls) when you upgrade to 0.13, please have a look here.

There are some modifications available for creating path-like URLs and furthermore modules URLs look much prettier this way. Cheers to all who made this possible.

Regards,
Nils


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Clean urls (hack)
PostPosted: Tue Apr 25, 2006 9:56 am 
Wow great  ;D

I was about to give up on my first attempt at using cmsms because I had no idea how to get the urls to play nice... maybe I will now...


Top
   
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Clean urls (hack)
PostPosted: Tue Apr 25, 2006 1:58 pm 
Offline
Power Poster
Power Poster

Joined: Tue Dec 13, 2005 10:50 pm
Posts: 1408
Location: Finland
0.13 will have clean urls integrated, and much better than this hack does :)


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Clean urls (hack)
PostPosted: Tue Apr 25, 2006 3:39 pm 
Offline
Power Poster
Power Poster

Joined: Wed Sep 08, 2004 3:32 pm
Posts: 520
tsw wrote:
0.13 will have clean urls integrated, and much better than this hack does :)


That is just what I said ...  ;)

Cheers,
Nils


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Clean urls (hack)
PostPosted: Tue Apr 25, 2006 5:17 pm 
Offline
Power Poster
Power Poster

Joined: Tue Dec 13, 2005 10:50 pm
Posts: 1408
Location: Finland
oh  :P

note to self: read more than just the latest reply!


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting