-
Posts
420 -
Joined
-
Last visited
-
Days Won
11
Everything posted by BrendonKoz
-
My difficulties were in understanding how to set up the fields to allow such a scenario, but not make it ridiculously complicated to maintain, or for the editing end-users. I suppose offering a numerical value for the column size (ex: 2-10) per matrix item would also be a valid solution, and far more customizable. As silly as it sounds, the reason I was thinking of offering varied custom sizes is because some of our users are extremely tech-averse, and will mess that up. ?
-
I have a single RepeaterMatrix field that I'm using to generate a bunch of available components. Most of the remaining components left to create are intended for columnar-layout options...in this case, equal width 2-column, 3-column, and 4-column options, as well as a 30/70, and 70/30 split. Ultimately I'd prefer to offer just the column option, and leave the content of the columns up to the end-user, rather than locking it into a "1 image, 1 textarea" style option. I'm having a hard time coming up with a way to offer the dynamic option, while also limiting the column count, and am curious how others might've tried solving this issue. It can't be all that unique! EDIT: Looks like I might (manually) recreate my RepeaterMatrix field and add it into a FieldsetOpen field along with a few settings (fields), such as a min/max number (2-4) and base the layout on that for the frontend. I don't need to force the columns to match the numbers of the column setting, the components would just flow into the number of columns as needed. Definitely not the most efficient, I'm sure, but it should work. It's too bad (at least without RockMigrations) that I can't easily create a duplicate of a RepeaterMatrix field! ?
-
Uploaded PDF file is not the proper, full size; becomes corrupted
BrendonKoz replied to BrendonKoz's topic in General Support
Verified: It was our webhost's (Dreamhost) customized, and overly intrusive mod_security settings. -
Problem with selector after upgrading from 3.0.210 to 3.0.229
BrendonKoz replied to lpa's topic in General Support
@lpa Reading over the ProcessWire Weekly, apparently there was definitely an issue that was fixed in the recent dev version. https://weekly.pw/issue/514/#latest-core-updates -
Problem with selector after upgrading from 3.0.210 to 3.0.229
BrendonKoz replied to lpa's topic in General Support
Just a passing thought without testing or checking, but it looks like banner_file and video_file are string-based values, whereas is_html5 and html are boolean-based (true/false). If that's correct, it's possible that some stricter checking needed to be done for PHP 8.x compatibility, and you might need to break that selector up into multiple parts. -
Hooking ProcessPageAdd::getAllowedTemplates -- Odd behavior
BrendonKoz replied to BrendonKoz's topic in General Support
It seems as though ProcessPageAdd::getAllowedTemplates is called so many times that it doesn't actually always have a $parent value on each call (because of how my authentication is configured). I had to test for null on that value, and exit gracefully if null, and if not then I could enter into my logic. The manual assignment of values worked because it forced a value each time regardless of what was passed into the method as a $parent value for the $event object. EDIT: This now works for a superuser account, but not for a standard account. It seems there's something else in permissions that I'm missing. Updated hook method, without any added business logic of my own, is now: public function allowTemplates($event) { // Not all calls pass in an argument value if (is_null($event->arguments('parent'))) return; // Identify the intended parent template and fetch its allowed (template) children $parent_t = $this->wire->templates->get($event->arguments('parent')->template); $child_t = $parent_t->childTemplates; // Assign the allowed children to an array we can set to return $allowed_templates = []; $allowed_templates[$parent_t->id] = $parent_t; foreach ($child_t as $t) { $t = $this->wire->templates->get($t); $allowed_templates[$t->id] = $t; } // I like sorted values ^_^ ksort($allowed_templates); // Return the expected template array back to the calling process $event->return = $allowed_templates; } If I give "Edit Pages", and "Create Page" permission to the role for the child template, and "Add Children" permission to the parent template for the role, then I can create a Job Listing (child) under the Job List (parent). However, once I do that, everyone with the role can successfully do this, despite me trying to send FALSE (or some similar value) back through any available hooked method. I can't seem to override a strict parent/child relationship. -
Uploaded PDF file is not the proper, full size; becomes corrupted
BrendonKoz replied to BrendonKoz's topic in General Support
Not entirely - we haven't yet identified what on our webhost (Dreamhost) caused the file to become corrupted and only upload a portion of the file. What we do know, however, is that it's not a fault of ProcessWire. ? Because it's only occurred on one PDF for all the files we upload/share, it's entirely possible there was also some issue with the file itself. I'm going to wait to follow up with our host if/when we discover another file that shows this symptom. I appreciate the follow-up. ? -
Backstory: I'm working on expanding access to permissions via a specific role, by using a FieldTypeTags on both user accounts and pages alike, thereby giving me (and others) the ability to control access per-page. The logic therein hasn't been fully fleshed out, but I keep getting stuck; for instance: on the Page List (admin home) screen, the "Add" button on hover shows up, but clicking on it threw an error that I didn't have permission (it was a parent-child relationship that the child was only allowed on that parent, and there's only ever allowed to be one parent). The role doesn't have page-create (or page-add) permission because the only template that is currently access-controlled is the home template...so theoretically, all templates can be created (I'd think?). I was having trouble where template permissions were seemingly overriding my hooks that were supposed to deny access, so I removed all but "home" role permissions. Anyhow... After finding Robin's TemplatesChildPages module it let me find a hook that I could use to forcibly override template permissions (saving/publishing does work). Unfortunately, I've only been able to get the "Add New" form to render when I've created the array in the ProcessPageAdd::getAllowedTemplates (after) hook when I create the return value's (template) array manually. (In this case it's a "job-list" parent template [indexes employment offerings], and 'job-listing' child template that describes the employment position.) So the following code allows the form to render and work as expected: $this->addHookAfter('ProcessPageAdd::getAllowedTemplates', $this, 'allowTemplates'); // ... public function allowTemplates($event) { $p = $this->wire->templates->get('job-list'); $t = $this->wire->templates->get('job-listing'); $event->return = [ $p->id => $p, $t->id => $t ]; ksort($event->return); } Obviously that will only work for my explicit example above while I test adding that particular template. So I went back and adjusted the hook to make it dynamic. Unfortunately, the following code throws an exception. public function allowTemplates($event) { $parent_t = $this->wire->templates->get($event->arguments('parent')->template); $child_t = $parent_t->childTemplates; $allowed_templates = []; $allowed_templates[$parent_t->id] = $parent_t; foreach ($child_t as $t) { $t = $this->wire->templates->get($t); $allowed_templates[$t->id] = $t; } ksort($allowed_templates); $event->return = $allowed_templates; } I've taken the $event_return value and processed it through a good old fashioned echo '<pre>'; var_dump($event->return); die('</pre>'); then taken the output (copy/paste) and saved it to a file, for each version above. I used WinMerge (to quickly compare) and the files are identical. The exception that is thrown, for the dynamic version, reads: ProcessWire: ProcessPageAdd: Template "job-listing" is not allowed here. But, as far as I can tell, the parent and child values exist in $event->return after my hook is run in both examples...yet only one seems to be working. Does anyone have any possible thoughts on this??
-
Looks like @Robin S had similar thoughts. ? https://processwire.com/modules/verify-links/
-
Uploaded PDF file is not the proper, full size; becomes corrupted
BrendonKoz replied to BrendonKoz's topic in General Support
I can't seem to reproduce it on my development server (mirrored PW website), so it must be something related to the webhost. Thanks for having me take a closer look. -
I am still using the outdated Xenu Link Sleuth to run a spider from my desktop against all links. It's fairly thorough, and you're essentially hitting your site with a decent amount of traffic all at once, but it mostly works (it still checks many external links - one level deeper than it should - even though I tell it not to). I do also have Ryan's FieldtypeVerifiedURL in use, but that - on its own - only checks links held within that fieldtype. A modern version of the same tool would be Screaming Frog's Link Checker. There is a free version, but it only checks up to 500 links. I run a check once a month for a single organization's web properties; it's a bit pricey for a once-a-month run for us, unfortunately. Otherwise, it seems like the best modern software-based option out there for the task.
-
I think the simplest would be to take advantage of some additional modules that can make this easier for you. Hanna Code (and add instructions for users in the CKeditor Notes field) TextFormatterOembed Or use a separate field, like FieldtypeOembed (since you'd usually want a video as either a link, or a full column fill anyway). Otherwise, you'd likely need to find, install, and configure custom CKeditor plugins that would handle this for you. This is also possible to do, but since the above is pretty easy, I didn't quite look this method up. ?
-
That might be another thing to test then, too - see if the automatic ZIP upload and decompression setting of a file field that ended up getting used in a, let's say FormBuilder form, which then creates pages for the user...would allow a PHP file to be created, and accessible, by a nefarious site user. In hindsight it seems silly to allow such a process to occur, but when you're so focused on the intended uses of something like this, the unintended sometimes is missed. (ex: Having a local writer's community website managed by ProcessWire, and allowing them to upload ZIP archives of text, html, photos, markdown, etc., to then be published for others to read/see - and then overlooking the potential for an HTML file to reference an external site via iframe that does some fun things - it's not specifically a ProcessWire issue, it's an oversight in development)
-
Has anyone experienced a scenario where a PDF (or other) file that's been uploaded, and shows as having been successfully uploaded, is reporting as an improper size, and then doesn't load correctly when attempted to be accessed/downloaded/viewed from the website? I have a PDF that, I believe, was generated from Canva. It is 4.5MB in size. During upload, the JS upload GUI reports the proper size in the progress bar, but then once complete, shows a filesize that is not the same as the original (2.5MB in this case). Unfortunately, it also seems to break and corrupt the file. It is indeed smaller. Thus far, I've manually uploaded, via FTP, the file overtop of the one processed by ProcessWire, but if this comes up again, I'm not sure what to look at. I have FileValidatorSVG installed, but the file extension here is definitely PDF. Also installed that might process files: WireRequestBlocker, SearchEngine File Indexer, WebP to JPG. I thought I'd recently seen a topic about this, but when trying to find it again, was unable.
-
This might be a question for @ryan, though I'm not aware of any selector for this, but again, I'm, unfortunately, also not well-versed in a multilingual setup. It does appear, based on @bernhard's discovery, that looping through the available result set of all options can get you what you need...I think.
-
How to protect files from being downloaded directly via url
BrendonKoz replied to hintraeger's topic in API & Templates
Have you tried the template settings for file-level access control? It might not be exactly what you want (without some fiddling), but it's what currently seems the closest thing to what you're looking for. -
I took Ryan's old Page Edit Per User module and modified it to: Allow users to assign access on pages they have edit access on (and pages they create) Check a field on the page, and current user, and make sure there is a matching value (ex: multiselect field on both the user account and the page) Allow adding pages so long as they have access to a parent page Setup: Assign a role that has "page-edit" granted, but no templates are explicitly assigned to this access. A multiselect text tag field is assigned to both the user profile template, and any templates of pages that I want the ability for access levels to be controlled. (example values of tags: HR, PR, IT, Administration, ...etc...) When a user has a tag value assigned that matches a page's tag value, access to edit (and/or add) is granted. It's mostly working (from the page tree) (I thought it was, the add button is visible, but the same error is displayed when clicking it); I have one instance where a parent isn't displaying the add button for children, but I'll look at that shortly... What definitely is not working: the "Add New" button is (surprisingly) properly displaying templates of pages that users have access to add based on my changes, but once a user tries to use that button, it displays the following error: This makes sense since the role doesn't assign any explicit templates, but now I'm trying to override that. I suspect once I fix this that there will be another area I'll also need to hook, but... This message is part of ProcessPageAdd::___execute(). I tried to hook into `ProcessPageAdd::getAllowedTemplates` because in `execute`, it throws that error only if the template of the page to add isn't already defined in ProcessPageAdd::allowedTemplates. I might be going about this all wrong, but in the init() method of my adjusted PageEditPerUser, I have the following: wire()->addHookBefore('ProcessPageAdd::getAllowedTemplates', $this, 'hookAllowedTemplates'); ...and then the method: /** * ProcessPageAdd::getAllowedTemplates hook * */ public function hookAllowedTemplates($event) { // bd('hookAllowedTemplates'); // bd($event, 'event'); // bd($event->object, 'event->object'); // bd($event->arguments(), 'event->arguments'); $event->replace = true; $allowedTemplates = []; $allowedTemplates[input()->get->template_id] = templates()->get(input()->get->template_id); return $allowedTemplates; } One thing I struggle with, without others' examples, is what return value (and format) is expected from pre/post hooks. In this case I tried to completely replace the call to ProcessPageAdd::getAllowedTemplates because the value of $event->object->allowedTemplates in the post-hook is similar to a numerically indexed (by template ID) array of a template object (but contains a few more properties), but I still received the error as shown above. (I know I'll need to do more checks on the values assigned in the above method call depending on scenario; right now my tests all have valid parent and template IDs, so I just want to get that working first.) Any potential thoughts, either at what to look at, or where to further debug? (...or more code to share?)
-
I unfortunately haven't had any experience working on a multilingual site, but hopefully merging the two following solutions together will get you on your way?
-
Are you able to see the categories from the public side of the interface when you're logged in as admin? If so, it might just be a permissions issue. If not, there's unfortunately too little information to go by in your description to really identify what's going wrong. Can you elaborate a bit more? Is the visibility just a UiKit thing, or is it a PW page attribute? How are your associations (parent/children) configured? What does your categories.php content that (1)queries for the categories and then loops through to display them look like?
-
If it's only an issue on Apple devices, then it's likely either (1)an update to Safari, or a (2)coincidence that both device's browsers got some sort of strange file corruption in their cache. Another options is that (3)it is just something kind of weird. Give it a day, turn the device(s) fully off and see what happens the next day. Sometimes hardware likes a nice rest, too. You could try hard-refreshing the pages on your Apple devices to see if that helps, or clear cookies and temporary cache (which may also delete saved passwords or logged-in accounts on websites for those devices).
-
The fun, and not-so-fun (in this regard) thing about ProcessWire is that it gives a lot of control over how to use it to the developer(s) creating the website(s) with it. It's a CMS/F (Content Management System/Framework). The reason I state this is because doing what you did, depending on how the original developer handled things, could work. Typically though, when you create a field, you then add that field to a template (or multiple templates) you wish to use it in, and then with the page(s) that are assigned that template, you reference it from within the PHP code of the template file(s). There are ways to create globally accessible fields so that it will always be accessible to editing from the interactive administrative back-end, but with something unlikely to be changed by a standard end-user (such as a Google Analytics script), you should be able to just edit the template files directly, and hopefully the prior developer made it easy enough to identify which file contains the code for the standard HTML headers. There are some confusing jargon when you're just getting started with ProcessWire: Templates, and Pages There are "template files" and "[system] templates". ...and "pages" in ProcessWire are essentially units of storage, since nearly everything is a page within the system, essentially a custom-named object that docs refer to. So you create a "page" and usually refer to "$page" objects, but $page objects can have fields (properties that hold values) that are also $page objects. ? Here's a good place to start: https://processwire.com/docs/tutorials/hello-worlds/ If you'd prefer a video walkthrough, although it's a bit advanced, it's recent and does also go through the basics.
- 1 reply
-
- 1
-
-
Are there any hooks that adjust template sort? Are there any template-based settings for pages that specify the default child sort? I haven't set it myself, but the "Fields" page's sort status under "Admin > Setup" in the page tree might also be set...?
-
If you haven't yet noticed it, @teppo has hit the 500th issue of PW Weekly! That is a ridiculously massive milestone and an amazing achievement, and after some quick maths, also tells me that he's held strong for almost 10 years now! I'm not sure what's more surprising, that he's managed to keep it going continuously for this long, or that I remember when he started it... That's a long darn time. I may not be a hugely active member of the community, but I'm darn proud to be a part of it regardless. Thank you so much for your devotion to the PW Weekly project, @teppo!!!!
- 5 replies
-
- 26
-
-
-
New post: Using date range fields in ProcessWire
BrendonKoz replied to ryan's topic in News & Announcements
My favorite part of the blog post (and what I was thinking about while reading): ♥ Thanks, Ryan! -
The "Thanks" trophy is nice in that it provides reputation points back to members, but aside from a little ego boosting, I don't think it has any terribly high value or merit -- with perhaps the exception of visually providing a means to let other visitors know what replies are worth reading carefully? The "mark as solution" feature is not enabled, or is at least hidden. I'm not sure why the email notifications are still worded that way, but you won't be able to find that button. ?