Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by gebeer

  1. Thanks, adrian, for correcting me. Indeed, I meant the Page Table field and pasted the wrong link.
  2. Thanks a lot, netcarver, for your detailed answer. I think I will go the pages route and save every timestamp as a page. Following your example above, I'd need a pages field type in my advertisement template to store the references to the timestamp pages, right? Or don't store the references and just extend your sample code: $published_at = $pages->find("template=publishing_schedule, published_at=$timestamp, advert_id={$page->id}"); And thanks also for pointing me to the when library. Interesting stuff. Might save me from reinventing the wheel
  3. Hi all, I'm not sure how to best store multiple timestamps in a field for a page. As there can be 100 or more timestamps attached to the page, I need to find the most efficient way to save those timestamps in a field and later search through that field. My use case: I have pages for advertisements with start date, end date and start time, end time and frequency of publishing (every 15, 30, 60 minutes). From that data I calculate timestamps at which the advertisement will be available for viewing. One advertisement can have 100 or more timestamps attached to it. Example: title of page: Advertisement1 field "ad_publish" contains timestamps: 1413136860,1413136920,1413136980,1413137040,1413137100...(can be a lot) Now what would be the best way of storing these multiple timestamps. IOW: what field type to use? I need to take into consideration that the field needs to be searchable with a *= selector like $publishedAds = $pages->find("template=advertisement, ad_publish*={$timestamp}") 2 options that I can think of for my "ad_publish" field: 1. textarea field, store timestamps as comma delimited values. 2. page field: store each timestamp as a page What would be more efficient and faster when it comes to searching through hundreds of timestamps? I'm sure some of you had similar use cases in their projects and I would be happy if you could share your experience or give me pointers on how to best approach this. Thank you.
  4. If I get you right, you need to have a page field where the user can add/remove characteristics and at the same time the user should be able to enter a value for that characteristic. I'm not sure how you could implement this with available PW functionality at the moment, but there is a discussion that seems to be related to your use case: https://processwire.com/talk/topic/7902-ability-to-edit-pages-from-a-page-field/?hl=%2Bpages+%2Bfield+%2Badd+%2Bpages+%2Bapi And also maybe the Profield Page Table may help.
  5. Hello, I'm trying to add a custom description to my formfield $serverField = $modules->get("InputfieldText"); $serverField->label = "Server Name"; $serverField->attr("id+name","servername"); $serverField->attr("value",$prefillServer); $serverField->attr("class","form-control"); $serverField->description("description","Desc");// need right syntax here. Or is the method missing $serverForm->append($serverField); I get an error: Method InputfieldText::description does not exist I looked at InputfieldText.module and there is no method for adding a description. Shouldn't there be one? Couldn't find anything in the API cheatsheet that would let me do that. How would I then go about adding a description to a form field?
  6. no swipe keyboard? Mine is also auto correcting and garbling things
  7. Thank you Soma, now I got you. I moved $serverads = $pages->find("template=advertisement, ad_server={$serverId}"); before $serverpage->delete() And now everything is working
  8. @Soma I already checked that page object for second page is still there after I delete first page. They are independent from another and $serverID is defined before the other stuff and is not related to the first page that gets deleted. $serverpage and $serverad live under different parents in the tree and both never have children.
  9. Thanks for that hint. But no subpages. I also tried $pages->delete($serverad). Same result. EDIT: and $pages->delete($serverad, true)
  10. Nice guide if you want to develop on a physical server. A year ago or so I switched to developing on virtual servers set up with vagrant. They're a breeze to setup and you can carry them with you wherever you go. Recently I discovered protobox which makes it quite easy to setup virtual machines with preinstalled processwire, wordpress or whatever else.
  11. 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.
  12. Thanks for that link kongondo. It really helped. When I do print_r($GLOBALS), I get: [_POST] => Array ( [name] => Test [uname] => test1 [regemail] => my@email.net [pass] => [_pass] => [sort_repeater1708] => 0 [publish_repeater1708] => 0 [_disable_repeater1708] => 1708 [servername_repeater1708] => [sort_repeater1709] => 1 [publish_repeater1709] => 0 [_disable_repeater1709] => 1709 [servername_repeater1709] => [sort_repeater1710] => 2 [publish_repeater1710] => 0 [_disable_repeater1710] => 1710 [servername_repeater1710] => [sort_repeater1711] => 3 [publish_repeater1711] => 0 [_disable_repeater1711] => 1711 [servername_repeater1711] => [sort_repeater1712] => 4 [publish_repeater1712] => 0 [_disable_repeater1712] => 1712 [servername_repeater1712] => [_reg_servers_add_items] => 0 [timezone] => Europe/Berlin [submitregistration] => Register Account [TOKEN609710988X1412858909] => VehDxck9zIEvN191SQ5G.1HKmG0EeQG41 ) Now I process $_POST with the function from the linked post. $servers = getMultiDimensional($_POST, "servername_repeater"); And get back my array Array ( [1798] => A Server [1799] => Another Server [1800] => And one more Server [1801] => [1802] => ) Now I can go on from there and process my values.
  13. Hello, I'm building a form through the API. In that form I am using a repeater field that is setup with 5 Ready-To-Edit New Repeater items. In the repeater is only one text input field named "servername". Now I'm having trouble accessing the repeater field values when I process the form. I read through the docs at https://processwire.com/api/fieldtypes/repeaters/. But when processing form input post values things seem to be different. I add the field to the form with: $registrationField = $fields->get("reg_servers")->getInputfield($pages->get("/registration")); $registrationField->attr("class","form-control"); $registrationForm->append($registrationField); The field is there in the form and working fine. Now when processing the form, I need to access the values of my repeater. Here's the relevant code: if($input->post->submitregistration) { $registrationForm->processInput($input->post); $servers = $registrationForm->get("reg_servers")->value; var_dump(count($servers)); // this gives int 5, which is fine foreach ($servers as $server) { echo "<pre>"; print_r($server->fields->servername); //servername is my text input field in the repeater echo "</pre>"; } exit(); } In the print_r output I can't find the value of my fields. I also tried var_dump($server->servername) and var_dump($server->servername->value) inside the foreach which gives an empty string. var_dump($server->fields->servername->value) gives null. How can I access my field values?
  14. GOT IT: After moving the $jsConfig script part to the head of my _main.php template file, I don't get the console errors anymore and I have a shiny CKEditor interface attached to my textarea
  15. I followed this thread carefully but still cant get CKEditor to work on the frontend. I'm building my form through the API. My setup: <script> <?php $jsConfig = $config->js(); $jsConfig['urls'] = array( 'root' => $config->urls->root, 'admin' => $config->urls->admin, 'modules' => $config->urls->modules, 'core' => $config->urls->core, 'files' => $config->urls->files, 'templates' => $config->urls->templates, 'adminTemplates' => $config->urls->adminTemplates, 'adminTemplates' => $config->urls->adminTemplates, ); ?> var config = <?php echo json_encode($jsConfig); ?>; </script> <?php $modules->get('JqueryCore'); $modules->get('CKEditor'); //$modules->get('InputfieldCKEditor'); //$config->styles->prepend($config->urls->adminTemplates . "styles/main.css?v=2"); $config->styles->append($config->urls->adminTemplates . "styles/inputfields.css"); $config->styles->append($config->urls->adminTemplates . "styles/ui.css?v=2"); $config->scripts->append($config->urls->JqueryUI . "JqueryUI.js"); $config->scripts->prepend($config->urls->JqueryCore . "JqueryCore.js"); $config->scripts->append($config->urls->adminTemplates . "scripts/inputfields.js"); So I think I'm loading everything necessary and in the correct order. Even when I switch $modules->get('InputfieldCKEditor'); for $modules->get('CKEditor');, the editor doesn't show. I get console errors: Uncaught TypeError: Cannot read property 'editors' of undefined (index):111 Uncaught TypeError: Cannot read property 'plugins' of undefined InputfieldCKEditor.js?v=128:16 line 111 is <textarea id="Inputfield_ad_content" class="FieldtypeTextarea InputfieldMaxWidth" name="ad_content" rows="5"></textarea> All scripts are loaded and visible in the resources tab of chrome debug console. Now I'm lost and any pointers to a solution would be great.
  16. I don't know about bumping the limit further up. But when setting up file downloads, there are some useful functions in the API that you could use. E.g. if you want to allow downloads only for certain users. Here's a post that helped.me.out: https://processwire.com/talk/topic/3634-down-uploads-on-a-per-user-policy/
  17. Thanks again. That helped. I'm using the API to build my forms. They have different names and ids already. When I create the submit button like // submit button! $submit = $modules->get("InputfieldSubmit"); $submit->label = " "; $submit->attr("value","Save Changes"); $submit->attr("id+name","submitprofile"); //Notice submitprofile here - that did the trick $submit->attr("class","btn btn-success"); $profileForm->append($submit); and check if data should be processed with if ($input->post->submitprofile) { //do processing here } It is working and other form submissions do not interfere anymore
  18. Each form has its own. I meanwhile checked that post data is only available for the form that was submitted. So the problem seems to be in my form processing logic somewhere. I will first try myself and find that problem and then report back here. Thank you so far kongondo.
  19. I tried that, too. For example I have email fields in 2 forms. Before they both had name "email". After renaming one of them to "profilemail", I still get unwanted effects on the email field and vice versa.
  20. Hi, I process 3 different forms with 3 different ids/names in the same template. Now my post values seem to get mixed up between the forms. What I tried is $profileForm->processInput($input->post); if ($profileForm->id == "profile-form") { //do something } Analogue with the other 2 forms. But that didn't help. In pure PHP I would use $_POST['profile-form']. But I want to stick wit the PW API. There I found $input->post["name"]. var_dump($input->post["profile-form"]) is null. How can I access and process only the data from my profile-form form using the API? EDIT: Also var_dump($input->post) does not reveal anything about the form id
  21. Thanks! I did try to edit the first post, but not in full editor mode. Now I know
  22. I can't mark the topic as solved. Maybe because it has been moved?
  23. @kongondo Thanks for moving it. Unfortunately I was just about to post at the same time and things got messed up so I'm overwriting this post. Finally my hook module is working. Big thanks to Soma again! Here's the final code: <?php class CleanupUserPages extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Cleanup User Data', 'version' => 0.1, 'summary' => 'Trashes all pages that where created by a user after user has been deleted', 'singular' => true, 'permanent' => false, 'permission' => 'user-admin', 'autoload' => true, ); } public function init() { $this->pages->addHookBefore("delete", $this, "hookDeleteUsers"); } public function hookDeleteUsers($event){ $page = $event->arguments("page"); if ($page->id && $page->template->name === "user") { $userPages = wire("pages")->find("created_users_id={$page->id}"); foreach ($userPages as $userPage) { wire("pages")->trash($userPage); } $this->message("All pages of user {$page->name} deleted"); } } } ?> I first had problems accessing the page template. The $page object returned by $event->arguments("page") works different from the standard $page object in templates. It took me a while to find that I have to use $page->template->name === "user". exit(var_dump($page)) was helpful.
  • Create New...