By madslund on
I have a block, that I made with the Views module.
The content comes from a custom content type I made with the CCK module.
My block's name is "middle", so I took the default block.tpl.php and copied that to a new file: block-middle.tpl.php.
That file looks like this:
<?php
// $Id: block.tpl.php,v 1.3 2007/08/07 08:39:36 goba Exp $
?>
<div class="block block-<?php print $block->module; ?>" id="block-<?php print $block->module; ?>-<?php print $block->delta; ?>">
<h2 class="title"><?php print $block->subject; ?></h2>
<div class="content"><?php print $block->content; ?></div>
</div>
I see where the content is output (print $block->content) ... but how do access the "sub-variables" in "content"?
For example, there is an image within the content, and instead of that just being output as an image, I need it to be output as a background in a div.
So what I'm looking for is something like this:
<div class="content">
<div style="background-image: url(<?php print $block->content->MyImage; ?>);">
<?php print $block->content->MyText; ?>
</div>
</div>
I hope this makes sense... :)
How do I do it?
Comments
...
There aren't any sub-variables in "content". Drupal asks modules for an HTML string, and that's what gets in a block. It knows nothing about "variables".
It seems that your want to theme the view (or to theme the node, if your view's row style is "Node"), not the block.
So...
That's probably right. I want to theme the node. How do I do that? :)
Figured that one out myself
views-views--myviewsname.tpl.php in my theme's folder.
Thanks for pushing me in the right direction. :)