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 5841577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:54:27+00:00 2026-05-22T11:54:27+00:00

I have in my view a partial containing a partialLoop. But when I run

  • 0

I have in my view a partial containing a partialLoop.
But when I run the page I have the following error message:

Call to a member function countComments() on a non-object in ...'_loop.phtml'

This is how I call my partial from within my view:

echo $this->partial('_post.phtml',$this->post);

where $this->post is a DB retrieved row

This is my partial’s content:

MY simplified Partial! 

echo $post->countComments();//the count number is correctly output..
echo  $this->partialLoop('_loop.phtml',$this->object);

This is my partialLoop’s content:

echo $this->object->countComments();//no output!

In the bootstrap I have set:

$view->partial()->setObjectKey('object');
$view->partialLoop()->setObjectKey('object');

Is this the right way to call partialLoops from within partials??

P.s. I var_dumped $this->object inside my partial and it is a PostRow OBJECT.I var dumped $this->object into _loop.phtml and I have 5 NULLS (standing for id,title,text,author,datetime fields of my post)

thanks

Luca

  • 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-22T11:54:28+00:00Added an answer on May 22, 2026 at 11:54 am

    I think that the reason is that when you pass $this->post into partial view helper like this:

    $this->partial('_post.phtml',$this->post);
    

    partial view helper will execute its toArray() method. Hence, your $this->object is an array and you are passing an array to your partialLoop. So, in your partialLoop you are trying to execute countComments() on an array representing your row post object, rather than actual row object.

    To avoid this, I would recommend passing variables to partial and partialLoop view helpers using array notation, e.g:

    $this->partial('_post.phtml',array('post' => $this->post));
    

    Hope this helps.

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

Sidebar

Related Questions

I have a partial view which contain JavaScript and Ajax, but does not run
I have a page containing a partial view with a list and a partial
I have two partial view and I want to call one of them in
I have multiple pages containing the same partial view. The partial contains a form
I have an Index View, where I got a form containing a partial view
I have a large Ruby on Rails form that has the following partial view
I have a view page with ajax.action link which returns a partial view from
I have a layout page within that layout I have used a partial view,
I have the following code in a partial view: @model MyOrganization.MyApp.Models.ProductListing @using (Ajax.BeginForm(TagProduct, new
I have a view Details which consists of a partial view _Tabs and a

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.