Fröhling

Niels Fröhling about [X]HTML, JS and technical tidbits

  • Home
  • About
21. November 2008

TypoScript insane

Ethatron in Scripts, TYPO3

Today I had to create an easy maintainable link-list inside an FCE. As TYPO3 does not offer any native link-lists, you have to make it yourself. Well after some time and try-out I got something working, and a beer from Steffen (thank you very much). It works similar to the tt_content.bullets, just that in this case each line contains a text and where it links, like this:

Title | http://google.com - - Google
Title | http://wikipedia.org - - Wikipedia

You may recognize it’s just a text and a complete typolink-parameter. Easy enough - you think. Well take a look and decide if you’ve made the same.

Here is the code (public domain):

10 = TEXT
10.field = field_links
10.wrap =
|
10 { trim = 1 split { token.char = 10 cObjNum = 1 1.parseFunc > # the negative match has to be done first, because the # following split actually changes the current-value 1.1 = TEXT 1.1.current = 1 1.1.wrap =
|
1.1.if.value.current = 1 1.1.if.matches = /\|/ 1.1.if.negate = 1 # continue with destructive splitting 1.2 = TEXT 1.2.current = 1 1.2.wrap =
|
1.2.if.value.current = 1 1.2.if.matches = /\|/ 1.2.trim = 1 1.2.split { token = | cObjNum = |*|1||2|*| # we don’t put the string into value, so we would not need to delete it # if we would delete it with ‘>’, the LOAD_REGISTER will not work 1.parseFunc > 1.1 = LOAD_REGISTER 1.1.title.current = 1 # we don’t put the string into value, so we don’t overwrite 2.1 # if we would overwrite 2.1, the RESTORE_REGISTER will kill all data 2.parseFunc > 2.2 = RESTORE_REGISTER 2.trim = 1 # so this is it, first fragment into value, second directly into typolink # the order of execution is sorted, so don’t worry about the strange order here 2.1 = TEXT 2.1.data = register:title 2.typolink { parameter.current = 1 ATagParams = rel=”shadowbox” target = extTarget = } } } }
Kein Kommentar
01. August 2008

treef: A textual file-tree pretty-printer for the bash

Ethatron in Scripts

Most often, when you search something extremly simple and obvious, you have a hard time finding it. The simpler and the more obvious, the harder. This time I wanted to send a listing of a directory structure per email, no complex content, no HTML no Doc (how again do you export directory-trees directly into a graphic or document?).

Here is the result (public domain):

#!/bin/bash

target=.
prefix=
last=

if test $# -gt 0; then
  target="$1"
fi
if test $# -gt 1; then
  prefix="$2"
fi

############################################################
# to make files-first-dirs-last:
# - scan files first seperatly
# - scan directories after seperatly

############################################################
# determine which is the last entry
# can either be a file or a directory
for sub in "$target"/*; do
   if test -f "$sub"; then
      num=$(ls -1 "$sub" | wc -l)
      if [ $num -gt 0 ]; then
         last=”$sub”
      fi
   fi
done

for sub in “$target”/*; do
   if test -d “$sub”; then
      num=$(ls -1 “$sub” | wc -l)
      if [ $num -gt 0 ]; then
         last=”$sub”
      fi
   fi
done

############################################################
# print the files available in the given directory
# then determine if there are parent-directories
# that also contain files, which we enter only if yes
for sub in “$target”/*; do
   if test -f “$sub”; then
      if [ "$last" != "$sub" ]; then
         echo “$prefix” \+- ${sub#$target\/}
      fi
      if [ "$last" = "$sub" ]; then
         echo “$prefix” \`- ${sub#$target\/}
      fi
   fi
done

for sub in “$target”/*; do
   if test -d “$sub”; then
      num=$(ls -1 “$sub” | wc -l)
      if [ $num -gt 0 ]; then
         echo “$prefix” \|

         if [ "$last" != "$sub" ]; then
            echo “$prefix” \+- ${sub#$target\/}
            echo “$prefix” \|\ \ \|
            treef “$sub” “$prefix | ”
         fi
         if [ "$last" = "$sub" ]; then
            echo “$prefix” \`- ${sub#$target\/}
            echo “$prefix” \ \ \ \|
            treef “$sub” “$prefix   ”
         fi
      fi
   fi
done

If you got faster variatoins of this quick hack fitting my needs, I’m going to update the code with your suggestions. Here BTW is an example of the output:

$ treef Windows\ NT
 +- htrn_jis.dll
 +- hypertrm.exe
 |
 +- Accessories
 |  |
 |  +- mswrd6.wpc
 |  +- mswrd8.wpc
 |  +- wordpad.exe
 |  `- write.wpc
 |
 `- Pinball
    |
    `- New Textdokument.txt
Kein Kommentar

Tags

  • Algorithms Assembler bash C++ Homemade Javascript MMX Optimization Rants TYPO3

Categories

    • Applications
      • TYPO3
    • TidBits
      • Algorithms
      • Approximations
      • Equivalence
      • Fixes
      • Javascript
      • Optimizations
      • Scripts
    • Uncategorized

Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org

Recent Posts

    • jQuery’s animate is short-thought
    • movntq alignment
    • OP-equivalent series (pavgd)
    • OP-equivalent series (psubq)
    • OP-equivalent series (paddq)

 

  • September 2010
    M T W T F S S
    « Aug    
     12345
    6789101112
    13141516171819
    20212223242526
    27282930  

Archives

    • August 2010
    • April 2010
    • February 2010
    • January 2010
    • July 2009
    • February 2009
    • December 2008
    • November 2008
    • August 2008
    • July 2008
    • May 2008
© 2010 Wired by Fröhling
Design von Dezzain Studio
Übersetzt von Htwo
Nature Pictures | Bamboo Blinds