For example, if a project node , you can create a node picture, with a field nodereference point to a particular project. Nodereference_url can automatically add a link to the node project leading to the creation of a picture node.
This may be convenient. Thus we have node photo , node level , node news, node registration, etc, each with a project targeting nodereference field. And in the project node, it automatically links that allow children to create these nodes.
automatic nodes are arranged in alphabetical order. What if I want another order?. Furthermore, what if we want to show the link just in some circumstances and not others?.
nodereference_url_create_link
The module contains the function nodereference_url nodereference_url_create_link ($ node, $ field_name, $ type_name, $ attributes), where:
- $ node is the node that contains the links
- $ field_name is the name of nodereference field pointing to parent (eg field_foto_proyecto )
- $ type_name is the name of the type (eg photo)
- $ attributes, optionally, lets you assign attributes to the link.
can be used in the template of the node that contains the links. For example, in node-proyecto.tpl.php :
... \u0026lt;div
class="nodereference_url_links">
\u0026lt;ul class="links">
\u0026lt;?
php if (! In_array ('manager', array_values \u200b\u200b($ user-> roles))) {
if ($ nid = misc_get_inscripcion_en_proyecto ($ node-> nid)) {echo
'\u0026lt;li>.' l (t ('You are enrolled in this project'), 'node /'. $ nid). '\u0026lt; / li> ';
} else {$ field_name = 'field_inscripcion_proyecto';
$ type_name = 'inscripcion';
$ attributes = array ();
echo '\u0026lt;li>. Nodereference_url_create_link ($ node, $ field_name, $ type_name, $ attributes ).'\u0026lt;/ li> ';}
} echo' \u0026lt;li>. nodereference_url_create_link ($ node, 'field_foto_proyecto', 'photo').'\u0026lt;/ li>';
echo '\u0026lt; li>. nodereference_url_create_link ($ node, 'field_plano_proyecto', 'plano').'\u0026lt;/ li>';
echo '\u0026lt;li>'. Nodereference_url_create_link ($ node, 'field_noticia_proyecto', 'news').'\u0026lt;/ li>';
?>
\u0026lt;/ ul>
\u0026lt;/ div>
\u0026lt; ;? php print $ links;?>
...
In this example, the registration link Create shown only if you have not created an entry before. Misc_get_inscripcion_en_proyecto (), defined in the misc module returns the node type registration is created by the user for this project, or FALSE otherwise.
0 comments:
Post a Comment