I use the amazon-module to display some books on my site. For that, I inserted the amazon field to a content type. I already changed the ‘amazon-item.tpl.php’ file so that some addition information from the amazon api is shown. That works fine.

I am now looking for a solution to the following:
I want to show the content of a CCK field (already in the used content type) together with the data of the amazon api. For example

Amazon: $title
Amazon: $creator
CCK: $node->field_own_description[0][‘view’]
Amazon: $numberofpages

And I am not able to do that so far.
1) If I enable that CCK field to be shown in the node body (admin/content/node-type/shop/display), it is below the amazon data. I want it to be shown between the amazon data (see above)
2) If I insert <?php print $node->field_own_description[0][‘view’] ?> directly to amazon-item.tpl.php, than no data is show for that field

Any idea how this can be done?

Comments

rfay’s picture

I've never tried to do this. Anybody have a technique?

The key thing to do is to use a debugger or devel module's dsm() function to explore the variables available to you.

fragtom’s picture

Hello DrupSpa,

if you would like to come to result i a fast way, you could do that in the following way.. I expect, that you are showing the node in page mode, then you are able to get the node-id via argument. Use the following in the amazon-item.tpl.php

// get node-id from internal path http://yoursite/node/4711
$nid = arg(1);
$node = node_load($nid);
$node = node_build_content($node);

After loading the node_build_content() you're able to access the cck-fields..

DrupSpa’s picture

@ #2
Thanks. That worked.

rfay’s picture

Title: Insert content from a cck field between the amazon data » Accessing full cck field information from the node level when theming
Status: Active » Fixed

Nice work, @fragtom!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.