Adding Pro Ajax Search to WP Pro Real Estate 7

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Adding Pro Ajax Search to WP Pro Real Estate 7

This topic contains 10 replies, has 2 voices, and was last updated by

 
Keymaster
3 years, 4 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #19057

    Participant

    Hi, sorry, I thought I had this figured out. I am using Realestate Pro 7 and currently have a single listing page that groups according to status and then price.

    I want to implement Pro Ajax Search without having to rewrite the entire template page. What is the best way to add the Ajax search?

    I have been attempting to modify the result page horizontal.php, but I think it would be better to integration with the WP template I use.

    Here is an example of my first attempted, but the formatting isn’t working.

    Pro Ajax Sample Page

    Here is the page that I want to integrate Ajax Pro Search into

    Current Listing Page

    Real Estate Pro 7 Listing Widget

    
    <?php
    /**
     * Listings
     *
     * @package WP Pro Real Estate 7
     * @subpackage Widget
     */
     
    class ct_Listings extends WP_Widget {
    
    	function __construct() {
    	   $widget_ops = array('description' => 'Display your latest listings.' );
    	   parent::__construct(false, __('CT Listings', 'contempo'),$widget_ops);      
    	}
    
    	function widget($args, $instance) {  
    		extract( $args );
    		$title = $instance['title'];
    		$number = $instance['number'];
    		$taxonomy = $instance['taxonomy'];
    		$tag = $instance['tag'];
    		$viewalltext = $instance['viewalltext'];
    		$viewalllink = $instance['viewalllink'];
    	?>
    		<?php echo $before_widget; ?>
    		<?php if ($title) { echo $before_title . $title . $after_title; }
    
    		echo '<ul>';
    
    		global $ct_options;
    		$ct_search_results_listing_style = isset( $ct_options['ct_search_results_listing_style'] ) ? $ct_options['ct_search_results_listing_style'] : '';
    
    		global $post;
    		global $wp_query;
    
            wp_reset_postdata();
    		
    		$args = array(
                'post_type' =&gt; 'listings', 
                'order' =&gt; 'DSC',
    			$taxonomy =&gt; $tag,
                'posts_per_page' =&gt; $number,
                'tax_query' =&gt; array(
                	array(
    				    'taxonomy'  =&gt; 'ct_status',
    				    'field'     =&gt; 'slug',
    				    'terms'     =&gt; 'ghost', // exclude media posts in the news-cat custom taxonomy
    				    'operator'  =&gt; 'NOT IN'
    			    ),
                )
    		);
    		$wp_query = new wp_query( $args ); 
                
            if ( $wp_query-&gt;have_posts() ) : while ( $wp_query-&gt;have_posts() ) : $wp_query-&gt;the_post(); ?&gt;
            
                &lt;li class="listing &lt;?php echo $ct_search_results_listing_style; ?&gt;"&gt;
    	            &lt;?php if(has_post_thumbnail()) { ?&gt;
                    &lt;figure&gt;
                    	&lt;?php
    	           			if(has_term( 'featured', 'ct_status' ) ) {
    							echo '&lt;h6 class="snipe featured"&gt;';
    								echo '&lt;span&gt;';
    									echo __('Featured', '');
    								echo '&lt;/span&gt;';
    							echo '&lt;/h6&gt;';
    						}
    					?&gt;
    		            &lt;?php
    		            	$status_tags = strip_tags( get_the_term_list( $wp_query-&gt;post-&gt;ID, 'ct_status', '', ' ', '' ) );
    		            	if($status_tags != ''){
    							echo '&lt;h6 class="snipe status ';
    									$status_terms = get_the_terms( $wp_query-&gt;post-&gt;ID, 'ct_status', array() );
    									if ( ! empty( $status_terms ) &amp;&amp; ! is_wp_error( $status_terms ) ){
    									    foreach ( $status_terms as $term ) {
    									    	echo esc_html($term-&gt;slug) . ' ';
    									    }
    									}
    								echo '"&gt;';
    								echo '&lt;span&gt;';
    									echo esc_html($status_tags);
    								echo '&lt;/span&gt;';
    							echo '&lt;/h6&gt;';
    						}
    					?&gt;
    		            &lt;?php ct_property_type_icon(); ?&gt;
    	                &lt;?php ct_listing_actions(); ?&gt;
    		            &lt;?php ct_first_image_linked_widget(); ?&gt;
    		        &lt;/figure&gt;
    		        &lt;?php } ?&gt;
    		        &lt;div class="grid-listing-info"&gt;
    		            &lt;header&gt;
    		                &lt;h5 class="marB0"&gt;<a>&gt;&lt;?php ct_listing_title(); ?&gt;</a>&lt;/h5&gt;
    		                &lt;p class="location marB0"&gt;&lt;?php city(); ?&gt;, &lt;?php state(); ?&gt; &lt;?php zipcode(); ?&gt;&lt;?php country(); ?&gt;&lt;/p&gt;
    		            &lt;/header&gt;
    		            &lt;p class="price marB0"&gt;&lt;?php ct_listing_price(); ?&gt;&lt;/p&gt;
    		            &lt;ul class="propinfo marB0"&gt;
    		            	&lt;?php ct_propinfo(); ?&gt;
    		            </ul>
    		            &lt;?php ct_listing_creation_date(); ?&gt;
    		            &lt;?php ct_brokered_by(); ?&gt;
                        &lt;div class="clear"&gt;&lt;/div&gt;
                </li>
    
            &lt;?php endwhile; endif; wp_reset_postdata(); ?&gt;
    		
    		&lt;?php echo '</ul>'; ?&gt;
            
               &lt;?php if($viewalltext) { ?&gt;
                   &lt;p id="viewall"&gt;<a>"&gt;&lt;?php echo esc_html($viewalltext); ?&gt; <em>&rarr;</em></a>&lt;/p&gt;
               &lt;?php } ?&gt;
    		
    		&lt;?php echo $after_widget; ?&gt;   
        &lt;?php
       }
    
       function update($new_instance, $old_instance) {                
    	   return $new_instance;
       }
    
       function form($instance) {
    		
    		$title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
    		$number = isset( $instance['number'] ) ? esc_attr( $instance['number'] ) : '';
    		$taxonomy = isset( $instance['taxonomy'] ) ? esc_attr( $instance['taxonomy'] ) : '';
    		$tag = isset( $instance['tag'] ) ? esc_attr( $instance['tag'] ) : '';
    		$viewalltext = isset( $instance['viewalltext'] ) ? esc_attr( $instance['viewalltext'] ) : '';
    		$viewalllink = isset( $instance['viewalllink'] ) ? esc_attr( $instance['viewalllink'] ) : '';
    		
    		?&gt;
    		&lt;p&gt;
    		   &lt;label for="&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;"&gt;&lt;?php esc_html_e('Title:','contempo'); ?&gt;&lt;/label&gt;
    		   &lt;input type="text" name="&lt;?php echo $this-&gt;get_field_name('title'); ?&gt;"  value="&lt;?php echo esc_attr($title); ?&gt;" class="widefat" id="&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;" /&gt;
    		&lt;/p&gt;
    		&lt;p&gt;
                &lt;label for="&lt;?php echo $this-&gt;get_field_id('number'); ?&gt;"&gt;&lt;?php esc_html_e('Number:','contempo'); ?&gt;&lt;/label&gt;
                &lt;select name="&lt;?php echo $this-&gt;get_field_name('number'); ?&gt;" class="widefat" id="&lt;?php echo $this-&gt;get_field_id('number'); ?&gt;"&gt;
                    &lt;?php for ( $i = 1; $i &lt;= 10; $i += 1) { ?&gt;
                    &lt;option value="&lt;?php echo $i; ?&gt;" &lt;?php if($number == $i){ echo "selected='selected'";} ?&gt;&gt;&lt;?php echo $i; ?&gt;&lt;/option&gt;
                    &lt;?php } ?&gt;
                &lt;/select&gt;
            &lt;/p&gt;
            &lt;p&gt;
                &lt;label for="&lt;?php echo $this-&gt;get_field_id('taxonomy'); ?&gt;"&gt;&lt;?php esc_html_e('Taxonomy:','contempo'); ?&gt;&lt;/label&gt;
                &lt;select name="&lt;?php echo $this-&gt;get_field_name('taxonomy'); ?&gt;" class="widefat" id="&lt;?php echo $this-&gt;get_field_id('taxonomy'); ?&gt;"&gt;
                    &lt;?php
    				foreach (get_object_taxonomies( 'listings', 'objects' ) as $tax =&gt; $value) { ?&gt;
                    &lt;option value="&lt;?php echo $tax; ?&gt;" &lt;?php if($taxonomy == $tax){ echo "selected='selected'";} ?&gt;&gt;&lt;?php echo $tax; ?&gt;&lt;/option&gt;
                    &lt;?php } ?&gt;
                &lt;/select&gt;
            &lt;/p&gt;
            &lt;p&gt;
    		   &lt;label for="&lt;?php echo $this-&gt;get_field_id('tag'); ?&gt;"&gt;&lt;?php esc_html_e('Tag:','contempo'); ?&gt;&lt;/label&gt;
    		   &lt;input type="text" name="&lt;?php echo $this-&gt;get_field_name('tag'); ?&gt;"  value="&lt;?php echo $tag; ?&gt;" class="widefat" id="&lt;?php echo $this-&gt;get_field_id('tag'); ?&gt;" /&gt;
    		&lt;/p&gt;
            &lt;p&gt;
    		   &lt;label for="&lt;?php echo $this-&gt;get_field_id('viewalltext'); ?&gt;"&gt;&lt;?php esc_html_e('View All Link Text','contempo'); ?&gt;&lt;/label&gt;
    		   &lt;input type="text" name="&lt;?php echo $this-&gt;get_field_name('viewalltext'); ?&gt;"  value="&lt;?php echo $viewalltext; ?&gt;" class="widefat" id="&lt;?php echo $this-&gt;get_field_id('viewalltext'); ?&gt;" /&gt;
    		&lt;/p&gt;
            &lt;p&gt;
    		   &lt;label for="&lt;?php echo $this-&gt;get_field_id('viewalllink'); ?&gt;"&gt;&lt;?php esc_html_e('View All Link URL','contempo'); ?&gt;&lt;/label&gt;
    		   &lt;input type="text" name="&lt;?php echo $this-&gt;get_field_name('viewalllink'); ?&gt;"  value="&lt;?php echo $viewalllink; ?&gt;" class="widefat" id="&lt;?php echo $this-&gt;get_field_id('viewalllink'); ?&gt;" /&gt;
    		&lt;/p&gt;
    		&lt;?php
    	}
    } 
    
    register_widget('ct_Listings');
    ?&gt;
    #19062

    Hi!

    Thank you for the details, it helps us a lot!

    Unfortunately the link to the page, where the plugin should be visible is broken. I am not entirely sure, what exactly are you trying to achieve yet. I believe, that the best possible implementation always depends on the situation. Usually, using the plugin shortcode on a page is the best way.

    You can also enable search results page override, so when redirecting to the results page, the plugin will try to push it’s own result to the results page template.

    Best,
    Ernest Marcinko

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


    #19067

    Participant

    Hi- Sorry, the page was set to private.

    Here is the layout of the current Portflio Listing
    Current Results

    I want to add ASP to this page layout. I modified the ASP horizontal results page, but here

    Beta ASP Layout

    But I have been unable to match the layout of the original Portfolio Listing.

    modified horizontal.php

    
    &lt;?php
    /* Prevent direct access */
    defined('ABSPATH') or die("You can't access this file directly.");
    
    /**
     * This is the default template for one horizontal result
     *
     * !!!IMPORTANT!!!
     * Do not make changes directly to this file! To have permanent changes copy this
     * file to your theme directory under the "asp" folder like so:
     *    wp-content/themes/your-theme-name/asp/horizontal.php
     *
     * It's also a good idea to use the actions to insert content instead of modifications.
     *
     * You can use any WordPress function here.
     * Variables to mention:
     *      Object() $r - holding the result details
     *      Array[]  $s_options - holding the search options
     *
     * DO NOT OUTPUT ANYTHING BEFORE OR AFTER THE &lt;div class='item'&gt;..&lt;/div&gt; element
     *
     * You can leave empty lines for better visibility, they are cleared before output.
     *
     * MORE INFO: https://wp-dreams.com/knowledge-base/result-templating/
     *
     * @since: 4.0
     */
    ?&gt;
    &lt;div class='vc_row wpb_row vc_row-fluid item listing col standard&lt;?php echo apply_filters('asp_result_css_class', $asp_res_css_class); ?&gt;'&gt;
    
        &lt;?php do_action('asp_res_horizontal_begin_item'); ?&gt;
    	
    &lt;?php
      $propertyid = $r-&gt;id;
      
      $ct_property_type = strip_tags( get_the_term_list( $propertyid, 'property_type', '', ', ', '' ) );
      $price = get_post_meta( $r-&gt;id, '_ct_price', true );
      $sqft = get_post_meta( $r-&gt;id, '_ct_sqft', true );
      $lotsize = get_post_meta( $r-&gt;id, '_ct_lotsize', true );
      $beds = strip_tags( get_the_term_list( $r-&gt;id, 'beds', '', ', ', '' ) );
      $baths = strip_tags( get_the_term_list( $r-&gt;id, 'baths', '', ', ', '' ) );
      $thumbnail = get_the_post_thumbnail( $r-&gt;id);  
      $description = strip_tags(get_post_field('post_content', $r-&gt;id));
      $shortdescription = substr($description,0,200);
      $link = $r-&gt;link;
      $status_tags = strip_tags( get_the_term_list( $propertyid, 'ct_status', '', ' ', '' ) );
      $city = strip_tags( get_the_term_list( $r-&gt;id, 'city', '', ', ', '' ) );
      $state = strip_tags( get_the_term_list( $r-&gt;id, 'state', '', ', ', '' ) );
      $zip = strip_tags( get_the_term_list( $r-&gt;id, 'zipcode', '', ', ', '' ) );
      $alttitle = get_post_meta( $r-&gt;id, '_ct_listing_alt_title', true );
      
    
    
    ?&gt;
    	
    	
    	
    
        &lt;?php if (!empty($r-&gt;image)): ?&gt;
            <a>link; ?&gt;'&lt;?php echo ($s_options['results_click_blank'])?" ' target='_blank'":""; ?&gt;&gt;
    			&lt;figure&gt;
    			
    				&lt;?php
    				if($status_tags != ''){
    					echo '&lt;h6 class="snipe status  ';
    							$status_terms = get_the_terms( $propertyid, 'ct_status', array() );
    			
    							    foreach ( $status_terms as $term ) {
    							    	echo esc_html($term-&gt;slug) . ' ';
    							    }
    			
    						echo '"style="display:block"&gt;';
    						echo '&lt;span&gt;';
    							echo esc_html($status_tags);
    						echo '&lt;/span&gt;';
    					echo '&lt;/h6&gt;';
    				}
    				echo '&lt;div class="propertyThumb"&gt;'.$thumbnail.'&lt;/div&gt;';
    					echo '&lt;span class="prop-type-icon"&gt;&lt;i class="fa fa-home"&gt;&lt;/i&gt;&lt;/span&gt;'; 
    				?&gt;
    			&lt;/figure&gt;
    			
    			
            </a>
        &lt;?php endif; ?&gt;
    
        &lt;?php do_action('asp_res_horizontal_after_image'); ?&gt;
    
        &lt;div class='asp_content'&gt;
    
    	&lt;div class="grid-listing-info"&gt;
    		&lt;header&gt;
            &lt;h5&gt;<a>link; ?&gt;'&lt;?php echo ($s_options['results_click_blank'])?" target='_blank'":""; ?&gt;&gt;&lt;?php echo $alttitle; ?&gt;
                &lt;?php if ($s_options['resultareaclickable'] == 1): ?&gt;
                &lt;span class='overlap'&gt;&lt;/span&gt;
                &lt;?php endif; ?&gt;
            </a>&lt;/h5&gt;
    		&lt;p class="location marB0"&gt;&lt;?php echo $city;?&gt;, &lt;?php echo $state;?&gt; &lt;?php echo $zip;?&gt;&lt;/p&gt;
    		&lt;/header&gt;
    	&lt;/div&gt;
            &lt;div class='etc'&gt;
    
                &lt;?php if ($s_options['showauthor'] == 1): ?&gt;
                    &lt;span class='asp_author'&gt;&lt;?php echo $r-&gt;author; ?&gt;&lt;/span&gt;
                &lt;?php endif; ?&gt;
    
                &lt;?php if ($s_options['showdate'] == 1): ?&gt;
                    &lt;span class='asp_date'&gt;&lt;?php echo $r-&gt;date; ?&gt;&lt;/span&gt;
                &lt;?php endif; ?&gt;
    
            &lt;/div&gt;
    
            &lt;?php if ($s_options['showdescription'] == 1): ?&gt;
                &lt;?php if (!empty($r-&gt;image) &amp;&amp; $s_options['hhidedesc'] == 0): ?&gt;
                &lt;?php echo $r-&gt;content; ?&gt;
                &lt;?php endif; ?&gt;
            &lt;?php endif; ?&gt;
    
        &lt;/div&gt;
    
        &lt;?php do_action('asp_res_horizontal_after_content'); ?&gt;
    
        &lt;div class='clear'&gt;&lt;/div&gt;
    
        &lt;?php do_action('asp_res_horizontal_end_item'); ?&gt;
    
    &lt;/div&gt;
    #19071

    Participant

    Does the horizontal.php add the template CSS?

    #19072

    Participant

    Also, how do I pull in additional meta and terms?

    #19083

    Hi!

    Please note, that customizations are not part of the support process. I will try to help you as much as I can, but I cannot guarantee anything here.

    I think this is a bit overly complicated in places. Can you please check the FTP access? I am not able to open the public_html directory with the credentials. Thank you!

    Best,
    Ernest Marcinko

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


    #19086

    Participant

    I understand this is beyond your support process, I apologize. I really like the functionality of the plugin and it is a unique function that I would like to implement in this website and several others. I appreciate you pointing me in the right direction, but also know you can’t focus a significant amount of your time on a single licensee.

    I have corrected the FTP access.

    #19090

    Participant

    Hello-

    I worked out my layout issue, I had to create entirely new div and CSS, but it is working, so thank you for your office of assistance, but I have solved that issue.

    If you have an quick answer for this.

    I need to order the results _ct_status and _ct_price. _ct_status is a term and _ct_price is a postmeta.

    I put these in the General Options->ordering but it seems to have no consequence on the how the results are displayed.

    #19091

    Hi!

    Great job!

    Ordering by a taxonomy term is not possibe there, but the custom field should work. I cannot access the site right now, I am getting a wordfence error, so I cannot check: https://image.ibb.co/n7EJ8U/download.png

    Best,
    Ernest Marcinko

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


    #19116

    Participant

    Hi-

    The URL login is:

    https://www.carswellandpartners.com/userlogin

    I have unblocked your IP, I assumed it was the ones from Turkey.

    I need to be able to change the order of the results so they are sorted by the _ct_status in a certain order based on taxonomy , then the _ct_price DSC.

    Is there a way to take $r and change the order of the array before it is sent to the horizontal.php template or something like that.

    Thanks!

    #19132

    Sure!

    The asp_results filter is the one you are looking for. That you can use to manipulate results before they are passed to the result template files.

    Best,
    Ernest Marcinko

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


Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.