-
Posts
45 -
Joined
-
Last visited
Community Answers
-
Ovi's post in Image Field description not saving was marked as the answer
The solution is here: https://processwire.com/talk/topic/12375-urgent-will-pay-help-debugging-image-fields/
-
Ovi's post in can't access image field was marked as the answer
OMG. Found the error! This needs to be a cautionary tale to others.
I had this code in the head section:
<?php if ($page->template = "typical-day"): ?> <!-- some files get added here--> <?php endif ?> As you can see there is a "=" sorely missing there (i miss-typed or was just tired, have no clue how it happened).
So it ended up changing the template of the page instead of just checking if it was set to "typical day". The "typical-day" template obviously did not even have the "homepage_slideshow" field assigned to it.
On the bright side
That is something very cool to be able to do (changing the template on run-time), which might have some interesting applications. Is that something one should do or should we stay away from it?
-
Ovi's post in Getting database.php error on image fields creation / editing was marked as the answer
Figured it out finally: Servint bungled things up and installed APC and Eaccelerator together No wonder things got screwy.
Thanks for all your help Ryan, you rock.
-
Ovi's post in Failing to hook from one custom module into another was marked as the answer
It's working!
I was missing $page->setOutputFormatting(false); and $page->save();
Working module:
<?php class PageAverageRating extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Copy average rating into hidden field', 'version' => 100, 'summary' => 'Copies the average rating to another field', 'singular' => true, 'autoload' => true, ); } public function init() { $this->addHookAfter("CommentFormWithRatings::processRatingInput", $this, 'copyAverageRating'); } public function copyAverageRating() { $page = wire('page'); // get access to the page $page->setOutputFormatting(false); // without this we can't save the page later on // we're interested in product pages only: if($page->template->name != 'product') return; // use the existing averageRating method to get the average rating and store it in the field // we created called average_rating: $page->average_rating = $page->product_comments->averageRating; $page->save(); } } Many thanks Antti, Soma and of course Ryan, you guys rock. This is finally starting to make sense for me.
I think i will write a guide to help people like me get started with module development.