UL List Issue

10 posts by 2 authors in: Forums > CMS Builder
Last Post: December 13, 2011   (RSS)

By KCMedia - December 8, 2011 - edited: December 8, 2011

Hi All

i have this scrolling image list http://www.actionmc.com.au/beta/index.php at the bottom called custom rides that displays 4 images at a time

Attached is the code to make that work, but i need to know how to make this work with cmsb as it is broken into 2 or more UL lists to make it work how can i make it so that is displays 4 images then a new UL then 4 images in LI then the next 4 and so on.

I have included the cmsb code also.

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php


// load records
list($custom_ridesRecords, $custom_ridesMetaData) = getRecords(array(
'tableName' => 'custom_rides',
));

?> <!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>Custom Rides - List Page Viewer</h1>
<?php foreach ($custom_ridesRecords as $record): ?>
Record Number: <?php echo $record['num'] ?><br/>
Title: <?php echo $record['title'] ?><br/>
Specification: <?php echo $record['specification'] ?><br/>
Custom Options: <?php echo $record['custom_options'] ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>


<!-- STEP 2a: Display Uploads for field 'images' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
<?php foreach ($record['images'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

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

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


<hr/>
<?php endforeach ?>

<?php if (!$custom_ridesRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->
Thanks



Craig

KC Media Solutions

www.kcmedia.biz
Attachments:

custom-rides-inc.php 2K

Re: [kcmedia] UL List Issue

By Jason - December 9, 2011

Hi Craig,

Try this:

<div class="slide2">
<?php
$imageCount = 0;
$imagesPerSlide = 4;
?>

<ul>
<?php foreach ($record['images'] as $upload): ?>
<?php if (++$imageCount % ($imagesPerSlide + 1) == 0):?>
</ul>
<ul>
<?php endif ?>

<li><a href="custom-motorbikes.php"><img src="<?php echo $upload['thumbUrlPath'];?>" alt="" width="<?php echo $upload['thumbWidth'];?>" height="<?php echo $upload['thumbHeight'];?>"></a><span><?php echo $upload['info1'];?></span></li>

<?php endforeach ?>
</ul>


</div>


I wasn't sure where you were storing the text you wanted displayed for the link, so I used the info1 field in this example.

Hope this helps you get started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] UL List Issue

By KCMedia - December 9, 2011

Hi Jason

i am getting an error about this line

<?php foreach ($record['images'] as $upload): ?>

checkout the site.

www.actionmc.com.au/beta/index.php
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [Jason] UL List Issue

By KCMedia - December 9, 2011

Hi Jason

i sort of got it working but the issue is that it is displaying all the images it should only show the first image of each bike in the list

I have attached the code again and also the cmsb code.

<?php



// load records
list($custom_motorbikesRecords, $custom_motorbikesMetaData) = getRecords(array(
'tableName' => 'custom_motorbikes',
));

?> <!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>Custom Motorbikes - List Page Viewer</h1>
<?php foreach ($custom_motorbikesRecords as $record): ?>
Record Number: <?php echo $record['num'] ?><br/>
Title: <?php echo $record['title'] ?><br/>
Features: <?php echo $record['content'] ?><br/>
Text: <?php echo $record['text'] ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>


<!-- STEP 2a: Display Uploads for field 'logo' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
<?php foreach ($record['logo'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

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

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



<!-- STEP 2a: Display Uploads for field 'upload' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
<?php foreach ($record['upload'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

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

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


<hr/>
<?php endforeach ?>

<?php if (!$custom_motorbikesRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->
Thanks



Craig

KC Media Solutions

www.kcmedia.biz
Attachments:

custom-rides-inc_001.php 2K

Re: [kcmedia] UL List Issue

By Jason - December 12, 2011

Hi,

We can do this by only using a single foreach loop and skipping any record that doesn't have an upload attached to it.

Try this:

<div class="slide2">
<?php
$imageCount = 0;
$imagesPerSlide = 4;
?>

<ul>
<?php foreach ($custom_motorbikesRecords as $record): ?>
<?php if (!$record['upload']) { continue; } ?>

<?php $upload = $record['upload'][0]; ?>
<?php if (++$imageCount % ($imagesPerSlide + 1) == 0):?>
</ul>
<ul>
<?php endif ?>

<li><a href="custom-motorbikes.php"><img src="<?php echo $upload['thumbUrlPath'];?>" alt="" width="<?php echo $upload['thumbWidth4'];?>" height="<?php echo $upload['thumbHeight4'];?>"></a><span><?php echo $record['title'] ?></span></li>

<?php endforeach ?>
</ul>

<?php if (!$custom_motorbikesRecords): ?>
No records were found!<br/><br/>
<?php endif ?>

</div>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [kcmedia] UL List Issue

By Jason - December 12, 2011

Hi Craig,

Our problem is that we were doing our check BEFORE we ouput and image, where we should have been doing the check AFTER.

Try this:

<div class="slide2">
<?php
$imageCount = 0;
$imagesPerSlide = 4;
?>

<ul>
<?php foreach ($custom_motorbikesRecords as $record): ?>
<?php if (!$record['upload']) { continue; } ?>

<?php $upload = $record['upload'][0]; ?>

<li><a href="custom-motorbikes.php"><img src="<?php echo $upload['thumbUrlPath'];?>" alt="" width="<?php echo $upload['thumbWidth4'];?>" height="<?php echo $upload['thumbHeight4'];?>"></a><span><?php echo $record['title'] ?></span></li>

<?php if (++$imageCount % ($imagesPerSlide + 1) == 0):?>
</ul>
<ul>
<?php endif ?>

<?php endforeach ?>
</ul>

<?php if (!$custom_motorbikesRecords): ?>
No records were found!<br/><br/>
<?php endif ?>

</div>


This should work better.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] UL List Issue

By KCMedia - December 12, 2011

Hi Jason

still not working right it is showing that one extra image per slide.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [kcmedia] UL List Issue

By Jason - December 13, 2011

Hi Craig,

Try changing the if statement to this:

<?php if (++$imageCount % $imagesPerSlide == 0):?>
</ul>
<ul>
<?php endif ?>


Since we're now doing the check after the image is outputted and now before, we want to use $imagesPerSlide, not $imagesPerSlide +1 in our check.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] UL List Issue

By KCMedia - December 13, 2011

Hi Jason

perfect thank you very much it looks good now.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz