掲示板

How to get Database Services into theme by using FTL in liferay 7 ?

7年前 に lokesh gorrela によって更新されました。

How to get Database Services into theme by using FTL in liferay 7 ?

Regular Member 投稿: 173 参加年月日: 16/03/09 最新の投稿
Hi guys

I want to use below requirements:

1) Use Database Services into theme by using Free Marker template language in liferay 7.
2) How to get Portlet URL into theme by using Free Marker template language in liferay 7.

Any one knows about this requirements please give replay.

Thanks
With Regards
Lokesh
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: How to get Database Services into theme by using FTL in liferay 7 ?

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
You cannot and should not do either of these things.

A theme is just supposed to decorate what is on the page. The theme is processed during every page render. So you don't want to do #1 because any slow processing code (such as accessing db) will make all pages using the theme appear to be slow.

A theme is also supposed to be agnostic - it doesn't and should not know what is being placed on the page and should not even care. Even portlets embedded in the theme are just runtime execs, the theme doesn't really communicate with the embedded portlets, it is just making sure they are included.

If you are doing or have done any of this, stop right now and rethink what you are doing, do things the Liferay way or you'll pay the consequences in rework later on.
7年前 に lokesh gorrela によって更新されました。

RE: How to get Database Services into theme by using FTL in liferay 7 ?

Regular Member 投稿: 173 参加年月日: 16/03/09 最新の投稿
Thanks for your replay.

In liferay 6.2 I have one functionality i.e I have created one theme and I provided one hyper linke i.e Feedback in that theme. This Feedback hyper link contains FeedbackManagementSystem-portlet. After that applied theme to organization. Whenever I click on Feedback link It is render to FeddbackManagementSystem-portlet after that portlet is showed in Pop Up. This functionality is working fine 6.2

Liferay 6.2 theme code for FeedbackManagementSystem-portlet show in Pop up:

#set($feedbackportletURL = $portletURLFactory.create($request,"feedback_WAR_FeedbackManagementSystemportlet",$themeDisplay.getPlid(),"RENDER_PHASE"))
$feedbackportletURL.setWindowState("pop_up")
$feedbackportletURL.setPortletMode("view")

<script src="$javascript_folder/jquery-1.4.2.min.js"></script>
<script>
function showPopup() {
try{
AUI().use('aui-base',
'aui-io-plugin-deprecated',
'liferay-util-window',
'liferay-portlet-url',
'aui-dialog-iframe-deprecated',
function(A) {
// var url =Liferay.PortletURL.createRenderURL();
// url.setPortletId("PortletY_WAR_OpenPortletAuiDialgportlet_INSTANCE_S4Rs");
// url.setWindowState('pop_up');
var popUpWindow=Liferay.Util.Window.getWindow(
{
dialog: {
centered: true,
constrain2view: true,
modal: true,
resizable: false,
width: 700,
height:640
}
}
).plug(
A.Plugin.DialogIframe,
{
autoLoad: false,
iframeCssClass: 'dialog-iframe',
uri:'$feedbackportletURL'
}).render();
popUpWindow.show();
popUpWindow.titleNode.html("Let us know");
popUpWindow.io.start();
});
}catch(e){
//alert(e);
}
}
</script>


<ul>
<li>
<img src="$themeDisplay.getPathThemeImages()/feedback.gif" title="feedback">
<a href="javascript:void(0);" onclick="showPopup();" style="coloremoticon063e53;font-size:12px;">Feedback</a>
</li>
</ul>



How to achieve this same functionality in liferay 7 GA2 ? Could you please tell the suggestion for achieve this functionality lifeay 7 GA2.
thumbnail
7年前 に Trevor Burkholder によって更新されました。

RE: How to get Database Services into theme by using FTL in liferay 7 ?

New Member 投稿: 3 参加年月日: 13/03/22 最新の投稿
lokesh gorrela:
Thanks for your replay.

In liferay 6.2 I have one functionality i.e I have created one theme and I provided one hyper linke i.e Feedback in that theme. This Feedback hyper link contains FeedbackManagementSystem-portlet. After that applied theme to organization. Whenever I click on Feedback link It is render to FeddbackManagementSystem-portlet after that portlet is showed in Pop Up. This functionality is working fine 6.2

