Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Article title name as URL?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #44178
    botpro7
    Member

    I am working on a simple CMS now, i have made post-new-page form, if i click “submit” button, the content will be saved into the database, by the same time i want the PHP script automatically create new folder in my root folder (i’m not sure whether it’s correct to create inside my root folder?)

    This is [the example](http://www.mactricksandtips.com/2013/03/speed-up-your-mac-by-solving-disk-errors-and-problems.html “example”).

    As you can see, the article’s URL (http://www.mactricksandtips.com/2013/03/**speed-up-your-mac-by-solving-disk-errors-and-problems**.html) equals to the article’s title (Speed Up Your Mac By Solving Disk Errors And Problems).

    How do i achieve this? Thanks in advanced.

    #132041
    Kitty Giraudel
    Participant

    You can do this manually with PHP. This is called a slug.

    Basically, all you have to do is switch it to lower case, remove special chars and replace spaces by dashes. :)

    [Here](http://stackoverflow.com/questions/2955251/php-function-to-make-slug-url-string) is something that should help you.

    #132075
    CrocoDillon
    Participant

    There is a great script on github: [BaconStringUtilsSlugifier](https://github.com/Bacon/BaconStringUtils) (you don’t need to use Zend to use the classes in `/src`.

    It does not only convert chars like `ö` to `o` but also `北亰` to `Bei Jing`, according to the readme (slugified that would be `bei-jing`)… You never know, right? ;)

    You then need to redirect requests to a common landing page (probably just `/index.php`, using .htaccess), read out the slug and query that page from a database (in which you have an indexed ‘unique, which is an index’ column with the slug to make queries fast).

    The `html` extension in your example doesn’t mean there is an actual html file.

    #132078

    search in developphp.com , they got what you want.

    #132085
    botpro7
    Member

    thank you for all the answers guys!

    digesting the explanation…..
    reading all the links……:)

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.