Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
If single record go directly to Details Viewer

 

 


fleff
User

Nov 28, 2011, 9:27 AM

Post #1 of 4 (401 views)
Shortcut
If single record go directly to Details Viewer Can't Post

The website in question has a section called "items". In it are records for several types of items. If a search for a particular type of item finds only one item for that type, my client wants to go directly to the details viewer for that item instead of going through the list viewer that would display only that one item. This is what I have put directly under the <body> tag:

<?php if ($itemsMetaData['totalRecords'] == 1): {
header("Location: /items_details.php");
exit;
}
?>
<?php endif ?>

That brings up the details viewer for the first record in the section, not the record we want. If I physically add the record number in the code, it works fine. My question is, how do I append the record number of the single item in the category requested? I tried the following:

<?php if ($itemsMetaData['totalRecords'] == 1): {
header("Location: /items_details.php?<?php echo $record['num'] ?>");
exit;
}
?>
<?php endif ?>

I get an error message. What should I have here to make it work?

Thanks,

Farnham


Jason
Staff / Moderator


Nov 28, 2011, 10:16 AM

Post #2 of 4 (399 views)
Shortcut
Re: [fleff] If single record go directly to Details Viewer [In reply to] Can't Post

Hi Farnham,

What you need to do is take out the <?php ?> tags where you're outputting the record num. You don't need these tags are you are already inside a PHP block.

Try this:


Code
<?php if ($itemsMetaData['totalRecords'] == 1): { 
header("Location: /items_details.php?". $record['num'] );
exit;
}
?>
<?php endif ?>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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


fleff
User

Nov 28, 2011, 6:49 PM

Post #3 of 4 (375 views)
Shortcut
Re: [Jason] If single record go directly to Details Viewer [In reply to] Can't Post

Thanks, Jason, but I'm still getting the details viewer for the first record in the section rather than the record found in the search. I checked to see what record number is found and it's the correct one for the record I want, but apparently the code is not adding it to the URL for the details page.

Farnham


Jason
Staff / Moderator


Nov 29, 2011, 9:57 AM

Post #4 of 4 (349 views)
Shortcut
Re: [fleff] If single record go directly to Details Viewer [In reply to] Can't Post

Hi,

Could you attach the .php file you're working with along with a link to an example that demonstrates the problem? That way, I can take a closer look.

If you don't want to post this information in the forum, please email it to support@interactivetools.com

Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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