Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by PascalKonings

  1. @Sebi Any chance you have time to take a look at my issue above?
  2. @Sebi I'm running into a problem deleting a repeater item through the API, or any page for that matter. Using my code below I'm getting an error public static function deleteEvent($data) { $data = AppApiHelper::checkAndSanitizeRequiredParameters($data, ['id|int']); // $data->id returns an integer wire('pages')->get($data->id)->delete(); // Using a static ID also fails // wire('pages')->get(1066)->delete(); return [ 'message' => 'deletion successful', 'status' => 200 ]; } The error I'm getting is: devmessage: {message: "Trying to get property 'id' of non-object", location: '/myDev/wire/core/PagesEditor.php', line: 296} error: "Internal Server Error" This line is within the isDeleteable function, where it tries to get the ID of the page that needs to be deleted, however it seems the $page: else if($page->id === $this->wire('page')->id && $this->wire('config')->installedAfter('2019-04-04')) { $error = "it is the current page being viewed, try \$pages->trash() instead"; } I've set up the route without any auth or roles, so it should work from that perspective. Other routes getting and posting are working fine! And running the API from the template directly works perfectly: wire('pages')->get(1066)->delete(); Am I missing something here?
  3. Hi Bill, yes it is an object and contains an id and all other information in the repeater field. Deleting it using @Jan Romero suggestion still throws me an error in the module "App API" that I'm using to delete this item: devmessage: {message: "Trying to get property 'id' of non-object", location: '/Applications/MAMP/htdocs/hkg/wire/core/PagesEditor.php', line: 296} error: "Internal Server Error" However deleting it from PHP without the module using: wire('pages')->get(1372)->delete(); seems to work fine. And it is the exact same code as in my App API endpoint. Must be a bug in the module then...
  4. After searching through this forum and not being able to find a working solution, thought I'd try it here. I must be overlooking something really simple. I have a template with a repeater field, containing a number of items. I want to use the API to remove one of these items, based on its ID, save the repeater (if necessary) and then save the page on which it resides. // The page with template "agenda" $agenda = wire('pages')->find("template=agenda")[0]; // The event field is the repeater field here // Getting the repeater item by ID $event = $agenda->event->get('id='.$id); // Disable output formatting $agenda->of(false); // Remove the event item from the event repeater $agenda->event->remove($event); // Not sure if this is needed // $agenda->event->save(); // Save the page $agenda->save(); Sofar I'm getting this error: Trying to get property 'id' of non-object Which seems to be because of the remove action: $agenda->event->remove($event); If I remove this line, all seems to work as intended, but obviously the repeater items is not being removed. What am I missing here?
  5. @ryan @Sebi Found it! I had maxUrlSegments set to 2 in my config file #doh
  6. @Sebi Thanks for this great module, I'm testing it for a project right now. However I'm running into a slight problem, not sure if this is a bug or it's something on my end. I'm testing it on two PW 3.0.165 instances and in one of them everything works perfect. In the other I can't seem to edit an application to set an apiKey in the admin. When clicking it (/processwire/setup/appapi/application/edit/1) it renders the 404 of the website instead of showing the edit page of the application. I have two languages setup for this project and also formBuilder module. Other than that, I don't see any differences with the other working project. The applications overview (/processwire/setup/appapi/applications) does work the way it should. Do you have any idea where this could be going wrong? Update: I removed all modules from the failing project that I had installed (FormBuilder, Language support), but to no avail. I can navigate to /processwire/setup/appapi/applications/ which lists all applications, and /processwire/setup/appapi/application/edit (without an ID and it will give me a missing ID message within the admin). As soon as I add an ID (/processwire/setup/appapi/application/edit/1) it will fail, throws a 404 outside of the admin. I also cleared out my ready.php to prevent any hooks causing issues. @ryan You obviously can't provide support for a custom module, but is there anything here that sounds familiar? Could there be a routing or permission issue here? Is there some caching going on somewhere that might be causing this?
  7. Hi, I'm building a picture gallery, consisting of multiple pages. On each page I would like to add tags to my images, which I can do nicely using the predefined image tags I can set up. However, I was wondering if it is somehow possible to fill the predefined image tags with more dynamic values, like for instance a list of pages (using title or a different field of that page, adhering to the rules for tags). This would make it more flexible for me, as I would not have to have multiple different images fields with different sets of predefined tags.
  8. Thanks @horst, Adding a count check did in fact solve the problem. if(count($page->banner) > 0) { $thumb = $page->banner->getRandom()->size(200, 200); echo "<a href='$thumb->url'>"; echo "<img src='$thumb->url' alt='$thumb->description' />"; echo "</a>"; }
  9. Hi all, I have an images field on my template, which can contain multiple images, returning an array. When trying to get either first() or getRandom() image of this array and then applying size(width, height) to it, the image will render properly resized, however in the PW logs I find: Fatal Error: Call to a member function size() on null. I can't understand why. When limiting the field to only 1 image and applying size, no error occurs. Also when looping through my array and applying size to each individual image, no error occurs. Does anyone have any clue as to why the image renders properly, but the log gets filled up with an error? // No errors foreach($page->banner as $image) { $thumb = $image->size(200, 200); echo "<a href='$image->url'>"; echo "<img src='$thumb->url' alt='$image->description' />"; echo "</a>"; } // Error in the logs, however rendering properly $random = $page->banner->getRandom(); $thumb = $random->size(200, 200); echo "<a href='$random->url'>"; echo "<img src='$thumb->url' alt='$random->description' />"; echo "</a>";
  10. Thanks, Sakkoulas and Adrian, I will contact my hosting provider as well to see if he can fix the problem!
  11. Hi Sakkoulas, did you by any chance solve this problem yet? I'm running PW 2.4.0 on a Windows machine and am running into the same problem. Frontend is working fine on my end, problem only occurs in the Admin environment. I'm on PHP 5.3.28.
  12. Thanks Adrian, your suggestion made the difference! I indeed had not set the parent template correctly. Apparently the underlaying templates inherited those settings. Updating the parent template to add children and create pages then displayed the "copy" button in the tree
  13. Hi, in PW 2.4.0 I have setup a role "publisher", containing the permission to Clone a page and Clone a tree of pages. All Permissions for this role: Delete pages Edit pages View pages User can update profile/password Clone a page Clone a tree of pages The user that is being set to publisher should then be able to view and edit, but also clone a page or tree of pages. Within the templates' Access tab, I have selected the publisher role to be able to: VIEW PAGES EDIT PAGES CREATE PAGES ADD CHILDREN Am I missing a "CLONE PAGES" option here? On the family tab, I have set "Can this template be used for new pages?" to "Yes". For some (for me) unapparent reason, I do not have the option to copy a page from within the tree, the button is missing, even though the template and role/user seems to be setup properly. How can I get this to work? Kind regards, Pascal
  • Create New...