Thursday, June 2, 2011

Re: Some core helpers not available within elements

did you include them in the controller?

maybe you use $html = something or $text = somethingElse
this would break the objects of $this->Html and $this->Text as well...


On 1 Jun., 13:51, the_nerd <thenerd...@gmail.com> wrote:
> Hi all,
>
> Some core helpers are not available within an element.
> e.g. (file = 'views/elements/event/event_teaser.ctp')
>
> In this element I have some HTML to show a teaser about an event.
> I want to truncate the content text, so i'm using the Truncate
> function of the Text Core Helper => this throws the following
> exception
>
> My code:
> <div class="entry">
>                 <?php echo $this->Text->truncate($theEvent['Event']['content'], 150,
> array(
>                                                                                                                                                                 'ending' => '...',
>                                                                                                                                                                 'exact' => false,
>                                                                                                                                                                 'html' => true
>                                                                                                                                                                 ));
>                 ?>
> </div>
>
> The error:
> Notice (8): Undefined property: View::$Text [APP/views/elements/event/
> event_teaser.ctp, line 6]
> Fatal error: Call to a member function truncate() on a non-object in /
> Applications/MAMP/htdocs/flanders_events/website/app/views/elements/
> event/event_teaser.ctp on line 6
>
> I'm having the same troubles when i use the Time core helper.
> But the strange thing is, i can use the Html helper without a problem
>
> Is there something I'm forgetting?

--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: