Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/27/2017 in all areas

  1. Restrict Repeater Matrix Allows restrictions and limits to be placed on Repeater Matrix fields. Requires ProcessWire >= v3.0.0 and FieldtypeRepeaterMatrix >= v0.0.5. For any matrix type in a Repeater Matrix field you have the option to: Disable settings for items (cannot change matrix type) Prevent drag-sorting of items Prevent cloning of items Prevent toggling of the published state of items Prevent trashing of items Limit the number of items that may be added to the inputfield. When the limit is reached the "Add new" button for the matrix type will be removed and the matrix type will not be available for selection in the "Type" dropdown of other matrix items. Hide the clone button when the limit for a matrix type has been reached. Note that in PW >= 3.0.187 this also means that the copy/paste feature will become unavailable for the matrix type. Please note that restrictions and limits are applied with CSS/JS so should not be considered tamper-proof. Usage Install the Restrict Repeater Matrix module. For each matrix type created in the Repeater Matrix field settings, a "Restrictions" fieldset is added at the bottom of the matrix type settings: For newly added matrix types, the settings must be saved first in order for the Restrictions fieldset to appear. Set restrictions for each matrix type as needed. A limit of zero means that no items of that matrix type may be added to the inputfield. Setting restrictions via a hook Besides setting restrictions in the field settings, you can also apply or modify restrictions by hooking RestrictRepeaterMatrix::checkRestrictions. This allows for more focused restrictions, for example, applying restrictions depending on the template of the page being edited or depending on the role of the user. The checkRestrictions() method receives the following arguments: $field This Repeater Matrix field $inputfield This Repeater Matrix inputfield $matrix_types An array of matrix types for this field. Each key is the matrix type name and the value is the matrix type integer. $page The page that is open in ProcessPageEdit The method returns a multi-dimensional array of matrix types and restrictions for each of those types. An example of a returned array: Example hooks Prevent the matrix type "images_block" from being added to "my_matrix_field" in a page with the "basic-page" template: $wire->addHookAfter('RestrictRepeaterMatrix::checkRestrictions', function(HookEvent $event) { $field = $event->arguments('field'); $page = $event->arguments('page'); $type_restrictions = $event->return; if($field->name === 'my_matrix_field' && $page->template->name === 'basic-page') { $type_restrictions['images_block']['limit'] = 0; } $event->return = $type_restrictions; }); Prevent non-superusers from trashing any Repeater Matrix items in "my_matrix_field": $wire->addHookAfter('RestrictRepeaterMatrix::checkRestrictions', function(HookEvent $event) { $field = $event->arguments('field'); $type_restrictions = $event->return; if($field->name === 'my_matrix_field' && !$this->user->isSuperuser()) { foreach($type_restrictions as $key => $value) { $type_restrictions[$key]['notrash'] = true; } } $event->return = $type_restrictions; }); http://modules.processwire.com/modules/restrict-repeater-matrix/ https://github.com/Toutouwai/RestrictRepeaterMatrix
    8 points
  2. This is the second site we've built for Visualization. The first launched some 5 years ago and was based on a different CMS (before we started working with PW). The site is fully responsive and features a 'quick quote system' using the FormBuilder module to manage quote requests and email both customer and site owners with the calculated quote. The prices for each part of the quote calculation are editable by the client in the CMS at any time. Every page features Meta Title and Description override option fields with tag content falling back to values based on the page's content if these are not filled in. Other than PW core v 3.0.42 additional modules are FormBuilder, ProCache and markupBlog. Any feedback welcome! http://www.avrackbuild.com/
    7 points
  3. My main 2011 15" Macbook Pro had serious graphic problems and stopped working couple weeks ago and I decided to build a Windows machine for the same reason. I also have a 13" that I use to travel. Here in Brazil, a Macbook Pro cost is outrageous, a powerful Mac setup can cost up to 3 or 4 months of salary of an experienced developer. A default 15" Macbook Pro costs here R$ 18.499,00 which converts to US$ 5,581.00!!! So, after 10 years of using only Macs, I built a PC that cost me about $1,700 and it's a beast of a machine for developing and video editing (and some games): Processor: Ryzen 7 1700 - Octa core, 3GHz RAM: 16GB 2133 MHz Motherboard: Gigabyte B350 Gaming 3 HD/SSD: 1 Kingston 250 GB SSD + 1 Western Digital 1TB 7200 rpm GPU: Asus Radeon RX 460 - 2GB RAM Monitor, keyboard, and mouse I already had. They cost about US$270 together. I installed Ubuntu through Windows WSL but I'm not using it like I thought I would. I installed Laragon and it works perfectly for running ProcessWire and other PHP projects. Windows 10 Pro is a very good OS, but I miss some good software like SequelPro and Transmit. The Windows equivalents are not as polished.
    2 points
  4. Are you talking about this? https://msdn.microsoft.com/en-us/commandline/wsl/about
    2 points
  5. See this issue: https://github.com/processwire/processwire-issues/issues/267 The example hook has been updated on the dev branch. $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'mypages') { $event->return = $event->pages->find('your selector here'); } });
    2 points
  6. Thank you, thank you, thank you, Robin S ! After returning and starting from "scratch," I strongly suspect that the weird invisible whitespace was the culprit. With another clean install, I typed everything Very Carefully (rather than cutting & pasting). It worked! I love my custom dates...and comments. Thank you again for your help and your patience, fbg13, Robin S and Mike Rockett !
    2 points
  7. I normally store my page references in a section of the main website page tree. I give this section a name that contains the word "Configuration ". I also store the results of Page Tables in this section.
    2 points
  8. @Roych, if a second argument is given to date() it must be a timestamp. So you need the unformatted value of the date field: <?php if (date('d-m-Y') == date('d-m-Y', $single->getUnformatted('Start_date'))): ?> <div class='Danes-text'>TODAY!</div> <?php endif; ?>
    2 points
  9. Ok Now iOS version is ready! https://itunes.apple.com/us/app/pw-app/id1252337641?l=es&ls=1&mt=8
    2 points
  10. Hi, There is a list of reserved words which cannot be used for a Field, see: https://github.com/processwire/processwire/blob/master/wire/core/Fields.php#L36 I do not remember exactly when, but limit was added to this list, hence you cannot upgrade without first renaming the Field in question in the admin. You will probably need to change some code too, in order to accommodate to this change.
    2 points
  11. There are long-standing issues with the $user page having output formatting off by default - there are a number of forum topics where it has come up. I'm not sure if it's deliberate or if output formatting is off consistently for $user, but you could use $user->getFormatted('date') to be sure. Related topics:
    1 point
  12. Hi everyone! I'm developing multiple sites that use the same codebase for templates. I am using git branches to take control of the changes on each branch (one branch per site, each template folder is a different worktree with the branch checked out) and push the changes to other branches when necessary. So far this has proven to be very useful. But now I come to get some thoughts,opinions, answers.. Now, I want to be able to do this: Let's say current page uses mytemplate.php. If custom.mytemplate.php exists, use it instead. this way, I can .gitignore custom.* and still have the flexibility to apply custom changes to every site that translate to other branches, sacrificing tracking the customizations on each branch due to the .gitignore, but that also simplifies the merging on other branches (for updates that have to translate everywhere) Do you think I could have a better approach for keeping track of customizations, maybe just be more carful on the merges when pulling changes? Could the "template swap if alternate file exists" thing get done in a Hook? Any other opinions or experiences doing a similar thing would be appreciated.
    1 point
  13. Thanks for the suggestion! Sooo, what I have to do is keep order haha, cause right now I've been making pulling changes from branch to branch, or to master. I guess I have to limit myself to a one way flow. Version control != Project management
    1 point
  14. +1 for WSL. It works wonderfully and has a lot of resources behind it. Getting better all the time.
    1 point
  15. I use vmplayer, nowadays called workstation player. Free for home use and 166 euro for a commercial licence. It is by far superior to virtual box in so many ways. Have a look here: https://my.vmware.com/en/web/vmware/free#desktop_end_user_computing/vmware_workstation_player/12_0
    1 point
  16. Haha I mainly use them for the PW App RSS seems old, but it´s gold for a news app ? I hope @teppo could see this issue. I´m currently using a cached version of the rss. Thanks Teppo for your help! ?
    1 point
  17. I'm a Linux guy end-to-end, but if I had to develop on a Windows machine my go-to solution would be to use https://www.virtualbox.org/ to setup a local Linux dev environment. I've also had a tinker with https://www.docker.com/ which looks like "the right way to go" but I don't it well enough yet.
    1 point
  18. Thanks man! I really do have a field named "limit". Ok ill check all the fieldnames with the reserved names and then try again! Cheers! EDIT: Ok so I renamed the field and the error disapeared! (Y)
    1 point
  19. With the recent CKEditor update to 4.7 the Table Cells Selection plugin can be entirely removed, will do it in the next update.
    1 point
  20. @clsource You must be the only person on the planet who reads these RSS feeds Nevertheless, this issue should be fixed, of course.
    1 point
  21. I guess it's th file compiler, try to disable it for the template (and clear cache).
    1 point
  22. i mainly use the options fieldtype for non relational type selects with huge numbers of options, such as countries, cities, states, and such where i just don't want those things showing up as pages..
    1 point
  23. @Slav only this gist https://gist.github.com/CanRau/662a559a07d6d7c492159d1cd497944f
    1 point
  24. This works for me. User name is generated by PW from first name and last name fields. New user enters email, password and a couple of custom fields. The user must be saved before the roles are added. Hook developed with help, esp from Ryan, in the FormBuilder forum. // Create new user from FormBuilder feu-register form $forms->addHookAfter('InputfieldForm::processInput', null, 'hookCreateUser'); function hookCreateUser(HookEvent $event) { $form = $event->object; if($form->name != 'my-fb-form-name') return; // if it's not the form you want, return // format the first_name and last_name as the username $sanitizer = wire('sanitizer'); $users = wire('users'); // ensure email address is valid and unique $email = $form->get('email'); $emailValue = $sanitizer->selectorValue($email->value); if($emailValue) { // check there aren't any other users with the same email $insiders = $users->find("include=all, email=$emailValue"); if($insiders->count > 0) { $email->error(__("Sorry that email is already in use")); return false; } } // makes sure the username is not already in use. $first_name = $sanitizer->pageName($form->get('first_name')->value); $last_name = $sanitizer->pageName($form->get('last_name')->value); if ($first_name && $last_name ) { $username = $first_name . '_' . $last_name; $u = $users->find("include=all, name^=$username"); if ($u->count > 0) { $number = $u->count+1; $username = $username . $number; } } else { // invalid or blank $username->error(__("Please enter a valid username")); } // ok, all checked, create user account $newUser = $users->add($username); $newUser->of(false); $newUser->email = $emailValue; $newUser->pass = $form->get('password')->value; $newUser->first_name = $form->get('first_name')->value; $newUser->last_name = $form->get('last_name')->value; $newUser->country = $sanitizer->text($form->get('country')->value); $newUser->phone = $sanitizer->text($form->get('phone')->value); $newUser->save(); $newUser->addRole('guest'); $newUser->addRole('my-custom-user-role'); // change to your user role name $newUser->save(); $newUser->of(true); }
    1 point
  25. It seems that Weekly.pw is having troubles with rss too! :C https://weekly.pw/rss/ (is rendering with html, not xml)
    1 point
  26. HELLO. I've recently found that the module doesn't currently work as expected. please do not use till this is resolved. Thanks Should work now. wasn't saving pages properly, but now fixed.
    1 point
  27. Will this do the trick? https://processwire-recipes.com/recipes/activate-all-languages/
    1 point
  28. Hi @zkriszti. Seems you installed blog with the option 'blank template files', hence there is no demo content. Blog's documentation, found here, should help you along. It's incomplete but sufficient to get you started.
    1 point
  29. Hi, just stumbled over a little module that i built for my last project. it helped me to test performance of my rockdatatables module to generate 3000 random json datasets and i want to share it with you. maybe it saves some time for someone. https://gitlab.com/baumrock/RockDummyData/ easy example: $rdd = $modules->get('RockDummyData'); for($i=0; $i<15; $i++) { // this has to be inside the for-loop to always get a new dummy $dummy = $rdd->getDummy(); echo date("d.m.Y H:i:s", $dummy->timestamp) . "<br>"; } more advanced: $json = new stdClass(); $json->data = array(); $rdd = $modules->get('RockDummyData'); for($i=0; $i<3000; $i++) { // this has to be inside the for-loop to always get a new dummy $dummy = $rdd->getDummy(); $obj = new stdClass(); $obj->name = $dummy->forename . ' ' . $dummy->surname; $obj->position = $dummy->job; $obj->office = $dummy->city; $obj->color = $dummy->color; $obj->start_date = new stdClass(); $obj->start_date->display = date('d.m.Y',$dummy->timestamp); $obj->start_date->sort = $dummy->timestamp; $obj->salary = rand(0,10000); $json->data[] = $obj; } echo json_encode($json); you have to store your random datasets on your own into the /data folder. there are several services for creating all kinds of random data on the web - if you know one service that allows sharing those datasets let me know and i can include common needed data into the module
    1 point
  30. I am really missing this module in version 3, are we any closer to an update? I am having to make do with Croppable Image 3, but the crop settings require both width and height values, not allowing either to be flexible.
    1 point
  31. I agree! I was playing around with the styles the other day for about 20 minutes to create a "calm" version, not yet finished, but see the screenshots.
    1 point
  32. I am quite happy with translation options included in PW. Translatable strings like $out = $this->_("Live long and prosper"); // syntax within a class (modules) $out = __("Live long and prosper!"); // syntax outside of a class (templates) are useful for modules and (rarely) in the template system. To make them accesible globally I define a page property in my _init.php file which is prepended to each template. /** * define globally used translatable strings here */ $page->__read_more = __('Read more'); $page->__submit = __('Submit'); Furthermore I use some language related functions (language specific date and time formats). These functions are placed in _func.inc which is included by the _init.php // Include shared functions include_once("_func.inc"); Everything else is content and should be stored in multilanguage fields. (text, textarea, optionselect)
    1 point
  33. Security doesn't magically get better just because files are outside the webroot. The .htaccess file does already block all access to critical files inside the processwire installation and all those files must be accessable by the webserver/php anyways, which makes things equally vulnerable in terms of those security holes which let an attacker execute his own code. And as you said for lots of hosting services it's not even an option to put library files outside the webroot. Obfuscation of the system also doesn't really improve anything considerably. Ask all those people here tracking how many attacks on wp-login.php they get even though their sites are obviously not wordpress sites. As soon as security issues are known they'll be tested no matter of how hard you try to mask your underlying system. It's already possible to share the wire folder for multiple sites, but it's to be considered that all pages also need to be updated at once, which at least for me is rather a downside than an important feature. But still this is already doable. Regarding the assets folder. ProcessWire does have a config to protect the whole assets folder essentially piping all requests to files through php to ensure access is granted for each one. If you only need to saveguard some files and prevent the php overhead for the others you can install the 3rd party "SecureFiles" module, which let's you put files out of the webroot when using this fieldtype. In regards to your point about static site generators. ProcessWire is different to Laravel in that it does depend on a database. And not only an empty one, but there need to be things installed to run ProcessWire. That's not really useful if you want some static site. If you only want html output to be generated from db data you can already use ProCache to serve static html to users with the full power of processwire to generate that html.
    1 point
  34. Maybe if you explained exactly what you would like to achieve? Creating fields only to store unordered lists might be an overkill. Welcome to the forums btw..
    1 point
  35. Hey Pete, I'm short on time, I think this is what you are after. $templates->get("template_name")->fieldgroup->getField($field, true)->label; *written in browser off the top of my head.
    1 point
×
×
  • Create New...