What I'm looking for is to add in a custom column that either has a checkmark or not based on if the entry's slug has a certain set of characters.
Example:
This would get a check: sluggyslug-SC_01234X
This would not: sluggyslug
I would be looking at the slug and matching via regex for the SC_XXXXX
portion.
I see there is the hook defineAdditionalEntryTableAttributes
and getEntryTableAttributeHtml
but I get an error when I try to set them.
The code I tried in my plugin:
public function defineAdditionalEntryTableAttributes()
{
return array(
'something' => "Some Column",
);
}
public function getEntryTableAttributeHtml(EntryModel $entry, $attribute)
{
if ($attribute == 'something')
{
if (preg_match("/(?:SC_\w{5})$/", $entry->slug)) {
return '<div class="center">✓</div>';
}
}
}
If I try to add the column, I just get this via the getElements
ajax call.
CException
Property "Craft\EntryModel.something" is not defined.
Is there anyway to add a column like this?