By bjste on
Hi there
I'm trying to style my nodes via. node-type.tpl.php.
I have used the print r function and get this:
[field_mainblogimage] => Array
(
[0] => Array
(
[fid] => 51
[list] => 1
[data] => Array
(
[description] =>
[alt] =>
[title] =>
)
[uid] => 1
[filename] => 83373914.jpg
[filepath] => sites/default/files/17/83373914.jpg
[filemime] => image/jpeg
[filesize] => 16916
[status] => 1
[timestamp] => 1274278782
[origname] => 83373914.jpg
[nid] => 17
[view] =>
)
)
I have tried allmost everything that I can think off, but still no result.
As I see it I should use the following code and that should work?:
<?php
if ($node->field_mainblogimage[0]['view']) { ?>
<?php print $node->field_mainblogimage[0]['view'] ?>
<?php } ?>
Could anyone give me a hint?
I really can't figure out what I keep doing wrong..
Comments
I think you want something
I think you want something like this:
Your "$node->field_mainblogimage[0]" is the array element holding a file reference, and this builds a download link to the image. To display that same image rather than link to it, try:
-Blake
www.BlakeSenftner.com www.3D-Avatar-Store.com
Thank you so much for your
Thank you so much for your help!
Your 2. solution was exactly what I had in mind - and it works nicely...
however.. could you perhaps explain for me:
how come that the other methods that number #2 and #3 described did not work?
All tutorials I find on the net tells the same... It does not make sense to me?
You can also look under the
You can also look under the Display fields tab for the content type. Make sure the field is included (not excluded) and you have picked a formatter in which case $node->field_mainblogimage[0]['view'] should work.
Thanks for your answers... I
Thanks for your answers...
I have checked the display property several times..
I have the following settings at the moment:
label: hidden
teaser: image
node: image
and ofcouse not checked any of the excludes
But I't still does not work... and I have no idea why... Caus all the explanations I find says the same as what I have done...
I guess I should try out #1's solution?
_
As can be seen right from your print_r dump,
$node->field_mainblogimage[0]['view']is empty so that's either what the php snippet is printing or why the 'if' is not firing it.As nevets said, check the display tab of the content type to make sure you're actually displaying something and that the image is where the field is looking for it and is accessible.
Hi there I'm still having
Hi there
I'm still having trouble with theming this type of node...
If I want to print the pictures title. Wouldn't it be:
print $node->field_mainblogimage[0]['title'];
Or... what do I do wrong?
The array from my print_r is as follows:
[field_blogimage1] => Array
(
[0] => Array
(
[fid] => 54
[list] => 1
[data] => Array
(
[title] =>
Fodbold
[alt] =>
)
[uid] => 1
[filename] => 82648720.jpg
[filepath] => sites/default/files/17/82648720.jpg
[filemime] => image/jpeg
[filesize] => 20048
[status] => 1
[timestamp] => 1274278848
[origname] => 82648720.jpg
[nid] => 17
[view] =>
)
[1] => Array
(
[fid] => 55
[list] => 1
[data] => Array
(
[title] =>
Fodboldbane
[alt] =>
)
[uid] => 1
[filename] => 82702414.jpg
[filepath] => sites/default/files/17/82702414.jpg
[filemime] => image/jpeg
[filesize] => 32258
[status] => 1
[timestamp] => 1274278868
[origname] => 82702414.jpg
[nid] => 17
[view] =>
)
)
You do see that the 'title'
You do see that the 'title' fields in your print_r() output are empty, right?
-Blake
www.BlakeSenftner.com www.3D-Avatar-Store.com
Actually - I didn't... It's
Actually - I didn't... It's the line after title I want to print out.. "Fodbold"
Hmm.. but how the hell should I be able to do that?
Perhaps it's easyer to make a new cck field for the title of the image...
Hmm...
But hey! Thanks for pointing it out! :)
Actually, upon looking at
Actually, upon looking at your print_r() output closer, it looks like your 'title' field is not empty, but contains "\nFodbold\n". Perhaps that's why you're not seeing your title, because you're CSS is expecting it to be a single line... ?
-Blake
www.BlakeSenftner.com www.3D-Avatar-Store.com
Thanks a lot for your help...
Thanks a lot for your help... I did find the solution. :)