or, to put in other words, how to theme a content type input form related to another content type through the Node Relativity module?

Thanx everybody.

|strexy

Comments

kirilius’s picture

Up!

kirilius’s picture

Any other ideas?
;-)

strexy’s picture

:)

derjochenmeyer’s picture

Im trying to get my head around node relativity. But i dont understand the question.

The title says output the question input.

What exactly do you want to do. Example please :)

----------------------
okay.cool

kirilius’s picture

Here is my example:

I want to define a node type A and a node type B (which has a CCK imagefield in it).
The relationship is: one A-node may have zero, one or many B-nodes under it.

A
|--B1
|--B2
|--B3
|--....

That can be easily defined using the Relativity module.

The thing I want to customize is the default behavior of the UI regarding those two node types. Right now after creating an A-node, there are default links under it allowing for adding new attached B-nodes. One thing I want to change is the display of these links:
- Which to show, which not to show
- Position on the screen relative to the main A-node (e.g. I want them placed and themed in a side-block, not under the A-node)

After adding a number of dependent B-nodes, a list of them is displayed under the A-node. That's another thing I want to change. The current list is just a basic list with options to remove the dependency and so on. The problem is that:
- Again I don't like the layout and would like to change it
- My B-type is actually an image! I would like to show a thumbnail gallery-style list of dependent images instead of node names. (in fact that's my main issue here).

A themeable view would be perfect in this case but view integration is not available, that's why i am faced with the option of digging into the code and update it myself, which I don't want to do for a number of reasons:
- I don't really know much about PHP (though I have a good programming experience) and will make lots of mistakes
- I will lose the advantage of clean module update if a new version comes out

derjochenmeyer’s picture

It seems easy :) tell me if im wrong:

  • go to admin/settings/relativity/display
  • set the Link operations weight to "0" for your A-node type

then:

  • go to admin/build/block
  • activate the default Node relativity: link operations-Block
  • optionally you can influence the visibility of that block a bit more, e.g. only activating it for certain roles

even then:

  • you can theme this block individually, e.g. using a block-modulename.tpl.php in your theme folder so you will have no problems with updates (A good book: Pro Drupal Development by John K. VanDyk and
    Matt Westgate for more on theming blocks)

For theming that block its a good idea to just create an empty file with that name (with the right name drupal will automatically [almost magically] use that fiel for theming your block). Use the following code to see all the available objects, arrays and variables. You should find at least a node id, with which you can get the path to your CCK image:

<pre>
<?php print_r($block); ?>
</pre>

did that help?

----------------------
okay.cool

kirilius’s picture

Yes, it did! Definitely. I am eager to try that now. Thank you very much for the thorough explanation!

The main problem still remains however: how to display a group of thumbnails for the B-nodes under the A-node?
It would be nice if I had a view that can handle the relationship between the nodes and return the group of dependent ones...

derjochenmeyer’s picture

No prob :-) I just worked on the same kind of thing for the last... hm, i guess months:

What i explained before is what i use for my admins (Node relativity: link operations). The following describes my output for the enduser:

  • goto admin/build/views/add and creaet a new block view
  • as View Type: choose teaser list
  • in the Fields section choose your image (you can thumb it with imagecache e.g.)
  • now the crucial part! As Arguments use Relativity: Parent Node ID with the follwoing Argument Handling Code (as it is, without! the php delimiters):
    $args[0] = arg(1);
  • Furthermore use Node: Type as a Filter to only show B-nodes

then another trick:

  • goto admin/build/block and configure your new block view
  • place it where you want e.g. in your content region with a high weight to show it under your A-nodes
  • now the tricky part. the following code goes in your Show block on specific pages: settings with the radio checked at Show if the following PHP code returns TRUE (PHP-mode, experts only). REMEMBER TO SET YOUR OWN NODE TYPE WHERE IT SAYS "A-node" IN THE FOLLOWING CODE
    <?php
    $match = FALSE;
    // Which node types
    $types = array('A-node' => 1);
    
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $nid = arg(1);
      $node = node_load(array('nid' => $nid));
      $type = $node->type;
      if (isset($types[$type])) {
            $match = TRUE;
      }
    }
    return $match;
    ?>
    

I hope it will also save you weeks of figuring it out. And maybe its helpfull to others. Its seems im not the only one who needs this functionality. :-)

I'm happy if i could help.

----------------------
okay.cool

kirilius’s picture

Once again: thank you very much! This was exactly what I needed.

With a little more customization from my side everything should be fine. The only thing that I would suggest (if the B-type is an image) is to use the "bonus pack grid" view type instead of the "teaser list". The grid view provides a more gallery-style display for the thumbnails.

Now I only need to figure out how to make the thumbnails in the view clickable and everything should be fine.

Thanks!

kirilius’s picture

It seems Node Relativity already has a generic support for views. Look here:

http://drupal.org/node/130870

However it is not fully finished yet. I ran into some problems with the block views, which I hope will be fixed soon. If that happens, I think that module will become one of the most powerful extensions to Drupal!

billybob4’s picture

Many thanks to all the people who have contributed to this. lifesavers :)

derjochenmeyer’s picture

Since its part of the solution to my own problem:

I also needed this hirachy to be displayed in paths and breadcrumbs.

Here is my amateur approach on how to use pathauto (version 5.x-2.x-dev as for 16th June 2007), custom breadcrumbs and token (dev version!!!!) for this task.

http://drupal.org/node/151739

I think that node relativity is a great module. It just needs exactly these features:

  • Custom relativity listings
  • path-, breadcrumb- and for some users even menu-creation.

I'll try it with a feature request.

----------------------
okay.cool