Link to home
Start Free TrialLog in
Avatar of bogorman
bogorman

asked on

Making editing of blocks user-friendly

I have started to design a drupal website:

http://209.200.96.22/acquiadrupal/

I want to make editing of blocks on the frontpage easier for users with the necessary permissions.  In admin mode (I can send the necessary username/passwords if you wish) when you hover over the  top of the block you see the usual links configure and edit view.  Configure doesn't help when it comes to editing/adding content to the block.   Edit view takes one to the view edit page but as the data for these blocks is defined in nodequeues it also does not help an inexperienced user.

The nodequeue for the top block only contains one node and the nodequeue for the lower block can contain an unlimited number of nodes.

Is there any way of making this process easier for the user?
Avatar of junipllc
junipllc
Flag of United States of America image

Hi bogoman,

I'm not 100% I understand your question, but that's because it's early in the morning here ;) ... so I'll give it a shot. If I'm on the wrong track, let me know.

I've run into problems like this, where having the end-user have to "know" a bit about Drupal isn't an option. In your case (I'm assuming you mean the main content column, although the left block would work as well) you could disable the "Edit View" and "Configure" rollover links and add your own to point to the proper editing mechanisms.

I've never had a need to use Nodequeue, but since the View is based on that data would it be possible to have the user directed like this:

 - an "Edit This" on each node so the user can go right to the Node Edit form
 - an "Edit This List" at the top of the View that points to the Nodequeue edit
 - an "Add To This List" at the top of the View that points to the Node Add form for that content type

...or something similar?

Basically, the approach here would be to "corral" the user into only those forms that were kind-of-made-for-the-end user instead of the Block Edit or View Edit (blech) forms.

Now, if I'm on track so far, then to do the stuff above you could use:

- a node.tpl.php file,
- the Header field in the View
- the Header field in the View

for each respective task above.

As with anything Drupal, there are a lot of other ways to do it, but I think that's where I would start.

If I'm off-base (I've had a little coffee now, so I'm starting to think a bit straighter), let me know and I'll see what I can do.

By the way, the permissions on your site are already set to allow for anonymous access to your config. It helped quite a bit, but don't forget to button that back up when you're done! :)

Good luck!

Mike
Avatar of bogorman
bogorman

ASKER

Hi Mike,
Thanks for your quick reply.
Will study it more carefully and get back to you.
Brian
Hi Mike,
Have studied your helpful email. Sorry about the config. Have corrected it now by setting update_free_access to FALSE.
The problem is with my homepage that all the blocks that contain content (not, of course the search block, etc) use nodequeue to define the content.
So, looking at the left sidebar, the top block (Saint Patrick) displays a teaser for the Saint Patrick node (if you click on it you will see the full node).  When you log in as admin, this node displays a nodequeue tab and clicking on that displays a link which enables the user to include the node in this nodequeue. In the case of Saint Patrick, the node is already in the nodequeue so the link allows the user to remove the node from the queue.    This particular nodequeue is set up to only allow one node in the queue so to change the content to, say, Saint John, the user displays the Saint John node, clicks on the nodequeue tab, and the link allows adding this node to the queue.  As only one node is allowed in the queue, the St P node is replaced by the St John one.
The block below in the left sidebar is based on a node which allows multiple nodes in the nodequeue so, to remove a node from the queue, the user would have to find the node and delete it from the queue via the nodequeue tab. To add a node to the queue, the user has to find another node and add it to the queue.
To make this process user-friendly seems to be quite difficult.   I suppose one idea would be to have a help link in each block which displays a custom help page to instruct the user.
What I can't understand is how you edit/add the links in a particular block.   How can I construct a tpl file for each block and add a link to it (each block is different and would need different help files).
Regards
Brian
I'm running a little behind with my Experts Exchange, did you resolve the problem? If not (which I suspect) I should have some more time to look at it tomorrow. I just want to let you know I haven't forgotten about your question...I'm just a little bogged down at the moment.

Mike
Thanks, Mike.
Look forward to hearing from you.
Brian
Wow, I totally flaked on this question, I'm sorry. I just re-read the whole thing, and I think I get what you're shooting at.

In order to create a .tpl.php that is specific to a particular block, you'd name it something like (and don't quote me on this, but....):

block-block-xxx.tpl.php
or
block-nodequeue-xxx.tpl.php

where xxx is the "delta" of the block. A block delta is kind of like a node id for a block...sort of. There's an explanation of how to find the proper filename for each particular block here:

http://drupal.org/node/104319

Each of your blocks will have a unique way of identifying it using a .tpl.php file. That link should be a huge help. Even with years of experience I still forget the exact format, and I have to refer to it constantly.

To change the "layout" of the block (e.g. add a link) all you need to do is copy block.tpl.php to the new name inside your theme directory (e.g. copy block.tpl.php to block-block-41.tpl.php) and edit the new file with any changes. Once you have it edited, make sure you flush your theme registry so the new file will be recognized...and voila! the blocks that you want to style will start obeying your every command.

