Interface Module Part Two

Apr
04

Editor's note: This is a long post. If you just want to see the screencast, click here, and there are notes about it below. If you want some sample code to help you understand, click here. If you want to read how Mike explains the whys and wherefores, get comfortable, ease the seat back, and read on.

If you build Drupal sites for a living, you already know that the administrative interface is one of the areas of a site that gets the least attention from developers. There are a lot of reasons for this, ranging from the fact that it works (therefore, it does not need to be pretty), to the fact that modifying the admin interface is labor-intensive (there are some sections you almost need to hack core to modify), to the fact that budgets don't always cover the costs of making the backend look nicer (and we all know about the bottom line).

This year, Trellon set out to address some common usability concerns in Drupal based on feedback received from clients. Something we often hear is that Drupal is very attractive from a functional standpoint, but Joomla is more user-friendly and has a nicer interface. This misperception about the underlying power of Drupal's theming layer is chiefly an aesthetic concern, it is something that can be resolved, and an ideal solution is one that reduces the overall time and complexity involved in deploying sites featuring more usable interfaces. As a nice to have, whatever usability solution is designed can be extended beyond the web browser into other mediums such as widgets and mobile phone applications.

Given that there are only 24 hours in the day and there is so much to the administrative backend, we needed to pick our battles. The administrative component that gets the most use is the content entry interface. This presents a big target for improvement, as users are most likely to benefit from usability enhancements simply because this is the place they visit the most frequently. Another reason we wanted to work on the node entry interface is that we figured that it is the area where we can do the most cool AJAX-y stuff and have a good time doing it. The work we are doing with the content entry interface could potentially be expanded to cover other parts of the system as well, so this looks like a good place to start.

We have been focusing our efforts in this area with the development of a new module, the Interface module. In our first post about Interface, we took a look at how this module can be used to manage the layout of node forms in a Drupal site. In this screencast, we are demonstrating the way the module works, and including live demos of content being entered into the system. You can start the screencast by clicking on the image below.

What You are Looking At

Out of the box, a Drupal node form is like a perfect game of Tetris, with every box stacked neatly on top of others in a big silo. You can theme content entry forms to look different ("less Tetris, more Q-Bert" is what we say) the same way you can theme pages and views, but this task can become labor intensive with a large number of content types and require maintainence over time as form defintions can change.

What Interface does, in essence, is allow you to put form elements into regions using a drag and drop interface. Regions are defined in a template file, and you can have different regions in your interface depending on the template you choose to use. Templates can be simple, and just define a set of regions, or they can be complex, and modify the way Drupal displays pages. Interface just makes it a lot easier to modify the way forms look and work, without really needing to do any programming. You will see how this plays out in two different ways.

In the first part of the screencast, we create a new interface for the page content type then navigate to the content entry form to see it in action. You will notice the administrative panel appearing at the bottom of the page. The administrative panel is used for a lot of things. When you click on a form element, it displays some information about selected attributes. It also lets you assign actions to form elements. While this is not demonstrated here, actions are a method of modifying the way a form element is presented to users. For instance, if you wanted to put a couple of form elements in a dynamic tab set, you would select an action from a drop down menu that would tell the form element to now be a tab.

In the second part of the screencast, we start modifying the interface for the story content type. You will notice we are using a template called Joomla, and that is exactly what it is, an interface that duplicates the layout and design of the content entry forms for the 1.0 version of the Joomla platform. Right now, this is not complete, the fieldsets off to the right are not displaying in tabs. But we are making progress, and people will be able to dump form fields into tab sets when the actions API is complete.

We built the Joomla template in as a way of showing how templates can be used to modify a lot more than the placement of form elements, you can build a template that completely changes the look and feel for that part of the site. Thinking about it from a themer's point of view, you would need to write a preprocessor to change the template file, a template for the form, spend time thinking about variables, etc. Maybe you can get this done quickly, maybe it will take a lot of tinkering to get it right. Interface seeks to make this a lot simpler through the use of uniform layouts and presentation elements that can be deployed over multiple content types. While a themer may have to write an original template to get things to look the way they want, it could be reused for every content type in a Drupal web site.

How It All Works

The Interface module is in a pretty advanced stage at this point and almost ready for release. As you might expect, working with the Forms API at a low level and designing an AJAX drag and drop interface to interact with it is pretty complicated. We planned on showing off and releasing an early version of the module at Drupalcon, but decided there were enough nuanced details that still needed to be worked out before putting it out there.

The patience has paid off. Interface has been designed with end users, themers and developers in mind. While a new user can get started right away with one of many prepackaged templates, we have focused on making the module powerful enough to extend the default functionality to handle new use cases without the need to fundamentally alter the underlying module code. The structure of the module, and the way it has been put together, should be interesting to anyone who plans working with it.

Here is some sample code to help you understand the rest of the discussion. This file includes a sample template file, info file and behavior file.

First off, Interface was designed to present themers with a familiar structure for creating new layouts and simplifying the way theming occurs. Every template comes with a template.tpl.php file used for telling Drupal where the droppable regions are. While you can include as much PHP in the template files as you want, all you really need is some basic HTML and CSS to put together a set of regions for displaying form elements.

Every template also uses a .info file to tell Drupal some information about the template itself. This includes the name of the template, the tpl.php files being used, any css files associated with the template, information about the regions, and installed behaviors associated with use of the template. Most of these settings are optional, and the ones that aren't are pretty straightforward.

Secondly, for developers, Interface was designed to be extensible, and creates new methods for interacting with and displaying dynamic form elements. Interface expands the options developers have for modifying form elements through the use of behaviors and actions. Think of a behavior as a way of telling Interface how to react to various situations people will encounter while editing an Interface. There could be a new CCK field Interface does not recognize, and a behavior would be used to tell the system how to handle it. Maybe you need to tell Interface to ignore certain form elements altogether, and only allow people to alter the placement of the wrapper around them. Behaviors have hooks for exactly that.

Behaviors also define actions, which are operations that can be carried out on form elements. For instance, if you wanted to change a submit button into an image, a behavior could associate an action with all submit buttons that, when activated, allows users to upload an image to the site and replace the button with an image when the form is generated. Actions are designed to be context specific, and behaviors use dynamic CSS selectors to determine what actions can be associated with what elements. A more complex example (and one that is keeping me up nights) is tabs. When you wrap a form element within a tab set, you need to be able to carry out various tasks within the tab set, that include dropping new form elements in, selecting the content of individual tabs, and more. Behaviors allow you to organize the way the system responds to events and associate the right actions with the right elements.

Developers, We Have an API Here

As described above, Interface comes with an API for extending it. To keep it simple, we designed the behaviors system to operate using a set of hooks similar to those found within Drupal.

Every behavior is a behavior, each one uses Drupal.behaviors to register the component and intialize itself when authoring an interface or entering content. A lot of information is dumped in Drupal.settings to tell Interface what is going on, and we plan on releasing a full API guide with the module that explains how all this works. In a real basic sense, you have to tell Interface what can be positioned, what can't be positioned, and where you can put stuff.

Within the behavior code, there are a number of hooks designed to allow Interface to detect and do various important things. Interface behaviors are pure AJAX components that are triggered by Interface at certain times.

Hook_register_grouper is one of them. In a standard Drupal form layout, every form element is enclosed in something, except for submit buttons. There are times when it becomes important for Interface to understand what is wrapped around the form element, so that it can tell Drupal where to put the form element when the form is rendered. Hook_register_grouper creates a category of markup, called a 'grouper', that is used whenever a form element is located within an element that exist as it's own entity in the form array used to construct the form. Here is an example from the common_groupers behavior:

<script>
/**
* Registers a grouper. hook_register_grouper tells interface that a form element appears within a grouper
* (or is a grouper itself) and that form elements placed within it are visible. It should return some
* text for display within the status bar on the panel of the authoring interface.
*/
Drupal.common_groupers_register_grouper = function(markup){
  if(markup.tagName == 'FIELDSET'){
    element = $(markup);
    return 'FIELDSET.' + element.attr('id');
  }
  return false;
}
</script>

This hook receives a single parameter, markup, and checks it to see if we are looking at a FIELDSET. If so, it reports back to the calling function what it has found to display in the status bar of the administrative panel. This hook does not need to be in every behavior, just the ones where the position of a form element relative to a grouper is important (there are some where it is not, like with form image buttons).

