Conditional Display of Field

8 posts by 4 authors in: Forums > CMS Builder
Last Post: July 27, 2009   (RSS)

Hi there on a list viewer I want to change the heading based on the variable being passed using seo urls...

E.g. when I go to:
www.domain.com/listviewer.php/type-value-a/
www.domain.com/listviewer.php/type-value-b
www.domain.com/listviewer.php/type-value-c/

So I assume I need something like this

if type = Value A
<h1>Value A</h1>
elseif type = Value B
<h1>Value B</h1>
else type = Value C
<h1>Value C</h1>

Not sure on what code to use though. Any suggestions?

Many thanks.

Re: [gkornbluth] Conditional Display of Field

Hi Jerry,

Thanks for that it worked with the addition of <?php break ?>

But I think I'm trying to do this the wrong way because it grabs the first record when showing "ALL" types and if there are no records then it dos not show anything.

example - see red text: http://www.staging.baobabmarine.com/brokerage.php

changing the drop-down displays the three different types.

Is there a better way of doing this?

Re: [aquaman] Conditional Display of Field

By ross - July 21, 2009

Hi there.

Thanks for posting!

Could you post a copy of that whole page you are working with? Best case scenario would be if you could attach the file instead of pasting code into a post.

I'll take a look at how you have things setup and see what options you have. I definitely think you are on the right track and Jerry's tips on if blocks was great.

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] Conditional Display of Field

Hi Ross, that's great, much appreciated. File attached.
Attachments:

brokerage.php 4K

Re: [aquaman] Conditional Display of Field

By ross - July 24, 2009

Hi there.

I've been looking through that code and usually, if you just go to brokerage.php without any search criteria, it will display all your records. The only thing right now is that the link to this page on your site doesn't actually work anymore. Could you send me an up to date link?

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] Conditional Display of Field

Hi Ross, the site has gone live and is now at http://www.baobabmarine.com/brokerage.php - I have commented out the code so it does not show but its still viewable in the source.

Re: [aquaman] Conditional Display of Field

By Dave - July 27, 2009

Hi aquaman,

Are you still working on displaying a different heading based on the seo url variable?

If so, you can test urls like this:
www.domain.com/listviewer.php/type-value-a/
www.domain.com/listviewer.php/type-value-b

With this code:
<?php if (@$_REQUEST['type'] == 'value-a'): ?>
Value A
<?php endif ?>

<?php if (@$_REQUEST['type'] == 'value-b'): ?>
Value B
<?php endif ?>

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com