Redirect URL

5 posts by 2 authors in: Forums > CMS Builder
Last Post: December 16, 2014   (RSS)

I have a redirect field called : redirect : that I would like to use in my code.

How can I do this?

Example:

<?php foreach ($festival_archive_2014Records as $record): ?>

<p><a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['name']) ?></a></p>
<?php endforeach ?>

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

By claire - December 16, 2014

Hi there

I'm not sure I understand where you want the redirect code to be added here? Do you want it in place of the $record['_link']?

--------------------

Claire Ryan
interactivetools.com

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

By claire - December 16, 2014

No no, just a plain if-else will do it here. Try this:

<?php foreach ($festival_archive_2014Records as $record): ?>
<?php if($record['redirect']):?>
<p><a href="<?php echo $record['redirect'] ?>"><?php echo htmlencode($record['name']) ?></a></p>
<?php else : ?>
<p><a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['name']) ?></a></p>
<?php endif; ?>
<?php endforeach ?>


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

--------------------

Claire Ryan
interactivetools.com

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

Ahhh...yes, that makes sense.  Thanks for the help...i'm still learning!

:-)