Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

tpl issue with getting an image to show

Posted on 2011-03-19
2
Medium Priority
?
410 Views
Last Modified: 2012-05-11
The code in question is in <!--item-pic-->  I pull in the subcat field (body) from the db and I have added an image field called field_imagesc and I am trying to get it to display but I get a blank output (seen here: http://tinyurl.com/6lxhxww).

<?php
$acount = count($node->field_subcats);
if($acount == 1){
     drupal_goto('node/'.$node->field_subcats[0]['nid'], NULL, NULL, NULL);
 } else {

 ?>

<div class="subcat-content">
    <div class="subcat-left">
        <h1><?php print $node->title ?></h1>
        <?php if(!empty($node->field_subcats['0']['view'])): ?>
        <div class="item-category">
            <ul>            
            	<?php foreach($node->field_subcats as $sub): ?>
                <?php $cat = node_load($sub['nid']); ?>
                <li><a href="<?php print url('node/'.$cat->nid) ?>" id="#subcat-<?php print $cat->nid ?>"><?php print $cat->title ?></a></li>
                <?php endforeach ?>
            </ul>
        </div><!--/item-category-->
        <?php endif ?>
        <?php if(!empty($node->field_subcats['0']['view'])): $i=0; ?>
		<?php foreach($node->field_subcats as $sub): ?>
		<?php $cat = node_load($sub['nid']); ?>
			<div class="item-pic-<?php print $cat->nid ?>" class="item-details <?php if($i==0) print 'active' ?>">
				<?php print $cat->field_imagesc[0]['view'] ?>
			</div><!--/item-pic-->
		<?php $i++; endforeach ?>
		<?php endif ?>
	</div><!--/subcat-left-->
	<?php if(!empty($node->field_subcats['0']['view'])): $i=0; ?>
    <?php foreach($node->field_subcats as $sub): ?>
    <?php $cat = node_load($sub['nid']); ?>
    <div id="subcat-<?php print $cat->nid ?>" class="subcat-details <?php if($i==0) print 'active' ?>">
        <h5><a href="<?php print url('node/'.$cat->nid) ?>"><?php print $cat->title ?></a> </h5>
        <?php print $cat->body ?>
       <!-- <p><a href="<?php //print url('node/'.$cat->nid) ?>">View Available Inventory.</a></p>-->
    </div><!--/subcat-details-->
    <?php $i++; endforeach ?>
    <?php endif ?>
</div><!--/subcat-content-->
<?php } ?>

Open in new window


Any thoughts?
0
Comment
Question by:iceman19330
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
junipllc earned 2000 total points
ID: 35172481
What are your display settings for that particular field (as specified in the content type definition, near Manage Fields -- Display Fields, I think it's called)? If you have them set as hidden, the "view" variable may not work.

Typically, I do something like this:

<img src="<?php print $cat->field_imagesc[0]['filepath'] ?>" alt="alt text here" />

Open in new window


or if I need to imagecache it, I use something like this:

$image_alt_text = "ALT TEXT HERE";
$field_imagesc_path = $node->field_imagesc['0']['filepath'];
$field_imagesc_code = theme('imagecache', 'PRESET_NAME', $field_imagesc_path, $image_alt_text, $image_alt_text);
echo $field_imagesc_code;

Open in new window


It looks like nothing is being output at all, but you are getting the node data (e.g. the item pic number). Do you have the development module installed? If you do, you could easily look at the data structure of the node to see how it's being populated by doing a drupal set message on the $cat... which in shorthand is this:

dsm($cat);

...place that right around where you want the picture to be displayed, then reload the page twice. If devel is installed then you should have a nice formatted clickable data structure show up in your messages area. That way you can be sure you have the exact variable you need.

I hope this helps!

Mike
0
 

Author Comment

by:iceman19330
ID: 35172838
Awesome used the img code provided and that worked.  Did tweak the Display fields, but it wasnt set to hidden, it also wasnt set as an image.
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question