2

I am adding a column to the entry table with links to reverse related entries:

    public function defineAdditionalEntryTableAttributes()
    {
        return array(
            'blockParent' => Craft::t('Parent'),
        );
    }

public function getEntryTableAttributeHtml(EntryModel $entry, $attribute)
{
    switch ($attribute)
    {
        case 'blockParent':
        {
            $criteria = craft()->elements->getCriteria(ElementType::Entry, [
                'relatedTo' => [
                    'targetElement' => $entry,
                    'field' => 'contentSections.blocks',
                ]
            ]);

            $html = '';

            foreach ($criteria as $entry) {
                $html .= craft()->templates->render('_elements/element', array(
                    'element' => $entry,
                ));
            }

            return $html;
        }

    }
}

Works great. Only I want to make the column sortable (based on the title of the first entry of each).

Is there a way to sort on these types of added columns? modifyEntrySortableAttributes seems to only work on real attributes, not added ones.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.