1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Lack of Interest Assign Route Filters to addons

Discussion in 'Closed Suggestions' started by xf_phantom, Jun 26, 2013.

  1. xf_phantom

    xf_phantom Well-Known Member

    It would be nice if we could assign the route filters to addons, just like the templates,phrases,prefixes,etc...
    So they'll become exportable with the addons.
     
    XCentral, rellect, nrep and 1 other person like this.
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    I personally feel that no add-on should make such a decision for an end user. So, for that reason, I'm against this.
     
  3. xf_phantom

    xf_phantom Well-Known Member

    My suggestions isn't really because of the possibility to share them with others
    It's to not have to do the changes manual on all the instances (dev, test, live) Just like with the suggestion to be able to export the options:D
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    If anything, it should export to a separate file. No add-on should have the power to over write options / routes on install (I guess you could add them via PHP).

    If this existed, you know add-on authors would do this and inadvertently screw up users sites.
     
  5. Jeremy P

    Jeremy P Well-Known Member

    Yeah how about exporting filters in general? I see the merit in being able to share the same ones across sites, but it shouldn't be tied to addons.
     
  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    ^ This ^. I would support that, but not attaching to add-ons.
     
  7. Chris D

    Chris D XenForo Developer Staff Member

    I would like to throw my 2p into the argument.

    I think distributing route filters with add-ons has a valid use case. I'm actually doing it with Xen Media Gallery 2.0.

    PHP:
            $filterExists $db->fetchRow('
                SELECT *
                FROM xf_route_filter
                WHERE find_route = ?
            '
    'xengallery/');

            if (!
    $filterExists)
            {
                
    $routeFilterWriter XenForo_DataWriter::create('XenForo_DataWriter_RouteFilter');

                
    $routeFilterWriter->bulkSet(array(
                    
    'route_type' => 'public',
                    
    'prefix' => 'xengallery',
                    
    'find_route' => 'xengallery',
                    
    'replace_route' => 'media',
                    
    'enabled' => 1,
                    
    'url_to_route_only' => 0
                
    ));

                
    $routeFilterWriter->save();
            }
    Why?

    Simple. When I first created Xen Media Gallery, the default route of the add-on was "media". Straight away it became apparent that this would:
    It would clash with other add-ons using the same route. I could have changed it to gallery. But no doubt one day that would clash too. If XenForo released an official gallery, that may cause issues too.

    So I made the change so that my add-on was shipped with the route "xengallery".

    I implemented my own route changer type system so that it was easy to change "xengallery" to "media" and I shipped that with the default option.

    Since the Route Filters came along, I can use the above code in the installer to create the route filter if it doesn't exist and later remove it during uninstall. I'm happy to carry on doing this, but I'd much rather that process be handled by XenForo and be more closely tied with the add-on system. As well as creating and removing the route filter, I'd like to see that being upgraded by an add-on upgrade and disabling it if the add-on is disabled.

    The latter in itself goes some way to mitigate the issue of a site being screwed up by an add-on or causing problems with others. But, of course, they can be disabled in the Admin CP easily enough anyway. And there's just as much chance of someone screwing up an install using my code above, as there is if a route filter was added using an add-on XML.

    So, hopefully, this might still be considered when the time is right :)
     
    Dan and Daniel Hood like this.

Share This Page