Forums / Cotonti / Development / Nice urls for plugins or modules

tensh
#1 2013-10-30 12:21

Hello;

Let's assume I have a plugin flowcharts that has the structure:

- mywebsite.com/index.php?e=flowcharts&uname=admin  would look like  mywebsite.com/flowcharts/admin (all flowcharts of admin)
- mywebsite.com/index.php?e=flowcharts&uname=admin&fid=3  would look like  mywebsite.com/flowcharts/admin/3 (flowchart id=3 of admin)
... but also mywebsite.com/index.php?e=flowcharts&fid=3 would lead to  mywebsite.com/flowcharts/3 (flowchart id = 3)

Any help in this area to produce custom nice urls for a plugin? And how about htaccess?

When I finish, I will share the module with you :)

Trustmaster
#2 2013-10-30 17:00

1. Create your custom datas/urltrans.dat based on plugins/urleditor/presets/handy.dat. Add these lines on top:

flowcharts	uname=*&fid=*	{$e}/{$uname}/{$fid}
flowcharts	uname=*			{$e}/{$uname}
flowcharts	fid=*			{$e}/{$fid}

2. Add these rules to your .htaccess:

RewriteRule ^flowcharts/([a-zA-Z][a-zA-Z0-9_-]*)/([0-9]+) index.php?e=flowcharts&uname=$1&fid=$2 [QSA,NC,NE,L]
RewriteRule ^flowcharts/([0-9]+) index.php?e=flowcharts&fid=$1 [QSA,NC,NE,L]
RewriteRule ^flowcharts/([a-zA-Z][a-zA-Z0-9_-]*) index.php?e=flowcharts&uname=$1 [QSA,NC,NE,L]
May the Source be with you!
Macik
#3 2013-11-01 12:05

And don't foget `URL editor` plugin should be installed and setuped with `Custom urltrans.dat` preset.

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F
tensh
#4 2013-11-03 18:27

Thank you very much :)