The Artima Developer Community
Sponsored Link

PHP Buzz Forum
Painless Listwidgets from Picktables

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Forum One

Posts: 118
Nickname: forumone
Registered: Sep, 2004

Forum One is consulting firm specializing in helping non-profits improve their online presence.
Painless Listwidgets from Picktables Posted: Sep 16, 2004 2:28 PM
Reply to this message Reply

This post originated from an RSS feed registered with PHP Buzz by Forum One.
Original Post: Painless Listwidgets from Picktables
Feed Title: Syntax Framework
Feed URL: http://blog.syntaxcms.org/rss.php?version=0.91
Feed Description: Finally, a place to answer Syntax questions
Latest PHP Buzz Posts
Latest PHP Buzz Posts by Forum One
Latest Posts From Syntax Framework

Advertisement

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' ) ); 

Read: Painless Listwidgets from Picktables

Topic: 3b Seperating Display and Data - Javascript table highlighting 13 Previous Topic   Next Topic Topic: Notes/Slides from OSCon 2004 Session?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use