TYPO3 - canonical tag - typo3

I would like to add a canonical tag which points to another domain.
My TYPOScript looks like this:
temp.canonical = TEXT
temp.canonical {
typolink {
parameter.data = TSFE:id
returnLast = url
}
wrap = <link rel="canonical" href="http://myotherdomain.com/|" />
}
page.headerData.123 < temp.canonical
Unfortunately this returns the full URL instead of the path which results in the following:
<link rel="canonical" href="http://myotherdomain.com/http://example.com/subpage" />

Funny... I always have to configure the typolink
forceAbsoluteUrl = 1
to get a full link. Probably this is caused because in the most projects of me I've configured
config.baseUrl = http://example.com/
Maybe this will help you to not get a full URL but attention that your system is still working correctly after setting a baseUrl if you didn't configure it earlier. Are there maybe other settings in your config. that could be the reason for this problem?

Related

Field from default language should be valid for all languages

I'm using this bit of Typoscript and a Templavoilà Plus input field to generate some text.
10 = TEXT
10.value.field = field_test
I work with English (default) and German contents. When I translate a content to German, the backend user has to fill in again field_test, which is the normal behaviour.
Modifying the Typoscript, how can I only use the English (default) content of the field_test even in the German content?
Put in other words, how can I get the value of a field of a particular language?
I saw LLL: and l10n_mode, can they be of any help? And if so, how can you use them in that case?
Is it even possible to achieve that with a simple Header of a tt_content?
Or could I use something like that to disable localisation of a single Templavoilà field ?
config.sys_language_softExclude = tt_content:subheader
config.sys_language_softMergeIfNotBlank = tt_content:subheader
The reason why I'm asking this, is because it would be quite useful not to have to fill in again TV fields for links or images for example…
Here is my Typoscript, where field_test is created with Templavoilà and filled in by an backend editor:
5 = IMAGE
5 {
if.isTrue.field = field_test
file = fileadmin/icons/test.png
wrap = <li>|</li>
imageLinkWrap = 1
imageLinkWrap.enable = 1
imageLinkWrap.typolink.parameter.field = field_test
}
I have tried modifying the Data Structure XML as follow, but even though I have no content in the German field_test, it doesn't display the Default/English content.
<meta type="array">
<langDisable>1</langDisable>
<langChildren>1</langChildren>
</meta>
…
<field_test type="array">
<tx_templavoilaplus type="array">
<title>Test</title>
<langOverlayMode>ifBlank</langOverlayMode>
…
</field_test>
A complete guess, maybe insertData = 1 helps out??
5 = IMAGE
5 {
if.isTrue.field = field_test
file = fileadmin/icons/test.png
wrap = <li>|</li>
imageLinkWrap = 1
imageLinkWrap.enable = 1
imageLinkWrap.insertData = 1
imageLinkWrap.typolink.parameter.field = field_test
}

Get friendly url of parent page through TypoScript for the body tag

I overwrite my body object through TypoScript like this:
page.bodyTagCObject.dataWrap = <body id="p{field:uid}" data-pid="p{field:pid}">
Now I would be interested to provide a data-xxx parameter to the body tag that contains the friendly url (EXT:realurl used) of the parent page.
Is there an easy way through TypoScript to achieve this?
You need to build the link and then wrap it.
In TYPO3 nearly everywhere you can use .stdWrap or .cObject. So you can wrap a wrap. Use this as inspiration:
page.bodyTagCObject.wrap {
cObject = TEXT
cObject.typolink {
parameter.field = pid
returnLast = url
}
dataWrap = <body id="p{field:uid}" data-pid="p{field:pid}" data-url="|" >
}

How can I set a meta description tag in Sailsjs using ejs templates?

