Hi all - still trying to figure this one out anyone

Hi

i am using the code to display an image - is there a way to display all rather than a new line for all (note 0,1,2,3,4,5) also for IE how can i display a null.


<div class="newssm">
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [0]['filepath']); ?></a>
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [1]['filepath']); ?></a>
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [2]['filepath']); ?></a>
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [3]['filepath']); ?></a>
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [4]['filepath']); ?></a>
</div>

Comments

qasimzee’s picture

You can always use a foreach as an alternative to the lines written above

--
Qasim Zeeshan
http://qasimzeeshan.com

jimmyg164’s picture

Hi

do you have a code example

much appreciated

qasimzee’s picture

Here is a rough example, I haven't executed it.

<div class="newssm">
<?php
for ($i = 0; $i < length($field_album); $i++) { 
?>
  <a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [$i]['filepath']); ?></a>
<?php
}
?>
</div>

--
Qasim Zeeshan
http://qasimzeeshan.com

sign’s picture

I would use l function to generate the link tho

<div class="newssm">
<?php
for ($i = 0; $i < length($field_album); $i++) {
  print l(theme('imagecache', 'smallnews', $field_album[$i]['filepath']), $node_url, array('html' => TRUE));
}
?>
</div>
qasimzee’s picture

Nice addition.

Thanks

--
Qasim Zeeshan
http://qasimzeeshan.com

jimmyg164’s picture

Hi Thanks for the replies from both of you

i get the following error

Parse error: syntax error, unexpected '}' in /hsphere/local/home/jimmyg164/car99.net/sites/all/themes/inverness/node/node-news.tpl.php on line 129

kind regards
jimmy

sign’s picture

can't see any problem with the code above, you might want to paste your whole .tpl.php file on drupalbin.com and share it with us

jimmyg164’s picture

<?php if ($node->teaser) { ?>
<div class="clear"></div>


<?php if ($title): ?>
	<div class="pagetitle"><a href="<?php print $node_url?>"><?php print $title ?></a></div>
<?php endif ?>

<?php if ($field_image): ?>

<div class="newsphoto">
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'newsthumb', $field_image [0]['filepath']); ?></a>
</div>
	<?php endif ?>

<?php if ($content):?>
	<div class="bodytext"><?php print $node->content['body']['#value']; ?></div>
<?php endif ?>

<div class="clear"></div>

<div class="author">
	By <?php print l($node->name, "news/user/$node->uid");?> on <?php print format_date($node->created, 'custom', 'l F j'); ?>
</div>

<?php if ($field_album): ?>

<div class="newssm">
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [0]['filepath']); ?></a>
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [1]['filepath']); ?></a>
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [2]['filepath']); ?></a>
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [3]['filepath']); ?></a>
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [4]['filepath']); ?></a>
</div>
	<?php endif ?>
<div class="clear"></div>

<ul class="shareit">
	<li><a href="<?php print $node_url?>"><img src="/sites/all/themes/inverness/images/rss_file_info_16.png"/>Read More</a></li>
	<li><a href="#"><img src="/sites/all/themes/inverness/images/feed_source_16.png"/>Source</a></li>
	<li><img src="/sites/all/themes/inverness/images/post_to_blog_16.png"/><?php print format_plural($comment_count, 'Comments (1)', 'Comments (@count)'); ?></li>
	<li><?php if (node_access('update', $node)): ?>
		<div class="links"><?php print l('(Edit)', 'node/' . $nid . '/edit'); ?> | <?php print l('(Delete)', 'node/' . $nid . '/delete'); ?></div>
		<?php endif; ?></li>
</ul>



<?php if ( !$page && ($id == 3 || $id == 5)) : ?>
<div class="ads468">
<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxx";
/* 468x60, created 24/06/09 */
google_ad_slot = "1448855671";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<?php endif; ?>
<!-- ***********************************************full page view************************************** -->
<?php } else { ?>

<?php if ($title): ?>
	<div class="pagetitle"><h1><a href="<?php print $node_url?>"><?php print $title ?></a></h1></div>
<?php endif ?>



<?php if ($field_image): ?>

<div class="newsphoto">
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'news_main', $field_image [0]['filepath']); ?></a>
</div>
	<?php endif ?>
	
	<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxx";
/* main news links */
google_ad_slot = "0101295744";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

<?php if ($content):?>
	<div class="bodytextw"><?php print $node->content['body']['#value']; ?></div>
<?php endif ?>

<div class="clear"></div>

<?php if ($field_album): ?>

<div class="newssm">
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [0]['filepath']); ?></a>
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [1]['filepath']); ?></a>
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [2]['filepath']); ?></a>
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [3]['filepath']); ?></a>
		<a href="<?php print $node_url?>"><?php print theme('imagecache', 'smallnews', $field_album [4]['filepath']); ?></a>
</div>
	<?php endif ?>
<div class="clear"></div>
<ul class="shareit">
	<li><a href="#"><img src="/sites/all/themes/inverness/images/feed_source_16.png"/>Source</a></li>
	<li><img src="/sites/all/themes/inverness/images/post_to_blog_16.png"/><?php print format_plural($comment_count, 'Comments (1)', 'Comments (@count)'); ?></li>
	<li><?php if (node_access('update', $node)): ?>
		<div class="links"><?php print l('(Edit)', 'node/' . $nid . '/edit'); ?> | <?php print l('(Delete)', 'node/' . $nid . '/delete'); ?></div>
		<?php endif; ?></li>
</ul>
<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxx";
/* main news links */
google_ad_slot = "0101295744";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<?php } ?>

kbeck303’s picture

I am currently using this code in my page.tpl.php

<?php print t($node->field_restaurant_images[0]['view']); ?>
<?php print t($node->field_restaurant_images[1]['view']); ?>
<?php print t($node->field_restaurant_images[2]['view']); ?>
<?php print t($node->field_restaurant_images[3]['view']); ?>

I have 2 imagecache formet setup - "large" and "thumubnail"

I would like the first image to use the "large" format. And the remaining 3 images to use the "thumbnail" format.

How would I incorporate the imagecache format into the above code?

kbeck303’s picture

<?php 
  $item = $node->field_my_image_field_name[0];
  $item['lightbox_preset'] = 'my_custom_preset_name';
  print theme('imagefield_image_imagecache_lightbox2', 'my_custom_preset_name', 'field_my_image_field_name', $item, $node, $rel = 'lightbox[bilder]'); 
?>

I found the answer here: http://drupal.org/node/274487