Pretty URLs for block actions - are they possible?
Permalink 1 user found helpful
I was thinking about this the other day, and trying to figure out if it's possible or not. Right now, in a block view when you do $this->action('method') it spits out a super long url with a lot of parameters pointing directly at the index page. Not really good for seo, bookmarking, etc.
Example URL:
http://5602.hutman.local/index.php?cID=1&bID=53&arHandle=Ma...
What seemed like it could work is to make a new method on the page controller, 'b' or 'block' or 'baction' and use that to pass the parameters on to the block, then render the view. I'm not entirely sure how to do that though.
Proposed urls:
http://5602.hutman.local/page-handle/b/passthru/$bID/$arHandle/meth...
or
http://5602.hutman.local/page-handle/b/passthru_stack/$stackID/$bID...
Is this a totally dumb idea? Does anyone have any ideas on how to implement it? I know it's still a pretty long, ugly url with the token, but I think it's probably better than a bunch of query string variables. Seems like it would be a good approach though. I wonder too if you could get rid of the passthru an area handle parts since you could probably find that out in the page controller. So then you could get an even nicer url:
http://5602.hutman.local/page-handle/ba/$bID/method/1351794829:69a7...
or
http://5602.hutman.local/page-handle/bsa/$bID/$sID/method/135179482...
Any thoughts or feedback are appreciated. This has been a limitation to concrete5 that I haven't really liked for quite awhile. I'd like to try and come up with a solution if there is one. Or maybe it's a non-issue? Have other people tried to fix this before?
Example URL:
http://5602.hutman.local/index.php?cID=1&bID=53&arHandle=Ma...
What seemed like it could work is to make a new method on the page controller, 'b' or 'block' or 'baction' and use that to pass the parameters on to the block, then render the view. I'm not entirely sure how to do that though.
Proposed urls:
http://5602.hutman.local/page-handle/b/passthru/$bID/$arHandle/meth...
or
http://5602.hutman.local/page-handle/b/passthru_stack/$stackID/$bID...
Is this a totally dumb idea? Does anyone have any ideas on how to implement it? I know it's still a pretty long, ugly url with the token, but I think it's probably better than a bunch of query string variables. Seems like it would be a good approach though. I wonder too if you could get rid of the passthru an area handle parts since you could probably find that out in the page controller. So then you could get an even nicer url:
http://5602.hutman.local/page-handle/ba/$bID/method/1351794829:69a7...
or
http://5602.hutman.local/page-handle/bsa/$bID/$sID/method/135179482...
Any thoughts or feedback are appreciated. This has been a limitation to concrete5 that I haven't really liked for quite awhile. I'd like to try and come up with a solution if there is one. Or maybe it's a non-issue? Have other people tried to fix this before?
Although... I do see how they could be cleaned up in 2 ways:
1) use the page's path / slug / pretty URL thing before the rest of the params (instead of always index.php?cID=123&bID=... , it would be /my/page?bID=....)
2) provide a way to easily output all those params in hidden form fields do they don't need to be in the URL for POSTed forms (like Loader::helper('form')->actionPatams()).
1) use the page's path / slug / pretty URL thing before the rest of the params (instead of always index.php?cID=123&bID=... , it would be /my/page?bID=....)
2) provide a way to easily output all those params in hidden form fields do they don't need to be in the URL for POSTed forms (like Loader::helper('form')->actionPatams()).
Yeah, I don't know what's best, I just don't like the current system. I was thinking about it for changing page content - maybe pagination, maybe filtering, stuff like that. So you'd have a url like:
/page-path/b/123/main/$token/show_properties/duplexes
Not sure if that's something you could really do. It's not the friendliest, but still perhaps better than the current system.
I've done it for page type controllers to determine what information is passed to page lists, tools files, etc. Seemed like it would be nice to be able to do it with blocks.
/page-path/b/123/main/$token/show_properties/duplexes
Not sure if that's something you could really do. It's not the friendliest, but still perhaps better than the current system.
I've done it for page type controllers to determine what information is passed to page lists, tools files, etc. Seemed like it would be nice to be able to do it with blocks.
Hmm... well for block actions (like pagination), it seems like you wouldn't need a lot of that stuff (e.g. tokens). Maybe if there were a way for the block itself to "register" with the dispatcher that it should receive certain actions on a certain page? Not sure how this could be done efficiently though.
Do you have some specific use case in mind where this isn't true?
Also, I'm not sure a "pretty" URL is really any better -- it's still not pretty, just has slashes instead of ampersands (in other words, it's not the slashes that make a URL SEO-friendly, but rather that the words in them have some kind of meaning). I'm not an SEO expert though so I could be wrong about this.