Home › Forums › MapPress Support › Mashup Popup template
- This topic has 21 replies, 2 voices, and was last updated 2 years, 12 months ago by
Chris.
-
AuthorPosts
-
May 22, 2019 at 4:27 am #18330
Chris
KeymasterHi,
Can you share your popup template? I’m wondering if maybe the error is there.
May 23, 2019 at 5:43 am #18332monsieurgraphiste
ParticipantHi 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 ?
May 23, 2019 at 5:43 am #18333monsieurgraphiste
ParticipantSorry there is no € symbol after {{poi.props.prix}}.
May 23, 2019 at 5:57 am #18334Chris
KeymasterHi
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}}} €
May 23, 2019 at 9:40 am #18335monsieurgraphiste
ParticipantHi 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
May 23, 2019 at 9:41 am #18337Chris
KeymasterMaybe 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/
May 23, 2019 at 9:42 am #18336monsieurgraphiste
ParticipantDo 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>
ThanksMay 24, 2019 at 3:05 am #18338monsieurgraphiste
ParticipantHi 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
-
AuthorPosts
- You must be logged in to reply to this topic.