new dynamic page with php

Hello,

is it possible to create a new dynamic page or functionality? But not via the admin page, because there is no possibility to add php code.
I would like to add a page inside the default layout and I would like to use the cumulus session management and so on. I do not know in which way or in which folder should I copy the php file.
Can you help me?

Comments

  • You can create a small plugin which simply adds routes to the router. Hook into the 'router.static_routes' filter and add as many custom routes/pages as you like.

    The routes you create can point to any custom PHP file as your controller. You can set the pth to the theme file from your controller.

    Should be pretty easy to do.
  • Thanks for the answer. I have written a plugin. The basic function is there but there are further problems.
    first of all my plugin code:


    ...
    public function load()
    {
    Plugin::attachFilter('router.static_routes', array($this, 'addroutes'));
    }
    public function addroutes($routes)
    {
    $routes['test'] = new Route(array(
    'path' => 'test',
    'location' => DOC_ROOT . '/cc-core/controllers/test.php'
    ));
    return $routes;
    }
    }


    is this right?
    in my log files there are many errors:

    PHP Warning: Missing argument 1 for addroutes::addroutes(), called in .../cc-core/lib/Plugin.php on line 133 and defined in .../cc-content/plugins/addroutes/addroutes.php on line 40

    I know that the first argument $routes is meant but it works. Where is the problem?

    And the second problem I have, how could I use the theme? like create a new page in admin panel with default layout. What I have to write into the "test.php" file.
  • Your plugin looks good. You are only missing the "name" property on your route. The name property is used as the page name in the view and theme. So you should do this instead:

    $routes['test'] = new Route(array(
    'path' => 'test',
    'location' => DOC_ROOT . '/cc-core/controllers/test.php',
    'name' => 'test'
    ));


    The rest can stay the same.

    The warning looks like it's coming from your plugin's constructor method. Are you running the latest version of CumulusClips (v2.3.1 as of today)? If so, please post the entire plugin file "addroutes.php" so that we could further debug.

    To set the view for your custom page, simply add this:

    $this->view->options->viewFile = DOC_ROOT . '/path/to/view.php';

    To your custom controller, in your case test.php as noted in your route.
  • @rodrigar You could use the plugin you already created and just add a new method to it that does what I described above.

    I'm closing this thread as the original poster never followed up. If you wish to continue to a ask about this, please open a new thread and we will gladly help you there.
This discussion has been closed.