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

undefined variable: viewParams

Discussion in 'XenForo Development Discussions' started by Matthew Hawley, Jan 14, 2014.

  1. Matthew Hawley

    Matthew Hawley Well-Known Member

    I am getting this error when I go the route for my custom addon (/directory). I don't get why I am getting this error because a lot of addons use viewParams in the controller public file.

    Server Error
    Undefined variable: viewParams

    1. XenForo_Application::handlePhpError() in CF/Directory/ControllerPublic/Directory.php at line 10
    2. CF_Directory_ControllerPublic_Directory->actionIndex() in XenForo/FrontController.php at line 337
    3. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
    4. XenForo_FrontController->run() in /home3/mcwh/public_html/xxx/index.php at line 13
    Here is my code for /ControllerPublic/Directory.php

    class CF_Directory_ControllerPublic_Directory extends XenForo_ControllerPublic_Abstract
        public function actionIndex()
            // send to template for display
            return $this->responseView('CF_Directory_Index', 'cf_directory_index', $viewParams);
  2. Brogan

    Brogan XenForo Moderator Staff Member

    You haven't defined them.
  3. Chris D

    Chris D XenForo Developer Staff Member

    I would recommend going through some basic PHP tutorials. There are some good ones. Code Academy and ... I think one's called Treehouse.

    It would be wise to go through the basics.
  4. Matthew Hawley

    Matthew Hawley Well-Known Member

    I use codeacademy a lot. I've completed the entire html & css course. :)
  5. Jeremy

    Jeremy Well-Known Member

    Learning basic PHP and how to debug it would be more beneficial to you than an HTML and CSS course.
  6. Matthew Hawley

    Matthew Hawley Well-Known Member

    I know...I was just saying that.
  7. Jeremy

    Jeremy Well-Known Member

    Most of your errors have come from a lack of general PHP knowledge. It would be highly beneficial to learn the basics before attempting an addon.

Share This Page