-
Posts
11,241 -
Joined
-
Last visited
-
Days Won
374
Everything posted by adrian
-
Hey Soma, Just went to install via the modules manager and got this notice (obviously not a big deal, but nice to fix): Notice: Undefined variable: success in /site/modules/ModulesManager/ModulesManager.module on line 393 BUT the following is a show stopper: ModulesManager: File could not be downloaded https://github.com/somatonic/ChromePhpLogger/archive/master There seems to be a problem with downloading or writing the module.
-
I am not sure if there is a decent guide to this anywhere, and I have only set these up a couple of times now, so not sure I have everything in my head, but I think at a minimum you need to go to the access tab for the home template, select yes and then able edit rights for the editor role. You can also do this for child page templates at any level. One thing I found confusing at first was being able to separate things so that some users can delete and other cannot. This requires setting up a new permission called page-delete and a new role called "deletor" or something along those lines. Then you can assign the manager user editor and/or deletor roles. When you're on the access tab for a template you need to select "edit pages" for the deletor role if you want them to be able to delete. Key thing to remember is that you can limit access to a very detailed level. There are also a few modules that can make things even more detailed: http://modules.processwire.com/modules/custom-page-roles/ http://modules.processwire.com/modules/page-edit-per-user/ http://modules.processwire.com/modules/page-edit-field-permission/
-
Hi Antti, Sorry if those comments seemed unappreciative. I completely see the value of being able to edit single fields separately on a page. Perhaps the idea of RenderAll doesn't really fit well with this module. Personally, the biggest benefit for me with Fredi is the ability to edit content from other pages - this is where AdminBar lets me down. I guess I am thinking of a way to combine the best of both somehow. I'll let you know if I have any brilliant ideas
-
Does it work with a more standard: $items = $pages->find("limit=10, sort=-modified"); Also, what do you see if you view the page source - it might show the start of the xml so you can see the tag problem.
-
What is the path to an uploaded image in an "Image FieldType"?
adrian replied to n0sleeves's topic in Getting Started
You can read more about output formatting about half way down this page: http://processwire.com/api/variables/page/ But, in your particular situation, Soma explains it well here: http://processwire.com/talk/topic/2917-command-line-script-file-api-not-performing-same-as-on-website/?p=28697 "Image field is always an array, it's just that page output formatting does change it so in template files you get an object if the image field is set to max 1 item. So if output formatting is off it's always treated as an array, disregarding the field settings." If you have it set to false, or you have max images set to anything but '1' then you need to do one of the following: $page->column1_image->first()->url $page->column1_image->eq(3)->url $page->column1_image->last()->url- 11 replies
-
- 1
-
-
- image location
- img src
-
(and 1 more)
Tagged with:
-
Soma, correct me if I am wrong (although I tested it and it works ), but isn't that the same as doing $product->fields->product_price->label ? Is one better than the other? No worries - you should do a search and see all the stupid mistakes I have made Any luck with the number_format issue?
-
Sorry that doesn't work. Does your original: $out .="<span>Price: </span><span>{$product->product_price}</span>"; print out the price correctly? Might be a silly question - but does your product_price field definitely have a Label defined? I checked the $product->fields->product_price->label and it works well for me. Just to be sure, can you try: $product->fields->product_price->name instead? number_format should work like that, but maybe just to test any issues with $product->product_price, try testing with something simply like "round" I see Soma lurking here too, so maybe he'll chime in
-
Hi Piqsel and welcome! This should get you what you want: $out .="<span>".$product->fields->product_price->label.": </span><span>" . number_format($product->product_price, 0, ' ', ' ') . "</span>"; Hope that helps, and feel free to keep asking away
-
What is the path to an uploaded image in an "Image FieldType"?
adrian replied to n0sleeves's topic in Getting Started
Is there any chance that you have output formatting turned off for the page? eg $page->of(false)- 11 replies
-
- image location
- img src
-
(and 1 more)
Tagged with:
-
Getting fake URLs (with UrlSegments) returned in search results
adrian replied to adrian's topic in General Support
Hey Ryan, I don't really want to have a template for the person pages, because unless I am not understanding, this would result in search returning links to pages like: /people/joe-blogs/ The would be a page that doesn't exist within the site's menu system and would send the user to something out of context. The template for my staff vs partners is also quite different - I want quite different output I was tempted to just separate and duplicate those people that are multiple categories, but that goes against the grain and doesn't make sense. I really like the simplicity of your approach to just handle the search output differently for a specific template. Obviously much cleaner and more scalable than my approach. What I was attempting to do with that messy code above was create something portable (although I agree it probably doesn't scale very well). They way that code works is to look for any field names in the matched pages foreach($m->fields as $field) { that match page names elsewhere in the page tree $pagematches = $pages->find("name={$field->name}"); For each match where the field is checked, generate a page with the matched page name. if($pagescount>0){ foreach($pagematches as $pm){ if($m->$field!=0){ So this code can be used (I think ) to match any of these scenarios that come up, without having to define the templates that need different treatment. That said, if you couldn't understand it, then it probably isn't a good approach. I'll probably leave it as is for now since it seems to work fine, but maybe next time I come across this situation I'll take your approach instead, unless you can think of a way to clean up what I have into something that could be scalable and fully portable I still have in my mind some module that would allow the ability to define custom rules to manipulate the pagearray based on these sorts of categorizations so that all API calls were seamless. In this example, people/person would be removed from the pagarray and About > Staff > Partners > Affiliates > Partners > Contractors > would be manipulated to return the fields and data from the person template. Although as I try to describe this, it sounds pretty messy -
I stand corrected - good lesson for me there diogo Very true though - that is what I love about PW - the way custom PHP is so easily implemented. All the flexibility of a fully custom coded site, with all the benefits of a CMS!
-
It sounds like you already know about the module for this: http://modules.processwire.com/modules/maintenance-mode/ I am not positive, but pretty sure this module wouldn't exist if there was an alternate way. If you're not familiar with modules yet, they are super easy to install, especially if you get the modules manager: http://modules.processwire.com/modules/modules-manager/ Once you have that, all other modules installs are just a couple of clicks and that's it
-
Hey Marty, I think that could be a good idea too. Having images saved to a custom image field would allow a lot of flexibility, especially for allowing admin users to insert images into a RTE on another page. It seems there has been significant discussion already on the config setup, ie. largethumb,200,200,basic-page,home I fear that maybe we need to go the JSON route (as suggested earlier), if we start adding any more options. Anyone have any more recent thoughts on this?
-
Thanks, I'll set up a pull request shortly. But for the sake of finalizing the code here too, here is the revised version which does a few more checks and other things. Hopefully my logic is sound. Also, just in case someone is interested. I am using this along with my, not yet released, PDFImageCreator module(http://processwire.com/talk/topic/3304-pdf-image-generator/). The module generates images from all the pages of a uploaded PDFs. Then I use this addition to the Thumbnails module to allow admin users to crop out a carousel/slider image from the PDF image to be used on the site's homepage. if(!$page->$prefix) { if(!wire('fields')->get($prefix)){ //If field with name matching the crop name doesn't exist, create it $f = new Field(); // create new field object $f->type = $this->modules->get("FieldtypeImage"); // get a field type $f->name = $prefix; $f->label = ucwords(str_replace('_', ' ', $prefix)); $f->description = 'This field stores user cropped images from other image fields on this page. To see new additions, you need to save this page.'; $f->save(); // save the field } //Add field to the page's template //This is separated out in case the field already exists, but is not in this template $page->template->fields->add($prefix); $page->template->fields->save(); } $page->$prefix->add($targetPath); //Add the image to the field $page->save($prefix); //If the developer sets the maxFiles value for the field to '1' and there is already an image in there, then delete the first one after adding the new one. //This seems to be necessary because the maxFiles = 1 setting doesn't limit addition of extra images via the API if(wire('fields')->get($prefix)->maxFiles==1 && count($page->$prefix) > 1){ $page->$prefix->delete($page->$prefix->first()); $page->save($prefix); }
-
I haven't looked over the shuffleAssoc function properly, but you can probably just use PW's shuffle(): $randimages = $bannerimages->shuffle();
-
Ok, I made a very simple hack to the thumbnails module. Inside public function ___executeSave() within the ProcessCropImage.module I added the following lines just before the timestamp comment. if(!$page->$prefix) { $f = new Field(); $f->type = $this->modules->get("FieldtypeImage"); $f->name = $prefix; $f->label = ucwords(str_replace('_', ' ', $prefix)); $f->save(); $page->template->fields->add($prefix); $page->template->fields->save(); } $page->$prefix->deleteAll(); $page->$prefix->add($targetPath); $page->save($prefix); Firstly it checks for the presence of a field named the same as the crops name. So, if you set up your crop as: thumbnail,100,100 then it will look for a field name 'thumbnail'. If it's not found, it creates it and adds it to the current page's template. I would like to be able to set the field visibility and Maximum files allowed settings, but haven't figure that out yet. Then it takes the cropped image and adds it to that field. Only minor inconvenience is that the image won't appear in the thumbnails field until the user saves the page. Not sure if there is any way around that - I feel like there should be a way to hook into the ajax image uploader to refresh the field, but haven't investigated yet. Antti, is this something you'd consider adding (maybe as a configurable option), or do you think my need is too specific?
-
Hey Macrura - good idea - for some reason I always resort to sql when it comes to these one off manipulations. Off topic, but I wonder if a module that allowed you to run code snippets would be a good idea. It could perhaps even have a library of examples to deal with common issues like this, and the ability to store/share your own snippets. Kind if along the lines of Nik's excellent SelectorTest. Ideally it would report all the changes made etc.
-
Thanks for all the great suggestions Ryan. I will definitely add those dependency checks and implement some config options, including the field, max image dimensions etc and make available on github / modules directory. I didn't really have any time to work on this yesterday, but I took a quick look at using $page->isChanged("field") in an attempt to determine whether the user has uploaded a new version of the PDF during the current page editing session, so it knows to regenerate the images. It didn't seem to work as I expected. Looking at the docs and cheatsheet it seems like I don't need to turn on change tracking in this scenario, but maybe I not properly understanding how this works. This seems like it should be the most elegant way to check this. The other thing I need to do is ensure Ghostscript is installed. I don't think there is a PHP way to do this without exec or system, so I am wondering what you think about having the module include a very small PDF file that the module install method can do a test readImage on. Would that be too hackish? I don't want to blemish PW
-
Hey Marty, Great idea on adding the cropped image to an image field. I might take a look at the module and tweak it to do that - I expect it should be fairly straightforward. Hey Soma - I personally like the concept of your imagesManager, but my users are very non-tech, so I don't know how it would fly with them. I am also not a fan of allowing/encouraging users to insert images into a RTE if the site structure can be standardized, but it isn't always possible unfortunately.
-
Ability to define convention for image and file upload names
adrian replied to adrian's topic in Wishlist & Roadmap
Thanks for the explanation Ryan. I had never thought it about it as a lazy way, but I certainly see your point. I initially used to write my little custom CMSs to retain original filenames, but changed to auto-generated because most of my work is for sites which provide lots of materials designed to be downloaded by end users. Having clients upload files with names like: Final ReportV6 web version for John Feb 23.PDF started to drive me a little crazy though. Not very useful or meaningful to the poor end user who downloads it. No amount of training or explanation could get them to make meaningful filenames. Thanks for the example module code - I will definitely make use of that. I really can't believe how easy you have made implementing custom modules. The lack of ability to do this with other system (whether real or perceived) is why I never went the CMS route for so many years It always seemed like I would be hacking away at things to make the functionality I needed. -
I am not sure on the recommended way of avoiding this scenario in the first place, but you could run some SQL to change those links. Something like: UPDATE field_body SET data = REPLACE( data, '/mysite', '' ) This is untested and as with any manual DB manipulation, make sure you have a good backup first.
-
Getting fake URLs (with UrlSegments) returned in search results
adrian replied to adrian's topic in General Support
Just wanted to note that I just updated the code block above. It now includes an additional 'if' to make sure that the checkbox field in question is actually checked. It also accurately counts the number of returned results. And it appends the parent title to the link title so users can see the difference between two links that otherwise look the same - eg Affiliates > Joe Blogs and Contractors > Joe Blogs. Seems to be behaving now, but I am sure I will come across another problem scenario or two before it is fully dialed. -
Sorry, one more thing - is it possible (or should I say, can you make it possible) to set just one dimension, or perhaps neither (set them to 0). I would like to allow the user the ability to crop freeform, and then resize automatically (if one dimension set), or later through a template if no dimensions set. I think this would be really useful - often in layouts you want all images the same width, but you don't care about height, and vice versa.
-
A couple of hopefully quick questions. I can't seem to find a way to use the "Select Image" feature within a text area to select one of the cropped images. It only seems to load up the original uncropped images. Is this possible? Also, is it possible to not do any cropping by default, but rather only if the user chooses to. I want them to be able to choose to crop just one of the images in a multi images field then grab that one (or the first one of the images) that has a cropped version. Make sense? Thanks!
-
Uninstalling AdminBar fixed the redirect issue - thanks, and sorry if I missed that mentioned somewhere else. It would be great to have that simplified version of AdminBar you mentioned too, to work with Fredi. I think the new page option is an important addition - thanks for looking into it. Sorry if my AdminBar and CKEditor inline editing link was confusing. I am not completely convinced about inline editing - I just know there has been a fair bit of discussion about it in this forum. I thought the ability of Fredi to limit editing to specific fields could be tied into inline editing with some visual cue to identify which fields are editable. Anyway, sounds like that is for a future module. renderAll() looks much better