Jump to content

Search the Community

Showing results for tags 'restore'.

  • 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
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

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 3 results

  1. Hello, I have a feeling I'm missing an easy thing here (again...). If I trash a page from API with : mypage->trash() Is there a simple way to restore it if needed ? I can do it in back-end, but I'd like to do it through API with something like mypage->restore() but this doesn't exit So if you can give me a little help on that, I'd appreciate. Thanks in advance !
  2. Hi, I've noticed when I trash pages from a PageTable field, then restore them, they are restored to their original location, however the connection is broken with the PageTable field. Is this expected behaviour? Is there a way for it to maintain this relationship? Otherwise restoring it doesn't actually restore it to it's previous state. Note that in this case the parent pages for the PageTable field is not set as the direct parent.
  3. 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!
×
×
  • Create New...