Hello,
I know this looks weird, but I'll try to explain my reasons and hope
some of you might be able to point me in the right direction.
I'm building a quite complex system, with lots of inner connections.
One thing that I need to do quite often is to notify users (by email)
based on some system changes.
At first I was doing pretty much everything in the controllers, but
then I found out that I was having a lot of similar code in some of
them. So my first thought was to access a controller's action from
another controller. After searching this group I came to the
conclusion that this was a bad thing to do and to access one
controller from another is bad practice. So I decided to move this
logic to a model. My reason was because models can pretty much be
universally accessible very easily.
Everything was working great, until I tried to get a view using the
Controller::render() function. I wasn't planning on displaying the
view from the model, of course. My idea was to send some variables
that I just got from the database to the view ( using set() ) and then
storing the render result to a variable. This variable is the body of
the email that I would send to the user.
I was trying to call render like this from my model:
$emailBody = Controller::render('/elements/email/html/body', 'email/
html/default' );
but I got a warning, a notice and a fatal error:
Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near 'beforeRender' at line 1 [CORE/cake/libs/
model/datasources/dbo_source.php, line 684]
Query: beforeRender
Notice (8): Undefined property: Conflict::$Component [CORE/cake/libs/
controller/controller.php, line 864]
Fatal error: Call to a member function triggerCallback() on a non-
object in /Users/x/Documents/www/cake/libs/controller/controller.php
on line 864
I was wondering what would be the right way to do this.
Please let me know if I was able to make myself clear.
Thanks a lot,
Burningfuses
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php