Constructing an URL from another section

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

I have 2 multi record sections:

1. Blog
2. Photogallery

The blog section contains a list field "related_photogallery" that is populated from the photogallery section (num,title).

I want in my blog page to show if there is a related photo gallery to an article… pretty obvious.
Everything is working fine even if there is no related photogallery in one of the articles.

The only problem is how do i link in an article to the related photogallery page?
At the moment the output is only a number… but i need also the title…and the dash.

<?php foreach ($blogRecords as $record): ?>
<?php echo $blogRecord['title'] ?>
<?php echo date("d F Y", strtotime($record['date'])) ?>
<?php echo $blogRecord['content'] ?>
<?php if ($blogRecord['related_photogallery']): ?>
<a href="photogallery.php?<?php echo $blogRecord['related_photogallery'] ?>">View related photogallery</a>
<?php else: ?>
<?php endif ?>
<?php endforeach ?>

Re: [videopixel] Constructing an URL from another section

By Chris - September 26, 2010

Hi videopixel,

Since your filenames contain only the title, and your List Field has that set as its "label", you can do this to get the filename:

<?php
$filenameValue = getFilenameFieldValue(array('title' => $blogRecord['related_photogallery:label']), 'title');
?>
<a href="photogallery.php?<?php echo $filenameValue ?><?php echo $blogRecord['related_photogallery'] ?>">View related photogallery</a>


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