Hi all.
On our site, we want to use some special blocks to display information. At the end of each block is a link. But, due to the design, this link cannot be set inside the body of the block when using the WYSIWYG editor. We used CCK to create a special content type with an extra "End Link" field for this link. Then, with Views, we outputted this link in a special way and got the design exactly how we wanted it. But now, we can only use ONE block with this particular view.

Is there a way to make this View like a "Block template" ? Or, for each node using this special content type, to create a block ? The problem is this custom field. How do we output it inside a block template ? We can't just go $block->custom_field...Or is there a CCK for blocks ? I searched for it but couldn't find it.

Thx

Comments

There are several "Node in

There are several "Node in Block" modules that may help you.

A Views Argument Might Help

Am I right to guess that for each node this block is displayed on, the link changes according to what node the block is being displayed on? If so, adding an argument to the view for the node id may help. If you do that you'll then have to insert the block manually with some code. I did this on a Drupal 5 site to get a block to filter the content based on the taxonomy terms that a certain node belonged to. I modified the code that I used and posted it below. I changed the argument from a taxonomy term to the node id.

<?php
$view
= views_get_view('VIEW_NAME');
print
views_build_view('block', $view, array($node->nid), false, 1);
?>

Try putting this in the node.tpl.php file for your content type and see what happens. I haven't tested the code so I'm not entirely sure this will work, but I have a suspicion that something like this may be the answer your looking for. I'm also not sure if my array($node->nid) will call the node id, so you may have to play around with how that's written to get the proper node id, especially if you're placing this code in a sidebar.

DC

--------------------------------
Delicious Creative
Liverpool Web Design, Video, Audio, & Creative Services
http://www.deliciouscreative.com

--------------------------------
Delicious Creative
Liverpool Web Design, Video, Audio, & Creative Services
http://www.deliciouscreative.com

Thanks for your replies

THanks guys, this is helpfull.

@DC : not exactly. We create a block called, say "New Product"...the body of the block is a summary of the product, and at the bottom we eould have a link "more info" pointing to a node with more info about the product. But we might have several product blocks on a page. But thanks a lot for your reply, very much appreciated :-)

@nevets: that sounds interisting. Wonder if you can output custom fields. I'll check. If it succeeds, I'll come back here and let everyone now, in case someone else runs into this problem.

Cheers,

- Wouter

wadmiraal

Worked

Ok, the NodeBlock module did the trick (by the time of writing, NodeAsBlock is only available for Drupal 5).

I could create a specific node type with CCK and have it display as a block. Then, creating a specific node template for my node type, I could easily style it the way we wanted. I could output our custom fields and put them exactly where we wanted in the design.

This is an awesome module, which allows for many possibilities ! Thanks for directing me to it !

- Wouter

wadmiraal