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

  • Home
  • SEARCH
  • 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 6717461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:51:18+00:00 2026-05-26T08:51:18+00:00

Title says all. I’ll have navigation that looks like this and it’s dynamically created

  • 0

Title says all. I’ll have navigation that looks like this and it’s dynamically created from database.

<ul>
    <li><a href='controller/view/1'>1</li>
    <li><a href='controller/view/2'>2</li>
    <li><a href='controller/view/3'>3</li>
</ul>

It should be same on every page (by page, I mean on every controller), except for the active one. It’s my first time in cakephp.

This is my elements file:

<ul id="left-navigation">
<?php
App::import('Model','Godina');
$navigacija = $this->Godina->find('all');
foreach($navigacija as $nav){
echo '<li>' . $this->html->link($nav['Godina']      ['godina'],array('controller'=>'godina','action'=>'program',$nav['Godina']['godina'])
) . '</li>';
}

?>

And this is the error that I am getting.

Fatal error: Call to a member function find() on a non-object in     /Applications/MAMP/htdocs/cakephp/app/View/Elements/godineNavigacija.ctp on line 4

And since my knowledge of cakephp core is quite low, it just doesn’t work.
Thanks.

  • 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-05-26T08:51:19+00:00Added an answer on May 26, 2026 at 8:51 am

    App::import just loads the file, like PHP’s include, it does not instantiate an object. So $this->Godina does not exist. You can do this:

    $Godina = ClassRegistry::init('Godina');
    $Godina->find(...);
    

    For proper MVC separation, you should not use models in the view though. You can fetch and set the data in AppController::beforeFilter, so it does it on every page, then output in the view. Alternatively, look into requestAction.

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

Sidebar

Related Questions

The title pretty much says it all. If I have something like (from PHP
I guess the title almost says it all. My original url looks like: http://www.something.com/buy/index.php?p=025823
The title pretty much says it all. I have a regex that I need
The title basically says it all. I mainly want to do this so that
Title pretty much says it all. The web.config, unchanged from how VS2008SP1 generated it,
Title more or less says it all. Specifically, I've become increasingly annoyed that in
The title basically says it all. I have a hexadecimal string representing a private
title pretty much says it all. I have a website which will only run
The title pretty much says it all. A cookie seems to have a few
The title just about says it all. I have a complex EF4 entity object

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.