thedigicraft / Atom.CMS

Atom.CMS
56 stars 50 forks source link

Multiple slugs in the URL? #138

Open ninasmurffh opened 9 years ago

ninasmurffh commented 9 years ago

So I have a users system on my website, and I would like to create profiles for the users, so I was just wondering if it's possible to have the url look like this: mywebsite.com/user/username instead of mywebsite.com/username? Any ideas appreciated!

creptor commented 9 years ago

it would be nice.... but I think that for that you have to edit the .httacces and set the variables to work with the / and of course edit the code given for the ceal url's.

ninasmurffh commented 9 years ago

@creptor Yeah, that's what I thought... Oh well, I don't have the skills to do all that so I guess I'll probably make a folder named users or something. But thanks anyway!

creptor commented 9 years ago

maybe what you can do is to set in the users page a script looking for this separation. Here is an example of an url and how it's habndle right now by our code: url="http://localhost:100/about/creptor/mess" this gives out these variables:

array (size=4)
  'base' => string '' (length=0)
  'call_utf8' => string 'about/creptor/mess' (length=18)
  'call' => string 'about/creptor/mess' (length=18)
  'call_parts' => 
    array (size=3)
      0 => string 'about' (length=5)
      1 => string 'creptor' (length=7)
      2 => string 'mess' (length=4)

So with this tou can just add a serch php function for $path['call_parts'][1] and will give you that result.

Note that for this you need to have static or well defined the css and the javascript, beacause it doesn't take the / as variables, and it loads in a diferent like page....

ninasmurffh commented 9 years ago

@creptor ehh sorry i didn't quite get that haha... But really it's fine i was just thinking if there was a simple way to do that, it's no big deal. :smile:

ninasmurffh commented 9 years ago

@creptor I solved it by creating a folder named user! :smile:

creptor commented 9 years ago

I kind of made an example of how to create a php script for a page that recovers the user information from a table so it can be show on the page. If you used another way to do this it's fine, but if you're creating a file for each user it wouldn't be safe or simple. Try to always use a database.