I hope I didn't just explain something you already know, and if I did, let me know and I promise this time I'll get back to you sooner!

Mike
Hi Mike,
Thanks for your help.
Have not tried your suggestions yet - hope to do so today.  Think they certainly should enable me to have a link in the block (say "Help with editing") which would open a new help page which applies spicifically to that block.
Problem I would have then is to have a print button on the page (to print and return to home page) and also a cancel button just to return the user to the home page.
How can I do that?
Brian
Hi Mike,
Have tried to follow your suggestions. At first I found it very difficult to determine the module name and the delta for the blocks on my homepage. However, I came across the following from the Pixel Clever site:

http://www.pixelclever.com/how-theme-specific-blocks-drupal

In it I found:

"Styling individual blocks follows the same basic pattern as styling regions, but there is one extra step. You have to find the unique block name so that you can know how to name the tpl file.
To do so there are two methods that work. One, the old fashion way (and my preferred method) go to the blocks page (admin/build/block) and find the listing for the particular block you wish to alter. Now hover over the link that says “configure”. If you are using Firefox (and you should be) you will need to look to the far bottom left corner of the Firefox window when you hover over the link, doing so shows you where you would go if you were to click the link. Don’t click though, just make note of the last two items of the url. For example when I hover over one of my jquerymenu blocks I see the following link in the left corner: admin/build/block/configure/jquerymenu/0. From that URL all we need are the last two elements: jquerymenu and 0. Using this we can now pinpoint that block for an override by creating a tpl file called block-jquerymenu-0.tpl.php. So essentially the formula is this: block-modulename-delta.tpl.php."

Am too tired to continue tonight but this technique appears to display the module name and delta easily. Will work on it tomorrow.  

In the meantime, any ideas on printing/cancel buttons?

Brian

I went to post this earlier, and Experts Exchange was down for maintenance -- here's a copy/paste:

-----

Yes, you just need to view the source (or hover over the link) but if you look at your source, you'll find this (home page, St. Patrick section):

 
 
<div id="block-views-nodequeue_3-block" class="block block-views region-even even region-count-2 count-2 with-block-editing"><div class="block-inner">

Open in new window


If you look at the id of the div, that should be where you obtain your .tpl.php name. So, in this case it would be "block-views-nodequeue_3-block.tpl.php" -- although I haven't used nodequeue so I can't be absolutely sure. If you have the devel_themer module installed you can check the little box at the bottom left of the screen, then click on the block in question. Typically the devel_themer module will give you a list of possible .tpl.php files you can use.

As far as the printing is concerned, I thought I had answered that but I probably got distracted by something shiny before I hit submit (it's not above so I didn't finish writing apparently). You can just add links the same way into the .tpl.php or into the help page you're linking to. The Cancel could point to "/" (e.g. <a href="/">Cancel</a>).

There is a print module that you can use to create printable versions of nodes (aptly named "print," I think, but it's PDF, Fax, and Print or something like that). That might help you with the printing since it just puts the links in for you.

If that doesn't work for you, then you can always just pop a little JavaScript in there to invoke the browser's print. If you do it that way, here's a good tutorial of how to do it:

http://www.htmlgoodies.com/beyond/javascript/article.php/3471121/Print-a-Web-Page-Using-JavaScript.htm

Of course, any of these text links could just as easily be button images (just replace the text "Cancel" above with an <img> tag), but that's just me since I love graphical elements. :)

I hope this helps!! Let me know if it doesn't, and get some sleep!

Mike
Hi Mike,

Have coped block.tpl.php from the themes/zen/zen subdirectory to my theme directory and changed its name to block-views-nodequeue_3-block.tpl.php . Have then flushed the caches.
My problem is now how to add the link.  The file contains:

 <div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?>"><div class="block-inner">

  <?php if ($block->subject): ?>
    <h2 class="title"><?php print $block->subject; ?></h2>
  <?php endif; ?>

  <div class="content">
    <?php print $block->content; ?>
  </div>

  <?php print $edit_links; ?>

</div></div> <!-- /block-inner, /block -->


The line:

  <?php print $edit_links; ?>

would appear to print the links (though as it is BELOW the content, am I right here?).   Anyway, how can I add a link?   Is $edit_links an array containing the links or am I talking nonsense here?

Anyway,  will be most grateful for your further advice.

Brian
You just just insert HTML right into that file. For example:


  <?php print $edit_links; ?><a href="/">Cancel</a>

You can really put the HTML anywhere you want in the block template, it doesn't have to be anywhere in particular. Try that first, save the .tpl.php file, and then reload the browser (power-refresh if you need to to make sure your browser isn't caching the page, or clear your browser cache and reload -- same thing).

If the .tpl.php is named properly then your new link should show up.

Mike
Hi Mike,

The coding now reads:

?>
<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?>"><div class="block-inner">

  <?php if ($block->subject): ?>
    <h2 class="title"><?php print $block->subject; ?></h2>
  <?php endif; ?>

  <div class="content">
    <?php print $block->content; ?>
  </div>

  <?php print $edit_links; ?><a href="/">Cancel</a>

</div></div> <!-- /block-inner, /block -->

but the link does not appear (I assume it should appear after the two links "configure" and "edit view")

so I suppose I have got the name wrong. One thing I thought of, however, is do you need a print statement in the php to print a link?

Otherwise how can I tell whether the template name is wrong?   I suppose I could install devel_themer but I have heard it conflicts with some other modules.

What would you suggest?

Brian



Yes, install devel_themer and enable it. Then use it to find the name you should be using for the template file, and then turn it off. It definitely does conflict with certain layouts and modules, but it's great for temporary use. It can be in the modules folder with no worries, just as long as it's disabled during normal operation of the site.

Just a side note: depending on the way the CSS for the theme is configured, the "Cancel" link may or may not show up next to the configure/edit links. But it should show up somewhere in the block.

As far as the print is concerned, you can either use the print module or use the Javascript solution (see a few posts ago for the link). Neither solution should require you to write or modify any PHP, although you always could use PHP to customize it.

Mike
Hi Mike,
Have installed devel_themer and enabled it.
Unfortunately I then could not display any of the website pages, so I deleted devel and devel_themer from the modules directory but I still cannot display any pages.
How can I cure this?
Brian
Did you disable the module before you deleted it? Note what I said above:

"It can be in the modules folder with no worries, just as long as it's disabled during normal operation of the site."

If your site is not coming up, put the modules back into the directory and see if that helps. Then *disable* the module. You can leave it in there. You should never, ever just delete a module's files without disabling it (and uninstalling it, if the module supports that).

You can also use drush (available on Drupal.org) to disable modules, uninstall them, or troubleshoot problems.

Have you read any primers or tutorials on Drupal theming? If not, then I think you may want to before you go too much further. Theming is a lot more complicated than we can go into via Experts-Exchange. If you need me to point you in the right direction I can find some good ones for you. There's a lot of information about theming out there, and I'd be happy to find some material that might fit your skill level and experience with Drupal. Just let me know how much experience you have. :)

Mike
Hi Mike,
Thanks.  Have uploaded devel and devel_themer to the site and I can now display the homepage but with a lot of errors:

# warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'devel_themer_catch_function' was given in D:\inetpub\DomainID207640\acquiadrupal\includes\theme.inc on line 656.
# warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'devel_themer_catch_function' was given in D:\inetpub\DomainID207640\acquiadrupal\includes\theme.inc on line 656.
# warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'devel_themer_catch_function' was given in D:\inetpub\DomainID207640\acquiadrupal\includes\theme.inc on line 656.

etc,  etc.....


Unfortunately I cannot display the modules page. I get:

The page cannot be displayed because an internal server error has occurred.

I can restore an earlier version of the site and install devel_themer again, but to avoid this is there anything else I can do, Mike to correct this?

Brian
Hi Mike,
Flushing caches has removed the errors from the homepage but I still get the internal server error when I try to access the modules page.
Brian
Hmmm...I think the best idea is to access your webserver's logs since it's generating an internal server error (this is typically detailed in an error log outside of drupal).

There is another way, though, to possibly get more information about the error, but depending on what it is it may not give you any information. Or it could be a treasure trove. Go to:

http://209.200.96.22/acquiadrupal/admin/reports/dblog

Actually, scratch that (I'm leaving it for future reference) -- you're getting an internal server error there too (I just checked).

This could be caused by a number of things. See this post on DO (shorthand for Drupal.org) and see if any of the solutions or links on that page help:

http://drupal.org/node/416906

Did you change anything other than just those modules? Perhaps if you temporarily take out the new template file you created it may help. This is just off the top of my head, but I think the best place to start is your webserver error log.

Good luck!

Mike
Of course, I cannot run update.php as I get the same error.
Is the only way to install Drush? I think I can run update with that, or is running update likely to get the site running again, so I can try and sort out the themer problem. Alternatively I can simply restore all the site from when it was working correctly.
After bombarding you with messages (sorry!) I may well find that the template name you suggested is the right one and I need to get more familiar with the coding.
I have three books on Drupal:
O'Reilly's "Using Drupal"
David Mercer's "Building Powerful and Robust Websites with Drupal"
and
Matt Butcher's "Learning Drupal 6"
I must confess I have only just "dipped into them"   Would any of these help?
I have next to no knowledge of php but have quite a bit of experience in other languages so I suppose with application I can learn!
Again, apols for endless messages but would like to get this sorted if poss.
Brian

Hi Mike,
Just read your most recent message. Will study it.
Brian
ASKER CERTIFIED SOLUTION
Avatar of junipllc
junipllc
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Mike,
Thanks again for all your help.   Did in fact download the server logs but I find them difficult to interpret.
I think I will restore an earlier backup to "get back to normal" and, as you suggest, do some more study. It may be complicated by the fact that the block contains a view (the one created by the nodequeue) and possibly it is this I should be editing to add the link. Also the link should only appear to admins.
Anyway, thanks again.
Brian