• Sorry for all of the new threads… I just have so many little pieces that I need to figure out.

    Another thing I was hoping I could get help with was getting the directions URL, not the full formatted link. I have a custom listing template and have found the full link, but I need just the URL to place a new link around the address.

    I have done this:

    <a href="https://maps.google.com/maps?saddr=&daddr=<%= address %>,<%= city %>,<%= country %>" target="_blank"></a>

    But because it is not URL encoded, there is a chance it could not work…

    Thanks.
    Rob

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    I didn’t test it, but the normal way is like this.

    
    destinationAddress = this.address + ", " + this.city + ", " + zip + this.country;
    
    url.src = "https://maps.google.com/maps?saddr=" + templateHelpers.rfc3986EncodeURIComponent( startAddress ) + "&daddr=" + templateHelpers.rfc3986EncodeURIComponent( destinationAddress ) + "";
    
    Maybe try this in the template code?
    
    

    rfc3986EncodeURIComponent( <%= address %>,<%= city %>,<%= country %> )
    `

    ?

    Thread Starter Rob_Huska

    (@rob_huska)

    Here is my listing template code:

    
    add_filter( 'wpsl_listing_template', 'custom_listing_template' );
    function custom_listing_template() {
    
        global $wpsl, $wpsl_settings;
    
    	ob_start(); ?>
    
    		<li data-store-id="<%= id %>">
    			<div class="wpsl-store-location">
    				<ul class="wpsl-store-info">
    					<li><h2><?= wpsl_store_header_template( 'listing' ); ?></h2></li>
    					<li>
    						<i class="icon--location"></i>
    						<a href="https://maps.google.com/maps?saddr=&daddr=<%= address %>,<%= city %>,<%= country %>" target="_blank">
    							<%= address %>
    
    							<% if ( address2 ) { %>
    								<span><%= address2 %></span>
    							<% } %>
    
    							<span><?= wpsl_address_format_placeholders(); ?></span>
    						</a>
    					</li>
    
    					<?php if ( !$wpsl_settings['hide_country'] ) { ?>
    						<li><%= country %></li>
    					<?php } ?>
    
    					<?php if ( $wpsl_settings['show_contact_details'] ) { ?>
    						<% if ( phone ) { %>
    							<li><i class="icon--phone"></i> <span class="wpsl-phone"><%= formatPhoneNumber( phone ) %></span> <span class="call">Call for Product Availability</span></li>
    						<% } %>
    						<% if ( fax ) { %>
    							<li><i class="icon--fax"></i> <%= fax %></li>
    						<% } %>
    						<% if ( email ) { %>
    							<li><i class="icon--mail"></i> <%= email %></li>
    						<% } %>
    					<?php } ?>
    
    				</ul>
    				<?= wpsl_more_info_template(); ?>
    
    			</div>
    			<div class="wpsl-direction-wrap">
    				<%= thumb %>
    
    				<?php if ( !$wpsl_settings['hide_distance'] ) { ?>
    					<%= distance %><?= esc_html( wpsl_get_distance_unit() ); ?>
    				<?php } ?>
    
    				<%= createDirectionUrl() %>
    			</div>
    		</li>
    		
    	<?php $listing_template = ob_get_clean();
    
    	return $listing_template;
    }
    

    (I converted everything to use an output buffer instead of a concatenating variable, it is just easier for me to see syntax)

    Where are you saying I could add that?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Directions URL in results list’ is closed to new replies.