Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

104 lines (79 sloc) 4.652 kB
drupalcon 2012
alice in wonderland of fields and entities
karen stevenson
will talk abtou lots of modules, not all are safe for production use
best analog to entities is alice in wonderland
in te beginning, the Story module.
needed to write code if you watned to have other fields (recommended path: copy/paste code, rename, etc)
next, flexinode, which took off way beyond expectation
in 4.7, enter CCK with custom content ttypes and fields, all through an nice ui (well, not nice)
when you have a hammer... (becasue everything could be a node and nodes were flexible)
around 5, 6 custom content types went into core.
everything isn't actually a noce, but everything needs fields (users, comments, etc)
in 7, cck is now in core and we only need the entity api (have fields in core, custom contet types, entities)
SKIP, go to views talk
views for developers
bevan rudge
custom code sucks. you have to maintain it, upgrade, it'll be buggy for a while, etc
"before you extend, can you bend?"
the more config you know, the lesscode you need
anayomy ofa view: (note to reader: find diagram if possible)
top level: title, display (display: header area: area plugin) exposed filters, attachments (before)
rows (row: entity OR field, field, ...) OR empty area (empty area: area plugin)
pager, attachments (after) (footer area: area plugin), feed icons
view3 lets you configure the eleemnt that wraps the field (v2 + semantic views)
also does "provide default field wrapper elements" under style options
other feature: field concatenation
"rewrite the output of this field"
feature: render field as link
and/or filters: new in views3, same as views OR but nicer
it's not in the ui, but you can OR together contextual filters
(the filters end up in the WHERE clause)
result summaries/oager summaries
"displaying 1-7 of 7"
area plugin
aggregate/count queries
prepreq is to be able to debug the sql, because it's complicated
also v. powerful
enable "use aggregation" -> "aggregation settings", "COUNT(...)"
alternate pagers: date, alphabetical, glossary
page: pager option does this
ussually use a contextual filter
views link area (views_linkarea contrib module)
exposes area plugin to add a link
review: look for simple solutions, don't write custom code
anayomy of a view, custom markup for fields, field concat, fields as custom links, no results behavior for fields and summary views.
and/or config for filters, contextual filters, results ummaries, agg/count queries, date/etc-based pagers, link are module
part 2: add new and custom feature
writing nasty custom code that'll cost us so much time and money
docs: api.d.o/api/views/groups (topical and api)
doxygen: drupal.geek.nz/views (updated for views 3)
ususally you'll need to create something that inherits from something, so doxygen helps you there
building a views module:
step 1: hook_views_api - where are your fiels, what version of the views api are you working against
step 2: create a subclass of the appropriate class (for linkarea, subclass views_handler_area)
look for an exisnting module or class that does something like what you need
step 3: expose the class/include file to the .info file (for d7)
step 4: expose class via hook_views_data - how the class integrates with the data schema (might need a pseudo-column)
how classes relate to features in the ui
views_handler_field - subclasses expose fields
viewsw_handler_arg - for contextual filters
views_handler_relationshiup - parent to clases that add relationship
views_handler_area - stuff that goes in the header, footer and no results
views_plugin_display - different Views displays (attachment, block, default, page, feed, etc)
views_plugin_style - formatter otpions (html list, for, rss, ...)
views_plugin_row - how a row gets formamter
v_p_pager - paging
v_p_access - usually unneeded, nice for subclassing if needed
vies_plugin_argument_default - when contextual filter looks somewhere other than the url for an arg
views_plugin_arg_validate - what should the arg look like
review: docs, oo hierarchy, example of views_linkarea, what classes are analogous to whcih config options
q1: how to use remote data
extend views_plugin_query, likely someone's already done it
entity-layer would mean duplicating data
q2: what happens when hook_views_api specifies 3.0-alpha1 and you're on 3.0
a: idk. check the docs. probably something sane
q3: view can have multiple handlers, but must have exactly one plugin
handler for dispalying data, plugin for gettting it
q4: how to migrate from 6 to 7
d7 only has views3, need to upgrade in d6, probably need to manually rebuild
Jump to Line
Something went wrong with that request. Please try again.