Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/05/2015 in all areas

  1. You'll get a integrity constraint violation everytime you try to save stuff to the database with duplicated keys, e.g. duplicated page id's or other things which should only exist in a single row in the db. It's about the integrity of the database tables and uniqueness of keys, not about security. But your error still comes from a attempt to save something like this, so you should still have a look, what's causing the error.
    6 points
  2. Yes, that's the case, I'm building a filterable portfolio, so I need the categories only as content "selectors/filters". But maybe in the future I could need those category pages and then I would need to create them anyway so it seems a more versatile solution.
    3 points
  3. Just made quite a bit refactoring on these modules and streamlined that it's totally same API usage no matter if you use "single product payment" like Stripe or "shopping cart, multiple products" like PayPal. Also PayPal payment verification is based on invoice id also, so you cannot spoof it with any earlier payment (earlier verification was amount only).
    2 points
  4. With pages you have "category" pages already Otherwise you need to build category views using url segments, get variables or so... Of course if you use categories only for presentation, then options might be faster / easier.
    2 points
  5. Yep, FF has this too under developer tools since the last #n? major versions, but I need to click three times until I get this native tool. The other ones I use since FF before version 2 ! and I need to click only once to open it. Therefore I said / thought "something like that". But you are right @Lostkobrakai, - @pwired: you only need to open the network monitor from FFs developer tools and have a look to the response headers of your ogg-page.
    2 points
  6. @pwired: you need something like Live HTTP headers add on for firefox. It shows you all HTTP headers on a request:
    2 points
  7. @Horst, that's a nice clean one. For Leah's I stripped out most of the fancy things, and ended up with some thing pretty similar to Peter's (final product).
    2 points
  8. Categories are really a perfect use case for pages rather than options. But to answer your question, this should do it: $options = $fieldtypes->get('FieldtypeOptions')->getOptions('categories'); foreach($options as $option) { echo $option->title; } This also works: $field = $fields->get('categories'); $options = $field->type->getOptions($field); If you are going to be using the selections for anything, use the $option->id property, rather than the title, just in case you later go back and change the title or something.
    2 points
  9. Not sure if this solves your needs in another way, but check out this module: https://processwire.com/talk/topic/5658-alpha-release-usergroups-page-based-permissions/ But, you might also be able to achieve what you want through some recent additions to dev which allows for parents for users: http://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users
    2 points
  10. Glad you like it Alan. For some more fun, keep one of those often-updated log files open in your browser, and watch it update automatically to show you the new log entries every time something gets added to it.
    2 points
  11. Just crafted PayPal module also: https://github.com/apeisa/PaymentPaypal
    2 points
  12. Here is very simple abstract class that I hope would get ideas and contribution from community, so that different PW projects could use same payments methods in generic way: https://github.com/apeisa/Payment Currently Payment modules just assume it's found from /site/modules/Payment/Payment.php, but I would love to get it autoloaded somehow (I went with PW module dependencies and transformed the base class into PW module also). Also I have tried to keep this as minimum as possible - hopefully I have not left anything too important out. I have also created one two payment modules, that use this base class: https://github.com/apeisa/PaymentStripe/ https://github.com/apeisa/PaymentPaypal/ Please visit their repos for examples.
    1 point
  13. DownloadGuard for ProcessWire About DownloadGuard This simple module was developed to give clients or users a unique download link to access file downloads you offer them. Installation & Usage 1. Place the module files in /site/modules/DownloadGuard/ 2. In your admin, click Modules > Check for new modules 3. Click "install" for __DownloadGuard__ 4. In the module Settings you can edit the default count for max downloads and the time, the download should be active. 5. During the installation a Page „Downloads“ is created in your PageTree. You can create children under this Page to make Downloads. In the children page you get your unique hash and the ability to upload your file. Todo - Let the system create the download links, for easy copy and paste. BitBucket Repository: https://bitbucket.org/m_knorr/downloadguard/overview Direct Download: https://bitbucket.org/m_knorr/downloadguard/get/master.zip
    1 point
  14. Hello, I'm not sure it's the right place to post this topic. I've just converted a Joomla! 1.5 website to Processwire 2.5.3. I didn't want to do some training for Joomla! for someone for whom I had made it years ago and who hasn't really edited/managed it since then. As I'm going to start some training tomorrow, I wanted to use Processwire. I have used a basic form based on some code found in an old topic of this forum on 1-2 websites already. They use the "Direct Output with Includes" approach. But for this one that I've put online today, I'm using the default intermediate profile as a base. (For another website in development, the multilingual profile is used.) So I've tried to insert the form in several ways in a Contact page, but due to the "Delayed output" approach it's more difficult than with the other approach. So I've finally installed the Hanna Code module that I'm using for the first time. I had to uninstall it once as I had a "Hello World" text appearing on the bottom of each page. I wasn't sure why, but apparently installing the Hanna Code module also installed the Hello World module and made this text appear. So, to come back to the reason I'm posting this, I have a hanna code named "contact_form" (that is inserted in the sidebar textarea editor of a Contact page - not sure for the moment if I'm going to use the basic-page template or the contact (contact.php) one): <?php /** * Example of a simple contact form in ProcessWire * */ // set this to the email address you want to send to (or pull from a PW field) $emailTo = 'whatever@gmail.com'; // or if not set, we'll just email the default superuser if(empty($emailTo)) $emailTo = $users->get($config->superUserPageID)->email; // set and sanitize our form field values $form = array( 'Nom complet ' => $sanitizer->text($input->post->fullname), 'E-mail ' => $sanitizer->email($input->post->email), 'Message ' => $sanitizer->textarea($input->post->comments), ); // initialize runtime vars $sent = false; $error = ''; // check if the form was submitted if($input->post->submit) { // determine if any fields were ommitted or didn't validate foreach($form as $key => $value) { if(empty($value)) $error = "<h3 class='error'>Veuillez vérifier que vous avez complété tous les champs.</h3>"; } // if no errors, email the form results if(!$error) { $subject = "Formulaire de contact"; $message = ''; foreach($form as $key => $value) $message .= "$key: $value\n"; mail($emailTo, $subject, $message, "From: $form[email]"); $sent = true; } } if($sent) { echo "<h3>Merci, votre message a été envoyé.</h3>"; // or pull from a PW field } else { // encode values for placement in markup foreach($form as $key => $value) { $form[$key] = htmlentities($value, ENT_QUOTES, "UTF-8"); } // output the form echo <<< _OUT $error <form action="./" method="post"> <p> <label for="fullname">Vos Prénom et Nom</label><br /> <input type="text" id="fullname" name="fullname" size="46" value="$form[fullname]" /> </p> <p> <label for="email">Votre e-mail</label><br /> <input type="email" name="email" id="email" size="46" value="$form[email]" /> </p> <p> <label for="comments">Message</label><br /> <textarea id="comments" name="comments" rows="5" cols="60">$form[comments]</textarea> </p> <p><input type="submit" name="submit" value="Envoyer" /></p> </form> _OUT; } (I also tried with a small php code with "include" in it and the previous code in a php file. I don't remember if it worked at least the same. Perhaps it was better for security reasons (?).) So, I have several questions/issues . # Is this form still "secure" with Processwire 2.5.3? And enough "secure" inserted from a Hanna code? # In the "Code" tab of the hanna code, I'm having an error message when hovering the cross next to line 38 : mail($emailTo, $subject, $message, "From: $form[email]"); The message is: "syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING". I've tried some things but it hasn't made the cross disappear. # Also, in the "Test Results" tab I have this: Notice: Undefined index: fullname in /home/cyberbodw/www/site/assets/cache/HannaCode/contact_form.php on line 62 Notice: Undefined index: email in /home/cyberbodw/www/site/assets/cache/HannaCode/contact_form.php on line 67 Notice: Undefined index: comments in /home/cyberbodw/www/site/assets/cache/HannaCode/contact_form.php on line 72 # The email message is well received but seems to be received 2 times in an interval of a few seconds. # The sender's email address doesn't appear in the "From" field (but it does appear in the message itself). Something like "(Unknown sender)" is written instead. (Perhaps related to the line of code next to the cross.) If it's not possible to have the sender's email address, is it possible to have something like "Contact form" in the "From" field, and how? (It's what appears in the "Subject" field currently.) # There is this: // set this to the email address you want to send to (or pull from a PW field) $emailTo = 'whatever@gmail.com'; // or if not set, we'll just email the default superuser if(empty($emailTo)) $emailTo = $users->get($config->superUserPageID)->email; How can I pull it from a second user (only view and edit rights for the moment) that is not the superuser? From a PW Field, and how? Is there a "superUserPageID" "equivalent" for the second user? Is "superUserPageID" used directly (it seems) or does it have to be replaced by the real ID? Can we find the second user('s) page ID, and, if yes, how? # Perhaps I'm forgetting one... NB: I know why I don't write often , it takes me too much time. I wonder how much time it takes (in general of course and more or less) for other people for average to large posts. Thank you in advance
    1 point
  15. FrontendUserRegister (dev / maybe unstable!!!) Simple user registration process. Create a new user with checked values if username & email isn't taken by a existing user and not empty a correct password is set Required FormHelper Version 0.0.5+ Download Processwire module page: http://modules.processwire.com/modules/frontend-user-registration/ Bitbucket Repo: https://bitbucket.org/pwFoo/frontenduserregister/ Usage // load module and output the register form echo $fur = $modules->get('FrontendUserRegister')->register("{$redirect_after_register}"); Planned features email activation Module isn't available anymore, but it's planed to replace FrontendUserLogin and FrontendUserRegister with the new FrontendUser module which is not released yet. A new support topic will be created after FrontendUser module is added to the PW module repo. Added new FrontendUser module
    1 point
  16. I'm glad to see that you are making some progress on this.
    1 point
  17. guys thanks for the replies and @horst I didn't know about the live headers plugin for firefox, next time this will allow me to debug. I gave this a try: I simply copied the .ogg file to another server and tried again. Now it's working ! html5 <audio> Player now shows up in firefox and plays the file. So it was definitely a server end problem on the host. I am going to install the live headers plugin and want to see the difference between both servers.
    1 point
  18. @netcarver Today I tried both Iceweasel (aka FF) and Chromium on the new Pi2 and I am not impressed at all - they both performed rather poorly (on Raspbian). PM will follow.
    1 point
  19. I like this one very much: http://pik.peterkroener.de/?_escaped_fragment_=/presentations/Pik/@1#!/core/welcome.html@1 It has a presenter mode too: http://pik.peterkroener.de/presenter.html#!/presentations/Pik/@1
    1 point
  20. I recently gave SASS/SCSS a whirl. You've gotta share some of your toolkit. It would be neat to see how other newbs are tackling their file/folder structures. Of course, you can also invest some time in creating snippets, setting up macros or using toolkits like emmet.io in your code editor. You can build sites pretty quickly that way. Joss mentioned a few of these above — if you haven't already, checkout bourbon, neat, bitters, refills. Those thoughtbot folks make good stuff.-------------------------------------------- I've really been liking Neat. I tried Susy just a few days ago, but found it confusing. Neat has been ... well, neat! I've added some refill elements to my site, now I'm going through little by little, learning some SCSS and customizing the output. I just learned how to minify my css, so that's cool sass --watch styles.scss:styles.min.css --style compressed Then you'll really like SMACSS https://smacss.com/
    1 point
  21. When I open a OGG file in chrome or firefox it plays it in the browser, same happens with MP3 or most video files. If I open a PDF, it is also shown in the browser, same with JPG, PNG, GIF and most surprising of all, it even happens with HTML files!
    1 point
  22. Thank you for this great module. So far ik works very well. One little thing I noticed is that in the modules log file with every page load (site not admin) it writes the line: 2015-02-05 16:21:06 ? ? Saved module 'FieldtypeCroppableImage' config data. The logfile contains more than 12000 lines since I installed the module 5 days ago (2.5.16 dev) If you want more info I'll be happy to help you Alfred
    1 point
  23. @netcarver - thanks, yes, this fixed it!
    1 point
  24. What about using user roles for this scenario instead?
    1 point
  25. You can try this possible fix: Source: https://support.mozilla.org/en-US/questions/1002505 Good luck
    1 point
  26. You should take a look at this. I think it's much nicer: http://lab.hakim.se/reveal-js/
    1 point
  27. Performancewise Chromium just beats Firefox. And it has a kiosk mode, too. From the cli "chromium --kiosk".
    1 point
  28. Thanks a lot for this quick fix I checked out the dev branch, reset my deployment script and everything works fine (and all post authors are happy now ).
    1 point
  29. Adding the page references via the csv module was/is allready possible: https://processwire.com/talk/topic/383-module-import-pages-from-csv-file/page-4#entry21476. And now apparently also via titles, as LostKobrkai points out. But i think you also want to create the tag pages (under a different parent) on the fly with this module. I'm not sure but i don't think this is possible. A solution would be to grab all the unique tags from your csv and import the tags seperately. Ah, MuchDev already said it. After that import the gallery items with the page (tag) references like above link.
    1 point
  30. Stumbled on this-see when your log files were last updated, so smoooth. Thanks Ryan/colleagues for this ever-improving fabulous product.
    1 point
  31. Yeah, this has been brought up before but wasn't really sure how to deal with it. Thanks for reminding me . For now, I have decided to convert and store the line breaks in 'quickpost' to paragraphs (instead of <br>) since I believe that is the intended action by the user when they use a line break in 'quickpost' to space out their text. Besides, that is what CKEditor is going to do when the full post is edited. Using nl2br will result in lots of <br> all of which CKEditor will wrap in one paragraph. But thanks to your idea, I am now using a pre_replace to do the job. It works fine. Committed to dev for now.
    1 point
  32. i think this shoud find its way into the docs - no word about that: https://processwire.com/api/variables/page/ but how? stumbled over this today and once more found the answer quickly in the forum but anyway, i'm sure there are others not knowing about this different behaviour of counting children...
    1 point
  33. @mike1: thanks for finding that. I have removed this line with eval() in @joes code example.
    1 point
  34. The date picker thing was confirmed by Ryan to be a bug, it'll be fixed in the next dev release.
    1 point
  35. @LostKobrakai Ever heard of Aesthetic Usability Effect, Scanning, or Visual Hierarchy? 'Look and feel' is central to usability. They cannot be separated in practice (although people do it in theory all the time). @Joss when you put it like that, I bow to your superior laziness.
    1 point
  36. Web development is moving fast, well more than fast, lightening speed. I think the days of hand coding everything from scratch will soon come to an end if it hasn't partly already. Not that it is not the best way to do things but when dealing with clients it is about time and money unless the client wants to pay for something really unique and doesn't mind waiting. When I first started out I wanted to hand code everything even if it already existed but as soon as building websites turned into something that I made a living from then money divided by time pushed me to find new ways to be efficient and if a tool helps me to do that then great.
    1 point
  37. @everyone wow, there are some great js resources listed here so far. Thanks for the tips. I am off to check them all out as soon as I finish this post. @Sephiroth Full disclosure... I have been hand coding html and css for over a decade (yes, css2 was terrible - moving on...). I know what I'm doing with them. The advice to learn HTML is noted, but not relevant in my case. I know my way around js better than php, but that is not saying much I can make js work, but I can't hand code it. I'm not looking at these tools as a way to get around poor coding knowledge. I'm looking for lazy tools. I love coding, but its not part of my main job, so I don't work on sites regularly (except my PW one, because it turns out I've become obsessed), and I don't remember every little trick I did last time to get everything to work together super smoothly. The main things I like about these kinds of software and frameworks is: 1. They handle browser compatibility & responsiveness issues for me - excellent for lazy coders 2. Default templates on the good ones (Foundation & Blocs) incorporate a bunch of UX recommendations by default, meaning that you have to actively go out of your way to create a website that is hard to use. I value UX standards, but I don't have anywhere near the amount of time I would need to honor them in every hand coded site. Another win for lazy. 3. All the js works together all the time without me thinking about it. 4. Speed of prototyping. Some of the things I hate about them relate to the things I love: 1. Ugly, ugly, div-riddled code. 2. Overkill on the js - all the frameworks include at least one script that I cannot imagine anyone using well. What I like about the Blocs proposal is: 1. Fast prototyping 2. Not ridiculous code - therefore I can easily and painlessly work with it after prototyping 3. Extra hard to make something unusable - this software is made by a guy who is VERY into UX standards. And I like that. He is into them so I don't have to be @Joss, I like your system, but I'm kind of disappointed. From your excellent lazy field suggestions, I was hoping you would have tracked down some really lazy, perfect front end system. It sounds like you have.... but you had to build it yourself! Not my idea of true lazy @renobird I'm with you. I like to peruse the new offerings - sometimes you find a gem.
    1 point
  38. Don't get me wrong, the last time I used any kind of tool like this was the original Dreamweaver in 1997, and I don't use any of the major frameworks. I do like Foundation though. I think it's important to evaluate new tools. Are they worth adding to your toolbox? In the case of an application like Blocs, I could see using it to build something small and quick. A lot of projects don't have the budget to hand code a fully custom design. Tools like Blocs could be a good alternative to using a pre-made template. Of course, you can also invest some time in creating snippets, setting up macros or using toolkits like emmet.io in your code editor. You can build sites pretty quickly that way. Joss mentioned a few of these above — if you haven't already, checkout bourbon, neat, bitters, refills. Those thoughtbot folks make good stuff. I agree with the idea of focusing on something and becoming an expert—but just up a few levels from the topic of tools. Specialize in web design/development. The tools you use to accomplish that are going to constantly evolve. You don't have to trade your tools for the latest shiny new fad, but you should explore things — sometimes they aren't just a fad.
    1 point
  39. I must admit that I have moved away from using fully fledged frameworks and instead have created myself a sass based toolkit. So,,,,, I have a default templates folder I use with the following jammed into it:# scss directory filled with things like Pocketgrid, bourbon, meyer-reset, mq.scss and so on. I have little sub directories in there where I have created some of my own starters like typography, colorscheme, a handful of useful grid bits to go with pocketgrid and some blank files for custom functions. I then gather that lot into a site.scss file. I also have a selection of javascript like respond.js. response.js, enquire and some other bits. Lastly, I have a lot of this included into head and foot scripts. When it comes to developing, I have it all enabled, but then chuck out what I don't end up using. Because it is all individual bits, that is easy to do. So, my started templates folder is pretty well stuffed, but unless I have gone mad, the production version is cut right down. So, that is the way I am going .... for the moment!
    1 point
  40. I think I stoped reading on when it said it's using Bootstrap 3. Nonetheless, I tried the tryout and it's not something I would use for building anything other than your typical Bootstrap layout page without knowing anything. Don't like the UI at all and it crashed after 2 min.
    1 point
  41. Alwaystrynewthingsandgetbetteroralwayadothesameandstaygood.
    1 point
  42. Don't learn the new way of the day. Stick with 1 worthy system, became specialized in it and you can accomplish any website.
    1 point
  43. Hey @Marvin, 1) Please add a Supportboard-Link to this entry in the modules directory. . . 2) Is it right that you do not respect any of the sitewide PW default settings for images? Not those that optionally can be defined especially for ImageManipulator nor those that are defined for the ImageSizer? // from core imageSizer 'autoRotation' 'upscaling' 'cropping' 'quality' 'sharpening' 'defaultGamma' 'useUSM' // for manipulator only 'bgcolor' 'targetFilename' 'outputFormat' . . 3) In the description of Gim you say that the only options that can be specified and set are quality and outputFormat, but Quality seems not to work, I always get the same result in filesize. OutputFormat works partly, means: when I try to create a jpeg and a png from the same image, (what I can do with Pim), it does not create the second file without forcing a recreate! And when I force recreation, it overwrites my first image with the second rendering. This is because it does not reflect the outputFormat in the filename. I use this test code: $image = $page->images->eq(0); $w = intval($image->width / 10 * 2); $h = intval($image->height / 10 * 2); echo "<p>test with defaults<br />"; $gim = $image->gimLoad('gim1')->resize($w, $h)->save(); echo filesize($gim->filename) . ' :: ' . $gim->url . '</p>'; echo "<p>test with outputFormat PNG<br />"; $gim = $image->gimLoad('gim1')->resize($w, $h); $gim = $gim->setOptions(array('outputFormat' => 'png'))->save(); echo filesize($gim->filename) . ' :: ' . $gim->url . '</p>'; echo "<p>test with quality 100<br />"; $gim = $image->gimLoad('gim2')->resize($w, $h); $gim = $gim->setOptions(array('quality' => 100))->save(); echo filesize($gim->filename) . ' :: ' . $gim->url . '</p>'; echo "<p>test with quality 20<br />"; $gim = $image->gimLoad('gim4')->resize($w, $h); $gim = $gim->setOptions(array('quality' => 20))->save(); echo filesize($gim->filename) . ' :: ' . $gim->url . '</p>'; and get this result: test with defaults 21235 :: /site/assets/files/1/pim_gim1_basename_02.jpg test with outputFormat PNG (and not forcing recreation) 21235 :: /site/assets/files/1/pim_gim1_basename_02.jpg or test with outputFormat PNG forcing recreation (look filesize!!) 178060 :: /site/assets/files/1/pim_gim1_basename_02.jpg test with quality 100 21235 :: /site/assets/files/1/pim_gim2_basename_02.jpg test with quality 20 21235 :: /site/assets/files/1/pim_gim4_basename_02.jpg . Also there is no validation done. Not for supported filetypes nor typos, and also not for a valid range for quality. . . 4) Why do you not keep IPTC, what is (sort of) mandatory within PW? At least you should print a big warning at the very top of the announcement for those that rely on this. (because AFAIK it is supported by every other image related part in PW since Version 2.3, or do I miss something?) . . 5) Same with the big warning should be done in regard of sharpening! The lib you implemented does not support any sharpening method! As a sidenote, one of the most timeconsuming image manipulations with GD / PHP is sharpening! . . 6) Also the lib does not support transparency in GIF, it renders them with black background. Detecting the need for AutoRotation is not supported too. . . 7) Ah, - regarding my post about the Imagick adapter I have seen there, this looks a bit like a stillbirth. (https://github.com/Gregwar/Image/pull/65) . . . When first reading your announcement here I was very happy because I have started a few times to rewrite the Pim to make it faster and more robust, but couldn't finish it, (lots of work to do). But now for me it sounds a bit more like a marketing strategy than a real chance for me to get my hands on a better Pim implementation in PW. . . . Besides the above mentioned, here is a list of not supported methods in Gim: getOptions (very limited) setOptions (very limited) getImageInfo (returns nothing) getPimVariations removePimVariations sharpen unsharpMask stepResize watermarkLogo watermarkLogoTiled watermarkText canvas blur pixelate getMemoryImage setMemoryImage . The supported methods are: brightness colorize contrast edgedetect emboss flip grayscale negate rotate sepia smooth . New methods, that are in Gim, but not in Pim: mergePageImage (can be used for watermarking) merge (can be used for watermarking) write (can be used for watermarking) overlayImageStretched (can be used for watermarking) // drawing functions circle ellipse line rectangle roundedRectangle . And those are methods from Gim that could be used to emulate our PW crop and upscaling settings: crop zoomCrop cropResize forceResize scaleResize
    1 point
  44. It's expected behaviour of the Pageimages (array) You're trying to set a pixel size to an array of images. Pageimages (array of images) doesn't have a size, because it is an array. You need to go 1 step deeper, get the image, then set the size to an individual image. If you run the code below, what does it say ? if ($page->header_image instanceof Pageimage) { echo "(Pageimage) - Single image, yeah, you can use size.<br>"; } elseif ($page->header_image instanceof Pageimages) { echo "(Pageimages) - Array of images, can't use size.<br>"; }
    1 point
  45. Okay, so we all like to think we are super organised when it comes to planning our ProcessWire site, but sometimes life is not like - we are uselessly lazy and can't even make our coffee in the right order (is is add the whisky first or second?). So, here are a couple of really lazy ideas to make everyone feel better about messing up. First Lazy idea Oh, I forgot to create a field! (or two, or three....) On the template edit page where you add the fields, how about a Create New Field button that allows you to create a field and add it to that template. Probably opens a modal window to create the field. Second Lazy Idea OH, why didn't I create the field BEFORE I created all these templates? No Problemo! On the field Info tab where you can see which templates use the field, what about having another box that lists all the templates that do NOT use the field and are displayed in columns with little check boxes next to them - tick the boxes and save to add the field to those templates. Third Lazy idea Adding a group of fields to a group of templates. I have actually just changed this from what I was going to suggest because my original idea was not lazy enough - far too much work for the user. So, you get a new button at the bottom of your list of fields and a check box next to each field. Hit the check box and the button gives you the option to Add fields to Template. A modal opens where you can change the order of the fields and select which templates you want to add them to. In addition, you get the option to add them within a tab set or field set and give that a name. Click Add and all those fields are added to the templates in the order you have set them. (Note, if any of the fields have already been added to any of the templates, then it either does not add those fields and tells you which were not added to which templates, or it fails completely and tells you which were not and so on.) Fourth Lazy Idea Lazy blokes template creation with fields. So, you suddenly realise you need 20 more templates with 18 existing fields each but you haven't got a handy dummy template with the right fields in. Don't panic. On the new template screen, simply select the fields you want, complete with tabs, field sets, and the right order, then choose the templates you want to create as normal and done! Wow, that was lazy! Fifth Lazy Idea I can't remember what I am doing where, why and when! So, this is a new screen under set up called something like Field Matrix. Basically it is a large, scrollable chart that has fields down the Left and templates across the top. From this chart you can now see which fields are being used on which templates shown by ticks and crosses. PLUS! You can actually add and remove fields from templates by clicking on their tick or cross to change it. THIS IS REALLY DANGEROUS (and probably a bad idea) but it is also wonderfully lazy! Doesn't all that laziness feel good? So there you go: Five lazy ideas to help tired, overworked, and disorganised web people get through their day, Joss (I know, far too many changes in one go - but I enjoyed thinking about them!)
    1 point
  46. What Ryan and Antti are saying here definitely makes sense (and they're the ones to know the module best anyway) but this was exactly what we were wondering too when that first Lister screencast hit our office. For 90% or more of all product, news, event etc. lists and/or tables Lister views would be more than enough. No custom, site-specific code and even being able to allow customer decide exactly what is visible and where.. and then modify that whenever needed -- how damn cool would that be? In case you ever decide to take Lister to that direction, it'd be a killer feature for a lot of sites (and an awesome time-saver for people building those sites), but I totally understand that this was never your intention and it would probably require a ton of extra work. Perhaps even so much that building another tool just for that would make more sense. Still, +1 for this idea from me/us
    1 point
  47. Greetings Manaus, As luck would have it, I just completed a project where the client needed to have a form on the front end where he can upload a CSV file and have it create pages. Using ProcessWire, I put together a system that does the following: 1. Presents the visitor with a simple form with a "title" and an "upload" field 2. Creates a parent page with the title = "title" 3. Uploads and saves the CSV file to the parent page 4. Opens the CSV file using PHP's native fopen 5. Reads the rows of the opened CSV file using PHP's native fgetcsv function; a simple counter skips the first row (which is assumed to be a header row) 6. Creates children of the "title" page, each with the name of the data in first column of each row 7. Presents a "success" message when it works. Your needs might be different, so just vary the code as needed, or post a follow-up question for more details. Here's the code (with my documentation added): <div class="chart_form_box"> <?php if ($input->post->title) // Confirm that a proper submission happened: if the form submission at least has a title, use the field entries to create a new parent page. { // Set a temporary upload location where the submitted "csv_import" file is stored during form processing (will be removed at the end of the process). $upload_path = $config->paths->assets . "files/csv_uploads/"; // This folder must exist in the directory structure. // New wire upload routine for the CSV file. $csv_upload = new WireUpload('csv_upload'); // Reference field name in HTML form that uploads the CSV file. $csv_upload->setMaxFiles(1); // Allow only 1 CSV file upload. $csv_upload->setOverwrite(false); // Rename any current files, instead of overwriting them. $csv_upload->setDestinationPath($upload_path); // Use the temporary location set above to place the CSV upload. $csv_upload->setValidExtensions(array('csv')); // Only allow CSV files. $csv_uploads = $csv_upload->execute(); // Execute CSV file upload. // First round of page creation (for the parent page, created from a title and a CSV file upload). // Set up submissions in the ProcessWire page tree. $np = new Page(); // create new page object. $np->template = $templates->get("windsor_parent"); // Set template for pages created from form submissions. $np->parent = $pages->get("/windsor-list/"); // Set parent for pages created from form submissions. $np->of(false); // Sanitize form submissions and store the submissions as values in the template fields for the new parent page. $np->title = $sanitizer->text($input->post->title); $np->name = $sanitizer->pageName($input->post->title, true); // Create a URL-friendly "name" based on the title. // Save/create the new parent page. $np->save(); // Run the file upload for "csv_upload." foreach($csv_uploads as $csv_upload) // Loop through the CSV uploads, even if there is just one. { $pathname = $upload_path . $csv_upload; // Store the temporary CSV file in the path dedicated to that purpose. $np->csv_upload->add($pathname); // Store the uploaded CSV file in the "csv_upload" field of the template. $np->message("Added file: $csv_upload"); // Include a message regarding the file that was uploaded. unlink($pathname); // Remove the file from the temporary folder since it is no longer needed after it is uploaded. } $np->save(); // Save page again after CSV file upload // Beginning of routine to save children of the page saved above: derived from the rows in the CSV file. if (($objCSV = fopen("http://www.pwplayground.com/site/assets/files/$np->id/$np->csv_upload", "r")) !== FALSE) // Open the uploaded CSV file that was saved above. { ?> <!-- Create a list of the rows in the CSV file --> <?php // Loop through the rows in the CSV file using PHP's fgetcsv function, with the goal of placing the data in each row of the CSV file into fields in our "windsor_child" template. $i = 0; // Set up a counter variable. This is used to keep track of iterations that will correspond to rows parsed in the CSV file. We will use this later to skip the first row, which is a header row. while (($objArr = fgetcsv($objCSV)) !== FALSE) // Instruct fgetcsv to add to the $objarr as long as there is a row to read. { if( $i >= 1 ) // Only run the process beginning with the 2nd row, thereby skipping the header row. { // Beginning of routine to save child pages based on the rows in the uploaded CSV file. $np2 = new Page(); // create new page object $np2->template = $templates->get("windsor_child"); // Set template for child pages. $np2->parent = $pages->get("/windsor-list/$np->name/"); // Set parent for child pages to be the page created above. $np2->of(false); // Set output formatting off during the page-creation process. // Sanitize the rows of the CSV files, just in case someone uploads something evil, then store the values in each row into the template fields for the new page. $np2->title = $sanitizer->text($objArr[1]); $np2->name = $sanitizer->pageName($np2->title, true); // Create a URL-friendly "name" based on the title. $np2->windsor_count = $sanitizer->text($objArr[0]); // Store the first column of each row in the "windsor_count" field of the template. $np2->windsor_name = $sanitizer->text($objArr[1]); // Store the second column of each row in the "windsor_name" field of the template. // Save/create the new child page. $np2->save(); // End of routine to save child pages based on the rows in the uploaded CSV file. } $i++; // Move the counter variable up one tick with each iteration. } ?> <?php } fclose($objCSV); // End of routine to save children of the page saved above. These are derived from the rows in the CSV file. ?> <!-- If uploading the CSV file, and creating the new parent chart page and children pages were all successful, then: (1) Confirming success; (2) Present option to jump to the newly created page; (3) Present option to create another new page. --> <div class="admin_success_box"> <p>SUCCESSFULLY CREATED A NEW CHART PAGE CALLED "<?php echo $np->title ?>"</p> <p><a href="<?php echo $np->url?>">VIEW THE NEW CHART PAGE </a>-- or --<a href="<?php echo $page->url ?>"> CREATE ANOTHER CHART PAGE</a></p> </div> <?php } // / if ($input->post->title) ?> <!-- Actual entry form that allows the user to set a title and upload a CSV file --> <h1>Use the Form Below to Create a New Parent and Children from a CSV</h1> <form action="<?php echo $page->url ?>" method="post" enctype="multipart/form-data"> <p><label class="create_chart_field_label" for="title">Title</label> <input type="text" class="create_chart_long1" name="title" value="<?php echo $input->post->title ?>"></p> <p>Upload 1 CSV File: <input type="file" class="create_chart_field1" name="csv_upload" /></p> <button class="admin_submit" type="submit" name="submit">CREATE CHART!</button> </form> </div> <!-- / chart_form_box --> My apologies for the formatting. (Also, the "chart" references are specific to my particular project.) As you can see, much of this involves using ProcessWire's API to create pages, but with a few extra steps for the CSV material. Thanks, Matthew
    1 point
  48. @bcartier: The ImportPagesCSV-module can't do this as is. But I tried making a tiny addition to make it support FieldtypePage (those used to make page references) and it worked amazingly well. The only change needed was to add 'FieldtypePage' to $fieldtypes array (just before init() function if you take a look at the module file), like this: protected $fieldtypes = array( 'FieldtypePageTitle', 'FieldtypeText', 'FieldtypeTextarea', 'FieldtypeInteger', 'FieldtypeFloat', 'FieldtypeEmail', 'FieldtypeURL', 'FieldtypeCheckbox', 'FieldtypeFile', 'FieldtypePage', // add this line ); After that addition it's possible to choose a Page field when connecting the fields from the CSV to the ones in the chosen template. I had pre-populated categories at the target site and used their id's in the CSV file to reference those categories. Multiple categories worked like a charm as well, just use a pipe in between id's (123|456|789). Moreover, if you've got only one category per entry to reference, then you don't even need the id's of the categories - you can use paths as well. Here's a little example: cat.csv: title one two three four entries.csv: title,categories a,/cats/four/ b,/cats/three/ c,/cats/one/ d,/cats/two/ Import cat.csv using a template for categories with (at least) title field, under a page at /cats/. Then import entries.csv using a template for entries, having a title field and a page field. This should leave you with entries that are connected to categories. I hope this gets you somewhere. @ryan: Looks like page references could be supported very easily. I just used this successfully to import ~3500 pages with category references from an old site to a new PW one. But maybe there's still something else to be done before they're fully supported?
    1 point
  49. Jasper, I didn't want to leave you empty handed, especially after you've tried this a few times and my suggestions didn't work. Here's an updated version of the ImportPagesCSV module that supports file and image filed importing. It supports both single and multi-file fields, so there aren't any limitations in that area. https://github.com/ryancramerdesign/ImportPagesCSV To import a multi-file field, place each filename or URL on it's own line in your spreadsheet, OR separate each by a pipe "|", OR separate each by a tab (you decide) – basically, you are delimiting the filenames/URLs within the field. In my own tests, I used the pipe "|" to separate the URLs and all seemed to work well. Of course, if there is only one image/file, you don't need anything other than the filename or URL (no delimiter necessary). I ended up changing quite a bit of code, so please let me know if you run into any error messages or anything – it may not be perfect yet, but hopefully close.
    1 point
×
×
  • Create New...