Jump to content

Search the Community

Showing results for tags 'Save'.

  • 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

  1. Hello to all of you, has anybody suffered from following: I do something like that: $nr = $page; $nr->of(false); $nr->foo= $bar; $nr->foo2 = $bar2; $page->save(); $p = new Page(); $p->of(false); $p->template = 'foobar'; $p->parent = $pages->get('/bar/'); $p->title = $bar; $page->save(); then populate some more fields and again $page->save(); Everything is working fine and my created confirm save message pops up....the page is saved, but there are 3 outputs giving me $page->title after saving on the frontend. It has something to do with the save method, because when I leave them out everything is working just as designed... Hopefully somebody has advice! Regards
  2. Hi all Seems I've bumped into an issue where, if I save a page or update a module, I'm redirected back to the home page (frontend). I was using 2.5.23-dev, and thought that an update to 2.5.27-dev would fix it, but no luck. No errors showing up in any logs either. The following modules are installed on the site: AIOM Diagnostics Map Marker Data Tables Maintenance Mode SEO Modules Manager Jumplinks Upgrades Template Notes Upon inspection, module/download/ is sending a 302 redirect to /. Interestingly, the inspector says that the following form data was sent to module/download/: godownload: Download and Update (0.0.4) which is the text for the button (was trying to upgrade the Upgrades module). I assume that is the problem? Update: This doesn't happen with every page, however. If I save the home page, I get redirected back to the home page. If I save the "certification" page, I get redirected to the home page. If I save the "donate" page, however, then it saves and reloads.
  3. public function init() { // add a hook after each page is saved $this->pages->addHookAfter('saved', $this, 'populateDefaults'); } /** * Populates model defaults after save for corresponding blank fields. * */ public function populateDefaults($event) { $page = $event->arguments('page'); if($page->template != 'vessel') return; //$this->message("hi {$page->model->hulls}"); if($page->model && !$page->hulls && $page->model->hulls) { $page->set("hulls", $page->model->hulls); $this->message("hi $page->hulls {$page->model->hulls}"); } } This sort of works; the message echoed is "hi 1082 1082". When I set the hulls to null in the above code, it then goes back to "hi 1082". However, it doesn't update the select input in the edit screen, and the "Missing required value" error for that field remains... Also the message shouldn't even be showing if $page->hulls is set... How can I get it to update the field value and the input?
  4. How can I programatically Save() to a Page Type field that contain multiple pages (PageArray)? This attempt fails with no error message, nothing is saved: $p = $pages->get(1234); $p->of(false); $p->foo = 4321; # Page Type field, I am trying to update the ID. // $p->foo = "bar"; // $p->foo->id = 4321; # Results in "Fatal error: Exception: Item 'id' set to PageArray is not an allowed type". $p->save(); Observation: It's hard to search documentation and forum entries for this topic because the keywords Page, Type and Save are frequently used in different contexts. I guess the most logical place to find information would be on 1) the "API Variable > $page" page - and/or, the "API Variable > FieldTypes" page. My request is that the documentation at some point will cover how to programatically CRUD each core field type (Checkbox, Datetime, Email, FieldsetOpen, FieldsetTabOpen, File, Float, Image, Integer, Page, Password, (Repeater), Text, Textarea, URL). Merry Christmas and thanks. Related: Create/Update a page programmatically
  5. Command (or Control) + S to save a page. I realise there is both Save (initially) and then Publish and Save and Keep Unpublished. Saving something is more of an automatic action and a requirement. Publish could be kept manual ?
  6. Hi there, can't seem to get my head around handling user timezones the right way and hope to get some feedback from people more knowledgeable than me. My scenario: Users can set publishing date/time for pages they create through a frontend form. These should be saved in the users' timezone. I have a date field for publishing time. PW saves dates as unix timestamps to the DB. For conversion of the date/time to the timestamp PW uses the default server time zone setting (in my case Europe/Berln). Now when a user in timezone America/New_York creates a page and sets the publishing date, it will be converted to a timestamp using the server timezone Europe/Berlin and saved to the DB. Later the user checks if his page is being published at the set time in New York. But it will be published at the wrong time because the user is in a different timezone. I assume it would be best to convert the publishing date/time to a timestamp using the user timezone and save that to the DB. Am I right here? How would I accomplish that? I found date_default_timezone_set. Can I simply use this to set the user timezone before I save values, like date_default_timezone_set($userTimezone); // where $userTimezone is a string like "America/New_York" $editpage->of(false); foreach($adform as $field) { // loop through all fields and save them if(in_array($field->name, $ignorefields)) continue; $editpage->set($field->name, $field->value); } $editpage->of(true); date_default_timezone_set($config->timezone); // do I have to set it back to server timezone here?
  7. Hello, I'm back again with my beginner issues... This time, I'd like to update a field found in a repeater across multiple pages. My code : $found = $pages->find("parent=/invitations/$user->name, guests.guest_name=".$form['oldname']); foreach ($found as $f) { foreach ($f->guests as $g) { if ($g->guest_name == $form['oldname']) { $f->of(false); $out .= '/01:'.$g->guest_name; // THIS IS TO CHECK IF IT WORKS $g->guest_name = $form['name']; $out .= '/02:'.$g->guest_name; // CHANGE APPARENTLY OCCURRED $f->save(); // BUT NEVER SAVES??? } } } Let me try to explain a little : the name of a 'guest' is modified on the front-end. I want to adjust all 'invitations' under the '$user->name' branch (that's how I organized my pages, maybe it's not the best solution...) where the 'oldname' was found (in a 'guests' repeater having 'guest_name' text fields). So I look for the pages and I try to loop each page to check which field has the 'oldname' and when I find it, I change it to the 'newname' ($form['name']) and try to save this change... I have tried many things, but this never worked ! Although I did the same stuff to delete a field (If I remove the guest) and it worked! I just don't understand, so if someone could give me a hand, I'd greatly appreciate... Thanks!
  8. Hi, Like the title says, is there a way to check what the values were before saving, to check for fields that have changed etc. Both the before and after event now seems to get the Page object after it has been updated.
×
×
  • Create New...