suntrop
Members-
Posts
316 -
Joined
Everything posted by suntrop
-
I am wondering why I need to add check_access to filter user roles // $page->members is a Page reference field to users $members = $page->members('roles=staff, check_access=0'); // output: 4 (for none superusers) $members = $page->members('roles=staff'); // output: 0 (for none superusers, but 4 for superusers) The members field is just a list of people belonging to a certain group. The group is split into users with the role 'staff' and those with just a 'member' role. I want to get only those with the staff role (and later those without that role).
-
So, if I create hooks with the pure purpose of passing $event to other private methods, "it is ok"? On my current example above the tricky part is, almost everything builds up from the tierprice, wich in return builds up the unit price, wich builds the price, … Sometimes I need the total, sometimes I need to get the unit price and sometimes I need the with or without VAT. Like a pyramid. On my very first draft I had a couple functions in _function.php, then I moved on to create all sorts of different/independent hook methods but a lot of methods did the same thing, just with some slightly other output. At the end I thought, what I nice idea to just pass always the $event around
-
Thanks a lot! The first point took me some time, but it is really obvious now The second one though isn't that clear to me. I have code more or less like your example but thought passing the $event always is better, because I can use those methods on its own. While it isn't necessary in the code section above, I have quite a couple of methods I need/want to use directly. I could create a hook for tierprice() as well, and call it $page->tierprice($page, 3) — but this seems wrong to me too. You would create a new method like getTierprice() which in return calls the private method tierprice()?
-
Hi all I am working on my knowledge of PW's hooks … and maybe on PHP OOP in general Now I have got two questions on this hook: // From basic-page.php template $page->price(3, true); // From my module's init() $this->addHook('Page::price', $this, 'price'); // and the method function price($event) { $page = $event->object; $quantity = $event->arguments(0); $vat = $event->arguments(1) ?? false; // Get tier price $unitprice = $this->tierprice($event); $event->arguments(1) = $unitprice; // possible/correct? if ($vat) $unitprice = $this->addVAT($event); return $unitprice; } FIRST Why does the PageArray comes from $event->object and where do know this from (beside just copying code from other forum posts ?) And why is $event->arguments(0) the first variable I pass to my method and not the $page as it says on that doc page: https://processwire.com/api/hooks/#read_arguments SECOND I would like to pass the complete $event (the $page and my arguments) to the addVAT() method. But in that method I need the $unitprice as well. Is it possible and the correct way to just create a new third argument ($event->arguments(2) = $unitprice)? Or do I need to write something like $unitprice = $this->addVAT($event, $unitprice)?
-
I had something similar but changed quickly to PayPalˋs Rest API. You can create subpages on the order pages, or use the repeater field. If you just want to store for technical reasons and „maybe we need to look at“ you can use PW log system and just log the response.
-
I might be wrong, but there is an option on the home template, right? You can force to use only HTTPS. But I don’t know if this passes the option down to child pages
-
I get this notice when using markup cache It is more or less the same from https://modules.processwire.com/modules/markup-cache/ $cache = $modules->get("MarkupCache"); if (!$data = $cache->get("tablerows__pageid_" . $page->id)) { $data = ''; foreach ($page->children('limit=499') as $child): $data .= '<tr>'; $data .= '<td>'; $data .= implode(" | ", $child->title); $data .= '</td>'; $data .= '</tr>'; endforeach; $cache->save($data); } // output cached table rows echo $data; Is there anything wrong or has something changed? Do I need to check if the cache file exists?
-
That is what I was looking for. I did not know there is a context menu for tables. I tried to select the table and click the toolbar button (like it works for links and images). Thanks!
-
When an editor adds a table you can insert a CSS class width, etc. But once the table is inserted I can't find any way to change any of the "meta data" like class, id, width, etc. Usually I provide some table designs (table-a, table-b, table-hover) and the editors can choose one. But if there is a big table and the editor wants to change it, there is only HTML where one can edit that. Or do I miss something here?
-
Thanks for your help! No cPanel, a custom made tool. I had installed Tracy Debugger, but couldn't see anything wrong. Maybe I will check the ProDevTools. On monday I will see t get in touch with someone else. Unfortunately there is no monitoring but I do have rights to install software. Had New Relic on my mind, but you link looks like a quite nice list. I am not that familiar with installing apps on the terminal, but I can clone the server and "test ruin" everything No, there is nothing new the last 30 days. It is a rather small business website. Just usual pages like "About", "Team" etc. There is almost nothing special in there. I will check on MySQL! Currently the site works fine. But I increased memory to 4 GB. I find it hard to believe I am using 4 GB for a tiny website
-
Hi guys Since last night I have trouble with my cloud server. It is a VPS with 2 CPU, 2 GB RAM and just one small website installed (about 30 pages, nothing fancy and less than 50 visitors/day). I am not a server expert, but I would believe these resource should be fine for PW (3.0.42). The hosting company just blames the website script and something uses too much RAM. It worked fine the last six month and I didn't change anything the last 30 days. Is there anything I can do to double check?
-
I need for an web app files that keep their original names. Like “A new flavour from Häagen-Dazs.pdf”. Why? Because my web app is some kind of file sharing (for a company) and those files need to be re-integrated into their original place. The company uses a DMS that partly relies on file names. If they get back “a-new-flavour-from-hagen-dazs.pdf” it’ll break consistency. I tried but couldn’t get rid of the file name validation. Is it possible to disabled it? I couldn’t find a hook for file uploads. Is it possible to hook into it and change back the original name? ... or instead, save the original name in the file description? So when I download the file I can pass in the original name? Another ugly way would be to just store file paths in a multiplier or just a folder path (but that excludes admin users uploading files within PW) I read a blog post by soma with an interesting solution to store files as a dedicated page. This would come in handy, because I need to manage access on all files anyway. Most files are coming from and front end upload form. But the admins will work on the PW backend and that is quite combersome to create for every file a new page, name it accordingly, upload the file and create a reference. On github I found a workaround by @matjazp but the Dropbox link isn’t working anymore. https://github.com/processwire/processwire-requests/issues/56#issuecomment-263669255
-
Need more Page access (beside template access)
suntrop replied to suntrop's topic in API & Templates
Well, of course. If I know what I am doing ? I will go through the code at the weekend. As mentioned on my first post above, there are two challenges. The other is completely different, so I’ll create new thread. Hopefully you guys can help there too -
Need more Page access (beside template access)
suntrop replied to suntrop's topic in API & Templates
Thanks. I saw this before and thought it was just for the page tree on the back end. I just had a quick look in the code and the hooks and it seems it isn’t intended for front end view permission, is it? -
Need more Page access (beside template access)
suntrop replied to suntrop's topic in API & Templates
Hey guys thanks for your input! I tested several options and both modules above. The dynamic roles are pretty cool and powerful. I think in my situation I would need hundreds of those roles (because sub groups have their own permissions and there are ~5 to 10 sub groups ). As I understand would need to create for each group and each sub group a custom role and a custom dynamic role to add access for those roles to that group/sub group. The UserGroups looks good as well. But I couldn’t see how to work with it. It says “create few groups, look for access tab on pages and try”. I made two groups, added a couple of users to it. But now what? There is no access tab on the edit page I had a look at Ryan’s Page Edit per User. The code looks quite short and easy. Would it be hard to transfer it from the user to the page itself? I mean, it would be nice if the page (group) has a select field where I just need to add useres who can have view access. I “just” need to hook into the viewable method? And will it work with $page->find() -
Hi all. I’m planning a new site/web-app and there are two challenging parts First and probably more difficult is managing access. The site is some kind of file sharing combined with a commenting system. Users can create a comment in their group and upload a file optionally. It is for a company that will share PDF, Excel, etc.. with its clients. The fun part is, there are a lot of groups each with its own access privileges. And even better there need to be sub groups for a subset of users from that group ? For example /groups/acme/ /groups/acme/onlyjohnandjane/ /groups/acme/onlyjaneandjim/ /groups/company-b/ /groups/company-c/ /groups/company-c/only-james-jack-jenny/ As you can see each group (aka company) has a top level page where all the group members have access and there need to be sub pages where only some selected members of that group can have access. Currently only some admin users need to have access to all/more than one group. At the moment I think there are about 30 to 50 groups concurrent. Perhaps they will change their mind and groups won’t be deleted but archived and there are +50 groups each year. Groups need to be set up very easily. Because of that I can’t tell them to create a template, add roles etc. And I am afraid the amount of templates will reach an unusable number. So my second idea to create a process module that creates a group with a template and useres isn’t the best idea. I found two related modules from Ryan, but both have their downside. The Page Edit Per User maybe fits in the most. But I don’t know if it works with my sub groups. Those need custom not inherited access. The Custom Page Roles sounds good as well but won’t work with PW’s API like $page->find() my first idea was to use unguessable URLs like /groups/neiUwnd728ns7nei726e384/ and if I carefully restrict all find() etc to those pages ... but that feels wrong Any ideas? What would be a good and safe way to create my pages?
-
point a new processwire deployment to existing db
suntrop replied to rohith's topic in Getting Started
What data? Data in your new/old MySQL database or actual files and folders? -
Hi LAPS I think Lister was designed for back-end use and will check if the user has proper permissions. Haven’t done that before but you can try to create a new role add the page-lister permission and add that role to the guest user. However, what is in your lister what can’t be rendered with PW’s API? Do you need just the table result or the form with all the search fields as well?
-
// EDIT It works now. There is a conflict with another Pages::saveReady hook, that updates the title, when a particular field is changed. It seems $page->isChanged('fieldname') is true when I create a new page and the field was already set in the source. I'll see how to get a workaround for this.
-
That is a nice solution! I will definitely try this if I can't get my hook to work … but I really would like to know what the problem is with my code. And when it works, I go and try your solution and compare them I am always happy to see how other people find their way to the same outcome. However, on that custom endpoint I would have to run just the same code and clone the page. Well … I'll test it now
-
Yes. At the end I need three buttons and each must clone the page to different destinations, with different templates and different code that runs before the page gets saved. If here is just one clone button I can’t distinguish “how” the page needs to be copied.