Hook_register_global_selector is another important one. When you look closely at the CSS and think about how it relates to form arrays, there are a lot of permutations of form elements that can come out of Drupal. By default, Interface knows to look for regions and form elements wrapped in a DIV.form-item tag and let people drag and drop them. For everything else, we let behaviors tell Interface what to associate with the drag and drop activity. Hook_register_global_selector provides a means to do that. The sample you see below is fairly simple, some behaviors will pass back complex selectors to handle

<script>
/**
* Registers a selector for use in the authoring interface. This hook provides a common
* method for adding new selectors to the drag and drop interface.
*
* returns an array, containing the CSS selector for each item to be added to the drag and drop.
*/
Drupal.common_groupers_register_global_selector = function(){
  // create an array of selector values
  var selectors = ["FIELDSET"];
  // return these items
  return ( selectors );
}
</script>

Not too scary.

There are other hooks, this is really just a preview of what is to come. Again, we plan on releasing full documentation for the API along with the Interface module to get people started. Something I really hope to see is people using and contributing to the module over time, and this includes the design and construction of the API. Behaviors are the only thing in Interface that is 'new' for someone who has been been building custom themes and modules in Drupal, and we have gone to pains to see to it that the underlying framework is similar to the way other parts of the Drupal platform are constructed.

One of the nice to haves are are hoping to achieve with this module is the ability to deploy content entry interfaces into things besides web browsers, such as widgets and mobile phone applications. We have given a lot of thought to how Interface can be extended to create interfaces for alternative platforms. While you can do this already, Phase II of the Interface module will be to make it simple to create content entry forms for multiple devices. We have created some internal Drupal API stuff as well for this purpose, which I will go into in the next screencast.

Until next time.

20 Comments

Hey wait! That's Joomla I see

Hey wait! That's Joomla I see in that video!

I can't wait for this module to come out.

Yes, there is a Joomla

Yes, there is a Joomla template we plan on shipping with Interface.

We will regard Interface as being in beta until someone can clone the Joomla interface in Drupal in under 5 minutes for any content type. Consider it a proof of concept.

Long term, Interface is going to be extended to do a lot more than just node forms. We plan on putting a dashboard system in place for various features that would let you let you clone most of the administration there as well.

M

Very cool. I think Vertical

Very cool. I think Vertical Tabs (http://drupal.org/node/323112) are easier to use still, but I really like the flexibility demonstrated in this video. How does it affect Vertical Tabs, and can we somehow get the best of both worlds? I'd appreciate your feedback/participation in the Vertical Tabs issue: http://drupal.org/node/323112. Thanks!

It's less about how Interface

It's less about how Interface affects vertical tabs and more about how vertical tabs affects Interface.

Our team regards things like vertical tabs as a behavior, a method of displaying form elements that can be associated with some actions in Drupal. It's not that far off from fieldsets in that way. Both interface and vertical tabs can exist side by side, or we could incorporate vertical tabs into Interface in some way. From the perspective of the people building this module, it's really just a matter of understanding what things are commonly used in Drupal and ensuring there is a way to work with them without breaking anything.

I have already built a behavor that does just about everything you can do with vertical tabs inside Interface in a behavior called tabbable. Imagine if you could build the vertical tabs without any code, and group together form fields into tabs in whatever way you want through a drag and drop interface. That's the idea, at least, with tabbable. I plan on showing it in the next screencast, which should be right before we release the module.

We have looked closely at vertical tabs as well as Nate Haug's form builder when working on Interface. It is kind of funny, every time I talk about Interface someone tells me it sounds just like one of those two other modules. I have come to using architecutural metaphors for explaining things - that other module is the plans for the house, Interface is the house built from the plans.

M

This is pretty awesome, are

This is pretty awesome, are you trying to cut the themers out of the webdevelopment process already? ;)

The developers of this module

The developers of this module have looked at the issue closely, and themers are just one of the imperfections to working with Drupal we have come to regard as necessary. Someday we hope to just be able to clone the awesome themers here at Trellon and share them with the world.

M

Cool. I'm seeing the module

Cool.
I'm seeing the module helps themer more than cutting them off.
Themer will have more flexibility in design with less/without coding.

Sounds neat, although I

Sounds neat, although I wasn't able to watch the video (need to install Quicktime...).

Anyway, how does this compare to Panels 3?

Yeah, good to have quicktime

Yeah, good to have quicktime installed if you want to watch screencasts.

Interface and Panels 3 is apples and oranges. Different tools for different purposes.

M

Fantastic! Your point as to

Fantastic! Your point as to theming the admin while meeting the bottom line is ringing in my ears, a final step often not included in budgets.

Have you been in touch with the people working on D7 UX? Seems like something they would be interested in.

Looking forward to trying it out.

I am still a bit puzzled on

I am still a bit puzzled on what this is trying to solve or enhance, a form element on the right makes it more usable (it visually probably does)? Or is it just that node/add is still horrible?

It sounds like a very abstract way, to get forms elements on the right.

The way you frame the

The way you frame the question says a little bit about how you see the module. I will try to answer.

First off, there is nothing horrible about node/add. It would be horrible if content entry forms did not work. There is a certain appeal to the uniformity in the way they look that I actually like. It is a lot easier to teach people to use a web site when all the forms look the same.

Secondly, Interface was designed to accomplish several things.

1) Improve the efficiency of theming forms.

Designers are designers, programmers are programmers, and it would be nice if a user could just make things look better without needing to be either.

2) Provide a method for authoring AJAX-y form widgets that makes them easy to deploy throughout a site.

What you don't see in the screencast is behaviors, which let users add tabs and other interactive elements to their forms through the same drag and drop interface. You will have to wait for that, but it is a major part of Interface.

3) Eliminate the need for static interfaces in Drupal altogether.

This is the big conceit of designers. Usability is not universal, especially with a platform that can be used in so many ways. The usability enhancements going into D7 will present problems for some people no matter how much work goes into planning them (maybe it will just be fewer people).

It would be nice to have a system without any predefined or static interfaces and provide users with complete control over how they work with the system. Imagine being able to rapidly prototype different interface ideas without needing a programmer for the task - and have them look like they are supposed to.

With templates, 'right' and 'left' don't necessarily apply in the design of form templates. It's the regions you define that matter, and they can be organized in a lot of ways that break from traditional columnar layouts (without a lot of coding). For instance...

One of the things I have been working on is a faceted region interface like the one used on the XBox. I have also been working on accordion style interfaces, like you might see on a hotel registration web site. These things are very common in rich internet applications (if they still call them that). Interface will take it to the point where these can be deployed without needing to write any code, and give a good structure for authoring interactive components.

4) Serve as a way of designing interfaces throughout Drupal, not just forms.

The initial release of Interface is centered around node forms. Building it gave our team a lot of insight into ways of organizing and presenting other stuff in Drupal, especially in the administration section.

In some ways, Interface is just a long, roundabout way of building out the tools I need for a widget module I have been working on for a while now. The first release will probably be centered around other forms in the system, then the administrative interface, then widgets. No promises, but building this has set off a lot of lightbulbs.

5) Be straightforward, easy to use, extensible, and fun to work with.

Building interface has been fun. We're hoping people see the usefulness of it in their sites.

Does this answer your question?

M

Thanks to Arob for presenting

Thanks to Arob for presenting at NYC Group on wednesday. projector malfunctioned, but he was still able to present while we watched it huddled around our netbooks ;)

What is your best guess for an initial release? 7 , 14 , 30, 45, or 60 days? We're just about to theme , and we're trying to make decisions on routes to go. Thanks! Looks great.

this can only b don on

this can only b don on drupal?

It sounds like a very

It sounds like a very abstract way, to get forms elements on the right.

this can only b don on

this can only b don on drupal?

Will this method work on

Will this method work on windows based hosting?

Thanks to Arob for presenting

Thanks to Arob for presenting at NYC Group on wednesday. projector malfunctioned, but he was still able to present while we watched it huddled around our netbooks

erotik shop
seks shop
sex shop

Find Online fashionable prom

Find Online fashionable prom dresses,homecoming dresses from top USA prom gowns designers,

ITS VERY INFORMATIVE

ITS VERY INFORMATIVE BLOG...USEFULL ONE... LEARNED LOT FROM THIS BLOG...Boots for men
Mens White Dress shoes

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options