2

I've inherited a site running a custom Zen sub-theme.

It uses standard CCK content types with several "page-node-" and "node-" template files for layout control.

The original designer used the .tpl files to manually embed various views and blocks (with specific HTML structure for styling) into different pages throughout the site. As you can imagine, these views and blocks can not be directly configured through the UI.

One page however has some block like sidebar image elements that cannot be manipulated through the UI and appear to be embedded via a template file, but I can't find a template file in either the sub-theme or base theme (zen) directory that would affect this page at the page level. There is a node level template, but it only affects the content area, not the right sidebar.

From the source, I can see that they are not actual blocks as they simply have "<p>" tags around them

<div id="sidebar-right-inner" class="region region-right">

    <p><a href="myurl" title="title"><img src="path/image.png" alt=""></a></p>


    <div id="block-block-39" class="block block-block region-even even region-count-2 
     count-6 with-block-editing"> ...

The element between #sidebar-right-inner and #block-block-39 simply has a <p> tag with no drupal classes or ids. This is what needs to go. Block-block-39 has been configured through the "blocks" administration page and is supposed to be there.

If it were indeed embedded via template file, I should have a file like sites/all/themes/mytheme/pages/page-node-15.tpl.php, but I don't. I've checked Page.tpl.php in both sub-theme and base theme (and every other .tpl file) and cannot figure out how these elements are getting there! Is there somewhere else that a block of HTML could be embedded?

I've tried disabling Javascript on my browser with no change. And if it were created through the UI somehow, I'm thinking it would have additional divs wrapped around it or other classes / ids.

I think I have a pretty good handle on how templates work (hierarchically speaking), and I've spent days searching for an answer. I'm sure I'm missing something silly, but I'm pretty stumped at the moment.

I basically need to just get rid of them.

  • Disable javascript to see if they might be injecting the content that way. You can also check if the context module is adding anything. Another place you can look is template.php. – Patrick Ryan Aug 15 '13 at 22:02
  • Given the id="block-block-39" tags, I'd look to see if they have been manually created through the block UI, eg admin/build/block and then thus stored in the DB... – Jimajamma Aug 15 '13 at 22:37
  • @PatrickRyan Template.php doesn't show any signs of it, Context Module isn't installed, Disabling JavaScript has no effect. :( Thanks for the suggestions though. – Aaron Waller Aug 16 '13 at 13:42
  • @Jimajamma Thanks for the reply. The id="block-block-39" div is simply what follows the element that I need to remove. I've updated the question for clarity. – Aaron Waller Aug 16 '13 at 13:45
0

Ok, these elements do not display an "edit block" option when I am logged in as an admin and mouse hover them, nor do they display any of the HTML class / id properties which are typically associated with a block. So It had to be somehow injected or modified VIA a template file.

I did however, finally discover that they were in fact being added via a cryptically named block.

This meant that it was likely being acted upon by a "block-" template. Armed with the newly discovered block number, I found that the file "block-block-22.tpl.php" was stripping the edit link and other divs and formatting to prevent the block from having it's own background etc.

The standard "block.tpl.php" file writes all blocks in the sub-theme like:

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

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

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

  <?php print $edit_links; ?>

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

Whereas "block-block-22.tpl.php" was overriding the default and writing it as such:

<?php print $block->content; ?>

effectively stripping all of the block's formatting so that only the images that it contained would show with no extra margin, padding, background etc.

I had a feeling I was missing something simple...

Furthermore, changing it to:

<?php print $edit_links; ?>
<?php print $block->content; ?>

Enabled the "edit block" link for administrators, so now it can be edited directly from the page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.