Forum Moderators: coopster
The category displays fine, site.com/category.
But when I try site.com/category/content it doesnt see $_GET['content'] as being set. Ive tried checking by simply echoeing 'Is set' if GET['content'] is set, but nothing.
Any help would be much appreciated.
You said about SEF URL's so I dont know if the url you gave was after or before the rewrite.
So what do your url's look like before the rewrite?
<edit>
Also what rewrite rules are you using? As it could be a problem with those rather than the php.
[edited by: PHP_Chimp at 7:12 pm (utc) on Feb. 19, 2008]
With mod_rewrite, it only works on category, content isnt seen as being set.
I've seen some people say that you cant use GET with this, but really dont know how else to go about this.
I am thinking possibly about trying to get the contents of the URL in an array, since category GET is seen, then just go through some switches. Would this be possible or right to do in this situation? Ive never designed a dynamic frontend before with a CMS and am a little lost on techniques to go about this.
As if you are going from -
site.com/?category=something&content=another_thing
to -
site.com/category/content
Then it looks as though you are loosing a lot of that information.
For example, this would be a more usual type set up
site.com/?category=something&content=another_thing
to -
site.com/something/another_thing
As in your are keeping the keys, but loosing the values. So in my case you know that the first 'directory' is actually your category and the page name is the content.
So there may well be only a very small change needed to your rewrite rules to get the values preserved...or of course I could have the wrong end of the stick ;)
I am going from category=category&content=content, but content is never seen as being set. Could it be that I use isset to check the category, and if category is set I use another isset to check if content is set? This way, content is only pulled if the category is set.
I have found another method that seems to work at the moment. I simply set an array for te URL and exploded starting at the category /, getting everything afterwards. This way, foreach value in the URL, I could use something like $url[0] and $url[1]. It works so far, but still would like to know why the GET method wasnt working two levels deep.
RewriteRule ^(.*)$ index.php?category=$1 [L]
Just move your more specific rule above that one and it should work:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*) $1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z_]+)/([^/]+) index.php?category=$1&content=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?category=$1 [L]