I would like to be able to set the description meta tag from the sails controller action. I have searched all over, but the only example involves the page title. This is my first node.js and sailsjs site, am I going about this the wrong way?
Something like this:
module.exports = {
index: function (){
res.view(
{
title: 'The Title Text',
metaDescription: "The Description Text"
});
}
};
Yes, this is correct. You can insert in your template with
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<meta name="description" content="<%= metaDescription %>">
Docs and examples can be found here:
http://sailsjs.org/#!/documentation/concepts/Views/Locals.html
http://sailsjs.org/#!/documentation/reference/res/res.view.html
Thank you #Bulkin for pointing me in the right direction. Here is the solution that worked for me. I put the local variable in the layout template and it worked by passing the meta tag text from the controller for all pages, but the home page. The home page kept throwing an error as seeing "metaDescription", as undefined. The fix was to set the local variable in the home page route of config/routes.
module.exports.routes = {
'/': {
view: 'home/index',
locals: {
metaDescription: "Description Text"
}
}
};

Embed google-plus in GWT

I am trying to embed Google-Plus into my GWT Application. I would like it to be embedded into a HorizontalPanel. I did read +1button developers google. I didn't find any post about this particular problem in stackoverflow. My problem might be that I don't understand how to include the js into a GUI component. I would appreciate an Example of how to add the Google+ code into a Panel.
Here is how to do it:
Documentation:
<!-- Place this tag in your head or just before your close body tag -->
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<!-- Place this tag where you want the +1 button to render -->
<g:plusone></g:plusone>
in GWT:
private void drawPlusOne() {
String s = "<g:plusone href=\"http://urltoplusone.com\"></g:plusone>";
HTML h = new HTML(s);
somePanel.add(h);
// You can insert a script tag this way or via your .gwt.xml
Document doc = Document.get();
ScriptElement script = doc.createScriptElement();
script.setSrc("https://apis.google.com/js/plusone.js");
script.setType("text/javascript");
script.setLang("javascript");
doc.getBody().appendChild(script);
}
I've personally never embedded the +1 button in GWT, but the linked article seems pretty self explanatory.
In the section "A Simple Button", it indicates that the simplest way of implementing GooglePlus integration is to add this:
<script src="https://apis.google.com/js/plusone.js" />
<g:plusone></g:plusone>
First, the <script> tag should be included in your .gwt.xml file.
Then I'd implement the <g:plusone></g:plusone> like this:
public class GPlusOne extends SimplePanel {
public GPlusOne () {
super((Element)Document.get().createElement("g:plusone").cast());
}
}
(Note that this code is untested, but it's based on the simple concept that a SimplePanel can be extended to compile as any HTML element.)
Then you'd use the new GPlusOne element wherever you'd want the button to show.
I found a better way to do it:
Follow this example to have the button work on invocation on a normal html page (you can try one here http://jsfiddle.net/JQAdc/)
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="https://apis.google.com/js/plusone.js">
{"parsetags": "explicit"}
</script>
<script type="text/javascript">
function gPlusBtn(id, params) {
/* window.alert("searching for "+ id +" with params: "+ params) */
paramsObj = eval( '('+params+')' );
gapi.plusone.render(id, paramsObj );
}
// params is here just for a reference to simulate what will come from gwt
params = '{href:"http://1vu.fr", size:"tall"}';
</script>
</head>
<body>
taken from http://jsfiddle.net/JQAdc/
<div id="gplus" />
<button onclick="gPlusBtn('gplus', params)">show!</button>
</body>
</html>
Then you can call a native method to trigger the button display on Activity start (if you're using MVP).
protected native void plusOneButton(String id, String params) /*-{
$wnd.gPlusBtn(id, params);
}-*/;
You can have multiple buttons with different urls, that's why id is left as a parameter.
NOTE: for me the raw HTML works on localhost, but the GWT version. I have to deploy to the server to be able to see the results

Edit asp header

Loosing my mind with this one.
I created a web application with asp.net and have the meta tag
<meta name="viewport" content="width=350; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;" />
to be able to make it more visible with the iwhatever devices. The content was more visible with this tag, but there is a huge amount of white space on the right hand side that the user can see and scroll to.
I added a condition that would resize the div that I put on the page
var pagediv = document.getElementById("HeadContent");
if (useragent.indexOf('iPhone') != -1 || useragent.indexOf('Android') != -1) {infodiv.style.width = '350px';}
but anything i try to resize the page/header with the asp site.css tag have yet to work.
Thanks in advance for your reply.;
Turns out I needed to edit the entire page
var divs = document.getElementsByClassName('page');
for (var i = 0; i < divs.length; i++) {
divs[i].style.width = '450px';
}