Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8390993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:08:30+00:00 2026-06-09T19:08:30+00:00

Fairly experienced programmer but new to CakePHP 2.1 and spending my day struggling to

  • 0

Fairly experienced programmer but new to CakePHP 2.1 and spending my day struggling to get a custom Helper to work in View by following the manual: http://book.cakephp.org/2.0/en/views/helpers.html

I’ve not been able to find an answer and would greatly appreciate any Cake expertise.

My helper file in app/Helper/EntriesHelper.php:

App::uses('AppHelper', 'View/Helper');

class EntriesHelper extends AppHelper {

    public function __construct(View $view, $settings = array()) {
        parent::__construct($view, $settings);
    }

    public function spanWrapper($content) {

        if(substr($content,0,1) == "@") {
            return "<span class='label label-warning'>$content</span>";
        }
        else if(substr($content,0,1) == "#") {
            return "<span class='label label-default'>$content</span>";
        } 
        else if (substr($content,0,4) == "http" || substr($content,0,3) == "www") {
            return "<span class='label'>$content</span>";
        }

        return $content;

    }

}

And my controller in app/Controller/EntriesController:

App::uses('AppController', 'Controller');

class EntriesController extends AppController {

    public $helpers = array('Form', 'Html', 'Js', 'Time');

    #public $components = array('RequestHandler');

    #public $viewClass = 'Json';

    public function index() {

        $helpers[] = 'spanWrapper';
        $this->Entry->recursive = 1;
        $this->set('entries', $this->paginate());
        #$this->set('_serialize', array('entries'));

    }
}

But a call from my View fails:

$this->Entries->spanWrapper($entry['Entry']['title']);

With the error:

Notice (8): Undefined property: View::$Entries [CORE/Cake/View/View.php, line 806]
Fatal error: Call to a member function spanWrapper() on a non-object in <path removed>/app/View/Entries/index.ctp on line 35

So the notice of undefined property is presumably causing the fatal error … but why so, if it’s implemented per the cookbook?

Darren

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:08:31+00:00Added an answer on June 9, 2026 at 7:08 pm

    The correct syntax is $this->helpers[] = 'spanWrapper'; when loading a helper within a method, or add it to your public $helpers array instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am fairly experienced C programmer but IOS is new for me. I do
I'm a fairly experienced programmer, but new to GUI programming. I'm trying to port
I'm a fairly experienced .NET desktop developer, but I'm new to Silverlight. I'm trying
I'm fairly new to Silverlight but experienced in web development, and I'm finding myself
I'm a fairly experienced web developer, but I've never needed to work with video
I am new to Symfony+Doctrine, but fairly experienced with web application development in general
I am fairly new to Rails, but I am pretty experienced with Ruby. Can
I have plenty of experience with this in PHP, but am fairly new to
Fairly new to programming. I just can't wrap my head around how to get
So, I am a fairly new programmer working towards an undergraduate Comp Sci degree

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.