Archive for November, 2008

24
Nov

PHP CRUD template for jqGrid

   Posted by: admin    in MySQL, PHP, Software Development

I have been using the JQuery for quite a while. JQuery does not have an official plugin for grids, there are several of them out there. I tried out a few and settled on jqGrid   I am very pleased with it in every way. I’ve used it in several projects and it’s always been very flexible and extendable for my needs. I’ve been able to easily add after effects like color sorting, drag and drop reorder etc. with ease. Writing the PHP for the typical CRUD (Create Read Update Delete) functions is very easy but is so boring that I had to do SOMETHING that would both give me a bit of fun and give me smoething to make this part of the process faster for me in the future. So I have a .php template here with it, I can change a few variables around and apply it to any MySQL operation that interacts with jqGrid.

define

$crudColumns =  array(
    ‘id’=>‘id’
    ,‘title’=>‘title’
    ,‘icon’=>‘icon’
    ,‘description’=>‘description’
    ,‘parent’=>‘parent_list_id’
);
$crudTableName = ‘list’;
$postConfig[‘id’] = ‘id’;

and it’ll create the select, search, paging, insert, update, delete interactions for jqGrid for you.
it also has some convenient spots to edit the sql for additional column / query manipulation. At a minimum it should serve as a good starting point for working with jqGrid beyond the examples they provide (Which are very good and helpful already). If you have any updates or suggestions for this please let me know.
-enjoy

12
Nov

SimplePie RSS Feed library

   Posted by: admin    in PHP, Software Development

SimplePie is a PHP development library for reading RSS. It’s amazingly simple, well documented and full featured. I have written 4 RSS readers for portals and virtual desktops using it, and it’s alsways been a pleasure to work with. Here is the link:

http://simplepie.org/

When would you use this? Anytime you want to pull an RSS feed into a page for a decision or display. Almost everything has an RSS feed. You can pull in multiple feeds, have them automatically cached and aggregated, and choose a sort method. It will also automatically find RSS feed URLs if you give it a URL to any site. Combine this with something like Dapper: http://www.dapper.net/ and there’s no limit to what you can integrate into your project!

Here’s some sample code to show how easy SimplePie is:

<?php
require_once(‘SimplePie/simplepie.inc’);

$feed = new SimplePie(array(‘http://suddendevelopment.com/?feed=rss2′,‘http://LegalizeThought.com/?feed=rss2′));
$feed->handle_content_type();

$htmlOut = ;
//====|| Get RSS items for feed||====\\
foreach ($feed->get_items() as $item){
$htmlOut .= ‘<div class="rssItem">’;
$htmlOut .=    ‘<div class="rssTitle"><a href="’.$item->get_permalink().‘">’.$item->get_title().‘</a></div>’;
$htmlOut .=    ‘<span class="rssDescription">’.$item->get_description().‘<br></span>’;
$htmlOut .=    ‘<span class="rssDate">’.$item->get_date(‘j F Y | g:i a’).‘</span>’;
$htmlOut .= ‘</div>’;
}
print $htmlOut;

?>