-
Posts
1,489 -
Joined
-
Last visited
-
Days Won
43
Everything posted by gebeer
-
Find most efficient solution for storing multiple values in a field
gebeer replied to gebeer's topic in General Support
Thanks, great. I'll test both of them over the next days and will let you know. EDIT: After having a quick look at both libraries, I found that both of them require a count for the recurrence of events. So I first need to calculate the count myself from the data available. Would have been great to just throw start date/time, end date/time and interval at some library and have it figure out the count by itself. (Being lazy again ). Think now I understand count. In recurr FREQ=MONTHLY;COUNT=5 means every 5 months. -
Find most efficient solution for storing multiple values in a field
gebeer replied to gebeer's topic in General Support
Not sure if the when library can handle hourly or even minutely recursion as it is not so well documented. Found recurr library which seems more suitable for my project. -
Situation where I need set a value for a page selected from a pagefield
gebeer replied to Gabe's topic in General Support
Thanks, adrian, for correcting me. Indeed, I meant the Page Table field and pasted the wrong link. -
Find most efficient solution for storing multiple values in a field
gebeer replied to gebeer's topic in General Support
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 -
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.
-
Situation where I need set a value for a page selected from a pagefield
gebeer replied to Gabe's topic in General Support
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. -
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?
-
no swipe keyboard? Mine is also auto correcting and garbling things
-
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
-
@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.
-
Thanks for that hint. But no subpages. I also tried $pages->delete($serverad). Same result. EDIT: and $pages->delete($serverad, true)
-
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.
- 7 replies
-
- 3
-
- ubuntu
- virtualmin
-
(and 3 more)
Tagged with:
-
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.
-
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.
- 2 replies
-
- 1
-
- processing
- form
-
(and 3 more)
Tagged with:
-
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?
- 2 replies
-
- processing
- form
-
(and 3 more)
Tagged with:
-
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
-
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.
-
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/
-
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
- 7 replies
-
- 3
-
- Multiple forms
- processing
-
(and 1 more)
Tagged with:
-
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.
- 7 replies
-
- Multiple forms
- processing
-
(and 1 more)
Tagged with:
-
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.
- 7 replies
-
- Multiple forms
- processing
-
(and 1 more)
Tagged with:
-
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
- 7 replies
-
- Multiple forms
- processing
-
(and 1 more)
Tagged with:
-
Thanks! I did try to edit the first post, but not in full editor mode. Now I know
- 14 replies
-
- Trash pages
- user
-
(and 2 more)
Tagged with:
-
Maybe you can add SOLVED to the thread headline. Thanks.
- 14 replies
-
- Trash pages
- user
-
(and 2 more)
Tagged with:
-
I can't mark the topic as solved. Maybe because it has been moved?
- 14 replies
-
- Trash pages
- user
-
(and 2 more)
Tagged with: