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:
<?php $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 :-)


ahmet
You could also create your view as a block, set it in a region at the bottom of your content area.
use blocks
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.
another approach
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.
insert_view
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 :-)
Post new comment