Beta

Slashdot: News for Nerds

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Drupal 6 Attachment Views

samzenpus posted more than 4 years ago | from the read-all-about-it dept.

Books 35

Trevor James writes "Green's book is without a doubt the definitive practical guide to using the Views 2.x module in Drupal 6, and to creating complex and dynamic page, block, and attachment-based views for your Drupal site. One big plus to this book's structure is that Green uses a real "live" production website project as a guide (he states early on that he was working on the site build for the client while writing the book and that the client approved of using the site build as the book's main example) — all of the chapters and subsequent tutorials are focused on building a site for a company that specializes in hiring out contractors and subcontractors. It's nice to see real-world examples being used in a computer tutorial book, especially one focused on Drupal and Drupal Views. The data Green is accessing is real data and this helps to engage the reader and show the multitude of real situations that a developer will get involved with when developing Drupal Views." Read on for the rest of Trevor's review.Green introduces us to Drupal 6.x Views in Chapter 1 by creating a page View. Green points out how a Views panel relates directly to the SQL statements being run on the backend by Drupal, something I have not seen done in any online tutorial or book — he maps out the panel View and shows, for example, that the Sort Criteria in your Views interface matches your SQL "ORDER BY" statements. A nice touch.

Green also shows us how to Analyze the views we create to test their configuration before previewing the View. This is another trick I was not aware of (and I use Views heavily in the work I do) so I'll emphasize here that the book covers the Views interface exhaustively. Every detail of the interface and building page and attachment Views is covered. Green tackles building Views using Arguments in both Chapters 1-2 and does it in a method that demystifies Arguments and makes them much easier to understand.

The book shows methods of leveraging the Views interface to preview your View data and content without having to leave the Views screen — in chapter 2 Green shows us how to test our attachment View by previewing the Arguments we've added directly in the Views live preview area.

Another nice surprise in this title is that the author covers many other Drupal components besides Views. In chapter 2 Green dives right into Drupal theming showing us how to create template files for our Views and add PHP and CSS to tweak and manipulate our Views display output. So right here you're not just getting a book on using Views but also some basic instruction on how to build theme template files and add code to the tpl files.

In Chapter 3 Green moves into a detailed tutorial on creating a module. First he shows us the core Drupal Contact form (Contact module) and we build a simple contact form. Next he explains that we can extend this simple contact form by building a custom module to add custom fields to our form — for example adding fields to collect address information and also tweaking the labels for the core Contact form. Green explains in detail how to build a module and how to use Drupal's form_alter hook to "alter" our Contact form. It's the best description and explanation of the form_alter hook I've read. Again Green gives us much more here than simple Views building — he shows us how to build a module in Drupal. Finally bringing Views back into the discussion we learn how to glue all of the parts we have — the contact form, custom contact fields from our module, a CAPTCHA field, and an embedded Gmap using the embed_gmap module — into a View and then display this view on our site to show multiple Drupal components on one page. We end up building a dynamic Contact Us Web page that contains a map, contact information and a Contact form. Amazing stuff.

For the first 3 chapters alone I recommend this book to anyone just starting to use the Drupal Views module, any Drupal developer who is interested in theming Views, and any Drupal user who is just starting to build their own custom modules. The book covers so much terrain in the first 3 chapters it's a definite must have on anyone's Drupal bookshelf.

Chapters 4-8 of Green's Drupal 6 Attachment Views contains the brunt of discussion and tutorials on building Views to support various content output. These chapters will give developers a good amount of practice building Views since Green emphasized rebuilding a View for the practice vs. simply exporting and importing your View code. I agree with this method. It might be easier to export and import your code but you'll start to understand the inner workings of View arguments and relationships if you build them from scratch each time you need to configure one.

In chapter 4 Green shows us how to override View settings so your attachment View does not conflict with your page or block View. Green also points out here that we can configure Views for multiple audiences and target the View to specific roles such as anonymous users or logged in site admins. In this chapter we create a management role-based View for our admin users to access.

In chapter 5 Green shows us how to create complex Views using attachments to display Bio content of our company's employees. He returns to a discussion of theming showing us how to theme the output of our View, this time focusing on theming content to surround and display next to an image. View relationships are introduced in this chapter so that we can filter specific jobs to specific project managers who are in charge of the job — this is based on using a node reference field in our content type. Again a nice description and tutorial on how to use CCK fields in our View output.

I'll stress here that the entire book (but mostly in these Views intensive chapters) contains a nice balance of screenshots and descriptive text. The screens are important as it's always nice to have the visual aid to accompany the tutorial bullet points and instructional material. In chapter 6 we create another complex 3-view composite display similar to the one built in chapter 5. Again Green stresses practice makes perfect when it comes to using and building Views in Drupal.

