Forum Replies Created
-
AuthorPosts
-
Ernest Marcinko
KeymasterHi!
Since the price is parsed from the database (I assume as a custom field), the best option in this case is to find and replace the dot “.” with a comma “,” that’s between 2 digits.
To do that, you will need to create a filter function. Based on this knowledge base article: https://wp-dreams.com/knowledge-base/numbering-the-results/I would add the following code to my themes functions.php file:
[code]
add_filter( ‘asp_results’, ‘asp_fix_comma_results’, 1, 1 );function asp_fix_comma_results( $results ) {
foreach ($results as $k=>$v) {
$results[$k]->title = preg_replace(‘/(\d)(\.)(\d)/’, ‘$1,$3’, $results[$k]->title);
}
return $results;
}
[/code]
If the price is in the title field, this should solve that.As for the second request: Yes it is possible, by adding a few lines of custom CSS code. You can add custom css code on the search options Theme Options -> Custom CSS panel:
[code]
.isotopic nav.asp_navigation ul li span {
line-height: 28px !important;
}.isotopic nav.asp_navigation ul li {
height: 28px !important;
}.isotopic nav.asp_navigation a.asp_prev,
.isotopic nav.asp_navigation a.asp_next {
height: 28px !important;
}
[/code]As you can see, this will change the navigation height to 28 pixels, so don’t forget to change the number accordingly in all 3 cases to match the search height.
March 12, 2015 at 11:40 am in reply to: Ajax Search Pro crashes Safari when viewport is minimized #4199Ernest Marcinko
KeymasterHi!
I just logged in, but it looks like you are working on it right now, as I can’t see the search shortcode anymore. I’ll check back a bit later.
Ernest Marcinko
KeymasterThis is the current method for decoding:
[code]
parse_str(base64_decode($_GET[‘asp_data’]), $s_data);
[/code]After that, the $s_data will contain all the information passed through as an associate array.
You might also find the includes/hooks.php file interesting. The first function there is the one that filters the default search results with the ones from ajax search pro. If you look at line 23, it says:
[code]
$res = ajaxsearchpro_search();
[/code]This is the most important line there. The $res variable will contain all the search results that ajax search pro returns as an array, which might be extremely useful to you. If you stored that variable somewhere or make it global, you will have access to it in the search.php theme file.
That might save you some time 😉
Ernest Marcinko
KeymasterWhat type of content are those on the ajax result list?
The search can override the results page with only posts/pages and custom post types. If those are categories or terms, they will not show there, because it’s not possible to add them to the query object.
Ernest Marcinko
KeymasterYes, but it’s actually outputted into the header as inline CSS, since it’s only a few lines. It’s the best place to put custom CSS, because the changes are visible immediately and it’s stored in the database so the future updates will not delete it.
Ernest Marcinko
KeymasterHi!
Of course. In some cases if the search bar is placed to appear on a javascript event (like in your case) the width is not triggered to calculate correctly.
The best and simplest fix is to force a min-width CSS attribute for the input fields:
[code]
.proinput input {
min-width: 350px;
}
[/code]You can add this code to the Custom CSS field, which you can find on the Theme Options->Custom CSS panel on the search options page.
Ernest Marcinko
KeymasterIf you set the “Override the default WordPress search results page?” option on the General Options->Behavior panel to yes, it will automatically replace the default wordpress search results with the ajax search pro ones. (that’s when it sends the asp_data variable)
Ernest Marcinko
KeymasterYour welcome and thank you for the kind words!
Just a quick note: If your custom search page will look like “/advanced-search/?kw={phrase}” format, then make sure that the “$_GET[‘s’]” variable is also set to the same value. I’m almost 100% sure, that it’s needed. So a simple
[code]if (isset($_GET[‘kw’])) $_GET[‘s’] = $_GET[‘kw’];[/code]
statement should prevent some funny unexpected behavior. I’m not sure however where to put this, I don’t know if it would work in search.php file.
I remember someone asked something similar last week, and I found this short article about customizing search url and redirection and stuff: http://wpengineer.com/2258/change-the-search-url-of-wordpress/
You might find it helpful as well. Have a nice rest of the day, and good luck with the coding!
Ernest Marcinko
KeymasterThanks!
Are those the same warnings? The try-catch structure should prevent the ones you got before.
Ernest Marcinko
KeymasterYes actually.
I’ve switched the ajax handler to a the custom ajax handler on the “Compatibility Options” submenu.
WordPress is not famous for it’s speed in general, and unfortunately each ajax request has to wait till every plugin and core function is loaded which takes time, usually around 1 second. Only then it starts to actually work on the ajax request. By turning on the custom ajax handler, some of the loading time is decreased, so you should see faster results now. (1-2 second difference)
Another thing that takes some time is the thumbnail generation. If the thumbnail is generated for the result for the first time, it take a bit more time. But the second time it’s cached, so no generation needed, thus the search is faster. If you try one search term two or more times, the second time it will be much faster – because the images are now generated.
Also, if you want I can install the upcoming version for beta testing. (not completely finished, but working) It has some other improvements as well, which should affect the search speed greatly. I’m releasing it very soon, and some feedback would be nice. Let me know, and I will install it via the plugin manager.
Ernest Marcinko
KeymasterHi!
The asp_data variable holds the details about the current state of options of the search if the “Override the default WordPress search results page?” option is enabled on the General options panel. On an ajax request this is sent as post data, but here get is used for various reasons for now. This is going to change in the upcoming version.
For the warning message: I don’t exactly know what is the cause, but it appears that in some cases a non-utf8 header is recieved while trying to parse the suggestions file. If you open up that file in wp-content/ajax-search-pro/includes/suggest.class.php and check lines 14-39, you should see a function there named getKeywords($q)
Try to replace that function with this one:
[code]
function getKeywords($q) {
$q = str_replace(‘ ‘, ‘+’, $q);
$method = $this->can_get_file();
if ($method==false) {
return array(‘Error: The fopen url wrapper is not enabled on your server!’);
}
$_content = $this->url_get_contents($this->url.$q, $method);
if ($_content=="") return false;
try {
$_content = mb_convert_encoding($_content, "UTF-8");
$xml = simplexml_load_string($_content);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
$res = array();
if (isset($array[‘CompleteSuggestion’])) {
foreach($array[‘CompleteSuggestion’] as $k=>$v) {
if (isset($v[‘suggestion’]))
$res[] = $v[‘suggestion’][‘@attributes’][‘data’];
elseif (isset($v[0]))
$res[] = $v[0][‘@attributes’][‘data’];
}
}
if (count($res)>0)
return $res;
else
return false;
} catch (Exception $e) {
return false;
}
}
[/code]This will try to convert the encoding first, and return without errors if anything fails.
Ernest Marcinko
KeymasterNot that one. There must be another shortcode placed, the results shortcode, which is in this format:
[code]
<?php echo do_shortcode(‘[wpdreams_ajaxsearchpro_results id=1 element="div"]‘); ?>
[/code]
That’s a bit different shortcode, but it must be there, as I can see the output of it.You either remove that shortcode, or move it below the
[code]
<div class=’header-menu’>…</div>
[/code]Currently, it should be above that line, based on the source code of the page.
Ernest Marcinko
KeymasterIt looks like the results shortcode is used in the header, so the search is displaying the results there naturally. If you remove the results shortcode from the header, the search results will appear below the search bar as default.
Ernest Marcinko
KeymasterOne more thing. Adding a minimum width might be necessary, because I think that the table cell display will shrink everything as much as possible. So this might work better:
[code]
<div style=’display: table-cell; vertical-align: middle; min-width: 220px;’>
<?php echo do_shortcode(‘[wpdreams_ajaxsearchpro id=1]‘); ?>
</div>
[/code]Ernest Marcinko
KeymasterYou most likely will need to edit your theme files to do that and use the php shortcode to display the search.
It’s usually the header.php file in the theme folder, but it varies from theme to theme. Before editing any of the theme files please make a backup in case anything goes wrong.
Based on the html output I can see, the search bar should probably be placed between the navigation menu and the header links div inside the “header-menu” div into a new container displayed as a table cell, something like:
[code]
<div style=’display: table-cell; vertical-align: middle’>
<?php echo do_shortcode(‘[wpdreams_ajaxsearchpro id=1]‘); ?>
</div>
[/code]But this is just a guess based on a quick look at the theme. It might be much more complicated than this. If you want to be sure to have a correct implementation, you can always ask the theme developer if he has a better suggestion.
-
AuthorPosts