MySource Matrix

E-Commerce module released under GPL

Posted on 05 Jan 2009 10:05pm by Aleks Bochniak

Today the E-Commerce model was released under the GPL version of MySource Matrix 3.20.0. Other modules such as Bulkmail, Calendar and Search were also included from the SSV version and distributed under the GPL.

This is an important release for MySource Matrix GPL users, as we now have the ability to create more dynamic websites using this new release. I have been testing 3.20.0 RC1 for about a week now, and I am quite pleased with it. The 3.20.0 stable release is even better with more bug fixes and features added.

Some additionals features of particular interest to me are:

  • Hipo Herder: Resume jobs in new window
  • Clear Matrix Cache: Multiple Root Nodes
  • New re-cache suffix
  • Metadata Value Cascading
  • Simple Edit Layouts applied by Root Node
  • Multi-Page Forms
  • Log In as another user (Troubleshooting Tool)
  • New Global Keyword for HTTP POST variable replacements
  • The name of the user that committed each asset version is now shown on the asset "History" screen

Most of this features have been required for quite some time, and it's good to finally see them released. Details about each of those features can be seen in the changelog.

Over the next couple of weeks I am going to add more content to this website, as well as a demonstration of the e-commerce module. I've been toying with the idea to see how possible it is to use paypal as a payment gateway, so keep an eye out for that too.

Permalink | Read comments

Enabling MySource Matrix cache

Posted on 21 May 2008 3:08am by Aleks Bochniak

By default MySource Matrix comes shipped with caching turn off. Squiz recommend in their documentation that to increase performance, caching should be enabled for your sites. To do this, you will need to access the Cache Manager in System Management via the Asset tree. The Cache Manager allows you to turn on caching as well as set the default expiry time.

The number of cache buckets allows you to set the file system directories to use for caching. If you set a low number, each directory will hold a large number of files which may reach operating system limits. If you set the number too high, each directory will hold a small number of files which may be inefficient.

The default expiry length (seconds) is 86400 (24h). For my site I have changed this to 604800 seconds (one week), as I don't post very often. I have also enabled Public Level, Permission Level and Group Level caching. More information about these options can be found in the System Administrator manual on Squiz's documentation website.

When an asset is updated the cache is not automatically cleared until the expiry time has been reached. To get around waiting for changes to appear on your site, you can create a Trigger to automatically clear the cache for an asset that has been updated.

Trigger to clear cache

Under the Trigger Manager (under System Management in the Asset tree), create a child asset of type Trigger named 'Clear cache on update'.

Set the following options:

Details

  • Status: Enabled

Events

  • Asset Updated

Conditions

  • Nil

Actions

  • Clear Matrix Cache
    Ignore Permissions
    Include Current Asset? Yes
    Level Selected assets and their dependants
  • Clear Matrix Cache
    Ignore Permissions
    Include Current Asset? Yes
    Level Selected assets and their children

The dependants of an asset are those that cannot exist without that asset. For example, the Page Contents asset of a Standard Page. The children of an asset are those that have been created underneath it in the hierarchy.

What this Trigger will do is clear the cache for any asset that has any of the attributes listed in Events updated. The cache for Asset Listings and Paint Layouts which list/nest other asset types will not be automatically cleared with this trigger. That is one exercise for you to figure out for yourself.

Permalink | Read comments

Upgraded MySource Matrix to 3.18.0

Posted on 23 Apr 2008 9:11pm by Aleks Bochniak

Finally after much drama of upgrading from Ubuntu Dapper to Edgy, then to Feisty, and then to Gutsy. I now have a working MySource Matrix 3.18.0 installation running on php5. woot

Now, I will go have a play and see what all the fuss is about. CAPTCHA on Asset Builders here I come!

Permalink | Read comments

How to make a tag cloud

Posted on 22 Jan 2008 9:39pm by Aleks Bochniak

Tag clouds or 'tagging' has been around used the web for a couple of years now, it's not relatively new or unique. However, using tags and/or tag clouds on your web-site can add value to your content and be beneficial to your users.

What is a tag cloud exactly? Wikipedia has a good definition. A simple example is just to your right in the side column under the heading 'Tags used'.

Creating one of these can be a little tricky in MySource Matrix, especially the GPL version (no lovely search module here). Since we can't use php code in our pages, we have to use javascript to do the hard work for us.

Some clarification

There are 3 different ways to tag a page or asset with terms. One way is to create a lexicon of terms in a thesaurus and use the tagging screen to select these terms, however it's not possible to print out which terms are used on the front-end and their associated weighting. Kind of disappointing really.

Screenshot of creating new metadata field type

The other two ways involve metadata. One using a thesaurus as a metadata field type, or using a multiple text field type. I prefer the multiple text option, as it allows me to enter free text as terms and removes the hassle of maintaining a definitive list separate to my content.

Building the cloud

First thing we need to do is to create a metadata schema with a default section and one metadata field called 'tags' of type "multiple text field".

Secondly create a few pages in a folder, apply our metadata schema and tag some terms. I have a few dummy pages which I have tagged with some latin text.

Below is part of a screenshot of one page's metadata screen.

Screenshot of a sample metadata screen

Next we need to create an asset listing page called 'tag cloud' to find all the pages in the folder. Nothing tricky needs to be defined for the asset listing, just the types of assets to list "Standard Page" and root node; being your folder.

I would suggest for all the divs created and used in this example be of type "Raw HTML" and style "Raw HTML". On the Type Formats -> Default Format page contents enter the following without trailing spaces:

%asset_metadata_tags%;

This tag should spit out something like (with the semicolon at the end):

lorem; lipsum; consectetuer; platea; nunc; morbi; mauris; venenatis; donec; primis; nulla; leo id; morbi; arcu; nunc; aliquam; mollis; elementum; commodo; nulla; tristique; pretium; ultrices; lorem; nunc; ultrices; leo; accumsan; nulla; condimentum; cursus; quam; posuere; curae; ipsum; primis; lorem; leo id; nulla; ultricies; libero; loboritis; non; ante; morbi; tristique; senectus; pellentesque; aliquet; curae; nonummy; nulla; suscipit; magna; lorem; purus; sapien; cras; ligula; iaculis; suscipit; commodo;

Now we need some javascript to split that long string into an array of unique terms, ordered alphabetically and their frequency counted.

Javascript comes to the rescue

In my Design I am importing a javascript file which contains 3 functions that help sort the array of terms and assign a css class to the tag link.


function unique(x) {   
  tmp = new Array(0);   
  for(i=0;i<x.length;i++) {      
    if(!contains(tmp, x[i])) {         
      tmp.length+=1;         
      tmp[tmp.length-1]=x[i];      
    }   
  }   
  return tmp;
}

function contains(x, e) {   
  for(j=0;j<x.length;j++) {
    if(x[j]==e) {
      return true; 
    }
  }  
  return false;
}

function getTagClass(z) {   
  var tagClass = "smallestTag";   
  if(z==smallest) {   
    tagClass="smallestTag";   
  } else if(z==largest) {   
    tagClass="largestTag";    
  } else if(z >= large) {    
    tagClass="largeTag";    
  } else if(z <= large && z >= medium) {    
    tagClass="mediumTag";    
  } else if(z <= medium && z >= smallest) {    
    tagClass="smallTag";   
  }   
  return tagClass;
}

In the Page Contents of the 'tag cloud' asset listing page, we need to pull in the list of tags with the %asset_listing% keyword and assign it a javascript string for processing. This string then needs to be split into an array, duplicates removed and sorted alphabetically.


<script type="text/javascript">
<!--
var a = '%asset_listing%';
var split = new Array();
split = a.split('; '); //string to array
var unique = unique(split);
unique.sort(); //sort alphabetically

We also need to find the number of times (frequency) a tag term is being used so we can assign a font size (with a css class) to it.


var frequency = new Array();
var counts = new Array();
var largest = 0;
var smallest = 1;
/* create array of tag counts and find sizes */
for(var i=0; i<unique.length-1; i++) {
   var mullet=0;
   unique[i] = unique[i].replace(/^\s+|\s+$/g, '') ;
   for(var j=0; j<split.length; j++) {
      if (unique[i]==split[j]) {
          mullet=mullet+1;
      }
      frequency[i] = mullet;
   }
}

Now, we need to do some simple maths to find the largest times a term has been used, the medium value, distribution and difference. The size of the tags will be from the smallest (1) to the largest (we still need to find it!).


for(var d=0;d<frequency.length;d++){
   largest=Math.max(largest,frequency[d]); //find largest
}
var diff = largest-smallest; //difference, smallest is always 1
var dist = diff/3; //distribution
var large = 1 + (dist*2);
var medium = 1 + dist;

The following code is used to write out a paragraph with the tags linked to Google blogsearch, and style the link with their relevant size.


/* continue */
if(unique.length != 0) {
  document.write('<p id=\"tags\">');
  for(var i=0; i<unique.length-1; i++) {
     var z=0;
     for(var j=0; j<split.length; j++) {
        if (unique[i]==split[j]) {
            z=z+1;
        }
        counts[i] = z;
     }
     var size = getTagClass(z);
     document.write('<a class=\"'+size+'" href=\"http://blogsearch.google
.com/blogsearch?q='+unique[i]+'\">'+unique[i]+'</a> ');
  }
  document.write('</p>');
}
//-->
</script>

So, that's basically it. There are probably a few ways to optimise the code and behaviour, but that's an exercise to come later when I have time. As a quick start it works very well.

Screenshot of a sample tag cloud

Above is a image of a tag cloud I created using this code.

Permalink | Read comments

Installing MySource Matrix on Ubuntu

Posted on 10 Jan 2008 9:01pm by Aleks Bochniak

Let's begin

This how to is written specifically for Ubuntu Dapper, however the instructions should still work with Edgy, Feisty and Gutsy.

Ubuntu’s package management is done through apt-get. But it starts out handicapped. You need to edit a config file as root to add some additional sources:

$ su root
$ vi /etc/apt/sources.list

Uncomment these lines (remove the “#“):

# deb http://us.archive.ubuntu.com/ubuntu/ dapper universe
# deb http://security.ubuntu.com/ubuntu dapper-security universe
# deb-src http://security.ubuntu.com/ubuntu dapper-security universe

Now update the repository index and upgrade your built-in software:

$ apt-get update && apt-get upgrade

OK, first the prerequisites; the first line installs some basic compiling tools you’ll need, like “make”.

$ apt-get install build-essential

Install Apache and PHP 4

As root, apt-get install the following packages:

  • apache2
  • apache2-common
  • apache2-mpm-prefork
  • apache2-utils
  • apache-common
  • apache-dev
  • apache2-doc
  • apache2-prefork-dev
  • perl
  • perl-base
  • perl-doc
  • perl-modules
  • php-db
  • php-http
  • php-mail
  • php-net-smtp
  • php-net-socket
  • php-pear
  • php-xml-parser
  • php4
  • php4-cli
  • php4-common
  • php4-curl
  • php4-dev
  • php4-gd
  • php4-imagick
  • php4-imap
  • php4-ldap
  • php4-mcrypt
  • php4-mhash
  • php4-pear
  • php4-pspell
  • php4-rrdtool
  • php4-snmp
  • php4-sqlite
  • php5-common
  • libapache2-mod-php4

Apache configuration file is located at: /etc/apache2/apache2.conf and your web folder is /var/www.

Restart the web server.

$ /etc/init.d/apache2 restart

Install the necessary pear modules.

$ pear install DB
$ pear install Archive_Tar
$ pear install Mail
$ pear install Mail_Mime
$ pear install XML_HTMLSax
$ pear install XML_Parser
$ pear install Text_Diff !(may get prompted to download this package)

Install PostgreSQL

It is recommended to use PostgreSQL 8+ for versions of MySource Matrix above 3.8

$ apt-get install php4-pgsql
$ apt-get install postgresql-8.1
$ apt-get install postgresql-common
$ apt-get install postgresql-client-8.1
$ apt-get install postgresql-client-common

Make sure you switch to the postgres user before creating the users and database for your installation

$ su postgres
$ createuser -U postgres matrix
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
$ createuser -U postgres matrix_secondary
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
$ createdb -U postgres -O matrix -E SQL_ASCII mysource_matrix
$ createlang -U postgres plpgsql mysource_matrix

Switch user back to root.

$ su root

Check your pg_hba.conf file to ensure that local user accounts are allowed "trust" access to PostgreSQL (instead of "ident sameuser", which is the default).

$ vi /etc/postgresql/8.1/main/pg_hba.conf

Change the upper two "local" lines and change "ident sameuser" to "trust".

# Database administrative login by UNIX sockets
local   all         postgres                          trust
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
# "local" is for Unix domain socket connections only
local   all         all                               trust
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

Install MySource Matrix 3.14.4

You can download the GPL version of MySource Matrix from the Squiz's Matrix website

$ su root$ cd /var/www
$ wget http://matrix.squiz.net/__data/assets/file/0013/20281/mysource_3-14-4.tar.gz
$ tar -zxvf mysource_3-8-2.tar.gz
$ cd /var/www/mysource_matrix
$ php install/step_01.php .

Edit the installation config file

$ vi data/private/conf/main.inc

and change these settings:

define('SQ_CONF_DB_DSN', 'pgsql://matrix@unix()/mysource_matrix');
define('SQ_CONF_DB2_DSN', 'pgsql://matrix@unix()/mysource_matrix');
define('SQ_CONF_DB3_DSN', 'pgsql://matrix_secondary@unix()/mysource_matrix');
define('SQ_CONF_SYSTEM_ROOT_URLS', '127.0.0.1');

This lines are just the minimum required for an initial installation, you can change the others if need be. More info here http://matrix.squiz.net/resources/installation/annotated-main.inc

Note: The address/ip in this example is the localhost address. Find out the ip of your machine with the command ifconfig.

$ php install/step_02.php .
$ php install/compile_locale.php .
$ php install/step_03.php .
$ php install/compile_locale.php .
$ chmod -R 755 /var/www/mysource_matrix
$ cd /var/www/mysource_matrix
$ chown -R www-data:www-data data cache
$ chmod -R g+w data cache

Apache Configuration

Edit the file /etc/apache2/sites-available/default and paste these lines.

<VirtualHost *:80> 
     DocumentRoot /var/www/mysource_matrix/core/web 
     ServerName 127.0.0.1 
 
     <Directory "/var/www/mysource_matrix"> 
            Options -Indexes FollowSymLinks 
            Order deny,allow 
            Deny from all 
     </Directory>  
     <Directory "/var/www/mysource_matrix/core/web"> 
            Options -Indexes FollowSymLinks 
            Order allow,deny 
            Allow from all 
     </Directory> 
     <Directory "/var/www/mysource_matrix/core/lib"> 
            Options -Indexes FollowSymLinks 
            Order allow,deny 
            Allow from all 
     </Directory> 
     <Directory "/var/www/mysource_matrix/data/public"> 
            Options -Indexes FollowSymLinks 
            Order allow,deny 
            Allow from all 
     </Directory> 
     <Directory "/var/www/mysource_matrix/fudge"> 
            Options -Indexes FollowSymLinks 
            Order allow,deny 
            Allow from all 
     </Directory>  
 
     Alias "/__data"    "/var/www/mysource_matrix/data/public" 
     Alias "/__lib"     "/var/www/mysource_matrix/core/lib" 
     Alias "/__fudge"   "/var/www/mysource_matrix/fudge" 
     Alias "/"          "/var/www/mysource_matrix/core/web/index.php/"  
 
</VirtualHost>

Cron setup

$ crontab -u www-data -e

Insert these lines

*/15 * * * * php /var/www/mysource_matrix/core/cron/run.php
0 0 * * *  /var/www/mysource_matrix/scripts/session_cleanup.sh

Installation Complete

Hopefully everything went smoothly and now you can start your webserver, as root user.

$ sudo /etc/init.d/apache2 start

To access the administration interface, append /_admin to the end of your system root URL. For example, http://127.0.0.1/_admin. You will see a login screen where you can enter the root user's username "root" and password "root".

Enjoy ;-)

EOF

Permalink | Read comments

Displaying 5 of 10 articles

Previous 1 2 Next