Rewrite to fix a wrong Elgg url

Hi!, how can I rewrite this url:

../pages/owner/group:2533

to

../pages/group/2533/all

I´ve tried with 

rewrite ^pages/owner/group:([0-9]+)$ /pages/group/$1/all last;

but dont works. Any sugestion??

I´ve Nginx and Elgg 1.8

 

  • @iionly the deprecated URLs are in menu items, just here. This link is created by Widget Manager.

    I see in classes/UrlFixer.php this code:

    // OLD: http://www.example.com/pg/blog/owner/group:1499
    // NEW: http://www.example.com/blog/group/1499/all
    if (strpos($parts[3], 'group:') !== false) {
    // Remove 'owner'
    unset($parts[2]);

    // Change 'group:1499' to 'group/1499'
    $parts[3] = str_replace(':', '/', $parts[3]);

    ...

    So I think it should solve the problem, but @Juho´s plugin is not having effect in my Elgg 1.8

    @Matt, about your suggestion, I dont have enought Elgg knowledge to do that :( 

     

  • My plugin fixes only the data that has been saved to the database (metastrings and entity description). The string in the widget manager has been hard-coded into the plugin code, so it cannot be updated using my plugin.

    Are you sure you're using the latest version of Widget manager? I find it highly unlikely that the latest version is using URL formats that haven't been used since Elgg 1.7.

  • I´ve installed WM 4.7, and I also tried with 4.8 version. I posted the problem in the plugin forum, but I dont have a solution for now.

  • I think the origin of the problem is in the core pages widget, which is enabled by WM for groups. The core widget is not built to be used in groups.

  • This is how you can fix it: Copy the original pages widget /mod/pages/views/default/widgets/pages folder to your theme and edit content.php

    $container = $vars['entity']->getContainerEntity();

    if ($content) {
            if (elgg_instanceof($container, 'group')) {
                    $url = "pages/group/" . elgg_get_page_owner_entity()->guid . "/all";
            }else{
                    $url = "pages/owner/" . elgg_get_page_owner_entity()->username;
            }

    ....

  • Awesome @Gerard!!, I´ve added this code, and copied the file content.php to my theme plugin, and it works perfect!!. 

    $container = $vars['entity']->getContainerEntity();

    //Fix widget for groups @Gerard
    if ($content) {
    if (elgg_instanceof($container, 'group')) {
    $url = "pages/group/" . elgg_get_page_owner_entity()->guid . "/all";
    }else{
    $url = "pages/owner/" . elgg_get_page_owner_entity()->username;
    }
    }
    ///////

    if ($content) {
    //////Fix widget for groups $url = "pages/owner/" . elgg_get_page_owner_entity()->username;
    $more_link = elgg_view('output/url', array(
    'href' => $url,
    'text' => elgg_echo('pages:more'),
    'is_trusted' => true,
    ));
    echo "<span class=\"elgg-widget-more\">$more_link</span>";
    } else {
    echo elgg_echo('pages:none');
    }

    Thank you very much.

    Great Elgg community!!! 

  • Same problem does also occur with the blog widget on group pages when Widget Manager plugin is used. It only works by coincidence because the blogs plugin catches the wrong urls (as the blogs plugin itself used a different url scheme in the past) and redirects to the correct page. Still, a deprecation warning occurs.

    For the widgets of other core plugins (files) the same issue might occur, too. Maybe the best would be if the Widget Manager plugin would be updated to include the necessary widgets for groups itself.

  • Yes @iionly, with files same problem, but not with blogs for me (maybe because I´ve blog_tools plugin installed).

    With files I´ve done same procedure with this code:

    $container = $vars['entity']->getContainerEntity();

    //Fix widget for groups @Gerard
    if ($content) {
    if (elgg_instanceof($container, 'group')) {
    $url = "file/group/" . elgg_get_page_owner_entity()->guid . "/all";
    }else{
    $url = "file/owner/" . elgg_get_page_owner_entity()->username;
    }
    }
    ///////

    if ($content) {
    // $url = "file/owner/" . elgg_get_page_owner_entity()->username;
    $more_link = elgg_view('output/url', array(
    'href' => $url,
    'text' => elgg_echo('file:more'),
    'is_trusted' => true,
    ));
    echo "<span class=\"elgg-widget-more\">$more_link</span>";
    } else {
    echo elgg_echo('file:none');
    }

    I will link this thread in Widget Manager discussion, sure it help