Distance Filters

This topic contains 34 replies, has 2 voices, and was last updated by Alex Meda Alex Meda 2 years, 4 months ago.

Viewing 15 posts - 16 through 30 (of 35 total)
  • Author
    Posts
  • #27805
    Alex Meda
    Alex Meda
    Participant
    You cannot access this content.
    #27807
    Alex Meda
    Alex Meda
    Participant
    You cannot access this content.
    #27808
    Alex Meda
    Alex Meda
    Participant
    You cannot access this content.
    #27830
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thanks. The custom code was almost working perfectly, I adjusted it a bit to give the same output as the advanced title field. I removed the address_field from the advanced title field, as it is no longer needed there.

    The final code is:

    add_filter( 'asp_results', 'asp_custom_field_to_results', 10, 1 ); 
    function asp_custom_field_to_results( $results ) {
      $custom_fields = 'address_field'; 	        // Enter the custom field names, comma separated
      $field = 'title';               					// 'title' or 'content'
      $position = 'after';           					// 'before' or 'after'
      $delimiter = ' ';               					// character between the field value and the field
    	
      $fields = explode(',', $custom_fields);
      foreach ( $fields as $custom_field ) {
    	  $custom_field = trim($custom_field);
    	  foreach ($results as $k=>&$r) {
    		if ($r->content_type != 'pagepost') continue;
    		if ( function_exists('get_field') )
    			$meta_value = get_field( $r->id, $custom_field, true ); // ACF support
    		else
    			$meta_value = get_post_meta( $r->id, $custom_field, true );
    		$meta_value = maybe_unserialize($meta_value);	
    		if ( is_array($meta_value) ) {
    			$meta_value = implode(', ', $meta_value);
    		}		
    		// Modify the post title to add the meta value
    		if ( $meta_value != '' ) {
    			$meta_value = '<p>Location: ' . $meta_value . '</p>';
    		  if ( $field == 'title' ) {
    			if ( $position == 'before' )
    			  $r->title  = $meta_value . $delimiter . $r->title;
    			else
    			  $r->title  .= $delimiter . $meta_value;
    		  } else {
    			if ( $position == 'before' )
    			  $r->content  = $meta_value . $delimiter . $r->content;
    			else
    			  $r->content  .= $delimiter . $meta_value;
    		  }
    		}
    	  }
      }
     
      return $results;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #27839
    Alex Meda
    Alex Meda
    Participant
    You cannot access this content.
    #27852
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #27953
    Alex Meda
    Alex Meda
    Participant
    You cannot access this content.
    #27962
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    The desktop one looks like some sort of CSS conflict there. Possibly a forced margin/padding of some sort. I will have to see that to tell exactly.

    The mobile might be just this option: https://i.imgur.com/R682367.png
    If it’s enabled, the results switch to a “hover” mode automatically.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #27976
    Alex Meda
    Alex Meda
    Participant
    You cannot access this content.
    #27998
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #28030
    Alex Meda
    Alex Meda
    Participant

    Happy Monday,
    You’re right! I tried it on 3 other computers and it works perfectly so my laptop screen resolution was definitely the right issue(I will fix it).

    ON MOBILE PHONE
    I tried it on a “iPhone Pro 11”, and the the pagination arrows which display more results seems to not working as it should be. As a matter of fact, when you click on the arrows for more results, all the results disappear all of a sudden. I am not sure yet if the issue was the phone resolution but I will make sure to test it on many other iPhone Devices to be sure.

    One last thing please, on mobile phones, I want the “Settings Box”(The filters bar) to be displayed only if the user starts typing something to be searched. How to make it work?

    Thank you!

    #28031
    Alex Meda
    Alex Meda
    Participant

    I was almost forgetting about this one but I would like to invite logged out users to register when they click on one of the results.

    So my question is to know if you could set up a custom redirection link to registration page for logged out users when they wish to see the whole content of the result which they clicked on it.

    #28052
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Well, I’m afraid the thing with the settings is not possible – that needs to be custom coded somehow. There is a javascript API, that may help, if you decide to try it, or if a developer may need it.

    The other one with the logged in users is also a custom coding issue, but should be simpler. Based on this knowledge base, I would try something like this:

    add_filter( 'asp_results', 'asp_custom_link_results', 10, 1 );
    function asp_custom_link_results( $results ) {
    	$link = 'https://www.google.com/';	// Link to use, when not logged in
    	
    	// Parse through each result item
    	foreach ($results as $k=>$v) {
    	  if ( !is_user_logged_in() )
    		$results[$k]->link  = $link;
    	}
    
    	return $results;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #28059
    Alex Meda
    Alex Meda
    Participant
    You cannot access this content.
    #28064
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    The URL seems to be incorrect as the error message says. You added the URL starting with “https://”, while I guess it should be “http://”.

    Everything required about the JS api should be in that documentation. You probably want to use the ASP.api(0, "toggleSettings", "show"); api method in a input type event on the search input.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 15 posts - 16 through 30 (of 35 total)

You must be logged in to reply to this topic.