Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm newbie in drupal and php/
Tell me please? what i do not right?
1. In my theme template.php i write next.
function phptemplate_nodeasblock($node) {
return _phptemplate_callback('nodeasblock', array('node' => $node));
}
2. Create nodeasblock.tpl.php and put in it next code
<?php
// For all other regions, a standard subject.
$subject = '<h3 class="title">'.$node->title.'</h3>';
// set our id's & classes. This becomes our target.
?>
<div <?php {
echo 'id="'.$node->nid.'"';
echo ' class="block block-',$node->nid,'"';
} ?>>
<?php echo $subject ?>
<div class="content">
<?php echo $node->teaser ?>
</div>
<div class="readon clear"><a href="<?php print '?q=node/'.$node->nid ?>"><?php print t('Read more') ?></a></div>
</div>
And... nothing.
If i delete all may exercises - block display with my node.tpl.php
When and what is error?
Comment | File | Size | Author |
---|---|---|---|
#3 | nodeasblock-shot.jpg | 47.91 KB | toologic |
Comments
Comment #1
mfredrickson CreditAttribution: mfredrickson commentedHello toologic,
The problem is that theme_nodeasblock returns an array like:
You're tpl file just returns a string. If you are happy with the block title, you could modify your phptemplate callback function to just return the content portion of the block:
then just use the .tpl file to control the content of the block (but not it's title).
Good luck! (feel free to reopen this ticket if you need more help)
-Mark
Comment #2
mfredrickson CreditAttribution: mfredrickson commentedRenaming as I'm linking to this node in the README file.
Comment #3
toologic CreditAttribution: toologic commentedSo many steps...
1. To prevent output block with block.tpl.php I create new template block-nodeasblock.tpl.php, where only one row inserted
2. Create (update) my template for nodeasblock output i use a next code in nodeasblock.tpl.php:
Hm... so many steps and snippets for simple access for Node structure.
Result in attached screenshot
Comment #4
toologic CreditAttribution: toologic commentedAny way great thanks for module and help.
Im happy, that it is fast.
Andrew
Comment #5
(not verified) CreditAttribution: commentedComment #6
TheoRichel CreditAttribution: TheoRichel commentedI would like to remove the 'Sumitted by..' data from my Nodeasblock-block. To get a grip on it I made and modified the following three files (I repeat what I learned above), but I see no changes whatsoever. This is what I did:
1. Added the following code to template.php
2. Created block-nodeasblock.tpl.php with just this line:
<?php echo $block->content ?>
3. Created nodeasblock.tpl.php witrh the following code:
But nothing happens
Firebug even tells me that where in the last piiece of code H3 is ordered I stell get H2
But to repeat: my mean problem is to get rid of the submitted info.
Many thanks
Theo Richel
Comment #7
TheoRichel CreditAttribution: TheoRichel commentedWell I did soemthing wrong and I found out what: I had PUT one of the files in the wrong directory. Now it functions as intended here, though nog yet as I want. I would like to have the title back and the submitted info away.
Comment #8
wuf31 CreditAttribution: wuf31 commentedThank you..
But how do you theme it for drupal 6 ??
Comment #9
netsensei CreditAttribution: netsensei commentedYou could override this function in your template.php file
There's also a hook
theme('nodeasblock', $node);
but you have to implement it yourself in your template.php (register with hook_theme and such!)