I don't understand the need for that process. There may be something I have
missed in terms of how Sapphire handles custom classes and objects, but to
me that code should never work in the desired application.
As I pointed out and Hamish expanded on, that code should not work without
the Project class extending one of the base classes first to open the
resulting objects up to the Framework. (DataObject or Page, or a child class
of either).
First, this class is setting and expecting functionality from a DataObject
property in the first line without the class extending DataObject or a
child. Second, there is no way to enter data in the CMS for Project objects
since the class is unknown to Sapphire (so there can't be any data yet
unless it was manually entered). Lastly, any Silverstripe template controls
won't do anything, since Project objects are not known to the framework
those controls are part of.
It may just be a simple typo in the email example. But it's worth
confirming.
A
----- Original Message -----
From: "nicolaas" <[email protected]>
To: "NZ PHP Users Group" <[email protected]>
Sent: Tuesday, October 12, 2010 10:58 PM
Subject: [phpug] Re: has_many relationship view issue
what version of SS are you using? Your setup should work. What do
you place between <% control Projects %> AND <% end_control %> - I
mean, how do you know it is not working? Is it placed in the right
area?
Firstly, add the following function to your HomePage class:
function Projects() {
return "hello world";
}
in your template, replace the <% control Projects %>..<% end_control
%> section with $Projects....
You should see hello world appear on your site now.
Next, undo the changes to your tempalte (go back to <% control
Projects %>...<% end_control %>)
Then, add the following function to your HomePage class:
function Projects() {
return DataObject::get("Project", "HomePageListing = ".$this->ID);
}
If that does not work then there is an issue with your data.
If it does give results now, then come back and ask again.
Cheers
nicolaas
--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]