-
Posts
5,034 -
Joined
-
Days Won
340
Everything posted by Robin S
-
We're on the same wavelength - I meant turning it off in the Panel Selector. ? Ending the session if/when someone does that sounds like a good idea.
-
The no time limit sounds good, but I usually close the panel after I've switched user because it takes up screen real estate. Maybe just the End Session button would be enough, or maybe force the User Switcher icon into the debug bar when it's active (currently you can exclude that icon from the debug bar while a User Switcher session is active, although I don't know why anyone would do that). Thanks.
-
Hi @adrian, Sometimes I want to spend a whole day using User Switcher so I'm wondering if the maximum session length could be increased beyond 60 minutes. I'm sure there must be a good reason why it has a limit, so if it would potentially cause problems to raise the limit for everyone maybe there could be some $config option that would define the session limit? Thanks.
-
Yep, perfect, thanks! Just to spell it out for any future readers... if($session->tracyUserSwitcherId) { // Run this code only if browsing via User Switcher //... }
-
$user->isSuperuser() will return false just like you show in your screenshot, which is expected because User Switcher is active. But what I'm wanting is something like the pseudocode $user->isReallySuperuser() that would return true when User Switcher is active. Now it doesn't need to be some method of $user, but I'm wondering if Tracy might be able to offer something that allows for a simple way to check if User Switcher is active and being used by a superuser (not sure if users less than superuser could even access User Switcher - I've never needed to allow that). Or maybe Tracy already does expose something that could be easily checked for this purpose?
-
Hi @adrian, If I'm working on a site that other users have access to I'll often do something like: if($user->isSuperuser()) { // Run this code for me only //... } But if I'm presenting as another user via the User Switcher panel then this won't work. Do you know of an easy way to check if the current user is in reality a superuser but is currently browsing via User Switcher? Thanks for any suggestions.
-
If you can create a simplified demonstration case you could open a core GitHub issue because id.sort is supposed to cause results to be in the order of the supplied IDs. For now you could follow the approach used in my FindMerge module, where array_slice() is used to get a slice of the IDs according to the current page number: https://github.com/Toutouwai/FindMerge/blob/cbc6f43138508a52ae095c7041dbb969cc7d7bf7/FindMerge.module#L86-L99
-
@Arcturus, I just released v0.1.4 which adds a hookable method for users like yourself who want to do advanced customisation of the CKEditor inputfield, so you don't need to hack the module itself. See the updated readme. Setting the stylesSet property is working for me. $wire->addHookAfter('InputfieldMarkupCKEditor::ckeReady', function(HookEvent $event) { /** @var InputfieldCKEditor $cke */ $cke = $event->arguments(0); /** @var FormBuilderForm */ $form = $event->arguments(1); /** @var FormBuilderField $field */ $field = $event->arguments(2); if($form->name === 'test_form' && $field->name === 'my_cke_markup_field') { $cke->contentsCss = '/site/templates/MarkupCKEditor/contents.css'; $cke->stylesSet = 'ckstyles:/site/templates/MarkupCKEditor/ckstyles.js'; } }); CKEDITOR.stylesSet.add( 'ckstyles', [ { name: 'Special heading', element: 'h2', attributes: { 'class': 'special-heading' } } ]); Make sure the prefix you are using in the setStyles property matches the style set name in the JS file.
- 17 replies
-
- 1
-
-
- module
- form builder
-
(and 1 more)
Tagged with:
-
v0.2.0 of the module is released, which is a fairly major update that brings support for Repeater, FieldsetPage and Repeater Matrix fields. Using the "Field widths" field you can quickly set the width of inputfields within a Repeater/FieldsetPage field or within each Repeater Matrix type. Repeater: Repeater Matrix:
-
-
@formulate, it sounds like you want to have some prioritised subset of the results interleaved with the rest of the results, so they are distributed rather than grouped near the end where they would otherwise appear. There isn't any "sort" value you can use in a selector to do this because sort can only work by ordering results based on some specific column in the database, and no such column exists for your case. So like @DaveP said, you need to get all the results and then apply the sort order yourself. But when you have large numbers of results you want to avoid loading all the results in a PageArray. It's more efficient to work with just the IDs and then get paginated results from those IDs, and to do that you can use the id.sort feature that @Jonathan Lahijani mentioned. Here's a demo of how you might do this. This is simplified to just use templates to distinguish between the priority results and the other results but you will be able to adapt it to your case. // Do the custom sorting using only page IDs for efficiency $priority_ids = $pages->findIDs("template=colour"); $other_ids = $pages->findIDs("template=country"); $merged_ids = []; // Loop over the $other_ids (this should be the larger of the two arrays) foreach($other_ids as $key => $id) { // Use modulo operator to insert one priority ID for every two other IDs if($key % 2 === 0) { $merged_ids[] = array_shift($priority_ids); } $merged_ids[] = $id; } // If there happen to be any priority IDs left over when the loop is finished, add them at the end if(count($priority_ids)) $merged_ids = array_merge($merged_ids, $priority_ids); // Now use id.sort to get pages matching the IDs in paginations of 20 $results = $pages->find([ 'id.sort' => $merged_ids, 'limit' => 20 ]);
-
Yes, that's exactly what it does. It works through the supplied selectors in order and appends the results of each to the last (with the provisos covered in the readme) but the returned PageArray is efficiently paginated which is important for performance if you are dealing with large numbers of results. In your case you are only retrieving 20 results which you're not paginating so you don't need this module for that scenario.
-
This new module can also be useful for these kinds of cases: It doesn't actually use the "id.sort" feature but will give the same kind of result in a similarly efficient way.
-
Find Merge Adds a Pages::findMerge() method that allows multiple PageFinder selectors to be merged into an efficient paginated set of results. This can be useful when you need more sophisticated sorting of results than what would be possible using only the sort value in a single $pages->find(). Details $results = $pages->findMerge($selectors, $options); $selectors is required and must be an array of selectors. Each selector can be in string format or array format. The findMerge() method will loop over the selectors in the order supplied, adding matching pages to the final results. $options is an optional associative array of options. limit (int) Limit for pagination. start (int) Manually override the start value rather than have it be automatically calculated from the current page number. excludeExisting (bool) Whether or not to exclude pages in each selector that have already been matched by a previous selector. Default is true. keepFirst (bool) When excludeExisting is false then a page might match more than one selector in the supplied array. But each page can only appear once in the results and if keepFirst is true then the page will appear in its earliest position in the results, whereas if keepFirst is false it will appear in its latest position in the results. Default is true. As a shortcut you can supply an integer as the second argument and it will be treated as the limit for pagination. Basic usage For most use cases only a limit will be needed for the $options argument. $selectors = [ 'title%=yellow', // title contains "yellow" 'title^=z', // title starts with "z" 'title=elephant', // title equals "elephant" 'template=colour, sort=-title, limit=3', // 3 colours in reverse alphabetical order 'template=country, sort=title, limit=40', // 40 countries in alphabetical order ]; $results = $pages->findMerge($selectors, 10); if($results->count) { echo "<p>Showing results {$results->getPaginationString()}</p>"; echo "<ul>"; foreach($results as $result) { echo "<li><a href='$result->url'>$result->title</a></li>"; } echo "</ul>"; echo $results->renderPager(); } Advanced usage The following notes are only relevant to rare cases and most users can safely skip this section. In the demo example the colour page Yellow will potentially match both the 1st selector and the 4th selector. Because of this the excludeExisting and keepFirst options will have an effect on the results. excludeExisting option false Note that the 4th selector asks for 3 colour pages (limit=3). By default excludeExisting is true, which means that when the 4th selector is processed it is interpreted as saying "find 3 colour pages in reverse alphabetical order that have not already been matched in an earlier selector". We can see that there are 3 pages in the results from that selector: Violet, Red, Orange. But if excludeExisting is set to false then the results are different. The matches of the 1st selector (Yellow, Yellow Warbler) are not excluded from consideration by the 4th selector (the 4th selector matches will be Yellow, Violet, Red), and because each page can only appear once in the results this means that the 4th selector ends up only adding 2 more pages to the results. $selectors = [ 'title%=yellow', // title contains "yellow" 'title^=z', // title starts with "z" 'title=elephant', // title equals "elephant" 'template=colour, sort=-title, limit=3', // 3 colours in reverse alphabetical order 'template=country, sort=title, limit=40', // 40 countries in alphabetical order ]; $options = [ 'limit' => 10, 'excludeExisting' => false, ]; $results = $pages->findMerge($selectors, $options); keepFirst option false As described above, the Yellow page potentially matches both the 1st and 4th selector. By default Yellow will appear in its earliest position within the results, i.e. the position resulting from it being matched by the 1st selector. But if keepFirst is set to false (and excludeExisting is false) then it will appear in its latest position within the results, i.e. the position resulting from it being matched by the 4th selector. $selectors = [ 'title%=yellow', // title contains "yellow" 'title^=z', // title starts with "z" 'title=elephant', // title equals "elephant" 'template=colour, sort=-title, limit=3', // 3 colours in reverse alphabetical order 'template=country, sort=title, limit=40', // 40 countries in alphabetical order ]; $options = [ 'limit' => 10, 'excludeExisting' => false, 'keepFirst' => false, ]; $results = $pages->findMerge($selectors, $options); keepFirst has no effect when excludeExisting is true. https://github.com/Toutouwai/FindMerge https://processwire.com/modules/find-merge/
-
Thanks for the report @monollonom, should be fixed in v0.2.4
- 18 replies
-
- 2
-
-
- inputfield
- images
-
(and 2 more)
Tagged with:
-
Maybe it's not intuitive but an equals sign matches pages in a Page Reference field regardless of whether it is a "single page" field or a "multiple pages" field with more than one page selected in it. So it must be some other issue, like maybe your page you are trying to find is unpublished or hidden?
-
You just need a plain equals sign. $pages->find("template=adebate, deb_inter=$page->id"); And usually I just use $page alone because the string value of a Page object is its ID. $pages->find("template=adebate, deb_inter=$page");
-
How to customize/modify the HTML generated by PW?
Robin S replied to Lumi's topic in Getting Started
In recent PW versions it's possible to insert new repeater items at any position, so if your customer wants to insert an item at the top they can click the "Insert new item before this one" button on the first repeater item. See the video at the top of this blog post: https://processwire.com/blog/posts/new-repeater-and-repeater-matrix-features/ Though I'm not sure why new repeater items added this way are not expanded when they are added, so I've opened a GitHub issue about it: https://github.com/processwire/processwire-issues/issues/1596 -
If you are adding the class in a hook rather than in an inputfield you are creating then the likely reason is that your hook is firing too late, after this module has already done its work. You would need to hook at the renderReady state and may need to adjust your hook priority to be sure of adding the class in advance of this module. Remember that this module also provides a hookable method allowing you to disable the module for specific inputfields - see the Usage section in the readme.
-
Probably the first step of "Add module"... ...should be updated to include any rules about how the repo needs to be organised. @ryan But most modules that I've seen abide by the following principles, so that's probably a good way to go: 1. Name the repo the same as the module, in your case "ProcessIndieAuth". 2. Put the module files and readme in the top level of the repo. Includes or assets could go in subfolders when needed.
-
multi-instance and unpublished repeater items
Robin S replied to Jennifer Stock's topic in General Support
It sounds like output formatting is off for the page in question. I haven't used multi-instance so I'm not sure if it's normal for pages retrieved this way to have output formatting off by default or if it's a bug. But you can turn output formatting on for your page like this: // $p is your page from the other instance $p->of(true); // Now output field values from $p -
The labels are settings/properties of InputfieldSelectImages so you would need to customise them there rather than via FieldtypeDynamicOptions. You'd use a hook like this: $wire->addHookAfter('InputfieldSelectImages::renderReadyHook', function(HookEvent $event) { $inputfield = $event->object; $field = $inputfield->hasField; $page = $inputfield->hasPage; // Some test here using $inputfield/$field/$page $inputfield->label_unavailable = 'This is my custom label.'; }); The styling is based on the core InputfieldImage, and rightly or wrongly the equivalent icon there is centered within the button, excluding the thumbnail border. So I don't want to change from that generally. But now that the icon has been changed to a cross instead of the earlier trash icon it does look like it could come up a couple of pixels so I've done that. Of course you can always tweak the styling to your liking with custom CSS as you're doing. Done.
- 18 replies
-
- 1
-
-
- inputfield
- images
-
(and 2 more)
Tagged with:
-
I think you want something like this: // Get all the tags that are used in this client's videos $tags_in_use = new PageArray(); foreach($client->videos as $video) { $tags_in_use->add($video->tags); } // Sort the tags if you like $tags_in_use->sort('title'); // Output the used tags in the sidebar foreach($tags_in_use->sort('title') as $tag) { // ... }
-
When you enable device mode in the dev tools the user agent will change and therefore the fingerprint will change. I solve this when developing locally with the following in config.php: if(in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) { $config->sessionFingerprint = false; } If you're working on a remote site and don't want to change the fingerprint settings then you can use an incognito window when viewing the front-end in device mode.