Leaderboard
Popular Content
Showing content with the highest reputation on 04/05/2013 in all areas
-
Validation tools are best used to check for real, structural problems; things that can cause you awful lot of headache when something odd happens in browser X because you forgot to close a tag or some script completely fails to function (or affects more stuff than it should) because your "unique" ID attribute wasn't unique after all. It may have been WordPress that made "code is poetry" a relatively well-known metaphor, but there's still some sense in it; working with pretty and compact (yet expressive!) code and valid, semantic markup is almost like reading a good book. Still the reality is that most people browsing your site couldn't care less whether or not it's "valid (X)HTML", so you really shouldn't sweat it too much either. (Not to mention that if you use editors like TinyMCE and CKEditor, implement any external widgets etc. you're probably going to end up with validation errors anyway.) The point I'm trying to make here is that if it makes you happy then by all means make your markup 100% valid -- otherwise just make sure that there's nothing fatal within those minor errors Regardless of that, adding empty image "alt" attribute is a good habit -- partly because it keeps validator quiet and makes spotting real problems easier but more importantly because it's actually an indicator for screen readers that "this image is not important and should be skipped." If I remember correctly, some screen readers spit out file names whenever alt is left out and that's not very cool or useful. (Will have to do some fact-checking about this later..) On the other hand, using alt texts purely for SEO is an awful idea. Seriously. I'm pretty sure that most people browsing with a screen reader don't appreciate having to listen useless, keyword-infested alt texts unless those also provide some real value for them. Sorry for taking this even more off-topic, but the subject was too fun to skip. @Joss: the site is very nice too!7 points
-
7 points
-
5 points
-
Okay, when I say music website, this is actually my own company website. This is built starting with my bootwire starter profile. It has a couple of interesting bits: It uses the Mediaelements jquery plugin for the audio to make it cross browser compatible (each audio file is in both mp3 and ogg format). It uses the explode tip I put in another post for posting the audio, allowing me to post one or several audio slugs at a time. It has a modified version of Jack Moore's tabs to which I have added slideup and down for a more interesting look - that is used on the front page with the three images. Each page can have either the default top banner or a custom one. I have also used a bit of JQuery to create a TOC on the fly for a couple of the longer articles and then rendered it with the Bootstrap Affix plugin. This can be toggled on and off on a page by page basis. Couple of other bits. If the site is running slow, that is not ProcessWire, I seem to be having some network difficulties with Cloudflare at the moment. http://www.dancingbear.co.uk Joss5 points
-
Manfred, although I think you are right in some of what you say, I think your tone is wrong and reveals your inexperience. I confess I was a bit irritated with your post because this is not the first time you throw the validator errors at someone in the forum. I agree that it's not difficult to add alt to all images but, although the validator is a useful tool, your brain and judgement are much more needed. Analize the images on Joss's site without your beloved validator and you will understand what I mean. Tell me honestly, is there any image that needs a description? I will answer: no. The first image is the banner, after that you have three images that are there to support the headlines, and finally you have the social buttons that are inside links (in this case the link should have a title, since there's nothing beside the image explaining what it does). I'm not saying that we should ignore the suggestions of the validator, and the recommendation is to add an empty alt to an image if there isn't a description (which Joss didn't). This is not for SEO as you mentioned, but mostly so that screen readers (software for visual impaired people) know they should ignore them. So, here's another important tool to have in your toolbelt http://webanywhere.cs.washington.edu/beta/ I sincerely hope I'm not being too harsh and that you don't take my observation personally.5 points
-
If I had a list that included things like Gin and Beer, I doubt I would be able to sort it by anything by the time I got to the end......3 points
-
3 points
-
Greetings, Nice Joss! But are you sure you wouldn't be better off doing the site with Joomla? Regarding validation errors: I think it's great to run our sites through the validator, but I find that most of the time it's a bunch of little ones. Also, just for fun I often run major sites through that validator to show how even "the best sites" have errors! For example... Microsoft - 515 errors NY Times - 379 errors Facebook - 33 errors Techcrunch - 20 errors So with 22 errors, you are doing better than Facebook! Thanks, Matthew3 points
-
2 points
-
Big thanks to Mats for the alltpaoland.com example and his clustering updates to my RCDMap class. With these available, I was able to learn enough (and admittedly copy enough!) to make the map project come together: http://www.synbioproject.org/library/inventories/map/ ... my code is a little messy, but it all works for the deadline, and I can go clean it up later. Beyond Google Maps, tools used here are jQuery Mobile, ProcessWire 2.3, ImportPagesCSV module, and ProcessWire Form Builder (for the add/edit map submissions). Thanks again Mats! I don't think I could have made much progress without your alltpaoland site as an example/guide.2 points
-
$page=new Page(); $page->template='basic-page'; $page->parent='/mommy/'; $page->name=microtime(); // .or $page->name='gilderbergersbang' . $page->parent->numChildren;2 points
-
A couple of tips when moving from Joomla. 1. Forget the idea of Categories and Articles. To be honest, Joomla is more of an Article Management System than a CMS (until you add tons of components) and so it has a very restricted way of looking at things. 2. ProcessWire uses pages as data containers - exactly what data is up to you. It could be a page made out of lots of fields, or pages could be lots of alternatives for a select field (pages field in PW), they are also users and all kinds of other things. So, try not to think of them like pages in a book or even web pages - though they can be both of those if you wish. 3. When you design a site with Joomla, the easiest way is to change your site to work how Joomla wants you to work. But, the best way to start with ProcessWire is to not think about PW at all, but just think of your website. Try and ignore how PW works and just work out how YOU want YOUR website to work. Once you have done that, you can work out how PW will help you achieve what you want. It really is that flexible. You can create anything that is familiar in Joomla in PW. For instance, Once you do the Basic Website Tutorial that Kongondo mentioned, there is a link at the bottom to the Simple News System. This shows how you can do Joomla type articles with categories. But you will quickly realise that this is only one way you can achieve that, and because you are doing it yourself, you can make it work anyway you wish. So, Welcome, and have fun!2 points
-
Probably we can do this like the Wordpress shortcodes original. Large parts of the source seem to be the same, but Wordpress only requires PHP 5.2 http://core.svn.wordpress.org/trunk/wp-includes/shortcodes.php2 points
-
ColorPicker Custom Fieldtype/Inputfield for ProcessWire 2.+ This module gives you a new custom Fieldtype. Let's you select a color using a Colorpicker jQuery Plugin. The color selected will be stored in HEX format uppercase: "EAEAEA"; To use it in your template as a background HEX color, you'd simple output the value and prefix it with a #: echo "background-color: #" . $page->color; When creating a new field in the admin, you can set a default value the field should be prefilled with when creating a new page. The field supports a "reset" button to be able to set it back to the default value. The colorpicker used: ColorPicker jQuery Plugin by Eyecon Since 1.0.6 the colorpicker supports color swatches to add predefined colors for easy selection. Thanks @Rayden for the implementation. How to install: Download the contents of this repository and put the folder renamed as "ColorPicker" into your site/modules/ folder Login to processwire and got to Modules page and click "Check for new modules". You should see a note that two new modules were found. Install the FieldtypeColorPicker module under "Field" section. This will also install the required InputfieldColorPicker at the same time. Done You can now create a new field with the "ColorPicker" Fieldtype. Get it from modules section: http://modules.proce...e-color-picker/1 point
-
Greetings Everyone, ************************************************* ************************************************* EDIT NOTE: This post started as a work-in-progress discussion as I was working out the elements of a successful form. After contributions from participants in this discussion, the code below has been tested and works well. You can use the code as shown below in your ProcessWire templates! Feel free to follow up with additional quesations/comments! ************************************************* ************************************************* I have successfully built front-end forms with ProcessWire to add pages via the API. It works great -- until I had to include image uploads along with the "regular" form fields. Then it temporarily got a bit complicated. In this discussion, I show how to handle front-end submissions in ProcessWire with the goal of allowing us to create pages from custom forms. I then go a step further and show how to use the same form to upload files (images and other files). I'm hoping this discussion can illustrate the whole process. I know a lot of people are interested in using ProcessWire to do front-end submissions, and my goal for this discussion is to benefit others as well as myself! First, here's my original contact form (no file uploads): <form action="/customer-service/contact/contact-success/" method="post"> <p><label for="contactname">Name:</label></p> <p><input type="text" name="contactname"></p> <p><label for="email">E-Mail:</label></p> <p><input type="email" name="email"></p> <p><label for="comments">Comments:</label></p> <p><textarea name="comments" cols="25" rows="6"></textarea></p> <button type="submit">Submit</button></form> And here's the "contact-success" page that picks up the form entry to create ProcessWire pages: <?php // First, confirm that a submission has been made if ($input->post->contactname) { // Save in the ProcessWire page tree; map submission to the template fields $np = new Page(); // create new page object $np->template = $templates->get("contact_submission"); $np->parent = $pages->get("/customer-service/contact-us/contact-submission-listing/"); // Send all form submissions through ProcessWire sanitization $title = $sanitizer->text($input->post->contactname); $name = $sanitizer->text($input->post->contactname); $contactname = $sanitizer->text($input->post->contactname); $email = $sanitizer->email($input->post->email); $comments = $sanitizer->textarea($input->post->comments); // Match up the sanitized inputs we just got with the template fields $np->of(false); $np->title = $contactname; $np->name = $contactname; $np->contactname = $contactname; $np->email = $email; $np->comments = $comments; // Save/create the page $np->save(); } ?> This works great! After submitting the form, we go to the "Success" page, and new submissions show up in the ProcessWire page tree right away. Excellent! Now I need to add a photo field. I altered the above form so it looks like this: <form action="/customer-service/contact/contact-success/" method="post" enctype="multipart/form-data"> <p><label for="contactname">Name:</label></p> <p><input type="text" name="contactname"></p> <p><label for="email">E-Mail:</label></p> <p><input type="email" name="email"></p> <p><label for="comments">Comments:</label></p> <p><textarea name="comments" cols="25" rows="6"></textarea></p> <p>Click the "Select Files" button below to upload your photo.</p> <input type="file" name="contact_photo" /> <button type="submit">Submit</button> </form> And here's the updated "contact-success" page: <?php // First, confirm that a submission has been made if($input->post->contactname) { // Set a temporary upload location where the submitted files are stored during form processing $upload_path = $config->paths->assets . "files/contact_files/"; // New wire upload $contact_photo = new WireUpload('contact_photo'); // References the name of the field in the HTML form that uploads the photo $contact_photo->setMaxFiles(5); $contact_photo->setOverwrite(false); $contact_photo->setDestinationPath($upload_path); $contact_photo->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); // execute upload and check for errors $files = $contact_photo->execute(); // Run a count($files) test to make sure there are actually files; if so, proceed; if not, generate getErrors() if(!count($files)) { $contact_photo->error("Sorry, but you need to add a photo!"); return false; } // Do an initial save in the ProcessWire page tree; set the necessary information (template, parent, title, and name) $np = new Page(); // create new page object $np->template = $templates->get("contact_submission"); // set the template that applies to pages created from form submissions $np->parent = $pages->get("/customer-service/contact-us/contact-submission-listing/"); // set the parent for the page being created here // Send all the form's $_POST submissions through ProcessWire's sanitization and/or map to a variable with the same name as the template fields we'll be populating $np->title = $sanitizer->text($input->post->contactname); $np->name = $np->title; $np->contactname = $sanitizer->text($input->post->contactname); $np->email = $sanitizer->email($input->post->email); $np->comments = $sanitizer->textarea($input->post->comments); $np->save(); // Run photo upload foreach($files as $filename) { $pathname = $upload_path . $filename; $np->contact_photo->add($pathname); $np->message("Added file: $filename"); unlink($pathname); } // Save page again $np->save(); ?> <p>Thank you for your contact information.</p> <?php return true; } else { ?> <p> Sorry, your photo upload was not successful...</P> <?php } ?> Replace the field references with your own field names, make sure to change the various paths to match yours, and change the various messages to be what you need for your project. Read the entire discussion to see how we worked through getting to the solution shown above. Thanks, Matthew1 point
-
1 point
-
1 point
-
I'm not 100 % sure right now, but I think if you don't set a name, Pw takes already care of this problem. Edit: Yep it does, found the code in Pages::___setupNew() protected function ___setupNew(Page $page) { if(!$page->name && $page->title) { $n = 0; $pageName = $this->fuel('sanitizer')->pageName($page->title, Sanitizer::translate); do { $name = $pageName . ($n ? "-$n" : ''); $child = $page->parent->child("name=$name"); // see if another page already has the same name $n++; } while($child->id); $page->name = $name; } //... So just set the title. If the same title appears multiple times, the API generates a name with -1,-2,-3...1 point
-
You could check checkboxes like this: if($checkbox) and if(!$checkbox) example: if($page->checkbox) echo 'i am set'; if(!$page->checkbox) echo 'i am not set'; So to modifiy your output in a foreach just put your markup in an if condition.1 point
-
Page Fields These basically list and select pages, normally where you specify a parent or a template or some other limiting criteria. You can set it for single or multiple select, and you have the options of various ways of doing that - a simple select dropdown, browsing the page tree, or the asmSelect system that is used for adding fields to templates. There are countless uses for this field: Creating a select options dropdown (each page is an option - this is not overkill, as I said before, pages are just data containers/objects, so it is perfectly fine to use them like this and means you can change the options!) Using them to select pages that represent categories Using them to select pages that represent tags - you can also set the field to create a new page (just the title field) so you can create tags on the fly. You can find more info here: http://wiki.processwire.com/index.php/Page_Field And there is more in the API Templates First of all it is important to realise the difference between a template and a template file. If you do my Basic Website Tutorial, it all becomes clear, but briefly: A template is what you use to collect fields together and control aspects of how a page is created. It does not need to be associated to a template file (though the resulting page cannot be displayed directly without a template file). For instance, in the Basic Website Tutorial I create a settings template that has no file. The values of the fields are called directly and individually into the website rather than being rendered as part of the page. A template file is the HTML markup plus any JQuery and PHP logic that handles the output of a page made with the associated template. In its simplest form it is basic html where you use a very simple bit of php to output a field: <?php echo $page->title; ?> <?php echo $page->body?> Templates Files are up to you to design. You can add any markup you like or use a framework like Bootstrap or Foundation or whatever you like. You could even put the site together with FrontPage '97 if you were mad enough - it would work! (Though, I haven't tried adding Front Page extensions...) It can be surprisingly easy to reproduce really complicated Joomla Extensions like galleries, slideshows and so on. You just need to go and grab a useful JQUery (or other) plugin that you like and use it pretty much as the instructions say - you just grab the data using the PW API rather than write in static values. You might want to go and play with my Bootstrap Demo Profile (http://processwire.com/talk/topic/2411-bootwire-basic-twitter-bootstrap-profile/) - it demonstrated several basic ideas using the Bootstrap framework and you can see how simple the code is. Put it this way, I come from using Joomla and Wordpress and I am certainly not a php coder (I am a composer, in fact) - but I manage! Oh, and I think translations are always welcome!1 point
-
Does something similar to below not work? if($page->hide_from_top_menu == 0){ } See this thread and the solution (post #9) as well as the issues about '=' versus '=='. Can't find it now but if I remember correctly, in PW checkbox is either 0 (unchecked) or 1 (checked). I could be wrong /k1 point
-
Hi Kongondo I think the clue here is in the word "label" rather than "Description" A label on a field would not be a long description, it would be a short friendly label as opposed to using the actual field name. This is the same in this case - it is meant so you can have "Main Post Template" rather than "post-template-main-v1" or whatever your template is actually called. Edit: Damn ... Appy got their first!1 point
-
Since I am in the media industry and therefore a lot of the sites I deal with have huge amounts of media embedded from elsewhere (like YouTube), I have learned to realise that I cannot do a perfect site - if for no other reason that on Chrome I get huge amounts of Script errors relating to iframes. There is also the small matter that If there can be an opposite to OCD, I am probably suffering from it - I am the most disorganised person I know and absolutely terrible when it comes to dotting Eyes and crossing Tees. But the site works and my clients seem to like it - more importantly, they like the show reels, and those are the only thing they and I care about. It is all about priorities.1 point
-
Write some instructions is the only way I believe. In the template file, just "break" the loop or slice your array. When you use repeaters, you'll never use hundreds of them so the overhead is minimum.1 point
-
I know horst, that's basically what i said. Anonymous functions are often referred to as closures (which is not entirely correct i suppose). Have a look at php docs for preg_replace_callback at the callback parameter and the example. Then at the similar code in Nico's module. You could probably use create_function instead of the closure but maube someone with better PHP knowledge can give better advice.1 point
-
1 point
-
I think it's not the preg_replace_callback that is causing the 'problem', but the use of a anonymous function in there. Maybe it could be done using create_function instead but i'm not sure this is desirable.1 point
-
It would go to far to ask PW to somehow analyze all module code. For PW to be able to check something i guess it's always up to the module author to provide info about the min. required PHP version, if applicable. Perhaps require it in the getModuleInfo part. PW then could always do version_compare against the PHP version available on the system. And maybe show a Pro-Tip urging people to finally update to 5.3+1 point
-
1 point
-
Hi there and welcome to the forums. I'm a little short in time right now so i won't go into specifics about search with dropdowns. Some general info: - I don't think that there is a dedicated page on this site detailing the security(features) of PW but you can be assured that it is excellent security-wise. A strong password mechanism, session fingerprinting and a lot more. I haven't heard of PW installs being hacked or otherwise compromised. - PW can be an excellent way to get acquainted with PHP (programming). Some basic PHP combined with some PW API 'magic' will enable you to become productive in a short period of time. Of course, if your serious about learning PHP it will require some effort to learn a language and general concepts of programming. - The best advice i can give is just install PW and do some tutorials that are on the wiki. Once it all starts to make sense definitely read through the API documentation on the site. - Also, browse the forums. A lot of great info can be found, although admittedly sometimes a bit hard to find. Post like this could be interesting for you1 point
-
Hi Franci, Welcome to ProcessWire! Regarding tutorials, have a look at this if you haven't seen them already: http://wiki.processwire.com/index.php/Basic_Website_Tutorial http://processwire.com/talk/forum/13-tutorials/ Many examples are provided right here in the forums but that can be difficult to find if you are new. I am sure others will provide more helpful answers but I can add PW is very secure. I'll let the more seasoned PW pros chime in here. By the way, learning PHP is good but you don't need advanced PHP knowledge to use PW. Coming in from Joomla, you will be amazed at the freedom PW gives you. You will need to unlearn Joomla ways though , e.g. be willing to get your hands a little bit dirty with some code. Once PW clicks, you will wonder why you hadn't used it before . Anyway, this is a very helpful forum and someone will soon give you better answers than mine! Cheers /k1 point
-
You cant put php files in templates folder and directly call them via url. You have to put it in root somwhere else. Its blocked by htaccess.1 point
-
This is what I'd expect to see. This is kind of a mystery, as the language pack shouldn't make any difference here. I'll have to experiment and see what's up. I was going to go take a look at the MetroWire theme, but looks like it's no longer available for download. I'm getting a 404 when clicking the download link: http://modules.processwire.com/modules/metro-wire/1 point
-
A straight up export->import of database dumps from dev to live seems like a disaster waiting to happen. Definitely read this: http://processwire.com/talk/topic/1284-best-practice-for-staging-to-live-database-synchronization/#entry12752 I would also look into some tools that aid in comparing and syncing. Did some Googling: http://blog.webyog.com/2012/10/16/so-how-do-you-sync-your-database-schema/ http://stackoverflow.com/questions/225772/compare-two-mysql-databases http://blog.webyog.com/2012/10/23/all-you-wanted-to-know-about-sqlyogs-schema-comparison-tool/ http://www.red-gate.com/products/sql-development/sql-compare/screenshots http://www.quest.com/toad-for-mysql/1 point
-
Joss, this is not fado at all... Mariza is good, but not the only one SiNNuT, the ironic thing about that link, is that they did it for mocking at others but their portfolio is not much better1 point
-
Better to participate now than to complain later https://docs.google.com/forms/d/1GPDA30gLd-5S8AAlZmwElS6RurOfQuWSAKqN7qMf-Io/viewform1 point
-
You can only pass static strings to the __() function. At least, the translation parser will only be able to find static strings. The only reason you'd put a variable in a call to the __() function, is if you knew the text was already available translated, and wanted to retrieve the translated version. But that text would have had to appear statically, somewhere else in the file. To make a multi-langage image field, you can use a Repeater. Your repeater would contain two fields: 'image' and 'summary'. Make the 'image' field of type Image, and set to to contain max 1 image. Make the 'summary' field of type TextLanguage (or TextareaLanguage). The Image field is the next one on the list to make multi-language capable, so should be within the next major version of ProcessWire.1 point
-
Thanks Ryan for the heads up, there's some nice examples for advanced coders. Strange. Now, I also would have thought that with !$u->getErrors() it wouldn't work, but it still does! I went and did many tests after you posted this and I can't see any difference and it all works as it should. The code works with both and I haven't looked into it further (core). I wish to be proven wrong but it really does (at least for me here) :/ I think you got a valid point with checking for if there's files really uploaded at all... However this wouldn't work if image upload would be not required in your form. Also the example you posted is also not showing how you could make required fields and inline error/repopulating fields, prevent CSRF and double posts. It's still a great example but as said, not a "complete" example that can be used in a public front-end form. May or may not suiteable for people not knowing what they're doing and only copy paste. What I also think could be the problem on Matthews side is that the PHP upload and post max size isn't enough to upload the file. I also tested this and it seems to fails silently with no errors and just shows the form again. Maybe there's a way to get around it, but thought it might be an issue since there's no error thrown as it's apache upload interrupting? --- It can get somehow complex to add all checks and validation to a form server side, and the following post example is also just for showing what all there's involved to make a pure php form (using some PW internals). Yet another example I've spent couple hours creating a form upload example - with files (images) upload to a page file field - adds new page on the fly and adds uploaded images - prevents CRSF attacks, this also prevents double post by refresh page after submit - has required fields with error messages inline - repopulates form field in case an error happened or a required field was not filled in - sanitizing and saving values to a page - jquery example with disabled submit button on form submit The gist repo can be seen here https://gist.github.com/somatonic/5233338 You can configure some variables and array's at the top and add remove fields as you wish to the html form markup. Like this: // --- Some default variables --- $success_message = "<p class='message'>Thanks for your message!</p>"; // --- All form fields as nested array --- // using html form field name => template field nam, from the page you're going to create $form_fields = array( 'fullname' => array('type' => 'text', 'value' => '', 'required' => true), 'email' => array('type' => 'email', 'value' => '', 'required' => true), 'message' => array('type' => 'textarea', 'value' => '', 'required' => true), 'newsletter_subscribe' => array('type' => 'checkbox', 'value' => 0, 'required' => false), 'images' => array('type' => 'file', 'required' => true) ); // --- WireUpload settings --- $upload_path = $config->paths->assets . "files/.tmp_uploads/"; // tmp upload folder $file_extensions = array('jpg', 'jpeg', 'gif', 'png'); $max_files = 3; $max_upload_size = 1*1024*1024; // make sure PHP's upload and post max size is also set to a reasonable size $overwrite = false; // --- Page creation settings --- $template = "upload-entry"; // the template used to create the page $parent = $pages->get("/uploads/"); $file_field = "images"; $page_fields = array('fullname','email','message','newsletter_subscribe'); // $page_fields = define the fields (except file) you want to save value to a page // this is for the form process to populate page fields. // Your page template must have the same field names existent // ------------------------------ FORM Processing --------------------------------------- include("./form-process.php"); To set this up. 1. Create a template upload-entry used to save the form submissions. With all the fields you'll have in the form, and name them the same as in the $form_fields 2. Create a form-upload.php template used to hold the form config and markup code: (create a template in PW with this name and the page the form should be rendered) https://gist.github.com/somatonic/5233338#file-form-upload-php 3. Create a form-process.php file in the templates folder with the processing code (This is included in the template file above after the configuration part) https://gist.github.com/somatonic/5233338#file-form-process-php There's a basic styling CSS: https://gist.github.com/somatonic/5233338#file-form-css And the jQuery snippet used to prevent double posting when double clicking the submit. https://gist.github.com/somatonic/5233338#file-form-js This is some screen showing the form:1 point
-
Matthew, the primary problem I can see is this line: if(!$contact_photo->getErrors()) { The issue there is that getErrors() always returns an array, which always resolves to "true" in your if statement. In order for it to work properly, you would need to count() the return value of getErrors() rather than typecast it to a boolean like you are doing now. However, I don't think that getErrors() is a good way to check for success with WireUpload, because errors could occur while files were still uploaded. So it's better for your code to ask the question "were any files uploaded?" rather than "did any errors occur?". Then worry more about errors if no files were uploaded. There were also several other minor issues or concerns, but I think the issue mentioned above is the primary reason it wasn't working. I've attempted to re-factor your code and resolve all the issues/concerns that I would have had with it. This is written in the browser, so there may still be typos, but hopefully the intentions are clear: <?php /** * Process the contact form * * Populate's ProcessWire's $notices API var with errors and messages * * @return bool Returns true on success, false on failure. * */ function processContactForm() { $input = wire('input'); $sanitizer = wire('sanitizer'); // Set a temporary upload folder where the files are stored during form processing // RC: precede temp dir with a period to ensure it remains non-web accessible $upload_path = $config->paths->assets . "files/.temp/"; // RC: create temp path if it isn't there already if(!is_dir($upload_path)) { if(!wireMkdir($upload_path)) throw new WireException("No upload path"); } // New wire upload $contact_photo = new WireUpload('contact_photo'); // References name of HTML form field $contact_photo->setMaxFiles(5); $contact_photo->setOverwrite(false); $contact_photo->setDestinationPath($upload_path); $contact_photo->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); // execute upload and check for errors $files = $contact_photo->execute(); // RC: use count($files) as your decision whether to proceed not not, rather than getErrors() if(!count($files)) { $contact_photo->error("No files received, so not creating page."); return false; } // Save in the ProcessWire page tree; map submission to the template fields $np = new Page(); // create new page object $np->template = "contact_submission"; $np->parent = "/customer-service/contact-us/contact-submission-listing/"; // RC: for safety, only add user uploaded files to an unpublished page, for later approval // RC: also ensure that using v2.3+, and $config->pagefileSecure=true; in your /site/config.php $np->addStatus(Page::statusUnpublished); // Send all form submissions through ProcessWire sanitization or just map a variable // RC: No need to have intermediate variables, I removed them--populating the $np page instead $np->title = $sanitizer->text($input->post->contactname); $np->name = $np->title; $np->contactname = $sanitizer->text($input->post->contactname); $np->email = $sanitizer->email($input->post->email); $np->comments = $sanitizer->textarea($input->post->comments); // RC: assuming this is a textarea fieldtype $np->save(); // Run photo upload foreach($files as $filename) { $pathname = $upload_path . $filename; $np->contact_photo->add($pathname); $np->message("Added file: $filename"); unlink($pathname); } // save page again $np->save(); return true; } // First, confirm that a submission has been made if($input->post->contactname) { if(processContactForm()) { echo "<h2>Your page was saved!</h2>"; } else { echo "<h2>Sorry things didn't work out!</h2>"; } foreach($notices as $notice) { $class = $notice instanceof NoticeError ? "error" : "message"; echo "<p class='$class'>$notice->text</p>"; } } else { // display contact form }1 point
-
I implemented the first of your requested features (MarkerClusterer) in your RCDMap class. You can find it here: http://processwire.com/talk/topic/690-map-marker-fieldtype/page-3#entry25865 Here it is in action (built for mobile): alltpaoland.com1 point
-
Martijn Having spent the first 25 years of my career as a recording engineer working in both advertising and music, I relate to that on so many levels that I just cannot begin to count them Absolutely precious! Joss Edit: Probably should clarify my past a little bit (though terribly incomplete): http://www.imdb.com/name/nm0762708/1 point
-
1 point
-
1 point
-
1 point
-
1 point
-
Sounds good, I am putting this in 2.3 and should be on the dev branch later today. It will look for a file /site/templates/errors/500.html and use it when present.1 point
-
This is correct, but not using the page->render module method I mentioned. Assuming you have a template setup for the side panel with a php file like this: <div class="side_panel"> <h4><?php echo $page->title; ?></h4> <?php echo $page->body; ?> </div> Assuming the page field is allowed multiple, then your code could be: <?php if($page->side_panel) { foreach($page->side_panel as $p) { echo $p->render(); } } $page->render(); just renders your side panel page using the template file with the variables filled in. Then you can have multiple different side panel types with own templates and fields for own purposes. Hope that makes sense.1 point
-
I assume that side_panel is your page-field. Coding depends little bit if it allows multiple values or not, but here are examples for both: Multiple: <?php if($page->side_panel) { foreach($page->side_panel as $p) { echo "<p>{$p->title}</p>"; } } Single: <?php if($page->side_panel) { echo "<p>{$page->side_panel->title}</p>"; } ?> Written in browser, so there might be some details wrong.. EDIT: As you can see it is much simpler than what you have tried earlier. When you learn this, then only sky is the limit with ProcessWire1 point
-
I used to do it like this: Add page reference field, that configured to allow to select pages with template "sidebar" for example. This sidebar template has just title and body and may other fields. Now add a page tree section ie "Sidebar Elements" in the tree, where you create the sidebar pages. Now on your normal content pages you can select 1 or more of them through the page reference field and even sort them. You can then render them using foreach over fields or using ->render method (need to install the module I think) for pages to render them using their own template file, which would only contain the markup for the sidebar element of course. There's a few more options and ways to archive this, but this turnes out to be very flexible and easy. You could also inherit those to while sub page branches aswell, like the mood image on basic site.1 point
-
Good question. You can use the built-in append() and/or prepend() functions, i.e. $menu_items->prepend($home); I believe the unshift syntax will also work: $menu_items->unshift($home); You don't have to worry about modifying the site tree because you would have to actually save a $page in order to modify the site tree. In addition, none of what you are trying to do here is modifying any pages, so even if you did save a page, it wouldn't modify anything. PageArrays are runtime dynamic arrays, and aren't saved anywhere unless they are attached to something like the result of a Page reference Fieldtype. See /wire/core/Array.php and /wire/core/PageArray.php for all the traversal and modification methods (there are a lot). For the most part, they are patterned after jQuery traversal methods, but I included alternate names like unshift() and shift() for people that prefer PHP function names. Just for fun, here's your example all bundled on one line. foreach($pages->find("parent=/navigation/")->prepend($pages->get('/')) as $item) { ... Or even shorter: foreach($pages->find("parent=0|/navigation/") as $item) { ... The selector above is saying to find all pages that have no parent (i.e. "0") or have a parent called /navigation/. Both examples above return the same result. That won't work because the function only accepts one param (a selector). But because all the pages you are selecting there have the same parent, this would work: $pages->find("parent=/, name=navigation|page|item2");1 point