Mats

Module: Leaflet Map

Recommended Posts

@Juergen In leaflet JS there is a method invalidateSize() which checks if the size of the map container has changed and then updates the map.

When you call the UIKit modal, the size of the map container changes and therefore your map needs to be updated manually.

So you need to listen to the show.uk.modal event and attach a handler that updates the leaflet map.

The problem here is that the map object is not easily accessible from the global document scope because the JS that renders the map is executed inside an anonymous function call.

You should find a script like this just before the closing </body> tag:

<script type="text/javascript">
 $(function() {
var mleafletmap1 = new jsMarkupLeafletMap();
mleafletmap1.setOption('zoom', 18);

mleafletmap1.init('mleafletmap1', 49.572056, 10.878165, 'OpenStreetMap.Mapnik');
var default_marker_icon = L.AwesomeMarkers.icon({ icon: 'home', iconColor: 'white', prefix: 'fa', markerColor: 'darkblue' });
mleafletmap1.addMarkerIcon(default_marker_icon, 49.572056, 10.878165, '/maptest/', 'maptest', '');
});
</script>

So if you try and get the map object with $(mleafletmap1), this will not return what you need.

In order to have the map object available in global scope, you need to change some module code. You can find the changes at my fork in MarkupLeafletMap.module. Just copy this over your local file.

Now the script before the closing </body> tag should look something like this:

<script type="text/javascript">
var mymap;
 $(function() {
var mleafletmap1 = new jsMarkupLeafletMap();
mleafletmap1.setOption('zoom', 18);

mleafletmap1.init('mleafletmap1', 49.572056, 10.878165, 'OpenStreetMap.Mapnik');
var default_marker_icon = L.AwesomeMarkers.icon({ icon: 'home', iconColor: 'white', prefix: 'fa', markerColor: 'darkblue' });
mleafletmap1.addMarkerIcon(default_marker_icon, 49.572056, 10.878165, '/maptest/', 'maptest', '');
mymap = mleafletmap1;
});
</script>

And you can now access the map object in your script with mymap.map. Example code:

<script>
	var myModal = $('#yourmodalID');
	mymodal.on('show.uk.modal', function(){
		mymap.map.invalidateSize(true);
	})
</script>

While this is just a workaround it should help to display the map correctly.

@Mats Maybe we should add something like this to the module code so in future versions a map object will be returned by default? Or do you see another way to access the map object with the module as is?

  • Like 2

Share this post


Link to post
Share on other sites

Thanks @gebeer

but after replacing the MarkupLeafletMap.module file with your version, the map will be not rendered at all. So its not a big problem. I can view the map without modal too. A code modification is not what I want.  But thousand thanks for your efforts.

Best regards

Share this post


Link to post
Share on other sites

@gebeer

I tested it on the V3 version and changed the content of the files as suggested. The map in the screen stays blank and the consoles says:

==> jquery.min.js:2:31515
jQuery.Deferred exception: t is undefined o.Util.trim@https://unpkg.com/leaflet@1.0.3/dist/leaflet.js:5:1149
o.Util.splitWords@https://unpkg.com/leaflet@1.0.3/dist/leaflet.js:5:1230
o.Evented<.on@https://unpkg.com/leaflet@1.0.3/dist/leaflet.js:5:3878
L.MarkerClusterGroup<.initialize@http://durvenleven.be/pw/site/modules/FieldtypeLeafletMapMarker/assets/leaflet-markercluster/leaflet.markercluster.js:6:515
o.Class.extend/e@https://unpkg.com/leaflet@1.0.3/dist/leaflet.js:5:2729
jsMarkupLeafletMap@http://durvenleven.be/pw/site/modules/FieldtypeLeafletMapMarker/MarkupLeafletMap.js:54:19
@http://durvenleven.be/pw/straatnamen/abraham-hansplein/:36:20
g/</j@https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:29946
g/</k<@https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:30262
 undefined

                                                                                
