cck for code junkies
DESCRIPTION
Slides from the session, "CCK For Code Junkies" that was presented at Drupalcamp ATL '10TRANSCRIPT
![Page 1: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/1.jpg)
CCK For Code CCK For Code JunkiesJunkiesDrupalCamp - DrupalCamp -
ATLATLPresented by: Geoff Maxey (cntlscrut)
1o.2.2o1o
![Page 2: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/2.jpg)
This presentation will be available at:
http://maxeydevbox.org/news/camp/cck-code-junkies-session
Feel free to visit and download the slides.
![Page 3: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/3.jpg)
Overview
To create a CCK field that contains multiple elements, interacts with 3rd party services, and can move/create content on a remote Drupal site.
Understand basic terminology of how CCK breaks down fields and widgets.
To cover the CCK field/widget API and how to implement it. Plus, cover the caveats and other roadblocks that may occur.
![Page 4: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/4.jpg)
Elements
Title Gallery ID Featured Links Search Engine Keywords Selectable Results Embed Code from Remote Site
![Page 5: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/5.jpg)
CCK Terms
CCK breaks things down into two different parts: Fields and Widgets
Fields – The namespace and container for data.
Widgets – The interaction space wherein we collect data from the user.
![Page 6: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/6.jpg)
API Overview
Install: content_notify()
Field: hook_field_info() hook_field_settings() hook_field()
![Page 7: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/7.jpg)
API Overview
Widget: hook_widget_info() hook_widget_settings() hook_widget()
Misc: hook_content_is_empty()
![Page 8: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/8.jpg)
API Overview
AHAH: hook_menu() callback_js() (callback for AHAH actions)
![Page 9: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/9.jpg)
Installation Functions
content_notify() -
Informs CCK of our field and which stage in Drupal's module install/uninstall process we are in.
![Page 10: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/10.jpg)
Field Functions
hook_field_info() -
Provide basic info about our field including the machine name, display name, and description.
![Page 11: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/11.jpg)
Field Functions
hook_field_settings() - Allows us to provide data specific to the set up of our field. We're looking at three different operations:
'form' – create a settings form for the field.
'save' – perform any special actions when saving the settings form.
'database columns' – define the schema structure for how our widget data will be saved in the database.
![Page 12: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/12.jpg)
hook_field_settings – 'form'
![Page 13: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/13.jpg)
hook_field_settings – 'save'
![Page 14: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/14.jpg)
hook_field_settings – 'database columns'
![Page 15: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/15.jpg)
Misc Functions
hook_content_is_empty() -
Perform any action if the field is empty.
Though this is declared an “optional” function, it is actually needed.
![Page 16: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/16.jpg)
Field Functionshook_field($op, &$node, $field, &$items, $teaser, $page)
Defines how the field will actually store and display its contents.
Possible values for $op: 'delete' 'delete revision' 'insert' 'load' 'prepare translation' 'presave' 'sanitize' 'update' 'validate'
![Page 17: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/17.jpg)
hook_field()
![Page 18: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/18.jpg)
Widget Functions
hook_widget_info() -
Define basic info about our widget.
![Page 19: CCK For Code Junkies](https://reader035.vdocuments.site/reader035/viewer/2022081413/54974786ac7959222e8b5309/html5/thumbnails/19.jpg)
hook_widget()
Here we can define our form elements using the FAPI! This is where the action happens.
Put on your 忍び装束 (shinobi shiozoku) it's Drupal Ninja Time!
(code available on site. Too big for slide.)