Solved

tpl issue with getting an image to show

Posted on 2011-03-19
2
408 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 500 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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

RTL (right to left) web applications aiming for audiences speaking languages like Hebrew or Arabic, are generally more complicated than the same applications aiming for audiences speaking Latin based languages. The main difference lies of course …
A big percent of today’s marketing activity is performed through the online environment. The marketing strategies that have existed a decade ago no longer relate to what’s happening today. We’re currently facing a revolutionary era, called the digit…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 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