Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/06/2015 in all areas

  1. Just checked in a first beta version of a new module I'm working on. Feel free to test out and see what's up with it. Pollino (beta) A simple poll module for ProcessWire This module makes it simple to setup polls for your website. It is based on a simple page setup to create the polls. So each poll is a page, and its children are the answers. Pollino will create the templates and a PollinoPolls page in the root to start with. You can add fields to the templates as you wish and later use hooks to modify the output of the poll. This can be useful, for example, to use images as options or just some custom markup etc. It provides some API to render the poll form and the result. These methods are hookable and it's easy to customize the output if needed. It can be rendered on any page and even multiple on the same page. Pollino takes care of saving the votes and preventing multiple votes. It comes with some configuration settings to choose what method to use to prevent from multiple votings: using cookie and an expire time or by IP and optionally also the UserAgent with and expire time or by logged in User Pollino isn't 100% plug'n'play but it provides a solid foundation and comes with some premade theme and output for you to start. It takes care of the boring stuff and lets you concentrate on the front-end stuff and styling. That's what matters after all. It does support multilanguage, as all strings are translatable in the module. Also since it's using simple pages and templates you're free to add or change fields to make its output multilanguage without much hassle. ----- Read more and download https://github.com/somatonic/Pollino Online Demo I setup a little demo here to see using https://lightning.pw http://titanium-x77.lightningpw.com/ Have fun.
    14 points
  2. I hope they'll ask WillyC to make one for them :-P
    11 points
  3. This site was recently launched and has been running great for the last few weeks. It is probably the largest PW project I have done; there is a lot of media to keep organized, this label has about 70 albums and over 400 artists... http://www.newfocusrecordings.com/ the homepage displays 12 random albums the catalogue page, uses datatables and loads the cover images on demand; the filtering is all done with the datatable, and the urls are updated without page reload... the album page: the pw version replaces a joomla version that was used for about 6 years.. and was a pain to work with; some modules: AdminCustomFiles AdminSaveActions AdminTemplateColumns AIOM+ FieldtypeColorPicker FieldTypeSelectFile (for selecting huge media instead of uploading into PW) FieldtypeTemplates (for selecting which template a certain support doc should show on) FormBuilder FormSaveReminder ImportPagesCSV (used to import some of the data from Joomla and Zoo) InputfieldSelectExtended (used to show additional info after a select action) PageReferencesTab PageTreeAddNewChildsReverse (new albums need to be at top of list) ProcessCustomUploadNames (to ensure the asset naming matches the catalog numbers) PageListerPro ProcessRedirects (for some legacy URLS) ProFields TextformatterBBCode (used for formatting of track and album titles with special characters, superscripts, bold, italic) VersionControl HannaCode SiteUtilities - a custom module that controls many helper functions, read id3 tags, move audio files, rename stuff etc.. some forum threads that relate to this project, and as always thank you to everyone who helped and more generally who take part in the forum! https://processwire.com/talk/topic/8366-setup-sharrre-sharing-widget-in-5-minutes/ https://processwire.com/talk/topic/8392-simple-built-in-docs/ https://processwire.com/talk/topic/8350-module-fieldtype-yaml/ I also work for this label, and have designed about 10 of the covers.. - - - - Special Features: Press View There is a user role called press, and on the user profile, site admins can select certain albums to allow access to for that press user. When the user logs in they can see which albums they have extended access to and then when they view the album there is an extended view and additional media and content. The page audio player will play full streams of the tracks, whereas the public view only plays the edited preview files; the presence of the full stream is indicated with a radio/wave icon.. left widget showing some extra content:
    10 points
  4. Update: Menu Builder Version 0.0.2 is now available. I'll update the original post later + post a new video. Main Changes: Beta status Menus stored as pages (note: just the menu, not the items!) Menu items stored as JSON in a field in the menu pages (empty values not stored) Add menu items from ProcessWire pages using page fields (option to choose between PageAutocomplete and AsmSelect [default]) or a Selector (e.g. template=basic-page, limit-20). For page fields, you can specify a selector to return only those specified pages for selection in the page field (i.e. asm and autocomplete) For page fields, now you can also add css classes and IDs as you add the items Menu settings for nestedSortable - e.g. maxLevels (limit nesting levels) Advanced features (e.g. add pages via selector, menu settings) currently permissible to superadmins only (may change to be permission-based) Delete single or all menu items without deleting the menu itself Lock down menus for editing Highly configurable MarkupMenuBuilder - e.g. can pass menu id, title, name or array to render(); Passing an array means you can conditionally manipulate it before rendering, e.g. make certain menu branches visible only to certain users [untested and the code is up to you!] More... Note: Some nestedSortable features not yet implemented/working (some are not really necessary actually). The module creates 3 fields (menu_items, menu_pages, menu_settings) and 1 template (menus). Menu pages are stored as children under the modules parent page (admin/setup/menu-builder/) - so not accessible in the frontend Issues: Drag and drop (ordering menu items) is some times finicky...something in the js I think or just my mouse.
    10 points
  5. I've just finished the work on this page and got the permission to share it on the showcase page. Maxim produces and distributes cosmetic products for many different brands in Germany, France and other European countries. This website showcases the company‘s high standards in quality and design. In a few days the translation will be ready and the website gets multilanguage support (Thank you, Ryan, for this awesome CMS).
    8 points
  6. Just hold the new c't one of the big german computer magazines....it's a 4 page article....very nice written. some extractions translated: ...backlinks online and in the end of the article $pw->awesome->url = http://ct.de/ybn5 best regards and a great weekend mr-fan
    6 points
  7. They appear to have reconsidered
    5 points
  8. Hi Jonah, welcome to the PW community! Your issues mostly seem to pertain to PHP, not ProcessWire specifically. To answer #3, you are correct in that there is no special ProcessWire syntax. In the code you show, there is nothing really “PW-specific”. What ProcessWire does here is provide you with variables you can use in your template, namely $page to access data related to the requested page. The PW-specific knowledge you need is not of syntax, but of those variables, their classes and their methods. In the example, you need to know what kind of object the field image_details is, so you can know to access it with foreach. In #1, be aware of PHP’s assignment and equality operators! In your if condition, you want to compare values, so you must use == or ===, but never =! You should also wrap the conditional blocks in {curly brackets}. It is not necessary if you only need one statement, but good practice if you ever need to add some more. Since it is a PHP question, I’ll let StackOverflow explain the difference between 'single' and "double" quotes: http://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php Basically, it doesn’t really matter, but double quotes give you more functionality. I assume #2 is related to #1 in that you have overwritten $page->title with the string "home", because you used the assignment operator = instead of comparing with ==.
    4 points
  9. Nice one ESRCH, but that only affects the View tab on editing a page - I also like to change the view links on the page tree. Yours does cover the only critical issue as that is when it is possible to lose changes to a page (unless you have Soma's Form Save Reminder installed). I just posted this over at: https://processwire.com/talk/topic/7588-admin-custom-files/?p=89331 because it uses Martijn's Admin Custom Files. This version also changes the view links on the page tree. ProcessPageList.js $(document).ajaxComplete(function(){ $('li.PageListActionView a').each(function(){ if($(this).attr('target') == undefined){ $(this).attr('target','_blank'); } }); }); ProcessPageEdit.js $( document ).ready(function() { if($('#_ProcessPageEditView').attr('target') == undefined){ $('#_ProcessPageEditView').attr('target','_blank'); } }); Maybe someone else will also like this approach.
    3 points
  10. I nearly fell off my chair after just seeing the announcement come into my inbox. Whoever is going to do the Processwire tutorials at tuts+ will have a lot of wow moments.
    3 points
  11. I have actually started using this version so that the links only show on hover and are hidden from the parent when a branch is open: .content .PageList .PageListItem:hover .PageListActions{display:inline;-webkit-transition-delay:.25s;transition-delay:.25s} .content .PageList .PageListItemOpen .PageListActions{display:none !important;} .content .PageList .PageListItemOpen:hover .PageListActions{display:inline !important;-webkit-transition-delay:.25s;transition-delay:.25s} In addition to quicker access and less confusion, it is also a huge performance increase on slow internet connections (I just spent a few months with horrible internet) because you don't need the ajax call to retrieve the child pages just to be able to edit the page, or add a new child.
    3 points
  12. Menu Builder As of 29 December 2017 ProcessWire versions earlier than 3.x are not supported Modules Directory Project Page Read Me (How to install, use, etc..) For highly customisable menus, please see this post. If you want a navigation that mirrors your ProcessWire page tree, the system allows you to easily create recursive menus using either vanilla PHP or Soma's great MarkupSimpleNavigation. In some cases, however, you may wish to create menus that: 1. Do not mirror you site's page tree (hirarchies and ancestry); and 2. You can add custom links (external to your site) to. That is primarily where Menu Builder comes in. It is also helpful if you: 3. Prefer creating menus via drag and drop 4. Have a need for menus (or other listings) that will be changing regularly or that you want to allow your admin users to edit. The issue of custom menus is not new here in the forums. The difference is that this module allows you to easily create such menus via drag and drop in the Admin. Actually, you can even use it to just create some list if you wanted to. In the backend, the module uses the jQueryUI plugin nestedSortable by Manuele J Sarfatti for the drag and drop and is inspired in part by the WP Custom Menu feature. Please read the Read Me completely before using this module. For Complex or highly-customised menus, it is recommended to use the getMenuItems() method as detailed in this post. Features Ability to create menus that do not mirror your ProcessWire Page Tree hierarchy/structure Menus can contain both ProcessWire pages and custom links Create menu hierarchies and nesting via drag and drop Easily add CSS IDs and Classes to each menu item on creating the menu items (both custom and from ProcessWire pages) or post creation. Optionally set custom links to open in a new tab Change menu item titles built from ProcessWire pages (without affecting the original page). E.g. if you have a page titled 'About Us' but you want the menu item title to be 'About' Readily view the structure and settings for each menu item Menus stored as pages (note: just the menu, not the items!) Menu items stored as JSON in a field in the menu pages (empty values not stored) Add menu items from ProcessWire pages using page fields (option to choose between PageAutocomplete and AsmSelect [default]) or a Selector (e.g. template=basic-page, limit=20, sort=title). For page fields, you can specify a selector to return only those specified pages for selection in the page field (i.e. asm and autocomplete) For superusers, optionally allow markup in your menu titles, e.g. <span>About</span> Menu settings for nestedSortable - e.g. maxLevels (limit nesting levels) Advanced features (e.g. add pages via selector, menu settings) currently permissible to superadmins only (may change to be permission-based) Delete single or all menu items without deleting the menu itself Lock down menus for editing Highly configurable MarkupMenuBuilder - e.g. can pass menu id, title, name or array to render(); Passing an array means you can conditionally manipulate it before rendering, e.g. make certain menu branches visible only to certain users [the code is up to you!] Optionally grab menu items only (as a Menu object WireArray or a normal array) and use your own code to create custom highly complex menus to meet any need. More... In the backend, ProcessMenuBuilder does the menu creation. For the frontend, menus are displayed using MarkupMenuBuilder. Credits In this module's infancy (way back!), I wanted to know more about ProcessWire modules as well as improve my PHP skills. As they say, what better way to learn than to actually create something? So, I developed this module (instead of writing PW tutorials as promised, tsk, tsk, naughty, naughty!) in my own summer of code . Props to Wanze, Soma, Pete, Antti and Ryan whose modules I studied (read copied ) to help in my module development and to Teppo for his wonderful write-up on the "Anatomy of fields in ProcessWire" that vastly improved my knowledge and understanding of how PW works. Diogo and marcus for idea about using pages (rather than a custom db table), onjegolders for his helpful UI comments, Martijn Geerts, OrganizedFellow, dazzyweb and Mike Anthony for 'pushing me' to complete this module and netcarver for help with the code. Screens
    2 points
  13. Thanks guys, Will look into it. Should be easy enough using $options. On my to do list: See $options. You can already do this: $options = array('menu_css_id' => 'main', 'menu_css_class' => 'navigation'); $menu = $modules->get('MarkupMenuBuilder')->render(1234, $options); Am I missing something? Will update docs later... Btw, one is not tied to using MarkupMenuBuilder -> you can easily json_decode($menuItemsJSON, true) the menu items JSON and recursively traverse the resultant array using a custom PHP function or even with javascript.
    2 points
  14. In neither. If you're editing the pageTable field there's a textarea "Table fields to display in admin" under the "Input" tab. There's the place to change the columns.
    2 points
  15. Awesome, can't wait to read it. Just bought the article online. btw. the article is called "Kurzer Prozess", literally translates to "short process", best English equivalent might be "to cut to the chase". Wordplay here.
    2 points
  16. I just tested it and it's very nice. I want to put a class on the menu submenu so on nested unordered list. Is there an option for this? For example <ul class="submenu">
    2 points
  17. This is a nice and much needed thread, however it would be great if each idea, complaint, feature or UI request referenced a Github Issue or another thread within the forum. To me, that would ensure that these important concerns were/are being addressed.
    2 points
  18. I also completely agree with this. As a workaround, I put this hook in a general "utilities" module: $this->addHookAfter('ProcessPageEdit::buildFormView', function($event) { $process = $event->object; $tabId = "ProcessPageEditView"; $viewLink = $process->getTabs()[$tabId]; $viewLink = substr_replace($viewLink, " target='_blank'", 2, 0); $process->removeTab($tabId); $process->addTab($tabId, $viewLink); }); But it would be much better if this was the default behavior...
    2 points
  19. Funny how all problems listed here annoyed me and others too, we get used to them and don't complain. That might even be dangerous, so client's feedback is key.
    2 points
  20. Do you also use the field descriptions extensively? My clients LOVE this, it makes it very clear what is used where and how.
    2 points
  21. What's interesting here is these are all minor / low-level friction points which if fixed could make the experience that much better. As developers we get past them but to clients who are less 'married' to the CMS they're probably bigger annoyances. If I hadn't directed this training session, I'd still think these were annoying but assume because no one else piped up about them, that I should live with them.
    2 points
  22. 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
  23. I setup a little demo here to see using https://lightning.pw http://titanium-x77.lightningpw.com/ You see it one single on home sidebar and on the PollinoPolls page you see two. The expire time is set to 1 minute. via cookies
    1 point
  24. m-artin, Welcome! If you just need accordions, you might like the TextformatterAccordion module. Here's a simple demo.
    1 point
  25. 1 point
  26. @Soma - where's your tip jar? I don't see it on your Modules page or signature.
    1 point
  27. How cool. I'm in discussions with a client to move his pretty large site over to PW. One of the features that I could see being a problem was a custom developed Poll snippet the client loves on his current site. I was literally worrying about this all week and how client would take news that his 'upgraded' site didn't have one of his most often used features Thanks so much!
    1 point
  28. Great looking site! Small thing: the image used (maxresdefault.jpg) for the Youtube video on the homepage does look like it has had too much compression when viewed on a desktop monitor/high resolution.
    1 point
  29. @cstevensjr - thanks for checking it out and for the compliments, most appreciated! @martijn - thanks! yeah i think you're right; it might be annoying the way it is now with the small link icon to open the album.. maybe i need to lose the icon and then make the link be on the .entry-innerwrap as you suggest.. that would leave more room for the text
    1 point
  30. The Profields Table seems to be a good fit for me in order to multiply accordion panels. So I want to add a +1 for the ability to use the ckeditor editor inside the table (perhaps in inline mode). This would be perfect for small text-formatting adjustments and even adding images with the ›insert image-button‹. Currently I use a workaround with an extra text-field inside every table-row for manually inserting an image-path. P.s. Processwire is just wow!
    1 point
  31. That's because at the moment, when you change the menu 'Title', only the title gets changed and not the name (i.e. on the PW page). In rendering using a title or name, it looks for the name. In that case, your new title would be first converted to a name and the module would look for a menu page with that name, which would obviously not exist (since name was not changed). Rendering by ID would still work though. But, I see no reason why I should not change this behaviour. I will make it change the name to match the title as well to be foolproof. Since menu pages are not visible in the frontend and are not really for querying, there is no harm in that. Thanks for the suggestion. ps: If possible, could you file feature requests at the project page in Github? I won't have time to work on this today and might forget some things, thanks.
    1 point
  32. You're using tabs in your code, for constancy using spaces is better. Thanks for creating this kongondo.
    1 point
  33. If you're using the current stable version then pages are the best way to take. If you're on the dev version you could also use the new fieldset options. It's a lighter alternative to creating pages just for providing options, but more flexible as the select dropdown module.
    1 point
  34. You don't seem to have noticed the edit to my last post. It's doable with "template" or "template.label".
    1 point
  35. Or if you use a Mac use TextWrangler or BBEdit to get rid of those gremlins with the “Zap Gremlins” function.
    1 point
  36. And make sure, that you checked "Should page URLs end with a slash? Yes" in your Logout template.
    1 point
  37. @tuxy Make sure that you put right URL to your logout page in "<a href='/logout'>". I recommend you to use ProcessWire API to get right URL. <?php echo "<a href='" . $pages->get("id=33977")->url . "?redirect=$page->id". "'>Logout</a>"; ?> 33977 change to your logout ID page. If you don't know how to find page ID just try to edit that page and get it from url /page/edit/?id=33977 ?redirect=1 probably mean that you try to to logout from homepage, which always have ID=1.
    1 point
  38. I’m not familiar with Sublime Text, but this seems to be a problem of both your phone and Sublime Text not honoring Unicode guidelines (check this out), albeit in different ways. Sublime Text doesn’t show you the problematic character at all and your mobile browser shows a missing glyph symbol. Try viewing your code sample from the first post on your phone. You’ll see the same rectangle right behind the closing PHP tag ?>. Sublime Text should have a view mode that shows invisible white space characters (like tabs, spaces, and your 2028 separator). If you turn that on, you should be able to delete it easily You have run into the same issue as this guy. That is to say, it’s not ProcessWire inserting the symbol
    1 point
  39. This module stated that it is not compatible with PW2.5 but so far haven't seen any issue with ProcessWire 2.5.21 dev. I'm sure i'm not the only one using this module so updating the compatiblity with 2.5 looks fairly save to me. Thank for this awesome module.
    1 point
  40. 1 point
  41. I leveled your posts to likes ratio Great you like the module !
    1 point
  42. @Martijn Geerts THIS module is a really great one! Thank you very much - just experimented with it a little bit and result is: easy == awesome best regards mr-fan
    1 point
  43. This has apparently been disabled because the circular reference lead to problems: https://github.com/ryancramerdesign/ProcessWire/issues/663 One possible solution for you would be to default to $page if no page is selected. Seems intuitive enough for the user, unless you need “no selection” to actually mean “no selection”. Another thing you could do would be to add a “proxy” page somewhere, called “<This Page>”, and check if that was selected, then use $page.
    1 point
  44. At the moment I have no usage for FCM module, but after FormHelper 0.5.2 is finished I've done a quick FCM rewrite. Only few tests done yet!
    1 point
  45. they declinded not.support wordpress universe model pw no good.for themeforest sales follow.the €
    1 point
  46. Using wireSendFile() for flexible download is great to mask the real file location on the server or to select the file according to the language, but it comes with an issue that appears for large files or slow connections: until the download completes, any other access to the website from the same session is blocked. For a user viewing a page that contains such a download link, this means that when he clicks on the download link, the download starts as expected, but until the download completes, the user can not navigate to a different page of the site, which is probably not the expected behavior. The solution to avoid this issue is to call session_write_close() before wireSendFile(), like this: $options = array( // boolean: halt program execution after file send 'exit' => true, // boolean|null: whether file should force download (null=let content-type header decide) 'forceDownload' => true, // string: filename you want the download to show on the user's computer, or blank to use existing. 'downloadFilename' => $clientFilename, ); // Close the php session, so wireSendFile doesn't block other connections from the same session while downloading session_write_close(); wireSendFile($serverFilePath, $options); This should not have any unwanted effect as long as the 'exit' option is set to true (because wireSendFile() calls exit() just after readfile() in this case). Note: The issue comes from PHP's session management, where "session data is locked to prevent concurrent writes only one script may operate on a session at any time" (as says PHP session_write_close documentation ). A google search "php readfile session_write_close" brings many exemple of this lock problem.
    1 point
  47. Hi MidRo, Welcome to ProcessWire and the forums. I see your question has not been answered 7 days later! Apologies, we are normally not that slow RE spam, yes, a number of us (including Ryan) recommend using a 'honeypot' field to filter out spam. Read more here: https://processwire.com/talk/topic/960-comment-spam-filtering-alternatives/
    1 point
  48. One way is to well redirect to another page that is only a text page instead after sending email... // if no errors, email the form results if(!$error) { $msg = "Full name: $form[fullname]\n" . "Email: $form[email]\n" . "Comments: $form[comments]"; mail($emailTo, "Contact Form", $message, "From: $form[email]"); $session->redirect("/some/thankyoupage/"); // populate body with success message, or pull it from another PW field // $page->body = "<h2>Thank you, your message has been sent.</h2>"; // $sent = true; }
    1 point
  49. Good question Alan. Here's a screenshot of the module config screen that I think answers your question. See the two settings at the bottom where you can define the max times to link and the distance required between links. AutoLinks is of course also smart enough not to attempt linking things that have already been linked.
    1 point
  50. 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
×
×
  • Create New...