Search

Is anyone familiar with how Symphony handles system authors in the admin interface?

I'm working on an extension that re-purposes a lot of the existing code that handles authors, but I can't figure out how a specific part works. In content.systemauthors.php there is code that makes author names (first column in table) a link to edit that author. I'm looking at the block that starts here.

When you get to the edit form, it should already be filled in with the existing information. The viewEdit method expects that the information is posted and tests for it here.

Can someone point me to where in the code the author fields are posted? I have almost everything else working, and can even update existing items in my extension, but I can't get it to show the existing information in the form.

New Authors are persisted to the authors table using the __action* functions in that file. __actionNew is for new Authors, __actionEdit handles existing Authors.

brendo, when you say "persisted to the authors table" do you mean written to the the mysql table "sym_authors"? I think I have that understood and working in my extension. My extension uses a new table for different items, but works the same way.

My understanding is that the action* functions are executed before running the corresponding view* functions. So a user goes to /system/authors/ to get the index page (the clickable table of authors). If the user clicks an author's name (while logged in as a developer), the link is to the edit page at /system/authors/edit/$id/ where the actionEdit function checks to see if the page is being reloaded after a "save" or "delete" action. Then, the viewEdit function is run. In this case, it pulls up the function that handles the form. In both actionEdit and form, some of the first things done require checking $_POST variables.

What I can't figure out is how clicking the link on the index page gets $_POST populated with the rest of the fields for the author that is clicked so that the info can be used in the actionEdit and form functions.

Well, now I'm not sure how the page is supposed to work.

I used Firebug to see if I could figure out what was going on with post variables, but it doesn't look like the fields are sent via $_POST when I click an author's name.

But looking at the form function, it still appears to me that it is either using an existing Author object or creating a new Author object depending on what is in $_POST.

After looking at the relevant files for the zillionth time, I think I was misunderstanding how the form function worked. If I finally read it right, there's no post data passed between the index and edit functions (at least in the case I'm worried about). Rather the if-else stuff gets the author id from the URL and fetches all the author info from the database. Done in the "if" statements inside the "else if".

if(isset($_POST['fields'])) {
    $author = $this->_Author;
}
else if($this->_context[0] == 'edit') {
    if(!$author_id = (int)$this->_context[1]) redirect(SYMPHONY_URL . '/system/authors/');

    if(!$author = AuthorManager::fetchByID($author_id)){
        Administration::instance()->throwCustomError(
            __('The author profile you requested does not exist.'),
            __('Author not found'),
            Page::HTTP_STATUS_NOT_FOUND
        );
    }
}
else $author = new Author;

If I finally got this correct, I guess $_POST would be populated with "fields" as in the first "if" statement if it's handling a saved action from the actionEdit function.

Correct, the __action* functions are only loaded up if $_REQUEST['action'] has a value. So clicking through from the index to the profile page does not trigger the methods, just __viewEdit(), which like you said, uses the AuthorManager to the retrieve the data.

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