-
Posts
4,077 -
Joined
-
Last visited
-
Days Won
87
Everything posted by horst
-
Hey @Ledzepman, here is a good reading about how to deal with urlSegments: https://processwire.com/docs/tutorials/how-to-use-url-segments/ And if you not already know it, best search results do you get with google like this: // searches the whole PW site https://www.google.com/search?q=site:processwire.com+urlsegment // only search in forum posts https://www.google.com/search?q=site:processwire.com/talk+urlsegment --- regarding to the check if a county page exists and taking the example from ryans tutorial, you can do it like this: // we are only using 1 URL segment, so send a 404 if there's more than 1 if($input->urlSegment2) throw new Wire404Exception(); // now check if there is no urlSegment1 if($input->urlSegment1 == '') { // display main content ... } else { // get you a PageArray of all county pages using a appropriate selector. This depends on how you have setup things $countyPages = $pages->get("/path/to/countyparentpage/")->children(); // build an array of what you need to validate, titles or names ? (I use their names in the example here) $validCounties = array(); foreach($countyPages as $cp) { $validCounties[$cp->name] = $cp->name; } // now check if it is a valid county if(isset($validCounties[$input->urlSegment1])) { // display county content ... } else { // unknown URL segment, send a 404 throw new Wire404Exception(); } }
-
No, it isn't in like you explained here, but it is somehow in without a double loop. But only when using a square boundary box and when the images are between the ratio aspects 1:2 -> 2:1. Images with more extreme ratio aspects are scaled none linear so that those are displayed smaller. So, the normal usage of weighten works like your description but is assuming the ratio aspect isn't wider than 2:1 / 1:2. When we add an additional param for the widest aspect ratio we should get the same effect as you described, I think. You first have to run a loop through the images, fetching their aspect ratios, and afterwards pass the highest value to the contain-weighten call. With images == photgraphs I think the average usage is well covered the way how it is setup now. But with logos it could be go much further with aspect ratios. Maybe you can drop in a small list of real logo usage aspect ratios (with extremes), so that I get a grasp of what we are talking here?
-
Best way to get random quote displayed on refresh?
horst replied to kathep's topic in Getting Started
Hi @kathep, welcome to PW and the forums. As with the most things here, there are no "right way" to do it. There are a few more or less equal but different solutions possible. What come into my mind are three variations: a) simply going with single pages b) going with repeaters c) going with Profields Pagetable I would go with single pages: 1) build a page called tools or something that only serves as parent for stuff that is not used to be displayed directly to the forntend. Set the page to hidden. 2) Build a template called category, it only needs a title field I think create a page under tools called categories that should serve as parent for your categories build child pages under categories that have the template category and the title are the names of your categories you need 3) Build a template called quotes, build the fields you need to be on a quotes page: quote_text = textarea quote_author = text quote_category = page, best is to use it with ASM select!, the source for it is the category parent! etc and assign them to the template Build a page under tools called quotes as parent for all single quote pages create your quote pages there (if you have to many for a manually creation, there are also automated import solutions available) If you have all setup you can get the quotes from every where in PW with a selector like this // get all quote pages $quotes = $pages->get("/tools/quotes/")->children(); // get all quote pages of a specific category $quotes = $pages->get("/tools/quotes/")->find("quote_category.title=category1"); // get all quote pages of a few specific categories $quotes = $pages->get("/tools/quotes/")->find("quote_category.title=category1|category2|category3"); // to get only one random out of those collections you call ->getRandom() at the end $quote = $pages->get("/tools/quotes/")->find("quote_category.title=category1|category2|category3")->getRandom(); If you get stuck at some point with this, come back and tell us. -
ok, then add a "include=all" to the selector, just to be sure that there are no pages get excluded because of restrictions! $result = $pages->find("has_parent=$p, include=all");
-
Have you double checked that the ids of your pages are correct? $ids = array(1050, 1080, 1090); foreach($ids as $id) { $parent = $pages->get($id); if (0 < $parent->id) { // page is found, lets call the selector $result = $pages->find("has_parent=" . $parent); echo "<p>found {$result->count} pages</p>"; } else { echo "<p>wrong ID for parent!</p>"; } }
-
Module: AIOM+ (All In One Minify) for CSS, LESS, JS and HTML
horst replied to David Karich's topic in Modules/Plugins
@MikeB & @JoZ3: has anyone of you opened an issue at Github? Maybe there it get better recognition. -
Yes it is. But you have to do it by yourself. And I think it isn't an easy task for a newbie. Maybe you read upon those links that Mr-fan has provided above? Maybe you will find another solution than to recoding the pages tree. And BTW: a tree is a tree, it starts from the roots and goes up until it reaches the top. I have never heard about a tree that groups his branches by colors of the leaves or by thickness of the branches. Mr-Fan has pointed you to Lister already.
-
to 1) I have read yes. You, as a developer, can run mails on behave of different clients. You can/should create subaccounts for each client and you also can point to subdomains of your clientdomains. This can be used to only have own domain names in the links of a mail. (create a sub.domain.tld and point its CName to your mandrill subaccount) to 2) I don't know what HIPAA-compliant is.
-
for users from phpclasses.org. Today I have read a bit from this podcast. A short explanation about Mandrill and transactional emails can be found right after the introduction in the text at "Mandrill by Mailchimp promotion for PHP Classes users (1:03)". You simply need to go to Mandril through a link or put in the promo code "phpclasses" on the Mandrill site. ALso they have a free plan for 12.000 per month without any promo code!
-
depending on your PW version: before 2.5: https://processwire.com/talk/topic/2942-or-in-pw-selectors/#entry29001 Hhm, cannot find it, but I could swear there is support for OR operators in selectors now in 2.5. Sorry, you need to search for it by yourself, maybe in the http://processwire.com/blog section. Or if someone reads this: do we have support for OR operators in PW 2.5 now? Where can we read about it?
-
I have updated the module to Version 0.1.0 beta and it has a new addition to the weighten option that can be used together with contain. The initial code I have taken for weighten calculations is from Martijn. I have changed it to simplify its usage so that you only need to specify a bounding square and have to switch it on, or additionaly prioritize landscape oriented images in two favours: x1, x2 or do the same for portrait oriented images with: y1, y2. (read more in the posts above) But if you (@Martijn ) like to use more different options, like with the original ImageFitBoundaries.module, you can use it by specifying different values for width and height together with the new value "comp##". For ## you set the value for compression like comp20, comp30, comp40 or whatever you like.
-
I'm not sure, but have you tried $pages->find("images.tags%=sport-1"); ?
-
$rowend = $member == $member->siblings->last() ? "</div>\n" : ( $key%3 == 0 ? "</div><div class=\"row\">\n" : '' ); ---------- ^--------------------------------------------------^ not tested but I'm pretty sure. You use surrounding braces where not needed, but not where they are needed.
-
It would be great if the wireMail function could be used for sending emails instead of the php mail function. This way people would be able to use it together with their favourite mail extensions. For example with SMTP support: wiremail-swiftmailer or wiremailsmtp
-
exactly! You can call size() with second param = 0 (zero), what is the same as calling width(). Pageimage::size build the names according to passed values for width, height and optional options for cropping and suffix: basename.widthxheight-suffix.ext and the code of the function for blog images should be look like that, because there is no $event->arguments(2) available like it could be when calling from templatecode: public function sizeBlogCloud($event) { $image = $event->object->getPageImage(); $width = (int) $this->input->get->width;//$event->arguments(0); // $height = (int) $this->input->get->height; //$event->arguments(1); // not needed here, or set it to 0 $options = array(); if ($width < $image->width) { // add a suffix if it is a resized version, don't add a suffix if it is the original unresized image $options["suffix"] = array("is"); } $resized = $image->size($width, 0, $options);
-
Ok, that -is suffix is also new to me, at least that it is implemented now. I remember we (Ryan, Nico, me) have had a talk 6 month ago that it would be good if image variations belonging to RTEs get flagged somehow. Without a flag there is / was a great chance that they get deleted with a call for $image->removeVariations(). Whereas all API created image variations in templates get recreated on demand after such a call, RTE-belonging images don't get recreated and the pages output was / is broken. Therefore it is a good implementation to flag them. @mike131: I think you should add the same code to your emulation: $image = $event->object->getPageimage(); $width = (int) $this->input->get->width; $height = (int) $this->input->get->height; $options = array(); if ($width < $image->width) { // add a suffix if it is a resized version, don't add a suffix if it is the original unresized image $options["suffix"] = array("is"); } $resizedImage = $image->size($width, $height, $options); $filename = $resizedImage->filename; ...
-
If I read it right, Blog want to get those, but why? Where is the code that do that? I don't know Blog (module / profile?). Suffixes are introduced since PW 2.4.15. Suffixes can be added to a variation name with the options: // if the original images name is basename.ext, the call for a width with a suffix "is" $options = array("suffix" => "is"); $image->width(200, $options); // results in this variation name: basename.200x0-is.ext So, the question is: Why, where or how does Blog trigger to create a variations name with suffix "is"? Pageimage::size builds the variationnames according to width, height, and the optional options cropping & suffix. Pointing me to the code would be of help. EDIT: Ah, now I saw that you hook into a process and "emulate" it by yourself: $this->input->get->width; Have a look to the original function and see if it defines / set a suffix named "is". If so, you need to add it to your emulation too. This will be fairly simple, if it is a static suffix. EDIT2: The line seems to be here: https://github.com/ryancramerdesign/ProcessWire/blob/dev/wire/modules/Process/ProcessPageEditImageSelect/ProcessPageEditImageSelect.module#L342
-
Steve (@netcarver) has written a parent - children system with Diagnostics. This sort of parent module recognizes and lists installed children in the configscreen and should provide some basic functionality: Martijn's AdminCustomFiles. Anything more that is needed?
-
To get the part of the url you can use parse-url
-
Very well done site! But IMO there is room for a little aprovement regarding the popup slideshow. The overlay is to much transparent. The color of the blueimp-overlay-div is set to rgba with 0.7 and additionaly to this a opacity of 0.5 is aplied. As the result the page content is not coverd enough and interferes with the presentation of the projectimages. EDIT: What I mean is that the images are more outstanding in the second screen, on a darker, less transparent background / overlay:
-
Hiding a container folder inside Breadcrumbs nav?
horst replied to PhotoWebMax's topic in API & Templates
If one want to exclude all hidden pages one may use: if ($item->isHidden()) continue; -
I'm not sure if I understand you right. But if you cannot add the hook on template layer, you need to create a module: <?php class SizeToCloud extends WireData implements Module { static public function getModuleInfo() { return array( 'title' => 'Size To Cloud', 'summary' => __('This module handles relations between pageimages and S3 cloud', __FILE__), 'version' => '0.0.1', 'author' => '', 'href' => '', 'singular' => true, 'autoload' => true, // 'requires' => array('PHP>=5.3.8', 'ProcessWire>=2.5.0') ); } public function init() { $this->addHook('Pageimage::size2cloud', $this, 'size2cloud'); } public function size2cloud($event) { $image = $event->object; // the event object is a pageimage $width = $event->arguments(0); // first argument to pageimage::size is the width $height = $event->arguments(1); // yes, second is height $options = is_array($event->arguments(2)) ? $event->arguments(2) : array(); // and optional an options array can be passedd // now do the manipulation and catch the resulting variation object $imageVariation = $image->size($width, $height, $options); // get the filename for your cloud stuff $filename = $imageVariation->filename; // do your stuff here ... // // return the variation pageimage object // return $imageVariation; // what do you need to return here? } } This example code should be saved as a file named SizeToCloud.module. It should be cpoied under site/modules/SizeToCloud/SizeToCloud.module Then refresh your modules section find it under new and install it. For more on Modules refer to the docs and to the HelloWorld.module what is a super good example module with all commented.
-
You may refer to all that is related to pageimages in the docs and the cheatsheet. You can everything derive from the pageimage object! For example go to the cheatsheet and select the advanced button, then filter for files (images are also instances of files), and voila, you will see that files have ->page. So you can use $image->page->id for the id, and everything else what belongs to page. Have a look at the cheatsheet for page. (use the advance button and / or click onto the properties and methods and then onto the more links)
-
What do you want to do? You want add / copy / submit all final files of a resize manipulation (one of width, height, size) additionally to a cloud? This can be done by simply get the filename after a manipulation. For this you may add your own wrapper to the pageimage functions. There is also no need to change width or height to size, because width and height are only wrappers for size. Finally size is called for all pageimage manipulations. You can add a simple hook to pageimage like this: wire()->addHook("Pageimage::size2cloud", null, function($event) { $image = $event->object; // the event object is a pageimage $width = $event->arguments(0); // first argument to pageimage::size is the width $height = $event->arguments(1); // yes, second is height $options = is_array($event->arguments(2)) ? $event->arguments(2) : array(); // and optional an options array can be passedd // now do the manipulation and catch the resulting variation object $imageVariation = $image->size($width, $height, $options); // get the filename for your cloud stuff $filename = $imageVariation->filename; // do your stuff here ... // // return the variation pageimage object // return $imageVariation; // what do you need to return here? }); // in your templates now you call the images like $image->size2cloud( 200, 0); // or $image->size2cloud( 200, 200, array("crop"=>false, "quality"=>70, "sharpening"=>medium)); // or $image->size2cloud( 0, 200); This can be set into a template file, e.g. if you have something like a inifile that is included into all template files. Or, if do not use this technique, you build a module from the function.
-
The line is an example, I wanted to suggest that you use one of them, that one that makes most sense. I said use this or that. If you only use PHP functions that are available with e.g. PHP 5.3, you simply can require PW>=2.4, because PW 2.4 itself requires PHP 5.3.8 or greater. But if you have a module that also would run with PW 2.2 or 2.3 regarding the PW core, but needs PHP version >= 5.4, then you must require PHP >= 5.4. I always would note the PW version, and only if the needed PHP is higher than the minimum required for PW I would note this additionally. I think the only situation not to note the PW version would be if your module run on all versions from 2.2 - 2.5. EDIT: Ah, now I understand. I have downloaded your new version: I don't know which versions your module need, sorry for confusion. It was only an example that should provide the typo, not the correct values / versions. I think you need PHP 5.3.0 because of the namespaces, but which version of PW it works with I don't know. Maybe >= 2.3 or >= 2.2 ? A hook to page::render is not one of the recently added functions.