536 Posts in 384 Topics by 230 members
|Go to End|
13 October 2009 at 7:17pm
I wonder if anyone know how to mod rewrite the forum functionality when showing post, so the last url will display the title of the topic.
For example :
Can it become like :
http://www.silverstripe.org/hosting-requirements/show/The PHP Hash Module Requirement
Any answer would be appreciated.
13 October 2009 at 8:07pm
It would certainly be possible.. you would have to overwrite the show method to use the title as identifier instead of the ID. Also, the method that returns the link to a post has to be overwritten.
There are some problems with this approach though:
- You would have to ensure that the Title is unique. So basically there can only be one post titled "I need help"...
- Searching the Database on non indexed varchar fields will take much more time than searching for the ID. This will become a problem when you have several thousand forum posts.
A better solution would probably be a mixture of the two. Something like:
So that you have the ID for the application and a human readable part of the URL
13 October 2009 at 8:55pm
Thx for your reply, well i think a second option http://www.silverstripe.org/hosting-requirements/show/270808/The-PHP-Hash-Module-Requirement is ok, but can you give me a specific mod rewrite that i should create on the htaccess file so it can be done like that?
13 October 2009 at 9:08pm
You don't need a specific rewrite rule for this. All the (non-file) URLs are being rewritten and handled by SilverStripe anyway. You have to customize the forum module to achieve your goal.
13 October 2009 at 10:50pm
Hmm so you mean for example
When i create the link i just create it like :
Even though i think the silverstripe actually only handle the topic id, whatever we type on the last is doesn't have an affect right?
For example :
Then it will still show my post right?
14 October 2009 at 12:24am Last edited: 14 October 2009 12:25am
Yes, apparently the Forum Module only uses the ID parameter, so you can just customize the creation of links as you suggested.
16 October 2009 at 9:49pm
ok so i have it working now, so here is how the url look like :
So the second parameter is the action parameter and the third one is the id, and what i did is just create a fourth parameter from the title which actually doesn't have any impact, the important thing is the action and id parameter.
I'm just wondering is this the right way for me to create a nice url so it can be crawled better by the search engine bot?
|Go to Top|