ok something tricky

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

By KCMedia - November 27, 2012

Hi all

ok i have this piece of code below and i have a single section with all the fields in it.

this is the code i have as you can see there are 4 boxes and inside each box there are 2 images and 1 text field.

I need to make it so that when there are more than 1 set of images per box it will slide which is what i can do with normal code but cant get it to work with cmsb

current code that works

<div class="four-boxes clearfix">
<div class="box">
<ul class="<?php if ($home_pageRecord['box_1_on'] == "1"): ?>slides<?php endif ?><?php if ($home_pageRecord['box_1_on'] == "0"): ?>slides1<?php endif ?>">
<li>
<div class="top">
<img src="img/four-boxes/icon-01.png" alt="" />
<span>technology</span>
</div>
<div class="image">
<img src="img/four-boxes/01.jpg" alt="" />
</div>
</li>
</ul>
</div>
<div class="box">
<ul class="<?php if ($home_pageRecord['box_2_on'] == "1"): ?>slides<?php endif ?><?php if ($home_pageRecord['box_2_on'] == "0"): ?>slides1<?php endif ?>">
<li>
<div class="top">
<img src="img/four-boxes/icon-02.png" alt="" />
<span>FREIGHT FORWARDERS &amp; CUSTOM BROKERS</span>
</div>
<div class="image">
<img src="img/four-boxes/02.jpg" alt="" />
</div>
</li>
</ul>
</div>
<div class="box">
<ul class="<?php if ($home_pageRecord['box_3_on'] == "1"): ?>slides<?php endif ?><?php if ($home_pageRecord['box_3_on'] == "0"): ?>slides1<?php endif ?>">
<li>
<div class="top">
<img src="img/four-boxes/icon-03.png" alt="" />
<span>TRAFFIC</span>
</div>
<div class="image">
<img src="img/four-boxes/03.jpg" alt="" />
</div>
</li>
</ul>
</div>
<div class="box">
<ul class="<?php if ($home_pageRecord['box_4_on'] == "1"): ?>slides<?php endif ?><?php if ($home_pageRecord['box_4_on'] == "0"): ?>slides1<?php endif ?>">
<li>
<div class="top">
<img src="img/four-boxes/icon-04.png" alt="" />
<span>MERRY CHRISTMAS</span>
</div>
<div class="image">
<img src="img/four-boxes/04.jpg" alt="" />
</div>
</li>
<li>
<div class="top">
<img src="img/four-boxes/icon-03.png" alt="" />
<span>TRAFFIC</span>
</div>
<div class="image">
<img src="img/four-boxes/03.jpg" alt="" />
</div>
</li>
</ul>
</div>
</div><!-- /four-boxes -->

and here is the code from cmsb code gen.

<!-- STEP2: Display Record (Paste this where you want your record to appear) -->
<h1>Home page - Detail Page Viewer</h1>
Record Number: <?php echo htmlencode($home_pageRecord['num']) ?><br/>
Box 1 On (value): <?php echo $home_pageRecord['box_1_on'] ?><br/>
Box 1 On (text): <?php echo $home_pageRecord['box_1_on:text'] ?><br/>
Box 2 On (value): <?php echo $home_pageRecord['box_2_on'] ?><br/>
Box 2 On (text): <?php echo $home_pageRecord['box_2_on:text'] ?><br/>
Box 3 On (value): <?php echo $home_pageRecord['box_3_on'] ?><br/>
Box 3 On (text): <?php echo $home_pageRecord['box_3_on:text'] ?><br/>
Box 4 On (value): <?php echo $home_pageRecord['box_4_on'] ?><br/>
Box 4 On (text): <?php echo $home_pageRecord['box_4_on:text'] ?><br/>
Page Title: <?php echo htmlencode($home_pageRecord['page_title']) ?><br/>
Keywords: <?php echo htmlencode($home_pageRecord['keywords']) ?><br/>
Description: <?php echo htmlencode($home_pageRecord['description']) ?><br/>
_link : <a href="<?php echo $home_pageRecord['_link'] ?>"><?php echo $home_pageRecord['_link'] ?></a><br/>

<!-- STEP 2a: Display Uploads for field 'sliding_images' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
Sliding Images:
<blockquote>
<?php foreach ($home_pageRecord['sliding_images'] as $index => $upload): ?>
Upload Url: <?php echo $upload['urlPath'] ?><br/>

<!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.

Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>
Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>

Image Tags:<br/>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

info1 (Alt) : <?php echo htmlencode($upload['info1']) ?><br/>
info2 (Link) : <?php echo htmlencode($upload['info2']) ?><br/><br/>

Extension: <?php echo $upload['extension'] ?><br/>
isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
<hr/>
// end uploads comment tag -->

<?php endforeach ?>
</blockquote>
<!-- STEP2a: /Display Uploads -->


<!-- STEP 2a: Display Uploads for field 'box_1_icon' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
Box 1 Icon:
<blockquote>
<?php foreach ($home_pageRecord['box_1_icon'] as $index => $upload): ?>
Upload Url: <?php echo $upload['urlPath'] ?><br/>

<!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.

Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>
Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>

Image Tags:<br/>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

info1 (Title) : <?php echo htmlencode($upload['info1']) ?><br/><br/>

