-
Posts
1,147 -
Joined
-
Last visited
-
Days Won
4
Everything posted by onjegolders
-
Thanks Pogidude, that's really helpful, I will try and do it this way around.
-
Sounds great Pete, will have to try this out soon.
-
That's frighteningly fast!
-
Check your site in incognito (private) mode frequently
onjegolders replied to diogo's topic in General Support
Sleep?! Sleep's for wimps! Good advice though -
Just picking up this old thread as I'm having issues with my selector when trying to only show pages whose date_field either is in the future or it is empty. Without putting all the various combinations on this thread. Does anyone have a working example? I was using $today = time(); and then checking that against my field "end_date". I've used children, find, filter, remove etc. I can't seem to find the combination where empty date fields also play nice. Thanks guys.
-
I'd be hesitant to say that that sort of functionality would take half an hour. That said, ProcessWire is an excellent choice for creating this sort of site as it has a very strong and easy to use API. You would be coding this yourself however, there is no plug-and-play solution. If you are happy with that idea then there are lots of examples and people on here who'd be very happy to help you out. As a flavour: <?php // Starting variables $out = "<h3>Please fill in the form below</h3>"; $error = 0; // Check if form is submitted if ($input->post->submit_form) { // Sanitize form input $name = $sanitizer->text($input->post->name); $email = $sanitizer->email($input->post->email); $phone = $sanitizer->text($input->post->phone); // Check for errors if (empty($name) || empty($email)) { $error = 1; $out = "<h3>Please provide a name and email address</h3>"; } // If no errors, process the form if ($error == 0) // Turn off output formatting before editing page values $page->of(false); // Set the new page values $page->title = $name; $page->email = $email; $page->phone = $phone; // Save the page $page->save(); $out = "<h3>Thanks for submitting the form.</h3>"; } ?> <?php echo $out; ?> <form action="./" method="post"> <label for="name">Name</label> <input type="name" name="name"> <label for="email">Email</label> <input type="email" name="email"> <label for="phone">Phone</label> <input type="text" name="phone"> <input type="submit" value="Submit" name="submit_form"> </form>
-
Anybody used this before? Looks promising.
-
Well said Marty.
-
Why not the people who are sponsoring just do so out of interest to see the project flourish? I agree with Owzim, a big part of Open Source is getting it thoroughly tested and transparent. If the module was right, I'd be happy to contribute and would be OK with others benefitting.
-
Probably not a lot at this point! But very soon Any ideas on what would be next in line? I guess it has to be something Ryan wants to do too!
-
I seem to have started again (perhaps the best thing to do in these scenarios) and written it afresh. Now seems to work. I think perhaps this is still the way to go. I know reverse references can be made in selectors but I keep thinking I will need an actual field value at some point later in the project. It just feels more solid having an automatic reference between the two. The following code seems to be working OK now: <?php // If form is submitted if ($input->post->submit_update_testimonial) { // Assign empty variables $out = ""; $error = 0; // Check if required fields empty if (empty($input->post->title) || empty($input->post->testimonial)) { $error = 1; $out = "<h3>Please include a title and testimonial</h3>"; } if ($error == 0) { // Set sanitized variables $title = $sanitizer->text($input->post->title); $testimonial = $sanitizer->textarea($input->post->testimonial); $date = $sanitizer->text($input->post->date); $student = $sanitizer->text($input->post->student); // $student_page = $pages->get((int) $student); $student_page = $pages->get("template=student, id=$student"); // $student_page->setOutputFormatting(false); // Find current feedback owner (if any) and remove it $current = $pages->get("template=student, student_feedback=$page"); if ($current->id) { $current->of(false); $current->student_feedback = ""; $current->save(); } // Update any page edits $page->of(false); $page->title = $title; $page->body = strip_tags($testimonial); $page->testimonial_date = $date; // Show/hide page if ($input->post->publish == "") { $page->addStatus(Page::statusHidden); } else { $page->removeStatus(Page::statusHidden); } // If assigned student exists assign it, else set it to empty if ($student_page->id) { $page->feedback_which_student = $student_page; } else { $page->feedback_which_student = ""; } $page->save(); if ($student_page->id) { $student_page->of(false); $student_page->student_feedback = $page; $student_page->save(); } } // end if no errors } // end if form submitted ?> <?php if(!$user->isGuest() && $user->name === $page->name OR $user->isSuperuser() OR $user->hasRole("editor")) { include("./header.inc"); ?> <div id="feedback_item_admin" class="content"> <div class="row"> <div class="large-12 columns"> <div class="content_area"> <div class="row"> <div class="large-9 columns"> <h3>Edit Testimonial</h3> </div> <!-- /.large-9 columns --> <div class="large-3 columns"> <a href="<?php echo $page->parent->url; ?>" class="tar flr">← Return to Testimonials</a> </div> <!-- /.large-3 columns --> </div> <!-- /.row --> <hr> <form action="./" method="post"> <div class="row"> <div class="large-8 columns"> <input type="text" name="title" value="<?php echo $page->title; ?>"> </div> <!-- /.large-8 columns --> <div class="large-4 columns"> <input type="date" name="date" placeholder="YYYY-MM-DD" value="<?php echo date('Y-m-d', strtotime($page->testimonial_date)); ?>"> </div> <!-- /.large-4 columns --> </div> <!-- /.row --> <textarea name="testimonial" cols="30" rows="10"><?php echo strip_tags($page->body); ?></textarea> <div class="row"> <div class="large-6 columns"> <label for="publish">Publish?</label> <input type="checkbox" name="publish"<?php if (!$page->is(Page::statusHidden)) { echo " checked"; } ?>> </div> <!-- /.large-6 columns --> <div class="large-6 columns"> <label for="student">Relates to student?</label> <select name="student"> <?php if ($page->feedback_which_student->id != "") { ?> <option value="<?php echo $page->feedback_which_student->id; ?>"><?php echo $page->feedback_which_student->title; ?></option> <?php } ?> <?php foreach ($pages->find("template=student")->remove($page->feedback_which_student) as $student) { ?> <option value="<?php echo $student->id; ?>"><?php echo $student->title; ?></option> <?php } ?> <option value="unassigned"<?php if ($page->feedback_which_student->id == "") { echo " selected"; } ?>>Unassigned</option> </select> </div> <!-- /.large-6 columns --> </div> <!-- /.row --> <input class="button secondary small drop_down" type="submit" name="submit_update_testimonial" value="Update"> </form> </div> </div> </div> <?php include("./footer.inc"); ?> <?php } else { throw new Wire404Exception(); } Thanks to Martijn for his help.
- 5 replies
-
- 1
-
- api
- multiple pages
-
(and 1 more)
Tagged with:
-
This looks fantastic Ryan, a real great addition to the backend and a huge thank you to Antti also for sponsoring this project. I think we need more sponsors if this is the end result!
-
Thanks again Martijn, I haven't managed to get it working this morning though that may be more to do with my head being overly full of rubbish. I'm now just wondering how you would all go about a similar scenario? I'm just finding it's getting more and more complicated and maybe I should try reverting to the backend (I posted in another thread about a two-way page field) or maybe just start this particular template again with a fresh mind? Maybe I don't even need the two way reference, I can just use different selectors for when I need to get the information the other way around (though it feels solid having an actual field value in both directions) Would be interested in getting some people's thoughts...
- 5 replies
-
- api
- multiple pages
-
(and 1 more)
Tagged with:
-
Thanks Martijn you may have a point, I'll have a look!
- 5 replies
-
- api
- multiple pages
-
(and 1 more)
Tagged with:
-
Hi guys, have been struggling all day with a problem creating a front-end form. The idea is that "students" are linked with "feedback" and on both templates there is a page field which links the two together. The superuser has an update feedback form on the frontend where they can make changes, set to hidden/visible as well as assigning the feedback to a student. For some reason I can get the feedback page itself to be updated, I can remove any old attachments from student pages to this feedback page but trying to update the new student to be attached is causing errors. I've had an error telling me to set OutputFormatting to false (it already is) and now I seem to be getting server errors that it's running out of time. I've included the current commented code below, can anyone see anything I'm missing? Thanks <?php // If form is submitted if ($input->post->submit_update_testimonial) { // Assign empty variables $out = ""; $error = 0; // Check if required fields empty if (empty($input->post->title) || empty($input->post->testimonial)) { $error = 1; $out = "<h3>Please include a title and testimonial</h3>"; } if ($error == 0) { // Set sanitized variables $title = $sanitizer->text($input->post->title); $testimonial = $sanitizer->textarea($input->post->testimonial); $date = $sanitizer->text($input->post->date); $student = $sanitizer->text($input->post->student); // Get current student who is attached to feedback (if any) and remove the attachment $current_s = $pages->get("template=student, student_feedback=$page"); if ($current_s->id) { $current_s->of(false); $current_s->student_feedback = ""; $current_s->save(); } // See if newly-selected student exists and if so attach it to this feedback (CAUSING ERRORS) $new_s = $pages->get("template=student, id=$student"); if ($new_s->id) { $new_s->of(false); $new_s->set("student_feedback", $student); $new_s->save(); } // Update the actual feedbcak contents from the form $page->of(false); $page->title = $title; $page->body = $testimonial; $page->testimonial_date = $date; // Update whether the feedback should be visible or hidden if ($input->post->publish == "") { $page->addStatus(Page::statusHidden); } else { $page->removeStatus(Page::statusHidden); } // If set to a student then assign it on the feedback page if ($student == "unassigned") { $page->set("feedback_which_student", ""); } else { $page->feedback_which_student = $student; } $page->save(); } // end if no errors } // end if form submitted ?> <?php if(!$user->isGuest() && $user->name === $page->name OR $user->isSuperuser() OR $user->hasRole("editor")) { include("./header.inc"); ?> <div id="feedback_item_admin" class="content"> <div class="row"> <div class="large-12 columns"> <div class="content_area"> <div class="row"> <div class="large-9 columns"> <h3>Edit Testimonial</h3> </div> <!-- /.large-9 columns --> <div class="large-3 columns"> <a href="<?php echo $page->parent->url; ?>" class="tar flr">← Return to Testimonials</a> </div> <!-- /.large-3 columns --> </div> <!-- /.row --> <hr> <form action="./" method="post"> <div class="row"> <div class="large-8 columns"> <input type="text" name="title" value="<?php echo $page->title; ?>"> </div> <!-- /.large-8 columns --> <div class="large-4 columns"> <input type="date" name="date" value="<?php echo date('Y-m-d', strtotime($page->testimonial_date)); ?>"> </div> <!-- /.large-4 columns --> </div> <!-- /.row --> <textarea name="testimonial" cols="30" rows="10"><?php echo strip_tags($page->body); ?></textarea> <div class="row"> <div class="large-6 columns"> <label for="publish">Publish?</label> <input type="checkbox" name="publish"<?php if (!$page->is(Page::statusHidden)) { echo " checked"; } ?>> </div> <!-- /.large-6 columns --> <div class="large-6 columns"> <label for="student">Relates to student?</label> <select name="student"> <?php if ($page->feedback_which_student->id != "") { ?> <option value="<?php echo $page->feedback_which_student->id; ?>"><?php echo $page->feedback_which_student->title; ?></option> <?php } ?> <?php foreach ($pages->find("template=student")->remove($page->feedback_which_student) as $student) { ?> <option value="<?php echo $student->id; ?>"><?php echo $student->title; ?></option> <?php } ?> <option value="unassigned"<?php if ($page->feedback_which_student->id == "") { echo " selected"; } ?>>Unassigned</option> </select> </div> <!-- /.large-6 columns --> </div> <!-- /.row --> <input class="button secondary small drop_down" type="submit" name="submit_update_testimonial" value="Update"> </form> </div> </div> </div> <?php include("./footer.inc"); ?> <?php } else { throw new Wire404Exception(); }
- 5 replies
-
- api
- multiple pages
-
(and 1 more)
Tagged with:
-
Interesting as I was just having the same thoughts myself. As an idea for a field, would it be possible to have a two-way page reference field (as opposed to doing all the work in the API)?
-
Thanks Ryan, It would've been the latest Chrome on a Mac. The project's moved on so will be hard to replicate, interesting what you said about unmatched tags, maybe that was it. Though I'm pretty sure I had HTML Purifier enabled.
-
Thanks Ryan, I've just updated to the latest version of your module (which fixes the rows issue) I'll let you know if still have the same problem. You're probably right about the styles though the real issue I had was that after the paste, the toolbar wouldn't reappear when I click back onto the textarea.
-
I love it when you have to try something new, perhaps only display data under certain circumstances, exclude certain pages or display things conditionally and you think "Ok well I'll just have a go before I go and look up how to do it". Refresh the page and "It worked!" I think to make up for finding this way too easy thanks to PW, I'm going to install Wordpress and then use 3 different plugins to create "custom fields". That ought to teach me.
-
Just feeling the love today for this incredible system. As with most great things, you tend to take them for granted after a while but I just had a realisation today of just how important ProcessWire is to my working life and the thought of having to use any other tool is too depressing for words! Thanks once again Mr Cramer
-
Strangely, sometimes when I paste in code from a static site, CK Editor shows me the content in a styled fashion (which is great) but then when I click back onto the content I can't get the toolbar to come back (I'm using inline mode). Other times, I seem to get default CK Editor styling. Anyone else seen this? Screenshot attached:
-
I think you've done a good job overall, it's certainly a design that will appeal to the audience more than fellow designers. One thing I'm not a huge fan of is changing a font-weight or font-style on hover, as is the case with the menu. It changes the space an element takes up and I think detracts from the experience. I always prefer working with subtle colour changes if possible.
-
How to automatically set the value of a field?
onjegolders replied to bytesource's topic in API & Templates
No problem. Ours also uses quotations and these do get deleted (unlike invoices which get cancelled). When we choose to send a quote to an invoice, at the top of the page, we perform the same number check to see what invoice number it needs to be allocated. It works fine for us. Let me know if I can help further.