==> TypeError: t is undefined[Meer info]  leaflet.js:5:1149
	o.Util.trim https://unpkg.com/leaflet@1.0.3/dist/leaflet.js:5:1149
	o.Util.splitWords https://unpkg.com/leaflet@1.0.3/dist/leaflet.js:5:1230
	o.Evented<.on https://unpkg.com/leaflet@1.0.3/dist/leaflet.js:5:3878
	L.MarkerClusterGroup<.initialize http://durvenleven.be/pw/site/modules/FieldtypeLeafletMapMarker/assets/leaflet-markercluster/leaflet.markercluster.js:6:515
	o.Class.extend/e https://unpkg.com/leaflet@1.0.3/dist/leaflet.js:5:2729
	jsMarkupLeafletMap http://durvenleven.be/pw/site/modules/FieldtypeLeafletMapMarker/MarkupLeafletMap.js:54:19
	<anoniem> http://durvenleven.be/pw/straatnamen/abraham-hansplein/:36:20
	g/</j https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:29946
	g/</k< https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:30262

In InputfieldLeafletMapMarker.module - Lines 61 and 64 I also bumbed the version to 1.0.3 for the admin side and there the 'map' is working fine. (rendering-georeferring, saving etc) 

Share this post


Link to post
Share on other sites

@Pretobrazza Did you also update the leaflet-markercluster files?

Because the inputfield map is not using the marker cluster plugin.

  • Like 1

Share this post


Link to post
Share on other sites

@gebeer

I replaced/added  the content of these files in /pw/site/modules/FieldtypeLeafletMapMarker/assets/leaflet-markercluster

MarkerCluster.Default.css    add oldie styles     3 years ago
MarkerCluster.css    Corrected spiderfy leg anim and leg opacity option     2 years ago
leaflet.markercluster-src.js    Tag v1.0.4     29 days ago
leaflet.markercluster.js    Tag v1.0.4     29 days ago

EDIT: IT IS WORKING !! Thank you very much @gebeer

setup: PW 3.0.58 © 2017  Leaflet 1.0.3 with modified files as above is FieldtypeLeafletMapMarker/assets/leaflet-markercluster

Edited by Pretobrazza
Clarity for future readers having similar problem

Share this post


Link to post
Share on other sites

@Pretobrazza It might be related to the jQuery version you are using. 1.11.0 is a bit outdated. You might want to try a newer one. My map is rendering fine on 2.2.4

Share this post


Link to post
Share on other sites

Hello @gebeer

11 hours ago, gebeer said:

@Pretobrazza It might be related to the jQuery version you are using. 1.11.0 is a bit outdated. You might want to try a newer one. My map is rendering fine on 2.2.4

Unless I'm missing something important about the version of jquery on my testing page I was using //ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js in the template file. Now I changed it to  //ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js and everything is fine with the map. The testing page takes a few seconds to load as There are 600+ pw children streets which will eventually be shown in the end ;) (look at the source). 

Next step for me to endeavor into :

I saw in the options of the leaflet-PW module, that one can control the behavior of  the `markerTitleField` (or alternatively markerLinkField) which means that a sliding pane or modal window would be triggered to load the content of a page. What do I put in there? Is it possible?

I'm looking around for a versatile Leaflet script (there are many it seems) to put content in a slider pane OR modal window, so that when someone clicks in the title link  in a popup or on a marker, instead of opening a new page, in the browser, a responsive page gets called up in a sliding pane or modal window inside the map with the possibility to have extra controls around them (eg. close, fullscreen, 'like', post a comment, mailto,  etc etc).  

.... but first finding the versatile sliding window (and/or modal) script to load any type of content into is already a challenge for me as I want to stick to the latest version of PW as well as of leaflet (1.0.3)  ...  Does anyone a suggestion?

Even though there is streetview in this example, I'm convinced that with the Leaflet Map module PW will render a page like this on it's socks, not so? 

(The next step after this will be even more of a challenge.to broaden the scope of this module even further)

Share this post


Link to post
Share on other sites
31 minutes ago, Pretobrazza said:

.... but first finding the versatile sliding window (and/or modal) script to load any type of content into is already a challenge for me as I want to stick to the latest version of PW as well as of leaflet (1.0.3)  ...  Does anyone a suggestion?

A dialog box, whether sliding or animated fade, doesn't have anything to do with ProcessWire. You can use Uikit, Bootstrap, or any other css framework to present that information.

 

Share this post


Link to post
Share on other sites

Thank you for your quick reply, but in the ### Options of the leaflet-PW module, can I control the behavior of  the `markerTitleField` (or alternatively markerLinkField) which means that the dialog box  would be triggered to load the content of a page. What do I put in the the `markerTitleField` (or alternatively 'markerLinkField')  option to do so? Is it possible? Does the corresponding .js or other file in the module provide for it?

