I'm using the following function print theme_relativity_show_children($node); to display the children of several parents. It works great, but in parent overview page with a varying nr of children, the output can be very varying and messy. How can you limit the nr of displayed nodes for for example to 3 or 5 with a more attched on the line? I'm customizing my theme and looking for some code, which can be inserted. Any ideas?

It should look like this:

Parent 1:
- Child 1
- Child 2
- Child 3
- more...

And not like this:
Parent 2:
- Child 1
- Child 2
- Child 3
- Child 3
- Child 4
- Child 5
- Child 6
- Child 7
- Child 8
- Child 9
- Child 10
- Child 11
- Child 12

Comments

storbaek’s picture

I was looking in the code of the relativity module and found the following theme functions:

* - theme_relativity_show_parents($node, $fieldset=1)
* - theme_relativity_show_children($node, $fieldset=1)
* - theme_relativity_show_ancestors($node, $ancestors, $fieldset=1)
* - theme_relativity_show_link_operations($childrentypes, $parent)
*
* - theme_relativity_block_parents($node)
* - theme_relativity_block_children($node)
* - theme_relativity_block_ancestors($node, $ancestors)
* - theme_relativity_block_link_operations($node)
*
* - theme_relativity_ancestor($ancestor, $indent=0)
* - theme_relativity_link($title, $target, $parent_nid=0, $extra='')
* - theme_relativity_bullets($items)

I am not a programmer, but I would like to know if someone might help to explain how the different functions can be used? For instance, can the functions be used in custom block the divide the 'add node' and 'attach node'?!!

kirilius’s picture

I have the same problem as you. Typically a parent would have a large number of child nodes so dumping them all below the parent doesn't make any sense. There should be a easy way to configure a display of a limited number of child nodes plus a page for displaying them all.

A clean way to do this would be to use views:
- Define a view for displaying a node's child records.
- Tell it to create both block and page
- Tell the block to show only 3 (for example) nodes and a more link (it's a checkbox)
- Tell the page to show the full list of children the way you want them

There is a patch which can help you with that: http://drupal.org/node/130870 but I don't know whether it is going to be released any time soon. Plus I had problems configuring the above-described functionality with it.

There is a method that works but I don't like it very much since it requires some custom coding, which makes the upgrade not quite reliable:
http://drupal.org/node/151412

storbaek’s picture

Hi Kirilius

I see your point! It's great that we can use view module to help control the ONE<->MANY relationsship, but I hope the functionality will be added as an argument or similar to the theme_relativity_show_children function. It's just a little cumbersome to have to define and depend on an extra view and an extra block just for the sake of limiting the output. But it is definetly an alternative and I will give it a go when the patch is released with the next dev version. Thanks again for the suggestion!

storbaek’s picture

Hi Kiril

I'm trying to do what you are proposing, but I cannot see hot I'm supposted to do step 1 and 4:

1) Define a view for displaying a node's child records. HOW?!!!:
Do I add theme_relativity_show_children($node) under arguments in the view? If yes, then Done.

2) Tell it to create both block and page. Done.

3) Tell the block to show only 3 (for example) nodes and a more link (it's a checkbox). Done.

4) Tell the page to show the full list of children the way you want them. HOW?!!!

I have no clue how the last should be done. Currently, I have print theme_relativity_show_children($node); which outputs ALL children from the parent.

I look forward to hear your advice.

Dan

nainainai’s picture

i have similar problem. fews of my parents node have like almost 200 children and i wonder if i could add some kind of pager in it like 20 childs for a page

leokyle’s picture

you can control it from the views edition page, with some ugly changes at relativity.module.

changing line 1270 aprox (5.x-2.3)

return views_build_view('embed', $view, $view_args, 0, 0); 

to somthing like

  if ($view->nodes_per_page > 0)  //prevent  division by 0
     {
     // use pager configuration from the view 
     return views_build_view('embed', $view, $view_args, $view->use_pager, $view->nodes_per_page);
     }
  else{ // just go as usual if nodes_per_page is 0 or less
     return views_build_view('embed', $view, $view_args, 0, 0); 
	}

good luck