Drupal 添加“添加新”使用 PHP 代码链接

发布于 2024-10-16 21:44:12 字数 240 浏览 7 评论 0原文

我有一个 cck 节点类型,其中包含对节点库类型的节点引用。由于我不想为我拥有的所有 CCK 节点实际创建一个新画廊,因此我想做以下操作。在显示cck节点的页面中;

如果给定节点存在图库引用,则显示该图库的链接。如果不存在画廊,我想显示一个链接“添加画廊”,理想情况下,这将以编程方式创建一个新的画廊节点和引用。我还想自动填充标题以及作者信息(而不授予用户访问权限)。我浏览了 drupal.org 试图找到信息,但无法弄清楚。

谢谢

I have a cck node type that contains a node reference to node gallery type. Since I don't want to actually create a new gallery for ever CCK node I have, I would like to do the fallowing. in the page that displays the cck node;

if the gallery reference exists for the given node, display a link to that gallery. If no gallery exists, I would like to display a link "add gallery", ideally, this would programatically create a new gallery node and reference. I would also like to automatically populate the title, as well as the author information (without giving the user access to this). I looked all over drupal.org to try and find the info but can't figure it out.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

踏月而来 2024-10-23 21:44:12
 <?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'];
 <?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
    }
    ?>

to get current node's nid :

<?php
if (arg(0) == 'node' && is_numeric(arg(1))) 

$nodeid = arg(1);

?>

or using any field value of CCK A (that you know) and applying a join with node table

$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'];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文