2

I made a plugin which customize columns table view for all my elements and using a filter on the source :

Entries: section

public function modifyEntryTableAttributes(&$attributes, $source)
{
    // set fields for one section
    if ($source == 'section:8' )
    {
        unset($attributes['expiryDate']);
    }
}

User Groups : group

public function modifyUserTableAttributes(&$attributes, $source)
{
    if ($source == 'group:6' )
    {
        $attributes['unepRegionDelegateMember'] = Craft::t('Région');
    }
}

It is working great for these two but I got a problem with the assets source param, it just does not work, I tried folder as explained in Craft Doc but does not work:
http://buildwithcraft.com/docs/plugins/hooks-reference#modifyAssetTableAttributes

Assets: folder

public function modifyAssetTableAttributes(&$attributes, $source)
{
    if ($source == 'folder:2')
    {
        unset($attributes['dateModified']);
    }
}

EDIT
In fact my problem was that I was mistaken by the asset sourceID which has nothing to do with the folderID requested by the function modifyAssetTableAttributes. See what I mean here:

For entries or user groups you can find the ID in CP in the section/usergroup page, the CP page URL contains the ID:
http://craft.dev/admin/settings/sections/5
http://craft.dev/admin/settings/users/groups/5

But for the assets the ID in the url is not the folderID : http://craft.dev/admin/settings/assets/sources/2

SO MY REAL QUESTION IS:
Is there a function to retrieve the main folder ID from an asset source handle to do $folderId = craft()->assets->source(‘asset-handle’)->id
So we could easily use function modifyAssetTableAttributes and provide source filter if ($source == 'folder:51’)
On the same pattern as for section : $sectionId = craft()->sections->getSectionByHandle('handle')->id;

ELEMENT MODEL + GETCRITERIA I tried this
$criteria = craft()->elements->getCriteria(ElementType::Asset);
$criteria->source = ‘asset-handle’;
But I dont see how to get to main folder ID after...

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.