Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/23/2019 in all areas

  1. Hi Rudy, Storing a JSON array in a TextArea should works as expected without doing anything than saving the field in a standard fashion. protected static function getDefaultData() { return array( 'json_config' => '' ); } public static function getModuleConfigInputfields(array $data) { $data = array_merge(self::getDefaultData(), $data); $modules = wire('modules'); $fields = new InputfieldWrapper(); $field = $modules->get("InputfieldTextarea"); $field->label = __('JSON Config'); $field->attr('name+id', 'json_config'); $field->attr('value', $data['json_config']); $fields->append($field); return $fields; }
    3 points
  2. I would simply backup the site and run it locally, e.g. with Laragon and a recent PHP version. Activate debug-mode in site/config.php, and test everything (backend and frontend). If there are PHP errors or warnings, it should be easy to fix them.
    3 points
  3. @Robin S Excellent! Works wonderfully now: Thanks for the swift fix!
    2 points
  4. @dragan, my previous commit to v0.1.4 contained a silly mistake that didn't account for nested lists. Should be fixed now in v0.1.5.
    1 point
  5. Seems pretty straightforward especially if capturing flow of conversation is not important. If that is a requirement, maybe Comments module (or borrowing from it) would cut it? Just wondering out loud...
    1 point
  6. @flydev Thanks! I was missing this bit $field->attr('value', $data['json_config']); Cheers!
    1 point
  7. I switched forth and back between left and right side bar and no it seems I'll stuck on right! ?
    1 point
  8. So, how's everyone? Version Control I finally started using VSC inbuilt version control, yipee! Thanks to @bernhard for the nudge. I got here after struggling to get a decent SourceTree replacement for Linux. Side Bar I've been wanting to move the side bar to the right but never got round to it. Today, I finally did it...and I like it! Any right side bar people here ??
    1 point
  9. Working fine here on PHP 7.2. However, I'd still do what @dragan suggested. Upgrades have a tendency to go awry :-). Also note that despite your best efforts to test locally, things may not always work as they should in your remote install. Often times it is because your host changed a setting in the server during the upgrade and worse, didn't even tell you about it! You'd be left in the dark blaming PHP 7 or some other module or ProcessWire only to realise a couple of emails later that actually, none of these were to blame ? and the culprit was a seemingly unrelated server setting. Hopefully, this doesn't happen to you...I'm not scaremongering; just thought you should be aware ?.
    1 point
  10. The fact that the data is being stored in the database as json is good. On retrieval you need to explicitly tell PW what/where to put the data. For example, a textarea field only has one 'value'. In your config screen there a several fields which should be populated with bits of the json data. I think you're one step away. Retrieve the json then assign the individual bits to your module config inputfields
    1 point
  11. Hi @gottberg There is a bit of work to get images, as the way you are doing return Images Objects and not array. You can have a look at this file to see the "complexity" to retrieve those objects : https://github.com/microcipcip/processvue/blob/master/site-processvue/templates/inc/pagefields.php#L236 Or you can build your own images array before assigning it to the API answer : See updated ImageHelper.php file at the bottom of this post. /* route : 'page' => [ ['GET', '{id:\d+}', Example::class, 'getPage', ["auth" => false]] ] */ // get page route answer function public static function getPage($data) { $data = RestApiHelper::checkAndSanitizeRequiredParameters($data, ['id|int']); $response = new \StdClass(); $p = wire('pages')->get($data->id); if(!$p ->id) throw new \Exception('Page not found'); $response->id = $p->id; $response->name = $p->name; $response->title = $p->title; $response->body = $p->body; $response->sidebar = $p->sidebar; $response->summary = $p->summary; // our own images array $images = array(); foreach ($p->images as $image) { array_push($images, array( $image->name => array( 'url' => $image->url, 'filename' => $image->filename, 'width' => $image->width, 'height' => $image->height // ... ) ) ); } $response->images = $images; return $response; } Result : --- Edit : The image class helper : <?php namespace ProcessWire; /** * InputfieldImage Helper * Use for single image * * Usage : * $image is your ProcessWire PageImage * return ImageHelper::get($image, [400, 800, 1200, 2000, 2500]); */ class ImageHelper { public static function get ($image, $widths = [400, 800, 1200]) { $response = new \StdClass(); $response->focus = ["x" => $image->focus['left'], "y" => $image->focus['top']]; $response->urls = []; $response->description = $image->description; $response->name = $image->basename; $response->width = $image->width; $response->height = $image->height; foreach ($widths as $width) { $croppedImage = $image->width($width); $url = new \StdClass(); $url->url = $croppedImage->httpUrl; $url->width = $croppedImage->width; $url->height = $croppedImage->height; $url->ratio = $croppedImage->height / $croppedImage->width; array_push($response->urls, $url); } return $response; } } /** * InputfieldImage Helper * Use for multiple images * * Usage : * $images is your ProcessWire PageImages * return ImagesHelper::get($images, [400, 800, 1200, 2000, 2500]); */ class ImagesHelper { public static function get($images, $widths = [400, 800, 1200]) { $response = new \StdClass(); $response->images = []; $img = new \StdClass(); // our own images array $imagesArr = array(); foreach ($images as $image) { $img->focus = ["x" => $image->focus['left'], "y" => $image->focus['top']]; $img->urls = []; $img->description = $image->description; $img->name = $image->basename; $img->width = $image->width; $img->height = $image->height; foreach ($widths as $width) { $croppedImage = $image->width($width); $url = new \StdClass(); $url->url = $croppedImage->httpUrl; $url->width = $croppedImage->width; $url->height = $croppedImage->height; $url->ratio = $croppedImage->height / $croppedImage->width; array_push($img->urls, $url); } array_push($response->images, $img); } return $response; } }
    1 point
  12. @ukyo thank you, I’ll have a look at your module. I just thought about creating a checkbox toggle module for myself.
    1 point
  13. Sadly, this doesn't work quite as expected here... The first time I used it, every page was created in root. The second time child and grand-child pages were created correctly, but there's something odd with the page-titles it generated for every parent page: PW 3.0.125
    1 point
  14. Update: Menu Builder Version 0.2.5. Just a quick maintenance update. Changelog Fixed a minor bug where we had to check if a variable was an array first before "counting" it. Removed a leftover debugging statement from the code (an echo of all things! Not even a bd()!!) ?.
    1 point
  15. @Gadgetto I have a module but didn't add it to module directory https://github.com/trk/FieldtypeToggle Module using : https://github.com/victornpb/vt-toggle Module only works with checkbox, will add support for radio, checkbox group and radio group. You can try it or you can continue with your solution.
    1 point
  16. We're still working on it :-). I'll write a progress report (post) next week.
    1 point
  17. I think this one of the most massive discussion about the project architecture I have ever read, featuring so many respected forum members, should not be left unanswered by the project lead. So feel like we need to bring it back up and ask @ryan to participate.
    1 point
  18. Maybe watching something similar helps: https://www.youtube.com/watch?v=_d0hZ8iS344 I'm thinking of logged in users being able to post messages in the PW backend which supports remote collaboration, or support developers by providing some means to announce changes made to the site. Currently if users want to communicate, PW does not support them at all.
    1 point
×
×
  • Create New...