Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/30/2018 in all areas

  1. There is also PageFrontEdit https://processwire.com/blog/posts/front-end-editing-now-in-processwire-3.0-alpha-4/
    3 points
  2. Hi, If you are looking for the grid only part of Bootstrap, there is no need anymore to compile this for your self. I noticed that Bootstrap has already split up the files in the download package. In the dist folder you can find the following files: bootstrap-grid.css = 37 kb bootstrap-grid.min.css = 29 kb And here is the css to give a bootstrap container any width you want: .container{ max-width: 1300px; /* use any width for your container without less or sass */ width:100%; }
    3 points
  3. Use the fields import / export functionality and respective the same for templates. Go to admin fields and click export, then select all the fields you need. Go to admin templates and click export, then select the template(s) you need. Edit: Additionally you may use the API: https://processwire.com/api/ref/templates/get-export-data/ https://processwire.com/api/ref/templates/set-import-data/
    2 points
  4. 2 points
  5. If you have any modules that check for ProcessWire version and don't use PHP version_compare, but instead use a string comparison, the comparison will fail. The modules that I know of that use this are in the Selectize group of inputfields and are being updated to a new version that fixes this. UPDATE 1: All of my modules that used the bad version comparison will be updated by tomorrow. UPDATE 2: All of the Selectize modules are now updated to work with PW 3.0.100 (fixed version comparison)
    2 points
  6. Hi, based on the work of @microcipcip and @gebeer (see their posts here and here), I put together a Processwire + React boilerplate (profile). Github repo: https://github.com/lapico/process-react Cheers, K
    1 point
  7. On twitter @pwtuts I made this site to: a) help get beginners up and running with PW. b) give something back to a community that has been very helpful (and patient) to me. c) improve my own knowledge because writing about it really drills it home. Modules: AOS - lots of useful admin tools Connect page fields - made tagging and related posts very easy indeed Custom inputfield dependencies - used to hide fields (on child pages) in a multipage post because all blog posts use the same template ProFields: repeater matrix - used for all body content (image, RTE and code fields) Markup Sitemap XML - for submission to google search console ProFields: Auto links - I have a bunch of pre-determined strings in here (that I need to print out and stick on the wall...) Tracy Debugger - still can't use properly IMagick image sizer - very fast compared to GD, especially when some posts have 5+ images and the originals are 2500px wide Tools: NodeJS with the usual suspects: "devDependencies": { "autoprefixer": "^7.1.2", "cssnano": "^3.10.0", "gulp": "^3.9.1", "gulp-postcss": "^7.0.0", "gulp-rename": "^1.2.2", "gulp-sass": "^3.1.0", "gulp-sourcemaps": "^2.6.0", "gulp-uglify": "^3.0.0", "postcss-flexbugs-fixes": "^3.0.0" }, "dependencies": { "bootstrap": "^4.0.0-alpha.6" } Bootstrap 4 (npm) SCSS In short: had a bunch of fun making this, learned loads. and looking forward to updating with more tutorials.
    1 point
  8. As threatened in the Pub sub forum in the "What are you currently building?" thread, I've toyed around with Collabora CODE and built file editing capabilities for office documents (Libre-/OpenOffice formats and MS Office as well as a few really old file types) into a PW module. If you are running OwnCloud or NextCloud, you'll perhaps be familiar with the Collabora app for this purpose. LoolEditor Edit office files directly in ProcessWire Edit your docx, odt, pptx, xlsx or whatever office files you have stored in your file fields directly from ProcessWire's page editor. Upload, click the edit icon, make your changes and save. Can be enabled per field, even in template context. Currently supports opening and saving of office documents. Locking functionality is in development. See the README on GitHub for installation instructions. You should be reasonably experienced with configuring HTTPS and running docker images to get things set up quickly. Pull requests are welcome! Here is a short demonstration:
    1 point
  9. Here is the setup page for a note showing one field under a category. Each can be repeated.
    1 point
  10. Doing something similar right now and using this excellent module: http://modules.processwire.com/modules/fieldtype-fields/
    1 point
  11. So I have a bunch of templates that define fields for different types of "notes". I put them under a parent page and then use a Page Reference field on the parent page of the templates. The user can select from the templates using a radio box (I allow multiple options, but you could use other input options to just get one). I later then process their templates as needed by reading in the template page and processing it. To add a new template I just add a page and it is then available without having to edit the option box. I may also use a loop on the children of the template parent with my own code to generate the select options. This would allow the templates having an extra value to indicate which group of user can see them. In this case a page reference field would not work easily (that I know of) as I want to filter the templates based on the "type" of user or some other property the user has.
    1 point
  12. Adrian, I have added an extra variable to recurme to give you the timeEnd as a unix timestamp so you can format it however you want. $event->timeEndUnix; Here is an example that outputs the exact information you want: <?php $p = $pages->get(1120); $event = $recurme->event($p); echo date('M d - ', $event->start_date); echo date('M d', $event->end_date)."<br />"; echo date('g:i a - ', $event->start_date); echo date('g:i a', $event->timeEndUnix); // outputs // Mar 14 - Feb 16 // 9:03 am - 9:02 am ?> IMPORTANT: We need to re-save an event to add the value of timeEndUnix to the json data. I know this is not ideal, however it was the best compromise until I make date saving & conversions better all around. I have also adjusted the 'timeEnd' value to be effected by the 'timeFormat' option if you prefer to use that instead, however, this will only work if your saved data for the event has timeEndUnix Value. You had mentioned that you have a lot of events, in order to take advantage of the new timeEndUnix variable, you will have to save your events again. Send me a PM and we can work out a way to do it with the API and add the timeEndUnix value to your JSON data for your existing events. Please try these (attached) files and let me know if you find any problems. Hope this helps, rrule-gui.js MarkupRecurme.module
    1 point
  13. I found by accident, trying to find out why my Chrome does this, that the Chrome "use Hardware acceleration if possible" enabled in settings is the Problem. It seems to have problems then rendering the CSS filter used there.
    1 point
  14. Thanks for this module, Robin. Note that the download link on the module page is broken.
    1 point
  15. @celfred, I don't think I'll be able to get my head around all the facets of your PW-based game, so will just answer in general terms. First thing is that, broadly speaking, there's no reason to avoid using plain PHP arrays, functions, etc in your development if that is easier or clearer for whatever you're wanting to achieve. Behind the scenes PW will be using these native PHP types and functions anyway. So it comes down to choosing whatever you find easiest or most transparent. So by all means use WireArrays/PageArrays where you find that easiest - in most circumstances that will be the way to go. But in your code I saw some places where you are creating new Page objects that are not actually going to be saved in the page tree anywhere. As if you are just creating these pages as a way to temporarily store some data. That doesn't make much sense to me and leads me to think there is probably some better way to do it. And it also pays to think about creating some structure to your data so that if you need to debug it or come back to the code in six months time you can dump things and understand what is going on from the dump. So that's why I suggested using a PHP array where the key names and array structure reveal the purpose of what you're doing. But if you need to take the 'players' element and do other things with it in the PW API then you're right that it would be easier if it were a PageArray rather than a plain PHP array of Page objects. So you could make that element a PageArray and then add pages to it... //... foreach($allPlayers as $player) { // Define the $groupId // Use an underscore (or other non-integer) in the $groupId to force it to be a string, not an integer // That way when array_multisort() is used later the keys will be preserved $groupId = $player->team->id . '_' . $player->group->id; // Optional: add $groupId to $player as a custom property in case you need it later $player->groupId = $groupId; // Add player to a PageArray in $uniqueGroups using $groupId as key if(!isset($uniqueGroups[$groupId]['players'])) $uniqueGroups[$groupId]['players'] = new PageArray(); $uniqueGroups[$groupId]['players']->add($player); } //... Then when you later need to work with the 'players' element it is a PageArray that you can use methods like sort() on. And while looking into the issue I discovered something new: although you cannot create a nested PageArray, you can create a WireArray of PageArrays. So you could think about taking this approach if you are more comfortable sticking with PW API methods rather than doing sorting etc in plain PHP. An example of what I mean about a WireArray of PageArrays... // Create a new WireArray to hold the PageArrays $my_wirearray = new WireArray(); // PageArray number 1 $pa1 = $pages->find("template=foo"); // PageArray number 2 $pa2 = $pages->find("template=bar"); // PageArray number 3 $pa3 = $pages->find("template=baz"); // Attach some custom data to the PageArrays $pa1->data('karma', 25); $pa2->data('karma', 13); $pa3->data('karma', 37); // Add the PageArrays to the WireArray $my_wirearray->add($pa1); $my_wirearray->add($pa2); $my_wirearray->add($pa3); // If you need to sort the WireArray by the custom data $my_wirearray->sort('-karma'); // Or maybe you want to explode on that custom data $karma_values = $my_wirearray->explode('karma', ['getMethod' => 'data']);
    1 point
  16. Thank you for the detailed response @kongondo ! The above code does not work, the plugin extends $page so you can directly call ‚pageQueryJson‘ on a Page or a PageArray you call it - altough you need to specify what results you‘d like to receive; $json = $pages->find('template=skyscraper')->pageQueryJson(['title']); from what you describe, it probably does not need to autoload I’ll change that with the next release. Thanks again!
    1 point
  17. You only use autoload if the module needs to load automatically when ProcessWire boots so that you can listen to every single request and typically attach hooks to some event of interest. Don't let this confuse you though. Modules can hook into events without being autoload modules. An example autoload module is Blog module's Publish Date. It listens to when Blog Posts are published and sets a publish date. As such, it needs to be auto-loaded. Does your module need to boot with ProcessWire or does one call it when one needs it? If the latter, then it means presently, it is just loading and using up resources when it doesn't need to. Can your module work like this? $pageQuery = $modules->get('PageQueryBoss'); $query = $pages->find('template=skyscraper'); $json = $pageQuery->pageQueryJson($query); It doesn't seem to me like it needs to autoload, but I've only had a brief look, so I could be wrong. You can read a bit more about autoload modules in the module class docs here.
    1 point
  18. I made this with Page Tables. It's not 100% perfect yet, but works for my demands _init.php: // Main Content if ($page->views) { $content = "<div id='views' data-uk-grid-margin>"; $contentview = ""; foreach ($page->views as $view) { $typ = $view->template; $id = $view->name; $colxl = $view->colxl; $gridcountxl = $colxl; $colsm = $view->colsm; $gridcountsm = $colsm; $colxs = $view->colxs; $gridcountxs = $colxs; $fw = $view->fullwidth; $nmnp = $view->removemargin; $border = $view->hasborder; switch ($typ) { case "Text": $text = $view->textfield; $ct = "<div id='{$id}' class='uk-width-small-". $colxs ."-12 uk-width-medium-". $colsm ."-12 uk-width-large-". $colxl ."-12'>$text"; $ct .= checkGrid($gridcountxs, $gridcountsm, $gridcountxl); $ct .= "</div>"; $contentview .= fullWidth($fw, $cv=$ct, $nmnp, $border); break; case "SlideGalerie": $bilder = $view->images; $sg = ""; $sg .= "<div id='{$id}' class='product-gallery views owl-carousel owl-theme'>"; foreach ($bilder as $b) { $bbig = $b->width(1920, $options); $bsmall = $b->size(485,325, $options); $bretina = $b->size(970,650, $options); $sg .= "<div class='g-item'>"; $sg .= "<a href='{$bbig->url}' data-uk-lightbox=\"{group:'{$view->name}'}\">"; $sg .= "<img data-src='{$bsmall->url}' data-src-retina='{$bretina->url}' class='owl-lazy' alt='$b->description'>"; $sg .= "</a>"; $sg .= "</div>"; } $sg .= "</div>"; $sg .= checkGrid($gridcountxs, $gridcountsm, $gridcountxl); $contentview .= fullWidth($fw, $cv=$sg, $nmnp, $border); break; // Case .. Case .. Case .. } $content .= $contentview; $content .= "</div>"; } _func.php /** * @param string $gridcountxs * @param string $gridcountsm * @param string $gridcountxl * @return string */ function checkGrid($gridcountxs = '', $gridcountsm = '', $gridcountxl = '') { $out = ''; if ($gridcountxs >= 12) { $out .= "<div class='uk-clearfix uk-visible-small'></div>"; } if ($gridcountsm >= 12) { $out .= "<div class='uk-clearfix uk-visible-medium'></div>"; } if ($gridcountxl >= 12) { $out .= "<div class='uk-clearfix uk-visible-large'></div>"; } return $out; } /** * @param string $fw * @param $cv * @param string $nmnp * @param string $border * @return string */ function fullWidth($fw = '', $cv, $nmnp = '', $border = '') { if ($nmnp) { $nomargin = 'uk-margin-top-remove'; } else { $nomargin = ''; } switch ($border) { case '1': $b = 'border-top'; break; case '2': $b = 'border-right'; break; case '3': $b = 'border-bottom'; break; case '4': $b = 'border-left'; break; case '5': $b = 'border-all'; break; default: $b = ''; break; } $fout = ''; if ($fw) { $fout = "<div class='full-width " . $nomargin . " " . $b . "'>" . $cv . "</div>"; } else { $fout = "<div class='uk-container uk-container-center uk-margin-large-top " . $nomargin . "'><div class='uk-grid " . $b . "'>" . $cv . "</div></div>"; } return $fout; }
    1 point
  19. 1 point
  20. Some threads worth reading if you haven't already seen them: https://processwire.com/talk/topic/5777-default-value-for-fields-in-admin/ https://processwire.com/talk/topic/1593-how-can-i-specify-default-value-for-certain-input-field/ https://processwire.com/talk/topic/394-default-field-value/
    1 point
  21. What's about: $page->parent('parent=' . $page->rootParent); // $page->rootParent returns $foo as Page, not name, not id just for the case that the name of foo will change in future, or: what is about usage in a multilanguage site?
    1 point
  22. <img src="logo-<?php echo $user->language->name; ?>.png" alt="" /> This will give you the name of the language. So you either make sure you change the language name or the filename of the images to make sure they match.
    1 point
  23. Thanks guys - Antti's was closest since this field allows multiple values. The goal for this was to pre-populate the author field with the current user's ID if the author field is empty (something that would only be the case on new articles). The check for empty ensures that editing old articles doesn't end up appending my name to them all In the module's init() function we have this: $this->addHookBefore('InputfieldPageAutocomplete::render', $this, 'addUserOnEmptyAuthor'); and the function is simply this: public function addUserOnEmptyAuthor(HookEvent $event) { $autocomfield = $event->object; if ($autocomfield->attr('name') == 'authors' && !$autocomfield->attr('value') && !in_array(wire('user')->id, $autocomfield->attr('value'))) { $autocomfield->attr('value', wire('user')->id); } } So it first checks the field is called "authors", then checks it's empty before adding the current user ID. I also left in another check (that's not required, since the check for empty is enough), but might be useful for others thinking of doing something similar, which simply checks if the current user's ID is in the list of values already. I know that even if it did appear twice in the editor, PW only saves it once, but it would look a bit odd to have the same person's name twice so there's a check for that if anyone needs it. And now I also know a bit more about OOPHP too as well as how to set default values for other fields Thanks all!
    1 point
×
×
  • Create New...