Jump to content

MarkE

Members
  • Posts

    1,082
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by MarkE

  1. I've noticed that both the Reno and UIkit admin themes are responsive when accessing pages, but this doesn't apply to modals. If viewing on a relatively small screen (say iPhone 5), part of the modal is always off-screen. Is there a fully responsive theme anywhere? If not, what would be required to achieve it? Or is this a pipe dream? Thanks.
  2. It seems to me that access control in PW is powerful but quite complex. Does anyone know of a tutorial/blog etc. that covers these complexities. I particular, how to make sure that the end result achieves the required access control. From what I have learned so far, a number of things interact: • Whether a page is published, unpublished or hidden • The access given to users of a template • Field level access – both global and as over-ridden in a template • Whether or not a template has an associated php template file • The output formatting of a page, set in a php script (false can disable field-level access controls) These need to be considered in combination to determine what is the actual level of access in any situation. Is there any way of getting an overview of all this? For example, if there is no guest access to a template then that restriction will also apply to any API invoked by a guest action which requires access to a page instance of that template. The only way I can see to allow API access but to prevent direct access is to allow guest access to the template, but not provide a template php file. Is this secure? Also, if fields have restricted access (e.g. no guest access), then any API invoked from the front-end (including webhooks) will not be allowed to see the contents (this is achieved by blanking the contents in formatting). Over-riding this can be achieved either by setting the relevant option on the Access tab of the restricted fields, or by turning off output formatting for the affected page just before accessing it (e.g. $p->of(false); ). See discussion at
  3. Yes. I just mentioned it because it is very big and full of things like <span class="tracy-dump-indent"> | | </span><span class="tracy-dump-key">fuel</span> <span class="tracy-dump-visibility">protected</span> => <span class="tracy-dump-object" ... I have no idea what it does.
  4. ... just having a root around - I seem to have 12mb session file - is that normal?
  5. It seems to be all pages. It was fixed after a reboot last time. I'm inclined to blame windoze - that's the usual source of my problems. Meanwhile, I'll turn Tracy off until I need it then reboot again...
  6. Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 33764184 bytes) in M:\xampp\apps\processwire\htdocs\site-ncog\modules\TracyDebugger\tracy-master\src\Tracy\Helpers.php on line 133 Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 10530816 bytes) in Unknown on line 0
  7. Thanks, but as you say - it ought not to be necessary. Anyway, today it is working ?
  8. It seems to make no difference which panels are enabled (or even none). However, unchecking the "Show debug bar" removes the error from the front end or back end accordingly.
  9. Just got this error message: Fatal Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 25956352 bytes) (line 27 of M:\xampp\apps\processwire\htdocs\site-ncog\modules\TracyDebugger\tracy-master\src\Tracy\assets\Bar\panels.phtml) Any idea what might have caused it or how to fix it? I uninstalled the module and the error went away. After re-installing it, the error came back. The message at the bottom of the screen reads: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 10563584 bytes) in Unknown on line 0
  10. Maybe I am missing something, but I do find it hard to get an overview of what data a given user can access, including via the API. Having fixed the problem in the OP, a different part of the same code then gave problems: When run from the backend this works fine and finds all the relevant children. However, the webhook, coming in as guest returns an empty array. I checked and removed any access restrictions with no luck. I also changed the code to this (i.e. removed the selectors): if (wire()->session->webhook) echo('This mandate details - Title: ' . $this->title . ' Id: ' . $this->mandateId . ' Num of children = ' . $this->numChildren . '<br/>'); $osCollections = $this->children; // was find("template=Collection, paymentStatus!=paid_out"); if (wire()->session->webhook) echo('Number of collections found = ' . $osCollections->count() . '<br/>'); This resulted in the following response to the webhook: This mandate details - Title: Mandate Id: MD0004TV8F2YP3 Num of children = 24<br/>Number of collections found = 0<br/> So $this->numChildren is correct, but $this->children is empty ? FWIW, here is the print_r output immediately afterwards: ( [hooks] => Array ( [PageArray::render] => MarkupPageArray->renderPageArray() in MarkupPageArray.module [PaginatedArray::renderPager] => MarkupPageArray->renderPager() in MarkupPageArray.module ) [count] => 0 [total] => 0 [start] => 0 [limit] => 0 [selectors] => parent_id=2661, sort=sort, status<1024 )
  11. I've been implementing the ideas in the excellent tutorial: https://processwire.com/docs/tutorials/using-custom-page-types-in-processwire/ I really like having a class to mirror certain important templates as it makes organising and structuring code more intuitive (to me) and avoids the need for many hooks. A key aspect of this is the ability to define a Page Class Name for a template, so that any pages with that template will automatically have the correct PHP class. To do this, you need to enable the advanced mode in the site/config.php and then edit the event template in the backend, under the system tab. However, I have a couple of issues that trouble me: The system tab carries a warning "Please note that all of these system settings are intended for ProcessWire system development (not site development). Use them at your own risk." Why is this? I assume that the term "ProcessWire system development" is intended to mean website apps (I am building a club membership site) as opposed to simple websites, and is not referring to the development of the Processwire system itself, but why the health warning? Is it still beta? What are the risks? The behaviour is not quite as I expected. If you create a new page with a template which has a pageClass then a hook after "save" shows the following: after entering the new page title and name and saving the "Add New" form, the page content is displayed. The page has presumably been saved as the "after" hook executes and shows that the template and custom pageClass have been assigned to the saved page, but the PHP class is still shown as Page, not the custom class. after the second save (of the page content), the hook shows that the PHP class is correct - the same as the custom pageClass. Is the behaviour in (2) intentional (and if so, why)? If not, is it a bug, or just unavoidable for some reason? (I also note, BTW, that the page id seems to be 0 after the first "save").
  12. Thanks for that. Reading the explanation (i.e. that the contents are masked by output formatting), I wonder whether it is better to over-ride this for the field in general or just in the specific use case (the webhook). I tried inserting $os->of(false); and the problem was fixed ? It seems to me that if there is only one use case to fix, this approach may be better than generally allowing the API access. However, it's nice to have the choice and this episode once again proves how well-designed PW is (even if its features are not immediately apparent to relative newbies like me!).
  13. ... so I disabled the direct running from the webhook and left the save hook in place. The idea being that when the webhook updated the page, the save hook would then run. Which it did, but still exhibiting the same problem... ... might it be something to do with whether the method gets initiated from the front end (webhook) or back end?.. ... Aha! - looks like the missing fields have additional access restrictions. The webhook, coming from the front end is treated as "guest" so the fields are not visible to it. So I think I may have found the cause - just need to find a solution now ?
  14. Hmm. I moved the code into a new method so that I could invoke it from the browser via a save hook or externally via a webhook. If I invoke it from the browser it works OK, but if it runs from the webhook then the problem persists. And I can't see how Tracy can help in the webhook case (which is why I dumped the vars to the page body).
  15. Thanks for that. I have installed Tracy Debugger, but haven't yet fully comprehended it. I can't get barDump to give me anything - I guess because this whole thing is run from a webhook and not executed in the browser. I'll try initiating the same code from the browser and see what happens...
  16. I'm probably being a bit dim, but I have been struggling a while with this: I'm developing a club membership site and generally it's going pretty well. I'm using custom page types as per this excellent tutorial: https://processwire.com/docs/tutorials/using-custom-page-types-in-processwire/ One such page type is a Mandate, which holds direct debit mandate details (using GoCardless). A method of the Mandate class is called whenever a webhook detects a change in status of a mandate. Two other templates are Payment and Collection. Payment pages (siblings of Mandates) hold details of required payments, whereas Collection pages (children of Mandates) hold details of collections attempted via direct debit. The relevant code of the webhook_update method of Mandate is: if ($event->action == 'created' || 'submitted' || 'active') { $osGCPayments = $this->parent->find("template=Payment, paymentStatus=order_placed, paymentMethod=1154"); // 1154 is id of GoCardless type if ($osGCPayments) { $osCollections = $this->find("template=Collection, paymentStatus!=paid_out"); $totalInCollection = 0; foreach($osCollections as $colln) { $totalInCollection += $colln->paymentAmount; } $unpaid = -$totalInCollection; $payIds = []; foreach($osGCPayments as $os) { foreach ($os->fields as $f){ $this->body .= ('Field: ' . $f->name . ', Val: ' . $os->$f . '; '); } $unpaid += $os->paymentAmount; $payIds += [$os->id]; } if ($unpaid > 0) { $amountInPence = $unpaid * 100; $this->create_payment($client, $mandateId, $amountInPence, $payIds); } } } The problem is that $os->paymentAmount, which has a value on the Payment page, returns no value in the above code. The line $this->body .= ('Field: ' . $f->name . ', Val: ' . $os->$f . '; '); was inserted to aid debugging and puts all the field names and values into the body of the Mandate page. The 'foreach's containing it run and inspecting the output shows that some of the fields have the correct values (including those that uniquely identify the page so that I am sure I am looking at the right one!), but that paymentAmount (float type), paymentMethod (page reference) and paymentDate (Datetime) are shown as empty. RuntimeMarkup and Text fields are shown correctly. The odd thing is that, for the foreach to run, $osGCPayments clearly contains the correct Payment pages, which means that the paymentMethod=1154 selector operated correctly, but paymentMethod is one of the field values that then appears to be empty in the selected pages. BTW, there are no Collection pages yet, so the first foreach does not run. Thanks in advance for any suggestions and apologies if I have done something stupid?
  17. Thanks guys. I'll make a note not to include the cache folder in deployments.
  18. Brief background: the live site is on a shared hosting service. I started developing on that but decided to continue it off-line. The development site is on W10 machine using Xampp. I had no significant trouble setting that up - importing the database using phpmyadmin. I then added a test environment on a Linux box (actually a Pi) running apache2 which is on the private network. I have done this (not with PW) a several times before and it has worked fine. So I exported and imported the database and copied over the files. After a few problems, I got everything running. However, I am getting one persistent warning, only in the test environment: Warning: touch(): Utime failed: Operation not permitted in /media/main/web/processwire/wire/core/FileCompiler.php on line 391 Any clues as to what is causing this?
  19. That's really helpful, thanks. I've had a play with these and they should work well together. I'm particularly impressed with - it will save a lot of PHP head-scratching.
  20. Just installed this and it looks good except that I am having difficulty adding new pages. I get this message: ProcessWire: ProcessPageAdd: Template Member is not allowed here (/members/) The settings I have used are parent = Members (i.e. url= /members/) and Template = Member. All the children of Members have template Member. If I deselect the Template = Member, the new page modal gives a choice of every template except Member. Am I being dim or what? The field is located on a completely different page (Memberships)
  21. Just discovered FieldtypeRuntimeMarkup So I can include PHP in the page edit - it doesn't have to be on an admin template page. Even more choices ? (I'll shut up now and wait for a response)
  22. Apologies - that was the wrong diagram attached in the previous post - this is the one I meant to attach: New website class diagram -Lucidchart.pdf
  23. I'm starting to make some good progress with this. I'm seriously impressed with the PW API, but there is quite a lot to get to grips with. However the documentation (and support here ? ) is very good. I've done some simple ProcessModules and that works well. Now I have a bit of a head scratch. My (partial and draft) class diagram looks like this: New website design - class diagram.pdf Ignore the colour coding for now. What I am trying to decide is how to implement the relationships. It seems to me that PW provides multiple options: Parent-child PageTable PageRef - multiple select Repeating PageRef fields From what I can see, 4 doesn't offer any benefits over 3, which has a cleaner interface. PageTables look nice, but you can't add pages that already exist outside the table. (I saw @Macrura's post in on Nov 25, 2014, but I'm not clear where that code would go. Is there some guidance as to what page relationship type to use where? What would others use for the classes in my diagram? Also, a related issue: when is it best to just use the tree in the back end for admin tasks vs. using admin pages and Process Modules? It seems to me that the tree approach involves less coding, but requires a more tech-savvy user than a custom-coded admin page. Thanks in anticipation of suggestions (and corrections of any misunderstandings on my part).
  24. Aha! I've worked out how to do that now, by adding the 'permission' item in the getModuleInfo array. I didn't see that in the tutorial ? , which is excellent BTW.
  25. Thanks @fbg13. I have seen those and have been building some process modules using the tutorial - which is working well. Am I to understand that I have to explicitly code the access rights into each process module using the API? I was hoping that PW would allow me to use the users-roles-permissions menu in the normal way.
×
×
  • Create New...