Display/hide link
15 posts by 5 authors in: Forums > CMS Builder
Last Post: July 22, 2009 (RSS)
By fleff - July 17, 2009
<div class="text_11_vb_red">
<script type="text/javascript">
if ('http://xxxx.org/emergency_linkDetail.php')
{
document.write('<a href="http://xxxx.org/emergency_infoDetail.php" class="navlinks_emergency">Emergency Information</a>');
}
</script>
</div>
I tried this JavaScript in one of my Listings Manager websites and it worked fine using a listings field ($lfield52$) in the "if" statement to see if it was empty. But I can't figure out how to get it to check the content of the emergency_linkDetail.php page to see if it is empty -- or if it has a keyword on it that will trigger the link. If LM were still available, I would have done it there. But don't get me wrong, I think CMS Builder is great.
Maybe there's a better way to accomplish this. Any help would be much appreciated.
Thanks,
Farnham
Re: [fleff] Display/hide link
By fleff - July 18, 2009
<script type="text/javascript">
if ('$link_creatorRecord["emergency_link"]' == 'yes')
{
document.write('<a href="http://xxxx.org/emergency_infoDetail.php" class="navlinks_emergency">Emergency Information</a>');
}
</script>
Farnham
Re: [fleff] Display/hide link
By isdoo - July 19, 2009
<?php if($newsRecord['field']): ?>
Action
<?php else: ?>
<?php endif ?>
So perhaps
<?php if($link_creatorRecord['emergency_link']): ?>
<script type="text/javascript">
{
document.write('<a href="http://xxxx.org/emergency_infoDetail.php" class="navlinks_emergency">Emergency Information</a>');
}
</script>
<?php else: ?>
<?php endif ?>
Re: [isdoo] Display/hide link
By fleff - July 19, 2009
Farnham
Re: [fleff] Display/hide link
By isdoo - July 20, 2009
Re: [isdoo] Display/hide link
By fleff - July 20, 2009
Farnham
Re: [fleff] Display/hide link
By Kenny - July 20, 2009 - edited: July 20, 2009
Just write a regular if statement that is triggered when the text field contains content
REGULAR IF STATEMENT
<?php if ($link_creatorRecord['emergency_link']): ?>
***Insert other code here***
<?php endif ?>
or optionally you can write an if statement that is triggered when the field is blank
REGULAR IF DOES NOT EXIST STATEMENT
<?php if (!$link_creatorRecord['emergency_link']): ?>
***Insert other code here***
<?php endif ?>
Kenny
Re: [fleff] Display/hide link
By ross - July 21, 2009
I agree with sagentic. Let's get you switched over to a fully PHP solution so that we can eliminate the JavaScript as a possible problem.
Can you give that a shot? And then perhaps post a copy of your whole template (as an attachment, please :)) so we can take a closer look at how it's all put together.
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/
Re: [ross] Display/hide link
By fleff - July 21, 2009
Thanks for the response. My guess is that either isdoo's or sagentic's script will work and that I'm doing something wrong. My emergency_linkDetail.php file works fine and either has a word on the page or nothing on the page when I enter or delete in the CMSB Link Creator section. But it posts the link on the website home page (copy attached) whether the page has a word or not, and then the link won't go away if I empty the emergency_linkDetail.php page. Do I have a path wrong somewhere or what? I'm sure it will do what I want once you take a look at it. Btw, the ticket ID is SJI-489756.
Best regards, Farnham
Re: [fleff] Display/hide link
By zip222 - July 21, 2009
Its likely that its not executing the php commands. Try switching the extension to .php and see if it works.