-
Posts
10,902 -
Joined
-
Last visited
-
Days Won
349
Everything posted by adrian
-
I knew the issue of wanting to configure the path to the search page was going to come up This was supposed to be a quick response while procrastinating from real work! Give me a few minutes!
-
Ok, how's this work for you? http://modules.processwire.com/modules/process404-search/
-
Maybe just replace slashes in the url with + and send those terms to the search page? Sounds pretty simple to achieve. Not tested ... $this->addHook('ProcessPageView::pageNotFound', $this, 'search'); public function search($event) { $request = parse_url($_SERVER['REQUEST_URI']); $path = $request["path"]; $result = trim(str_replace(basename($_SERVER['SCRIPT_NAME']), '', $path), '/'); $result = explode('/', $result); $term = implode('+', $result); $session->redirect("/search/?q=$term"); } Might be more things to consider. Maybe no real need to explode/implode. Maybe just a str_replace('/','+', $result), but you get the idea.
-
Interesting - I was wondering about that choice of logo size and position - I thought Ryan was being artistic! I just did a hard reload and it is now in the right spot and right size, and those buttons are missing
-
-
Not yet: http://processwire.com/talk/topic/1390-repeater-module-title-of-item/ http://processwire.com/talk/topic/4826-custom-repeater-field-input-title/
- 1 reply
-
- 1
-
Yeah, what happened to your menu header? It's there for me, along with the new logo.
-
I think this is what you are looking for: $datetime = strtotime("2014-03-01"); $sp = $pages->find("modified>$datetime"); foreach($sp as $p){ echo "<p>{$p->title}</p>"; } Just swap out modified for created if that's what you want.
-
Well it sounds like you are only after those templates with a template file. Actually can't think of how to do this with a selector right now, but you could find all parents of the page and then foreach through these and do a: foreach($page->parents as $parent){ if($parent->viewable()) { echo $parent->title; break; } } https://github.com/ryancramerdesign/ProcessWire/blob/03387f8283d518e9cc405eff8f05cd6a5bf77c4c/wire/modules/PagePermissions.module#L166 The will not only check to see if there is a template php file, but also check to make sure the user has view permission for the template. I haven't tested this, so I am not sure if the echo page title will be the closest parent or not, but hopefully it might get you going in the right direction?
-
Really great writeup teppo - I feel like this should be posted somewhere upfront. As you so eloquently stated it really is PW's ability to use pages and custom field types with the selector engine, but then if you really need it, it's not difficult to integrate full custom database tables with SQL queries. It's that combo that sold me too!
-
Sorry about that - I did have a quick look for that, but missed it. Apparently I wasn't searching with: http://processwire.com/talk/topic/4510-field-type-json/?p=44317
-
MVC Options: http://modules.processwire.com/modules/spex/ http://processwire.com/talk/topic/4892-an-almost-mvc-approach-to-using-templates/ http://processwire.com/talk/topic/3587-templates-mvc-recursion-etc/ http://processwire.com/talk/topic/5031-get-started-with-pw-mvc-module-by-harmster/ A few links to get you going on understanding what a page really is: http://processwire.com/talk/topic/5059-2-question-about-pages/ http://processwire.com/talk/topic/5325-database-table-versus-pages/ http://processwire.com/api/variables/pages/ http://wiki.processwire.com/index.php/Page_Field
-
Well assuming keywords and license are in the same format, have you tried foreach'ing through $license like you did with $keywords?
-
http://processwire.com/talk/topic/5660-form-builder/
- 1 reply
-
- 1
-
Great idea Steve - I'll do that for sure. Done and committed!
-
Several of the outstanding issues and a couple of bug fixes have been taken care of this morning. Be sure to grab the latest from Github EDIT: Even more issues taken care of this afternoon. Updated in post #47 above.
-
No problem at all. I learned some things along the way Speaking of which, here is a much more concise version of the script using the ImageSizer approach I picked up from Soma at some point: $cp = $pages->get(1157); $cp->of(false); foreach($cp->fields as $imagesfield){ if($imagesfield->type == "FieldtypeImage" || $imagesfield->type == "FieldtypeCropImage"){ foreach($cp->$imagesfield as $image){ $ImageSizer = new ImageSizer($image->filename); $ImageSizer->resize($imagesfield->maxWidth,$imagesfield->maxHeight); } } } As for the memory issues. If it's just max_execution_time that should be an easy fix. If it is also memory related then you might come up against a barrier, no matter where you set the limit if you have too many images. You might need to do it in batches, which you could automate by simply adding a check to see if the dimensions of the image already match what they are meant to be. That way on each batch you'd skip by those that have already been resized. I think that might be a decent approach, but maybe someone else will chime in on this. You also might be better off bootstrapping PW from a php file and running that from the command line.
-
This is fantastic teppo! I don't necessarily think you should (as it may make the module unnecessarily complex), but do you have any plans to implement any of the SwiftMailer plugins like Decorator, AntiFlood, and Throttler? I use these for sending out bulk emails to subscribers. I think perhaps in these cases it is simpler if we just include swiftmailer separately in the appropriate template/module code, but thought I'd raise it in case you have any ideas along these lines.
-
Here's the same deal with a crop image field. Before: After: Maybe not terribly helpful sending you screenshots of it working for me though EDIT: I can't imagine why it would matter, but are you running PW 2.4 on this site? I am testing on 2.4.1. MORE THOUGHTS: Are the initial images that you're trying to resize named without the dimensions suffix? I assume so, but just checking. Maybe you could send screenshots of your before and after and also the before and after filenames in the 1157 folder. Might help us figure it out.
-
Ok, here is my test. I emptied the Max Dimensions settings and uploaded two images and got this: Then I went and changed the Max Width setting to 50 and left the height blank. Then I ran that script I gave you and then reloaded the page and I see this: That is the behaviour you're looking for - right?
-
Weird - just to be sure, you are definitely using the second script that I posted above? I just tested again and it works fine on multiple images in a field. Could you maybe post the exact code you are using if it differs at all from what I posted and maybe detail out all the settings for your images field. I can't think of what the issue might be at the moment.
-
Hey Marty, I did a quick test with a CropImage field and so long as you change: if($imagesfield->type == "FieldtypeImage"){ for if($imagesfield->type == "FieldtypeImage" || $imagesfield->type == "FieldtypeCropImage"){ it seems to work fine. Of course it will only resize the main image, and not the cropped version. I haven't tested this with Custom Upload Names yet, but I can't think of any reason why it wouldn't work.
-
Hey Marty, I'll take a stab at this. There are a few issues as I see things: The Max Image Dimensions setting: "..... does not affect any images in the system, or images added via the API." but you have noted that already. From your explanation it sounds like the images are already installed. You could resize everything using the API, but then you'd end up with the original sized one as the main image still, but will the sized variation available - I don't think this would help much. So if you upload using the API, you'll need to do the resize yourself. Of course the $image->size() method in the PW API will add the .XxY suffix to the filenames. So I have a couple of scripts for you. This first one allows you to install an image using the API and have it resized to match the Max dimensions settings. This assumes your images field is called "images". I don't think this specifically helps you since you already have the images installed, but I wanted to post this in case it helps someone else. Read below for the next version which I think does what you need. $cp = $pages->get("/"); $url_to_image = "http://ian.umces.edu/images/ian_banner.png"; $cp->images->add($url_to_image); $cp->of(false); $cp->save("images"); $pagefile = $cp->images->last(); $imagesfield = $cp->fields->get("name=images"); $filename = $pagefile->filename; $pagefile2 = null; if($imagesfield->maxWidth && $pagefile->width > $imagesfield->maxWidth) { $pagefile2 = $pagefile->width($imagesfield->maxWidth); unlink($pagefile->filename); rename($pagefile2->filename, $pagefile->filename); $pagefile->getImageInfo(true); // force it to reload it's dimensions } if($imagesfield->maxHeight && $pagefile->height > $imagesfield->maxHeight) { $pagefile2 = $pagefile->height($imagesfield->maxHeight); unlink($pagefile->filename); rename($pagefile2->filename, $pagefile->filename); $pagefile->getImageInfo(true); } I think this code should do what you need. Obviously the first line sets the $cp to the home page, so you'll need to adjust as necessary. After that it runs through all the image fields on that page and resizes the images to match the values in the Max Dimensions settings. Let me know how you go with it. $cp = $pages->get("/"); $cp->of(false); // required for a single image field foreach($cp->fields as $imagesfield){ if($imagesfield->type == "FieldtypeImage"){ foreach($cp->$imagesfield as $pagefile){ $filename = $pagefile->filename; $pagefile2 = null; if($imagesfield->maxWidth && $pagefile->width > $imagesfield->maxWidth) { $pagefile2 = $pagefile->width($imagesfield->maxWidth); unlink($pagefile->filename); rename($pagefile2->filename, $pagefile->filename); $pagefile->getImageInfo(true); // force it to reload it's dimensions } if($imagesfield->maxHeight && $pagefile->height > $imagesfield->maxHeight) { $pagefile2 = $pagefile->height($imagesfield->maxHeight); unlink($pagefile->filename); rename($pagefile2->filename, $pagefile->filename); $pagefile->getImageInfo(true); } } } } Both examples are quite verbose and I am sure could be optimized quite a bit, but should get the job done. I did some testing and they both seem to work just fine.
-
Thanks Marty - I'd really appreciate that
-
I am not having any issues specifically with the description not being available. However, I notice that the toggle expansion arrows for each field are not showing. Maybe there is a clue with that though? Just about to post this when I saw that you have fixed it - seems like it was related to the missing toggle arrows
- 2 replies
-
- 1
-
- fields
- description
-
(and 1 more)
Tagged with: