Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
UL List Issue

 

 


kcmedia
User

Dec 8, 2011, 3:20 PM

Post #1 of 10 (952 views)
Shortcut
UL List Issue Can't Post

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

(This post was edited by kcmedia on Dec 8, 2011, 3:21 PM)
Attachments: custom-rides.inc.php (1.75 KB)


Jason
Staff / Moderator


Dec 9, 2011, 10:46 AM

Post #2 of 10 (945 views)
Shortcut
Re: [kcmedia] UL List Issue [In reply to] Can't Post

Hi Craig,

Try this:


Code
  <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 - Programmer 
interactivetools.com

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


kcmedia
User

Dec 9, 2011, 2:00 PM

Post #3 of 10 (941 views)
Shortcut
Re: [Jason] UL List Issue [In reply to] Can't Post

Hi Jason

i am getting an error about this line

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

checkout the site.

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

Craig
KC Media Solutions
www.kcmedia.biz


kcmedia
User

Dec 9, 2011, 4:27 PM

Post #4 of 10 (935 views)
Shortcut
Re: [Jason] UL List Issue [In reply to] Can't Post

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
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */


// 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.php (1.17 KB)


Jason
Staff / Moderator


Dec 11, 2011, 10:16 PM

Post #5 of 10 (922 views)
Shortcut
Re: [kcmedia] UL List Issue [In reply to] Can't Post

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:


Code
<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 - Programmer 
interactivetools.com

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


kcmedia
User

Dec 11, 2011, 10:21 PM

Post #6 of 10 (919 views)
Shortcut
Re: [Jason] UL List Issue [In reply to] Can't Post

Hi Jason

that sort of worked if you have a look it is dropping an extra image into some of the scrolls
Thanks

Craig
KC Media Solutions
www.kcmedia.biz


Jason
Staff / Moderator


Dec 11, 2011, 10:57 PM

Post #7 of 10 (917 views)
Shortcut
Re: [kcmedia] UL List Issue [In reply to] Can't Post

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:


Code
<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 - Programmer 
interactivetools.com

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


kcmedia
User

Dec 12, 2011, 11:56 AM

Post #8 of 10 (912 views)
Shortcut
Re: [Jason] UL List Issue [In reply to] Can't Post

Hi Jason

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

Craig
KC Media Solutions
www.kcmedia.biz


Jason
Staff / Moderator


Dec 12, 2011, 10:07 PM

Post #9 of 10 (909 views)
Shortcut
Re: [kcmedia] UL List Issue [In reply to] Can't Post

Hi Craig,

Try changing the if statement to this:


Code
        <?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 - Programmer 
interactivetools.com

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


kcmedia
User

Dec 13, 2011, 11:43 AM

Post #10 of 10 (883 views)
Shortcut
Re: [Jason] UL List Issue [In reply to] Can't Post

Hi Jason

perfect thank you very much it looks good now.
Thanks

Craig
KC Media Solutions
www.kcmedia.biz