Home | SourceForge | Documentation | FAQ | What's New | To-Do List | Forums | Download | Contact

Sparse - Frequently Asked Questions

Q. What is Sparse?

A. Sparse is an open source, usable, flexible, powerful framework which allows web developers to make entire CGI applications without ever programming anything - and tossing full Ajax functionality in, to boot. All that's required is knowing how to use a few extra HTML tags and sticking a single PHP tag at the top. For a quick intro, click here.

Q. What can Sparse do?

A. Sparse can deal completely with adding, editing, and displaying data; navigating amongst data; sorting and searching; checking and displaying errors. Sparse will also cache itself so that it only has to get information about the tables and template once.

Q. Why is Sparse different?

A. Sparse allows developers to simply write plain HTML pages with tags representing widgets and buttons for displaying or entering data, similar to XUL. Changing the look or behavior of your form is as simple as changing a tag attribute or moving the tags around. Programming code isn't required at all, though it can be easily augmented with code.

Q. What does Sparse mean?

A. Well, I guess you could say it stands for "SQL Parse(r)", with some acrobatics making the P stand for PHP (it's not like they didn't do it). With the new Ajax functionality, maybe I could argue the A is Ajax. And maybe "sparse", as in "not dense", means you've got a framework that doesn't have too many elements and is easy to understand and use. But really, I just wanted a real English word of one or two syllables that made sense.

Q. Why was Sparse designed?

A. The need for Sparse arose from my own experiences in coding PHP backends, when I found myself doing much of the same things over and over again, and my introduction to Microsoft Access "forms", which allow you to define a user interface that's "attached" to the data. The template for it came from my work in writing Firefox extensions, and my exposure to XUL, which impressed me by its combination of usability and flexibility.

Q. Who's behind Sparse?

A. As of this writing (October 2006), Sparse was coded and documented entirely by myself, Daniel Orner. I am currently an M.Sc. student at York University. My thesis is based on Histree, a Firefox extension. I am also the creator and webmaster of the Final Fantasy Compendium.

Q. What requirements does Sparse have?

A. Sparse is programmed in pure PHP, with no external dependencies. It has been tested with PHP v4.3.8 and MySQL v.3.23.58. It should work with later versions of PHP and MySQL as well. It will not work well with PHP versions less than 4.3, but the MySQL version shouldn't matter much.

Q. Do I have to know PHP to use Sparse?

A. No, you don't! You can use PHP to make your applications do a whole lot more, but you can easily use Sparse without ever writing any PHP. All you need to know is SQL and HTML. (CSS can also make your life easier, but it's not required.)

Q. How is Sparse different from template engines like Smarty?

A. Template engines are designed to separate application logic from business logic. Though that's an excellent and laudable goal, it's not what we do. Sparse is firstly much more specific; it deals only with the common task of SQL programs. Sparse tries to do as much of the application logic as it can, meaning you don't have to program it at all. Other than a few bits and pieces here and there (such as user validation, error displaying, etc.), all of which can be done without any full PHP code at all, presentation is pretty much all there is.

Q. Are there any disadvantages to using Sparse?

A. The beta version does have some issues (including, we expect, many which we haven't even detected yet), which is why we don't recommend it being used for critical applications. For one thing, the Sparse tag reference may change drastically while we figure out exactly what we need to do, so if you use it now you may find that a later version of Sparse might not read your template properly. However, we anticipate that the release version of Sparse will be safe, robust, and fairly stable, so anyone who can help test the beta would get us that much closer to our goal!

Q. What can I do to help Sparse?

A. Sparse is currently in beta, and needs testers! Although it has been extensively tested and seems to be fairly stable, it hasn't been destruct-tested, nor has it been tested on different platforms or versions of PHP/MySQL. We are also extremely interested in suggestions for changes to the tag definitions and reference, so please weigh in on our forums!
We also need a bit of help with our website, which looks a bit, well, sparse. Let us know if you can snazz it up a bit!

Q. How do I install Sparse?

A. You don't have to install it at all. Just put the PHP files in any directory and include them in your HTML file. For example, you can put them in the directory /www/sparse/ , and then at the top of every file you use Sparse with, you just put the following:

  SparseThisPage('username', 'password');

Don't forget that your server will have to parse your HTML file using PHP, so generally you'll have to save it with the file extension .phtml or .php.

Q. What do the colors in the documentation mean?

A. Brown words mean an HTML tag. Blue words mean an HTML attribute. Pink words mean a value of an HTML attribute (e.g. display or update).

Q. Does Sparse require that the user have cookies enabled?

A. Sparse uses PHP's session functionality, which only uses cookies if Ajax is turned off (see Configuring Sparse). You can alter this behavior by including the following directive before you call SparseThisPage() or SparsePage():

ini_set(session.use_cookies, "0");

Q. Does Sparse require that the user have Javascript enabled?

A. No, Sparse does not require Javascript. It outputs a full Ajax program, but is fully degradable, meaning that if Javascript is disabled, it'll still work fine.

Q. Sparse is acting weird or messing up! What's wrong?

A. Sparse can get confused a couple of ways. Firstly, you can check the warning log for some indications of things you may be doing wrong (see Configuring Sparse). Here's a checklist of things you shouldn't be doing:
Many important errors other than the ones mentioned will be indicated in the warning log.

Q. Can I interleave Sparse forms with my own?

A.  Yes. You can use regular <INPUT> tags inside an sqltemplate tag and it'll be returned normally; you can deal with it inside your PHP code. Just ignore anything beginning with "sparse" or "SPARSE" in $_REQUEST. You can use this to e.g. upload files, get values that have nothing to do with the defined tables, etc.

Q. Can I put other PHP tags in my Sparse template?

A. Yes, you can include any PHP code you want! Take a look at the Advanced PHP Usage page for more details!

Q. Can I embed a Sparse tag inside another tag or attribute?

A. Yes! You can use this to e.g. print out part of a link. For example:

<a href="employee.php?employee=<sqlfield name="employee" type="text" />">

Note that although this is not valid HTML, by the time Sparse is finished with it, it will be. 8-) The entire sqlfield tag will be replaced by a single value.

Q. Can I nest Sparse templates (i.e. place one within another)?

A. Unfortunately, allowing nested templates would be very difficult in the current implementation and would require making the Sparse code significantly more complex than it is now. There are no plans to implement this at the moment.

Q. I have a field which is a foreign key. Can I "link" it so that only one widget is used in my template?

A. You can use a hidden sqlfield tag to do this. Let's say you have two fields "myField1" and "myField2". Create your sqlfield widget with the name myField1, then create another sqlfield with the name myField2, whose type is hidden, and set its displayValue attribute to $row['myField1']. When the row is updated, both fields will be given the same value.