Hello, like putting in so handy pluging urleditor
Macik |
|
---|---|
In my case (already using Handly preset of URL editor) I can't do this as «PHP does not support function overloading, nor is it possible to undefine or redefine previously-declared functions». Some kind of a solution may be adding a hook to cot_url_custom (from URLEditor) as we have in cot_apply_rwr() for adding costom rules to it. https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
Trustmaster |
|
---|---|
The problem is: cot_url() / cot_url_custom() is called 100-500 times per request. Adding a hook to it would make the whole site slower. Another solution would be using a set of callback functions. But both should be tested with a PHP profiler. May the Source be with you!
|
Macik |
|
---|---|
Yes, in case of high load the hook is not best solution. But cot_url_custom already a complicated function itself. How you suppose to use callback function? Any way there should be a clear solution to extend «handly url» composing. I mean «i18n» block hardcoded in cot_url_custom is not pure style. Добавлено 1 день спустя: I think I can solve my needs with custom urltrans. So question is: can I add custom url rules to «urltrans.dat» via web form or must editing file direct in filesystem? https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
|
This post was edited by Macik (2012-07-06 12:05, 11 years ago) |
Trustmaster |
|
---|---|
Both are acceptable. I personally prefer editing urltrans.dat directly because it is faster. But be careful with tabs and spaces, it is quite sensitive to that. May the Source be with you!
|
Macik |
|
---|---|
Ok. Thanks. The first time I just missed «new rule» link in web UI of urleditor. Добавлено 5 часов спустя: «urltrans» work quite well for my case. It's hardcoded as an array in my plug, so I inject it in $cot_urltrans right in the code. $my_urltrans[] = array( 'params' => cot_parse_str('mode=catalog&gfx=1'), 'trans' => '{!$mode}{$_area}/{$c}/{$s}/{$typ}/{$vp}+{$year}+{$month}/graphics/{$mg}/{$bt}/' ); // and so on $cot_urltrans['myplug'] = $my_urltrans; But had another inconvenient thing. As I use shorthand style of call «cot_url», like cot_url('myplug', 'mode=catalog'); // other parameters added automatically from global scope as noted in urltrans So I trapped myself to cot_url_custom. If urleditor not installed - my code will not work. And anyway I must write a cot_url wrapper to autimatically send all long chain of parameters to cot_url(). https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
|
This post was edited by Macik (2012-07-06 22:05, 11 years ago) |