Express entity ID

Permalink
Hello, i have this code
$entity = Express::getObjectByHandle("sport");
$list = new Concrete\Core\Express\EntryList($entity);
$list->setItemsPerPage(10);
$pagination = $list->getPagination();
 $results = $pagination->getCurrentPageResults();
  foreach ($results as $Single) {
echo $Single->getAttribute('sport_news');
}


Attribute 'sport_news' is Express Entity - refers to another express object. Unfortunately, I get the exact name of this entity (select anothre express), but I also need an ID.

Can you advise me on how to get the ID of the other Express Object that is referenced in the attributes 'sport_news' this first Express Object?

I hope I described it well in English, i little speak english. :)

Thank you

 
mnakalay replied on at Permalink Reply
mnakalay
Hello,

I am not 100% sure it's going to work but try this
$attribute = $single->getAttribute('sport_news');
$aKey = $attribute->getAttributeKey();
$akID = $aKey->getAttributeKeyID();
DSeven replied on at Permalink Reply
Hello, there is an error:
Call to undefined method Concrete\Core\Entity\Attribute\Value\Value\ExpressValue::getAttributeKey()
mnakalay replied on at Permalink Reply
mnakalay
I see.
Try this instead
$ak = $entity()->getAttributeKeyCategory()->getByHandle('sport_news);
$akID = $ak->$ak->getAttributeKeyID();
DSeven replied on at Permalink Reply
Does not work. Never mind, I did it through search code by attribute.
onemhz replied on at Permalink Reply
onemhz
for me works this:
use Concrete\Core\Entity\Express\Entity;
use Concrete\Core\Express\EntryList;
$entry='sport';
$entity = Express::getObjectByHandle($entry);
$list = new EntryList($entity);
$entries = $list->getResults();
   foreach($entries as $entry){
      echo $entry->getAttribute('sport_news');
   }