Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Best way of override a class in Vanilla Forums

jonaguerajonaguera New
edited March 2016 in Vanilla 2.0 - 2.8

I had integrate JSconnect in vanilla in order to use an external login system. In addition, I have followed the recommendations in this post ... https://vanillaforums.org/discussion/28209/change-the-url-of-user-profile
... in order to generate the link to the user profile in the external system (overriding UserUrl function in bootstrap.before.php).

But the links to the current user profile are generating as "/profile", and since I put the custom UserUrl function in bootstrap.before.php, /profile path gives me a "Page not found" error.

I can bypass this problem by adding this lines in library/core/class.theme.php , in Link method... after $Url = Gdn::Request()->Url($Path, $WithDomain); ...

  switch ($Path) {
     case 'profile':
        $Url = UserUrl($Session->User);
        break;
  }

My question is ... how can I put this piece of code out of the core files? How can I override GDN_Theme::Link method to add this snippet, but in an external file?

Tagged:

Best Answer

Answers

  • R_JR_J Ex-Fanboy Munich Admin

    Based on what I can find in some plugins here, I guess you could try to pt the following code in conf/bootstrap.before.php:

    $tmp = Gdn::factoryOverwrite(true);
    Gdn::factoryInstall(
        Gdn::AliasTheme,
        'Gdn_Theme',
        PATH_ROOT.DS.'conf'.DS.'class.theme.php'
    );
    Gdn::factoryOverwrite($tmp);
    unset($tmp);
    

    There surely are better places for a custom class than the conf folder. Maybe a plugin folder with a "fake" plugin that only displays a "how to enable this" in its settings.

  • I finally implemented @hgtonight solution and redirect 302 to the "current user profile" of the master system. I think it's more straightforward than the way I was taking.

    Thank you very much.

Sign In or Register to comment.