Jump to content

Robin S

Members
  • Posts

    5,008
  • Joined

  • Days Won

    333

Everything posted by Robin S

  1. I'd be totally fine with that. It could be a "Don't create field" checkbox and you could even use some custom CSS to put it somewhere subtle and out-of-the-way. That way it's not distracting/confusing for people who use the module in the standard way but is available for those who want it.
  2. That sounds sensible. I guess Pluralize would need to be reinitialised with different settings depending on if a field is being created or not, so you could put that JS into a function with a parameter that switches the type of initialisation and then call that on window load and on checkbox change. Or there are probably other ways too.
  3. Hi @adrian, This will probably sound like an odd request given the name of the module... What do you think about adding an option to not actually create a Page Reference field but only create the templates and pages (if any)? The smart template naming and template restriction features are so useful that I often execute the module and then just delete the Page Reference field because I don't need it. I'm not sure if you or anyone else ever do this, but if I'm not the only one maybe it would be a handy addition to the module?
  4. Sounds like something is interfering before ProcessPageView::pageNotFound can execute. You can check by using Tracy Debugger to dump $url inside the hook and see if the hook is firing or not. If not then it might be caused be something in .htaccess or in Jumplinks. To check you could copy the site to your local machine, replace .htaccess with a clean copy and uninstall Jumplinks - whether it's worth the trouble depends on how important it is to you to get those redirects working.
  5. I can see a few issues, mostly relating to your formatTags setting: 1. The Format plugin is for block-level elements and the <a> element you have included is not block-level. 2. Normally list formatting is applied with the dedicated <ul> and <li> buttons and not via the Format dropdown. 3. You are configuring format tags but you haven't included the Format dropdown in the toolbar, so the format tag options aren't going to be available the user. 4. If you specify format tags beyond those configured by default in CKEditor (p;h1;h2;h3;h4;h5;h6;pre;address;div) then you have to configure corresponding "format_(tagName)" settings. This is the cause of the JS error. From the documentation: 5. Usually you don't want TextformatterEntities applied to a field that is going to contain HTML. If what you are trying to do is remove the heading options from the Format dropdown then you can set Format Tags to "p" only and the NumberedList, BulletedList and PWLink toolbar settings will allow those corresponding tags also.
  6. @Ben Sayers, if you're still having problems and just need a solution to get the redirects working you could hook ProcessPageView::pageNotFound in /site/init.php $wire->addHookBefore('ProcessPageView::pageNotFound', function(HookEvent $event) { $url = $event->arguments(1); // The old URLs you want to redirect from (relative to site root) $redirects = [ '/blog/foo/', '/blog/bar/', ]; if(in_array($url, $redirects)) { // Get the blog landing page however suits $blog_page = $this->wire('pages')->get('template=blog'); // Redirect to blog landing page $this->wire('session')->redirect($blog_page->url); } });
  7. Check that you have given the role in question the "page-lister" permission.
  8. You need to pass your settings to $config->js() in a renderReady() method. https://github.com/processwire/processwire/blob/7d4ca45673152436ea492b6577341ee3550e2821/wire/core/Inputfield.php#L1224-L1244
  9. Attempt to log in via the LoginRegister module several times in short period of time using an incorrect password.
  10. Welcome to the forums @skoskie ? The Comments fieldtype already includes a star rating option: https://processwire.com/blog/posts/processwire-2.6.21-upgrades-comments-more-on-pw-3.x/#new-star-ratings-for-comments-fields
  11. @msavard, in this module HTML tags are not supported inside attributes. But you could use Markdown for the same result, for example: In your attribute: Claims filed between **February 16 - December 10** will receive a [partial exemption](https://www.google.com) for that year. In your Hanna Tag code: <div class="message-box"><?= $sanitizer->entitiesMarkdown($text) ?></div>
  12. Maybe: check_access=0 https://processwire.com/docs/selectors/#access_control
  13. Awesome, works great!
  14. I'm sure you're right, but I'm not 100% clear on what you mean here. It seems like both include and exclude settings would use OR conditions: exclude (role1 OR role2 OR role3) include only (role1 OR role2 OR role3) Or maybe you mean AND/OR in terms of combining the two settings? "exclude (roles) AND include (roles)" versus "exclude (roles) OR include (roles)" I imagined using one setting or the other but not both, but maybe there are some situations where a user would want to combine them.
  15. Hi @adrian, I have a little problem with the User Switcher panel: there's a config option for limiting the list of users that appear in the panel, which is great because often there can be a lot of front-end-only users. But the problem for me is that the option gets defined in terms of roles that are excluded rather than included: I'm not sure how common this is for others, but I often give back-end users (who I want to be able to switch to via the User Switcher) front-end roles because they can also be "members" as well as "administrators". So these kinds of users have multiple roles. What do you think about adding an "include only these roles" option for User Switcher as well as a "exclude these roles" option? Or maybe you have another idea of how this might be accommodated?
  16. v0.1.10 released. Now that new core ways of setting field widths in template context have been introduced it seems that users are sometimes setting a field width using a core input and then saving the Edit Template form. Although it's not necessary to save the Edit Template form after adjusting a field width using a core input (those settings are AJAX-saved), it's not unlikely that users will do this and in these circumstances the old width stored in the Template Field Widths inputfield was overwriting the new width. So from v0.1.10 onward the widths entered into the Template Field Widths inputfield are only saved if Edit Template is saved with the Template Field Widths inputfield in a open state. And it's recommended to use the default "Collapsed" config option for Template Field Widths if you think you might also use core inputs for setting field widths.
  17. All good if another way is added to open files in PhpStorm, but I use the editor:// protocol with PhpStorm and never had any problem with it. It's been a long time since I set it up but I expect I followed the PhpStorm docs and I don't remember it being difficult.
  18. Yes, there are core permissions built in for this purpose. https://processwire.com/docs/user-access/permissions/#user-admin-permissions https://processwire.com/blog/posts/new-user-admin-permissions-automatic-version-change-detection-and-more-2.6.10/#new-user-admin-permissions
  19. It all depends on how your original image was created. Was it saved at maximum quality? Was it passed through some sort of optimisation process/service (TinyJPG, CompressOrDie, etc) that compressed the image and reduced the filesize? Your PW resizer settings are asking for maximum quality, minimum compression, and therefore you can expect relatively large filesizes. And the PW resizer is not going to produce filesizes as small a specialised optimisation service, particularly one that you customise the settings of per image.
  20. Yes, by catching the exceptions. See example here:
  21. @Orkun, do you know about $page->listable()? It determines whether a page may appear in Page List (and also PageListSelect inputfields, which is probably something you want too). So you could do: $wire->addHookAfter('Page::listable', function(HookEvent $event) { /* @var Page $page */ $page = $event->object; if(!$page->editable() && !$page->addable()) $event->return = false; }); You can hook ProcessPageListRender::getNumChildren to customise the child count. But in some cases depending on what is determining a page's listable status you might decide it's not worth the trouble. Here's one way you might do it (in /site/ready.php): // Work out which templates are editable or addable for the user and store them on the $user object // Doing this here to avoid doing it repeatedly in the getNumChildren hook if(!$user->isSuperuser() && $page->template == 'admin') { $user_roles_ids = $user->roles->explode('id'); $allowed_templates = []; foreach($templates as $template) { $edit_add_roles = array_merge($template->editRoles, $template->addRoles); if(count(array_intersect($user_roles_ids, $edit_add_roles))) $allowed_templates[] = $template->name; } $user->allowed_templates = $allowed_templates; } // Set a selector to correct the children count $wire->addHookBefore('ProcessPageListRender::getNumChildren', function(HookEvent $event) { $user = $event->wire('user'); if($user->isSuperuser()) return; $selector = 'template=' . implode('|', $user->allowed_templates); $event->arguments(1, $selector); }); Be aware that there are some other areas you probably want to consider if you are hiding pages in Page List. Here are some pointers to get you started: Pages that can be found in the admin search - look at manipulating the selector by hooking ProcessPageSearch::findReady Pages that can be found in Lister - look at manipulating the selector by hooking ProcessPageLister::getSelector
  22. Try hooking after ProcessPageEdit::buildForm. ProcessPageEdit::buildFormContent only contains the page template fields and not the fields from the Children, Settings, etc tabs. Another hurdle is that the value of InputfieldPageAutocomplete is always an array, and ProcessPageEdit expects the value of the parent_id field to be an integer. This seems to be working: $wire->addHookAfter('ProcessPageEdit::buildForm', function(HookEvent $event) { /* @var InputfieldWrapper $form */ $form = $event->return; $orig_pi_field = $form->getChildByName('parent_id'); $attrs = [ 'collapsed', 'required', 'label', 'icon', 'id', 'name', 'value', ]; $new_pi_field = $event->wire('modules')->get('InputfieldPageAutocomplete'); $form->insertAfter($new_pi_field, $orig_pi_field); $form->remove($orig_pi_field); foreach($attrs as $attr) { $new_pi_field->$attr = $orig_pi_field->$attr; } $new_pi_field->maxSelectedItems = 1; }); $wire->addHookAfter('ProcessPageEdit::processInput', function(HookEvent $event) { /* @var InputfieldWrapper $form */ $form = $event->arguments(0); if($form->id !== 'ProcessPageEditSettings') return; $pi_field = $form->getChildByName('parent_id'); if(!$pi_field || !$pi_field->isChanged()) return; $parent_id = $pi_field->value; $parent_id = (int) reset($parent_id); /* @var Page $page */ $page = $event->object->getPage(); $page->parent_id = $parent_id; });
  23. I also have this question. Which is the recommended branch to use? @Soma
  24. The method that sets the filename is here: https://github.com/processwire/processwire/blob/655c4cdd245fa4990d010c06ccfcfd37a04c0fde/wire/core/Pagefiles.php#L554-L599
  25. As an alternative to step 2 and adding the matched images to cloned fields, in step 6 you could copy the matched files to the page's folder in /site/assets/files/. That's probably the easier approach. Edit: here's some API code you could execute in the Tracy console... // Find all image fields $image_fields = $fields->find("type=FieldtypeImage"); // Find all templates that contain those image fields $tpls = new TemplatesArray(); foreach($image_fields as $image_field) { /* @var Field $image_field */ $tpls->add($image_field->getTemplates()); } // The page that contains the unorganised images - update ID to suit $unorganised = $pages(1287); // Find all pages with missing images $pages_with_missing_images = $pages->find("template=$tpls, id!=$unorganised"); // Loop over those pages foreach($pages_with_missing_images as $p) { // Get the directory for the page $page_dir = $p->filesManager()->path; // Loop over the image fields foreach($image_fields as $image_field) { // Continue if the page doesn't contain the image field if(!$p->fields->has($image_field)) continue; // Get images as Pageimages object regardless of formatted value foreach($p->getUnformatted($image_field->name) as $image) { // Look for a matching image among the unorganised images $match = $unorganised->images->get("name={$image->basename}"); if($match) { // Copy to the page directory if a match is found $files->copy($match->filename, $page_dir); } else { // Display (or log) a message about unmatched images d("No match found for image '{$image->basename}' in field '{$image_field->name}' on page '{$p->title}'"); } } } }
×
×
  • Create New...