LilaQ
LilaQ

Reputation: 350

Change filelinks layout in Typo3 (6.2.14)

I want to change the layout of the filelinks a little bit. I'm still a TS beginner, so please bear with me.

Here is what I need to have as output:

<ul class="list__download">
  <li>
    <a href="/#" class="list__link">Preisblatt A    
      <span class="list__info">2.3 MB / PDF</span>
    </a>
  </li>
  <li>
    <a href="/#" class="list__link">Preisblatt B
      <span class="list__info">2.3 MB / PDF</span>
    </a>
  </li>
  <li>
    <a href="/#" class="list__link">Preisblatt C
      <span class="list__info">689 GB / SFV</span>
    </a>
  </li>
</ul>

My initial approach in the TypoScript was like this:

tt_content.uploads.10.10.1.dataWrap = <h2>|</h2>        
tt_content.uploads.20.stdWrap.dataWrap = <ul class="list__download">|</ul>
tt_content.uploads.20.renderObj.wrap.cObject.10.oddEvenClass >
tt_content.uploads.20.renderObj.wrap.cObject.10.elementClass >
tt_content.uploads.20.renderObj.wrap.cObject.20.value = <li>|</li>
tt_content.uploads.20.renderObj.20 = COA
tt_content.uploads.20.renderObj.20 {
    10 = TEXT
    10 {
      data = file:current:title
      wrap = |
    }

    15 < linebreak

    20 = TEXT
    20 {
      data = file:current:description
      wrap = <span class="list__info">|</span>
    }

    wrap = <a href="#" class="list__link">|</a>
}
tt_content.uploads.20.renderObj.30 >

With this TS it looks exactly the way I want it to be, but of course the actual link to the file is gone (only replaced it with this dummy a-Tag wrap).

I also tried to write this code block to:

tt_content.uploads.20.renderObj.20.data 

instead of the default

file:current:title // file:current:name

but then the elements are completely missing.

Can you help a TS-newbie out? How can I achieve to get my desired layout, and link a- and span-Tag to my uploaded file?

Thank you very much in advance

Upvotes: 1

Views: 949

Answers (1)

Bharat Parmar
Bharat Parmar

Reputation: 1880

check out this one :

tt_content.uploads.20 {

    renderObj {
        10 >
        15 >
        20 >
        20 = TEXT
        20 {
                data = file:current:size // file:current:name
                bytes = 1
                bytes.labels = ” B| KB| MB| GB”
                htmlSpecialChars = 1
                outerWrap = <li>|</li>
                innerWrap = {file:current:name}<span class="fileDesc"> |  &nbsp /&nbsp;{file:current:extension}</span>


                required = 1
                replacement {
                # equivalent to former useSpacesInLinkText = 0; remove using > to disable it
                10 {
                    search = _
                    replace.char = 32
                }
                # equivalent to former stripFileExtensionFromLinkText = 0; move "_20" to "20" to enable it. Disabled by default.
                _20 {
                    search = /(.*)(\..*)/
                    replace = \1
                    useRegExp = 1
                }
            }
            typolink {
                parameter.data = file:current:originalUid // file:current:uid
                parameter.wrap = file:|
                fileTarget < lib.parseTarget
                fileTarget =
                fileTarget.override = {$styles.content.uploads.target}
                fileTarget.override.override.field = target
                removePrependedNumbers = 1
                ATagParams = class = "list__link"

                title {
                    data = file:current:title
                    htmlSpecialChars = 1
                }
            }
            #wrap = <span>|</span>
        }
        20.innerWrap.insertData = 1
        20.innerWrap2.insertData = 1
        20.wrap.insertData = 1
        30 >
        wrap.cObject {
            10 = LOAD_REGISTER
            10 {
                oddEvenClass = odd li-first |*| even || odd
                elementClass = {file:current:extension}
                elementClass.insertData = 1
            }

            20 = TEXT
            20 {
                value = <tr class="{register:oddEvenClass} {register:elementClass}">|</tr>
                insertData = 1
            }
            30 = RESTORE_REGISTER
        }
    }
}

Upvotes: 6

Related Questions