19 minutes ago, rick said:

A dialog box, whether sliding or animated fade, doesn't have anything to do with ProcessWire. You can use Uikit, Bootstrap, or any other css framework to present that information

 

Share this post


Link to post
Share on other sites

I can't give specific details as I do not use this module. In theory, however:

You can load page content into a bootstrap (just an example) dialog box via an ajax request based on the user clicking the markerTitleField and then display that dialog box.

OR

Depending on the number of clickable markerTitleFields, you could pre-load hidden containers with the appropriate content and display the corresponding dialog box.

Maybe I'm not understanding the issue, which is likely. :)

Share this post


Link to post
Share on other sites

@rick

To call the map in the test page map I use:
 

<?php $options = array('markerIcon' => 'flag', 'markerColour' => 'purple', 'markerTitleField' => 'title',); 
  echo $map->render($page, 'map'); ?>

to zoom into my question in the options I find among many others::

`markerLinkField` | Page field to use for the marker link, or blank to not link (type: string; default: url)
`markerTitleField` | Page field to use for the marker title, or blank not to use a marker title (type: string; default: title)

I'm missing something like markerTitleLinkField whereby I could call a dialog box, am I right? 

Share this post


Link to post
Share on other sites

You wouldn't necessarily create another field just to provide a link. You can use jquery to locate the title field(s) and enclose the content within the desired anchor tag. 

But isn't that what the link field is for?

Share this post


Link to post
Share on other sites

@Pretobrazza with the options markerLinkField and markerTitleField you can pass field names. The content of those fields on your page will be used as title and url within the marker popup.

To apply the options you have to pass them to the render method

<?php $options = array('markerIcon' => 'flag', 'markerColour' => 'purple', 'markerTitleField' => 'title',); 
  echo $map->render($page, 'map', $options); ?>

If you want to have additional popup content you can use the option 'popupFormatter' which is documented in the Readme.md. You can pull any content from any page and put it in the 'popupFormatter' option's callback function.

 

 

Share this post


Link to post
Share on other sites

Hello everyone,
Hello @gebeer

After having tested lots of modal rendering scripts, for 3 solid days, I ended up with Featherlighta very lightweight jQuery lightbox plugin, which seems to harness many possibilities.

  1. From a 'Title' field in a Leaflet map popup, I can now render  child pages with a map in modal windows overlaying each other.  However now I need every map to get a different ID  instead of 'mleafletmap1' otherwise they won't render. I tried to put $page->name but as soon as there are hyphens, it doesn't work. Any idea of which dynamically generated variable I could use as an ID for the maps in the base-template?
  2. In the popover  the title has to be clicked twice to fire a modal page. How (where) can I change this behavior?
  3. Even though everything is working fine inside the map, at the bottom of the modal windows with a map I find this:
$(function() { var percelen = new jsMarkupLeafletMap(); percelen.setOption('zoom', 14); percelen.setOption('scrollWheelZoom', 1); percelen.init('percelen', 51.341845581086325, 3.268561363220215, 'OpenStreetMap.Mapnik'); var default_marker_icon = L.AwesomeMarkers.icon({ icon: 'home', iconColor: 'white', prefix: 'fa', markerColor: 'green' }); });

(in a map with markers this gets much longer)

Is it an error that this appears under each modal map or is it something I will have to look into on the side of Featherlight?

In any case, at least I'm moving on now and as soon as the problems above can be solved (especially the first 2), I will start playing around with basemaps  and wms and see what happens ... 

Share this post


Link to post
Share on other sites

Hello,

I managed to render a leaflet map with wms in a barebone template in processwire.

Seen that it works, I added a new provider in leaflet-providers.js and I also updated providers.inc and providers.json files.

In leaflet-providers.js  I added:

		.......
		}, <--- didnt forget the comma ;)
		GRB: {
			url: 'https://geoservices.informatievlaanderen.be/raadpleegdiensten/GRB/wms?',
			options: {
				layers: 'GRB_BSK',
				format: 'image/png',
				transparent: true,
				attribution: 'Realized on Processwire'
			}
		}

As a proof of concept first, in order to render the map I must replace the L.tileLayer by L.tileLayer.wms somewhere in the script so that I can obtain a:

