Forum
Getting results URL in title
I have a filter form on my website which filters job type and location. How can I get the result page title to display like below:
Showing results for: Building Services in Cheddar
This is my URL of the results page: /results.php?type=Building+Services&location=Cheddar
For similar stuff, I've used perch_get() and perch_page_attributes_extend(). So, at the top of your page:
Thanks for the reply. Not sure I follow this?
Which part don't you understand?
This code is needed in your results.php page - perch_get() gets the arguments from the url (in your case, type and location). You can then use those variables to dynamically update the title for the page - using perch_page_attributes_extend(). Passing the string to pageTitle essentially "overwrites" the value that may already have been set for the results.php page title.
Check out the docs for both functions for further examples (I think).
sorry my fault. I didn't mean the page title. I meant the title on the page above the results.
Ok, great. Does that answer your question then?
Sorry, not really. What would I put between the <h1> tags on my page to show the two key terms the page is showing the results for?
Referring back to my first post, you have the values from the url stored in $type and $location - use those to build a string and plonk it between the h1 tags. Job's a good 'un.
sorry? build a string?
I am not to good with php language. please can you help with the code I would need?
James. It turns out I was happy to give you an answer in my first post, so I should be equally happy to provide you with an answer in this post.
However - (this is just an opinion of mine) - that kind of bypasses the fun in learning why the answer you've been given is the answer. As it turns out, the code/string you need is in my first post - I'm passing a string to an array item called 'pageTitle'. You could use that same string in your code as follows (concatenating, or building, a string):
However, there's loads of ways of doing the same thing, depending on your coding preferences and/or style. Doing a Google search for "php build string with variables" will show most ways (along with a good smattering of angry internet people who will argue their way is THE BEST). Assuming you're storing the url values in variables as per my first post, you could do:
Or if you don't want to use variables, just do:
Actual apologies for the (unintentional) sanctimonious tone and general waffle.
Thank you, thank you... that's perfect.
It makes perfect sense when I see the code, but unless you know the correct php terminology it can be hard to google the function I need.
Cheers :-)