I'm using CCK + CCK image field module right now and I pretty happy with its features.
But, I want to customize my theme and have content available where I want it.
example:
my CCK content type is called: CARTOON and it contains 3 fields
so
CARTOON
- title (text field)
- cartoon_image (image field)
- cartoon_text (text field)
Wow, my content is uploaded at once with all these 3 fields filled out, SO I have a title, an image, and a text below the image. Now the problem is, I want to get somehow the value of this cartoon_image field, so that I can use it no matter where in my template.
does anyone know how to get this value?
Comments
theme CCK
Info about theming CCK nodes here:
Creating a template
http://drupal.org/node/62468
To quote from that page...
"A logical question at this point is how do you know what fields are available to use. Here is a tip that will help you design your theme. Add the following code to the very end of the template:"
<code><?php print_r($node); ?>
This will print to the page all available variables from your CCK type.
Mark
thanks, I know how to print
thanks,
I know how to print all those variables, but my question is: how to read these?
[field_colum_cartoonimage] => Array
(
[0] => Array
(
[fid] => 21
[title] =>
[alt] =>
[nid] => 33
[filename] => BOrattenvergif.jpg
[filepath] => files/BOrattenvergif.jpg
-> I need this filename variable...
I already tried several things, but can't get that value...
I need the exact syntax and that's what I don't havE..
Pakfriet.be
Try something like
Try something like
<?php print $node->field_colum_cartoonimage[0]['filename']; ?>
.I'll try this out later
I'll try this out later tonight and will get back to you, thanks already!
Pakfriet.be
unfortunately, this doesn't
unfortunately, this doesn't print anything :(
Pakfriet.be
Try what mark suggested,
and use
<?php print_r($node); ?>
. This will give you a list of variables. Then use the format I gave you to print the values you are after. Maybe try<?php print $node->field_colum_cartoonimage[0]['value']) ?>
. You might find the variable is called something slightly different to the example you gave me - perhaps "colum" is spelt "column"?From the example page
What about:
<?php print $field_colum_cartoonimage['view'] ?>
or
<?php print $field_colum_cartoonimage['value'] ?>
or if you have multiple $field_colum_cartoonimage:
view and value
Looking at this post (I don't have an answer for the question sorry) I started wondering, what is the difference between array['view'] and array['value'] ? These aren't php terms are they? This is drupal specific meaning.
array['view'] vs. array['value']
array['view'] is filtered and safe to display.
array['value'] is raw and could contain code. You probably don't want to display this.
To anyone else browsing this thread...
Since I stubbled across this thread when looking for the variable I wanted, I thought I might as well post here after finding it.
The code below worked for me for calling a field I have given the name of "section".
<?php print $node->field_section[0]['value'] ?>
~ Dave
You're not just another Dave
YOu're THE Dave, thanks for that post
Can you do something like this...
...also in blocks?
I need to display the CCK-field-data of a book-coverpage in a block on all its subpages. I posted this here: http://drupal.org/node/260594
Any idea how to do this?
Thanx buddy
It does work i believe its combination of object at top level and then array below.
FileField
Can anybody tell me how to do this with a filefield?
thanks
j
Answer
This will do it:
$node->field_pdf[0]['filepath']
This works like charm
Thanks a lot anotherdave for posting your find. It works.
thank you i tried same its working but...
hi,
thank you i tried same its working but...its displaying all my content including images,text,link together. where can i get those variables individually?
Thank you Dave
How can i Fetch path from this value
Hello,
I am using webform to create a page.it contains a field Image path (Type = File)
When i attach a file(ex: homepage-banner.jpg) and submit it
in the data base value which is stored is:
a:5:{s:8:"filename";s:19:"homepage-banner.jpg";s:8:"filepath";s:40:"files/webform/upload/homepage-banner.jpg";s:8:"filemime";s:10:"image/jpeg";s:8:"filesize";i:48792;s:6:"source";s:5:"image";} Banner
How Can Fetch path From This.
Please Help Me.
How to print more drupal node variables
I got here looking for a way to print a drupal node variable but I cant seem to get it right. Maybe you guys can give me a hand.
When doing print_r ( $node->content[field_fechanacimiento] )
I get this:
Array ( [#type_name] => autor [#context] => full [#field_name] => field_fechanacimiento [#post_render] => ... etc etc
How can I print the field_name?? I get confused by the "#" sign.
Greetings
you do need to use the # sign
you do need to use the # sign i prefer using the devel (http://drupal.org/project/devel) module to get the variables, you can use dev load tab to find out a particular element.
Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form
Sorry if this question comes
Sorry if this question comes across as stupid to anyone .. but I wanted to know where I can find a comprehensive list of the attributes that a field may take. By attribute I mean for the field named section $node->field_section[0]['value'] .. has ['value'] as its attribute and this can be changed to ['view']. Similarly what are the other attributes can be used. I tried searching the API but couldn't find what I was looking for. Thanks for your help
subscribing...
...saurabh.bhambry's request.