whatever = L.tileLayer.wms("https://geoservices.informatievlaanderen.be/raadpleegdiensten/GRB/wms?", {
            layers: 'GRB_BSK',
            format: 'image/png',
            transparent: true,
            attribution: "Realised on Processwire"
        }).addTo(map);

After a hint from @gebeerI tried to do so  in MarkupLeafletMap.js line 47. but I don't think I'm doing it right.  

Is there a particular syntax I should use?

Share this post


Link to post
Share on other sites

Could you consider setting scrollWheelZoom: false as option for the backend?

I inadvertently easily change carefully set zoom settings just by scrolling the edit-page with the Trackpad or mousewheel. :-)

Share this post


Link to post
Share on other sites

Hello,

Now I have come to the stage whereby I want to import hundreds of pages via CSV with addresses. 

I tried to find a solution in this forum via Google search and tried all the possibilities  that were suggested for Batch child editor  as well as in the code of the ImportPagesCSV module being used/suggested  for Ryans's MapMaker but both of them refuse to work and import the adresses, lat lng zoom in one way on another into the Leaflet mapfield.

Now I have 2 questions:

1. Is anyone succeeding at the moment to upload CSV's to the Leaflet Map addressfield?  How?   My version of PW is 3.0.61 - Leaflet V 1.03 - php 7.0. 

2. If so, here's my second question (to @gebeer,  I think?):     Say, I only upload the address, will it geocode automatically? If not can it be done or will I be to geocode the addresses externally beforehand before I upload the CSV's?

Kind regards,
Bernard   

Share this post


Link to post
Share on other sites

@Pretobrazza, I just tested CSV import of FieldtypeLeafletMapMarker fields with the ImportPagesCSV module and it works fine but needs a couple of simple modifications to the ImportPagesCSV module.

Add FieldtypeLeafletMapMarker to the array of allowed fieldtypes:

/**
 * List of Fieldtypes that we support importing to
 *
 */
protected $fieldtypes = array(
    'FieldtypePageTitle',
    'FieldtypeText',
    'FieldtypeTextarea',
    'FieldtypeInteger',
    'FieldtypeFloat',
    'FieldtypeEmail',
    'FieldtypeURL',
    'FieldtypeCheckbox',
    'FieldtypeFile',
    'FieldtypePage',
    'FieldtypeLeafletMapMarker',
    );

Tell the module how to handle the import of the FieldtypeLeafletMapMarker fieldtype:

/**
 * Assign a value to a page field 
 *
 */
protected function importPageValue(Page $page, $name, $value) {

    $field = $this->fields->get($name); 

    if($field->type instanceof FieldtypeFile) {

        $value = trim($value); 
        // split delimeted data to an array
        $value = preg_split('/[\r\n\t|]+/', $value); 
        if($field->maxFiles == 1) $value = array_shift($value);
        $data = $page->ImportPagesCSVData; 
        $data[$name] = $value; 
        $page->ImportPagesCSVData = $data; 

    } elseif($field->type instanceof FieldtypeLeafletMapMarker) {

        $value = trim($value);

        // If importing pipe-separated latitude and longitude values, e.g. "-46.0026999|168.03567"
        // list($lat,$lng) = explode('|', $value);
        // $page->$name->lat = $lat;
        // $page->$name->lng = $lng;

        // If importing address string (automatically geocoded on import)
        $page->$name->address = $value;

    } else {

        $page->set($name, $value); 
        if($name == 'title') $page->name = $this->sanitizer->pageName($value, 2); // Sanitizer::translate
    }
}

You'll see I added two ways to import the map pin location: lat/lng (commented out) or address. If you import an address string the lat and lng are geocoded automatically on import. If you import lat and lng without an address then the pin is placed at that location but no address string is automatically generated. If you were to import an address string and a lat/lng (not shown here and not recommended) then the lat/lng is ignored and the location is geocoded from the address string - i.e. the same as just importing an address string.

You could add a zoom value if you wanted - just separate from the other value(s) with a pipe and adapt the example for lat/lng, i.e. explode() and list().

Edited by Robin S
removed draft text

Share this post


Link to post
Share on other sites

Hello @Robin S,

Thank you for your reply!

Since yesterday I tried those combinations but to no avail. Just now I turned the php7 to 5.6 but there too it doesn't work for me.