Chapter 7 contains a interesting take on how to enhance and theme a simple "About Us" Web page. I liked the use of Views in this chapter to make a basic Drupal page more dynamic and interactive. Green's expertise is apparent in this chapter as he takes something so basic and static and turns it on its head (and takes it completely out of the box) to show you how you can engage static content better by building it using the Views module. This chapter is a gem in the book and one that clients should read — it will give clients ideas about how to take static content and make it vital content on their site. About Us pages do not need to be boring.

Chapter 8 focuses on building simple administrative control panel using Views. Again Green challenges us as Drupal developers to step out of the box and build useful and custom management tools for our clients.

Chapter 9 shows us how to build role specific menus outside of Views using the Drupal menu and block system. Green diversifies here and begins the excellent discussion in these last two chapters of Drupal's administrative functionality outside of the Views module which has up to this point been the focus of the book. Green gives a tutorial on how to create a "peek-a-boo" login block. What's that you ask? Read this chapter to get the full rundown — it's functionality that will impress your client — using Javascript and an API. Good stuff here. Finally a discussion of adding a new theme region to your Drupal theme (always good to know how to do) and a final look at the Views module, creating a current Jobs/News block.

Chapter 10 wraps this excellent title up by showing us some of Drupal's core functionality that always ends up on the "punch list" in our projects — stuff like:

* Setting the admin theme
* Enabling clean URLs
* Error reporting
* File system
* Input formats
* Logging
* Performance
* ... and more

Read Chapter 10 for sure and then show it to your lead admin/project manager on the client side since it's a great cheat sheet for administering Drupal.

Green had published an opus here on Drupal Views and Drupal 6.x in general. I'll enjoy working through this book in more detail and practicing his Views attachment problems in my own work.

You can purchase Drupal 6 Attachment Views from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

cancel ×

35 comments

more books (3, Informative)

