"No listings" link code

6 posts by 3 authors in: Forums > CMS Builder
Last Post: November 14, 2008   (RSS)

Re: [WEVOLUTIONS] "No listings" link code

By Dave - November 12, 2008

What do you mean by separate page? Like a popup? Or in a different frame? Or just that if there is no matches then it shows a completely different page?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] "No listings" link code

By wevolutions - November 12, 2008

If there are no listings I want it to load a completely different page than the listings page.

Re: [WEVOLUTIONS] "No listings" link code

By Kenny - November 13, 2008

One way would be to use an if statement and a javascript redirect.

<?php if ($record['content']): ?>

***Insert html code here***

<?php else: ?>

<script>document.location.href='page2.php'</script>

<?php endif ?>



It may or may not be the best option, but right off the top of my head, it would work.


Kenny

Re: [WEVOLUTIONS] "No listings" link code

By Dave - November 14, 2008

Another way is to put the code up at the top before ANY html is output, like this:

<?php
if (!$featured_carsRecords) {
header("Location: http://www.example.com/newurl.html");
exit;
}
?>


Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [WEVOLUTIONS] "No listings" link code

By Kenny - November 14, 2008

Definitely go with Dave's solution - I was wondering how to do a PHP redirect in this situation. They are more reliable than a javascript redirect. There are still a few people who don't have javascript enabled, therefore my solution wouldn't work for them. Since PHP is a server side action, it will always work.

As Dave said - make sure it goes before any HTML or it won't work.

Thanks Dave for the code!