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?
I coded this:
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
<?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
the loader loads the class into memory so you need to instantiate the controller
Loader::block('reviews');
$cnt = new ReviewsController();
Loader::block('reviews');
$cnt = new ReviewsController();
The class name is probably different because the controller is located in a 'reviews' package.
You should do $bc = new ReviewsReviewsBlockController();
You should do $bc = new ReviewsReviewsBlockController();
thanks everyone for the feedback!
that should do it.
Mike