Jump to content

Search the Community

Showing results for tags 'delete'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Categories

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 23 results

  1. After working with PW for quite so time i came to my first issue: After testing around I added pages "part" with few fields and repeater. $p = new Page(); $p->template = 'part'; $p->parent = '/parts/'; $p->name = $pageName; $p->save(); $p->of(false); .... // adding repeater $store = $p->pStores->getNew(); $store->sCount = $sCount; $store->sPartNr = $sName; $store->sPrice = $sPrice; $store->sStore = $pages->get(24464)->id; $store->save(); $p->pStores->add($store); $p->save(); added about 1600 items. Later on I deleted them Using foreach ($pages->get('/parts/')->children as $p){ wire('pages')->delete($p); } Now i can't add any repeater items to new pages I create using code above. It gives me error Can't save page 0: /1473421482-73-1/: It has no parent assigned Now I try to delete repeater field and recreate it. But it says that Can't delete template 'repeater_pStores' because it is used by 1685 pages. But there are no pages. I looked in DB. and found that repeater fields still hold values for pages that does not exists. [EDIT]: found that pages still exist in db. So i deleted them manually. Recreated field but same problem stands. Im not sure in witch step I fcked up, but can someone point fingers at me and tell what i did wrong or why its not working?
  2. I have 100+ spam/Russian user accounts on a semi-test site. Is deleting them one by one the only option? Is there no way to select a whole page of spam user accounts and batch delete them?
  3. Hi all, I use version 3.0.62. Is there a way to delete all children of a page with one click - without parent page? thanks
  4. Hi all, Just wondering if its safe to delete the content of the cache table manually within the database?
  5. Last night I run into issue. I was trying to empty my trash that have 140 000+ pages init. All pages have repeater fields. When I pressed "Empty" on trash menu I wasn't able to use back-end for 2h+ (I kept refreshing page when It time-outed). After PW process was done 30k pages were deleted. I'm still left with 110k pages to remove. Is there a way to safely remove all pages but with increased speed? Thanks
  6. Hello! I have a strange problem with the "delete" method of the "pages" API-variable: When I insert a parent- and a child-page, and then immediately try to delete first the child- and then the parent-page, an exception is thrown telling me that the parent cannot be deleted, because it still contains a child-page. You can reproduce this behaviour using the following code: <?php require 'index.php'; $parentPage = new ProcessWire\Page; $parentPage->name = 'parent'; $parentPage->template = 'basic-page'; $parentPage->title = 'parent'; $parentPage->parent = $pages->get('/'); $parentPage->save(); $childPage = new ProcessWire\Page; $childPage->name = 'child'; $childPage->template = 'basic-page'; $childPage->title = 'child'; $childPage->parent = $pages->get('/parent'); $childPage->save(); $pages->delete($pages->get('/parent/child')); $pages->delete($pages->get('/parent')); (I put this code into a file called "experiments.php" in the root directory of the site, because I do not know of any better way for quickly testing out code in ProcessWire yet) Can you tell me why this code throws an exception? What am I missing? I am using ProcessWire 3. Thanks for your help! PS: Yes, I know about the second parameter in the "$pages->delete" method, but it should not be necessary to be set in this scenario if I`m correct.
  7. within my module not sure how to delete the current user and redirect without incurring this error: Fatal error: Exception: You do not have permission to execute this module - ProcessPageView (in /srv/users/serverpilot/apps/betaville-dev/public/wire/core/Modules.php line 1022) #0 /srv/users/serverpilot/apps/betaville-dev/public/wire/core/Modules.php(940): Modules->getModule('ProcessPageView') #1 /srv/users/serverpilot/apps/betaville-dev/public/wire/core/Session.php(609): Modules->get('ProcessPageView') #2 /srv/users/serverpilot/apps/betaville-dev/public/wire/core/Wire.php(398): Session->___redirect('/') #3 /srv/users/serverpilot/apps/betaville-dev/public/wire/core/Wire.php(333): Wire->runHooks('redirect', Array) #4 /srv/users/serverpilot/apps/betaville-dev/public/site/modules/Subscribers/Subscribers.module(345): Wire->__call('redirect', Array) #5 /srv/users/serverpilot/apps/betaville-dev/public/site/templates/login.php(27): Subscribers->deleteUser('benjaminbyford5...') #6 /srv/users/serverpilot/apps/betaville-dev/public/wire/core/TemplateFile.php(182): require('/srv/users/serv...') #7 /srv/users/serverpilot/apps/betavi in /srv/users/serverpilot/apps/betaville-dev/public/index.php on line 248 $u = $this->user; // user found and deleted $this->users->delete($u); // send to homepage $homepage = $this->pages->get('/'); $this->session->redirect($homepage->url);
  8. I cannot manage to delete this page upon uninstallation of a Process module I have that was working previously. I thought the only difference would be that I added `namespace ProcessWire;` to the start of the module PHP, however I've tried without it and still I get It is an admin page. Right now I have $get = 'template=admin, parent!=trash, name=importall, include=all'; $gp = wire('pages')->get($get); if($gp->id) { wire('log')->save($log, "$gp->id".get_class($gp).__NAMESPACE__); $gp->delete(); if(!wire('pages')->get($get)->id) wire('log')->save($log, "Deleted Imports page."); } previously $gp = $this->pages->get('template=admin, parent!=trash, name=importall'); if($gp->id) { $this->pages->delete($gp, true); $this->log->save($log, "Uninstalled ". get_class()); } Why will it no longer delete? I can't even do so by the GUI.
  9. I have a module that creates a repeater field on install: $f = new Field(); $f->type = wire('modules')->get('FieldtypeFieldsetTabOpen'); $f->set("name", "iu_maptab")->set("label", "Mapping"); $f->set("tags", "impupd")->save(); $r = new Field(); $rName = "iu_map"; $r->type = wire('modules')->get('FieldtypeRepeater'); $r->set("name", $rName)->set("label", "Map Fields"); $r->set("tags", "impupd")->save(); $f = new Field(); $f->type = wire('modules')->get('FieldtypeSelectExtOption'); $f->set("name", "iu_field")->set("label", "Template Field"); $f->option_table = "fields"; $f->option_value = "id"; $f->option_label = "name"; $f->set("tags", "impupd")->set("columnWidth",50)->save(); $f = new Field(); $f->type = wire('modules')->get('FieldtypeText'); $f->set("name", "iu_value")->set("label", "Source Value Selector"); $f->set("tags", "impupd")->set("columnWidth",50)->save(); $f = new Field(); $f->type = wire('modules')->get('FieldtypeCheckbox'); $f->set("name", "iu_static")->set("label", "Use Static Value"); $f->set("tags", "impupd")->set("columnWidth",50)->save(); $f = new Field(); $f->type = wire('modules')->get('FieldtypeFieldsetClose'); $f->set("name", "iu_maptab_close");//->set("label", "Mapping"); $f->set("tags", "impupd")->save(); $rfg = new Fieldgroup(); $rfg->name = "repeater_{$rName}"; $rFields = ["iu_field", "iu_value", "iu_static"]; foreach($rFields as $rf) { $rfg->append($this->fields->get($rf)); } $rfg->save(); $rt = new Template(); $rt->name = "repeater_$rName"; $rt->flags = 8; $rt->noChildren = 1; $rt->noParents = 1; $rt->noGlobal = 1; $rt->slashUrls = 1; $rt->fieldgroup = $rfg; $rt->save(); $rpg = "for-field-{$r->id}"; $r->parent_id = $this->pages->get("name=$rpg")->id; $r->template_id = $rt->id; $r->repeaterReadyItems = 3; foreach($rfields as $rf) { $r->repeaterFields = $this->fields->get($rf); } $r->save(); Now I can't uninstall it, on account of a field being used in the fieldgroup created for the repeater -- can't delete that field because it's in the fieldgroup which I am trying and failing to delete: $rf = wire('fields')->get('iu_map'); $rt = wire('templates')->get('repeater_iu_map'); $rfg = $rt->fieldgroup; if($rf) { wire('fields')->delete($rf); wire('fieldgroups')->delete($rfg); wire('templates')->delete($rt); } foreach(wire('fields')->find("tags*=impupd") as $f) { wire('fields')->delete($f); } Please help this is such a bother. The fieldgroup should be deleted before attempting to delete the field itself.
  10. Maybe i don't see it but how can i delete pages with admin template? PW 3.0.18 logged in as superadmin - advanced mode on... status: System: Non-deleteable and locked ID, name, template, parent (status not removeable via API) is checked...but i wanna remove this page it's from a failed installation of a module...i've deleted module files and db entries...so far. But the admin page stays.. Regards mr-fan
  11. Hello everyone! I'm not sure the right thread is chosen, but anyway I'll continue. My pages structure looks like Category->Subcategories->Pages A task is to make PW to count Pages,when their amount is changed and write it to the Subcategory's and Category's appropriate field regardless of Pages amount change is made from admin of template. So I'm trying to hook into 'save', 'trash', 'restore' and 'delete' methods from within a site module. 'Save' hook seems to work fine, but hooking into 'trash' requires to track Page->parent and Page->parent->parent the the other way, because they are changed to 'Trash' and 'Root' when 'trash' execution is is finished. The other words, at the moment when I have to count Pages in Category and Subcategory, where the Page was 'thrashed' from, there is already no way to determine, what the Category and Subcategory contained this Page. I'm trying to hook into 'trash' before execution, find Page Category and Subcategory and assign them to an module object property, so after the 'trash' execution I can hook into it again and count Pages in Category and Subcategory, saved in properties. But something causes my before 'trash' hook to execute two times: before and after 'trash', and as the result module object properties contain not Category and Subcategory, but 'Trash' and 'Root' pages. Here is my Code: public $country; public $region; /** * Initialize the module * */ public function init() { $this->pages->addHookBefore('trash', $this, 'prepareTripSave'); $this->pages->addHookAfter('trashed', $this, 'afterTrash'); } /** * Counts 'Trips' in 'Region' and 'Country' * */ public function countTrips($event) { $page = $event->arguments('page'); if ($page->template == 'Trip') { // do only when 'Country' and 'Region' are find if(count($this->country) && count($this->region)) { $this->message('ok'); $amount = $this->region->children("template=Trip")->count(); //count 'Trips' in 'Region' $this->region->setOutputFormatting(false); $this->region->amount = $amount; $this->region->save("amount"); // save only field $this->region->setOutputFormatting(true); $amount = $this->country->find("template=Trip")->count(); //count 'Trips' in 'Country' $this->country->setOutputFormatting(false); $this->country->amount = $amount; $this->country->save("amount"); // save only field $this->country->setOutputFormatting(true); } else { $this->message('nop'); } $this->message("Country: {$this->region->amount}; Region: {$this->country->amount}"); $this->region = ''; $this->country = ''; } } public function prepareTripSave($event) { $page = $event->arguments('page'); if ($page->template == 'Trip') { $this->region = $this->pages->get($page->parentID); // find 'Region' by 'Trip'->parentID $this->country = $this->region->parent; // find 'Country' as a 'Region'->parent $this->message("Before Region: {$this->region->title}; Country: {$this->country->title}"); } } public function afterTrash($event) { $page = $event->arguments('page'); if ($page->template == 'Trip') { $this->message("After Region: {$this->region->title}; Country: {$this->country->title}"); } } Thanks!
  12. Hi, is there any way of deleting the entire contents of an array from the API? I have had some success removing an item with: $page->image->remove($page->image->first()); But as I have to specify the item within remove() I'm not sure how to remove all the items. Thanks
  13. I can't seem to remove a template, I have a template called sitemap - and it reckons it's used by 1 page, however that page has been deleted yet it's not reflected - the 'search' filter also shows up no pages using that template, yet the template still things it's in use. Any way to fix this? cPanel with PW 2.6.1 regards John
  14. I have a system set up in processwire whereas I have an Editor role that can edit content of pages. On my site I have pages like the Home Page, Contact Us, etc, whereas I want them to be able to edit the page content. On the other hand, I have a page set up with children for a product gallery that I want them to be able to add, edit and delete categories and products within each category. For example: (edit only) Home [edit] Contact Us [edit] Product Categories ..... Celing Fans [edit] [add] [delete] ............ ceiling fan #1 [edit] [add] [delete] ..... Lamps [edit] [add] [delete] ............. lap #1 [edit][add][delete] And so on. In my Editor role I enabled page-delete, however, I want page-delete not to show up on the home page, contact us, only in the product category and product pages. Any help is appreciated. thanks,
  15. Hi, I'm just trying to delete file field via API. I want to delete it completely without concerning which pages is using it. I found this code: $fields = wire('fields'); foreach ($fields->find('name=field_name') as $field) { foreach ($field->getFieldgroups() as $fieldgroup) { $fieldgroup->remove($field); $fieldgroup->save(); } $fields->delete($field); } This removes the field from database it is OK. But it doesn't remove the files (from filesystem) that ware added to pages. As I was going through PW source code I've found that I have to save the page also, but it really complicates the thing. The problem starts in FieldtypeFile::___deletePageField method where the $pagefile is handled differently according to field output formatting. If the $pagefile is PageFile, the unlink is called which also deletes the file from filesystem. If the $pagefile is PageFiles the deleteAll is called which only adds hooks on page save. Why is it done this way? This makes inconsistency when deleting the field. Is there some better way to delete the field without caring about pages?
  16. The field is empty, the template has over 2 million pages. So of course caution is necessary... I can't try anything too crazy. When I try to delete the field in admin area, as soon as I click on the confirmation checkbox and submit, it goes straightaway (fraction of a second) to a Bad Gateway 502 (nginx) error page. I also tried the API solution outlined by kongondo here: https://processwire.com/talk/topic/7480-removing-a-field-from-database/?p=72039 - it does not work, the script just stops running (again very quickly) at the save() part. Also tried deleting from the $fieldgroups api variable instead of from $templates. Same issue. Here is what I am getting from debug=true: Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 72 bytes) in /www/wire/core/PageFinder.php on line 306 Call Stack: 0.0000 242496 1. {main}()/www/index.php:0 0.0663 4512544 2. ProcessPageView->execute()/www/index.php:240 0.0663 4512896 3. Wire->__call()/www/index.php:240 0.0663 4512896 4. Wire->runHooks()/www/wire/core/Wire.php:320 0.0663 4515024 5. call_user_func_array:{www/wire/core/Wire.php:365}()/www/wire/core/Wire.php:365 0.0663 4515360 6. ProcessPageView->___execute()/www/wire/core/Wire.php:365 0.0721 4647600 7. Page->render()/www/wire/modules/Process/ProcessPageView.module:172 0.0721 4647784 8. Wire->__call()/www/wire/modules/Process/ProcessPageView.module:172 0.0721 4647784 9. Wire->runHooks()/www/wire/core/Wire.php:320 0.0722 4652776 10. PageRender->renderPage()/www/wire/core/Wire.php:387 0.0722 4653128 11. Wire->__call()/www/wire/core/Wire.php:387 0.0722 4653128 12. Wire->runHooks()/www/wire/core/Wire.php:320 0.0722 4655256 13. call_user_func_array:{www/wire/core/Wire.php:365}()/www/wire/core/Wire.php:365 0.0722 4655592 14. PageRender->___renderPage()/www/wire/core/Wire.php:365 0.0726 4696624 15. TemplateFile->render()/www/wire/modules/PageRender.module:356 0.0726 4696808 16. Wire->__call()/www/wire/modules/PageRender.module:356 0.0726 4696808 17. Wire->runHooks()/www/wire/core/Wire.php:320 0.0726 4698936 18. call_user_func_array:{www/wire/core/Wire.php:365}()/www/wire/core/Wire.php:365 0.0726 4699104 19. TemplateFile->___render()/www/wire/core/Wire.php:365 0.0727 4723816 20. require('/www/site/templates/delete.php')/www/wire/core/TemplateFile.php:169 0.0742 4726296 21. Fieldgroups->save()/www/site/templates/delete.php:14 0.0742 4726648 22. Wire->__call()/www/site/templates/delete.php:14 0.0742 4726648 23. Wire->runHooks()/www/wire/core/Wire.php:320 0.0742 4728464 24. call_user_func_array:{www/wire/core/Wire.php:365}()/www/wire/core/Wire.php:365 0.0742 4728800 25. Fieldgroups->___save()/www/wire/core/Wire.php:365 0.0745 4733760 26. FieldtypeInteger->deleteTemplateField()/www/wire/core/Fieldgroups.php:196 0.0745 4734200 27. Wire->__call()/www/wire/core/Fieldgroups.php:196 0.0745 4734200 28. Wire->runHooks()/www/wire/core/Wire.php:320 0.0745 4736336 29. call_user_func_array:{www/wire/core/Wire.php:365}()/www/wire/core/Wire.php:365 0.0745 4736760 30. Fieldtype->___deleteTemplateField()/www/wire/core/Wire.php:365 0.0745 4737192 31. Fields->deleteFieldDataByTemplate()/www/wire/core/Fieldtype.php:878 0.0745 4737632 32. Wire->__call()/www/wire/core/Fieldtype.php:878 0.0746 4737632 33. Wire->runHooks()/www/wire/core/Wire.php:320 0.0746 4739464 34. call_user_func_array:{www/wire/core/Wire.php:365}()/www/wire/core/Wire.php:365 0.0746 4739888 35. Fields->___deleteFieldDataByTemplate()/www/wire/core/Wire.php:365 0.0754 4743128 36. Pages->find()/www/wire/core/Fields.php:536 0.0754 4743480 37. Wire->__call()/www/wire/core/Fields.php:536 0.0754 4743480 38. Wire->runHooks()/www/wire/core/Wire.php:320 0.0754 4745344 39. call_user_func_array:{www/wire/core/Wire.php:365}()/www/wire/core/Wire.php:365 0.0754 4745680 40. Pages->___find()/www/wire/core/Wire.php:365 0.0758 4749608 41. PageFinder->find()/www/wire/core/Pages.php:199 0.0758 4750048 42. Wire->__call()/www/wire/core/Pages.php:199 0.0758 4750048 43. Wire->runHooks()/www/wire/core/Wire.php:320 0.0758 4751864 44. call_user_func_array:{www/wire/core/Wire.php:365}()/www/wire/core/Wire.php:365 0.0758 4752288 45. PageFinder->___find()/www/wire/core/Wire.php:365 Hope this is enough information for one of you seasoned folks to help me out.Thanks in advance!
  17. Hi, I want to delete 2 pages with $page->delete() after one another . But only one of the pages gets deleted. My code $serverpage = $pages->get($serverId); if ($action == "delete") { if ($serverpage->id) { $serverpage->delete(); //When I comment this out, $serverad further down gets deleted //if ads for that server exist, delete them $serverads = $pages->find("template=advertisement, ad_server={$serverId}"); if (count($serverads) != 0) { foreach ($serverads as $serverad) { if ($serverad->id) $serverad->delete(); //does not get deleted when $serverpage->delete() above executes. } $serverout .= "<div class='alert alert-success' role='alert'>All Ads for the server deleted.</div>"; } $serverout .= "<div class='alert alert-success' role='alert'>Server successfully deleted.</div>"; } else { $serverout .= "<div class='alert alert-danger' role='alert'>Server does not exist and could not be deleted.</div>"; } $serverout .= $serverForm->render(); } When $serverpage->delete() is executed, $serverad->delete() has no effect. When I comment out $serverpage->delete(), $serverad->delete() is working. I don't get any errors and I already checked that $serverad is a valid page object in all cases. Now I'm clueless of what the problem might be.
  18. Hi all, I'm struggling in putting together a process module. I want to trash all pages that belong to a specific user after the user has been deleted. I found one related thread by onjegolders where he is doing things the other way around. In my case I need a process module that hooks after user delete. And I would like to use the wire/modules/Process/ProcessPageTrash.module. It is my first time creating a pw process module. I have read through the basics of creating modules including the wiki article and looked at the code of ProcessPageTrash.module. But I'm having a hard time putting things together. This is what I've got so far: class ProcessCleanupUserPages extends Process { public static function getModuleInfo() { return array( 'title' => 'Cleanup User Data', 'version' => 0.1, 'summary' => 'Deletes all pages that where created by a user after user has been deleted', 'singular' => true, 'permanent' => false, 'permission' => 'user-admin', 'requires' => 'ProcessPageTrash', 'autoload' => "process=ProcessPageList", // What to add here - autoload only on user list page ); } public function init() { $this->users->addHookAfter('delete', $this, '___execute()'); // is this correct? } public function ___execute() { //get user ID $userID = $this->id or $event->id // How to get the user ID? //get all pages that were created by the deleted user $userPages = $pages->get("created_users_id={$userID}"); // syntax for trash pages - call module ProcessPageTrash on $userPages } protected function render() { // print out message to admin after pages are successfully trashed } } ?> I added comments with "???" where I don't know exactly what to do. Any help would be much appreciated. Thank you.
  19. Hi again fellow PWers, A while back I created a newUser module that added a new user when a page (student) was added. This all works great. Today I'm trying to add a delete function to this same module (as we were getting leftover users when students were deleted) but it's throwing NullPage errors. I tried changing the hookAfter to hook Before but am still getting errors. Also strangely it's causing an issue when trying to delete these pages from the trash. I'm getting a "this page cannot be deleted" error. Any pointers would be greatly appreciated ------------------------------------------------------------ <?php class Createnewuser extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Create a new user', 'version' => 101, 'summary' => 'Creates a new user and edits an existing member on saving a member page.', 'singular' => true, 'autoload' => true, ); } public function init() { $this->pages->addHookAfter('added', $this, 'createTheUser'); $this->pages->addHookAfter('save', $this, 'updateTheUser'); $this->pages->addHookBefore('delete', $this, 'deleteTheUser'); } public function createTheUser($event) { $page = $event->arguments[0]; if($page->template == 'student'){ $newuser = new User(); $newuser->of(false); $newuser->name = $page->name; $newuser->pass = $page->password; $newuser->save(); $this->message("New user also added $newuser->name."); } } public function updateTheUser($event) { $page = $event->arguments[0]; if($page->template == 'student'){ $the_user = $this->users->get("name=$page->name"); $the_user->of(false); if ($page->isChanged("password")) { $the_user->pass = $page->password; } if ($page->isChanged("email")) { $the_user->email = $page->email; } $the_user->save(); $this->message("User $the_user->name also updated."); } } public function deleteTheUser($event) { $page = $event->arguments[0]; if($page->template == 'student'){ $the_user = $this->users->get("name=$page->name"); $the_user->delete(); } } }
  20. For some reason when a non-superuser has access to modify users it does not show the Content and Delete buttons (tabs) when editing a user. Is this intended? And what would be the easiest way to re-enable this? Thanks
  21. Hello I wonder how I should do if I want give to my client the permission to delete some specific pages but prohibit others. In my case, the site where I am working on there are "works" pages, that I'd like the client be able to edit/delete but the rest of pages, he can just edit, not delete them. In other word, I'd like my client can be able to delete to pages with template "work" and no other pages with other templates. This should be my sitemap: Home (client can just edit) Works (just edit) - Work 1 (edit and delete) - Work 2 (edit and delete) ... - Work N (edit and delete) Store (just edit) Contact (just edit) Any suggestion? Thanks
  22. The 'global' flag for field is great, untill you don't need that field anymore and you have over 30 templates that have that field assigned... It looks like you have to manually edit every template and delete the field from there, save, then check the checkbox to confirm? Is there a way to do this faster? Thanks.
  23. I made ​​some test page for a new project and given a look to the database, but they are a bit confused. Where are the records? I am a DBA and have fields without tables, it seems strange, even if the good performance of processwire depend from this. I created a page with a table. Simple, very simple with processwire. Now I need a from to insert / update data on another page, and a button or a check box to delete the row. I consulted the APIs, but other than delete Field and PaGE have not found anything. I have to delete fields one by one? (or am I doing something wrong?) A book about processwire with examples would be welcome.
×
×
  • Create New...