我有一个cck节点类型,其中包含节点库类型的节点引用。因为我不想为我所拥有的CCK节点创建一个新的画廊,所以我想做的就是休息。在显示cck节点的页面中;
如果给定节点存在库引用,则显示指向该库的链接。如果没有图库,我想显示一个链接“添加图库”,理想情况下,这将以编程方式创建一个新的图库节点和参考。我还想自动填充标题以及作者信息(不允许用户访问此标题)。我查看了整个drupal.org,试图找到信息,但无法弄明白。
由于
答案 0 :(得分:0)
<?php
$node_A = node_load($some_nid);
if(empty($node_A->field_type_gallery_node_ref[]['nid'] )// imp point this field is an array
{
//link to add gallery page
//call a function for creating a node of gallery and return the nide and you can pass //parameters like nid of A etc..then return the new node from the function
$node_GALLERY = get_gallery_node_new($node_A->nid);
$node_type_A->field_type_GALLERY_node_ref[]['nid'] = $node_GALLERY;
}
else
{
//display this gallery
}
?>
获取当前节点的nid:
<?php
if (arg(0) == 'node' && is_numeric(arg(1)))
$nodeid = arg(1);
?>
或使用CCK A的任何字段值(您知道)并应用节点表的连接
$nid_ref_query ='SELECT nid FROM `content_type_A` cto join node n on cto.nid=n.nid where cto.field_some_field_you_know =' . $something;
$nid_array = db_fetch_array(db_query($nid_ref_query));
$nid = $nid_array['nid'];