Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Hosting Requirements /

What you need to consider when choosing a hosting provider and plan.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Forum Mod Rewrite


Reply


7 Posts   1743 Views

Avatar
draft

Community Member, 57 Posts

13 October 2009 at 7:17pm

Hi,

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 :

http://www.silverstripe.org/hosting-requirements/show/270808#post270808

Can it become like :

http://www.silverstripe.org/hosting-requirements/show/The PHP Hash Module Requirement

Any answer would be appreciated.

Avatar
banal

Community Member, 901 Posts

13 October 2009 at 8:07pm

Hi

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:
http://www.silverstripe.org/hosting-requirements/show/270808/The-PHP-Hash-Module-Requirement

So that you have the ID for the application and a human readable part of the URL

Avatar
draft

Community Member, 57 Posts

13 October 2009 at 8:55pm

Hi,

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?

Thx.

Avatar
banal

Community Member, 901 Posts

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.

Avatar
draft

Community Member, 57 Posts

13 October 2009 at 10:50pm

Hmm so you mean for example
http://silverstripe.org/hosting-requirements/show/270862#post270862

When i create the link i just create it like :

http://www.silverstripe.org/hosting-requirements/show/270808/Forum-Mod-Rewrite

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 :

http://silverstripe.org/hosting-requirements/show/270862/whatever
Then it will still show my post right?

Avatar
banal

Community Member, 901 Posts

14 October 2009 at 12:24am

Edited: 14/10/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.

Avatar
draft

Community Member, 57 Posts

16 October 2009 at 9:49pm

hi,

ok so i have it working now, so here is how the url look like :

mysite.com/page/show/1/title

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?

Thx.