mr.dreadful (758768) | more than 4 years ago | (#32323632)

"Green's book is without a doubt the definitive practical guide..." The Views module author has a book coming about views: http://www.amazon.com/Drupals-Building-Blocks-Quickly-Websites/dp/0321591313 [amazon.com]

Re:more books (2, Funny)

abigsmurf (919188) | more than 4 years ago | (#32324032)

In your view, which views book offers the best views on views?

Re:more books (0)

Anonymous Coward | more than 4 years ago | (#32324442)

I'm somewhat against people writing open source software and then charging for the documentation.

Re:more books (3, Insightful)

gorzek (647352) | more than 4 years ago | (#32324602)

It's unfair to call it "charging for documentation." Views is quite well-documented. I figured out how to use it with no documentation whatsoever--it's pretty intuitive all on its own.

I see nothing wrong with writing a popular open source program, then trying to make a little money writing books on how to use it effectively. There's nothing stopping others from writing up tutorials and giving those away for free. And, since the code is available, the author can't possibly keep any secret tricks to himself, to exploit only in the pages of a for-profit book.

This might be a fair criticism for proprietary software, but it doesn't hold much water when it comes to open source, and especially not Drupal modules, which tend to be intuitive if not always well-documented.

Re:more books (1)

meustrus (1588597) | more than 4 years ago | (#32331636)

Drupal? Intuitive? What universe are you living in?

Re:more books (0)

Anonymous Coward | more than 4 years ago | (#32332260)

It is well known that PHP attracts the best programmers. As a result, Drupal has uniformly excellent code quality, especially in contributed modules. It follows that the documentation would also be among the best in the open source world.

Re:more books (1)

drinkypoo (153816) | more than 4 years ago | (#32332544)

It is well known that PHP attracts the best programmers. As a result, Drupal has uniformly excellent code quality, especially in contributed modules. It follows that the documentation would also be among the best in the open source world.

It isn't. Many modules are undocumented to the point of being uncommented. And I'm talking about important modules like Voting API. Some of the documentation is great. Some of the documentation is complete shit, and some of it is missing entirely. Some modules seem to be documented only as video tutorials. There's a lot of great things about Drupal, but completeness of documentation isn't one of them.

Re:more books (1)

Rhaban (987410) | more than 4 years ago | (#32340020)

There's a lot of great things about Drupal, but completeness of documentation isn't one of them.

It's still the most documented open source cms with this level of functionnality. Anyone who ever read the documentation for ezpublish would agree.

Re:more books (1)

gorzek (647352) | more than 4 years ago | (#32334182)

Your mileage may vary, but I've used a lot of CMS software, and I've Drupal to be the best balance of power and ease-of-use. It's ridiculous how extensible it is, yet I don't find maintaining it daunting or confusing. It all makes a reasonable amount of sense.

Re:more books (2, Insightful)

Sleepy (4551) | more than 4 years ago | (#32329102)

>I'm somewhat against people writing open source software and then charging for the documentation.

I could agree with your statement IF the following condition were TRUE: ... that third parties were prohibited from creating or sharing documentation.

This isn't true, so I strongly feel your point of view is misplaced and not correct.

It IS fair to say that Views is difficult for users who are not well familiar with databases. Views is a simple concept - get access to the raw data fields that make up content types - but in doing so you completely bypass all Drupal features put into place for usability reasons. For example, you can use Views to directly access User fields and Taxonomy, and build a list of all users and the Taxonomy tags they applied to content, and maybe which articles were the most frequently tagged. That's powerful. You could build a custom module to do this for you and you could make it with tons of user friendly and error checking features... but your application would be locked to "rails" or a fixed path.

Views is a possibility engine.

If I were you, I might moderate my opinion a little. If you are having trouble with Views, you CAN learn from Drupal camps or IRC or the Views forums. In doing so, try to be more PRECISE about your complaint -- remember, this is mostly a community of dedicated volunteers. When you praise something, you encourage more development. If you criticize something (AND you can't be bothered to get the complaint correct) then you will offend people and you will be ignored.

It is very true that all the "smart people" working on Views are all done with Views 2, and hard at work on Views 3. A good number of them are working on Panels and Chaos Tools. Much of the Drupal Community is hard at work on Drupal 7. SO you have this situation here where there is plenty of accurate reference documentation by the projects - but not a lot in the way of deep tutorials. It's true that there isn't a lot of that kind of documentation, and if you are spoiled by Google (as I am) you can get frustrated that you can not simply Google for answers on some advanced topics.

Put yourself in the place of the people you just criticized:
  What if you spent months volunteering for Habitat For Humanity or some other home-building group, and the first thing you hear from the beneficiary is them complaining: "I'm somewhat against people building housing for the poor, and then not providing handyman maintenance for free.". That person wouldn't DESERVE the house, and if this is how you would react then you deserve to stick with proprietary CMSs.

(Never mind the much shorter counterpoint: Have you ever READ documentation for a proprietary CMS lately?It has been a long long time since documentation was bound and printed. It's all in a Help file now, which some users proudly state they will not read).

What's the URL of the example site for the book? (1)

sprior (249994) | more than 4 years ago | (#32323866)

There is mention above of a client site being used as the example for the book, but no mention of what site it is. I'd like to see that site to help me decide whether I'm interested in the book or not - anyone know what it is?

Re:What's the URL of the example site for the book (2, Funny)

rcuhljr (1132713) | more than 4 years ago | (#32323952)

www.dontslashdotmydrupalsite.com?

Re:What's the URL of the example site for the book (-1, Troll)

Anonymous Coward | more than 4 years ago | (#32324168)

There is mention above of a client site being used as the example for the book, but no mention of what site it is

The name of the site is in the title itself [rupaul.com]

Re:What's the URL of the example site for the book (2, Interesting)

AlistairGroves (546420) | more than 4 years ago | (#32324612)

From a bit of digging around I assume it is this site: http://guildbuildersinc.com.nyud.net/ [nyud.net] (coral cache) or guildbuildersinc.com Although you can't really see much on there without logging in. I'd be interested to hear views of anyone else that has seen the book, as the only review on Amazon is by the same person as on here.

yet another book on a specific aspect of drupal! (1)

chicane (38348) | more than 4 years ago | (#32323976)

Having invest 300hrs+ in drupal 6 and having a bookshelf of some 15 books on specific aspects I remain disappointed by the sprawling architecture and lack of cohesion of this product.
I look forward to a book that can bring order to the chaos that i perceive drupal currently to be with its multitude of modules however this evidently is not that book.
On a secondary note with drupal 7 currently in its fifth alpha iteration i suspect this book is designed with obsolescence in mind.

Maybe somehow i failed to drink the kool-aid

Re:yet another book on a specific aspect of drupal (1, Insightful)

Viol8 (599362) | more than 4 years ago | (#32324042)

"disappointed by the sprawling architecture and lack of cohesion of this product."

Its written in PHP. What the hell do you expect? :o)

Anyway , if you don't like it why do you use it?

Re:yet another book on a specific aspect of drupal (1)

chicane (38348) | more than 4 years ago | (#32324272)

That its written in PHP doesnt make it inherently good or bad after all a dictionary contains the words making up both the most expressive poetry and the simple tabloid headlines.

A Conversation relies upon a vocabulary in common and in my experience(defined above) Drupal fails to clearly define that vocabulary and explain it readily.

It seemed appropiate to the task but I would probably not choose to develop in it subsequently

Re:yet another book on a specific aspect of drupal (0, Offtopic)

kronosopher (1531873) | more than 4 years ago | (#32324680)

Its written in PHP. What the hell do you expect? :o)

90% of web "developers" aren't software engineers. Real software engineers use real platforms which make the web look like shite. PHP actually has come a long way as a language, but PHP developers tend to know the web platform(primarily HTML/CSS) and usually can't code their way out of a wet paper bag. In fact, Drupals overall failure as an API and the general lack of sophistication among its developers is typical when describing anything on the web platform. PHP has its caveats, trust me, but the crappy web platform tends to spawn even crappier applications.

Re:yet another book on a specific aspect of drupal (1)

Viol8 (599362) | more than 4 years ago | (#32334000)

I 100% agree. Looks like some web "developers" modded you down though.

Re:yet another book on a specific aspect of drupal (2, Informative)

AvitarX (172628) | more than 4 years ago | (#32324140)

Using Drupal did a good job of bringing a lot of it together for me.

I only have limited experience with it and joomla (we'll say about your 300 hrs in each), but my feeling with Drupal is the opposite of yours.

I feel that everything is connected ion a way that makes things awesome, where Joomla it was all over the place.

I love how in Drupal everything is simply a node, so I can create products to sell, and using views make some decent categories, create a side-bar with top sellers, create an news feed of new products, etc.

With CCK I can make content that is quite detailed, and using views I can display it however I want (on a map, in a hot list in the side bar, as blurbs in a blog kind-of style, a tagcloud of most popular keywords, an image slide show etc.).

All of this is integrated quite well I think, and it allows for a module adding functionality to add it to everything, since in the end, it is all just nodes.

I haven't used wordpress at all, but to contrast with Joomla, where when I install a map component, I am creating maps, not content.

When i used a store module, I am creating products, not content.

Yes there is a lot to drupal, but attachment views extend the functionality that does not exist in other systems, certainly not in a way that allows you to work with ALL of the content of a site in a consistent interface.

though maybe I just drank the kool-aid...

Re:yet another book on a specific aspect of drupal (1)

drinkypoo (153816) | more than 4 years ago | (#32332566)

I love how in Drupal everything is simply a node, so I can create products to sell, and using views make some decent categories, create a side-bar with top sellers, create an news feed of new products, etc.

Except that in basic drupal, not everything is a node. For example, taxonomy elements are not node objects unless you install the category module [drupal.org] , which is beta code. Users are not node objects, and the user node module seems to be gone these days. Themes and modules are not node objects, though they richly deserve to be. If you want everything to be a node, you need to try The Everything Engine [everything2.com] . And then you need to suffer with mod_perl.

When i used a store module, I am creating products, not content.

Is that why the default menu options created for adding content are in a menu called "Create Content"?

Re:yet another book on a specific aspect of drupal (1)

AvitarX (172628) | more than 4 years ago | (#32337768)

Is that why the default menu options created for adding content are in a menu called "Create Content"?

That was a complaint about joomla, in Drupal it is all content (though i guess not users, themes, or modules). I don't know what purpose the theme or module would have as a node though.

With Drupal I guess it's more that all content is content which make me like it, more than everything is a node.

Re:yet another book on a specific aspect of drupal (1)

drinkypoo (153816) | more than 4 years ago | (#32340218)

That was a complaint about joomla, in Drupal it is all content (though i guess not users, themes, or modules). I don't know what purpose the theme or module would have as a node though.

If you want to manipulate a theme or module you use theme or module specific functions. If everything is a node you don't. This is far more annoying in the case of taxonomies and terms, of course.

With Drupal I guess it's more that all content is content which make me like it, more than everything is a node.

I don't really know what you're trying to say. In Drupal, not all content is a node, although the Drupal 6 "way" is to use CCK (since that's integrated these days, at least the basics thereof) to create nodes for all content. This wasn't true in Drupal 5, leading to much frustration in migration, especially for users of the amazontools module, like me. I still have D5 Amazon node info in my database — sorry, non-node info — because I've had problems with the migration path and haven't taken a stab at it lately. However, there are various types of non-node content in the system, again notably including taxonomies and terms. These elements have descriptive text, which when integrated into Drupal's node system would likely be the "body text". Ideally they would be able to be parents and children of other types of content in the system (perhaps via the node relationship module) and you'd be able to construct views which displayed their text right along with the text of their other-node-type parents and children... but you can't, because categories aren't nodes, and terms aren't nodes.

Re:yet another book on a specific aspect of drupal (1)

AvitarX (172628) | more than 4 years ago | (#32341998)

But is a category really a piece of content?

It would be nice I guess to be able to treat a taxonomy page or display page as a node and augment it with CCK (I know I mess around more than I would like trying to get the Term pages to display as i want), but I don't think the distinction between them and content is purely artificial.

I guess i really just need more imagination though, as the everything engine description did not really help me out.

Another thing I like about Drupal is that it doesn't feel like I am fighting it too much (second paragraph of this reply not withstanding).

Re:yet another book on a specific aspect of drupal (1)

drinkypoo (153816) | more than 4 years ago | (#32342806)

But is a category really a piece of content?

Content as you see it is a node with body text ($node->body). But a category has text associated with it as well, which could well be considered body text (and which is often used as such) yet you can't get it from the node object, because it's not a node.

It would be nice I guess to be able to treat a taxonomy page or display page as a node and augment it with CCK (I know I mess around more than I would like trying to get the Term pages to display as i want), but I don't think the distinction between them and content is purely artificial.

It really is, though. Unfortunately it's the way it was done and it's hard to change now.

Re:yet another book on a specific aspect of drupal (1)

AvitarX (172628) | more than 4 years ago | (#32351242)

Not to be dense, but would this simpley make the way a category is defined essentially a field type using CCK?

So I could essentially create a content type of taxonomy, and define it using the category field type, making it work more the way i originally claimed it did?

Also, with CCK being integrated into core, it could very well move in that direction I would guess.

Re:yet another book on a specific aspect of drupal (1)

abigsmurf (919188) | more than 4 years ago | (#32324206)

I've been using drupal for the first time to design a site fully from scratch (rather than just using a theme) and I'm both impressed and frustrated by it.

I wish more module developers would use more specific class names so I can customise things easier. I've got dozens of .tpl.php files in my theme folder largely because I've had to go in and insert styling into their classless elements (ul,li and h2 being the most frequent offenders).

Probably approaching it wrong (I usually am) but adding a simple 'modulename_element' class to elements would save so much time.

Re:yet another book on a specific aspect of drupal (1)

Funkymoses (215816) | more than 4 years ago | (#32326884)

I've been using drupal for the first time to design a site fully from scratch (rather than just using a theme) and I'm both impressed and frustrated by it.

"Impressive and frustrating" should be the Drupal motto, and I say this as a guy who's largely happy with his two-year-old migration to the swiss army beast. (http://mgoblog.com) I'm hoping 7 hammers out 50% of the frustration -- seems like it should -- and am looking forward to the day nine months after its release when all my modules are ported.

Re:yet another book on a specific aspect of drupal (1)

WiFiBro (784621) | more than 4 years ago | (#32329324)

Probably the outer element contains some sort of class name. So you would have to go with css like .modulename_element div h2{
    font-weight:bold;
}

which would by the way make your css dependent on template changes.

Re:yet another book on a specific aspect of drupal (1)

abigsmurf (919188) | more than 4 years ago | (#32332686)

Sometimes they do which is helpfull. However all too often they use a generic class like item-list or content

Drupal? (2, Funny)

rudy_wayne (414635) | more than 4 years ago | (#32324054)

I thought that tranny's name was RuPaul.

Wait 6 months... (2, Interesting)

Angostura (703910) | more than 4 years ago | (#32326578)

... and he'll be able to write the definitive guide to Views in Drupal 7. CCK got integrated into the core, but Views didn't. I suspect getting Views ported is going to be a pain.

Re:Wait 6 months... (1)

Endophage (1685212) | more than 4 years ago | (#32329464)

There's already a Views 3 development version available for the drupal 7 dev release that works perfectly. I've been playing about with the D7 dev version for a few months now, there's a lot of great improvements. I'm particularly loving the admin overlay. It's much better than the overlay module for D6 and makes it nicer working with the site admin in general.

Re:Wait 6 months... (1)

meustrus (1588597) | more than 4 years ago | (#32331692)

I can't imagine why Views is not being integrated into Core. I mean, Core 6 had such necessary things as an OpenID authentication module. I would personally like to see certain things rewritten to use Views instead of the legacy methods already used, such as the front page or Drupal forums.
Check for New Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Create a Slashdot Account

Loading...