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

Overriding an option?

Discussion in 'XenForo Development Discussions' started by Renari, Mar 14, 2014.

  1. Renari

    Renari Member

    I've been trying to override the boardIndex option and the only way I can see to do it is to make a class that extends the autoloader class and have it override the value and use XenForo_Autoloader::setInstance() to force the modified version.

    I haven't tested the above but does anyone know of an easier way to go about doing this?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    Use the Option DataWriter to update the value.
     
  3. Renari

    Renari Member

    Thanks Chris,
    PHP:
        public static function indexRouteOverride(XenForo_Dependencies_Abstract $dependencies, array $data)
        {
            
    $dw XenForo_DataWriter::create('XenForo_DataWriter_Option');
            
    $dw->setExistingData('indexRoute');
            
    $dw->setOption('indexRoute''home');
            
    $dw->save();
        }
    I was calling this at the init_dependancies hook and it says that indexRoute is an unknown option. I believe this is because at that time the board hasn't loaded any of it's options. But I can't seem to find a better place to put this, assuming I'm even using the datawriter class correctly which it's entirely possible I'm not.
     
    Last edited: Mar 16, 2014
  4. Chris D

    Chris D XenForo Developer Staff Member

    This is what you need to do:

    PHP:
        public static function indexRouteOverride(XenForo_Dependencies_Abstract $dependencies, array $data)
        {
            
    $dw XenForo_DataWriter::create('XenForo_DataWriter_Option');
            
    $dw->setExistingData('indexRoute'true);
            
    $dw->set('option_value''home');
            
    $dw->save();
        }
     
    Renari likes this.

Share This Page