-
Posts
259 -
Joined
-
Last visited
Everything posted by creativejay
-
Module Page Image Manipulator | API for 1 & 2
creativejay replied to horst's topic in Modules/Plugins
That solves the missing image. Unfortunately there's a new error now.. -
Module Page Image Manipulator | API for 1 & 2
creativejay replied to horst's topic in Modules/Plugins
As you saw, there's a path associated in the case of "without realpath" and "with realpath" outputs nothing. Sorry to lean on you heavily for this, I've never encountered this problem before. -
Module Page Image Manipulator | API for 1 & 2
creativejay replied to horst's topic in Modules/Plugins
Thanks! I am getting the 'UHM' version, though I'm not sure why. The results are: But the image does exist at http://www.creativejay.com/swatchmob/site/assets/images/authorwmk/swmb-mls.png so I'm really not sure what makes this path unreadable. Edited to add: I had the same problem if I called the URL from an image field (on the user's profile) as the PNG source, as well. -
Module Page Image Manipulator | API for 1 & 2
creativejay replied to horst's topic in Modules/Plugins
Thanks for the quick reply. Unfortunately this results in no change. The echo of $AlphaImageUser is the same for both wire("config")->... and $config->... (and both result in the correct path). -
Module Page Image Manipulator | API for 1 & 2
creativejay replied to horst's topic in Modules/Plugins
Okay, I've written a bit in Hanna Code editor, and I'm getting this error: Exception: Cannot read the pngAlphaImageFile! Now, if I echo the URL for the file I set as the watermark image, it's correct. Is this error referring to the way my file was saved? I used Photoshop's Save for Web, PNG-24, with Transparency, convert to sRGB. Is there something else I ought to be doing? I checked your sample action but I don't see save settings, and it has too much styling for what I want to do (and I'm using a smaller-than-image watermark). In case it's an error with my coding, here's my Hanna Code: <?php if(isset($img)) { $myImage = wire('page')->blog_images->eq($img); //echo $myImage->url; } else { $myImage = wire('page')->blog_images->first(); //echo $myImage->url; } if(isset($pos)) { // If the position is set, we're good } else { // otherwise we make sure the position is set to the default. $pos = 'SE'; } if(isset($pad)) { // If the padding is set, we're good } else { // otherwise we make sure the padding is set to the default. $pad = '2'; } $username = wire('user')->name; $AlphaImageUser = "{$config->urls->assets}images/authorwmk/swmb-{$username}.png"; // echo $AlphaImageUser; $pngAlphaImage = $AlphaImageUser; if($myImage != '') { // Here's where the PageImageManipulator watermark code goes $imgsrc = $myImage->pimLoad('SwMb')->watermarkLogo($pngAlphaImage, $position=$pos, $padding=$pad); // **this is the line triggering the error $newimg = $imgsrc->height(400)->url; echo $newimg; echo "<a href='{$imgsrc->url}' title='Click for Full Size' /><img src='{$newimg}' class='align_center' alt='{wire('page')->title}' /></a>"; echo "<p><small>{$myImage->description}</small></p>"; } -
Module Page Image Manipulator | API for 1 & 2
creativejay replied to horst's topic in Modules/Plugins
Thanks, Horst, that's what I was afraid of figured! -
Module Page Image Manipulator | API for 1 & 2
creativejay replied to horst's topic in Modules/Plugins
Hi Horst, thanks so much for creating this module. I have a question regarding page images that are set to allow multiple uploads per page, and which are placed into the body with CKEditor. Is there a method you would recommend for attacking each of these images, or would I be better off forcing my authors to use Hanna to place their images and tuck the image manipulation call in the hanna code? -
Thanks! I edited my question above to include the link to the discussion whose module I used. I'm reaaaaally close! Of course not as close as I thought I was about 5 hours ago.. XD
-
I'm searching back through this discussion and not finding if anyone ever came up with a solution that prevented blog-author from editing other users' posts (other than their own). Was anything ever worked up or around to limit people to editing just their own content? EDITED TO ADD: Okay, I found this which blocks the users from editing other people's content: https://processwire.com/talk/topic/3875-module-to-add-userid-to-pages-and-control-edit-permissions/?p=37915 I'm getting there!
-
I agree, I'm looking at line 1841 in my (untouched) ProcessBlog.module. I see no reason that pages with template 'form-builder', 'blog', 'blog-widgets', 'swmb_error', or 'admin' should show up in that list. However, when I add 'parent=/blog-posts/' to the filter, the pending count returns to 0. I'm just the black child fluke-finder.
-
I just noticed that a superuser who created 9 pages that are unpublished OUTSIDE of the blog in the tree has a listing of 9 pages as pending in the Blog / Author dashboard. Not sure why, as the module seems to limit it to the blog-post template. I thought I'd mention it.
-
Thank you kongondo! As usual I can go to sleep trusting that the ProcessBlog Fairy will leave working PHP code underneath my pillow... This seems to be the line that made the difference "foreach ($authorsList as $key => $value) {" Got that working now! I'm sure I'll be back with something else soon! Thanks again!
-
As written, that only indexes the post count: Array ( [0] => 6 [1] => 1 [2] => 0 ) Not sure why it won't let me assign my variable as a key. Will tackle it more tomorrow.
-
It didn't quite work as-is. The list it output was the top user and the title of a post, one line for each post. Then it sorted the next user's single post. So it did sort correctly, but it didn't display the number of posts for that user and I only wanted one result per user. So I attempted to use the sort filter but of course since I was still searching users, not posts, it wouldn't work. In the screen below you see the table with the correct information but the wrong order. Beneath that is the order and information from your code.
-
Okay, I see your query was looking at blog-post, so the created_users_id.count applies to the field created_users_id which is part of a blog-post page. What I'm actually looking to do is sort the user list by the total (published) posts attributed to the user.. so I need to build that attribution somehow (before the query). What would you do? My brain keeps telling me I should create a new field for template user called user_post_count, and write a hook for each post save that would assign the value of created_users_id.count to that field. Is that too convoluted?
-
Yes, and bless you for that feature!
-
Hey, look at that! I stepped away before tackling the sort order and you did the work for me! I have to add some posts for the other users to test this, since for now post count order is the same as the default. I'll report back in a few minutes. Just wanted to say my thanks!
-
@kongondo is the total blog-post count for the user stored anywhere? I'm trying to list my authors (in a custom admin page) in order of post count (greatest to least). Anything you can think of that would do it? Thanks again! I see "$authorPublishedCnt = count(wire('pages')->find("template=blog-post, created_users_id={$author->id}"));" in ProcessBlog.module line 1840, which seems about what I'm looking for... though I'd like to subtract unpublished posts (which I can do with math in a later line if necessary). Is there a way for me to access created_users_id in admin? I tried that and createdUser but they both threw errors. I love how typing out a question to you almost always helps me think through it. Sometimes I'm lucky enough to be inspired to try something before I post the question. Other times, not so much. So the call I ended up using was: $points = count(wire('pages')->find("template=blog-post, created_users_id=$mobster->id")); The trouble I was having was that I was comparing the user id to the page name. Doink!
-
New to Hooks, trying to wrap my head around the syntax
creativejay replied to creativejay's topic in Getting Started
This is where it came out. I inferred that the "true" was as inappropriate as the rest of my call. I've added it back, and tested it with a title that ends in an exclamation point, and it works. Thanks! -
New to Hooks, trying to wrap my head around the syntax
creativejay replied to creativejay's topic in Getting Started
"Swatches" is the correct page title that's associated with that field. I swear I had $p->blog_categories->title == 'Swatches' a couple revisions ago (then I changed it to $p->blog_categories == '1040' and must have changed it back without adding the fieldname back). Anyhow, it's working now! Thank you EVERYONE! I would be proud, but you guys seriously did most of the work. I really appreciate it! Below is the final content of the module file (which is installed ). I'm posting the entire thing in case someone else is in need of help with the entire context situation. I'll mark this one as solved though really it's the culmination of the entire thread. Thanks, everyone, for bearing with me. <?php /** * ProcessWire 'Rename Swatches' module by forum user creativejay * * Checks to see if a page uses the template "blog-post" and has a $p->blog_categories->title value of "Swatches" then redefines the value of $p->title and $p->name * * * ProcessWire 2.x * Copyright (C) 2014 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://processwire.com * */ class RenameSwatches extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( // The module's title, typically a little more descriptive than the class name 'title' => 'Rename Swatches', // version number 'version' => 4, // summary is brief description of what this module is 'summary' => 'Checks to see if a page uses the template blog-post and has a blog_categories->title value of Swatches then redefines the value of title and name', // Optional URL to more information about the module 'href' => 'https://processwire.com/talk/topic/8863-new-to-hooks-trying-to-wrap-my-head-around-the-syntax/', // singular=true: indicates that only one instance of the module is allowed. // This is usually what you want for modules that attach hooks. 'singular' => true, // autoload=true:indicates the module should be started with ProcessWire. // This is necessary for any modules that attach runtime hooks, otherwise those // hooks won't get attached unless some other code calls the module on it's own. // Note that autoload modules are almost always also 'singular' (seen above). 'autoload' => true, // Optional font-awesome icon name, minus the 'fa-' part 'icon' => 'eraser', ); } public function init() { $this->addHookAfter('Pages::saveReady', $this, 'renameBeforeSave'); } public function renameBeforeSave(HookEvent $event) { $p = $event->arguments[0]; if($p->template->name === "blog-post" && $p->blog_categories->title == 'Swatches'){ $concatenatedName = $p->createdUser->name; $concatenatedName .= '-' . $p->blog_brand->title; $concatenatedName .= '-' . $p->blog_name; $concatenatedTitle = $p->blog_brand->title; $concatenatedTitle .= ' ' . $p->blog_name; $p->title = $concatenatedTitle; $p->name = $this->sanitizer->pageName($concatenatedName, true); $this->message("Changed title according to the new module."); } } } -
New to Hooks, trying to wrap my head around the syntax
creativejay replied to creativejay's topic in Getting Started
Too funny, ESRCH, yes, I did install it. But it's an even dumber question if you don't ask. And kongondo, fantastic catch on the blog-post, you're right about that (obviously, or my blog would've broken). Unfortunately there's another flaw in there somewhere. I added an echo within the if statement and it's not firing, so I assume the problem is with... if($p->template->name === 'blog-post' && $p->blog_categories == 'Swatches'){ -
New to Hooks, trying to wrap my head around the syntax
creativejay replied to creativejay's topic in Getting Started
Thanks ESRCH, I've updated that. It's still not quite firing now. About to try matching the category by page ID instead of title... EDIT: ... no change -
New to Hooks, trying to wrap my head around the syntax
creativejay replied to creativejay's topic in Getting Started
Here's the latest version, which still does not effect the change when I save a page. public function init() { $this->addHookAfter('Pages::saveReady', $this, 'renameBeforeSave'); } public function renameBeforeSave(HookEvent $event) { $p = $event->arguments[0]; if($p->template->name === 'blog_post' && $p->blog_categories->title == 'Swatches'){ $concatenatedName = $p->createdUser; $concatenatedName .= '-' . $p->blog_brand->title; $concatenatedName .= '-' . $p->blog_name; $concatenatedTitle = $p->blog_brand->title; $concatenatedTitle .= ' ' . $p->blog_name; $p->title = $concatenatedTitle; $this->sanitizer($concatenatedName, true); $this->message("Changed title according to the new module."); } } -
New to Hooks, trying to wrap my head around the syntax
creativejay replied to creativejay's topic in Getting Started
@kongondo your default blog_categories is, but I changed it to a Single Page field because of the way my (already familiarly strange to you) blog is structured. -
New to Hooks, trying to wrap my head around the syntax
creativejay replied to creativejay's topic in Getting Started
$p->blog_categories->title ? $p->createdUser->title ? And I should turn $p->blog_date into a string, I imagine?