Vizualization Googlemaps Bubble Formatting

darkroast

Member
Couple of issues I'm having with formatting the pop-up bubble template in a Google Maps visualization. Here's the site / page I'm having issues with: http://gls2.darkroasthosting.com/index.php/ministry-partners

Click on the (only, at this point) icon, and you'll see what I'm noticing.

1. The bubble map seems to be adding extra <br /> at the top and bottom of the bubble, as well as within the bubble itself. There are places in the template where I'm using a <br /> to generate a new line, but it's not supposed to be doing it everwhere.

2. One of the elements I'm trying to display is a website (link) element; it's not displaying correctly.

3. One of the fields is an email field. It's defined as a "field" element; is there any way to make it a linked field? Would I want to set that element as a "link" type? If so, there's the same problem as with #3. Also, is it possible to have the email link simply be text ("Send an Email") instead of the actual email address (for spam prevention)?
 
we'd also convert any "\n" into a "<br />" I believe so:

"One line
Two lines"

would be rendered as :

"One line<br />Two lines"

would that explain what you are seeing?

2 - what bubble template code are you using?

3- Say you're elemetn's full name is "your___email" then this would work:

Code:
 "<a href="mailto:{your___email}">Send an email</a>

Note that wont help for spam as the email is still in the page source code, better to poiint to a contact form or similar.
 
Ok, cool - I used the code for the email field you provided, and that worked perfectly! I also tried using the same format for the website, but that didn't work quite right. I think it might be a result of how the website link element type gets pulled into the popup. If all else fails, I can simply make this element a regular field element, and that should fix that.

I'm not sure that extra new line characters are the issue. I don't have any in the code, which looks like this:

Code:
<div id="viz_bubble">
<h1>{partner_name}</h1>
{partner_address}
{partner_city} {partner_state}, {partner_zip}
<br />
<a href="{partner_website}">Visit Our Website</a>
<a href="mailto:{partner_email}">Send an email</a>
{partner_phone}
</div>

There doesn't seem to be any extra characters there.
 
Not sure what's causing so many br's. As Rob said, we replace newlines with br's, but that doesn't explain the 3 of them after each line, there should only be one.

Can you test this, by editing the ./plugins/fabrik_visualization/googlemap/models/googlemap.php, and around line 534 should be:

PHP:
					$html = str_replace(array("\n\r"), "<br />", $html);
					$html = str_replace(array("\n", "\r"), "<br />", $html);

Comment those two lines out thusly:

PHP:
					// $html = str_replace(array("\n\r"), "<br />", $html);
					// $html = str_replace(array("\n", "\r"), "<br />", $html);

... and see how many br's you get.

BTW, if those lines are at a significantly different line number, you should probably do a github update. I've been tweaking and fixing some other stuff in that code in the last few weeks.

-- hugh
 
OBTW ...

I'm not sure that extra new line characters are the issue. I don't have any in the code, which looks like this:

Well, you do have newlines in there. Any time you hit "Enter" to create a new line in the template, that's a new line. So if you have ...

Code:
Line One.
Line Two.[code]

... after we run the template through nl2br(), that becomes:

[code]Line One.
<br />
Line Two.

So if you put ...

Code:
Line One.
<br />
Line Two.

... that becomes ...

Code:
Line One.
<br />
<br />
<br />
Line Two.

... which ... thinking about it, would explain those three br's between lines. The one we put after Line One, your original br, and the one we put after your br line. :)

I think what I'll do is put in an option for "Convert newlines to <br>", so you can control whether we do this or not. Set to "No" it would then put you completely in charge of where you put your line breaks.

Oh, and yes, looks like we are rending the 'link' element incorrectly. Looking at your page, I see that we are using the entire JSON structure we store in the table, with the...

Code:
{"label":"text of label","link":"htttp://somethig.com"}

... instead of an actual rendered link. I'll take a look at that.

-- hugh
 
I've added a modification yesterday because
"\r\n" (which is inserted for a new line on my site - maybe windows) was replaced by 2 <br>s
I think this will reduce some of the new lines.

But every new line is replaced by <br/> (hopefully only one now), so
xxx
<br/>
yyy
will be displayed as
x
You only need to put
to get one empty line (or
xx<br/><br/>yyy
 
Yeah, hopefully I fixed that. Explained in my comment:

PHP:
					if ($template_nl2br)
					{
						// $$$ hugh - not sure why we were doing this rather than nl2br?
						// If there was a reason, this is still broken, as it ends up inserting
						// two breaks.  So if we can't use nl2br ... I need fix this before using it again!
						/*
						$html = str_replace(array("\n\r"), "<br />", $html);
						$html = str_replace(array("\n", "\r"), "<br />", $html);
						*/
						$html = nl2br($html, true);
					}

... in the code I'm about to commit. I added the $ntemplate_nl2br test, on a new option so you can just turn off our nl2br conversion. And I commented those funky str_replace()'s out, and just used nl2br().

As mentioned, if there was some good reason we weren't using nl2br() before, I'll have to fix those lines. But it works fine for me. Haven't tested it on a Windows box though.

-- hugh
 
OK, the reason the link element isn't working is almost certainly it's not set to be shown on your List.

In the list rendering code, we typically don't render elements which aren't being displayed in the list. This can save a huge amount of processing, especially for lists with lots of elements, only a few of which are shown in the list.

We try and be intelligent about it, but we aren't intelligent enough. For instance, we'll render them all if you have a group template on your list which uses placeholders. But ... we don't have any exceptsions for map viz bubble templates.

So ... I'm going to add another element option, in the List settings, similar to the existing "Include in list query", for "Always render". And use that so you can force rendering for an element, if Fabrik isn't smart enough to work out that it needs to render it.

That might take a while, as there's a few places changes need to be made for that. So for now, just include that in the List display, and it should magically start rendering properly in your map bubble template.

-- hugh
 
Ah, I think I see a way of working round this with just a couple of lines.

I noticed I'd already added a formatAll() option in the list model, when I was last working on the 'email' form plugin, for a very similar reason. So I can work round it the same way. Not quite as efficient, as it'll force rendering of all element if you use a bubble template, but I don't see that being a huge problem.

-- hugh
 
Hmmm.

Well, apparently that won't work, due to the way we now render the list, via a cache callback.

Rob - is there any "official" way of working round that? I want to access $this->_formatAll inside finesseData(), but because that's called via call_user_func, $this isn't in scope, and we load the $listModel form scratch.

So formatAll() no longer works the way I originally wrote it, with a plugin being able to call $listModel->formatAll(true) before calling getData().

-- hugh
 
OK, I went about it in a different way, and implemented a new element option, "Always Render". It's in the List Settings tab.

This should work for any element which you have set to NOT show in the list, but you still want us to render for display, if you need to use it in things like the map viz bubble templates.

So next time you update from github, you should be able to turn "show in list" off, and "always render" on instead.

-- hugh
 
[solved]

Ok... let's see:

I did a github update with the latest as of today. I now have Fabrik 3.0.7. That seems to have fixed the issue.

Also, I used the "Always Render" option for the link and that works now too!

Thanks, folks. I'll mark this one as solved.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top