Loading a block controller outside of the block output.

Permalink
I have downloaded the add on "Reviews" and i want to display the average rating on a product page but I dont want the average rating to be shown inside the block that i have added to my product page. Im trying to call the class and instantiate it so i can use the functions outside the actual block. The class is located in packages/reviews/blocks/controller.php. How can I do this?

 
Mnkras replied on at Permalink Reply
Mnkras
Loader::block('reviews');


that should do it.

Mike
glin425 replied on at Permalink Reply
I coded this:


<?php $reviews = Loader::block('reviews'); ?>
                <?php     echo $reviews->outputRatingDisplay($reviews->getAverageRating()); ?>


I am still getting an error.

Fatal error: Call to a member function outputRatingDisplay() on a non-object in /home/orangeseal/www/sitecopy/blocks/product/templates/product_details.php on line 102
guyDesign replied on at Permalink Reply
the loader loads the class into memory so you need to instantiate the controller

Loader::block('reviews');
$cnt = new ReviewsController();
A3020 replied on at Permalink Reply
A3020
The class name is probably different because the controller is located in a 'reviews' package.

You should do $bc = new ReviewsReviewsBlockController();
glin425 replied on at Permalink Reply
thanks everyone for the feedback!