Item an important feather in SE. We can make our life easy by using it.
For decliring Item in SE. We have to do it in Module/setting/manifest.php
Here we use this
// Items --------------------------------------------------------------------- 'items' => array( 'item1', 'item2', 'item3' ),
Every item will represent a particular table.
If we follow the naming convention of SE in database table.
Then our Table name will be plural and row class will be singular
So, If we have a item named “item” then it’s primary key will be “item_id” and table will be “items”
Calling Item
By using item we can easily use any table and get it’s a particular row easily.
Table info using Item
$tableInfo = Engine_Api::_()->getItemTable('[itemname]');
Table’s a perticular row using Item
$rowInfo = Engine_Api::_()->getItem('[itemname]',[primary_key_value]);
We have also two very important items.
1. Viewer
2. Subject
##Viewer: This item gives us the information of a user who is current viewing on the site
$viewer = Engine_Api::_()->user()->getViewer(); $id = $viewer->getIdentity();
[This function will return id of this table, it is a magic function of item in SE]
##Subject: This item gives us the information of a subject which is being viewing by a user
$subject = Engine_Api::_()->core()->getSubject(); $id = $subject->getIdentity();
[This function will return id of this table, it is a magic function of item in SE]
Before we using subject we first have to set he subject
Setting a subject
Engine_Api::_()->core()->setSubject($subjectToSet);
How to set
if (0 !== ($id = (int) $this->_getParam('id')) && null !== ($subjectToSet = Engine_Api::_()->getItem('item', $id))) { Engine_Api::_()->core()->setSubject($subjectToSet); }
We have to set it in it’s controller. and it is good if we set it in ini()
public function init() { }
Tagged: Item, socialengine, Subject, Viewer
Hi Mate,
Well I am getting weird error regarding item.
I am getting error “Unknown Item Type : advinvite_matchinvite”.
I have made already model of this class : “Advinvite_Model_Matchinvite” also Api is already there for this module “Advinvite_Api_Core” and I have already set the Item in the manifest file in the array : “advinvite_matchinvite”.
Still I am getting error and I can’t user getItem feature or relatively coz it always shows unknown item 😦
Please help me mate….
Waiting for positive response.
Thank you 🙂