Search

Hi,

Sorry - newbie to Symphony, so if this is covered somewhere else, please direct me (although after searching, I can’t find it).

We’ve used symphony as CMS the front page/brochure site to our web application - we require our front page to have a login form which sends the user to the our web app (for login, etc. which in turns sends a user back if the username or password is invalid - yep, I am aware we could do more with regards to using something like JQuery to auth before redirect, etc. however, for now…).

Our web app relies on passing a token within the form (as part of the session), along with changing the “name” of input fields dynamically, again, session based.

How would I go about manipulating the markup/XSLT from a php function that creates these fields dyamically for me? I was looking at creating an extension, but this is maybe overkill? There doesn’t seem like too much documentation knocking around for creating a new extension either (or again, I could be looking in the wrong place?)

So I hope that made sense?

Thanks in advance for any replies.

Thanks, James.

The best way would be to provide the information you need to manipulate your form through your page XML. Top get your own custom content into the page XML you can do this either with an Event or a Data Source. It doesn’t matter which you choose, but I think a Data Source probably makes the most sense (I think of a Data Source as providing content/data to your page, and an Event manipulating or processing content/data from a page).

Take a look at your existing /workspace/data-sources folder and you’ll find the Data Sources that you’ve created using Symphony. You should be able to customise one of these (duplicating it and changing some PHP) to get the information you need.

How about something like this:

<?php

    require_once(TOOLKIT . '/class.datasource.php');

    Class datasourceloginform extends Datasource{

        public $dsParamROOTELEMENT = 'login-form-info';

        public function __construct(&$parent, $env=NULL, $process_params=true){
            parent::__construct($parent, $env, $process_params);
        }

        public function about() {
            return array(
                     'name' => 'Login Form Info',
                     'author' => array(
                            'name' => 'Your Name',
                            'website' => 'http://domain.com',
                            'email' => 'you@domain.com'),
                     'version' => '1.0',
                     'release-date' => '2010-08-02');
        }

        public function grab(&$param_pool=NULL) {           
            $result = new XMLElement($this->dsParamROOTELEMENT);
            $result->setAttribute('foo', 'bar');
            $result->appendChild(new XMLElement('foo', 'bar'));
            return $result;
        }
    }

This is a custom Data Source that you can attach to a page (save it as data.loginform.php in /workspace/data-sources). Notice the grab() function which returns an XMLElement which is a Symphony object that represents an XML element. You should be able to append the data you need as attributes or elements, and then read these values using XSLT.

Brilliant - thanks. I’m giving that a go right now…..

Yep - that was spot on!

Brilliant, Many thanks :)

Cheers, James.

No probs :-)

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