Closed (fixed)
Project:
Node Family
Version:
master
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Oct 2006 at 10:27 UTC
Updated:
20 Oct 2006 at 17:00 UTC
At the moment, I'm using the following code in a tpl.php file:
<?php
if ($children[1]) {;
print "<fieldset class=' collapsible collapsed' style='background-color:#FFFFF2 '><legend><b>Personal Profile</b></legend>";
print node_view($children[1]);
print "</fieldset>";
} elseif ($user->uid == $node->uid) {
print "<fieldset class=' collapsible collapsed' style='background-color:#FFFFF2 '><legend><b>Personal Profile</b></legend>";
print "<div align='right'><font size='-2'><a href='/my_profile/personal_details?destination=user'>Create your Personal Profile</a></font></div>";
print "</fieldset>";
}
?>
...
<?php
if ($children[0]) {
print "<fieldset class=' collapsible collapsed' style='background-color:#FFFFF2 '><legend><b>Contact Profile</b></legend>";
print node_view($children[0]);
print "</fieldset>";
} elseif ($user->uid == $node->uid) {
print "<fieldset class=' collapsible collapsed' style='background-color:#FFFFF2 '><legend><b>Contact Profile</b></legend>";
print "<div align='right'><font size='-2'><a href='/my_profile/contact_details?destination=user'>Create your Contact Profile</a></font></div>";
print "</fieldset>";
}
?>
The problem that I've just come to realise (ahem!) is that child 0 is not always the users Contact Profile and child 1 is not always the Personal Profile because it depends on the order in which they were created. Is it possible to write code to determine what child 0 is so that in the legend, I can write the appropriate heading?
Regards
Patrick
Comments
Comment #1
fagoyeah, you can use nodefamily_relation_load_by_type($nid) instead.
e.g.
Comment #2
Patrick Nelson commentedSorry for being a thicko, but what goes in
'your_content_type'? I've tried putting in the name of the content type (it's a CCK), e.g.,content_profilebut that doesn't seem to work. Or am I missing something?Regards
Patrick
Comment #3
fagoyep, that looks right and should work so - of course as long as there is a child node of this type.
Have a look at the output of "print_r($children);" to see how the array is built.
Comment #4
Patrick Nelson commentedfago,
It's OK - there was a slight typo in the code above, it should read:
(no closing bracket after 'your_content_type'] on the foreach line)
Thanks for all your help - works a treat now.
Regards
Patrick
Comment #5
fagoah yes, great that it works now.
Comment #6
(not verified) commented