Jump to content

Tom.

Members
  • Posts

    461
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by Tom.

  1. I have a script that I would like to upload and make sure the files keep it's file name. This is a multi-image image field. Just using $p->images->add($_FILES['file']['tmp_name']) works. However this doesn't: if(count($_FILES['file']) != 0) { $p->images->removeAll(); $u = new WireUpload('file'); $u->setDestinationPath($p->images->path); foreach($u->execute() as $filename) $p->images->add($filename); } if(!$error) $p->save(); There is no error given, however non of the images are added? What am I missing here? Edit: print_r($u); print_r($u->execute()); Both return an empty array. I'm guessing WireUpload('file') doesn't use $_FILES and there for can not be used with DropZone? Edit2: WireUpload does use $_FILES. There is some sort of bug happening here with using Ajax and WireUpload.
  2. @Zeka There is many inconsistencies between in-memory and DB. Things being case sensitive etc. I'm recently seeing the inconsistency throw people more and more. As the API is the same - I think it's hard to know what's going to be DB and what's going to be in-memory. I think there are things that can be done to bring in-memory searches to bring it inline with DB searches. For now this should work: <?php $validation = []; preg_match_all('/\(([^\)]+)\)/' $selector, $matches); foreach($matches[1] as $match) { $validation[] = $page->matches($match); } if(in_array(true, $validation)) { // Page Matches one OR Group. } ?> I haven't tested it, but it should work, might require a little tweaking. Or <?php $validation = false; preg_match_all('/\(([^\)]+)\)/' $selector, $matches); foreach($matches[1] as $match) { if(!$validation) { $validation = $page->matches($match); } } if($validation) { // Page Matches one OR Group. } ?>
  3. I'm integrating FoxyCart SSO at the moment, I want to make it so when someone registers using ProcessWire it also registers them for the Store. To do this I have to set FoxyCart up to use the same encrypting method as ProcessWire. I know it uses a hash and a salt. But I was wondering if anyone has done this before? I'm struggling to utilise the ProcessWire API to pass FoxyCart the hash and salt for a particular user.
  4. Worked a charm - thanks! EDIT: Spoke to soon, in this case it must be = because if you have an empty selector that means that product variation doesn't exist. So selecting colour=blue isn't enough, but *= will still make a selection.
  5. I'm having a strange issue here where my selector is case sensitive on a default install with no modification MySQL. The selector is as follows: $vars = explode("?", $_SERVER[REQUEST_URI])[1]; $selector = implode(", ", explode("&", $vars)); echo $selector; $variation = $page->wc_variations->get("wc_variation_value='$selector'"); This doesn't work `$selector` outputs `size=14, colour=blue` If I was to change the value given to `Size=14, Colour=Blue` it then finds the repeater item. Anyone else come across this issue before? EDIT: Seems like there is an inconsistency between database searches and in memory searches. I've just done an extra: foreach($page->wc_variations as $variation) $variation->wc_variation_value = strtolower($variation->wc_variation_value); Before doing the selector. Not great, but it works.
  6. Yeah, I usually just copy the code over the CSS just for that utility then customise it to how I want it to look. It also means I only get the CSS for the utilities I'm using. Very few utilities actually require CSS. Things like masonry grid, grid filtering and parallax don't require UIKits CSS. You can get to the CSS of just a component on GitHub: https://github.com/uikit/uikit/blob/develop/src/less/components/slider.less
  7. Well, I use personally use UIkit 3 + TailwindCSS. Tailwind you are going to hear a whole lot more about in the upcoming months. I know you are talking about file size and this is exactly why UIkit + Tailwind is great! I don't really use UIkit's CSS at all. I just use the JavaScript because the amount of utilities they have manage to pack into 130kb (less than most images) is amazing. I'm talking Parallax, Sliders, Lazy Loading Images, Srcset utilities, placeholder generators, scrollspy, sticky. Most of which can be and usually is utilised in any project. I challenge you to get all of that under 130kb. Also it doesn't have any dependencies. Tailwind you can get down to about 3KB per website using Purge and Gulp/Webpack. It truly is amazing and Utility first CSS is such a refreshing way to work with CSS. I know all the arguments, and I'm a minimalist. I don't like all the classes too. But Tailwind's benifits out weigh the cost. 1. You don't have to struggle with inherited styles, or coming up with class names to define each section, some of which may look the same but be very different in content. 2. Consistency, it puts pressure on you to keep things consistent. So you hardly stray to loads of different type sizes and colours. 3. With Purge, you can have an entire website styles in ~3kb. I believe Ryan chose UIkit 3 because he has learnt the classes and is confident with the framework, and is impressed with the JavaScript utilities. And because you can build website much quicker using it. I see it as a hybrid between utility and a standard framework. It offers many utility classes. You could also Purge UIkit's CSS and get it around 160KB. I don't believe that this isn't a good fit for ProcessWire as you have previously mentioned. Many who use ProcessWire love UIkit. It follows the same philosophy: A powerful framework, that is easy to understand and learn to get things done quicker. Just like ProcessWire gives developers confidence in that they can do challenging bits of functionality easily with the power of ProcessWire's amazing API (like seriously, I built a real estate system using ProcessWire, something I wouldn't have dreamed of doing on any other platform). Well UIkit also gives that confidence to the front-end. But if I was to choose for myself, I much prefer pairing Tailwind for the CSS and UIkit for the JavaScript. That ~140KB (Tailwind + UIkit) covers me for most websites I build.
  8. @adrian Hi Adrian, I know you have done the latest version of this module. I'm having a few issues using your folk on 3.0, not entirely sure if it's me. 1. You mentioned that it sets a sleep value of the page ID, so if the URL is to ever change it will be update. This doesn't seem to be working at all. I can set it to a local url but it does not update if I change the url. 2. It doesn't seem to store ID's at all on a local install. I think both of the above is because it's installed on a folder: I mean the domain is http://dev.agency.com/client - so the url is /client/link/to/page and exactly why I need 1 or 2 for when it goes live. I'm going to do a folk and fix that. Let me know if you want to merge.
  9. As in a user has an article in that category? So your structure in the backend would be: Articles - Post - Post - Post Categories - Category - Category The Template Post will hold the User or I guess "Published by"? And a Category will be a page reference on the Post template? If this is your structure this will work. Also lets assume a Post can be in multiple Categories. $results = $pages->find("template=post, title%=$searchTerm"); foreach($results as $result) { foreach($result->category as $category) { $categories[$category->title][] = $result->published_by; } } // Show Results foreach($categories as $key => $value) { echo "<h3>$key</h3>"; foreach(array_unique($value) as $user) { echo $user; } } I haven't tested this at all, but using my imagination I think it might work. If not it will definitely send you on the right track. I'm sure there is more efficient ways of doing this. However, this is what comes into my head first.
  10. I've used ProcessWire for very similar things, and will continue to use ProcessWire for those things in future. In fact I have a project coming up soon for competition entries and will be using ProcessWire. I always see ProcessWire as a Content Management Framework over a Content Management System.
  11. @Gideon So I also can't seem to download 3.0.116. Both the Website and ProcessWireUpgrade module report 3.0.115 being latest.
  12. @Robin S Thanks for your response - this has now been fixed: https://github.com/processwire/processwire-issues/issues/716#issuecomment-427372423
  13. Hey, I'm having an issue where you see different output based on whether you are logged in or not: <div class="px-1"> <div class="flex flex-wrap -ml-1 -mt-1" uk-scrollspy="target: > div; cls: fade-up; delay: 100;"> <?php foreach($value as $item): $item->block = $blocks[$item->size->value]; ?> <?php if($item->size->value != 'half' || $item->prev()->size->value != 'half'): ?> <div class="pl-1 mt-1 <?=$item->block['class']?>"> <?php if($item->size->value == 'half'): ?> <div class="flex flex-wrap -ml-1 -mt-1"> <?php endif; ?> <?php endif; ?> <?php if($item->size->value == 'half'): ?> <div class="pl-1 mt-1 w-1/2 lg:w-full"> <?php endif; ?> <?=$item->render()?> <?php if($item->size->value == 'half'): ?> </div> <?php endif; ?> <?php if($item->size->value != 'half' || $item->next()->size->value != 'half'): ?> <?php if($item->size->value == 'half'): ?> </div> <?php endif; ?> </div> <?php endif; ?> <?php endforeach; ?> </div> </div> This works great when you are logged in! It keeps the 'half' sized blocked grouped together when they are next to each other. See output: <div class="pl-1 mt-1 w-full lg:w-1/3 uk-scrollspy-inview fade-up" style=""> <div class="flex flex-wrap -ml-1 -mt-1"> <div class="pl-1 mt-1 w-1/2 lg:w-full"> <a href="[hidden]" class="block-half block no-underline relative bg-grey bg-cover overflow-hidden"> <div class="group absolute pin p-3 md:p-6" style="background-color: rgba(0, 0, 0, 0.15)"> <h2 class="text-base md:text-lg xl:text-2xl lg:w-2/3 text-white uk-scrollspy-inview fade-up" style="">About us </h2> <h2 class="text-base md:text-lg xl:text-2xl lg:w-2/3 text-black uk-scrollspy-inview fade-up" style="">Our practice</h2> <span class="absolute pin-b pin-l ml-3 md:ml-6 mb-3 md:mb-6 xl:text-xl flex items-center opacity-0 group-hover:opacity-100 transition text-white">View About us</span> </div> </a> </div> <div class="pl-1 mt-1 w-1/2 lg:w-full"> <a href="[hidden]" class="block-half block no-underline relative bg-grey bg-cover overflow-hidden"> <div class="group absolute pin p-3 md:p-6"> <h2 class="text-base md:text-lg xl:text-2xl lg:w-2/3 text-yellow uk-scrollspy-inview fade-up" style="">Feed </h2> <span class="absolute pin-b pin-l ml-3 md:ml-6 mb-3 md:mb-6 xl:text-xl flex items-center opacity-0 group-hover:opacity-100 transition text-yellow">View Feed</span> </div> </a> </div> </div> </div> Perfect! However, when you are logged in it displays like this: <div class="pl-1 mt-1 w-full lg:w-1/3 uk-scrollspy-inview fade-up" style=""> <div class="flex flex-wrap -ml-1 -mt-1"> <div class="pl-1 mt-1 w-1/2 lg:w-full"> <a href="[hidden]" class="block-half block no-underline relative bg-grey bg-cover overflow-hidden"> <div class="group absolute pin p-3 md:p-6" style="background-color: rgba(0, 0, 0, 0.15)"> <h2 class="text-base md:text-lg xl:text-2xl lg:w-2/3 text-white uk-scrollspy-inview fade-up" style="">About us </h2> <h2 class="text-base md:text-lg xl:text-2xl lg:w-2/3 text-black uk-scrollspy-inview fade-up" style="">Our practice</h2> <span class="absolute pin-b pin-l ml-3 md:ml-6 mb-3 md:mb-6 xl:text-xl flex items-center opacity-0 group-hover:opacity-100 transition text-white">View About us</span> </div> </a> </div> </div> </div> <div class="pl-1 mt-1 w-full lg:w-1/3 uk-scrollspy-inview fade-up" style=""> <div class="flex flex-wrap -ml-1 -mt-1"> <div class="pl-1 mt-1 w-1/2 lg:w-full"> <a href="[hidden]" class="block-half block no-underline relative bg-grey bg-cover overflow-hidden"> <div class="group absolute pin p-3 md:p-6"> <h2 class="text-base md:text-lg xl:text-2xl lg:w-2/3 text-yellow uk-scrollspy-inview fade-up" style="">Feed </h2> <span class="absolute pin-b pin-l ml-3 md:ml-6 mb-3 md:mb-6 xl:text-xl flex items-center opacity-0 group-hover:opacity-100 transition text-yellow">View Feed</span> </div> </a> </div> </div> </div> Which breaks the layout completely. I have ProCache & ProDrafts installed but both are turned off. I've tried Incognito mode both logged in and out to see if it's a caching issue, however it seems completely down to be logged in or not? Strange one. Anyone know what's going off here? I'm going to try `->next("include=all")` as that's the only thing I can think off at this point. If it works then it must be a bug. EDIT: ->next("include=all") fixes it. This is a bug as all repeater items are published.
  14. Perfect response, thank you very much ? I just couldn't get my head around the logic for some reason.
  15. I have no idea why, but I can't solve this haha! I have a block system that groups two half blocks together. So it checks what comes before or after it to create the markup <div class="masonry flex flex-wrap -ml-1 -mt-1"> <div class="masonry-sizer w-1/2 lg:w-1/3"></div> <?php foreach($value as $item): $item->block = $blocks[$item->size->value]; ?> <?php if($item->size->value == 'half' && $item->prev()->size->value == 'half'): ?> <?php else: ?> <div class="pl-1 mt-1 <?=$item->block['class']?>"> <?php endif; ?> <?=$item->render()?> <?php if($item->size->value == 'half' && $item->next()->size->value == 'half'): ?> <?php else: ?> </div> <?php endif; ?> <?php endforeach; ?> </div> So I've got the logic down, however I don't want the else. Easy solution, I just turn it into a false. <div class="masonry flex flex-wrap -ml-1 -mt-1"> <div class="masonry-sizer w-1/2 lg:w-1/3"></div> <?php foreach($value as $item): $item->block = $blocks[$item->size->value]; ?> <?php if($item->size->value != 'half' && $item->prev()->size->value != 'half'): ?> <div class="pl-1 mt-1 <?=$item->block['class']?>"> <?php endif; ?> <?=$item->render()?> <?php if($item->size->value != 'half' && $item->next()->size->value != 'half'): ?> </div> <?php endif; ?> <?php endforeach; ?> </div> I assumed that would work. I thought wrong! hahaha. Maybe my brain just isn't on it today. Anyone know what's happening here?
  16. @ryan that doesn't sound pleasent! I hope you make a full recovery!
  17. <div uk-grid> <div class="uk-width-1-6"> </div> <div class="uk-width-expand"> </div> <div class="uk-width-1-6"> </div> </div> 1/6 is about as close to 15% you'll get I think. For 25% just use uk-width-1-4.
  18. Hi, I'm having a really strange bug with repeaters. https://imgur.com/gIdIv8e This is the repeater showing 3 items https://imgur.com/RY7l01C The count on the front is showing 3 items using <?=$page->repeater->count?> When I add a new item https://imgur.com/Ub3dFEC So there is now 4 on the back end. The count is still showing 3 and nothing is being output despite all the fields being filled in. I can clone the new one I've created and nothing, however if I clone one of the items I've already created it shows up: https://imgur.com/C77HirR Despite the backend looking like this: https://imgur.com/GY8yrhO Edit: Update - I've also noticed that all the fields are saving but the image field. I'm going to uninstall ProDrafts and see if it's that. Edit: This is a bug with ProDrafts
  19. The required only if... isn't working in a repeater. Is this not supported in a repeater? The show if.. and required if.. have the same value, show if works but required if doesn't.
  20. Not too sure what doGeocoding function is doing but have you tried hooking before Pages::save? Also check out this https://modules.processwire.com/modules/fieldtype-map-marker/ which does what you are trying to accomplish.
  21. Is the image field set to array mode?
  22. I haven't done translation myself, but from what I believe to be true is you install multi language fields from the Core and manually translate. I think the translation file you uploaded is for translating the CMS backend. I could be completely wrong, but from the multi language website's I have seen they have used the multi language input fields which you can find in the core.
  23. Just use `<?php foreach(): ?>` and `<?php endforeach; ?>` - I very much doubt hosting companies will remove support for that. I wouldn't bother using a Template Language. It's just overhead that's not often worth it.
  24. I create a 'ready.php' in the '/site' folder. This is where you can put your class and you can access it anywhere. If you need to re-use it or plan on releasing it, or just want to keep your code tidy. I would use a module.
  25. $string = '{mailto address="someone@domain.com" encode="javascript" text="link text" subject="The subject line"}'; function mailtoArray($input) { preg_match_all('/(?<attr>[\w]+)=\"(?<value>.[^\"]+)\"/i', $input, $matches, PREG_SET_ORDER); return $matches; } if (strpos($string, '{mailto') !== false) { $matches = mailtoArray($string); print_r($matches); } I would do it that way. One of the matches is the entire tag, it's [0], then [1] or ['attr'] is group match 1 and [2] or ['value'] is group match 2. However you can do a string replace on just match 1 to format it to an anchor tag.
×
×
  • Create New...