Jump to content

darrenc

Members
  • Posts

    48
  • Joined

  • Last visited

Everything posted by darrenc

  1. Ahhhhhh! Very clever/simple/elegant. You just gave me thousands of ideas for implementing sym/hard links. Thanks again, netcarver.
  2. I have one more question, and I am curious to hear how people handle it in their own development environments: github - my forked processwire local - processwire "working directory" local - processwire running, installed on my local dev/testing webserver #2 is where the git magic happens; branching, making commits, and then pushing to #1 and eventually making a pull request. My question is about how #2 and #3 work on your own environments. In order to get processwire up and running, #2 has to install and change files (/site/, .htaccess). Now in #3 state, this is where I would actually be making code changes and testing to see if I break something. Then I would have to copy my changes back to #2 in order to do the git business? This seems very inefficient obviously, but I don't know if there's another way to make #2 and #3 be the same directory?
  3. adrian, extremely helpful and that completely makes sense. I'll brush up a bit more on git and then go from there. Thank you for following up.
  4. I had an idea for a very minor/modest enhancement that I'd like to make to the repeater module. I've never contributed or really used GIT and I don't know how it all works with regards to how people can submit things to the processwire project in order for them to be included: Is it welcomed? Is there a specific procedure that I should follow? I don't presume to be the best developer so if my code isn't particularly good am I just wasting time and hindering rather than helping? etc. I think maybe that's enough said for you to understand where I'm coming from. Please let me know how you think an amateur like me should proceed. Thank you kindly.
  5. Yeah I was thinking Ipa's suggestion could be handled at the field configuration level when revealing the "pass" field which comes by default. I guess that's probably what you're saying craig but one level lower?
  6. That's a good question adrian and something I had considered as a solution. -vs- The first one with nested repeaters logically makes more sense to me, and requires less inputting of the duplicate data for the user (date range in this, simplified, example). Is there an advantage, or necessity, of flattening out the data like you suggest? I'm trying to determine where a structure like this could go horribly wrong.
  7. Joss this is exactly where I decided that a repeater needed to exist because "daily, weekly, monthly" aren't the only possibilities. The most flexibility for the system would allow the owners to define periods as they see fit, so maybe someone new to the system might want a "weekend" rate, another a "holiday" rate, or even create some kind of "company employee nightly" rate. The potential for different rate types could go from the 3 standard into tens (but probably not hundreds) of rate types. In that case "rate_type" makes the most sense as a page reference rather than making more and more rate fields manually. Because of that I thought that the only way to handle allowing someone to dynamically choose (or create) their own rate type, I needed that second-level repeater. Granted there maybe could be a better way to approach this while allowing the same flexibility for the end-user. But maybe not?
  8. Question #2 is answered: i had my page field set up wrong and it was returning a page array instead of a page. If anyone wants to discuss an alternate data structure to solve question #1 I would still be interested in hearing it. Thank you.
  9. I apologize in advance for the long post, but it is an easy read. I'm dealing with a situation where I can't think of how to do this, practically, without using repeaters within repeaters. I'll try to be very clear but keep the example simple: a "vacation home rental" site. Let's say you're a user looking for somewhere to vacation in 2015, you go to the website and click the main menu item "All Homes (page)" and are met with a list of all the homes you can potentially rent. You pick any one of them and get to the page (child page of homes) where it displays for you the basic details - description, body, maximum occupancy, pets allowed, etc... all plain fields on the "home" template object. Now, each home can be rented for different rates at different times of the year. Maybe it is at a popular summer spot so the rates are more expensive during the summer, or very popular in winter due to it's proximity to a ski mountain. You probably make a repeater called "rental_period" with start/end date fields on it among other things. However inside each of those rental_periods exists options for prices on a daily, weekly, scale. eg: /all-homes/malibu-darrens-beach-house/rental_period #1 - Summerrate_option #1 - Daily: $200 rate_option #2 - Weekly: $600 rental_period #2 - Winterrate_option #1 - Daily: $50 rate_option #2 - Weekly: $200 rate_option #3 - Monthly: $600 As a hypothetical owner I've decided that my beach house is so popular that I can maximize my income by not offering a monthly rate during the summer. In winter in order to entice longer stays I steeply discount a rate. Obviously this would vary home by home. Question #1 -- How would you set this up differently if not using repeaters inside repeaters? To me this only makes sense as a rental_period repeater with a rate_option repeater inside it. Neither of them is ever going to get particularly long - but maybe one house only has one rental_period, yet another has 5. Furthermore maybe one rental_period has a couple of rate_options, but another rental_period on a different property has several (weekday, weekend, holiday, three night minimum, weekly, etc). This type of setup seems unwieldy if considering setting these up as child and grandchild pages of each home, and I am not sophisticated enough to think of another way. Question #2 -- Referencing page fields inside the repeater broke down. What am I doing wrong? Given my example, lets say the price is a simple integer field "rate" but the daily|weekly|monthly is a select box page reference field named "time_period". I wasn't able to access properties of the time_period page as I expected to. In simplified code... // example home.php which outputs property and rate details // output the basic page-level stuff echo $page->get("headline|title"); echo $page->location; echo $page->description; echo $page->occupancy; // etc... // output rental periods repeater // only ignoring count() testing for purposes of simple example foreach ($page->rental_periods as period){ echo $period->name; echo $period->start_date; echo $period->end_date; // loop my repeater inside my repeater foreach ($period->rate_options as $option){ // page reference, did not echo the time_period title as expected! echo $option->time_period->title; echo $option->rate; } } In the code above, which I thought would be fairly straight forward, my "$option->time_period->title" echoed nothing instead of the title of the page. If you've stick with me this far I want to thank you for entertaining my rambling. I am curious how you all would approach something like this, perhaps get some tips as to why this approach could have drawbacks, as well as maybe get some insight into why my output failed.
  10. Please consider this a formal request and/or a question about why we are not allowed to use spaces in passwords in the admin. Doesn't adding a few spaces to a password or passphrase significantly increases its security? Even the horrible example "This is my password." is much more secure than most passwords people pick for themselves (Possible Combinations: 10,596,610,576,391,421,000,000,000,000,000,000,000), more secure than the same characters sans-spaces, and likely easier and more natural to type. Personally, I'd rather have a length requirement than be forced to use a digit and no spaces. Everyone has their own methods I suppose, so I was wondering if someone could shed some light on this?
  11. Exactly as you said it, thanks adrian. The fault was entirely my own -- when I couldn't get the relative path working I jumped to the conclusion that the spaces in the filename were causing issues. That, of course, was a dead end. final working code for anyone interested: // do a bunch more stuff $p->save(); echo "saved id:{$p->id} {$p->url}\n"; // add images, y u no store? // Answer: using relative path was wrong (and rawurlencode is unnecessary) // $p->images->add( "./images/" . rawurlencode($row["image"]) ); // get the full server path to processwire, and from there the images $path = $config->paths->root . "test/images/" . $row["image"]; $p->images->add( $path ); $p->save(); Thanks again, Adrian.
  12. adrian, I'm pretty sure I tried all combinations of the plain string first, but I could be mistaken. I'll be going back through this today and, this time, systematically keeping track of the attempts which failed. At risk of asking stupid questions, which path is "the full path" ? The web hosting account file path? the public_html root relative path? the sub.domain.com root-relative path? $config->urls->root? $config->paths->root? is this an issue with bootstrapping that I have to treat differently? It's all relative one way or another unless i'm stating http://dev.domain.com/test/images/ correct? Those were all the questions swirling in my mind yesterday. I'm sure I'm doing something simple/obvious wrong, I just couldn't figure out which. Hopefully with fresh eyes I'll figure it out today.
  13. site setup: /public_html - regular site files, unrelated to pw/dev - processwire lives here (subdomain pointed dev.domain.com)/test - where my bootstrapped script runs/images - images to be imported code in /test: // processwire bootstrap include '../index.php'; $pages = wire("pages"); $sanitizer = new Sanitizer(); foreach ($csv as $row) { // test if the page exists $name = $sanitizer->pageName( $row["title"], true ); $p = $pages->get("name={$name}"); if (!$p->id) { // if not, create one $p = new Page(); } $p->template = "sampler"; $p->parent = $pages->get("/samplers/"); $p->name = $name; $p->title = $sanitizer->text( $row["title"] ); // do a bunch more stuff $p->save(); echo "saved id:{$p->id} {$p->url}\n"; // add images, y u no store? $p->images->add( "./images/" . rawurlencode($row["image"]) ); } error: Error: Uncaught exception 'WireException' with message 'Unable to copy: ./images/Best%20MCC%20Pic-2.jpg => /home/samplers/public_html/dev/site/assets/files/1027/best_20mcc_20pic-2.jpg' in /home/samplers/public_html/dev/wire/core/Pagefile.php:109 Stack trace: #0 /home/samplers/public_html/dev/wire/core/Wire.php(271): Pagefile->___install('./images/Best%2...') #1 /home/samplers/public_html/dev/wire/core/Wire.php(229): Wire->runHooks(Array, Array) #2 /home/samplers/public_html/dev/wire/core/Pagefile.php(74): Wire->__call('install', Array) #3 /home/samplers/public_html/dev/wire/core/Pagefile.php(74): Pageimage->install('install', Array) #4 /home/samplers/public_html/dev/wire/core/Pagefile.php(50): Pagefile->setFilename('./images/Best%2...') #5 /home/samplers/public_html/dev/wire/core/Pageimage.php(68): Pagefile->__construct('./images/Best%2...') #6 /home/samplers/public_html/dev/wire/core/Pageimages.php(38): Pageimage->__construct(Object(Pageimages), './images/Best%2...') #7 /home/samplers/public_html/dev/test/index.php (line 109 of /home/samplers/public_html/dev/wire/core/Pagefile.php) This error message was shown because you are logged in as a Superuser. Error has been logged. Probably relevant: $row["image"] spits out a regular "Image name here 9000.jpg" string. It's the end of the day and I'm a bit bleary-eyed, but I feel as though I've tried every path/url combination and sanitization of the image name string. I haven't figured whether it is just me doing something wrong (likely) or some server configuration. Can anyone tip me off as to what's going wrong?
  14. Ryan/Pete thanks for following up. Seeing the hook solution is interesting. When looking into the issue I also ran across the room34.com solution. In the end I think it was better served by making a module due to the nice benefits it affords in the admin: mainly, being able to apply it on a field-by-field basis as desired.
  15. class TextformatterNBSPstripper extends Textformatter { public static function getModuleInfo() { return array( 'title' => 'Unicode nbsp Stripper', 'version' => 100, 'summary' => "Replaces the Unicode non-breaking space character with a regular space. This prevents browser rendering of multiple consecutive spaces within text content.", ); } public function format(&$str) { if( !preg_match('/\x{00A0}/u', $str) ) return; $str = trim( preg_replace('/\x{00A0}/u', " ", $str) ); } } The above is the module I made. Obviously very basic but this is all new to me so hopefully I did it right. Happy to hear any pointers. I think I'll give it some testing and then submit a module addition on the off chance anyone else wants something similar.
  16. Okay, after checking the database it seems that the spaces get stored as u+0020 (a normal space) and u+00A0 (a non-breaking space character), as a repeating sequence as necessary depending on the number of spaces pressed. Here is sublime text revealing the nbsp character http://i.imgur.com/76S7cwT.png tiagoroldao, your code definitely didn't work (and in very interesting ways that i don't yet understand). However, after some looking at wire/modules/textformatter, I do understand where you were coming from. Clearly these modules are what I'm looking for as a base for my own. I'll try to figure something out based on what I know now. Joe, that's not a bad idea either actually and I hadn't thought of that. Thank you for the suggestion. Still working on it...
  17. I don't want to keep double spaces. When writing content, people tend to put two spaces after a period. Something makes the assumption that they indeed want to keep the double (or more) spaces and thus converts them ones into a in order to maintain that spacing. and when that happens it affects how the text wraps http://i.imgur.com/yWC91eH.png (lines 4&6). instead of a plain space that would normally be ignored, the browser forces the and indents the line. I wouldn't say that I am losing sleep over the issue, but it would be nice if I had some control over this at the field-level in order to prevent this kind of potential whitespace mangling (maybe a client puts 5 spaces after every period, cringe). I'll try your code out tomorrow morning to see if it works. I checked the database and the entities are not being stored as . Perhaps they are being stored as a separate type of whitespace character that gets converted later? Either way i'll be sure to report back. Thanks!
  18. Hi I don't exactly know how to approach this issue. I don't love how tinymce seems to input a space and an when a user types two consecutive spaces into the editor of, for example, the body field (textarea). I'm not exactly sure where the translation from two spaces to " " happens, but since I've noticed that wordpress does a similar thing I assume it is tinyMCE that is the culprit. Doing some googling for tinyMCE and this issue is somewhat of a mess. I was wondering if perhaps it would be better solved in a processwire module, filter, hook, or something else. Ultimately the goal would be to simply keep them as actual plain spaces, or to remove the double spaces after periods and before additional text. I'd appreciate some thoughts on the matter. I should probably do a bit of due dilligance myself and see whether it gets stored in the db or whether the transition happens when processwire outputs the data.
  19. Jacknails, we approached the issue more from a end-user UI perspective and decided they should jump through as few hoops as possible. The most accurate description might be that it's a contact form with an attached wishlist. Secondly, while I am definitely open to looking at, and trying to strip-down, a cart module I think it would be better for us (totally new to PW) to learn a bit more by building this feature up exactly how we want it to behave. Dragan, yes requiring user signup was also a consideration and, for now, it is not a requirement. And yes we could set a cookie, and that was something that occurred to me once I read the pseudocode. Thank you both for following up.
  20. Wanze, soooooo helpful thank you. I have lots of work to do to explore the API and "get" the pseudo code to the fullest, but this conceptualization was great. I think that was a stiff push in the right direction. Thank you again for taking the time to reply.
  21. Still pretty new to all of this, I am looking to build a website with a catalog component showing products in various categories with various options. I assume most of these, if not all, will be set up as pages (allowing maximum flexibility?). The structure isn't concrete yet but that is the loose plan for now. The client has since requested a scope change that any user looking at the site could... add a browsed item to some kind of wish-list functionality "build a quote" that they could... review what they selected on one page (potentially removing or changing quantities i assume) and then... submit this wishlist/quote request, along with some basic contact information, back to the client so that they could follow up further. It isn't an industry where one would ever provide a cart, with prices, and allow someone to buy an item -- so a formal cart seems somewhat overkill. Because of my unfamiliarity I was wondering if someone could help provide some insight as to how something like this could be accomplished with processwire off the shelf, or with a basic module, or perhaps it would need a completely custom module to be built. At the very least it would help me respond to the client with options. Ideally I would like to build with processwire. Thanks for any thoughts.
  22. boundaryfunctions, I've gone through it much of it and feel like I am somewhere in between understanding the basic site and understanding one of the more complex builds (skyscraper, or blog). I realize that with time I can probably piece all of this stuff together to develop my own understanding. However, I just feel like when you can get into the mind of an expert in a system (author of xyz book) then you get the best vision of walking down that path. It's like the difference between exploring a New York City on your own, asking people on the street where a good place to eat is -vs- getting a guidebook or spending the day with a local take you to spots and give you inside tips or ideas. One can just get up to speed faster the second way and not feel so overwhelmed. Appreciate the response, and I'll certainly dig deeper.
  23. I am definitely a book learner. The structured approach of a book, explaining basic concepts and building on them, makes it much easier to understand and conceptualize a system and the potential it has. Do you have any plans to release a book that would become the defacto comprehensive way to learn ProcessWire?
×
×
  • Create New...