In one of the existing pages I had already saved an address but after uploading 2 records with an address (with $page->$name->address = $value;) , that one too disappeared. Could it be pw 3.0.61  which causes an issue?

Tonight I tried with BCE too but there too  .. no success :(

Share this post


Link to post
Share on other sites

This morning I tried again and only found 1 error in JqueryCore.js:2:40351 ( /wire/modules/Jquery/JqueryCore):  Use of getPreventDefault() isn't supported anymore. Instead use: defaultPrevented.   ->  I did so and the error went away. 

On the other hand, when I try and drop a CSV in the the ImportPagesCSV upload box, it doesn't accept it, so I have to press the upload button. For normal fields an even pictures the the ImportPagesCSV module  is working fine but not for the Leaflet submaps.  Same problem with BCE.  

My version of PW is 3.0.61 - Leaflet V 1.03 - php 7.1  now

Share this post


Link to post
Share on other sites
On 4/11/2017 at 0:26 PM, Pretobrazza said:

@gebeer

I replaced/added  the content of these files in /pw/site/modules/FieldtypeLeafletMapMarker/assets/leaflet-markercluster

MarkerCluster.Default.css    add oldie styles     3 years ago
MarkerCluster.css    Corrected spiderfy leg anim and leg opacity option     2 years ago
leaflet.markercluster-src.js    Tag v1.0.4     29 days ago
leaflet.markercluster.js    Tag v1.0.4     29 days ago

EDIT: IT IS WORKING !! Thank you very much @gebeer

setup: PW 3.0.58 © 2017  Leaflet 1.0.3 with modified files as above is FieldtypeLeafletMapMarker/assets/leaflet-markercluster

Hi,

I face a problem that at a first glance looks so as the above ... but is different. Having pw3.0.61, after upgrading LeafletMapMarker to the last version (2.8.1), the module stopped outputting the leaflet <script> tag with its content. The <div id='mleafletmap1' ...> with its options is present, both single and multiple (21) items/pages supplied tested (1st parameter).

Would anyone know where the issue comes from and how to correct it?

The rendered html is this:
 

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="/site/templates/scripts/jquery.js"></script>
    
    <!-- Leaflet --><link rel="stylesheet" type="text/css" href="/site/modules/FieldtypeLeafletMapMarker/assets/font-awesome-4.6.3/css/font-awesome.min.css">        <!-- Styles supporting the use of Leaflet.js -->
        <link rel="stylesheet" type="text/css" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
        <link rel="stylesheet" type="text/css" href="/site/modules/FieldtypeLeafletMapMarker/assets/leaflet-markercluster/MarkerCluster.css" />
        <link rel="stylesheet" type="text/css" href="/site/modules/FieldtypeLeafletMapMarker/assets/leaflet-markercluster/MarkerCluster.Default.css" />

        <!-- Scripts supporting the use of Leaflet.js -->
        <script type="text/javascript" src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script>
        <script type="text/javascript" src="/site/modules/FieldtypeLeafletMapMarker/assets/leaflet-markercluster/leaflet.markercluster.js"></script>
        <script type="text/javascript" src="/site/modules/FieldtypeLeafletMapMarker/assets/leaflet-providers/leaflet-providers.js"></script>
        <script type="text/javascript" src="/site/modules/FieldtypeLeafletMapMarker/MarkupLeafletMap.js"></script>

        <!-- Extend Leaflet with Awesome.Markers -->
        <link rel="stylesheet" type="text/css" href="/site/modules/FieldtypeLeafletMapMarker/assets/leaflet-awesome-markers/leaflet.awesome-markers.css" />
        <script type="text/javascript" src="/site/modules/FieldtypeLeafletMapMarker/assets/leaflet-awesome-markers/leaflet.awesome-markers.min.js"></script>
</head>
<body>
<div id='mleafletmap1' class='MarkupLeafletMap' style='width: 100%; height: 700px;'></div>
</body>
</html>

 

Edited by loukote
clarification

Share this post


Link to post
Share on other sites
On 5/10/2017 at 1:25 AM, loukote said:

[...] Would anyone know where the issue comes from and how to correct it? [...]

Hm, funny: the map appears when a user is logged in the back-end, does not appear otherwise. In MarkupLeafletMap.module (version 3.0.2) on line 231 the map <div> is output and the <script> is sent to the be hooked before the </body> end-tag just after that, lines 233 to 283. @gebeer, would there be anything suspicious in the MarkupAddInlineScript.module?

Share this post


Link to post
Share on other sites

@loukote I just checked on a 3.0.61 install with leaflet 2.8.1 and 3.0.2 and here it is working as expected, even if not logged in to the backend at the same time.

This could be a permission related issue. Do you have any access restriction set on the template that renders the map?

You can check the value of $page->inlineScript on the page that you output the map after the code that renders the map. If it has a value, then the script code should be prepended to the closing </body> tag.

Share this post


Link to post
Share on other sites
On 11/5/2017 at 10:15 PM, loukote said:

Hm, funny: the map appears when a user is logged in the back-end, does not appear otherwise.

For me the problem with the map either or not appearing on the front-end lied with the " Front-End Page Editor " module. When uninstalling that module the problem dissapears as well.

Share this post


Link to post
Share on other sites

In my case I also had the problem that the map was not rendered.

I found out that a javascript (in my case fullcalendar) for initialization was responsible for this behavior. So I decided to put it inline only on that page where I needed it and not in an external javascript file which is included in every page load.

Another point was that if I turn template cache on the map will not be rendered too, so I disable the cache on the template where the map is included.

So if you have problems, please check this 2 points. Maybe this solves your problem.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By OLSA
      Hello for all,
      ConfigurationForm fieldtype module is one my experiment from 2016.
      Main target to build this module was to store multiple setup and configuration values in just 1 field and avoid to use 1 db table to store just single "number of items on page", or another db table to store "layout type" etc. Thanks to JSON formatted storage this module can help you to reduce number of PW native fields in project, save DB space, and reduce number of queries at front-end.
      Install and setup:
      Download (at the bottom ), unzip and install like any other PW module (site/modules/...). Create some filed using this type of field (ConfigurationForm Fieldtype) Go to field setup Input tab and drag some subfields to container area (demo). Set "Name" and other params for subfields Save and place field to templates ("Action tab") How to use it:
      In my case, I use it to store setup and configurations values, but also for contact details, small content blocks... (eg. "widgets").
      Basic usage example:
      ConfigForm fieldtype "setup" has subfields:
      "limit", type select, option values: 5, 10, 15, 20
      "sort", type select, option values: "-date", "date",  "-sort", "sort"
      // get page children (items) $limit = isset($page->setup->limit) ? $page->setup->limit : 10; $sort = isset($page->setup->sort) ? $page->setup->sort : '-sort'; $items = $page->children("limit=$limit, sort=$sort");  
      Screenshots:


       
      Notes:
      Provide option to search inside subfields Provide multilanguage inputs for text and textarea field types Provide option for different field layout per-template basis Do not place/use field type "Button" or "File input" because it won't works. Please read README file for more details and examples Module use JSON format to store values. Text and textarea field types are multilanguage compatible, but please note that main target for this module was to store setup values and small content blocks and save DB space. Search part inside JSON is still a relatively new in MySQL (>=5.77) and that's on you how and for what to use this module.
      Thanks:
      Initial point for this fieldtype was jQuery plugin FormBuiled and thanks to Kevin Chappel for this plugin.
      In field type "link" I use javascript part from @marcostoll module and thanks to him for that part.
      Download:
      FieldtypeConfigForm.zip
      Edit: 14. August 2018. please delete/uninstall previously downloaded zip
      Regards.
         
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://gitlab.com/baumrock/RockPdf
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
    • By bernhard
      WHY?
      This module was built to fill the gap between simple $pages->find() operations and complex SQL queries.
      The problem with $pages->find() is that it loads all pages into memory and that can be a problem when querying multiple thousands of pages. Even $pages->findMany() loads all pages into memory and therefore is a lot slower than regular SQL.
      The problem with SQL on the other hand is, that the queries are quite complex to build. All fields are separate tables, some repeatable fields use multiple rows for their content that belong to only one single page, you always need to check for the page status (which is not necessary on regular find() operations and therefore nobody is used to that).
      In short: It is far too much work to efficiently and easily get an array of data based on PW pages and fields and I need that a lot for my RockGrid module to build all kinds of tabular data.

      Basic Usage

       
      Docs & Download
      https://modules.processwire.com/modules/rock-finder/
      https://gitlab.com/baumrock/RockFinder/tree/master
       
      Changelog
      180810, v1.0.5, basic support for options fields 180528, v1.0.4, add custom select statement option 180516, change sql query method, bump version to 1.0.0 180515, multilang bugfix 180513, beta release <180513, preview/discussion took place here: https://processwire.com/talk/topic/18983-rocksqlfinder-highly-efficient-and-flexible-sql-finder-module/
    • By Thomas Diroll
      Hi guys I'm relatively new to PW and just finished developing a page for a client. I was able to include all necessary functionality using the core fieldtypes but now I it seems that I need to extend them with a custom one. What I need is a simple button, that copies the absolute url (frontend not PW-backend) of the page which is currently edited to the clipboard. As this feature is only needed inside a specific template, I tend to use a custom fieldtype which provides this feature. I've been looking inside the core modules code (eg. FieldtypeCheckbox.module) but I don't really get the structure of it and how its rendered to the admin page. I also didn't find a lot of tutorials covering custom fieldtypes.
      Maybe some of you could give me some tips on how to write a basic custom fieldtype that renders a button which copies the value of
      page->httpUrl() to the clipboard using JS. Thanks!
    • By bernhard
      Some of you might have followed the development of this module here: https://processwire.com/talk/topic/15524-previewdiscussion-rockdatatables/ . It is the successor of "RockDataTables" and requires RockFinder to get the data for the grid easily and efficiently. It uses the open source part of agGrid for grid rendering.
       
      WHY?
      ProcessWire is awesome for creating all kinds of custom backend applications, but where it is not so awesome in my opinion is when it comes to listing this data. Of course we have the built in page lister and we have ListerPro, but none of that solutions is capable of properly displaying large amounts of data, for example lists of revenues, aggregations, quick and easy sorts by the user, instant filter and those kind of features. RockGrid to the rescue 😉 
       
      Features/Highlights:
      100k+ rows Instant (client side) filter, search, sort (different sort based on data type, eg "lower/greater than" for numbers, "contains" for strings) extendable via plugins (available plugins at the moment: fullscreen, csv export, reload, batch-processing of data, column sum/statistics, row selection) all the agGrid features (cell renderers, cell styling, pagination, column grouping etc) vanilla javascript, backend and frontend support (though not all plugins are working on the frontend yet and I don't plan to support it as long as I don't need it myself)  
      Limitations:
      While there is an option to retrieve data via AJAX the actual processing of the grid (displaying, filtering, sorting) is done on the client side, meaning that you can get into troubles when handling really large datasets of several thousands of rows. agGrid should be one of the most performant grid options in the world (see the official example page with a 100k row example) and does a lot to prevent problems (such as virtual row rendering), but you should always have this limitation in mind as this is a major difference to the available lister options that do not have this limitation.
      Currently it only supports AdminThemeUikit and I don't plan to support any other admin theme.
       
      Download: https://gitlab.com/baumrock/RockGrid
      Installation: https://gitlab.com/baumrock/RockGrid/wikis/Installation
      Quikckstart: https://gitlab.com/baumrock/RockGrid/wikis/quickstart
      Further instructions: https://gitlab.com/baumrock/RockGrid/wikis/quickstart#further-instructions
       
      Module status: alpha, License: MIT
      Note that every installation and uninstallation sends an anonymous google analytics event to my google analytics account. If you don't want that feel free to remove the appropriate lines of code before installation/uninstallation.
       
      Contribute:
      You can contribute to the development of this and other modules or just say thank you by
      testing, reporting issues and making PRs at gitlab liking this post buying me a drink: paypal.me/baumrock/5 liking my facebook page: facebook.com/baumrock hiring me for pw work: baumrock.com  
      Support: Please note that this module might not be as easy and plug&play as many other modules. It needs a good understanding of agGrid (and JavaScript in general) and it likely needs some looks into the code to get all the options. Please understand that I can not provide free support for every request here in the forum. I try to answer all questions that might also help others or that might improve the module but for individual requests I offer paid support for 60€ per hour.
       
      Changelog
      180730 support subdir installations 180711 bugfix (naming issue) 180630 alpha realease  
      Use Cases / Examples:
      Colored grid cells, Icons, Links etc. The Grid also has a "batcher" feature built in that helps communicating with the server via AJAX and managing resource intensive tasks in batches:

      Filters, PW panel links and instant reload on panel close:

      You can combine the grid with a chart library like I did with the (outdated) RockDataTables module: