开发者

Drupal 7 - how do I insert content programmatically in a theme's template with a php function?

I just started working with drupal 7 a week ago, and I have figured out the basics (and the huge differences between drupal 6 vs. 7)

Now, while creating a theme from an html layout the the designer gave me, i have created a few regions, the main menu loads at the top, the content right below etc..

now, at some of the nodes - i need to insert some more dynamic data (e.g. a few divs in different places, each is getting different page content that is开发者_JS百科 created as a page in the CMS backend)

i would really like to know , how can I programmatically add pages and\or any other content (text, image..etc..) created in the cms backend, to my theme's node.

I mean, i have tried to look on google, tried to copy portion of code from the drupal themes which came with the installation etc.. nothing works properly.

pseudo code to what i mean (in case i did not explain my self that good):

load_function('content type' , 'content name')

and use that for an example like this:

load_function('page' , 'about-us');

which will load the about-us content right into where i embed the php code in.

just to remind - i am talking about Drupal 7.

any help will be so much appreciated :)

thank you!


// Create node object.
$node = new StdClass();
$node->type = 'image';
$node->language = LANGUAGE_NONE;
node_object_prepare($node);

$node->title = $filepath;    

$node->body[$node->language][0]['value']   = $body_text;
$node->body[$node->language][0]['summary'] = text_summary($body_text);

node_save($node);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