Closed rzschoch closed 9 years ago
The code for kirbytag is not working with my plugin (I think so, but I will test it), because I load my plugins in the pre
time and not in the tag
time.
How did your plugin directory looks like.
It should be...
{kirbyinstall_dir}
- site
- plugins
- kirbycms-extension-gmaps
- kirbycms-extension-gmaps-lib.php
- kirbycms-extension-gmaps.php
- ...
What error/exception did you get? Please also write the used code for the execution of my plugin.
You are correct. I get following erros.
Notice: Undefined index: content in /srv/http/thomas/site/plugins/kirbycms-extension-gmaps/kirbycms-extension-gmaps-lib.php on line 221
Notice: Undefined index: content in /srv/http/thomas/site/plugins/kirbycms-extension-gmaps/kirbycms-extension-gmaps-lib.php on line 235
Notice: Undefined index: content in /srv/http/thomas/site/plugins/kirbycms-extension-gmaps/kirbycms-extension-gmaps-lib.php on line 246
Notice: Undefined index: content in /srv/http/thomas/site/plugins/kirbycms-extension-gmaps/kirbycms-extension-gmaps-lib.php on line 257
I will correct this.
Errors are away, but the parameter are not supplied to function to create the html code
Bug is now corrected. But I also found a error in my documentation. I updated the README.md file.
Here now the working example.
use at\fanninger\kirby\extension\gmaps\GMaps;
$attr = array();
$attr[GMaps::JS_ATTR_LAT] = 35.7152128;
$attr[GMaps::JS_ATTR_LNG] = 139.7981552;
$attr[GMaps::JS_ATTR_ZOOM] = 4;
echo GMaps::getGMap($page, $attr);
Thanks for your time and the fixed issues I didn’t have (but it will certainly help somebody) :)
I’m not sure if I understood your documentation, but when I try to use your php examples in my snippets or templates (or my own kirbytags) I’m not able to import your GMaps extension with the use syntax (example: use at\fanninger\kirby\extension\gmaps\GMaps;).
When I implement it like that, this error is thrown: Parse error: syntax error, unexpected 'use' (T_USE)
Do you have any advice for me? My purpose is to have blueprint fields (in the panel) for filling a place or coordinates.
Ok, currently the tag don't support fields as parameter, but this is a open point on my todo list. It should be easy to implement. I already support this in my image plugin.
Syntax: {page-field}
or {file-field}
for KLM files.
Example: (googlemaps lat: {page-lat} lng: {page-lng} zoom: {page-zoom})
When I have time this weekend, I will implement this feature in the package.
Now to your error message.
I test it with my template files and it works. Did the tag work?
Example: (googlemaps lat: 35.7152128 lng: 139.7981552 zoom: 4)
Did you use the use
in a function? -> see link
The use keyword must be declared in the outermost scope of a file (the global scope) or inside namespace declarations. This is because the importing is done at compile time and not runtime, so it cannot be block scoped.
When you would like to use it in a function, write the code in this form.
$attr = array();
$attr[at\fanninger\kirby\extension\gmaps\GMaps::JS_ATTR_LAT] = 35.7152128;
$attr[at\fanninger\kirby\extension\gmaps\GMaps::JS_ATTR_LNG] = 139.7981552;
$attr[at\fanninger\kirby\extension\gmaps\GMaps::JS_ATTR_ZOOM] = 4;
echo at\fanninger\kirby\extension\gmaps\GMaps::getGMap($page, $attr);
I add page field support for some parameters to the plugin.
JS_ATTR_ZOOM
JS_ATTR_LNG
JS_ATTR_LAT
JS_ATTR_PLACE
JS_ATTR_KML_TITLE
JS_ATTR_MARKER_TITLE
Example: (googlemaps lat: {page-lat} lng: {page-lng} zoom: {page-zoom})
It now works, thanks. The problem was the scope indeed ...
However, I’m also looking forward to your fields as parameter feature.
@rzschoch For the first parameters the field support is active in the current version.
Thank you for your nice extension, it really helps a lot.
Is it possible to use the kirbytags syntax in templates, like so (http://getkirby.com/docs/cheatsheet/helpers/kirbytag):
I always got an error, so I can’t use your extension at the moment. That is, because your given examples don’t work for me, unfortunately. The line ...
... throws an exception.
Thanks for your help!