Jump to content

darrenc

Members
  • Posts

    48
  • Joined

  • Last visited

Everything posted by darrenc

  1. Okay fair enough I haven't tested this yet either but lets say it works... i would presumably get the same reference doing it the longer way: foreach ($image->getVariations() as $variation) { if ($variation->width == 201) $image->removeVariations($variation); // nope if i have $variation as the reference to the exact same file, how do i remove it from the variations-stack for the image?
  2. Is there a way to delete a specific variation of an image without simply nuking every single variation? I've been working with processwire for a while and I'm surprised this isn't possible given the things you can do with different arrays of PW objects. Here's what I've tried: $image->size(200, 200); $image->size(201, 201); $image->size(202, 202); $image->size(203, 203); $image->removeVariations("width=201"); // nope $image->getVariations()->find("width=201"); // nope $image->getVariations()->get("width=201"); // nope foreach ($image->getVariations() as $variation) { if ($variation->width == 201) $image->removeVariations($variation); // nope if ($variation->width == 201) $variations->delete($variation); // nope if ($variation->width == 201) $image->delete($variation); // nope if ($variation->width == 201) $variations->remove($variation); // nope if ($variation->width == 201) $image->remove($variation); // nope }
  3. I understand the desire to cut down on the core size especially when the profiles are just implementations of the same thing to help beginners. However I think both beginners and pros could benefit from having the installer simply accept a zip file of the profile they want to install, and rather than providing instructions on what one has to do to get the profile unzipped and named in order to install correctly... simply let the installer handle it. Reduce that screen to two options: Start with a blank profile Upload an existing profile Perhaps two buttons, and the upload your own button reveals some more instructions: a link to the starter examples (which provide zip downloads), and an explanation about how it accepts exported profiles, and a file input. Providing the file and clicking next should be enough to have the installer unzip and ready the profile for installation - thus simplifying this screen and making it less intimidating for beginners, easier for people who have a starter theme downloaded in zip, and faster for people who use their own. Possible?
  4. To echo what @cstevensjr @dragan are experiencing, I get the same issue when trying to install the module via classname. I opened a github issue about it. However, I was able to install successfully by using the zip file link and providing the github repo master.zip url https://github.com/blynx/MarkupProcesswirePhotoswipe/archive/master.zip Hope this works for you guys too. Thanks @blynx!
  5. ahhhhhhhhhhhhhhhhhhhhh great! thank you kindly @adrian
  6. lets say, in _main.php I have some placeholder regions for content/sidebar <div id="content">foo</div> <div id="sidebar">bar</div> in my home.php template, maybe i don't want the sidebar div at all. But when I put in the intentionally blank code <region id="sidebar"></region> I simply make my sidebar div blank, it doesn't remove it. Q: Is there a slick way to simply nuke that div#sidebar entirely from markup?
  7. In my map I want to turn the clustering off. What's the simplest way?
  8. I'm trying to understand how I could have users log in as "members", provide them with a customized experience, but still serve them cached pages? For example let's say I have 3 roles Guest Member SuperUser And let's say I have a NavBar type component that has a menu. Plus it has "log in!" if guest, or "logged in as Mike Smith" I would want guests to see a cached site with guest-only page access. Members should also see cached pages, but their menu may have access to members-only pages or fields or information. Furthermore they might have a "logged in as Mike Smith" element. SuperUsers can stay uncached. How does one go about creating that cache so that visitors aren't constantly re-creating the menu? Or that when "Sally Baker" logs in, she doesn't see a homepage that is cached for "Mike Smith" with all his elements? Thank you in advance for any replies.
  9. frequently i do something like the following expanded simple version.... foreach ($foos as $foo) { // always a title & link $title = " <h1 class='foo__title'> <a href='{$foo->url}'> {$foo->title} </a> </h1> "; // sometimes a headline $headline = NULL; if ($page->headline){ $headline = " <h2 class='page__headline'> {$page->headline} </h2> "; } echo " <div class='foo'> $title $headline </div> "; } the short take away is that i... know certain fields will exist, and i want to wrap them in specific tags/classes have fields that might exist, and i want to wrap them in specific tags/classes or output nothing silently want to wrap all of the output Probably due to inexperience, I haven't found a slick way to simplify this pattern for myself. Using a function and arguments seems very messy to me because it can get complicated to maintain as pieces need to change. maybe I just write crappy functions. Do you guys have a very maintainable way to output a fields value, always wrapped in specific tag/class, but only if it exists?
  10. @abdus that's an approach i'm not at all familiar with, thanks very much i'll experiment with it. @fbg13 interesting, I wonder why that is done.
  11. <?php namespace ProcessWire; class Foo {}; $foo = new Foo; $foo->message = "hello world"; function print_foo() { global $foo; print_r($foo); } print_r($foo); // success print_foo(); // nothing ?> In any template file, or init, the above code doesn't pull $foo into the function's local scope. It seems to not exist even though I'd fully expect it to be there. Does anyone have insight into why this happens or how I should be approaching it?
  12. OHHHHHHHHHHHhhhhhhhhhhhhhhhhhh. God, I feel dumb but honestly I was totally perplexed by that. Thank you so much LMD. I will try it out and see.
  13. What I did edit the default 'body' field (textarea, ckeditor) field > body > input: "enable ACF" checked "yes" by default field > body > input: "extra allowed content" ... The instructions indicate "Example: img[alt,!src,width,height]" in order to enable a tag with attributes you want to allow through the filtering. a[class] I wrote the above expecting that now i would be able to class my a tags in the editor, maybe make one a "button" style or whatever. However, this doesn't actually work as it seems Extra Allowed Content doesn't actually do what it indicates. I've tried a dozen different variations and after googling here and seeing some responses in other threads, I think this should be addressed. The box is a nice way to enable a few attributes the user might want to allow for clients or themselves, I don't see why one would require making a module or going above and beyond the tools and text areas already provided in order to simply allow a few attributes. I could turn ACF Off entirely, but that doesn't really address the problem: I want to filter the input for clients but still configure some tweaks that I deem would enhance and not break the site. Simply: it's there, it's nice to have, should work right, but it doesn't seem to. Help?
  14. Is it possible to make a page field, that outputs options based on what a user has selected in a previous page field? Template data setup house (template) title (text) body (textarea) neighborhood (page field) neighborhood (template) title (text) Obviously it's set up with lots of neighborhood pages, and if you create a house you get a dropdown of those neighborhoods which you can select. What I want to do featured_neighborhood (template) title (text) body (textarea) neighborhood (page field) homes_in_neighborhood (page field) The goal would be for the user to create a new featured neighborhood, choose the neighborhood reference, and then homes_in_neighborhood would be a selection dynamically created from whatever neighborhood that is. Is this possible in PW? Thanks in advance!
  15. Thanks so much Robin, that definitely does work for me as well. I wish I understood the "why" of this a bit better (the array weirdness, and why ready.php worked differently from the module when not hard-coded), but I guess I'll plow ahead and return to this later. Thanks again for your help.
  16. Thanks Robin, I'm sort of confused why that mattered but you're right that I now have a proper multidimensional array... However now, upon upload, the image sizes get created but the upload thumbnail continues to hang in the "working" state http://imgur.com/a/ZkWco I can't save the page and obviously a reload dumps the images. Any thoughts? My code: // return empty array if not set $sizes = isset($this->config->imageSizes) ? $this->config->imageSizes : []; // loop through the sizes and create the images if (count($sizes)) { foreach ($sizes as $size) { $image->size($size["width"], $size["height"]); } }
  17. Somatonic made a module to make image variations, of a custom size, upon uploading them. https://gist.github.com/somatonic/5685631 It works great but it has values hardcoded into the code. $image->size(120,120); $image->size(1000,0); I thought that it might make sense to use the config.php to create a multidimensional array for my thumbnail sizes, that way I could reference them from the module as well as my template. // in config.php $config->imageSizes["foo"] = ["width" => 12, "height" => 34]; $config->imageSizes["bar"] = ["width" => 56, "height" => 78]; But back in my module, when I try to loop through $config->imageSizes or $this->config->imageSizes I seem to get absolutely nothing. I'm also not the best programmer so I'm having a hard time figuring out how I can debug something like this that only fires when an image gets uploaded - I tried wire("log")->save("debug", $myOutput) which could be not the best move. Any help appreciated - the goal is to have one reference set of sizes and then be able to refer to it in the module as well as my templates. Thanks!
  18. Ohhhh very interesting. Thank you very much Martijn. Great answer.
  19. Standard website lives at www.foobar.com and by default the template files are served up from /site/templates/ Can processwire be set up to serve requests from dev.foobar.com by pulling template files from another directory? /devsite/templates or /site/devtemplate/ ?
  20. And actually you really could just drive it all out of page reference fields. For example you could make the field:rating a page reference and add it to your website data structure. website data ​food​[see above] ratings​professional expert intermediate novice none Simply drive the reference from /website-data/ratings/ and then youll have some flexibility if you ever want to change the ratings and turn them to "stars" or assign them numeric values.
  21. teamjoe sally lawrence website data food fruitsapples bananas clementines vegetablesasparagus broccoli cauliflower meatbeef chicken pork Lets say you set up your processwire website like this. Everything in italics is merely website data as pages. team = template "team", and actual viewable page with a template file joe, sally, lawrence = template "employee" the rest = template "generic-data" On the employee template you could attach a repeater called "food_ratings". That repeater could have two fields, "food" and "rating". Field:rating would simply be numeric from 1-10, and field:food would be a "page reference" field. Now when you create or edit a new employee page, you have a repeater where you can attach the data of an arbitrarily chosen new food and then give it a rating value for how much that person likes it, eg: darrenfood_ratings1 = apple, 10 food_ratings2 = broccoli, 5 food_ratings3 = chicken, 9 Could something like this be a solution for you?
  22. Just to follow up to conclude the thread for someone who might search in the future, I've set it up in the following hierarchy: order order form Astep1 step2 step3 order form Bstep1 step2 step3 step4 step5 ​order form N​stepN "order" is the master page (and template) that handles everything via URL segments, and lots of error checking. All of the sub-structure is simply data and organization, no template files for any of the pages and they cannot be accessed directly via the front end. A/B testing is handled through a page-reference field in the order template which allows the client to pick one, or many, order forms to be tested. If there are multiple, a new user is silently assigned a random order form based on that field and stored in $session. Using urlSegments, if a user goes to /order/step2/ the proper page is shown based on that session variable which dictates whether the user should get "step2" of order form A or B. Beyond that all the tracking is handled via analytics JS using flags. Set by variables output by PHP, they reveal which path the user was on, and how far they got. eg: { path : 'order-form-a', distance : 'step4' } I think it's a good solution, so hopefully the design withstands the test of time. Thanks for the guidance!
  23. mr-fan, are you responding to the A/B testing aspect of it? "cliententry-[one|two]" being one process or another randomly given to the user when they visit?
  24. DaveP, yeah I've been looking at URL segments as a way to implement some A/B testing as well. I'll explore that more today since your suggestion seems so well received! netcarver, the form I'm dealing with involves doing calculations, and checking, and logic between steps, which I suppose could be all done via AJAX. Either way it's a bit more involved and that js won't solve my issues, thanks though.
  25. Lets say you wanted to make a 6 step order form where a user stepped through it entering various data, making choices, having those choices calculate or be error corrected before moving on to the next pages... how would you accomplish that? Simple example... lets say, in order, the process is the something like the following: enter a fruit enter a quantity enter a vegetable enter a different quantity Provide your home address Thank you / Order review Obviously think much more complex than this, but in rough theory do you think that you'd be making individual, unique, templates for each step of this process? Each each step would need some kind of error checking or another - each page "submit" would post back to itself and then have code in the template file top top to check that the data is valid and move on to the next step or, if not, repeat. If someone enters "laser beam" on step 3, you want to be able to make sure they are prompted to actually enter a vegetable. In addition you'd want to allow the user to go back at any point and change something while retaining all the previously entered data -- $session object? Perhaps that's not the best way? And as the form gets more complex or adds additional steps (bad UX aside) it would require more unique templates and code? Or maybe there's a way to create one "order-stage" template which somehow gracefully handles the unique data needs and error checking for each page? Hanna code maybe? I wonder if anyone has insights as to what might be a good approach. Thanks in advance.
×
×
  • Create New...