Publisher does not support the Fluid field type. Please do not contact asking when support will be available.
If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.
Ticket: Search does not redirects to result page if URL prefix enabled
Status | Resolved |
Add-on / Version | Publisher 1.6.6 |
Severity | |
EE Version | 2.10.1 |
Marijan Boljar
Oct 27, 2015Description:
If URL prefix is enabled then search result redirects to home page.
Have tried with Channel URL and Search Results URL settings set to /glossary/ and /glossary/search-results/, have tried with {site_url}glossary (for Channel URL) and {site_url}glossary/search-results (for Search Results URL, and have tried to leave this empty also.
Whatever option I try I always get redirected to home page instead search results.
If I turn off URL prefix in Publisher settings then all works without problems and search results are displayed.
Also Site URL in config.php is set to full domain name.
Can you please help and check this issue.
Detailed steps to reproduce the issue:
1. Enable URL prefix
2. Create Simple Search form
3. Create Results page
4. Try to search
As I mentioned, if URL prefix is disabled then all works ok.
BoldMinded (Brian)
Are you using the native search form or something like Low Search?
Marijan Boljar
Native search form
BoldMinded (Brian)
Can you share the search form tag as it is in your template, and the parsed version of it from your browser?
Marijan Boljar
Hello Rein,
sorry for delay, here us code.
TEMPLATE CODE
BROWSER CODE
Let me know if anything else is needed. Thanks, Marijan
Marijan Boljar
Sorry , should be “Hello Brian” No morning coffee still 😊
BoldMinded (Brian)
Can you do me a favor and go to the Publisher_search.php class around line 93 and you’ll see this function.
change it to
Then share the output when you reload the search page.
Marijan Boljar
This is browser code after adding var_dump
I also get PHP warning when added this line
If I comment var_dump Warning goes away.
BoldMinded (Brian)
Change the var_dump to ee()->publisher_log->to-file($this->_meta);
It should save it to cache/publisher/log.txt
Marijan Boljar
When using this code I get
BoldMinded (Brian)
oh, its ee()->publisher_log->to_file($this->_meta);
to_file, not to-file. Sorry about that.
Marijan Boljar
No prob Brian.
Here is result from log.txt
BoldMinded (Brian)
Ok, lets try something else. Find the src/Service/Parser.php file and add these two lines, then just load the page that has the search form tag on it.
https://www.dropbox.com/s/jv2fx0w3ip5wxrc/Screenshot 2015-10-29 09.03.00.png?dl=0
Marijan Boljar
Ok , done, now we have log.txt looking like this.
BoldMinded (Brian)
Ok, in that 2nd conditional in the screenshot, fix the variable name:
$meta[‘no_results_page’] = ee()->publisher_helper_url->swap_url($meta[‘no_results_page’], FALSE);
It currently said no_result_page, should be plural.
After that, it should be redirecting to those pages properly. Try going directly to en/glossary/search-results/ in your browser and see what happens. Try it with and without the trailing slash.
Marijan Boljar
Here are details Brian
I needed to change “meta_no_result” also where conditional is set to get prefix “en” in front of no result URL. I think this is what you wanted, if I am correct.
So this was changed (~ 426)
with
and this (~ 428)
with
So after those two changes log.txt contains
Without changing
to
, there was no prefix added.
But still if there is URL prefix present in URL, search result for term that exists or does not exists returns to homepage, it does not redirect to result or no result page. If search is done from homepage where there is no URL prefix, or from other pages when URL prefixes are turned off then it all works ok. As soon as there is URL prefix present, it redirects to homepage.
Here are pictures
https://dl.dropboxusercontent.com/u/24921882/Direct_URL_enter.png https://dl.dropboxusercontent.com/u/24921882/Search_URL_Prefix_OFF_no_results.png https://dl.dropboxusercontent.com/u/24921882/Search_URL_Prefix_OFF_with_results.png https://dl.dropboxusercontent.com/u/24921882/Search_with_URL_prefix_on_resturns_to_homepage.png
Do you have any idea ?
BoldMinded (Brian)
Check my previous comment about going to the pages directly, without performing a search. Just type them into the browser with and without the trailing slash. What happens then?
BoldMinded (Brian)
I just tested this locally and the results and no-results pages work fine for me.
https://www.dropbox.com/s/jsyc0mwqca9bwip/Screenshot 2015-11-01 06.59.25.png?dl=0
My templates
BoldMinded (Brian)
Also, per the docs, it is no_result_page, not no_results_page. https://ellislab.com/expressionengine/user-guide/add-ons/search/simple.html#parameters
Marijan Boljar
Hello Brian,
sorry for delay but I was doing lot’s of implementation and also wanted to do a really throughout testing of this issue.
I think I have found a problem, would you please be so kind to test and check ?
I had a URL rewrite in Apache to remove ending trailing slash. When I removed this rewrite rule search started to work with or without prefixes.
Here is htaccess code that was removed and all started to work.
Do you have any alternative to this code or maybe a suggestion ? Thanks for all your help.
BoldMinded (Brian)
I can’t help with the htaccess file, but I can remove the trailing slash from the URLs that Publisher is creating, which it shouldn’t be adding by default (which is why I asked about accessing the page directly earlier with and without the slash).
BoldMinded (Brian)
Comment has been marked private.
Marijan Boljar
I have provided screenshot with Direct URL enter to search results 4 days ago as screenshot. Here it is again just in case.
For both cases (with or without trailing slash) result is the same, if I go direct to the URL with search results it gives EE message “Your search did not return any results.” https://dl.dropboxusercontent.com/u/24921882/Direct_URL_enter.png
If there is search entered in input field that has no results, this displays “no_result_page” that was defined.
BoldMinded (Brian)
Are you positive that the text you are searching for exists in the language you’re on? The search feature has been implemented for awhile in Publisher now with no similar issues reported, and I can’t replicate the issue locally (searching works fine for me), and when these two things happen, it usually indicates an environment specific issue, either with the server, htaccess, incorrect template code, bad data etc.
Have you tried replicating this in a clean EE environment?
Marijan Boljar
We did not understand each other good. Searching text works great now, no issues.
With or without prefixes all works great.
I just provided you with image of what happens when you enter url of search results directly. So the screenshot above is what you asked, to quote “Try going directly to en/glossary/search-results/ in your browser and see what happens. Try it with and without the trailing slash.”
So I tried to access page and just provided you with results.
It works like this, there are 3 cases (direct URL enter without search, search for keyword that exists, and search for keyword that does not exists)
All is good 😊 All works