Leaderboard
Popular Content
Showing content with the highest reputation on 03/15/2014 in all areas
-
Here's a video of a module we're working on that I thought you guys might like. The module, Lister, provides a different type of Page List than the tree that you usually interact with in ProcessWire. It gives you a table of pages with customizable columns, filters and actions. Rather than try to explain what it does, I figured I'd show you. This module also uses a new (soon to be released) Inputfield invented by Apeisa, developed by me, and sponsored by Avoine, called InputfieldSelector – it's what you see on the configuration screen as well as the Filters tab. I recommend bumping up the size/quality to 720p so that you can properly see everything. The video has no sound... I tried to do one with narration, but that didn't work out.8 points
-
3 points
-
Recently I got a brand new iMac so I needed to install PHP SQL and configure Apache. I'm using the same web develop environment for years and I'm really happy with it. Raymond is also using this and Arjen did the same recently. I love to share how I setup this environment in a step by step tutorial. Let's setup PHP, MYSQL and activate mail using gmail smtp for OSX 10.6 and up, perfectly suitable for ProcessWire. It doesn't install Apache, it uses the Apache installation, which comes with OS X. The PHP installer package is created by Liip and it is based on entropy's php package. For MYSQL we gonna install the DMG Archive (x86, 64-bit). After we installed PHP, we configure Apache & PHP so that we’re able to run the ProcessWire sites in our own ~/Sites directory. For El Capitan see Arjen's https://processwire.com/talk/topic/5797-setup-a-processwire-environment-on-a-fresh-macos-x-install/?p=103674 Install PHP We gonna use the PHP installer created by Liip. (more information) Go to: /Applications/Utilities/ Open: Terminal.app Type: curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5 Press: RETURN Type: your admin password Press: RETURN ( download starts and continues with a the install ) note: If you want to have an older PHP version, replace 5.5 with 5.4. (PHP 5.5 is the current stable) After the install is completed Apache is restarted and complains about “Could not reliably determine the server's fully qualified domain name, using your-computer-name.local for ServerName”. This notice is not a problem, we only use this Mac for local website development. Setup Apache Open a new finder window. Press: shift + command + g ( Go to folder ) Type: /etc/apache2/ Press: go Open: httpd.conf Find the line: #Include /private/etc/apache2/extra/httpd-vhosts.conf Remove the # infront to enable. Press save and enter your password when asked. Enable the use of ~/Sites folder:Open the folder /etc/apache2/users/ * Duplicate the Guest.conf and name it martijn.conf Open the duplicated file that we created * Change: <Directory "/Users/Guest/Sites/"> to <Directory "/Users/martijn/Sites/"> Change: AllowOverride None, to AllowOverride All Save the file. The file should look like: <Directory "/Users/martijn/Sites/"> Options Indexes MultiViews AllowOverride All Order allow,deny Allow from all </Directory> Configure the vhosts includes Open /etc/apache2/extra/httpd-vhosts.conf Comment out the 2 VirtualHost examples by putting a # in front Be sure that NameVirtualHost *:80 doesn’t start with a # sign. * Add the include: include /Users/martijn/Sites/_vHosts/*.conf at the bottom of the file. Save the file, password will be asked. The file should at least have these two lines: NameVirtualHost *:80 include /Users/martijn/Sites/_vHosts/*.conf * ( Replace martijn with your short admin name ) The ~/Sites folder (Users/martijn/Sites) Goto your user Home folder. Create the Sites folder in your user home ( if not exist ) Create inside the Sites folder a folder called _vHosts Create the folder domains inside the ~/Sites folder Create a folder inside the domains folder called processwire ( processwire will be the domain name ) Inside the processwire folder create 2 directories: 1. htdocs 2. logs ( make this writeable by right click the folder and choose Get info ) Create inside the htdocs folder a file called index.html with some content. The folder structure should look like: ~/Sites |`-- _vHosts | `-- domains | `-- processwire | |-- htdocs | `-- index.html | `-- logs Configure PHP Open the file: /usr/local/php5/php.d/99-liip-developer.ini ( This file is the last ini file that gets loaded, so perfectly suitable for your personal settings ) Make your personal changes here. ( setting xdebug.max_nesting_level=1000 for example if needed ) Save the file ( password will be asked. ) Make an alias the this file by right click and choose: Make Alias Name the alias _settings.ini or what ever you want to name it. Move the alias to your ~/Sites folder Create a vHostIn our ~/Sites folder we created a folder named _vHosts. This folder we gonna use for the vHosts. All files ending with .conf in this folder will be loaded when we (re-)start Apache. Create a new file with your favourite text editor. Type the following in the file: ( Replace martijn with your short admin name ) <VirtualHost *:80> DocumentRoot /Users/martijn/Sites/domains/processwire/htdocs/ ServerName processwire ErrorLog /Users/martijn/Sites/domains/processwire/logs/error.log.txt CustomLog /Users/martijn/Sites/domains/processwire/logs/access.log.txt common </VirtualHost> Save the file with the filename processwire.conf in the folder _vHosts The hosts fileGo to the Finder Press: shift + command + g ( Go to folder ) Type: /etc/hosts & press return Open the hosts file with you favourite editor Type 127.0.0.1 processwire below 127.0.0.1 localhost but above 255.255.255.255 broadcasthost Save the file Right click the file & choose: Make Alias Move the alias that you created to your ~/Sites folder Rename it to _hosts The file should look like: ## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 127.0.0.1 processwire 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost Test the Apache & PHP setup Go to: /Applications/Utilities/ Open: Terminal.app Type: sudo apachectl restart Press: RETURN Type: your admin password Press: RETURN At this point Apache & PHP will be up and running.Go to a browser and type: processwire/ in the address bar and press enter. MYSQL For managing MySQL databases I use Sequel Pro it's a very handy tool and in this tutorial we set the root user password with it. For the SQL server we gonna use the MySQL DMG Archive (x86, 64-bit) Download the following: MySQL DMG Archive (x86, 64-bit) Sequel Pro Open the mysql-5.6.16-osx10.7-x86_64 image * install mysql-5.6.16-osx10.7-x86_64.pkg, MySQLStartupItem.pkg & install the prefPane * if MACOSX complains about: ( mysql-5.6.16-osx10.7-x86_64.pkg” can’t be opened because it is from an unidentified developer. ) You should open your System Preferences, go to Security & Privacy and Allow apps downloaded from: Anywhere Set the root user password Double click the sequel-pro-1.0.2.dmg. The disc image will mount Drag'n'drop the Sequel Pro.app to your /Applications/ folder. Open Sequel Pro Type by name: 127.0.0.1 Type by host: 127.0.0.1 Type by username: root Login Press command + u Select the root user on the left side Fill in the password Press apply We're Done ----- Todo how to use it after the setup is complete2 points
-
Thanks Ryan. You give me way too much credit. Happy that I could contribute to selector inputfield. And always grateful that company I work at has great trust and support for processwire. Lister is really a game changer for ProcessWire, thanks for building it Ryan!2 points
-
Shortest is to just echo $page->field. If empty it will not output anything.2 points
-
Just wanted to share what I recently used to create forms in modules and in frontend using the API and Inputfield modules PW provides and uses on its own. I think many newcomers or also advanced user aren't aware what is already possible in templates with some simple and flexible code. Learning this can greatly help in any aspect when you develop with PW. It's not as easy and powerful as FormBuilder but a great example of what can be archieved within PW. Really? Tell me more The output markup generated with something like echo $form->render(); will be a like the one you get with FormBuilder or admin forms in backend. It's what PW is made of. Now since 2.2.5~ somewhere, the "required" option is possible for all fields (previous not) and that makes it easier a lot for validation and also it renders inline errors already nicely (due to Ryan FormBuilder yah!). For example the Password inputfield already provides two field to confirm the password and will validate it. De- and encryption method also exists. Or you can also use columns width setting for a field, which was added not so long ago. Some fields like Asm MultiSelect would require to also include their css and js to work but haven't tried. Also file uploads isn't there, but maybe at some point there will be more options. It would be still possible to code your own uploader when the form is submitted. Validation? If you understand a little more how PW works with forms and inputfields you can simply add you own validation, do hooks and lots of magic with very easy code to read and maintain. You can also use the processInput($input->post) method of a form that PW uses itself to validate a form. So getting to see if there was any errors is simply checking for $form->getErrors();. Also the $form->processInput($input->post) will prevent CSRF attacks and the form will append a hidden field automaticly. It's also worth noting that processInput() will work also with an array (key=>value) of data it doesn't have to be the one from $input->post. Styling? It works well if you take your own CSS or just pick the inputfields.css from the templates-admin folder as a start. Also the CSS file from the wire/modules/InputfieldRadios module can be helpful to add. And that's it. It's not very hard to get it display nicely. Here an code example of a simple form. <?php $out = ''; // create a new form field (also field wrapper) $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name",'subscribe-form'); // create a text input $field = $modules->get("InputfieldText"); $field->label = "Name"; $field->attr('id+name','name'); $field->required = 1; $form->append($field); // append the field to the form // create email field $field = $modules->get("InputfieldEmail"); $field->label = "E-Mail"; $field->attr('id+name','email'); $field->required = 1; $form->append($field); // append the field // you get the idea $field = $modules->get("InputfieldPassword"); $field->label = "Passwort"; $field->attr("id+name","pass"); $field->required = 1; $form->append($field); // oh a submit button! $submit = $modules->get("InputfieldSubmit"); $submit->attr("value","Subscribe"); $submit->attr("id+name","submit"); $form->append($submit); // form was submitted so we process the form if($input->post->submit) { // user submitted the form, process it and check for errors $form->processInput($input->post); // here is a good point for extra/custom validation and manipulate fields $email = $form->get("email"); if($email && (strpos($email->value,'@hotmail') !== FALSE)){ // attach an error to the field // and it will get displayed along the field $email->error("Sorry we don't accept hotmail addresses for now."); } if($form->getErrors()) { // the form is processed and populated // but contains errors $out .= $form->render(); } else { // do with the form what you like, create and save it as page // or send emails. to get the values you can use // $email = $form->get("email")->value; // $name = $form->get("name")->value; // $pass = $form->get("pass")->value; // // to sanitize input // $name = $sanitizer->text($input->post->name); // $email = $sanitizer->email($form->get("email")->value); $out .= "<p>Thanks! Your submission was successful."; } } else { // render out form without processing $out .= $form->render(); } include("./head.inc"); echo $out; include("./foot.inc"); Here the code snippet as gist github: https://gist.github.com/4027908 Maybe there's something I'm not aware of yet, so if there something to still care about just let me know. Maybe some example of hooks could be appended here too. Thanks Edit March 2017: This code still works in PW2.8 and PW3.1 point
-
You can create your own databases and execute queries easily with PW. Here is an example from Martijn that I found with a quick search (there are many more in the forums) http://processwire.com/talk/topic/4691-can-i-use-my-own-database-table-in-processwire/?p=45770 That said, I thinks it's proven already that PW can handle that amount of pages, and using them instead of custom tables would give you the benefit of being able to use the API of course. I guess I'm not exactly saying "what the hell man, just use pages!", but you need to find a balance between performance and how easy it will be to work with that data, knowing that performance will be also dependent on the system your site will live in and that there are cool tools like pro-cache that could help you with that.1 point
-
Won't tell to much but I think there's an alternative responsive admin theme in development.1 point
-
Thanks for fixing my sloppy code Also, here is a great article on ternary operators: http://davidwalsh.name/php-shorthand-if-else-ternary-operators Anything you think you might be sacrificing in PW by not using templating syntax, is more than made up by the abilities of simple everyday PHP. Ryan also wrote a good article here: http://processwire.com/api/why-php-syntax/1 point
-
I've also been exporting "everything", though (like you said) the copy method obviously can't literally export everything.. These are the errors I get in the same situation, with repeater field added. Ready items for this repeater is set to 3 and you can view the final JSON output here. Notice: Trying to get property of non-object in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 1403 Warning: Invalid argument supplied for foreach() in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 1403 Notice: Trying to get property of non-object in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 1038 Warning: Invalid argument supplied for foreach() in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 1038 Warning: Invalid argument supplied for foreach() in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 1026 Notice: Trying to get property of non-object in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 1403 Warning: Invalid argument supplied for foreach() in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 1403 Notice: Trying to get property of non-object in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 1403 Warning: Invalid argument supplied for foreach() in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 1403 Notice: Trying to get property of non-object in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 1403 Warning: Invalid argument supplied for foreach() in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 1403 Testing your zip file didn't go exactly as planned, though that was probably user error; didn't select "replace", tried to "append" with parent set to "home" and as a result I got "Integrity constraint violation: 1062 Duplicate entry 'about-1' for key 'name_parent_id'". Slightly weird thing here is that when trying this again with "replace", I got the same error, though this might be because something was broken earlier. Might have to setup another test site to see what's actually going on here -- if this works for you, there's most likely something wrong with my test site. One specific thing I'm not really comfortable with, though I'm not entirely sure if that's possible to avoid either, is that even though the import fails things like fields and templates are still added and/or kept. This could potentially leave the site in a kind of a strange state, with some old content and some new. It'd be cool if failed import "cleaned up the mess", so to speak Another thing that probably should be handled somehow are possible permission errors: Warning: copy(/site/templates///basic-page.php): failed to open stream: Permission denied in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 449 Warning: copy(/site/templates///gallery.php): failed to open stream: Permission denied in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 449 The reason for these is obvious and (again) I should've known better, but then again, the module could also check for necessary permissions beforehand -- or perhaps just interrupt the import the moment this happens and notify user to make sure that permissions need to be tweaked? .. and by the way, those template paths with three forward slashes look a bit strange, but that's far from fatal PS. I actually enjoy testing this module and see a lot of potential in it. As a matter of fact it's already proven it's worth in some of our projects, saving me quite literally hours of work, on more than one occasion. If it sounds like I'm only seeing bad things here, that couldn't be further from the truth1 point
-
I read your question three times and still don't understand it, might be that someone else will read it more clearly and will be able to help you, but in case it's not just me having trouble with it, can you give some concrete examples of what you want to achieve?1 point
-
echo "<div id="block-parent">$out</div>"; Thanks adrian, but i changed your last line with the following code that it works like a charm echo "<div id=\"block-parent\">" . $out . "</div>";1 point
-
Hey teppo, Thank you for the testing. I can replicate that same export error. I hadn't come across it before, but looking at your export JSON, I noticed that the page field you included has a parent_id of "home". I never anticipated that. The module will actually find all page field parent/child trees and add them to the export, so if for example you had a pagefield that linked to a categories/category tree, then it would grab that info, export it and import it on the new site, even though it is not directly under the parent you chose when exporting. I think the module actually handles this scenario quite well (despite the error which is an easy fix) - so if you do choose home, it won't try to export the entire home tree, but it will use the children of home on the new site, once you do the import, which is what happened for me when I imported your JSON. Does that make sense? EDIT: Actually that 1038 error is because your page field doesn't have a "Template of Selectable Pages" set. I have always been testing with page fields with both "Parent of ..." and "Template of..." defined in the Input tab. I'll have to make sure there aren't any further complications here. The message about importing template files should be hidden in this case, since it is clear you used the copy/paste approach. Obviously template files (*.php) can only be migrated with the "Save" output format. I'll take care of hiding that when it's not appropriate. Now for the confusing one, the errors with repeater fields. I haven't had any issues with those in quite some time now so I am curious on the exact setup. Would you mind testing one again and send me the errors you're getting and also the JSON, and if they're not being included in the export, perhaps you could sketch out their structure. One thing I am curious about on the repeater front - what option are you choosing for "Components to Export"? I have been doing almost all my recent testing with "Everything", so I am wondering if that might have something to do with it. I notice that none of your page fields have any content. Thanks again, really appreciate this! BTW, I have attached an export of a page tree that shows repeater and page fields working, along with images and RTE embedded images. Be sure to import "Everything" and choose "Replace". It should go into any parent, but I have been testing mostly with Home as the import's root is "About". It will replace your About (if you have one) and also install a US states page tree for the state selector field. There are a couple of repeaters at the bottom of the gallery child page. files.zip1 point
-
@joe_ma: email not getting sent and the fact that you're not getting success message both indicate that in your environment PHP's mail() doesn't work. The reason for that can only be guessed, but to make sure I'd create a simple mail() call somewhere and see if you can actually send anything anywhere. If it turns out that mail() simply isn't working for you at all, first you'll want to check if your web host has any tips for this situation. This depends, of course, entirely on what kind of hosting setup you've got. It would also make sense to take a look at your error logs (/site/assets/logs/errors.txt), Apache error logs if you've got access to those and try this with debug mode turned on in your /site/config.php. See if there's anything strange happening when you're trying to send this email. Note that you should only set debug mode on if this is not a live site, you really don't want that to be turned on in production environment! (In case that you've got an SMTP server you can use for sending email, you could also try installing Wire Mail SMTP or Swift Mailer, but note that for either of these to work you'll need to use current dev branch of ProcessWire, which isn't necessarily a good idea for live site either!) About your second question: you can do that (append them to $success_message) or simply output them right after / before success message. Doesn't really matter, other than if you're trying to use values user submitted, you'll want to do that after the "$form = array( ..." line and use them from that array, so that they're sanitized: // set and sanitize our form field values $form = array( 'datum' => $sanitizer->text($input->post->datum), 'ankunftszeit' => $sanitizer->text($input->post->ankunftszeit), 'anzahl_plaetze' => $sanitizer->text($input->post->anzahl_plaetze), 'name' => $sanitizer->text($input->post->name), 'adresse' => $sanitizer->text($input->post->adresse), 'plz' => $sanitizer->text($input->post->plz), 'ort' => $sanitizer->text($input->post->ort), 'email' => $sanitizer->email($input->post->email), 'tel' => $sanitizer->text($input->post->tel), 'extras' => $sanitizer->textarea($input->post->extras), ); // append values to success message if ($form['datum']) $success_message .= "<br />Datum: " . $form['datum']; // etc.1 point
-
@adrian, I've been testing this a bit and getting this after export: Notice: Trying to get property of non-object in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 1038 Warning: Invalid argument supplied for foreach() in /site/modules/ProcessPageTreeMigrator/ProcessPageTreeMigrator.module on line 1038 Not sure if this affects the import process, though. At least pages get imported properly, but there is something a bit strange there too; see attached screenshot. "Following template files" seems to suggest that something was (supposed to be) migrated there too, but now it looks like somethings missing below that headline? Earlier this template had repeater field on it and I was seeing quite a bit more errors, so I removed the repeater field in case that was causing it somehow. Errors did actually go away, but only partly -- as you can see, some still remain. I'm running 2.4 master branch on a local MAMP installation with PHP 5.5.10. You can see exported data here.1 point
-
Another pretty major update today. Here's the list of changes: Friendly error handling when modules/fieldtypes aren't installable on the destination site which also prevents any actions until you install the required modules. Support for migrating page data for all (hopefully) custom fieldtypes. I have tested with cropImage, MapMarker, Dimensions, and Phone. Let me know if you find one that doesn't work. Also, if you are playing around with MapMarker, be sure to make the changes shown in this PR: https://github.com/ryancramerdesign/FieldtypeMapMarker/pull/4/files - seems like it might only affect very recent devs of PW and hopefully Ryan will commit that change soon anyway. New Import Types: Append, Overwrite, Replace. Explained fully in the module, but the key new functionality is replace, which effectively allows you to edit the content in a section (Page Tree) of a site (say on your dev server), including changes to field settings, which fields are in the template (including repeater fields and their subfields), and the page data in the fields, and all these changes will be replicated on the destination site. This is very new, so let me know if you find something I have missed. Remember, there is one happy customer already .... But I am looking for more If you want a quick demo, don't forget you can try installing Ryan's blog profile as a child of your Home using the zip attached to this post.1 point
-
Thanks! It's a pleasure to work PW once you understand you are not forced to do things 'the CMS way'. Seems like this is the hardest part when coming from another cms.1 point
-
small update: added separate inputfield for HTML signature into config page to solve an issue found by tuomassalo. https://github.com/horst-n/WireMailSmtp/issues/1 version now is 0.1.81 point
-
Agreed. Also nice to see more Finnish agencies joining ProcessWire!1 point
-
http://www.4p8.com/eric.brasseur/gamma.html#introduction or before: http://processwire.com/talk/topic/3768-processwire-231-dev-branch/page-5#entry43649 BTW: I remember well the first words from a colleague who has experience for more then 20 years working in international architecture photography bussiness after playing around 2-3 days with his first ProcessWire version of his site: "Schönes Programm, übersichtlich und einfach. Vor allem alle meine Bilder sind so klar und knackig." (english with googleTranslate: "Nice program, clear and simple. Above all, all my images are so clear and crisp.") And be aware: by visualizing images or anything else within a website there are involved many instances. (Browser, System, Monitor). Above all, one can not make reliable statements if you do not at least use a good set hardware calibrated monitor. And even two well adjusted monitors doesn't show the exact same output. So, before going academic here, ... back to work.1 point
-
This may be a bit off-topic (nothing new from me), but I remember someone saying that "Page" makes much more sense than "Node" (for an example) for web use, and I really do agree with that. Still it's interesting to see how people not used to ProcessWire's jargon (and often coming from other systems and/or custom-built applications) get confused here. CMS/CMF such as ProcessWire has to manage content as nodes / items / pages / rows of some form and in this case those items are called Pages. They're not that different from Nodes in Drupal or Posts (and, these days, a whole bunch of different "post types") in WordPress.. or even from simple database rows. The main difference between database rows and Pages, of course, is that Pages have mostly web-related helpers (methods) attached to them and the built-in ability to pull content automagically from multiple tables. Sure, you could say that Pages are objects and thus have some overhead from there, and you'd be absolutely right. Then again, it all depends on your use case and what really matters for you. Most things built in ProcessWire could be considered "web sites" and web sites usually consists of (surprise!) Pages. Makes sense, huh? It is also important to note that you don't actually have to use Pages for everything. Saying "in ProcessWire everything is a Page" is misleading. It's true for the bulk of everything built with ProcessWire, but there are exceptions. For my Version Control, Changelog and Login History modules, for an example, I chose another route: a custom database table. In my opinion custom database tables are better option in some cases, but this way (like Pete already pointed out) you won't be able to use ProcessWire's selector engine; you'll have to write all your queries as plain, old SQL instead and route them through $db (MySQLi) or $database (PDO) objects. Doable, but potentially less secure (with selectors there's no risk of SQL injections, for an example) and more complicated. There's also the option of creating custom Fieldtypes. Each Fieldtype defines it's own schema, so this is very viable alternative to custom database tables. This way you'll still be able to work with native selector engine, but you'll get some of the benefits of plain database tables also. Ryan's Events Fieldtype is a good example (and starting point) of this. ProcessWire sets very few limits on the way you work. Want custom tables? Sure, go ahead, do it. Want to use Pages you can add fields to later with ease, edit with built-in admin tools and find using selectors? Sure, we can do that too. Combination of both, pages with fields of custom type and schema? No problem, we've got you covered. .. and this is one of the main reasons I love ProcessWire.1 point
-
Hi vigilante, welcome to the forum! There is a blank profile http://modules.processwire.com/modules/processwire-blank-install/ A site like this will be more complex to build with any tool. If pages are very different, one way is to have almost a template per page. if there are things in common, you can use the same template and use includes or functions on a common file. If the differences are minimal, you can do simple checks inside your templates for the page ID or any other characteristic this page may have that differentiates them from the others (a field. or the person that is looking at it, or the language, or whatever) You write it on template files, but has I told above, you have to be a bit clever about doing it. If the site really asks for it, either because of each page needing different fields, or because the code just need to be too different for each page, you can also go the 1 page / 1 template route of course I've seen that Joss and Kongondo also answered already, but still didn't see their answers. I bet they are loooooooooooooooong!!!! edit: I was right about Joss. Kongondo is not in a good shape today1 point
-
Ah, well as it happens, it was them that wanted it changed from 0.9 to 0.8 I meant to mention that for their news, or "notices" as they call it, they decide manually what gets shown on the front page (only will show 4) and what gets featured in the carousel on the noticeboard. The rest of the noticeboard page is all those articles that are NOT featured, though they may be on the front page. This is just because they have some issues which don't seem to want to go away, so they want to keep those articles up the top all the time. It is not heavily managed, but just enough to give them a little bit of versatility without swamping them with option. This is actually one of the more important points about something like ProcessWire - the ability to develop the settings the client needs without lumbering them with a huge amount of default options that they will never use and make their UI look messy.1 point
-
Thank you, Ryan. My intent was to implement some sort of security auditing such that I would receive a message whenever a CSRF was attempted. So I needed to catch the exception. The following code works for me. try { $form->processInput($input->post); $session->CSRF->validate(); } catch (WireCSRFException $e) { echo "Processing aborted. Suspected attempt to forge the submission. IP logged." . $e->getMessage(); /* * Some code to execute whenever the token gets spoofed * Like sending a notification mail with the spoofer's IP address */ die(); // live a great life and die() gracefully. }1 point
-
Due to scope, you need to use wire('config') inside a function. Same is true for all the PW variables: http://processwire.com/api/variables/ If you'll be using it a lot in the function, you can do $config = wire('config') and then use $config as normal after that.1 point
-
[quotamos]This is really interesting stuff and I'm learning so much from it. I've already tested Soma's code and it works very well. Is there a way of configuring $form->render() so that it outputs different html (divs for ul/li etc.)? [/quotamos] you.can usage. $form->setMarkup(); und $form->setClasses(); two.set markups und html caresses. see.eliamos /wire/core/InputfieldWrapper.php1 point
-
Great tutorial Soma! This is the best summary of using PW's Inputfields that I've seen. I noticed you did $field->attr('id+name', 'email') so just wanted to explain what that is for those that may be unsure of the syntax. That syntax is basically saying to set the 'id' and 'name' attribute to have the 'email'. While every field needs a 'name' attribute (like in HTML) the 'id' attribute is optional… if you don't assign an id attribute, PW will make one up. If you intend to custom style a field with CSS or target it from javascript, then it's best to assign your own 'id' attribute. Otherwise, it doesn't matter. // this… $field->attr('id+name', 'email'); // …is the same as: $field->attr('id', 'email'); $field->attr('name', 'email'); // …as is this (direct reference): $field->id = 'email'; $field->name = 'email'; The advantage of using the attr() function over direct reference is that attr() can't ever collide with other Inputfield properties that might have the same name as a field attribute. It's basically your way of saying "this should definitely be an HTML attribute and not anything else." For recognized attributes like 'name' or 'value' it doesn't matter what syntax you use because an Inputfield already knows 'name' and 'value' are standard HTML attributes. But if you needed to add a custom attribute like "data-something", well then you'd definitely want to use the attr() method of setting. That attr() method should only be used for things that would actually be HTML attributes of the <input>, because they will literally end up there. So if you do an $field->attr('label', 'Hello'); you'll end up with an <input label='Hello'> in the markup, which is obviously not something that you want. That's why you assign a non-attribute property like 'label' or 'description' directly, like: $field->label = 'Something'; Last note about $attr() is that it can be used for both setting and getting attributes: $field->attr('value', 'something'); echo "The field's value is: " . $field->attr('value'); // same as: $field->value = 'something'; echo "The field's value is $field->value"; To extend your example, lets say that you wanted the 'email' and 'password' fields in a fieldset titled "About You". You would create the fieldset, and then add/append the fields to the $fieldset rather than the $form. Then you'd add the $fieldset to the $form: $fieldset = $modules->get('InputfieldFieldset'); $fieldset->label = 'About You'; $field = $modules->get("InputfieldEmail"); $field->label = "E-Mail"; $field->attr('id+name','email'); $field->required = 1; $fieldset->append($field); // append the field $field = $modules->get("InputfieldPassword"); $field->label = "Password"; $field->attr("id+name","pass"); $field->required = 1; $fieldset->append($field); $form->append($fieldset); Or lets say that you wanted those 'email' and 'password' fields to be each in their own column so that are next to each other horizontally rather than vertically. You would assign the 'columnWidth' property to both the email and password fields. In this case, we'd give them both a value of 50 to say that we want them to be a 50% width column: $field->columnWidth = 50; To jump out of tutorial mode and into idea mode: lately I've been thinking that PW should have a YAML to Inputfields conversion tool in the core (something that would be pretty easy to build), so that one could define a form like this: And create it like this (where $yaml is the string above above): $form = $modules->get('InputfieldForm'); $form->load($yaml); echo $form->render();1 point
-
Here's another option: $field = $fields->get('your_page_select_field'); $inputfield = $field->type->getInputfield($page); $options = $inputfield->getSelectablePages($page); The advantage is that it'll work with all selectable pages settings (i.e. template, selectors, code, parent). Whereas the previous examples assume the selection is built just around a parent (which is perfectly fine too if that suits your needs).1 point