Liferay 6.2 theme code for FeedbackManagementSystem-portlet show in Pop up:

#set($feedbackportletURL = $portletURLFactory.create($request,"feedback_WAR_FeedbackManagementSystemportlet",$themeDisplay.getPlid(),"RENDER_PHASE"))
$feedbackportletURL.setWindowState("pop_up")
$feedbackportletURL.setPortletMode("view")

<script src="$javascript_folder/jquery-1.4.2.min.js"></script>
<script>
function showPopup() {
try{
AUI().use('aui-base',
'aui-io-plugin-deprecated',
'liferay-util-window',
'liferay-portlet-url',
'aui-dialog-iframe-deprecated',
function(A) {
// var url =Liferay.PortletURL.createRenderURL();
// url.setPortletId("PortletY_WAR_OpenPortletAuiDialgportlet_INSTANCE_S4Rs");
// url.setWindowState('pop_up');
var popUpWindow=Liferay.Util.Window.getWindow(
{
dialog: {
centered: true,
constrain2view: true,
modal: true,
resizable: false,
width: 700,
height:640
}
}
).plug(
A.Plugin.DialogIframe,
{
autoLoad: false,
iframeCssClass: 'dialog-iframe',
uri:'$feedbackportletURL'
}).render();
popUpWindow.show();
popUpWindow.titleNode.html("Let us know");
popUpWindow.io.start();
});
}catch(e){
//alert(e);
}
}
</script>


<ul>
<li>
<img src="$themeDisplay.getPathThemeImages()/feedback.gif" title="feedback">
<a href="javascript:void(0);" onclick="showPopup();" style="coloremoticon063e53;font-size:12px;">Feedback</a>
</li>
</ul>



How to achieve this same functionality in liferay 7 GA2 ? Could you please tell the suggestion for achieve this functionality lifeay 7 GA2.


The following will work in Liferay 7 DXP

AUI().use(
    'aui-base',
    'aui-io-plugin-deprecated',
    'liferay-util-window',
    'liferay-portlet-url',
    'aui-dialog-iframe-deprecated',
    function(qlToggle) {
        qlToggle.one('#YOUR-BUTTON-ID').on('click',
            function(event){
                var url =Liferay.PortletURL.createRenderURL();
                url.setPortletId("YOUR PORTLET ID")  //Quick Links Portlet
                url.setWindowState('pop_up');
                url.setPlid("YOUR_PLID");
                var popUpWindow=Liferay.Util.Window.getWindow(
                    {
                        dialog: {
                        	/*insert custom parameters here, such as width, height, zindex*/
                        }
                    }
                ).plug(
                    qlToggle.Plugin.DialogIframe,
                        {
                            autoLoad: false,
                            iframeCssClass: 'dialog-iframe',
                            uri:url.toString()
                        }).render();
                popUpWindow.show();
                popUpWindow.titleNode.html("TITLE");
                popUpWindow.io.start();
            }
        );
    }
);
thumbnail
7年前 に Olaf Kock によって更新されました。

RE: How to get Database Services into theme by using FTL in liferay 7 ?

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
lokesh gorrela:
Thanks for your replay.

In liferay 6.2 I have one functionality i.e I have created one theme and I provided one hyper linke i.e Feedback in that theme. This Feedback hyper link contains FeedbackManagementSystem-portlet. After that applied theme to organization. Whenever I click on Feedback link It is render to FeddbackManagementSystem-portlet after that portlet is showed in Pop Up. This functionality is working fine 6.2

Liferay 6.2 theme code for FeedbackManagementSystem-portlet show in Pop up:


In addition to the code sample that is already here: You can figure out a portlet's id by checking "Advanced Styling" in "Look & Feel": Liferay 7 will generate most portlet's IDs differently as it's now no longer based on WAR files (unless you deploy them as WAR files, but I haven't looked at the ID-generation in that case).

Funny enough: The feedback-link that you generate does not require any database access at all, right?

And if you really need interactivity on the page, you can also always embed individual portlets in the theme. As David says, you better make sure they're blazingly fast though, because they will be part of every page load.