blog.Resource

Archive:

News-Feeds:


RSS 2.0
RSS 0.91
RDF
ATOM 0.3
December 2, 2009

New icons for my pages

Category: Steffen Kamper

Easy way to customize your pages with own icons

Here i want to show you an easy way to add own icons to your pages and how to use them in a menu.


First i took 5 icons from famfamfam and put them to fileadmin/pageicons

then i added the following snippet to my typo3conf/extTables.php:

$TCA['pages']['columns']['module']['config']['items'][] = array('Pagetype 1', 'pagetype1', '../fileadmin/pageicons/asterisk_orange.png');
$TCA['pages']['columns']['module']['config']['items'][] = array('Pagetype 2', 'pagetype2', '../fileadmin/pageicons/award_star_bronze_1.png');
$TCA['pages']['columns']['module']['config']['items'][] = array('Pagetype 3', 'pagetype3', '../fileadmin/pageicons/award_star_silver_3.png');
$TCA['pages']['columns']['module']['config']['items'][] = array('Pagetype 4', 'pagetype4', '../fileadmin/pageicons/award_star_silver_2.png');
$TCA['pages']['columns']['module']['config']['items'][] = array('Pagetype 5', 'pagetype5', '../fileadmin/pageicons/award_star_gold_1.png');

$ICON_TYPES['pagetype1']['icon'] = '../fileadmin/pageicons/asterisk_orange.png';
$ICON_TYPES['pagetype2']['icon'] = '../fileadmin/pageicons/award_star_bronze_1.png';
$ICON_TYPES['pagetype3']['icon'] = '../fileadmin/pageicons/award_star_silver_3.png';
$ICON_TYPES['pagetype4']['icon'] = '../fileadmin/pageicons/award_star_silver_2.png';
$ICON_TYPES['pagetype5']['icon'] = '../fileadmin/pageicons/award_star_gold_1.png';

Now i see them if i edit any page properties, in options tab with "contains plugin". Easy to choose one of them. As soon you save it, you see this icon for your page in pagetree - perfect.

You can use such icons to show editors a special page for special content, or just to make your BE more colorful :)

Now lets use these settings in a normal HMENU. The field where the setting is saved is called "module", so we use a CASE object for wrapItemAndSub to use this for CSS-class. Here is the snippet:

lib.my_menu = HMENU
lib.my_menu {
  entryLevel = 0
  wrap = <ul>|</ul>
  1 = TMENU
  1.NO {
    wrapItemAndSub.cObject = CASE
    wrapItemAndSub.cObject {
      key.field = module    
      default = TEXT
      default.value = <li>|</li>
      
      pagetype1 = TEXT
      pagetype1.value = <li class="pagetype1">|</li>
      
      pagetype2 = TEXT
      pagetype2.value = <li class="pagetype2">|</li>
      
      pagetype3 = TEXT
      pagetype3.value = <li class="pagetype3">|</li>
      
      pagetype4 = TEXT
      pagetype4.value = <li class="pagetype4">|</li>
      
      pagetype5 = TEXT
      pagetype5.value = <li class="pagetype5">|</li>
    }
  }
}

And we're done. Have fun!


comments

comment #1
Gravatar: Philipp Gmape Philipp Gmape December 3, 2009 00:35
thanks!

nice to know,
looking at the picture, does it mean that "contains plugin" just means to change the icon
or is this field used for other purposes as well?

Best regards
Phil

comment #2
Gravatar: maddesigns maddesigns December 3, 2009 07:20
wow that great!

comment #3
Gravatar: Steffen Kamper Steffen Kamper December 3, 2009 09:33
This field is "only" used for the icon. You all know that for tt_news to visually mark a folder as container for news.

comment #4
Gravatar: Michael Wolfinger Michael Wolfinger December 3, 2009 09:38
great feature and especially useful for us since we're working on BE customization.

comment #5
Gravatar: Natalie Natalie December 3, 2009 12:06
Oh, this really looks like an idea worth pursuing when we see the need for an unobtrusive, yet obvious visual categorization system to aid a client's staff through the thicket of a site tree.

comment #6
Gravatar: Fabien Udriot Fabien Udriot December 3, 2009 22:32
A knew it was possible but didn't take the time to find out how. Thanks a lot! :)

comment #7
Gravatar: Nathan Lenz Nathan Lenz December 5, 2009 03:04
Here is a fun idea for an extension. Have it look for site root pages, then domain records. Fetch the favicon.ico file off each domain. Then create icons and assign them to each of "contains plugin" fields.

If there are multiple domain records, it could give the person a choice if they have different favicons.

comment #8
Gravatar: Pim Broens Pim Broens December 7, 2009 13:35
This is a great little tutorial for something a lot of guys out there. Thanks!

comment #9
Gravatar: Lina Ourima Lina Ourima December 23, 2009 16:23
For those who speak German I have published a small tutorial on this topic last year.
There are some further examples for using the page-type:
http://typo3-blog.net/tutorials/news/custom-seitentypen.html

Greetings and Happy X-Mess

Lina

Sorry, comments are closed for this post.