24/02: T3: ml_links

Die TYPO3-Extension ml_links ermöglicht es, vor bzw. nach einem Link ein spezielles Symbol darzustellen. So habe ich auf einer Webpräsenz eingestellt, dass vor jedem externen Link eine kleine Weltkugel, vor jedem mailto-Link ein Brief und vor jedem PDF-Download das PDF-Symbol dargestellt wird. Weitere Informationen sind auf der Beschreibung der Extension: hier

Etwas habe ich jedoch vermisst: das mitgeben zusätzlicher Attribute für das img-Tag dieses Symbols. Die Extension wurde so umgebaut, dass man mit TSConfig den Wert image.params setzen kann. In der Datei class.tx_mllinks_pi1.php (im Ornder /ext/ml_links/p1/) wurde die erste Funktion insertImage wie folgt angepasst:

/**
* add image
*/
function insertImage ($data, $linkTag) {
$img = “”;
if (file_exists($data['image'])) {
// start img tag
$img .= ‘<img src=”‘ . $data['image'].’”‘;
if (isset($data['image.']['alt'])) {
$img .= ‘ alt=”‘ . $data['image.']['alt'].’”‘;
}
if (isset($data['image.']['params'])) {
$img .= $data['image.']['params'];
}
// end img tag
$img .= ‘/>’;
// surround img-tag with a link?
if (isset($data['image.']['link']) && $data['image.']['link'] == 1) {
$img = $linkTag . $img . ‘</a>’;
}
if (!empty($this->tag)) {
if (isset($data['separator'])) {
$img = $data['separator'] . $img;
}
else {
$img = $this->separator . $img;
}
}
$this->buildLink = true;
}
return ($img);
}

Die Funktion main(…) wurde im case URL ebenfalls geändert:

//add image
if (isset($data['image.'][$ext]) && file_exists($data['image.'][$ext])) {
$imageTag = ‘<img src=”‘ . $data['image.'][$ext].’”‘;
if (isset($data['image.'][$ext]['alt'])) {
$imageTag .= ‘ alt=”‘ . $data['image.'][$ext]['alt'] . ‘”‘;
}
if (isset($data['image.'][$ext]['params'])) {
$imageTag .= $data['image.'][$ext]['params'];
}
$imageTag .= ‘/>’;
}
elseif (file_exists($data['image'])) {
$imageTag = ‘<img src=”‘ . $data['image'].’”‘;
if (isset($data['image.']['alt'])) {
$imageTag .= ‘ alt=”‘ . $data['image.']['alt'] . ‘”‘;
}
if (isset($data['image.']['params'])) {
$imageTag .= $data['image.']['params'];
}
$imageTag .= ‘/>’;
}

Meine Konfiguration ( TSConfig) lautet nun (Vorlage von hier):

lib.ml_links_conf {
seperator = “”
external {
10.image = typo3conf/ext/ml_links/icon_globe.gif
10.image.alt = Externer Link
10.image.params = class=”mllinkimg”
10.image.link = 1
20.linkTag = 1
}
mailto {
10.image = typo3conf/ext/ml_links/icon_mailto.gif
10.image.alt = Mail Link
10.image.params = class=”mllinkimg”
10.image.link = 1
20.linkTag = 1
}
pdf {
10.image = typo3conf/ext/ml_links/icon_pdf.gif
10.image.alt = PDF
10.image.params = class=”mllinkimg”
10.image.link = 1
20.linkTag = 1
30.filesize = 1
}

}

# Links im normalen Text
# Text und Text m/Bild – RTE – normaler Textlink
tt_content.text.20.parseFunc.tags.link.postUserFunc = tx_mllinks_pi1->main
tt_content.text.20.parseFunc.tags.link.postUserFunc < lib.ml_links_conf

# Text und Text m/Bild – Link auf dem Bild
tt_content.text.20.parseFunc.tags.link.typolink.userFunc = tx_mllinks_pi1->getFiletype
tt_content.text.20.parseFunc.tags.link.typolink.userFunc < lib.ml_links_conf

# Links in Listen – GEHT NET ???
# Inhaltselemente Text und Text m/bild – RTE – Links in Listen
tt_content.text.20.parseFunc.tags.typolist.default.parseFunc.tags.link.postUserFunc = tx_mllinks_pi1->main
tt_content.text.20.parseFunc.tags.typolist.default.parseFunc.tags.link.postUserFunc < lib.ml_links_conf

tt_content.text.20.parseFunc.tags.typolist.default.parseFunc.tags.link.typolink.userFunc = tx_mllinks_pi1->getFiletype
tt_content.text.20.parseFunc.tags.typolist.default.parseFunc.tags.link.typolink.userFunc < lib.ml_links_conf

So weit so gut. Nur etwas funktioniert noch nicht wie gewünscht: Links, die in Listen (li) erscheinen, werden nicht geparst. Vielleicht finden wir auch da noch eine Lösung.

4 Kommentare »

  1. 1. Thomas wrote:

    Mögliche Lösung:
    Das Problem, dass die Extension bei einigen Linktypen nicht verwendet wird liegt an der fehlenden Definition im TS, spontan hätte ich zwei weitere Definitionen:

    lib.parseFunc.tags.link.typolink.userFunc = tx_mllinks_pi1->getFiletype
    lib.parseFunc.tags.link.postUserFunc = tx_mllinks_pi1->main

    lib.parseFunc_RTE.tags.link.typolink.userFunc = tx_mllinks_pi1->getFiletype
    lib.parseFunc_RTE.tags.link.postUserFunc = tx_mllinks_pi1->main

    1. März 2008 @ 16:12 (comment)

  2. 2. Freshmeat wrote:

    Ich habe auch das Problem mit den Links in Listen.
    Das Typoscript aus dem Kommentar von Thomas hat bei mir leider nichts bewirkt.

    3. April 2008 @ 11:14 (comment)

  3. 3. Thomas wrote:

    Ich habe das Problem mit den Links in Listen auch nicht gelöst. Ich habe die Frage dem Autor der Extension gestellt und seine Antwort darauf als Kommentar ins Blog geschrieben. Wirklich ausprobiert habe ich es nicht (da ich damit lebe bzw. es nicht mehr so als nachteilig betrachte).

    Wenn du zu einer Lösung mit den Links in den Listen kommst, wäre ich um einen kleinen Hinweis froh. Vielleicht hat es tatsächlich etwas mit falschen TypoScript-Definitionen zu tun.

    3. April 2008 @ 11:37 (comment)

  4. 4. Freshmeat wrote:

    also für die Links in den Listen habe ich hier (http://www.typo3.net/forum/list/list_post//62171/?page=1&sword=ml_links#pid232793) eine Lösung gefunden die funktioniert.

    lib.parseFunc.tags.link.typolink.userFunc < tt_content.text.20.parseFunc.tags.link.typolink.userFunc
    lib.parseFunc.tags.link.postUserFunc < tt_content.text.20.parseFunc.tags.link.postUserFunc

    Dafür habe ich noch ein weiteres Problem. Und zwar mit Bildern die über den RTE eingefügt & verlinkt werden.

    3. April 2008 @ 12:27 (comment)

Hinterlasse einen Kommentar

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(req)

(req, never shown)

Note: Spam control is in use - if this is your first comment, it will be automatically sent for moderation. Other moderation is carried out on a per-post basis.