Start a new topic
Answered

Modify Text In Search Results Page

Hello Everyone,


I want to edit the search results text, to match my requirements.

I attached a picture here to explain what i want to do. 

I would appreciate a lot your help on sorting this out.


Kind regards,


Daniel

png

Best Answer

Hi Daniel, after carefully reading you comment, the final code looks like this:

 

<?php
	if ($searcherror != "") { 
		echo '<h1 class="hero">Your search returned 0 results</h1>';
	} else {
		if ($profs[profession] != '') {
			if ($profs[service_name] != '') {
				echo '<h1 class="hero">'.$profs[profession].' specialized in '.$profs[service_name].'</h1>';
			} else {
				echo '<h1 class="hero">'.$profs[profession].' Results:</h1>';
			}
		} else {
			echo '<h1 class="hero">Here are the Results:</h1>';
		}
		if ($page[h2] != "" && $page[content] == "") { 
			echo '<h2>'.$page[h2].'</h2>';
		} 
		else if ($_GET[search] == "zip-code") { 
			echo '<h2 style="text-transform:none;">Within '.$radius.' '.$w[distance_full];
			if ($_GET[location_dislay_value] != 1) { 
				echo 's';
			} 
			echo ' of '.$_GET[location_display_value].'</h2>';
		}
	}
	echo '<div class="clear"></div>';
?>

 

Where you can see it behaves just like you mentioned. You can then work based on this to extend to other options. Hope you like it friend.


Hi Daniel, sure thing friend. Simply go to your backend and Toolbox -> Widget Manager and search for the Search Results Header widget. Your code currently looks like this:

  

<?php
	if ($searcherror != "") { 
		echo '<h1 class="hero">Your search returned 0 results</h1>';
	} else {
		echo '<h1 class="hero">'.$page[h1].'</h1>';
		if ($page[h2] != "" && $page[content] == "") { 
			echo '<h2>'.$page[h2].'</h2>';
		} 
		else if ($_GET[search] == "zip-code") { 
			echo '<h2 style="text-transform:none;">Within '.$radius.' '.$w[distance_full];
			if ($_GET[location_dislay_value] != 1) { 
				echo 's';
			} 
			echo ' of '.$_GET[location_display_value].'</h2>';
		}
	}
	echo '<div class="clear"></div>';
?>

 

Simply change the like that says  echo '<h1 class="hero">'.$page[h1].'</h1>'; 


to '<h1 class="hero">'.$profs[profession].' specialized in '.$profs[service_name].'</h1>'; 


So the final code (Which is already applied on your site as an example) would be:


  

<?php
	if ($searcherror != "") { 
		echo '<h1 class="hero">Your search returned 0 results</h1>';
	} else {
		echo '<h1 class="hero">'.$profs[profession].' specialized in '.$profs[service_name].'</h1>';
		if ($page[h2] != "" && $page[content] == "") { 
			echo '<h2>'.$page[h2].'</h2>';
		} 
		else if ($_GET[search] == "zip-code") { 
			echo '<h2 style="text-transform:none;">Within '.$radius.' '.$w[distance_full];
			if ($_GET[location_dislay_value] != 1) { 
				echo 's';
			} 
			echo ' of '.$_GET[location_display_value].'</h2>';
		}
	}
	echo '<div class="clear"></div>';
?> 

  

Hope you like it. Of course for this code, I would extend it to check if the main category and sub category have information in them, if not, print something else, since it would print "specialized in" alone. The variables to check are $profs[profession] and $profs[service_name].

Thank you soo much Luis,


All great, I love it...that's exactly what i wanted to achieve, but as you just mentioned, now i ended up having another issues:


1. Just a simple search without any category or subcategory choice and you end up seeing "Specialized in" which makes no sens. Please see attached.

and

2. if you make a simple search choosing just the category, it will come up as category "specialized in" and it doesn't make sense at all. Please see attached  


Here is what i want to achieve:

1. for the issue 1, instead of "specialized in" as it appears now, i want to have the text "here are the results"

2. for the issue 2, instead of "category specialized in", i want to have the phrase "specialized in" to be deleted and and to have instead the word "results" so the final text will be "main category results"


I know, i look bad that i can't sort this out by my self but i am pretty new to it and i don't want to make a mistake so your help will be greatly appreciated.


Thanks a lot for your help,


Kind regards,


Daniel

png
png

Hi Daniel, ok will start work tomorrow for an example of this.

Answer

Hi Daniel, after carefully reading you comment, the final code looks like this:

 

<?php
	if ($searcherror != "") { 
		echo '<h1 class="hero">Your search returned 0 results</h1>';
	} else {
		if ($profs[profession] != '') {
			if ($profs[service_name] != '') {
				echo '<h1 class="hero">'.$profs[profession].' specialized in '.$profs[service_name].'</h1>';
			} else {
				echo '<h1 class="hero">'.$profs[profession].' Results:</h1>';
			}
		} else {
			echo '<h1 class="hero">Here are the Results:</h1>';
		}
		if ($page[h2] != "" && $page[content] == "") { 
			echo '<h2>'.$page[h2].'</h2>';
		} 
		else if ($_GET[search] == "zip-code") { 
			echo '<h2 style="text-transform:none;">Within '.$radius.' '.$w[distance_full];
			if ($_GET[location_dislay_value] != 1) { 
				echo 's';
			} 
			echo ' of '.$_GET[location_display_value].'</h2>';
		}
	}
	echo '<div class="clear"></div>';
?>

 

Where you can see it behaves just like you mentioned. You can then work based on this to extend to other options. Hope you like it friend.

Luis,


I have no words to thank you for this...

it is exactly what i wanted to achieve.


Thank you very much indeed. I appreciate it very much...


Daniel

I did not see this widget ... I have a ticket in asking how to edit the search page listing and all I get is to edit the listing feature ... but there is no form associated with the search page.

In addition where would I find this widget you speak of ..

 

Hi Devon, since you are in a bootstrap site, you won't be able to see this widget since it is for version 3.0 and you have 4.0. Nonetheless, I added the widget to your widget list so you can play around with it and customize it to your liking. Hope this helps.

Thanks alot Luis ... does this means this widgets does not apply any more.



For the time being, it applies, but an updated Bootstrap based one will be added to the site in the future.