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

Add-on to add page to the account section

Discussion in 'XenForo Development Discussions' started by Radi, Aug 3, 2015.

  1. Radi

    Radi Member


    I am working on an add-on that will integrate SilverPop with XenForo.

    That is my first add-on, so please bear with me.

    By reading the how-to's, I was able to add links to the account sidebar, but am having a hard time finding information on how to add a view and route to it. I have experience with CakePHP, but XenForo is very different MVC.

    I am linking users to - /index.php?account/email-preferences and need a way to display my page(view) when a user goes there.

    Any help is welcome!

    Here is my code:


    class SilverpopIntegration_Listener_LoadClassController {
        public static function 
    extendControllerPublic_Account($class, array &$extend) {
            if (
    $class == 'XenForo_ControllerPublic_Account') {
    $extend[] = 'SilverpopIntegration_Index_ControllerPublic_Account';

    class SilverpopIntegration_Index_ControllerPublic_Account extends XFCP_SilverpopIntegration_Index_ControllerPublic_Account {
        public function 
    actionEmailPreferences() {
    // code...
    2015-08-03 17_21_46-Code Event Listener Editor _ Admin CP - XenForo.png

    Now when I reload the account page I see this message:
    Fatal error: Class 'SilverpopIntegration_Index_ControllerPublic_Account' not found in W:\var\www\html\www.xenforo.localhost\library\XenForo\FrontController.php on line 442
    Last edited: Aug 3, 2015
  2. Chris D

    Chris D XenForo Developer Staff Member

    There is a very strict naming convention - it's one class per file, and the file name and class name are made from each other.

    With that in mind, this is named correctly:
    Filename: /SilverpopIntegration/Listener/LoadClassController.php
    Class: SilverpopIntegration_Listener_LoadClassController

    This isn't:
    Filename: /SilverpopIntegration/Index.php
    Class: SilverpopIntegration_Index_ControllerPublic_Account

    The correct file name should be (based on that class name):
  3. Radi

    Radi Member

    Thank you @Chris D. That was very helpful. I will remember this one :)

    I updated my code to:
    class SilverpopIntegration_ControllerPublic_Account extends XFCP_SilverpopIntegration_ControllerPublic_Account {
        public function 
    actionEmailPreferences() {
    // do stuff
    and that fixed my issue.

    Would you please shed some light on this part of my code:

            return $this->_getWrapper(
    Am I doing that correct? What is "XenForo_ViewPublic_Account_Preferences_SilverpopIntegration_Index" used for?
    Last edited: Aug 4, 2015

Share This Page