Best way of override a class in Vanilla Forums
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?
Best Answer
-
hgtonight MVP
Just route
/profile
to your other default profile link. Use the routes section of the dashboard.Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
8
Answers
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
: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.
Just route
/profile
to your other default profile link. Use the routes section of the dashboard.Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
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.