Log in | Register | Lost password

Bottom
short urls another howto
  • Posted: 02.12.2006, 23:44
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    To change the usual address to a nice one I change the template, so that it produces the links I want to. Instead of the core.FullUrl I use sth like that:

    Code

    <a href="ps_<!--[$core.tid]-->_<!--[$core.pid]-->_<!--[$core.title|strip:"-"|regex_replace:"/[,|_|;]/":"-"|escape:"url"]-->.htm"><!--[$core.title]--></a>

    The REGEX to convert those links to the "ugly" ones looks like that:

    Code

    RewriteEngine On

    RewriteBase /

    RewriteRule ^ps_([0-9]{1,4})_([0-9]{1,4})_.*$ index.php?module=Pagesetter&func=viewpub&tid=&pid= [L]


    Perhaps this is not very new, but I didn't find a description of this simple method.
  • Posted: 03.12.2006, 03:01
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    This is really cool, and more standard... Could it be made to use slashes insted of underscores? Can you make it show something like:

    Code

    http://www.mydomain.com/YYYY/mm/dd/tid/pid/title.html


    ??

    This because it would look so much better and it would also add "time of posting" into context.
  • Posted: 03.12.2006, 20:32
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Sure, you are building the url yourself, so you can use any character you want. You just have to "Regex" it afterwards.

    How about this:

    Code

    http://www.mydomain.com/tid/pid/YYYY/mm/dd/title.html
    For me the Regex would be slightly easier like this:

    Code

    RewriteEngine On

    RewriteBase /

    RewriteRule ^([0-9]{1,4})/([0-9]{1,4})/.*$ index.php?module=Pagesetter&func=viewpub&tid=&pid= [L]

    For the Date I found three variables:
    created
    lastUpdated
    publishDate
    You could use them in the template somehow like this:

    $core.lastUpdated|date_format:"%B/%e/%Y"
    The whole thing would be so:

    Code

    <a href="<!--[$core.tid]-->/<!--[$core.pid]-->/<!--[$core.lastUpdated|date_format:"<the-date-format>"]-->/<!--[$core.title|strip:"-"|regex_replace:"/[,|_|;]/":"-"|escape:"url"]-->.htm"><!--[$core.title]--></a>

    For the %sth's of the look here:
    http://smarty.php.net under date_format.



    edited by: drichter, Dec 03, 2006 - 09:56 PM

Template courtesy of Designs By Darren.