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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:44:55+00:00 2026-05-16T22:44:55+00:00

I have a model class (obviously, it extends Doctrine_Record) that acts as a custom

  • 0

I have a model class (obviously, it extends Doctrine_Record) that “acts as” a custom template.

I want to get values like this: “echo $record->virtual_field”. Is there a way to override the getter method in my custom template to provide a custom response, then either pass on the request to the parent class or not?

In other words, is there a way to override Doctrine_Record::__get() from a related template?

  • 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-16T22:44:55+00:00Added an answer on May 16, 2026 at 10:44 pm

    Ok. I assume you’re not talking about actual Behaviour ‘actAs’ Templates.

    If you define a new __get() method, it will automatically override the parent’s __get() method.

    Now in your new __get() method, you first check if it exists in your current instance, and then the parent’s.

    I hacked this together (bear in mind, it’s almost midnight):

    <?php
    class bar {
    public $data = array();
      public function __construct() {
        $this->data['virtual_field'] = "set in bar";
      }
    
      public function  __get($name) {
        if(array_key_exists($name, $this->data)) {
          return $this->data[$name];
        }
        return null;
      }
    
      public function __set($name, $value) {
        $this->data[$name] = $value;
      }
    }
    
    class foo extends bar {
    public $data = array();
      public function __construct() {
    
      }
    
      public function  __get($name) {
        if(array_key_exists($name, $this->data)) {
          return $this->data[$name];
        }
        if (parent::__get($name))
          return parent::__get($name);
    
        return null;
      }
    
      public function __set($name, $value) {
        $this->data[$name] = $value;
      }
    }
    
    $a = new foo;
    echo $a->virtual_field;
    

    Now I dont know how well this works for what you are trying to achieve.

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

Sidebar

Related Questions

I have a model class like this: class Note(models.Model): author = models.ForeignKey(User, related_name='notes') content
I have a model class that uses a custom validator as shown in following
I have a model class ModelHome that is a child of Model ie: class
Assume I have this model : class Task(models.Model): title = models.CharField() Now I would
Let's say I have a model class called Project, but instead of this: class
I currently have a model set up like so: I have a Test class
I have the following model: class A(models.Model): name = models.CharField(max_length=50) content_type = models.ForeignKey(ContentType) This
Suppose I have this model: public class ViewModel { [Required] public string UserInput {
I have Group model that has_many institutions, and schools. class Group has_many :institutions has_many
I have this simplified model: class Item(models.Model): name = models.CharField(max_length=120) class ItemImage(models.Model): image =

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.