Mashup Popup template

Home Forums MapPress Support Mashup Popup template

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #18330
    Chris
    Keymaster

    Hi,

    Can you share your popup template?  I’m wondering if maybe the error is there.

    #18332
    monsieurgraphiste
    Participant

    Hi Chris,

    Sure, here it is :

    <h3>{{{poi.title}}}</h3>
    {{{poi.thumbnail}}}
    <br />
    <ul class="infos">
    <# if (poi.props.annonce_surface) { #>
    <i class="fal fa-home" aria-hidden="true"></i> {{poi.props.annonce_surface}} m²
    <# } #>
    <i class="fal fa-bed" aria-hidden="true"></i> {{poi.props.annonce_chambres}} chambre(s)
    <i class="fal fa-bath" aria-hidden="true"></i> {{poi.props.annonce_sdb}} SDB
    {{poi.props.prix}} €
    
    
    

     

    Maybe do you prefer WP admin access to check what’s wrong ?

    #18333
    monsieurgraphiste
    Participant

    Sorry there is no € symbol after {{poi.props.prix}}.

    #18334
    Chris
    Keymaster

    Hi

    I see a few small problems in the filter & template:

    1) For the filter, you begin by appending to $html, but it’s not defined yet.  So replace:

    $html .= '<span class="price label label-warning">';

    with:

     $html = '<span class="price label label-warning">';

    2) In the template, I’d suggest using ‘<span>’ instead of ‘i’.  Also, when you use two braces the HTML is escaped – i.e. the returned HTML from the filter was being escaped.  Use 3 braces instead, which outputs the value without modifying it:

    <h3>{{{poi.title}}}</h3>
    {{{poi.thumbnail}}}
    <br />
    <ul class="infos">
    <# if (poi.props.annonce_surface) { #>
    <span class="fal fa-home" aria-hidden="true"></span> {{poi.props.annonce_surface}} m²
    <# } #>
    <span class="fal fa-bed" aria-hidden="true"></span> {{poi.props.annonce_chambres}} chambre(s)
    <span class="fal fa-bath" aria-hidden="true"></span> {{poi.props.annonce_sdb}} SDB
    {{{poi.props.prix}}} €
    #18335
    monsieurgraphiste
    Participant

    Hi Chris,

    Thanks for the updated code.

    I’m always having trouble displaying price.

    I returns “ARRAY” value for $price.

    here is the updated function :

    function myfilter($props, $postid, $poi) {
    $price = get_post_meta( $postid, ‘annonce_prix’ );
    $html = $price;
    $html .= ‘ €’;
    if ( has_term( ‘location’, ‘offre’, $postid ) )
    $html .= ‘<small> / mois</small>’;
    if ( has_term( ‘location-saisonniere’, ‘offre’, $postid ) )
    $html .= ‘<small> / nuit</small>’;
    $props[‘prix’] = $html;
    return $props;

    }

    Mashup : <span class=”price label label-warning”>{{{poi.props.prix}}}</span>

    Thanks for your help

    #18337
    Chris
    Keymaster

    Maybe specify the last argument ‘single’ = true for get_post_meta, otherwise I think it will return an array:

    https://developer.wordpress.org/reference/functions/get_post_meta/

    #18336
    monsieurgraphiste
    Participant

    Do you know why the PHP function number_format is not working ?
    <p class=”prettyprint prettyprinted”><span class=”pln”> $html </span><span class=”pun”>=</span><span class=”pln”> number_format</span><span class=”pun”>(</span><span class=”pln”> $price</span><span class=”pun”>,</span> <span class=”lit”>0</span><span class=”pun”>,</span> <span class=”str”>’,'</span><span class=”pun”>,</span> <span class=”str”>’ ‘</span> <span class=”pun”>)</span> <span class=”pun”>.</span> <span class=”str”>’ € ‘</span><span class=”pun”>;</span></p>
    Thanks

    #18338
    monsieurgraphiste
    Participant

    Hi again Chris,

    It works like a charm now.

    Thanks for all your help.

    number_format is also OK.

    Have a good day and a good weekend

Viewing 8 posts - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.