21280 Posts in 5729 Topics by 2600 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 354 Views |
-
Adding additional values to a DataObjectSet

14 July 2011 at 12:10am Last edited: 14 July 2011 12:11am
Hi All,
This is probably something really simple that I am missing here.
Basically building an item management system for frontend users to manage their own items. I have everything working fine except for one thing and I am sure it is something really simple that I just haven't found yet.
Essentially what I am asking is, is there a way to push a new column of data onto each row in a return DataObjectSet
So for example if I had FirstName (Colin) and Surname (Burns) and I wanted to create a new column called NickName which I created by the first letter of the FirstName and the Surname (cburns). I want know how to create this column in the logic and push it onto my DataObjectSet.
N.B: There is probably a way to do this specific example in the template, but that's not what i am looking for. I've deliberately tried to use a really simple example as a demonstration.
if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
$SQL_start = (int)$_GET['start'];
$AllItems = DataObject::get(
$callerClass = $thisClassName, // enter the Object type (e.g. 'MyPageType')
$filter = "ItemType = 'want' AND Status = '{$thisStatus}' AND MemberID = '".Member::currentUserID()."'",
$sort = "Created DESC, Value DESC",
$join = "",
$limit = "{$SQL_start}, $itemsPerPage" // enter the number of items per page (int)
);// So I guess in here I would need to loop through the DataObjectSet using two of the fields in it to create a new field and then push it onto the DataObjectSet
return $this->customise(array('AllItems' => $AllItems))->renderWith('ajax_ListManagement_All');
Any suggestions would be grand
Cheers,
Colin -
Re: Adding additional values to a DataObjectSet

14 July 2011 at 12:24am Last edited: 14 July 2011 12:24am
how about...
if ($AllItems) foreach ($AllItems as $item) {
$item->NickName = $item->FirstName.'_'.$item->Surname;
}I do it all the time...
-
Re: Adding additional values to a DataObjectSet

14 July 2011 at 12:30am
Thanks for the reply, I will give it a shot.
I told you I thought it would be simple
| 354 Views | ||
|
Page:
1
|
Go to Top |

