search using criteria in URL
9 posts by 2 authors in: Forums > CMS Builder
Last Post: June 19, 2009 (RSS)
By benedict - May 17, 2009 - edited: May 18, 2009
I have gone to http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html and it all seems straight forward but I can not get it to work.
I have a list page called library_newslist.php
In my link on another page I want it to find all the news items that have the service type of "Corporate Advisory". So I create this link:
<a href="library_newslist.php?service=Corporate%20Advisory">Click here</a> to read all news items related to Corporate Advisory
But it presents all the records, not just the ones I want.
Any idea what I am doing wrong?
Cheers,
B
Re: [benedict] search using criteria in URL
By benedict - May 18, 2009 - edited: May 18, 2009
'allowSearch' => '0',
This works fine now. Now for part 2 of my problem which refers to the resulting news list:
AS described earlier, my link says this:
<a href="library_newslist.php?service=Corporate%20Advisory">Click here</a> to read all news items related to Corporate Advisory
What I didn;t mention is that this link is on a detail page that has its info fed like this:
<a href="library_newslist.php?service=<?php echo $servicesRecord['title'] ?>">Click here</a> to read all news items related to <?php echo $servicesRecord['title'] ?>
This is all working fine. The only thing is that my newslist page just has a heading of "News". My Client would like it to say "News: Corporate Advisory". Is there any code I can use to pull the field from the URL onto the page next to my heading?
Re: [benedict] search using criteria in URL
By ross - May 18, 2009
Thanks for posting!
I see what you are trying to do here and there are a couple ways to get that going. The easiest would be to just use this:
<?php echo $_GET['service']; ?>
That will grab the value from your URL.
Let me know if that works for you. There may be a little formatting needed but try that first and we'll go from there.
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: [benedict] search using criteria in URL
By benedict - June 10, 2009
Just a follow up to this one - this works great except for those services that have an ampersand in them (for example "Acquisitions & Mergers"). Is there some code I should include to exclude the '&'?
Re: [benedict] search using criteria in URL
By ross - June 10, 2009
Glad to hear we are almost there :).
I think what you'll want to do with this one is HTML encode the values when you create the link itself. What I mean by that is take this bit of code:
<a href="library_newslist.php?service=<?php echo $servicesRecord['title'] ?>">Click here</a> to read all news items related to <?php echo $servicesRecord['title'] ?>
and replace it with this:
<a href="library_newslist.php?service=<?php echo htmlspecialchars($servicesRecord['title']) ?>">Click here</a> to read all news items related to <?php echo $servicesRecord['title'] ?>
That should help. If it doesn't, could you give me more details on what you mean by it doesn't work?
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] search using criteria in URL
By benedict - June 17, 2009
Sorry for the delay in replying. Still no luck with your revised code.
What it is presenting is a link like this:
a href="library_newslist.php?service=Distribution & Licensing"
Which is exactly what it did before with the old code. I just ran the search term through your encoder and it says that Distribution & Licensing should appear as:
Distribution%20%26%20Licensing
But my browser is trying to create this link:
Distribution%20&%20Licensing
How do I get it to create the %26 instead of an '&'.?
Re: [benedict] search using criteria in URL
By ross - June 19, 2009
Could you try using urlencode () instead of htmlentities()
That should get things going. 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] search using criteria in URL
By benedict - June 19, 2009