[TYPO3-english] Show different page icon in BE when
Jigal van Hemert
jigal.van.hemert at typo3.org
Mon May 19 21:39:07 CEST 2014
Hi,
On 19-5-2014 17:39, Loek Hilgersom wrote:
> I'd like to have the backend show a different page icon when something
> is set in 'Show Content from Page'. Just like you get a little arrow on
> the icon when you make a shortcut.
>
> That would take away a lot of confusion for editors (trying to put
> content on a page and wondering why nothing changes, etc).
>
> Any idea how to achieve that?
You can change the page icon itself with a userfunc (the usual overlays
are still applied). This code was used in a 4.x extension. Use the
namespaced class names if you make 6.x specific extensions.
Create an extension. In ext_tables.php:
// Defines $icon array()
$pathToExtension = t3lib_extMgm::extRelPath('<<ext_key>>');
$icons = array(
'mystate' => $pathToExtension .
'Resources/Public/images/icons/mystateicon.png',
'mystate_hide' => $pathToExtension .
'Resources/Public/images/icons/mystateicon_hide.png',
);
// Gives the $icon array to the sprite manager
t3lib_SpriteManager::addSingleIcons($icons, '<<ext_key>>');
// Register userfunc for page icon
$TCA['pages']['ctrl']['typeicon_classes']['userFunc'] =
'tx_iconClass->getPageIcon';
In class.tx_iconClass.php :
class tx_iconClass {
/**
* Determines icon class for special page cases
*
* @param array $parameters array with record
* @param string $ref Unused reference parameters
* @return string Class name of page
*/
public function getPageIcon($parameters, $ref) {
$iconClass = '';
$row = $parameters['row'];
if (....some..condition...) {
$iconClass = 'extensions-<<ext_key>>-mystate';
if ((int)$row['nav_hide'] === 1) {
$iconClass .= '_hide';
}
}
return $iconClass;
}
}
The "hidden" state is a bit special. It doesn't trigger an overlay icon
to be added to the page icon, but it uses a separate icon.
Your special icons are shown everywhere in the backend where the page
icon is usually displayed.
--
Jigal van Hemert
TYPO3 CMS Active Contributor
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the TYPO3-english
mailing list