ok something tricky

7 posts by 2 authors in: Forums > CMS Builder
Last Post: November 30, 2012   (RSS)

Re: [kcmedia] ok something tricky

Hi Craig,

I think you need to have your layout something like this:

<div class="four-boxes clearfix">
<div class="box">
<?php
//count the number of images in box_1_icon so we can determine if we need the slides or slides1 class
$count = count($home_pageRecord['box_1_icon']); ?>
<ul class="<?php if ($count > 1): ?>slides<?php else: ?>slides1<?php endif ?>">
<?php
//loop through the images and display them in an li
for($i=0;$i < count($home_pageRecord['box_1_icon']); $i++): ?>
<li>
<div class="top">
<?php if($image = @$home_pageRecord['box_1_icon'][$i]): ?>
<img src="<?php echo $image['urlPath']; ?>" alt="" />
<span><?php echo $image['info1']; ?></span>
<?php endif; ?>
</div>
<?php if($image = @$home_pageRecord['box_1'][$i]): ?>
<div class="image">
<img src="<?php echo $image['urlPath']; ?>" alt="" />
</div>
<?php echo endif; ?>
</li>
<?php endfor; ?>
</ul>
</div>
</div>


This is just an example for the first box.

I've assumed that the layout of box_1 images and box_1_info are the same. So they have the same number of images in the same order, they are just different sizes.

It might be worth altering your section so that you just have one upload field called box_1, and that you have it generate a second thumbnail that is the same size as box_1_icon. Then you could use a foreach loop to pass through your images instead of a for loop.

Let me know if you have any questions.

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] ok something tricky

Hi Greg

thanks for that but it didnt work there is some kind of code error in or around the last endif ? i am not sure just dreamweaver is throwing an error
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [greg] ok something tricky

HI Greg

ok found the problem it is to early in the morning to start coding lol you have this

<?php echo endif; ?>

shouldnt have echo in there.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [greg] ok something tricky

Hi Greg

i have this working but i cant get the linking of the image working using the info2 field here is the code i have at the moment any idea why

<div class="box">
<?php
//count the number of images in box_1_icon so we can determine if we need the slides or slides1 class
$count = count($home_pageRecord['box_1_icon']); ?>
<ul class="<?php if ($count > 1): ?>slides<?php else: ?>slides1<?php endif ?>">
<?php
//loop through the images and display them in an li
for($i=0;$i < count($home_pageRecord['box_1_icon']); $i++): ?>
<li>
<div class="top">
<?php if($image = @$home_pageRecord['box_1_icon'][$i]): ?>
<img src="<?php echo $image['thumbUrlPath']; ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="<?php echo $image['info1']; ?>" />
<span><?php echo $image['info1']; ?></span>
<?php endif; ?>
</div>
<?php if($image = @$home_pageRecord['box_1'][$i]): ?>
<div class="image">
<a href="<?php echo htmlencode($upload['info2']) ?>"><img src="<?php echo $image['urlPath']; ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="<?php echo htmlencode($upload['info1']) ?>" /></a>
</div>
<?php endif; ?>
</li>
<?php endfor; ?>
</ul>
</div>
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [kcmedia] ok something tricky

Morning,

I think the problem is that all of your image data is being stored in the $image variable, but your currently calling a variable called $upload. I've edited the code to what I think it should be below:

<div class="box">
<?php
//count the number of images in box_1_icon so we can determine if we need the slides or slides1 class
$count = count($home_pageRecord['box_1_icon']); ?>
<ul class="<?php if ($count > 1): ?>slides<?php else: ?>slides1<?php endif ?>">
<?php
//loop through the images and display them in an li
for($i=0;$i < count($home_pageRecord['box_1_icon']); $i++): ?>
<li>
<div class="top">
<?php if($image = @$home_pageRecord['box_1_icon'][$i]): ?>
<img src="<?php echo $image['thumbUrlPath']; ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $image['height'] ?>" alt="<?php echo $image['info1']; ?>" />
<span><?php echo $image['info1']; ?></span>
<?php endif; ?>
</div>
<?php if($image = @$home_pageRecord['box_1'][$i]): ?>
<div class="image">
<a href="<?php echo htmlencode($image['info2']) ?>"><img src="<?php echo $image['urlPath']; ?>" width="<?php echo $image['width'] ?>" height="<?php echo $image['height'] ?>" alt="<?php echo htmlencode($image['info1']) ?>" /></a>
</div>
<?php endif; ?>
</li>
<?php endfor; ?>
</ul>
</div>


Thanks
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] ok something tricky

hi Greg

thanks for that works great.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz