Switching links on programs
4 posts by 3 authors in: Forums > CMS Builder
Last Post: May 13, 2009 (RSS)
By interchanges - May 12, 2009
Hello,
My client needs to have 2 separate outcomes for a listing depending on what fields are entered in the CMSadmin.
He has 2 separate fields that need to be linked to the main title of the program. Either a link to a file that he uploads OR a website URL that he would like to link it to.
Right now i have this currently as my PHP code for the title linked to the uploaded file:
<?php foreach ($record['file'] as $upload): ?><a href="<?php echo $upload['urlPath'] ?>"><?php echo $record['title'] ?></a><?php endforeach ?>
But if i do not upload a file, the title doesn't display at all.
So in the absence of an uploaded file, i would like to place a URL link instead. My URL link would be from this field in the admin: <?php echo $record['web_link'] ?>
Is there a way to do an if/else statement that will work with one or the other depending on the field that is entered in the admin?
Thanks in advance!
My client needs to have 2 separate outcomes for a listing depending on what fields are entered in the CMSadmin.
He has 2 separate fields that need to be linked to the main title of the program. Either a link to a file that he uploads OR a website URL that he would like to link it to.
Right now i have this currently as my PHP code for the title linked to the uploaded file:
<?php foreach ($record['file'] as $upload): ?><a href="<?php echo $upload['urlPath'] ?>"><?php echo $record['title'] ?></a><?php endforeach ?>
But if i do not upload a file, the title doesn't display at all.
So in the absence of an uploaded file, i would like to place a URL link instead. My URL link would be from this field in the admin: <?php echo $record['web_link'] ?>
Is there a way to do an if/else statement that will work with one or the other depending on the field that is entered in the admin?
Thanks in advance!
Re: [interchanges] Switching links on programs
By Damon - May 12, 2009
Hi,
Trying using this code to only display the web link if there is no uploads:
<?php if(!$record['file']) : ?>
<?php echo $record['web_link'] ?><br />
<?php endif ?>
Hope that helps.
Trying using this code to only display the web link if there is no uploads:
<?php if(!$record['file']) : ?>
<?php echo $record['web_link'] ?><br />
<?php endif ?>
Hope that helps.
Cheers,
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Damon] Switching links on programs
By interchanges - May 13, 2009
Hey Damon,
That did not work when i placed it in the code. That essentially removed the link to the file and the URL and made all the links go back to my homepage which isnt even in the system. here is what i did which might be wrong, please let me know.
<?php foreach ($record['file'] as $upload): ?><a href="<?php if(!$record['file']) : ?><?php echo $record['web_link'] ?><?php endif ?>"><?php echo $record['title'] ?></a><?php endforeach ?>
That did not work when i placed it in the code. That essentially removed the link to the file and the URL and made all the links go back to my homepage which isnt even in the system. here is what i did which might be wrong, please let me know.
<?php foreach ($record['file'] as $upload): ?><a href="<?php if(!$record['file']) : ?><?php echo $record['web_link'] ?><?php endif ?>"><?php echo $record['title'] ?></a><?php endforeach ?>
Re: [interchanges] Switching links on programs
By ross - May 13, 2009
Hi there.
Could you post a link to the page you are working on? I'd like to see your code in action.
Thanks!
Could you post a link to the page you are working on? I'd like to see your code in action.
Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/