Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/23/2016 in all areas

  1. Christmas stockings are where you find the small gifts, while the big stuff goes wrapped up under the tree. Yet, looking back, it often seems like some of the most useful stuff ends up in those stockings… Swiss army knifes, digital tire gauges, flash drives, and so on. This week, the big stuff is between you and Santa, but what we do have are lots of useful stocking stuffers for you to enjoy in ProcessWire 3.0.46! https://processwire.com/blog/posts/pw-3.0.46-stocking-stuffers/
    9 points
  2. Merry Xmas to you and your family Ryan! Every week of the year you're kind of our Santa Claus P.s. = Does every update of this new release apply for the 2.8.x branch too?
    5 points
  3. I am trying to do something similar to a $page->rootParent check, but for a site using Soma's multi-site module. Because the "roots" for a multi-site are actually the 2nd level pages rather than the first level, this means that $page->rootParent doesn't give me what I need to check which "section" of the site I'm currently in. This made me wonder, shouldn't there be a simple $page->level or $page->depth property that returns how deep any page is located in the page tree? Then we could do things like $page->parents('level=2') to get a parent at a specific level, $page->level to determine whether to show/hide some element in a template, or $pages->find('level=2') to get all pages at a certain level. I built some hooks to add in this functionality, although it won't work for database selectors: /** * level * * @return int - Level/depth of this page in the page tree */ $this->wire()->addHookProperty('Page::level', function($e) { $e->return = $e->object->parents->count(); }); /** * parentLevel(int $level = null) * * @param int $level * @return - Returns the Page's parent page at the requested depth/level in the page tree. Returns NullPage if there is no page at that level */ $this->wire()->addHook('Page::parentLevel', function($e) { $that = $e->object; $level = $e->arguments[0] ?: null; if($level == null) $e->return = new NullPage(); else { $parents = $that->parents->append($that); if($parents->count() < $level) { $e->return = new NullPage(); } else { $e->return = $parents->eq($level); } } });
    3 points
  4. Just stopping by to wish all the other members a happy Christmas. Or if you don't celebrate Christmas, then a happy holidays! And if you don't have a holiday, maybe you'll get one next year :-p Been working on two websites concurrently with PW so pretty busy! Not been able to stop by here as much as I would have liked. On a plus note, both are now at the demo stage. I actually need to find some work in the new year as I'm kicking off my self employment again, so anyone wants to see the demo sites to see the kind of stuff I'm doing, then I'm happy to share in a PM. TBH, they're not highly technical, still more brochure style at the moment, but looking to move onto bigger and better things. Maybe a meetup in Surrey or something would help kickstart things a little. Have a good one people Sam.
    3 points
  5. This is certainly a nice idea. I'd also really like to see this as database level selector. And you can shorten the method hook quite a bit like this: $this->wire()->addHook('Page::parentLevel', function(HookEvent $event) { $level = (int) $event->arguments(0); if($level < 0) return $event->return = new NullPage(); $event->return = $event->object->parents->append($event->object)->eq($level) ?: new NullPage(); }); Edit: Without the second line in the hook it would also accept $page->parentLevel(-3), which goes from the current page upwards.
    3 points
  6. This functionality is now built into the core so you can use with ML textareas:
    2 points
  7. There's also the MarkupCache module, which is similar to WireCache, but file based. ProCache is indeed a nice solution, but like TemplateCache it's not going to solve @adrianmak's problem of caching different markup for mobile/desktop requests.
    2 points
  8. Worked it out. payment->embed() should have been payment->render(); Would be ace to add some docs with your payment modules if possible. Happy to contribute if I get my head around it...
    2 points
  9. Merry Christmas/Happy Holidays to everybody in the PW Community!
    2 points
  10. I needed a field that would allow me to select one or more templates, very much like the Page Select. So I created a module that does just that! I based it off of Ryan's FieldtypeModules because the functionality is quite similar. You can also define which templates are selectable by the asmselect field. Hope this helps someone that wants to do the same thing! FieldtypeTemplates.module
    1 point
  11. Tense Tense (Test ENvironment Setup & Execution) is a command-line tool to easily run tests agains multiple versions of ProcessWire CMF. Are you building a module, or a template and you need to make sure it works in all supported ProcessWire versions? Then Tense is exactly what you need. Write the tests in any testing framework, tell Tense which ProcessWire versions you are interested in and it will do the rest for you. See example or see usage in a real project. How to use? 1. Install it: composer global require uiii/tense 2. Create tense.yml config: tense init 3. Run it: tense run For detailed instructions see Github page: https://github.com/uiii/tense This is made possible thanks to the great wireshell tool by @justb3a, @marcus and others. What do you think about it? Do you find it useful? Do you have some idea? Did you find some bug? Tell me you opinion. Write it here or in the issue tracker.
    1 point
  12. Just for reference: https://github.com/processwire/processwire-issues/issues/130 If you want a quick fix until @ryan gets this sorted, just add the $options argument to the User version of the method, eg. public function editUrl($options = array()) { on this line: https://github.com/processwire/processwire/blob/e8b9f1294311a9e57d05b5cb5b7395b7685e951b/wire/core/User.php#L448
    1 point
  13. Uahh! It was a heavy birth, but now it is working as expected. As @kongondo pointed out, the deletion of the old pages have to take place after creation and saving of the new child pages. But this is only possible if each of the child pages has an unique path name. Otherwise the saving of the new children is not possible (duplication of the path names). Solution: I have added the current time stamp to the path name. Now the path names of my children look like "name-of-the event-23-12-2016-1482482098". Now every child page has a unique path name. Now I was able to put the code for deleting the old children after the saving of the new created children. .... .... //check for other languages and create UNIQUE path names foreach ($this->languages as $lang) { $lname = $lang->isDefault() ? '' : $lang->id; $default = $this->languages->get("default"); if ($page->title->getLanguageValue($lang)) { $k->set("name$lname", $page->title->getLanguageValue($lang) . '-' . $eventstartmultiple . '-' . time()); } else { $k->set("name$lname", $page->title->getLanguageValue($default) . '-' . $eventstartmultiple . '-' . time()); } $k->set("status$lang", 1); } $k->save(); } //delete old children $pages = $this->wire('pages'); $repeaterID = $this->wire('fields')->get('eventpricerepeater')->id; // this is the 'repeater_field_name' page $repeaterPage = $pages->get("parent.name=repeaters, name=for-field-$repeaterID"); foreach ($page->children as $child) { if (in_array($child->id, $oldchildrenids, true)) { $id = $child->id; $child->delete(); $this->message("{$child->id} wurde gefunden und gelöscht"); $childRepeaterPage = $repeaterPage->child("name=for-page-$id"); // will also delete the repeat item pages, e.g. the '1234567890' if ($childRepeaterPage->id) $pages->delete($childRepeaterPage, true); } } The deletion code is now after the saving of the new children. Each child gets an unique path name by adding the time stamp via "time()" at the end. Every time i create new children, they will be created properly (and the corresponding repeaters too). All old children and repeaters will be deleted properly. Special Thanks to @kongondo and to @adrian for their patience and help getting this to work.
    1 point
  14. Hahah, Canucks I guess you call me because of the Canadian location of residence? I am not really Canadian even though I live here for a long time. Originally I am from a small sunny country located on the Black Sea Coast called Bulgaria But, no offense taken at all...
    1 point
  15. No problem at all - glad you decided to stick around - it's nice to have some more Canucks here!
    1 point
  16. Adrian, your code did the trick perfectly. To be honest, at the beginning I created an image field and assigned it to the logo and anywhere else an image is needed, however, these days I decided to split them as somewhere I might need to allow a single image, somewhere an array, have different requirements for empty field etc. It won't hurt if you have a few different image fields, eg. logo, body_image, background or anything else. At least it does not make any template heavier... I will redo the images call everywhere now and move on. Thanks again, adrian for the suggestions and feedback. The reason I think PW is my final stop is that the community is GREAT!!!
    1 point
  17. you define the cache name above/outside of the functions, like in my example right? It should actually work.. uh I'm quite sure you need to wrap $config->prefix in curly braces like so "{$config->prefix}__$page->id-$page->template-{$user->language->name}"; without them php thinks the two underscores are part of the variable but there is no variable called $config->prefix__
    1 point
  18. $thumbnail = $page->image->first()->size(600,480); Although if I have an images field that is named to sound like a single image, eg "image" then I always make sure to set the max to 1, rather than 0 so I don't get confused about whether it's going to be a single image or an array.
    1 point
  19. Here are is a SCSS snippet if you would like to use inline roles (I'm not liking those big green asm items). It also enables removing roles by clicking on its label (not only on its icon), "user" icon instead trash and there's a line-through effect on hover too. You can use an online tool to make CSS from it.
    1 point
  20. You like to keep me busy don't you How's this? That along with a few tweaks/fixes has been committed. Don't forget to fork and contribute
    1 point
  21. For those wanting to delete source images, you can find my script in this Gist. Make sure you have successfully converted the images to the CI3 standard before you run it to delete the source images.
    1 point
  22. This is not the right way to get the url of a single image. When using image fields you want to select the "Formatted value" setting that suits the number of images your field is allowed to hold. I recommend you stick to two of these options: Array of items - select this when "Maximum files allowed" is set to either 0 (no limit) or greater than 1 Single item - select this when "Maximum files allowed" is set to 1 Next you need to understand what is going to be returned when you use $page->image (assuming your image field is named 'image'). If you chose "single item" then $page->image will be a single image object. If you chose "array of items" then $page->image will be an array of image objects. You don't want to ever echo an object itself (it may return some value but it's generally not good practice), but you might echo some property of the object (e.g. description) or call some method on the object (e.g. url or size). When dealing with an array of image objects you will either loop over them with foreach or you can get a single object from the array with a method such as first() or eq(). So take this code example from above: You want to get the URL of a single image in the field. If your image field is formatted as "single item" then you would do this: $image = $page->image->url; If your image field is formatted as "array of items" then you would do this: $image = $page->image->first()->url; One more thing... You are setting width and height attributes on the img tag so you should use the size() method to make sure the image is cropped to the same dimensions (or same ratio of dimensions if you are wanting a HiDPI image). $page->image->size(600,480)->url Otherwise you wont get the desired result if someone uploads an image with a different aspect ratio.
    1 point
  23. Hi, thank you for reply. I decided to build this module in another way. I think this works nice and is efficent for projects with hundreds of images, like Product-Catalogs. Ok, here is my brand new version module: image upload to another page upload and add to pages field image comparison to prevent duplicates basename comparison and pixel comparison search images by text (or show all) no more autocomplete-clone. A built a own Javascript to api logic to get images back. select images in an easy way drag n drop the imagepages like in imagefield to sort Because its extensive stuff, i decided to take a screen capture. I dont know how add a videocontainer here, so you have to download or open the following link in browser: Screen Capture http://download.frech-und-artig.de/selectOrUpload.mp4 (mp4, 91 MB) 3:35 = upload and select images 5:48 = image comparison 7:18 = image comparison with new page 8:00 = testing change of LibraryParent Image Preview Things that i have done: extended Image configuration fields hook in Page::saved to push uploaded images to new/other page ans check if page and image fields connected right to each other extended Page configuration fields hook in PageField::saved to control PageField Config hook in ProcessPageSearch to provide image thumbs instead of boring labels created new InputField "InputfieldPageSelectOrUpload" without pageAutocomplete cloning i added own logic to sortable / add / remove events etc I focused all the time to simplynes for user comfort. But one thing is anoying: that i have to use two fields: the image and the pagefield. I'd loving it, if there is a way, to setup only one field which is presenting two fields in one. How can i merge this? I leaved the bunch of $this->messages("...") in the module for now, because they explain some things and reports errors. What do you think? See zip in attachement. I hope you understand my amazing english skills. SelectOrUpload-0.0.1.zip
    1 point
  24. There are several options: 1) The easiest option would be in the Console Panel in TracyDebugger 2) Converted to an action for the Admin Actions module - this would be a great option because I expect there will be lots of users wanting to convert from Thumbnails to Croppable image over the next few months - hint hint @netcarver, @horst, or @jacmaes 3) In a test hanna code 4) In a template file 5) In a bootstrapped script in the root of your site
    1 point
  25. Hi @Qualtext, Nice job on the modules! Most of us around here are not true pros, and I don't think you need a pro to finish off your modules - you're doing great so far and you're nearly done. Just stick at it. You've probably seen it already, but this is the docs page that is particularly useful for module development: https://processwire.com/api/ref/module/ The bits I quote below are from this page. It isn't necessary to merge everything into a single module file. It's not unusual for a single module release to actually contain two or more modules. Put both modules inside the same directory, decide which is the primary module and have that module install the other automatically by using the "installs" property in the getModuleInfo() array. This takes care of item 1 or 2 in your list of installation steps. Another thing you could do to finish off your modules for release is add code that creates some of the required pages and templates. You can use the ___install() method to do this. In your list of installation steps I think your install method could potentially take care of the following items: 3,4,5,6,7,9. Items 8 and 10 you leave up the user. Search the forum and API docs and look at the code of other modules to understand how to create templates, fields and pages via the API. Give your auto-created templates/fields/pages names that are unlikely to be already in use, e.g. prefix them with the name of your module class. The labels/titles can be anything though. Here are some links to start with:
    1 point
  26. Is it possible to use a selector to find fields that have a given textformatter applied? I tried... $flds = $fields->find("textformatters=TextformatterHannaCode"); ...but the textformatters property is an array so I get an array to string conversion error. So a broader question would be: is it possible to use a selector to match inside a property that is an array? For the textformatter, is there a more efficient way than just iterating over $fields? $flds = []; foreach($fields as $field) { if( is_array($field->textformatters) && in_array('TextformatterHannaCode', $field->textformatters) ) $flds[] = $field; }
    1 point
  27. Thanks for all the prompts to get this updated and out on GitHub, everyone. My apologies for not doing it a long time ago! Here's the modules directory entry: http://modules.processwire.com/modules/fieldtype-templates/ Out on GitHub: https://github.com/Hani79/Processwire_FieldType_Templates Shout out to @adrian for fixing the bug reported by @Raul and @lisandi
    1 point
×
×
  • Create New...