-
Posts
5,008 -
Joined
-
Days Won
333
Everything posted by Robin S
-
When you want to change a page's url or httpUrl in a hook you do this by hooking Page::path - the URLs are derived from the path. The classic post about this is Ryan's CMSCritic case study: So for a hook like this... $wire->addHookBefore('Page::path', function(HookEvent $event) { $page = $event->object; if($page->template == 'news_item') { $event->replace = true; $event->return = "/my-custom-path/$page->name/"; } }); ...the results are...
-
I don't have a multi-language installation to test on but it should be possible. You'll have to work out the best way to use conditionals to construct your selector but the default language selector would look like... $result = $pages->find("repeater_element.body%=foo"); ...and the non-default language selector would look like... $result = $pages->find("repeater_element=[body.data{$user->language}%=foo]");
-
You can use my Custom Inputfield Dependencies module to do this.
-
Yes, it is true, because all of those settings are handled by the image inputfield and when you add an image via the API the inputfield is not involved. So you have to do you own checks, resizing, etc. For some starting code take a look at my AddImageUrls module: https://github.com/Toutouwai/AddImageUrls/blob/bed9f2a910c3b120756e35e84ff734f345160bfa/AddImageUrls.module#L119-L171
-
I use this plugin and it works nicely: https://plugins.jetbrains.com/plugin/7448-zero-width-characters-locator
-
See the selectors documentation for sub-selectors: https://processwire.com/docs/selectors/#sub-selectors There are two syntaxes available: square brackets and dot, with the dot syntax being shorter and arguably easier to read, but having some limitations. It's not quite clear to me how many levels of nesting exist in your case but your selectors would look something like this with two levels of nesting: // Square brackets syntax $results = $pages->find("page_reference_1=[page_reference_2=[text|headline%=pencil]]"); // Dot syntax - probably not as useful in your case because pipe OR conditions are not allowed in the field portion of the selector $results = $pages->find("page_reference_1.page_reference_2.text%=pencil");
-
This sounds like it relates to change tracking, with changes to the custom fields not being detected. Did you see the API example in the module readme, where track changes is specifically set for the custom field being set? Having said that, when I tested I wasn't able to save changes to ImageExtra custom fields via the API regardless of the trackChange() call or if the description was also set. This question probably belongs in the ImageExtra support topic so the module author might see it, although they haven't been active here lately so not sure how well the module is being supported currently.
-
v0.2.1 released. This is a fairly major update in that there has been quite a bit of refactoring. Please be alert for and report any issues. ProcessWire >= v3.0.0 is now required. This release adds a new hookable HannaCodeDialog::buildForm() method that lets you build the dialog form in the hook rather than setting inputfield options as pseudo-attributes in the Hanna Code tag settings. From the readme... Build entire dialog form in a hook You can hook after HannaCodeDialog::buildForm to add inputfields to the dialog form. You can define options for the inputfields when you add them. Using a hook like this can be useful if you prefer to configure inputfield type/options/descriptions/notes in your IDE rather than as extra attributes in the Hanna tag settings. It's also useful if you want to use inputfield settings such as showIf. When you add the inputfields you must set both the name and the id of the inputfield to match the attribute name. You only need to set an inputfield value in the hook if you want to force the value - otherwise the current values from the tag are automatically applied. To use this hook you only have to define the essential attributes (the "fields" for the tag) in the Hanna Code settings and then all the other inputfield settings can be set in the hook. Example buildForm() hook The Hanna Code attributes defined for tag "meal" (a default value is defined for "vegetables"): vegetables=Carrot meat cooking_style comments The hook code in /site/ready.php: $wire->addHookAfter('HannaCodeDialog::buildForm', function(HookEvent $event) { // The Hanna tag that is being opened in the dialog $tag_name = $event->arguments(0); // Other arguments if you need them /* @var Page $edited_page */ $edited_page = $event->arguments(1); // The page open in Page Edit $current_attributes = $event->arguments(2); // The current attribute values $default_attributes = $event->arguments(3); // The default attribute values // The form rendered in the dialog /* @var InputfieldForm $form */ $form = $event->return; if($tag_name === 'meal') { $modules = $event->wire('modules'); /* @var InputfieldCheckboxes $f */ $f = $modules->InputfieldCheckboxes; $f->name = 'vegetables'; // Set name to match attribute $f->id = 'vegetables'; // Set id to match attribute $f->label = 'Vegetables'; $f->description = 'Please select some vegetables.'; $f->notes = "If you don't eat your vegetables you can't have any pudding."; $f->addOptions(['Carrot', 'Cabbage', 'Celery'], false); $form->add($f); /* @var InputfieldRadios $f */ $f = $modules->InputfieldRadios; $f->name = 'meat'; $f->id = 'meat'; $f->label = 'Meat'; $f->addOptions(['Pork', 'Beef', 'Chicken', 'Lamb'], false); $form->add($f); /* @var InputfieldSelect $f */ $f = $modules->InputfieldSelect; $f->name = 'cooking_style'; $f->id = 'cooking_style'; $f->label = 'How would you like it cooked?'; $f->addOptions(['Fried', 'Boiled', 'Baked'], false); $form->add($f); /* @var InputfieldText $f */ $f = $modules->InputfieldText; $f->name = 'comments'; $f->id = 'comments'; $f->label = 'Comments for the chef'; $f->showIf = 'cooking_style=Fried'; $form->add($f); } });
-
I just submitted a pull request with fixes for the overflow positioning, offset when CKEditor is in inline mode, and overrides for the <ul> padding and margin coming from AdminThemeUikit. https://github.com/BitPoet/ProcessCKInlineComplete/pull/4
-
It's possible, but not as simple as it should be because it seems that the option() method of Datepicker (and Timepicker) is not working for the stepMinute option. Instead it seems you have to destroy and re-init the datepicker if you change stepMinute. In some custom admin JS, for a field named "date"... // For a Datetime field named "date" with time enabled $('#Inputfield_date').on('focus', function() { // Get the existing options for the Datetimepicker var options = $(this).datetimepicker('option', 'all'); // If the picker has the default stepMinute setting... if(options.stepMinute === 1) { // Set custom stepMinute setting options.stepMinute = 15; // Destroy picker $(this).datetimepicker('destroy'); // Re-initialise picker $(this).datetimepicker(options); } });
-
Here's an example... The page structure: Some pet species have breed child pages and some do not. The selector string for selectable pages for the breed field is "parent=page.species". In ready.php: $wire->addHookAfter('ProcessPageEdit::buildForm', function(HookEvent $event) { /* @var InputfieldForm $form */ $form = $event->return; $breed_field = $form->getChildByName('breed'); if(!$breed_field) return; $species_with_breeds = $event->wire('pages')->find('parent=/selects/pets/, children.count>0'); $breed_field->showIf = 'species=' . $species_with_breeds->implode('|', 'id'); });
-
See how PW determines $config->ajax here. So you may need to set the X-Requested-With header:
-
Do you mean you tried to upload a WebP image to an Images field? If so that's not supported - the blog post explains that WebP is an output format only:
-
It doesn't look like there is a way to keep HTML comments intact when using the core Markup Regions feature. Even if there was a way to set the "exact" option you mentioned (which there isn't currently because the Markup Regions methods aren't hookable), comments are also removed here. You could make a feature request at GitHub for an option to keep HTML comments.
- 1 reply
-
- 4
-
-
-
There is a honeypot option. There's a JS-based approach that goes back a long time... ...and a more recent addition... https://github.com/processwire/processwire/commit/8405c586f03a2a0a6271b5edd5ba9361f768da6a
-
@Zeka, you can hook before any Process execute method that the user has access to and replace the output. You can see an example here where I replace ProcessLogin::executeLogout (because that is something that all users have access to). I like the sound of @elabx's suggestion of adding a new execute method and accessing the URL segment for it, but with some quick testing I couldn't get that to work. But that's probably just me.
-
Ah right, unfortunately AdminThemeUikit::renderBreadcrumbs() returns early unless some protected class properties are set, and there is no setter method provided. It's a shame that AdminThemeUikit wasn't designed with flexibility for customisation in mind, because it means that users like yourself have to create a totally separate theme that duplicates almost the entirety of the AdminThemeUikit code just to achieve a few minor changes. It would have been nice if something like Markup Regions could have been employed in the theme template files. But it looks like there's no better way for now, so I've merged your PR.
- 79 replies
-
- 2
-
-
- breadcrumbs
- admin
-
(and 2 more)
Tagged with:
-
Very slow boot time - please help me find the cause!
Robin S replied to sodesign's topic in General Support
Some thoughts... What about any auto-prepended _init.php and/or auto-appended _main.php - any code in there that would impact performance? Bear in mind that the PW debug mode and Tracy Debugger have their own memory usage, DB queries, etc. The Tracy overhead in particular could vary a lot depending on what panels are in use. To get a fair comparison across the EE and PW sites on the server you should disable PW debug mode and Tracy and use some consistent performance measurement technique/tool on both sites. -
Thanks @flydev, but that solution feels less than ideal - I think there is a better way. If you want to implement the AdminThemeUikit breadcrumbs in your custom theme (which you would have to in order for the Breadcrumb Dropdowns module to work) then you can just call AdminThemeUikit::renderBreadcrumbs() because it is a public method. So in your custom theme template files where you want to output the breadcrumbs you can do something like this: echo $modules->get('AdminThemeUikit')->renderBreadcrumbs();
- 79 replies
-
- 1
-
-
- breadcrumbs
- admin
-
(and 2 more)
Tagged with:
-
problem with identical named images and wireZipFile
Robin S replied to simonGG's topic in General Support
In theory yes, but in practice you will hit PHP memory and timeout limits at some point. Just try it and see how you get on. -
problem with identical named images and wireZipFile
Robin S replied to simonGG's topic in General Support
Probably one of the $sweepstake_children doesn't have any images. Probably best not to rename the images within the page because that results in the loss of potentially useful filename data and would break any links to the images within CKEditor fields. Instead you could copy the files to a temporary directory, renaming them in the process, then create the zip and download from there. Here is some code you can adapt for your purpose: // Create temp directory $td = $files->tempDir('to-zip'); $td_path = (string) $td; $files_to_zip = array(); foreach($page->children() as $child) { $image = $child->images->first(); // Continue if no image exists if(!$image) continue; // Set path including new filename as needed $new_path = $td_path . "{$child->id}.{$image->ext}"; // Copy image to new path $success = $files->copy($image->filename, $new_path); // Add new path to array if($success) $files_to_zip[] = $new_path; } // Set destination path for zip file $zip_path = $td_path . time() . '.zip'; // Create zip file $success = $files->zip($zip_path, $files_to_zip); // Send download if($success) $files->send($zip_path); // Optionally remove temp directory now rather than waiting for it to automatically expire $td->remove(); -
Not so long as you keep it outside of the /wire/ folder.
-
1. If you put your PHP file in the site root it won't be affected by the htaccess restrictions. You could also put it any other place besides those places with restricted access. 2. See the "Files" tab in the template settings: "Disable automatic prepend of file..." / "Disable automatic append of file..."
-
When output formatting is off the value of a Images field is a Pageimages object (WireArray). So you have to do: $page->pageBanner->first()->focus(10,10);
-
See Ryan's post here: