multi section images on 1 homepage

6 posts by 3 authors in: Forums > CMS Builder
Last Post: January 4, 2011   (RSS)

By Maurice - January 2, 2011

Hi all,

i have a few sections like news, blog and events

on a home page i want to place images from all those sections the content is oke but the upload code is the same for all images.

how can i display the images from different sections on 1 page?

Thnx
-------------------------------------------

Dropmonkey.nl

Re: [Jason] multi section images on 1 homepage

By Maurice - January 3, 2011

cool do u have an example?
-------------------------------------------

Dropmonkey.nl

Re: [Maurice] multi section images on 1 homepage

By Chris - January 3, 2011

Hi Maurice,

Does this do what you want?

<?php

// load records

list($fooRecords,) = getRecords(array(
'tableName' => 'foo',
));
list($barRecords,) = getRecords(array(
'tableName' => 'bar',
));
list($baazRecords,) = getRecords(array(
'tableName' => 'baaz',
));

?>

<h1>Section: Foo</h1>
<?php foreach($fooRecords as $record): ?>
<h2>Record: <?php echo $record['num'] ?></h2>
<?php foreach($record['upload'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
<?php endforeach ?>
<?php endforeach ?>

<h1>Section: Bar</h1>
<?php foreach($barRecords as $record): ?>
<h2>Record: <?php echo $record['num'] ?></h2>
<?php foreach($record['upload'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
<?php endforeach ?>
<?php endforeach ?>

<h1>Section: Baaz</h1>
<?php foreach($baazRecords as $record): ?>
<h2>Record: <?php echo $record['num'] ?></h2>
<?php foreach($record['upload'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
<?php endforeach ?>
<?php endforeach ?>

All the best,
Chris

Re: [Maurice] multi section images on 1 homepage

By Jason - January 3, 2011

Hi,

For example, if we wanted to use a section called news and a section called articles, it would work like this:

I'm assuming that the name of the image field in both sections is called images:



<?php
list($newsRecords,$newsMetaData)=getRecords(array(
'tableName' => 'news',
'allowSearch' => false,
));

list($articleRecords,$articleMetaData)=getRecords(array(
'tableName' => 'articles',
'allowSearch' => false,
));

$imageRecords = array_merge(array_pluck($newsRecords,'images'),array_pluck($articleRecords,'images'));
$imagesRecords=array_filter($imageRecords);
?>

<?php foreach($imageRecords as $imageRecord):?>
<?php foreach($imageRecord as $image):?>
**OUTPUT IMAGE HERE**
<?php endforeach ?>
<?php endforeach ?>



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] multi section images on 1 homepage

By Maurice - January 4, 2011

wauw you guy's are the best thanx allot.

Maurice
-------------------------------------------

Dropmonkey.nl