Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/28/2018 in all areas

  1. bernhard, I've been working on a project with mPDF and there are lots of variants to the PDF content and how they are saved/downloaded, etc... It got me thinking about making a PW helper module to make things a little more sane to deal with. I decided to see how others were dealing with PDF creation within ProcessWire, and whaddya know — what I was imagining already exists. Just wanted to say thank you!
    4 points
  2. Another hidden treasure in the PW Backend: PW 3.0.61 introduced the VEX library for dialogs: https://processwire.com/blog/posts/processwire-3.0.61-master/#admin-and-ui This is how you can use them in your custom admin pages: In your module's php load the vex library (eg in the ready() method of your module - init() might not work as it might load too early!) $this->wire('modules')->get('JqueryUI')->use('vex'); Then in your javascript: // show confirm dialog ProcessWire.confirm('Are you sure you want to delete this E-Mail?', function() { // on confirm $i.removeClass('fa-trash').addClass('fa-spin fa-spinner'); $.get('./trash/?mailid=' + $a.data('mailid'), function() { $a.closest('.RockGridWrapper').find('.rockgridbutton.refresh').click(); }); }, function() { // on abort grid.api().deselectAll(); }); Result: I opened a pull request with a little fix for handling clicks on the CANCEL button. If you want to support it, give it a thumb: https://github.com/processwire/processwire/pull/108
    2 points
  3. I found (trough smashing magazine) these two cool links with a good overview with all properties about grid and flexbox: http://grid.malven.co http://flexbox.malven.co
    2 points
  4. Well, in the meantime, as a quick and dirty workaround, you could just insert an old-fashioned dialog in modules/ProcessPageListerPro/ProcessPageListerPro.js / line 29 $("#Inputfield_run_action").click(function() { var $form = $(this).parents('form'); $form.attr('target', 'actions_viewport'); // change target for this submission $viewport.slideDown(); if($viewport.is(".InputfieldStateCollapsed")) $viewport.find(".InputfieldHeader").click(); setTimeout(function() { $form.attr('target', '_top'); }, 1000); // restore target var $icon = $(this).find("i.fa"); $icon.attr('id', 'actions_spinner').attr('data-icon', $icon.attr('class')).removeClass($icon.attr('class')).addClass("fa fa-lg fa-spinner fa-spin"); if (window.confirm("Do you really want to do this?")) { } return true; });
    2 points
  5. This is already possible since PW 3.0.87: https://processwire.com/blog/posts/pw-3.0.87/#new-field-template-context-settings
    2 points
  6. Attention: This is the thread for the archived open source version of RockPdf. This module is neither developed any further nor maintained nor will it get any fixes. Modules Directory: https://modules.processwire.com/modules/rock-pdf/ Download & Docs: https://github.com/BernhardBaumrock/RockPDF Please see the new version here:
    1 point
  7. 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.
    1 point
  8. Hi! Wanted to share this and ask for opinions: I see a lot of regex approach to finding/changing links but the DOMDocument class seems very useful, is there a downside to this? Any other comment to improve this? ? (naming convention, code style?) <?php /** * Textformatter to output local links inside RTA textarea fields, as their language equivalents * by Eduardo San Miguel * * ProcessWire 2.x * Copyright (C) 2011 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class TextformatterLanguageLinks extends Textformatter implements Module { public static function getModuleInfo() { return array( 'title' => "Multilanguage links", 'version' => "100", 'summary' => "Textformatter to output local links inside RTA textarea fields, as their language equivalents", 'author' => "Eduardo San Miguel", 'requires' => array( "PHP>=5.4.0", "ProcessWire>=2.5.28" ), 'icon' => 'languages' ); } public function format(&$str) { $dom = new DOMDocument(); $dom->loadHTML($str); $tags = $dom->getElementsByTagName('a'); foreach ($tags as $tag) { $path = wire("sanitizer")->path($tag->getAttribute("href")); if($path){ $possiblePage = wire('pages')->get($path); } else{ continue; } if($possiblePage->id){ $langPageUrl = $possiblePage->localUrl(wire("user")->language); } //If empty? if($langPageUrl){ $str = str_replace($tag->getAttribute('href'), $langPageUrl, $str); } } } } Edit: Already found bugs because I wasn't sanitising the assumed path in the href attributes.
    1 point
  9. Thanks for pointing me to this. I was using the wrong keyword(modal, popup) to search for this feature. This is the thing I am looking for. Let me back-link your tutorial here for people like me.
    1 point
  10. PW already has VEX onboard. You can easily use it like I did in RockGrid. See this example: You'd just need to target the right save-button and save only when the user confirms.
    1 point
  11. Thank you! Happy to hear that and glad I could give something back to you, Reno - thanks for all your great contributions ?
    1 point
  12. I've stumbled into this as well in the past. Most users I've shown the Actions don't really get the current concept. They either forget they are performing actions on all or they forget to filter at all. Ryan came up with some solutions. Personnaly I would like an gmail approach so make sure the user is as notified as possible of what is going to happen. The current UX doesn't really cut it. A modal could work too.
    1 point
  13. Just tried out 2-factor auth for the first time - works like a charm! (both with email and with Google Authenticator).
    1 point
  14. thanks @mel47 that is a bug! I'll fix it as soon as possible. then also your problem @dragan should be gone ?
    1 point
  15. A few things... With the axios call, try querying the relative and not the absolute url. Also, take note of the trailing slash on the url, sometimes that can trip you up depending on your template settings. Finally, you probably don't need to set the entire response to your Vue data object, with axios you are looking for response.data. axios.get('/ajax-actions/test-api/).then(response => (this.info = response.data)); If you need to keep the full absolute url, or if you are calling the api page from a different url, then look into CORS. Setting the header below on your template should be enough, depends on your setup (eg see this topic for issues with CORS when using procache). <php header('Content-Type: application/json,charset=utf-8'); header("access-control-allow-origin: *"); //... ?>
    1 point
  16. Hi. I'm searching since a couple of days why I get this behavior. I follow your example for pages but it never display with separator (in my picture id=1284 or 1286 or 1290). I have no idea why, maybe an expert eye could spot something. $finder = new \ProcessWire\RockFinder('template=activite', ['title']); //really simple example $field =$finder->addField('discipline', ['title']); $field->separator = "|"; return $finder->getSQL(); SELECT `rockfinder`.* FROM /* original pw query */ (SELECT pages.id FROM `pages` WHERE (pages.templates_id=58) AND (pages.status<1024) GROUP BY pages.id ) as `pwfinder` /* rockfinder */ LEFT JOIN ( SELECT `pages`.`id` AS `id`, `title`.`title` AS `title`, `discipline`.`discipline` AS `discipline`, `discipline`.`title` AS `discipline:title` FROM `pages` /* --- join title --- */ LEFT JOIN (SELECT `pages_id` AS `pageid`, `title`.`data` AS `title` FROM `field_title` AS `title`) AS `title` ON `title`.`pageid` = `pages`.`id` /* --- end title --- */ /* --- join discipline --- */ LEFT JOIN (SELECT `discipline`.`pages_id` AS `pageid`, `discipline`.`data` AS `discipline`, GROUP_CONCAT(`title`.`data` ORDER BY `discipline`.`sort` SEPARATOR ',') AS `title` FROM `field_discipline` AS `discipline` LEFT JOIN `field_title` AS `title` ON `title`.`pages_id` = `discipline`.`data` GROUP BY `discipline`.`pages_id`, `discipline`.`data`) AS `discipline` ON `discipline`.`pageid` = `pages`.`id` /* --- end discipline --- */ ) AS `rockfinder` ON `pwfinder`.`id` = `rockfinder`.`id` /* end rockfinder */ Thanks!!
    1 point
  17. Pretty sure this was announced in a recent blog post with sessions in the database. Bank holiday in the UK so I will take a look in the morning.
    1 point
  18. So, food for thought in terms of REGEX vs DOMDocument: Benefits of using REGEX: Essentially faster/more efficient for processing of the data Doesn't care about valid source structure as it's parsing straight text, not XML nodes Implementation is unlikely to change Detriments of REGEX: Writing a perfect implementation of a REGEX when dealing with HTML to handle all use-cases without experiencing any edge-cases is difficult (might "greedily" match more than intended) It definitely works, but the developer argument is: is it the best (most appropriate) tool for the job? Without a good knowledge of REGEX, harder to understand the underlying code if changes/updates are required Benefits of using DOMDocument: Written specifically for the purposes of this type of task (searching/modifying the DOM) DOMDocument shouldn't ever be "greedy" over what it matches, like REGEX unintentionally tends to do Detriments of DOMDocument: May require valid HTML, but with iterations of HTML, what exactly is considered valid? Would different versions of PHP handle the DOM differently with version differences? Potential of implementation changes. loadHTML() may modify your source - what goes in might not be what comes out Character encodings may cause unforeseen issues (don't they always!) Without a good knowledge of PHP's approach to using DOMDocument, the code process can get rather difficult to understand if changes/updates are required Some further reading from someone else with more thorough testing: https://blog.futtta.be/2014/05/01/php-html-parsing-performance-shootout-regex-vs-dom/ https://blog.futtta.be/2014/04/17/some-html-dom-parsing-gotchas-in-phps-domdocument/ Realistically it's a judgment call. Speed and server efficiency versus (one would hope) better valid modifications/detections. I don't think there's really a right or wrong solution. Some shared hosting servers don't install the DOMDocument PHP extension by default though, so you'd want to check for the existence of the function during your module's install method. P.S. - Thanks for asking the question -- I knew DOMDocument was slower, but haven't compared in awhile. The articles I saw above were an interesting read. ?
    1 point
  19. Thx @Mackski I've done a slightly different approach: You now have the option between three methods: save() show() download() The save() method will return the resulting file urls and paths on success: @flydev thx I've added it to the modules directory ?
    1 point
  20. You should add this module to the modules directory , it rocks ?
    1 point
  21. Thx Sergio, sure I'm happy to share some insights. The library is mPdf (version 7) https://mpdf.github.io/ and I created a little helper module and just set it to public if anyone is interested: The custom design is just a regular PDF done by a designer and it is then imported into the pdf as needed (see line one in the next screenshot). My helper module provides a possibility to create only the HTML (not the pdf) so debugging is a lot easier: This is the result. The second logo would be the logo of the actual client of course... CSS is done with LESS, so it is easy to style and modify variables. LESS is compiled via AIOM on the fly without the need of any other compilers/setup. widows/orphans are controlled by a .nopagebreak class that can be applied so some blocks that should stay together: Charts have a fixed size so the amount of text above those charts is limited so that everything stays on one page. To get the TOC working with the custom design without page numbers etc. was quite tricky but finally it works very well. Also the "annex" feature is very nice, where they can upload a custom PDF without background and page numbers and the text is imported in the document automatically with the correct background and page numbers: We just created a word-template with the correct colors, fonts and headline sizes and that's it ?
    1 point
  22. Recipes website: http://superpola.com Modules Used: ProCache ProcessImageMinimize / minimize.pw Batcher AIOM
    1 point
×
×
  • Create New...