Follow Sebastiaan de Jonge on Twitter
Sebastiaan de Jonge

Blog

12Jan

Cool TypoScript: Alphabetical selector/list

Posted on January 12, 2010 in TypoScript by Sebastiaan de Jonge

The idea for the project was to generate an alphabetical list of products for a tt_products webshop. To make the process list the right products I extended the search a little with a new functionality. However this was not really the challenge! The challenge came with writing the navigation for this. I wanted to do this entirely with TypoScript. And I (we, got a little help from Pim Broens ;-)) did it!

The Code

lib.alphalist 
  1. lib.alphalist = HTML
  2. lib.alphalist {
  3.   value = 0-9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
  4.   value {
  5.     wrap = <div class="alphalist">|</div>
  6.     split {
  7.       token = ,
  8.       cObjNum = 1
  9.         1 {
  10.           cObject = HTML
  11.           cObject {
  12.             value {
  13.               typolink {
  14.                 parameter = 256
  15.                 additionalParams.current = 1
  16.                 additionalParams.stdWrap.wrap = &tx_ttproducts_pi1[sword]=|
  17.                 ATagParams = class="active"
  18.                 ATagParams.if {
  19.                   value.data = GPvar:tx_ttproducts_pi1|sword
  20.                   equals.current = 1
  21.                 }
  22.               }
  23.               current = 1
  24.               insertData = 1
  25.               case = upper
  26.               override = &#35;
  27.               override.if {
  28.                 value = 0-9
  29.                 equals.current = 1
  30.               }
  31.             }
  32.           }
  33.         }
  34.       }
  35.     }
  36.   }
  37. }
lib.alphalist = HTML
lib.alphalist {
  value = 0-9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
  value {
    wrap = <div class="alphalist">|</div>
    split {
      token = ,
      cObjNum = 1
        1 {
          cObject = HTML
          cObject {
            value {
              typolink {
                parameter = 256
                additionalParams.current = 1
                additionalParams.stdWrap.wrap = &tx_ttproducts_pi1[sword]=|
                ATagParams = class="active"
                ATagParams.if {
                  value.data = GPvar:tx_ttproducts_pi1|sword
                  equals.current = 1
                }
              }
              current = 1
              insertData = 1
              case = upper
              override = &#35;
              override.if {
                value = 0-9
                equals.current = 1
              }
            }
          }
        }
      }
    }
  }
}

What does it do?

It's not so complicated as it seems, we simple create a comma seperated list with all the values we want to have as menu items. Next thing we do is split up and modify the links to our needs (text in uppercase, add an activestate). That's it!

Comments (1)

  1. Gravatar: Pim BroensPim Broenson January 15, 2010
    at 15:05
    Reply to this comment

    that's it? it's freaking briljant mate!

Got something to say?

 
Notify me when someone adds another comment to this post
 

Search

Categories

Tags

Archive

Blogroll

Syndicate