Tag in the header, when certain parameters are met. Currently the base tag is filled wi..." /> Tag in the header, when certain parameters are met. Currently the base tag is filled wi..." /> Tag in the header, when certain parameters are met. Currently the base tag is filled wi..."/>

Typo3 how to add target=_blank parameter in base meta tag

1.6k views Asked by At

I am trying to add target="_blank" parameter to the <base> Tag in the header, when certain parameters are met.

Currently the base tag is filled with the url give in config.baseUrl:

<base href="http://yourdomain.com/">

I've gone through the reference and tried different settings (meta, pages.headerData, ..) but I was not able to manipulate the <base> tag within the header.

what I want to achieve is this:

<base href="http://yourdomain.com/" target="_blank">

what I got so far is to remove the baseUrl completely and set <base> manually:

page.headerData.1 = TEXT
page.headerData.1.value < config.baseURL
page.headerData.1.wrap = <base href="|" target="_blank">
config.baseURL > 

Still i have 2 problems with this: Typo3 (in my case 4.5) adds a CSS link before my tag - which results in a file not found message when I open any sub-path on the website. when opening: http://yourdomain.com/path/subpath

<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="generator" content="TYPO3 4.5 CMS">
    <link rel="stylesheet" type="text/css" href="typo3temp/stylesheet_xxx.css?xxx" media="all">
    <base href="http://yourdomain.com/" target="_blank">
    <title>Some title</title>

chrome says:

/path/subpath/stylesheet_xxx.css?xxx    GET 404

(where it should find the file in /stylesheet_xxx.css?xxx ..)

the other problem is, that when doing a HMENU with special=rootline

logo = HMENU
logo {
   special = rootline
   special.range = 0|0
}

the href to the startpage will always be blank, after I unset config.baseUrl.

Any help would be greatly appreciated.

/edit: adding a second <base> tag in header would work, but the validator doesn't like two base tags :(

2

There are 2 answers

1
brandelizer On

Maybe this constants help you?

 # default target for links:
 PAGE_TARGET = _blank
 # target for links in sitemap:
 content.pageFrameObj = _blank

From here: http://www.pi-phi.de/25.html

2
Urs On

On the first issue (they are related, I know):

I wouldn't add the config setting to page.headerData.1.value, rather use a constant:

mydomain = www.mydomain.com

then

config.baseURL > 
page.headerData.1 = TEXT
page.headerData.1.value < {$mydomain}
page.headerData.1.wrap = <base href="http://|" target="_blank">

About the routing issue: is that really so? According to your code, it should look in www.mydomain.com/typo3temp.

In the documentation, it says that the baseURL should have an end slash. But in all my sites, I use it without, and it works fine. Give it a try without the end slash.

On the second issue

logo = HMENU
logo {
   special = rootline
   special.range = 0|0
}

Is this only a "home" link? Then consider adding it with a typolink to the home page's pid instead or even totally by hand, as it will likely never change (href="\").

PS: base tag is a bit out of fashion, but you know that already. I used to use it mostly because of IE 8 issues, and now, well, I'm used to it. Also, for TYPO3, the use of "absRefPrefix" has been recommended. I'm just noting this here academically.