#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    7
    Rep Power
    0

    Using dynamically created static link with premade template


    Hey everyone,

    I've been overloading my brain trying to figure this one out and could use some direction. I don't need snippets (though won't turn down the help :P ) just help figuring out the logic behind how to achieve this. Here's what I want to achieve:

    I'm making a local job listing site, and I want the url to be the job title, so mysite.com/jobs/job-listing-name.php ... I want to have a stock template for the listing, normally this is easy enough, and I'd just use the ID for the file name, but that would be like this: mysite.com/jobs/template.php?id=.... so how can I make a stock template without using variables in the URL is my real question? I know I can get all info from the db where the job title is equal to the file name, but I have no idea how to make the templated page under the unique page name. Thanks in advance, and this is probably all over the internet but I have no idea how to word it so google is of little help, in fact this whole blab probably will need to be clarified a lot before I can even get a usable answer. Thanks!
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,853
    Rep Power
    6351
    You would use modrewrite just like devshed does.

    www.yoursite.com/jobs/1234-This-Is-a-Great-Job.php

    Becomes

    www.yoursite.com/jobs.php?jobid=1234

    Proceed from there.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    7
    Rep Power
    0
    Thanks, and I'm assuming it works the opposite way? And will that work with get?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,971
    Rep Power
    375
    what he posted uses GET variables?

    btw at least try to learn about mod re-write instead of asking here, everything will become clear. (I hope)
  8. #5
  9. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Originally Posted by neg89
    Thanks, and I'm assuming it works the opposite way? And will that work with get?
    It's a one way conversion and the RewriteRule is able to retain any passed GET variables.

    I use it (well, used it) to convert URLs like:

    domain.com/t43.10_Some-Topic-Name?sortBy=topicName

    to function as:
    domain.com/modules/forums/topics/?topicId=43&page=10&sortBy=topicName

    The end user will only ever see the "pretty URL", but the webserver will treat it like the latter.

    But I've since changed my system to relay all requests that don't match a literal object into my PHP, for my PHP to handle the above kinds of routing. But that's probably more complex than you'd want to deal with here.

IMN logo majestic logo threadwatch logo seochat tools logo