Extension: <?php echo $upload['extension'] ?><br/>
isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
<hr/>
// end uploads comment tag -->

<?php endforeach ?>
</blockquote>
<!-- STEP2a: /Display Uploads -->


<!-- STEP 2a: Display Uploads for field 'box_1' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
Box 1:
<blockquote>
<?php foreach ($home_pageRecord['box_1'] as $index => $upload): ?>
Upload Url: <?php echo $upload['urlPath'] ?><br/>

<!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.

Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>
Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>

Image Tags:<br/>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

info1 (Alt) : <?php echo htmlencode($upload['info1']) ?><br/>
info2 (Link) : <?php echo htmlencode($upload['info2']) ?><br/><br/>

Extension: <?php echo $upload['extension'] ?><br/>
isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
<hr/>
// end uploads comment tag -->

<?php endforeach ?>
</blockquote>
<!-- STEP2a: /Display Uploads -->


<!-- STEP 2a: Display Uploads for field 'box_2_icon' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
Box 2 Icon:
<blockquote>
<?php foreach ($home_pageRecord['box_2_icon'] as $index => $upload): ?>
Upload Url: <?php echo $upload['urlPath'] ?><br/>

<!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.

Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>
Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>

Image Tags:<br/>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

info1 (Title) : <?php echo htmlencode($upload['info1']) ?><br/><br/>

Extension: <?php echo $upload['extension'] ?><br/>
isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
<hr/>
// end uploads comment tag -->

<?php endforeach ?>
</blockquote>
<!-- STEP2a: /Display Uploads -->


<!-- STEP 2a: Display Uploads for field 'box_2' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
Box 2:
<blockquote>
<?php foreach ($home_pageRecord['box_2'] as $index => $upload): ?>
Upload Url: <?php echo $upload['urlPath'] ?><br/>

<!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.

Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>
Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>

Image Tags:<br/>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

info1 (Alt) : <?php echo htmlencode($upload['info1']) ?><br/>
info2 (Link) : <?php echo htmlencode($upload['info2']) ?><br/><br/>

Extension: <?php echo $upload['extension'] ?><br/>
isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
<hr/>
// end uploads comment tag -->

<?php endforeach ?>
</blockquote>
<!-- STEP2a: /Display Uploads -->


<!-- STEP 2a: Display Uploads for field 'box_3_icon' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
Box 3 Icon:
<blockquote>
<?php foreach ($home_pageRecord['box_3_icon'] as $index => $upload): ?>
Upload Url: <?php echo $upload['urlPath'] ?><br/>

<!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.

Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>
Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>

Image Tags:<br/>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

info1 (Title) : <?php echo htmlencode($upload['info1']) ?><br/><br/>

Extension: <?php echo $upload['extension'] ?><br/>
isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
<hr/>
// end uploads comment tag -->

<?php endforeach ?>
</blockquote>
<!-- STEP2a: /Display Uploads -->


<!-- STEP 2a: Display Uploads for field 'box_3' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
Box 3:
<blockquote>
<?php foreach ($home_pageRecord['box_3'] as $index => $upload): ?>
Upload Url: <?php echo $upload['urlPath'] ?><br/>

<!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.

Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>
Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>

Image Tags:<br/>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

info1 (Alt) : <?php echo htmlencode($upload['info1']) ?><br/>
info2 (Link) : <?php echo htmlencode($upload['info2']) ?><br/><br/>

Extension: <?php echo $upload['extension'] ?><br/>
isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
<hr/>
// end uploads comment tag -->

<?php endforeach ?>
</blockquote>
<!-- STEP2a: /Display Uploads -->


<!-- STEP 2a: Display Uploads for field 'box_4_icon' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
Box 4 Icon:
<blockquote>
<?php foreach ($home_pageRecord['box_4_icon'] as $index => $upload): ?>
Upload Url: <?php echo $upload['urlPath'] ?><br/>

<!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.

Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>
Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>

Image Tags:<br/>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

info1 (Title) : <?php echo htmlencode($upload['info1']) ?><br/><br/>

Extension: <?php echo $upload['extension'] ?><br/>
isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
<hr/>
// end uploads comment tag -->

<?php endforeach ?>
</blockquote>
<!-- STEP2a: /Display Uploads -->


<!-- STEP 2a: Display Uploads for field 'box_4' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
Box 4:
<blockquote>
<?php foreach ($home_pageRecord['box_4'] as $index => $upload): ?>
Upload Url: <?php echo $upload['urlPath'] ?><br/>

<!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.

Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>
Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>

Image Tags:<br/>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

info1 (Alt) : <?php echo htmlencode($upload['info1']) ?><br/>
info2 (Link) : <?php echo htmlencode($upload['info2']) ?><br/><br/>

Extension: <?php echo $upload['extension'] ?><br/>
isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
<hr/>
// end uploads comment tag -->

<?php endforeach ?>
</blockquote>
<!-- STEP2a: /Display Uploads -->

<!-- /STEP2: Display Record -->

anyone help me work out how to get this work without having to make up 4 different multi sections.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [greg] ok something tricky

By KCMedia - November 28, 2012

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

By KCMedia - November 28, 2012

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

By KCMedia - November 29, 2012

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

By gregThomas - November 30, 2012

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

By KCMedia - November 30, 2012

hi Greg

thanks for that works great.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz