Search code examples
typo3typoscripttypo3-7.6.x

Typoscript filelink - Hide label


I create a link to a file using filelink. I getting the name of the file using another Templavoila FCE field_title (see precedent post).

What I want is pretty simple, I want to display only the icon, not the label. I managed to display no text, but I still get the <a></a>.

I tried using labelStdWrap or labelStdWrap.override, but so far nothing worked. I found in the TsRef that you can hide the icon, but nothing is said about hiding the label.

Here is the Typoscript :

lib.field_datasheet = TEXT
lib.field_datasheet {
  value {
    field = field_title
    wrap = |.pdf
    }
  filelink {
    path = /fileadmin/datasheet/
    icon_link = 1
    }
 }

The HTML code I get is that :

<a href="/fileadmin/datasheet/Title.pdf">
 <img src="/typo3/sysext/frontend/Resources/Public/Icons/FileIcons/pdf.gif">
</a>
<a href="/fileadmin/datasheet/Title.pdf">Title.pdf</a>

And it's the entire last line I don't want to be displayed.


Solution

  • You can remove the label with link in this way:

    lib.field_datasheet = TEXT
    lib.field_datasheet {
      value {
        field = field_title
        wrap = |.pdf
      }
      filelink {
        path = /fileadmin/datasheet/
        icon = 1
        icon_link = 1
        file.cObject = TEXT
      }
    }
    

    file.cObject = TEXT will remove the label and link, but the icon and its link will be unaffected.