Drupal Search: Core API; CCK & Views (second half)
The notes from my presentation are organized into book pages here. There is a short 2 minute video embedded on page 3. You can also watch a 15 minute demonstration of the site that I put together for the client here.
See also: OSCMS description here
This presentation supported by CivicActions
Slide 1 - Contrib Modules
- views – merlinofchaos – great module!
- views_fastsearch
- views_filterblock
- daterange
- everything is available in D4.7 & D5
This presentation supported by CivicActions
Slide 2 - General Overview
- Create View
- Provide Page View
- Add Filters
- Search: Fast Index
- Node: Created Time Between (or other daterange)
- Any other existing filter, such as taxonomy or node type
- Create a custom filter
- Add Block Views Filterblock.0
- Configure Block to use view
- Place block anywhere, on (or not on) any page
This presentation supported by CivicActions
Slide 3 - Live Client Demo
Flash video - watch it here (Drupal.org doesn't allow embedded objects)
This presentation supported by CivicActions
Slide 4 - Creating a Search
- Download, Install & Enable Modules
- Enable search module
- Create View (admin/build/views)
- Add & Expose Filters
- Place views_filterblock in left sidebar
- Configure views_filterblock (admin/build/blocks/configure/views_filterblock/0)
- cron needed to create search indexes
This presentation supported by CivicActions
Slide 5 - Standard Filters
- Node: Author Name, Author is Anonymous, Author is Current User, Created Time, Current User Authored or Commented, Has New Content, Title, Type, Updated Time Between
- Comment: Count, Last Changed Time, Last Comment Time, Pending approval
- Role: Author Role
- Search: Index
- Taxonomy: Term, Term for Something, Vocbulary Name
This presentation supported by CivicActions
Slide 6 - Views Filter
- Additional Filters
- Node: Created Date Between, Modified Date Between (daterange)
- Search: Fast Index (views_fastsearch)
- Any module can create a new filter
- usernode module to search by user
This presentation supported by CivicActions
Slide 7 - Creating an Exposed Filter
function searchdemo_views_tables() {
$tables['searchdemo_users'] = array(
'name' => 'users',
'join' => array(
'left' => array('table' => 'node', 'field' => 'uid'),
'right' => array('field' => 'uid'),
),
'filters' => array(
'name' => array(
'name' => t('Node: Author Name contains'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
'help' => t('filter by a particular user.'),
),
)
);
return $tables;
}
This presentation supported by CivicActions
Slide 8 - Creating a (more compliced) Exposed Filter
Change from previous slide:
'handler' => 'views_handler_filter_picture',
Then add:
function views_handler_filter_picture($op, $filter, &$filterinfo, &$query) {
$query->add_table('users', false, 1, array(
'left' => array('table' => 'node', 'field' => 'uid'),
'right' => array('field' => 'uid'),
));
$sqlops = array(0 => '=', 1 => '<>');
$query->add_where('users.picture'. $sqlops[$filter['value']] ."''");
}
This presentation supported by CivicActions
Slide 9 - Gotchas!
- Views displays nodes
- not everything is a node, but many things can be nodified (i.e., usernode module)
- Taxonomy exposed filters are select lists, not checkboxes
- Form_alter
- extend views_filterblock to handle this as an option
- Node: Author filter is a select list, not a textfield
- create your own exposed filter
- Searching relies on cron
- node_cron_last, node_cron_last_nid can get out out-of-sync
This presentation supported by CivicActions
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion