3

The context:

I need to insert an imagemap into a page in TYPO3 6.1.

As EXT:imagemap_wizard is not working currently in 6.1, I can create the imagemap offline and then insert it via the HTML content type.

The question:

It would be nice to be able to just write the internal URLs in the HTML, but output realURLs. Can the "HTML" type field be passed through the parser that renders URLs?

So that

<area shape="rect" href="index.php?id=55" coords="6,153,189,231" alt="">

would be rendered as

<area shape="rect" href="/my/realurl/" coords="6,153,189,231" alt="">

Or is there another way? Maybe put the HTML into a fluid template and tell it to render any URL it finds in the template?

Urs
  • 4,984
  • 7
  • 54
  • 116
  • The question is more academic than urgent, but it would be interesting to know if it's possible. – Urs Jan 17 '14 at 16:44

2 Answers2

2

If you parse the HTML-Content object via lib.parseFunc, you can use the -Tag which will create typolinks. With realurl installed, you get the urls you want:)

The HTML-Content Object will be rendered (with css_styled_content) via tt_content.html.

So add

  tt_content.html.parseFunc < lib.parseFunc_RTE

To your HTML Object, and put in your content the LINK-Tag:

  <area shape="rect" href="<link>55</link>" coords="6,153,189,231" alt="">

IMHO not an accademic question, you should allways use typolinks :)

maholtz
  • 3,631
  • 1
  • 17
  • 17
  • Sounds great! But lib.parsefunc entity-encodes the and tags (not though). I've tried setting `tt_content.html.parseFunc.allowTags = area,map,img` or `tt_content.html.parseFunc.allowTags:=addToList(area,map,img)`,but no luck yet – Urs Jan 17 '14 at 20:08
  • nope, dont change the parseFunc itself, just use it. It will parse your HTML-Object and creates a link to page 55 if you have an 55. If realurl is activated, you get it via /path/to/site/ – maholtz Jan 20 '14 at 11:03
  • The issue is that it ouputs the following: `<map name="image_map"> <area shape="rect" href="<link>55" coords="6,153,189,231" alt="" /> </map> ` – Urs Jan 20 '14 at 11:55
  • So the parseFunc (without the allowTags settings mentionned above) does some htmlescape or similar transformation on the map and area tags it shouldn't do. And it doesn't even parse the typolink, I just noticed --- what could that be? Some previous setting messing it up? – Urs Jan 20 '14 at 11:57
  • oh, sorry, lib.parseFunc_RTE should be the right choice... can you try that? – maholtz Jan 20 '14 at 13:50
  • Without setting allowTags, parseFunc_RTE simply escapes all the code. If I set `tt_content.html.parseFunc.allowTags:=addToList(area,map,img)`- then it accepts the map and img tags (progress!) - but still escapes the area tag, not parsing the typolink. If I used a fluid template instead for the same code, would there be a possibility to apply another parser that's maybe less strict? – Urs Jan 21 '14 at 08:35
1

The simple approach with parseFunc_RTE does not work, because we need to act on the attribut. So, this code is tested with css_styled_content TYPO3 6.1. So, just use the tags function:

# we parse the HTML, but we only focus on tag *area*
# i created an COA, because IMHO it is easier to maintain.
# i guess, it would be possible in a few lines only, but i did not tested that
tt_content.html.parseFunc.tags.area = COA
tt_content.html.parseFunc.tags.area {
 wrap = <area |/>
 20 = TEXT
 # all attributs are loaded into parameters array
 20.data = parameters:shape
 20.noTrimWrap = | shape="|" |
 30 = TEXT
 30.typolink.parameter.data = parameters:href
 # we only need the URL, not the full link
 30.typolink.returnLast = url
 30.noTrimWrap = | href="|" |
 40 = TEXT
 40.data = parameters:coords
 40.noTrimWrap = | coords="|" |
 50 = TEXT
 50.data = parameters:alt
 50.noTrimWrap = | alt="|" |
}

# for testcase, create TS-Template with css_styled_content included
# and create html-record on that page in column 0
page = PAGE
page.10 < styles.content.get
maholtz
  • 3,631
  • 1
  • 17
  • 17
  • Fantastic! Thanks a lot. I've implemented it successfully. I think I'll open a new question "How to insert an imagemap in TYPO3" so it can be found more easily - do you want to post your solution there too (so I can accept it)? – Urs Mar 12 '14 at 10:30
  • Your actual title is way better - it is about typolinks in HTML-Fields. IMHO you should not open a new question. Can`t you just change the title, if you think it is needed? – maholtz Mar 12 '14 at 11:48
  • Hm as you say, you saved my day! :-) I like it when you find a tutorial on stackoverflow. I'll change the title. Anyway, I've added your solution to http://forge.typo3.org/issues/53263 which is pretty googlable – Urs Mar 12 '14 at 15:10