Jump to content

gebeer

Members
  • Posts

    1,393
  • Joined

  • Last visited

  • Days Won

    39

Everything posted by gebeer

  1. Don't know about performance, but with this code you would set the value of $my_page_array to 1234 which most likely would throw an error. For comparison use $my_page_array === 1234 If you have the $page object that you are searching for already, you can also pass that directly into the has() method like $my_page_array->has($page) instead of $my_page_array->has("id=1234")
  2. One of those hidden beauties that would be great to have them in the Cheat Sheet...
  3. You need to create a file /site/modules/InputfieldCKEditor/contents.css with the styles you want to apply inside the Editor. And have a look at /site/modules/InputfieldCKEditor/README.txt on how to activate it: contents.css ============ Example CSS file for the admin editor. To make CKEditor use this file, go to your CKEditor field settings and specify /site/modules/InputfieldCKEditor/contents.css as the regular mode Contents CSS file.
  4. This might be related to the directory traversal setting in AIOM. I stumbled over this once. Thank you for this hint. I wasn't aware of it.
  5. I can confirm that it works for put requests. For patch/delete, I'm sorry, but I can't confirm because I havent used them. If you get an empty $params, this may have 2 reasons: 1. you did not specify the header Content-Type application/json 2. the JSON in the request body is malformed
  6. To expand on arjen's answer: I had use cases where I had to add more than one tab to several templates. To avoid creating too many individually named fields of type FieldsetTabOpen, I did the following: Create fields of type FieldsetTabOpen with generic names, like tab1, tab2 etc. Apply the field to template A and in the template override for the field label name it e.g. "Sidebar Left" Apply the same field to template B and in the template override for the field label name it e.g. "Sidebar Right" This way you only have one field of type FieldsetTabOpen but can use it for differently named Tabs in different temp[lates.
  7. I can confirm, that put is working. All JSON that I send in the request body is available in $params. For patch/delete, I'm sorry, but I don't know because I haven't used them. If $params is empty: did you make sure that header Content-Type application/json is set? Or maybe the JSON in your request body is malformed?
  8. I am not sure about passing variables to field->renderValue. But adding your JS and CSS dependencies to custom arrays is pretty straightforward. In config.php you can define your custom JS and CSS arrays like $config->customJs = new FilenameArray; $config->customCss = new FilenameArray; Then in your template file where you want to include your dependency you do $config->customJs->add('pathtoyourscriptfile'); $config->customCss->add('pathtoyourstylefile'); In the head section of your html you then render them with <?php if(count($config->customCss)) foreach($config->customCss->unique() as $file) echo "\n\t<link type='text/css' href='$file' rel='stylesheet' />"; ?> and in the head or end of body section render your JS <?php foreach($config->customJs->unique() as $url) echo "<script src='$url'></script>"; ?>
  9. Hello Mission and welcome to the forum! Do you have any custom code where you deal with database connections or does this happen on a clean install of PW? And what is your hosting provider/setup (shared hosting)?
  10. Looking again at my above implementation for additional content in the marker popup feels a bit hacky because the content of the popup is being constructed in MarkupLeafletMap.js I think the cleaner and proper way of doing it would be to construct the HTML that goes into the popup on the template file level and then pass it to the map render function. Something like this: $options = array(); $options["markerPopupContent"] = "<b><a href='{$page->url}'>{$page->title}</a></b>{$page->body}"; // ... more options $map = $modules->get('MarkupLeafletMap'); echo $map->render($items, 'map', $options); Hope to get your opinion on this. I would then implement the code into my fork of this module.
  11. Since browser support for flex is now pretty good, I am looking into using flexboxgrid. It looks very promising and looking at their github repo with all those likes and forks it sure will last. Has anybody here used it and what do you think?
  12. @houseofdeadleg At the moment only the title is supported. You would need to change some code in the module: https://github.com/madebymats/FieldtypeLeafletMapMarker/blob/master/MarkupLeafletMap.module#L115 -> add another line 'markerBodyField' => 'body', https://github.com/madebymats/FieldtypeLeafletMapMarker/blob/master/MarkupLeafletMap.module#L192 -> add another line $body = $options['markerBodyField'] ? $page->get($options['markerBodyField']) : ''; https://github.com/madebymats/FieldtypeLeafletMapMarker/blob/master/MarkupLeafletMap.module#L193 -> change line 193 to $out .= "$id.addMarker($marker->lat, $marker->lng, '$url', '$title', '$body'); "; https://github.com/madebymats/FieldtypeLeafletMapMarker/blob/master/MarkupLeafletMap.js#L65 -> change line 65 to this.addMarker = function(lat, lng, url, title, body) { https://github.com/madebymats/FieldtypeLeafletMapMarker/blob/master/MarkupLeafletMap.js#L98 -> change line 98 to marker.bindPopup("<b><a href='" + marker.linkURL + "'>" + title + "</a></b><br>" + body); Then in the template where you render the map, you need to include the markerBodyField in the options that you pass to the render function, e.g. $options = array(); $options["markerTitleField"] = $page->title; $options["markerBodyField"] = ($page->body) ? $page->body : ""; // ... more options $map = $modules->get('MarkupLeafletMap'); echo $map->render($items, 'map', $options); I have not tested this but it should work. Please report back here.
  13. @horst you could also use the (relatively) new $sanitizer->int($value) or $sanitizer->intUnsigned($value) method like if(wire("sanitizer")->int($input->get->id)) {...}
  14. @Alxndre' I can see an advantage using $params: it utilizes a standardised way of sending data through the request body in a JSON object. So there is only one place where you have access to all the data that was sent with the request. Also, if you do basic http authentication and use my modified version of the helper classes, you will have access to $params["name"] and $params["pass"] to do request validation.
  15. @alan do you get <li> instead of <fieldset> tags? That would be the default behaviour. You can set the HTML tags that are rendered, even by inputfield type, see here.
  16. It would be fantastic if we could set different configurations for CKEditor fields based on template or user roles. Like described on https://weekly.pw/issue/14/ under "More CKEditor upgrades", we can use config files in /site/modules/InputfieldCKEditor/ to store settings per field. E.g. for the body field this would be /site/modules/InputfieldCKEditor/config-body.js. Maybe this logic could be extended to something like /site/modules/InputfieldCKEditor/config--field-body--template-home--role-mycustomrole.js. I was coming over from Joomla to PW couple of years ago and there we had an excellent CKEditor integration called JCE where you could define settings per user role etc. Maybe I am wrong but up to now we need to create additional fields if we need editor config settings per template. If there already is a way to do that I'd be happy to know.
  17. And Sublime Text has 2 plugins that index method definitions and let you jump there quickly: https://github.com/SublimeCodeIntel/SublimeCodeIntel https://packagecontrol.io/packages/WhoCalled%20Function%20Finder (not maintained anymore)
  18. The manual for selector operators states for ~= "Contains all the words". So your search returns only fields that have all of the $parts, e.g. "myfabric yellow". I think you need to use the OR operator for your selector values, too (see here). So your code would read $selector .= ", title|body|collection.title|hue.title|pattern.title|pattern_type.title|usage.title~=" . $sanitizer->selectorValue(implode('|', $parts)); | pipe instead of blank space in the implode.
  19. I have converted the relevant db query code to PDO and will issue a pull request.
  20. thank you adrian. I will give the renaming a try. Yes, I'm sure that it is this module because the error throws only on pages with embedded video and on the settings page for the module in the backend. The module officially supports PW only up to 2.4. That may be why it is not using PDO. EDIT: rnaming $db to $database didn't help. $db is initialized in the module with $db = wire('db');
  21. When I open a page with video embedded, I get this: Error: Class 'mysqli' not found (line 23 of /home/gocinet/public_html/wire/core/Database.php) Same error when I access the module settings page in the backend. PW 2.7.0. This only happens on the live server, not on my dev machine. So it seems to be server related. Any pointers on how to solve this would be great. Thank you. EDIT: I just discovered that mysqli support is not installed on the live server (godaddy VPS). Installing it should solve the problem.
  22. With $pages->get("template=events") you only get one page. You need to use $pages->find("template=events") to get all event pages. Try $nextevents = $pages->find("template=events")->events->find("end_date>today, sort=end_date, limit=2"); Not sure though if this works. You might need to loop through your events and inside the loop remove those that don' match required dates $nextevents = $pages->find("template=events, sort=end_date"); foreach($nextevents as $e) { if ($e->getUnformatted(events->end_date) < time()) $nextevents->remove($e); } // get first 2 events with slice, see https://processwire.com/api/arrays/ nextevents = $nextevents->slice(0, 2);
  23. @LostKobrakai yes, this is right. Here Soma gives a good example of how to use your own form markup and do the processing with PW API.
  24. I am using REST API to exchange information between independent PW installs. There is Ryan's Pages Web Service Module you could use on the client sites and then query it from the main site. Or clsource's REST Helper classes for setting up a REST API. I wrote a tutorial on setting up the latter. If you decide to go the REST route, there is the HTTPful REST client for PHP which makes life a lot easier when doing requests with PHP (from your main site to the client sites).
  25. @justb3a thank you for those. Didn't know about $form->setClasses(). Pete has just given some nice info about $form->setMarkup() over there. I will definitely have a closer look at these methods.
×
×
  • Create New...