[Solved] Drupal 7: Programatically creating a 'page' node

Hey Guys ... I figured it out how to do that!
(but still only one problem)
Using Firebug (Mozilla Firefox plugin), i managed to figure out the name of the elements and then fill it with the proper values.
Creating a 'page' node programmatically, in Drupal 7, is done using the following code:

<?php
global $user;

$customNode = new stdClass();

$customNode->type = 'page';
node_object_prepare($customNode);
$customNode->uid = $user->uid;
$customNode->name = $user->name;

$customNode->title = 'Your page title';
$customNode->language = 'en';
$customNode->body[$customNode->language][0]['value'] = 'Your value';
$customNode->body[$customNode->language][0]['summary'] = 'Your summary';
$customNode->body[$customNode->language][0]['format'] = 'filtered_html';

$customNode->menu['enabled'] = 1; // 1 to enable providing a link in main menu
$customNode->menu['link_title'] = 'Your page link title';
$customNode->menu['description'] = 'Your page description';
$customNode->menu['parent'] = 'main-menu:0';
$customNode->menu['weight'] = 5;

$customNode->path['alias'] = 'Your Alias';
$customNode->comment = 1;

$customNode->status = 1; // 1 means published
$customNode->promote = 0;
$customNode->revision = 0;

$customNode->changed = $_SERVER['REQUEST_TIME'];
$customNode->created = $_SERVER['REQUEST_TIME'];

node_submit($customNode);

How to access to view_mode variable from node in html.tpl.php or page.tpl.php?

How do I access to $view_mode in html.tpl.php or page.tpl.php? The $view_mode variable is only accesible in node.tpl.php. I need in html.tpl.php or page.tpl.php! I try with global $view_mode but not work...

I need to add some variable to javascript in html.tpl.php when $view_mode is FULL!

I have Drupal 7!

Thanks!

Out of memory when trying to load modules

Hi, Ive been experimenting with drupal for a while now but have come across a problem:
When trying to activate modules I get an error message saying 'out of memory, tried to allocate x amount of memory y amount missing'
Can anyone tell me what is going on and possibly how to get around it?
Thanks.

manipulate User Registration

Hi Guys,
i just started dev Plugins with Drupal and try several things. Now i wonder how i can manipulate the Userregsitration or -activation. I just want to add a DB-Insert, when a new User register. Hope somebody can help me!

THX

maxlength-js custom using

hi everyone,
i have installed maxlength-js drupal7 module on my site,
it work fine for counting the body characters in js,
but my problem is how can i apply this module for the summary field,
actually i want count and limitation property on the summay/teaser fields
please guide me i am totally new to drupal,

Suspicious File... filemanager.config.php

Hi folks,
I have ConfigServer Security and Firewall running on my Dedicated box, and I'm having a problem with the latest ckeditor in my Drupal 7.x installs.

ConfigServer does not like the filemanager.config.php file that comes in this latest version It keeps flagging it as a suspicious file.
I know I can tell server security to ignore it but can anyone give me some insight as to why this file is a risk?

Pages

Subscribe with RSS Subscribe to RSS - Drupal 7.x