Search

Most of the core is pretty well documented (or self-explaining), but the content directory of some extensions (and its contents) is still a mistery to me.

I understand that every file creates its own page, but how are the functions inside those files related to the way they are called? (action, view, etc)

Is there some documentation about these files that I am missing?

Maybe I should be more specific.

If I wanted to make a page which accepts a url parameter (containing the section to save to) and I wanted to create an index and an edit page, how would I do that?

Do I have to create new functions like: __ViewEdit, __ViewIndex? Where does the __ActionIndex() function I’ve seen a lot come in? (haven’t been able to call them from a url)

Have a look at the __switchboard() method in /symphony/lib/toolkit/class.administrationpage.php (line 103):

    function __switchboard($type='view'){

        if(!isset($this->_context[0]) || trim($this->_context[0]) == '') $context = 'index';
        else $context = $this->_context[0];

        $function = ($type == 'action' ? '__action' : '__view') . ucfirst($context);

        if(!method_exists($this, $function)) {

            ## If there is no action function, just return without doing anything
            if($type == 'action') return;

            $this->_Parent->errorPageNotFound();

        }

        $this->$function();

    }

If $_REQUEST['action'] is set, an action() method will trigger. Otherwise, a view() method will trigger. Both of those call the __switchboard() method above, which defers to more specific methods, based on the URL, if they exist.

So /symphony/extension/yourextension/ninjabunnies would look for a __viewNinjabunnies() function (I think). And if you submit a post to that page, you can process it in an __actionNinjabunnies() function. Someone correct me if I’m wrong.

Which means, I believe, that you could have functions in your content.index.php file like:

__viewIndex(){}
__actionIndex(){} // for table actions, for example
__viewEdit(){}
__actionEdit(){}

And then use /symphony/extension/yourextension/ and /symphony/extension/yourextension/edit.

If you want to pass more URL params you can grab them in $this->_context I think.

Thanks a lot!

The __switchboard function was exactly what I was looking for. Just didn’t know where to look;)

I believe your explanation should be in the docs, somewhere.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details