Search

Hi,

I like to incorporate some values of a webcart session directly into the page XML output so I can generate a form to conclude the payment.

Would this be possible, and how?

Well, there is the old Session Monster extension, which I believe still functions. If not, I’m sure you could use it as a basis for something that does.

Or you could write a custom data source that puts the session data in an XMLElement object and returns it. Then add that data source to your page.

Here’s one that works on my site:

<?php
require_once(TOOLKIT . '/class.datasource.php');
Class datasourceSession extends Datasource{
    function about(){
        return array(
                'name' => 'Session Data',
                'author' => array(
                    'name' => 'Carson Sasser',
                    'website' => 'http://carsonsasser.com',
                    'email' => 'sassercw@cox.net'),
                'version' => '1.0',
                'release-date' => '2010-08-23T12:00:00+00:00');
    }
    function grab(&$param_pool) {
        $result = new XMLElement("session_data");
        foreach($_SESSION['sym-'] as $key => $value) {
            $node = new XMLElement($key, $value);
            $result->appendChild($node);
        }
        return $result;
    }
}

I’m with wisolman, a custom DS is what you’re after. A quick note that you’d name your file data.session.php and save it to /workspace/data-sources and it’ll show up in the Blueprints > Data Sources list (and the list when configuring a page).

I didn’t use it in the end, but after I requested it Lemonstand added the ability to include its “partials” (mini HTML/XML views) into Symphony very easily (discussion).

Ok great, thanks.

I am getting an error though when I loop through my cart session in the custom datasource (Invalid argument supplied for foreach()).

    foreach($_SESSION['cart'] as $key => $value) {
        $node = new XMLElement($key, $value);
        $result->appendChild($node);
    }

I also tried using $_SESSION[‘sym-‘][‘cart’] for the cart session which did not work.

Invalid argument supplied for foreach()

This’ll occur if what you’re iterating over is not an array. Try:

var_dump($_SESSION);die;

What do you see?

I’m fairly sure someone has asked about this before, in that they try to access SESSION themselves and it’s empty. Not sure if Symphony is doing anything to overwrite sessions or somesuch?

Ok thanks,

That’s the strange thing, the session should not be empty. The cart is filled and shows up in the the website alright using the exact same session data. But perhaps I made a little glitch 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