开发者

Url routing in elgg

开发者 https://www.devze.com 2023-02-25 15:17 出处:网络
I am trying to creat开发者_高级运维e a social network application using elgg.Since i am pretty new to elgg i like know whether i can define url routing like in cakePHP

I am trying to creat开发者_高级运维e a social network application using elgg.Since i am pretty new to elgg i like know whether i can define url routing like in cakePHP

I need the url like this mydomain.com/username instead of mydomin.com/pg/profile/username

Is there any way that i can avoid /pg/ and /mod/ from the urls??

I am using elgg version 1.7.8.

I am not interested in url rewriting with .htaccess.

Thanks in advance


elgg itself is using .htaccess file to redirect /pg, /action etc. So, I think there is no other way than using .htaccess.


Elgg's page handling is pretty bad but you can register handlers as follows.

for /mypage:

    elgg_register_page_handler('mypage', function($pages){
        //content here
        //the $pages parameter is an array. so /mypage/a/b with return
        // array('a','b');
    });


Matt Beckett has written a profile URL plugin (https://community.elgg.org/plugins/1091233) that, though for 1.8 and above, is only 35 lines of code and does exactly what you ask. You should be able to adapt this quite easily for 1.7.8.

He has also written a fuller page handler hijack plugin that may help if you have other use cases apart from user profiles - see https://community.elgg.org/plugins/854839

It is also only for 1.8 and above, however, and may take more effort to backport than the first.

0

精彩评论

暂无评论...
验证码 换一张
取 消