views:

45

answers:

4

I am developing a module to display video. I have created a view so-called navigation for the user to select a video from a list.

Now I want o add this navigation to every node with type = 'video'. I don't know whether I should create a template for it ( then I have to put the template file in theme folder which is not so good ) or use some kind of hooks ( I haven't figured out which one to use ) ?

I tried to install http://drupal.org/project/views_attach, however the view only appeared in the content (after Title) which is not what I really want. I want it to be on top of the title.

Please help. I'm using drupal 6 Thanks in advance.

A: 

Sounds like you'd just create the navigation block any number of ways, and tell the block to only show on video node types using php in the display rules. Maybe menu_block module can help you here.

Kevin
Do you mean the hook_block ?
iKid
No there is a module called Menu Block which lets you add navigation easily. http://drupal.org/project/menu_block
Kevin
A: 

You can render the view anywhere you want in your node template with views_embed_view.

Create a template specific for your video node type: node-video.tpl.php and insert the view where you want it.

googletorp
i've seen this recommendation before, and for simple views it works well. If your view pulls in additional css or js files (like jcarousel views plugin), views_embed_view in a tpl file happens too late in the page generation chain for supporting files to be added to the page's markup.
@googletop I have came across this before, however as I mentioned I don't want to put the file in theme folder. I wrote a module, so I want it to be installable. If I use template how can I have it installed in other sites ?
iKid
A: 

If you don't want to do it via template files, the Panels module can be used to have different layouts per node type. Once you install it, create a variant under the node_view panel and restric that variant to be selected for nodes of type 'video'

A: 

I finally found how to implement a view as block (simply select block as a content view) and I use this code below to display a block in a certain node type

<?php
  $match = FALSE;
  $types = array('video'=>1);

  if ((arg(0) == 'node') && is_numeric(arg(1))) {
    $node = node_load(arg(1));
    $match = isset($types[$node->type]);
  }
  return $match
}
?>
iKid

related questions