 |
|
Wednesday, September 29. 2004
Not at all Syntax related but I was looking at PHP Presents today and am quite impressed by the range of presentations available. Does anyone know if there are similar presentaion repositories available for HTML, MySql, or other LAMP components?
Monday, September 27. 2004
Version 1.1.1 of Syntax CMS is available Syntax CMS 1.1.1. This release bundles a number of bugfixes and minor feature improvements:
- Various fixes to make syntax less dependent on register_globals being on
- Added :hover styling for rows in navigation widget to make it easier to pick out where to publish/feature content.
- Added htmlarea textarea WYSIWG editor as an available widget.
- Display fixes in Site Administration application.
- Added _link() method to simplify outputing href tags.
- Standardized use of NAV_ROOT_EL to build out section paths, breadcrumbs, etc.
- Improved CSS style of Site Administration app.
Thursday, September 16. 2004
The ListWidget class goes a long way towards making it easy to work with input widgets for lists of options. One of the most common uses of it is for building filtering interfaces based on a picktable in your syntax database. Usually, to do so you have to jump through a small number of hoops.
pxdb_import( 'content.output.pxdb_picktable' );
$picks = new pxdb_picktable( 'topics' );
$topics = $picks->get_listwidget_array();
// add default 'All' option at top
$topics = array_unshift( $topics, array( 'value' => '', 'label'=>'All' ) );
$topicsList= new ListWidget( $topics, 'topic' );
Now in cvs, is a single function that replicates the above lines. Its signature is list_from_picktable( $form_element_name, $pick_table_name, $additional_elements). The $additional_elements parameter is primarily there for adding a default or 'All' element at the beginning of your list.
$topicsList = list_from_picktable( 'topic', 'topics', array( 'value' => '', 'label'=>'All' ) );
Tuesday, September 14. 2004
One of the task's we're often asked to do is save input from a form to the database and also send a notification message to a recipient. Recently I had to do that and include the record's data as part of the email message. While it's easy enough to build a custom message each time, the following solution builds the message body based on a defined view for your datatype. You'll need a newer copy of the metadata.pxdb_view class as I had to add a method to it allowing you to create a pxdb_view object based on the datatype id and view name. The main benefit to this approach, beyond it's flexibility is that we can add new fields to our view and the email sent out will automatically include those too without further intervention on your part.
if( $rec_id = $adm->save() )
{
pxdb_import( 'content.output.pxdb_record' );
pxdb_import( 'metadata.pxdb_view' );
// success! -- $rec_id is saved (or added) record id
$view = "success"; // for redirection later
// now get the just saved record back out of the database
$record = new pxdb_record( $rec_id );
// start building our email message
$msg = "A new feedback message has been sent:\n";
//get the 'public' view for the FEEDBACK datatype. We used
// this view to present a form to users.
$view = pxdb_view::fetch_object_view( DATATYPE_FEEDBACK, 'public' );
// build the rest of the message based on the fields used
$viewfields = $view->arr_typesfields();
while ( list(,$viewfield) = each( $viewfields ) )
{
$msg .= "\n ".$viewfield['displayname'].': '.$record->get_field( $viewfield['identifier'] );
}
// send it off to the intended recipient
mail( FEEDBACK_RECIPIENT, FEEDBACK_SUBJECT, $msg, "auto@".$_SERVER['SERVER_NAME']."\r\n" );
} // end if
Friday, September 3. 2004
Filtering by a parent object, such as a seciton, was previously a needlessly complicated process that involved setting up a parent filter and adding it to your main filter via add_parent, as show below:
$sectionFilter =& pxdb_search::filter(DATATYPE_SECTION);
$sectionFilter->add_value('id', $Request->getVar('in_section'));
$content_filter->add_parent($sectionFilter);
The latest CVS snapshot simplified add_parent by allowing it accept either a pxdb_search filter, a pxdb_record or descendant object, a numeric record id, or a record's idnum value. This makes it easier to filter by parent objects since any of the following are now valid calls. The add_parent() method will handle all the filtering internally.
$content_filter->add_parent( $Section ); // seciton is a pxdb_record descendant
or
$content_filter->add_parent( $Section->get_id() );
or
$content_filter->add_parent( $pxdb_record->get_field( 'idnum' ) );
Tuesday, August 17. 2004
When thinking about the architecture of a Syntax site, remember that just because someone may want a list of documents or events, it doesn't mean that ginning up a module and plunking it on the main navigation is the right answer. It has a lot of drawbacks:
- Your site navigation is not dynamic. This starts to resemble the Bad Old Days of static HTML. Once you pick a term, you're stuck with it. Never underestimate the psychological comfort that is had by having the option to change something, even if it's a bad idea to do it.
- Your page title is similarly static. This further resembles the Bad Old Days. It helps to get a project out the door when you can say "if you don't like it, you can change it." Again, this is true even if you've done killer information architecture and selected culturally appropriate and tested terms.
- You have limited options for dynamic text on the main listing page. You can embed a section call within the template through
F1CMS::module() (more on the power of that later), but that requires modifying not only the list template but also creating a custom template for each hidden section so it doesn't start listing other content items. Plus it turns your Section Navigation admin area into a nest of hidden sections that aren't really sections but content items. You could introduce a datatype that will function in that capacity, but that creates its own complications. How do you decide where each item will be published? Will you build its own module just for display?
Fortunately a much better option exists. You'll still have to create a custom section template, but it will be a logical, functional, and non-hidden section.
Continue reading "Sectional Thinking About Modules"
Monday, August 16. 2004
One of the cool features of Syntax, left over from its F1DB days, is the variable type field for each object.
The upshot is that, by default, when you use the type dbfield in an object, Syntax automagically looks for a picklist with the name of the datatype in it, in this format:
{name of object}types
So if you have a datatype called "article," the corresponding type picklist would be articletypes.
This is really useful, because it allows each datatype to have its own picklist of types--eventtypes, articletypes, puddingtypes--but only use one field in the master records table.
Otherwise, you'd have to make a new dbfield entry for each type you had, and they'd be available to other datatypes--which is silly when your datatype is blancmange and your list is puddingtypes (Blood, Yorkshire, Figgy).
However, with great power comes great responsibility. If you set up a new datatype and you choose to repurpose the type dbfield, you'll be up a creek.
But what if you'd like another such field?
Then you need to investigate the "Variable Table" feature of DBasis when creating that dbfield entry. So far, to my knowledge, it only accepts one variable:
$(objecttype)
The setup for the type dbfield is:
pickid variable table $(objecttype)types
Any text before or after $(objecttype) will be used when constructing the name of the pick table to look for. So my($objecttype)ingredients would result in myarticleingredients, myeventingredients, and of course, myblancmangeingredients.
Generally, of course, you'll find just the one default type dbfield more than sufficient.
Wednesday, August 11. 2004
I've updated the source code documentation to reflect the changes and additions we've made to get it ready for release.
Monday, August 9. 2004
For Sections, breadcrumb trail is automatically set based on the hierachy of sections and the page title is set to the last section in the trail. When you're working with modules, to add elements to the breadcrumb trail and set the page title you only need to do one thing: add a trail point to the Request object. Its probably best to only do this if the request is not an internal module request:
if (!$Request->isIncluded())
{
$Request->addTrailPoint( array( 'url'=>$_SERVER['REQUEST_URI'], 'crumb'=>$Record->get_field( 'name' ) ) );
include_once(SITE_TPL_PATH . '/header.tpl');
}
Wednesday, July 28. 2004
It might be good to use the thumbnail generating class at http://phpthumb.sourceforge.net/ as the thumbnail processor available. It has a number of features that would be nice to enable via parameters or wrapper processors:
- A border (configurable color & width) can be applied.
- Thumbnails can be a fixed dimension regardless of source aspect ratio and background filled with configurable color.
- Border corners can optionally be rounded (independant horizontal & vertical radius)
Tuesday, July 27. 2004
Most of the time when you're building a web site, you are pullng information from a database according to some criteria and then formatting for output, usually HTML but it could be RSS or XML or something else entirely. The way to handle this in Syntax CMS is to create a list capability within a module. You'll probably end up having a module per datatype to handle the various individualities of working with different datatypes. This tutorial shows you a general approach to writing flexible, reusable, and powerful list capabilities that can then be called from section templates or even other modules.
Continue reading "HOWTO: write a powerful list capability"
Thursday, July 22. 2004
Some of the Syntax CMS plugins (web image type validator and image resize processor) check the content-type of uploaded images. However, they check for image/jpeg and not the newer progressive JPEG content-type image/pjpeg. I have fixed these in CVS, but if you have problems uploading JPEGS on older Syntax sites then just update the appropriate plugin file from CVS.
Tuesday, June 15. 2004
We agreed to use the following conventions for numbering versions as we make releases in the future:
- Major revision numbers would indicate radical changes to Syntax or its requirements, such as moving to PHP5 or using XML instead of mysql to persist datatype definitions.
- Middle revision numbers indicate a release that requires changes to the database, either creation of new tables or altering existing table structures.
- Minor revision numbers will indicate improvements and fixes to the Syntax classes.
Friday, June 11. 2004
I updated the pxdb_collection class to no longer need to call pxdb_collection::find() after calling pxdb_collection::set_order(). Now you can either explicitly call pxdb_collection::execute() or simply start iterating through your list with pxdb_collection::fetch_record(), which calls pxdb_collection::execute() automatically if there's no result set.
Friday, June 11. 2004
Problem:
I want to change the order in which my records are returned, in SQL this is 'order by my_field ASC'. I see that the pxdb_collection class has the set_order() method, but when I try this it doesn't seem to work. My code is:
$Records = &new pxdb_collection(DATATYPE_DOCUMENT);
$Records->set_order('sunrise DESC');
echo $Records->get_sql();
Continue reading "Changing the order of results: set_order() & find()"
|
|