Jump to content

torf

Members
  • Posts

    64
  • Joined

  • Last visited

Everything posted by torf

  1. So after going through the database for days without finding any suspicious entries I had a long talk with my client and it turns out - the error wasn't there in the beginning. So @flydev: duplicator is definitely innocent. The error was a simple typo in production ready.php (they are both quite different so it wasn't too obvious). I had two lines with: if(($page->template = "myTemplate") But why this altered the output the way it did I have no idea.
  2. @flydev I'll start with 8 and see where it get's me tomorrow. 😄 @WillyC I'll give it a try but first I have to bring the whole darn thing back to my dev Server. disabling the mods on production is something I wouldn't dare to. No idea if they may loose some settings and both are crucial for the site.
  3. OPening page 3 works directly. But when I try to access another tab I get the next warning about templates. Funny thing - this time the Problem is on page 8. And the same page on my dev site: I've tried with advanced mode and it looks just as it's supposed to look. But you are right. I do not use multi-language (only a german translation) but a couple of modules that do fiddle around with user rights ( Admin Restrict Branch and Page Edit Per User). But those modules are on both sites.
  4. So far I found no strange differences. But that will take some time as the pages are quite different regarding their content. ProcessWire Version is 3.0.184 What I found in my exeptions Protocol is: Template changes are disallowed on page 3 because it has system statusIn /wire/core/Page.php line 2000 And thats the setTemplate function protected function setTemplate($tpl) { if(!is_object($tpl)) $tpl = $this->wire()->templates->get($tpl); if(!$tpl instanceof Template) throw new WireException("Invalid value sent to Page::setTemplate"); if($this->template && $this->template->id != $tpl->id && $this->isLoaded) { if($this->settings['status'] & Page::statusSystem) { throw new WireException("Template changes are disallowed on page $this->id because it has system status"); } if(is_null($this->templatePrevious)) $this->templatePrevious = $this->template; $this->trackChange('template', $this->template, $tpl); } if($tpl->sortfield) $this->settings['sortfield'] = $tpl->sortfield; $this->template = $tpl; return $this; } But I've absolutely no idea why Processwire would try to set a template when opening the admin branch of the site tree.
  5. Thanks for the reply. Both are MyIASM, but what I found is that dev is utf8 while production utf8mb3. No idea if that makes any difference. Doing another export is no option as the production site has hundreds of articles (it's up and running already), but I'll go through it manually.
  6. Database is libmysql - mysqlnd 7.4.33, Server Version: 10.6.11-MariaDB, Server runs on cp1252 West European, DB is utf8mb4_unicode_ci Unfortunately there is no direct phpmyAdmin access without sending my clients admin access to the whole Domain/hosting.
  7. Thanks a lot - I used Version v1.4.21 But the sites are not 100% the same. There is the possibility that something has been changed on production server, or that some read/write access may be different.
  8. I've got a strange behaviour on one site I cannot explain. It looks like my superuser is missing some rights and I cannot find out where i could have compromised the system. - I cannot add any page directly under my root page - if I click on admin pages i get a strange warning (Page 3 is supposedly Admin/Pages) After that I cannot open the page lister. It stays empty and giving me an error with the same text. If I log out sometimes it helps, sometimes it stays that way for some time. - All of my users (including superuser) are missing the "view"button in page lister I tried to add a new superuser, but that makes no difference. Also I've got the same site in my development server where I have no odd behaviour. Has anybody experienced something like that before? (The Site has been moved via Duplicator - maybe that has changed something?)
  9. Oh! I just did not realize that one. Thanks a lot!
  10. I have no idea if that is even possible, but I run into a problem with planning ahead the structure every now and then: If I have multiple templates that use the same field I try to reuse my fields of course. So let's say I have the field: myPictures (Images / jpg / max 5 images / ...). I use that field with different descriptions in multiple Templates. Now the site is in use, and after some month the client decides that in one template there need to be 8 possible upload slots with only png allowed. Now I'm stuck. If I change the field it changes for all, if I make a new field I loose all the uploads that already have been made for this template, if I'm going the safe way and add different fields for every template from the beginning I get to many fields that are maybe never needed. Is there any solution for that problem?
  11. As i ran into the same Problem here is a very simple solution that only uses one loop for grouping (well it's not exactly grouping, but it looks like) $myPages = $pages->find("template=myTemplate, sort=FieldtoGroupby, sort=title"); //select all pages and sort by field you want to group, then by sorting field $lastgroup = "somevalueneverused"; foreach($myPages as $myPage) { $actualgroup = $myPage->FieldtoGroupby; if ($lastgroup != $actualgroup) { echo "<h3>".$myPage->FieldtoGroupby."</h3>"; } echo "<p>".$myPage->title."</p>"; $lastgroup = $actualgroup; } Downside: you only can sort your categories by the field to group by.
  12. Wow. Cool one. It absolutely works. I cannot use it in my special case as I have to use ready.php (the field is used in two templates and only one uses the parent as selector. So I need to use an if statement to determine the actual template), but it's good to know it works that way as well.
  13. Thanks a lot. In that case I just use the normal select. Changing core files only leads to trouble and I try to avoid it if not absolutely necessary.
  14. I have a page reference field that only shows certain pages based on a field on the the chosen page that also exists at the parent page. To get the allowed pages I added in ready.php $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if ($event->object->hasField == "my_page_reference_field") { $page = $event->arguments(0); $zv = $page->parent->name; $event->return = $event->pages->find("template=myTeplate, searchterm=$zv"); } }); As long as I use radiobuttons or select field this works great. But using automplete I get all the pages from the whole site. Does anybody know why this happens?
  15. Thanks a lot. My mistake was to look for the title. That does not work directly. So with your help I managed to get the data I needed. $searchterm = $input->urlSegment1; $myPage = $pages->findOne("template=Template1, title={$searchterm}"); $myList = $pages->find("template=Template2, PRfield={$myPage}"); That works as expected.
  16. I'd need some advice how to search for specific pages that have use a certain value in a page reference field. The task is quite simple: find all pages with a certain template that also use a page reference field with a specific title. $pageList = $pages->find("template=myTemplate, {PRField->title}={$input->urlSegment1}"); I also tried to split it but to no avail: $pageList = $pages->find("template=myTemplate, {PRField->title}={$input->urlSegment1}"); $finalpageList = $pages->find("{$pageList->PRField->title}={$input->urlSegment1}"); I'm absolutely positive that I'm missing a crucial point here.
  17. @flydev Wow. Thanks a lot. That absolutely does work and I'm positive that I'd never figured that out on myself. Thanks again. @Robin S That's a cool approach too. Especially as it is very short. But I'm unsure about the CSS parts. Am I right that those CSS files need to be called directly inside admin.php rather than from site/ready.php ?
  18. I do not think that this would help. It's not so much about handling the pagination. I'd need to turn it off for certain roles. I added two Screenshots to the original post to make it more clear. There are 127 pages under "Zweigvereine", but the user is only allowed to see the one he's able to edit. So he has 2 empty pages before his link appears on the third one. If I could turn of pagination for his role his page would be listed directly.
  19. I have a long list of pages in my backend that uses pagination to be less confusing for my editors. Works great. Now I have another role, where every user with a specific role can edit only his own page out of this list. Thanks to Page Edit Per User and Admin Restrict Branch that works great as well. Additionally I added a small part to my ready.php to hide all the other pages this user cannot edit: if($this->user->hasRole('specificRole')){ $ap = $user->editable_pages[0]->id; //there is always only one page $wire->addHookAfter('Page(id!='.$ap.'|1058)::listable', function($event) { //1058 is the id of the parent page $event->return = false; }); } But my problem is that the pagination still works. So a user with editing rights on a page named "zzzzz" for instance has to klick on the last page of a set of empty pages to see his link. Is there any way I can turn of pagination just for this specific role?
  20. @Zeka I wholeheartedly agree to most of what you wrote. The first version is more beautiful and presumably more performant. But as in most cases this is a small clients projects. Meaning nobody is ever going to look at that code and judge it by those standards. As soon as the page is online no one (including myself) will look at the code for a long period of time. Then my client will ask for some changes and I - or even worse - a new person will open that site and try to figure out how things are happening. And at this point the first version has its flaws. From the viewpoint of structure the second version (although not as beautiful) is better to handle. I have everything regarding one workflow at one point. So anyone not familiar with the code can look for "what happens with field1?" without gathering together bits and pieces shattered over half the document. Of course i can use comments but it's still like "what you are looking for is in shelf 1" vs. "What you are looking for is in shelf 1, 2, 5, 12 and some minor places I surely forgot to mention". So if performance issues are neglectable I'd rather prefer the second version for any page that is not maintained on a regular basis.
  21. I was wondering: when I use the same hooks on different pages, is it better to only use that hook once and divide with if statements or is it ok to call a hook multiple times. Like: $wire->addHookBefore('Pages::saveReady', function(HookEvent $event){ $page = $event->arguments(0); if($page->hasField("field1")) { //do something } if($page->hasField("field2")) { //do something else } }); $wire->addHookAfter('Pages::unpublishReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->hasField("field1")) { //do something } if($page->hasField("field2")) { //do something else } }); or //Things regarding pages with Field 1 //###################### $wire->addHookBefore('Pages::saveReady', function(HookEvent $event){ $page = $event->arguments(0); if($page->hasField("field1")) { //do something } }); $wire->addHookAfter('Pages::unpublishReady', function(HookEvent $event) { if($page->hasField("field1")) { //do something else } }); //###################### //Things regarding pages with Field 2 //###################### $wire->addHookBefore('Pages::saveReady', function(HookEvent $event){ $page = $event->arguments(0); if($page->hasField("field2")) { //do something else } }); $wire->addHookAfter('Pages::unpublishReady', function(HookEvent $event) { if($page->hasField("field2")) { //do something else } }); //###################### Of course the first version looks nicer, but if you have a lot of functions it becomes increasingly confusing to keep track of those functions. The second version makes it much easier to keep logic together but I'm concerned if that will raise trouble with performance.
  22. @BitPoet Oh. I missed that little piece of Information. Thanks a lot. And you're right. I'll have a look into Pages::publishReady. @bernhard and @Jan Romero I admit that it would be nicer without an extra field, but as there is the possibility that the date needs to be changed manually in the future I'd rather go with an additional field before I have to reinvent everything in five months.
  23. I need to show (in my backend) since when a page special type of page has been published (not created, as there may be a long delay between creation and publishing). So I made a datefield in my template and added following code to my site\ready.php $wire->addHookBefore('Page(template=templateName)::published', function($event){ $page = $event->arguments(0); $this->message("the Hook has been called"); if($page->hasField("myDateField")) { $newDate = date("d.m.Y"); $page->myDateField = $newDate; } }); But for some reason the hook is not called when I publish the page. Is there something I'm missing?
  24. My task is to give users edit permission to their specific page (not created by them) as long as the page is unpublished and somehow I can't get it to work. The idea would be user can only access a special branch in the backend (I do not want them to see all the pages) in this branch there are dozens of pages (same template) but each user can only access his personal page as long as the page is unpublished they can edit and save it the publishing permission is with another role as soon as the page is published the user may see it in the backend, but has no more editing permission So the idea was to use Admin Restrict Branch and Page Edit Per User modules which both work great. But Page Edit Per User seems to fiddle with the permissions, so the user can still edit his published page even if he has no page-publish permission. Is there any way I can revoke the page edit permission manually after the page is published (and reinstall it when the page is unpublished again)?
  25. Works like a charm. Thank you very much.
×
×
  • Create New...