Drupal Views. Too powerful?

When working on a Drupal site for a client earlier today I had an odd problem.

The client wanted a page that lists downloadable files and has a little blurb about the downloads at the top, so I duly created a view that lists all published nodes of type 'Download' and sticks some HTML at the top.

The problem occurred when the client wanted to change the HTML header text. Views is very powerful and the interface used to edit them is fairly complex.  Giving the client access to the views administration pages would probably result in more support phone calls than we'd get if we told the client to ask us to make these changes as required.

Still, if a client can't edit their own website, what is the point of a CMS?

In the middle of documenting the precise steps to follow to edit the correct view, I remembered that I can in fact use a piece of custom PHP code as header, and I can load anything at all that way.  In this case, I can load a user-editable page and display the relevant part a the view header.

In the end, two lines of PHP made my problem go away. I created a Story and made a note of its node id, which was 39. In the view header, can I load this node via the node_load() API call and the display just the body:

  $h_node = node_load(39);
  print $h_node->body;

All the client needs to do is edit node 39 via the normal WYSIWYG editor.  Views is so powerful that it solves the problem of being too powerful :-)


With the solution you have described, the user will need to edit the text above the view out of context - i.e. they'll edit node 39 in order to change a different page on their website.

Rather than including a page above a view, why not include the view at the bottom of the page? This way the user will see the view at node/39 and also edit the text above the view at node/39/edit.

The insert view module (http://drupal.org/project/insert_view) might be easiest way to do this, but has the disadvantage that the user may accidentally delete the token and remove the view from the page.

Hmm, interesting. I didn't know that existed. In this case though I fear the token might not survive an edit.

However, viewfield might work; I can create a specific content type with a hidden (on the edit page) CCK field containing the view. I will play and find out :-)

You could also create your view as a block, set it in a region at the bottom of your content area, and set the block to only appear on that particular page. No extra module needed.

This is my preferred method as well. I find that most people grasp block administration pretty quickly, and besides the block admin screen is one of the more fun bits of putting together a site.

With the solution you have described, the user will need to edit the text above the view out of context - i.e. they'll edit node 39 in order to change a different page on their website.Şarkı Sözü

hey and just to let you know I got this error after posting that last comment. you might want to take a look at that. =)

user warning: Unknown column 'reputation' in 'field list' query: INSERT INTO drupal_mollom (entity, did, session, changed, quality, reputation, languages) VALUES ('comment', '441', '1010075b6044a12c56', 1286441230, '', '', '') in /srv/www/shared-drupal-6/html/includes/common.inc on line 3528.

Odd, that column is supposedly unused and was removed from the database with update 6114. I've had a look and I don't see any old versions of the module sitting around. Peculiar. I might clear the cache and cross my fingers :-/

I'm building a site where different clients can see in the private news site (ie, a news client to see A1, A2, B ,..., client to see B1, B2, etc.) and news groups (client To see P1, P2, ..., customer B see P1, P2 ,...). I do not need more sophistication than that. My question is: clusters too powerful for my needs? ". I worry that the learning curve is steep OG (is so great and appear to lack good documentation) and maybe a much simpler solution that addresses my problem exists.

Any advice on this question is welcome.

A very useful post this one - I've been using customfield (PHP Code) to load nodes as bit of library text in my views which is extremely flexible.

My one problem is trying to get a piece of PHP that will load node translations that automatically work rather than creating a view per language. Any ideas?

I would strongly recommend handling this differently...

Use the Panels interface to create a Panels Page that contains both an easily edited Page node and a Views list of content. If your theme already includes a convenient [edit node] link, then you're done. Otherwise, you'll also want to include a special link on that Panels Page that shows up only for a user with appropriate permissions to send them to the edit page for that particular Page. This link could be on a third pane in your Panels Page.

I'm not going to be more specific than that, since I recommend using a theme or template that has an [edit node] link built in. But if anyone would like help creating a special link as I mention, I'd be happy to advise with more specifics given an understanding of your unique scenario. *** Feel free to contact me.

Panels makes a lot of things easier to compartmentalize.

Hope this helps someone! (:
- Drew

Add new comment