Related Files Sidebar

3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 8, 2010   (RSS)

Re: [zip222] Related Files Sidebar

By Chris - December 8, 2010

Hi zip222,

I'm guessing that your 'related_files' field is a multi-value list field? If that's the case, $page['related_files'] will contain a tab-separated list of nums. Here's how to work with that:

$commaSepNums = implode(", ", array_map('intval', explode("\t", trim($page['related_files']))));

$relatedfilesRecord = array();
if ($commaSepNums) {
list($relatedfilesRecord,)=getRecords(array(
'tableName' => 'related_files',
'allowSearch' => false,
'where' => "num IN ($commaSepNums)",
));
}


...and then in your page:

<ul>
<?php foreach ($relatedfilesRecord as $relatedfiles): ?>
<?php foreach ($relatedfiles['file'] as $upload): ?>
<li><a href="<?php echo $upload['urlPath'] ?>"><?php echo $relatedfiles['title']; ?></a></li>
<?php endforeach ?>
<?php endforeach ?>
</ul>


I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Related Files Sidebar

By zip222 - December 8, 2010

Perfect. Thanks!