[TYPO3-english] Show different page icon in BE when

Loek Hilgersom loek at netcoop.nl
Tue May 20 14:32:23 CEST 2014


Hi Jigal,

Thank you for the explanation and the code.

I renamed tx_iconClass to tx_myext_iconClass. The only other thing I had to 
change to make it work is that the iconClass should return 
'extensions-myext-mystate' instead of just 'mystate'.

Except clearing the sprites folder in typo3temp I also had to clear the opcode 
cache to see my changes, but it worked!

Thanks,
Loek


On 19-05-14 21:39, Jigal van Hemert wrote:
> 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.
>


More information about the TYPO3-english mailing list