Express entity ID
Permalink
Hello, i have this code
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
$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
Hello, there is an error:
Call to undefined method Concrete\Core\Entity\Attribute\Value\Value\ExpressValue::getAttributeKey()
Call to undefined method Concrete\Core\Entity\Attribute\Value\Value\ExpressValue::getAttributeKey()
I see.
Try this instead
Try this instead
$ak = $entity()->getAttributeKeyCategory()->getByHandle('sport_news); $akID = $ak->$ak->getAttributeKeyID();
Does not work. Never mind, I did it through search code by attribute.
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'); }
I am not 100% sure it's going to work but try this