I am using freemarker template on Liferay Portal CE 6.2 and my site has 2 languages (italian and english). Is there any variable or function to get the link to the same page in the other language?
Example: I am on page /en/operations and I want that by clicking on the "italian" button the browser goes to /it/attivita, which is the translated page specified on pages admin.
I found the solution on the liferay forum: https://web.liferay.com/it/community/forums/-/message_boards/message/74709035
<#assign languageUrl = portletURLFactory.create(request, "82", layout.getPlid(), "ACTION_PHASE") />
${languageUrl.setParameter( "struts_action", "/language/view" )}
${languageUrl.setParameter( "redirect", theme_display.getURLCurrent() )}
${languageUrl.setPortletMode( "view" )}
${languageUrl.setWindowState( "normal" )}
${languageUrl.setParameter( "languageId", "xx_XX" )}
set the xx_XX to the locale you want to switch to and add a link to languageUrl:
Italian
Related
I am currently building a custom widget which has links in it. If a link is clicked, the newly opened tab has no authorization. It says the unauthorized access is forbidden. Client authorization required.
I am building the link via javascript.
var newLinkButton = (url, text) => $('<a>', {
class: 'btn btn-default btn-xs',
href: url,
role: 'button',
text: text
});
and set the base target in the header to _blank
<base target="_blank" />
The TFS sets access right equal to the ones from the iframe in which it was called. That is anonym. How do I tell TFS to take an already existing authorization?
You need to redirect to another page (not open a new page) from current page. Change _blank to _top.
<base target="_top" />
I am having trouble with the og meta tags for social media sharing.
I have links for social media sharing in my app :
= link_to "http://www.facebook.com/share.php?u=#{request.base_url}#{request.env['PATH_INFO']}" do
#i{class: "fa fa-facebook-square social-icon", "aria-hidden"=>"true"}
= link_to "http://www.linkedin.com/shareArticle?mini=true&url=#{request.base_url}#{request.env['PATH_INFO']}&source=#{request.base_url}" do
#i{class: "fa fa-linkedin-square social-icon", "aria-hidden"=>"true"}
= link_to "http://twitter.com/intent/tweet?status=#{request.base_url}#{request.env['PATH_INFO']}" do
#i{class: "fa fa-twitter-square social-icon", "aria-hidden"=>"true"}
each link get the absolute url of the current page and insert it in the sharing url of each specific social media.
I have a notification page with twitter, facebook and linkedn sharing buttons. I have included the following og tags :
- content_for(:page_meta) do
%meta{ property: 'og:title', content: "J’ai voté pour mon lauréat Stars et Metiers" }
%meta{ property: 'og:url', content: laureates_url }
%meta{ property: 'og:description', content: "J’ai voté pour mon lauréat coup de ❤ Stars & Métiers 2016 ! Et vous, quel est votre coup de cœur ? avec lien minimisé vers la page lauréat du site" }
og: url is not the current page url because I dont want the social media post to redirect to the page where the social media buttons where but to a different one (laureates_url)
However I keep getting an error message from each social media that " the page is not found"
What am I doing wrong here ?
UPDATE
after using the facebook debugger with my url :
https://developers.facebook.com/tools/debug/og/object/?q=https%3A%2F%2Fstaging-starsetmetiers.herokuapp.com%2Fprix-coup-de-coeur-du-public%2F17701%2Fnotification
It seems that facebook is able to crawl my url. It even shows me a preview of the potential post. Two problems are still unresolved :
1) When I click on the facebook sharing link on my website I dont get the preview as in the facebook debugger. I still get a page not found error :
2) the debugger tells me
The 'og:description' property should be explicitly provided, even if a value can be inferred from other tags.
And it is true that in the preview the debugger shows me, it uses the description from the classic meta name= "description". However there is an og:description present in my page that is the description I want to show in my posts and it is present on the page :
<meta content="J’ai voté pour mon lauréat coup de ❤ Stars & Métiers 2016 ! Et vous, quel est votre coup de cœur ? avec lien minimisé vers la page lauréat du site" property="og:description">
How can I fix these problems ?
Thanks for sharing the output of your page in the Facebook debugger as I suggested in my comment. For your two questions,
It looks like there is a stray closing parenthesis in your Facebook share link. If you remove it, the page should be found normally.
It does look like your meta tags are properly labelled with the Open Graph properties (og:url, etc), so I don't understand why the crawler isn't picking it up. The only thing I can think of is that the order of the property and content attributes in the meta tag is in the reverse order of the example shown on the Facebook site, but I doubt that matters...
I would like to build an Firefox extension which after users click it, a web page is dynamically constructed and opened in a new tab.
In "tab" API, I only saw tab.open() open a hyperlink to a remote website. Can I construct a JavaScript variable contains all the HTML contents (Like var page = "blahblah....") and open it? How to do that?
You don't have to dynamically construct it, just put a htm page in your addon and then the link to it will be resource://your addon id/blah.htm. This addon here creates a page: addons.mozilla.org/en-US/firefox/addon/twitch-alarm
You can also create an about:blah url to your page, this shows how to do it without the sdk: github.com/Noitidart/ZooniverseXpert
You don't have to create a html page dynamically but put a html page in your addon and refer it when you open a tab.
tabs.open({
url : self.data.url("js/error.html"),
onReady : function(tab) {
var errorWorker = tab.attach({
contentScriptFile : self.data.url("js/error.js")
});
errorWorker.port.emit("error_page",message);
}
});
Here I am displaying an error page which is stored in my addon and attaching a content script file to dynamically change the contents of html page through message passing between main.js and error page.
Hope it is of some use to you.
Issue: I am unable to access portlet action URL from within panel in my struts2 liferay portlet.
Description:
I need to access "var"
<portlet:actionURL var="Overview" ../>
from inside
<sj:tabbedpanel href=%{Overview}.../>
but I am unable to access it , it gives blank value!
options I have tried:
<sj:tab href=${Overview}..../>
It gave exception:"according to tld or attribute href, does not accept any expressions" ,
also tried <sj:tab href=%{#Overview}..../>
didnt gave any exception but it did not fetch any value either.
Please help!!
Users open documents by links in old format http://server/db.nsf/VIEW_UNID/DOC_UNID. The form has property set to open XPage instead.
Origin of these links is email notification generated by "universal agent". It simply sends link to document. It does not know, what form is associated with what XPage, therefore it generates universal links instead of "/page.xsp&documentId=...".
The problem: relative links computed at client do not work - < a href = "/page.xsp?params"> should be more effective - no roundtrip and easy to compute at page load. They evaluate to http://server/db.nsf/0/page.xsp?params, what ends with Error 404, naturaly.
XPage contains "help" section, what is another document with RT field containing text, images and links. And relative links in that RT field work when XPage is opened from another XPage - view (/page.xsp), but fail when redirected from notification link (/0/UNID).
Question: How to effectively reset browser's address bar to extended XPages format http://server/db.nsf/page.xsp?documentId=DOC_UNID after opening redirected documents/views by old fashioned URLs?
Main problem is in discrepancy of relative links on server side (evaluated in SSJS) and client side (evaluated by browser). I have solved my problem by simple redirect in case document is open by old fashioned link.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:eventHandler event="onClientLoad" submit="false">
<xp:this.script><![CDATA[var url = "#{javascript:context.getUrl()}";
var l = window.location;
if (url != l) {
window.location.replace(url);
}
]]></xp:this.script>
</xp:eventHandler>
</xp:view>
Simply said, if open URL differs from internal URL (as resolved by XSP engine), browser redirects to correct URL. This solved many problems we had with inline images (image resource) and attachments.
Try "./page.xsp¶ms" or ../ if you want to go back to the root - I have noticed IBM do this in their coding as well. Hope this helps.
Have you tried to set pageBaseUrl property in your XPages? This would help to repair the relativ links:
<xp:this.pageBaseUrl>
<xp:baseUrl>
<xp:this.href><![CDATA[#{javascript:"http://stackoverflow.com/"}]]></xp:this.href>
</xp:baseUrl>
</xp:this.pageBaseUrl>
Another idea is to do a redirect in beforePageLoad-event in the XPage if the URL is in old fashioned style.