List Info

Thread: Proper way to programmatically modifying a CCK node's nodereference field in 4.7




Proper way to programmatically modifying a CCK node's nodereference field in 4.7
user name
2006-09-20 00:03:31
I want to programmatically add related blog postings
references to a CCK 
node's nodereference field called field_related_blog_posts.
Would 
something like this be the proper way to do this in 4.7? I
know the fapi 
pull in 5.0 would help with this.

$node = node_load(5);
$node->field_related_blog_posts[] = array('nid' =>
$blog_nid, 'view' => 
'<a>..</a>');
node_save($node);

-- 

Rob Roy Barreca
Founder and COO
Electronic Insight Corporation
http://www.electroni
cinsight.com
robelectronicinsight.com

Proper way to programmatically modifying a CCK node's nodereference field in 4.7
user name
2006-09-21 18:27:54
Can anyone with some CCK knowledge point me in the right
direction with 
this? Just trying to manually add node's to a CCK
nodereference field.

Thanks!

Rob Roy Barreca
Founder and COO
Electronic Insight Corporation
http://www.electroni
cinsight.com
robelectronicinsight.com



Rob Barreca wrote:
> I want to programmatically add related blog postings
references to a 
> CCK node's nodereference field called
field_related_blog_posts. Would 
> something like this be the proper way to do this in
4.7? I know the 
> fapi pull in 5.0 would help with this.
>
> $node = node_load(5);
> $node->field_related_blog_posts[] = array('nid'
=> $blog_nid, 'view' 
> => '<a>..</a>');
> node_save($node);
>
Proper way to programmatically modifying a CCK node's nodereference field in 4.7
user name
2006-09-28 00:07:21
Thanks to some help from dopry on IRC I've got a little
handle on the 
CCK API. To programmatically add references to a CCK
nodereference 
field, I'm doing something like below although it probably
needs a 
little smoothing.

  $field = content_fields('field_related_blog_posts',
'content_initiative');
  if (is_array($project_nids)) {
    foreach($project_nids as $nid => $title) {
      $node = node_load($nid);
      $additions = content_field('load', $node, $field, 
$node->field_related_blog_posts, NULL, NULL);
     
      $already_exists = FALSE;
      foreach($additions['field_related_blog_posts'] as
$delta => $array) {
        if ($array['nid'] == $blog_nid) {
          $already_exists = TRUE;
          break;
        }
      }
      if (!$already_exists) {
        $additions['field_related_blog_posts'][] =
array('nid' => 
$blog_nid);
      }
      content_field('update', $node, $field, 
$additions['field_related_blog_posts'], NULL, NULL);
    }
  }

Of course the keys are:
  $additions = content_field('load', $node, $field, 
$node->field_related_blog_posts, NULL, NULL);
  content_field('update', $node, $field, 
$additions['field_related_blog_posts'], NULL, NULL);

Rob Roy Barreca
Founder and COO
Electronic Insight Corporation
http://www.electroni
cinsight.com
robelectronicinsight.com



Rob Barreca wrote:
> Can anyone with some CCK knowledge point me in the
right direction 
> with this? Just trying to manually add node's to a CCK
nodereference 
> field.
>
> Thanks!
>
> Rob Roy Barreca
> Founder and COO
> Electronic Insight Corporation
> http://www.electroni
cinsight.com
> robelectronicinsight.com
>
>
>
> Rob Barreca wrote:
>> I want to programmatically add related blog
postings references to a 
>> CCK node's nodereference field called
field_related_blog_posts. Would 
>> something like this be the proper way to do this in
4.7? I know the 
>> fapi pull in 5.0 would help with this.
>>
>> $node = node_load(5);
>> $node->field_related_blog_posts[] = array('nid'
=> $blog_nid, 'view' 
>> => '<a>..</a>');
>> node_save($node);
>>
>
>
off-topic question regarding menu presentation style
user name
2006-09-28 00:52:41
Hi, 
I know this is an off-topic question but the development
contributors can
best answer this since it involves a bit of coding activity.


I wanted to utilize the menu style as at the bottom section
(before footer)
of http://www.skype.com.
What I want to do is present the menus as presented
on skype but how will I present them through code so that
they show up in
columns and are balanced across the website page layout?

Regards
-----------------------
Fouad 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.9/456 - Release
Date: 9/25/2006
 

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )