<?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'];
我認爲這是完全合理的感謝!我實際上使用面板(3)來顯示cck節點。我可以在可見性規則中過濾PHP代碼,這是我將它放置的位置(而不是創建和編輯模板)。我對如何獲得$ some_nid有點困惑......顯然它取決於cck節點會有所不同。如果我調用node_load()它會加載當前節點嗎? – user379468 2011-02-12 22:49:00