3

I can go to http://example.com/admin/entries/sectionHandle, and the Entries list has that source selected, but I can't find a way to do that with sources added through modifyEntrySources.

I've got two extra sources for entries that have been fully translated, and those that haven't, so we can track our progress as we translate the site.

Is there anything I can add to the array so that I could link to something like http://www.example.com/admin/entries/untranslated?

public function modifyEntrySources(&$sources, $context)
{
    if ($context == 'index')
    {
        $sources[] = array('heading' => 'Translations');

        $sources['translations:untranslated'] = array(
            'label' => Craft::t('Untranslated'),
            'criteria' => array('translationCompleted' => array('0', null))
        );

        $sources['translations:translated'] = array(
            'label' => Craft::t('Translated'),
            'criteria' => array('translationCompleted' => '1')
        );
    }
}
2

After a little more digging, I discovered this can be achieved by adding a data array with a handle value to the source, so that code becomes:

public function modifyEntrySources(&$sources, $context)
{
    if ($context == 'index')
    {
        $sources[] = array('heading' => 'Translations');

        $sources['translations:untranslated'] = array(
            'label'    => Craft::t('Untranslated'),
            'criteria' => array('translationCompleted' => array('0', null)),
            'data'     => array('handle' => 'untranslated'),
        );

        $sources['translations:translated'] = array(
            'label'    => Craft::t('Translated'),
            'criteria' => array('translationCompleted' => '1'),
            'data'     => array('handle' => 'translated'),
        );
    }
}

This doesn't appear to work for nested sources however.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.