• Content count

  • Joined

  • Last visited

Community Reputation

19 Good

About darrenc

  • Rank
    Jr. Member
  1. darrenc

    In my map I want to turn the clustering off. What's the simplest way?
  2. 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.
  3. 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?
  4. @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.
  5. <?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?
  6. darrenc

    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.
  7. 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?
  8. 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!
  9. 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.
  10. 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"]); } }
  11. 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!
  12. Ohhhh very interesting. Thank you very much Martijn. Great answer.
  13. 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/ ?
  14. darrenc

    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.
  15. darrenc

    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?