This wiki does not contain official documentation and is currently deprecated and read only. Please try reading the documentation on the Liferay Developer Network, the new site dedicated to Liferay documentation. DISCOVER Build your web site, collaborate with your colleagues, manage your content, and more. DEVELOP Build applications that run inside Liferay, extend the features provided out of the box with Liferay's APIs. DISTRIBUTE Let the world know about your app by publishing it in Liferay's marketplace. PARTICIPATE Become a part of Liferay's community, meet other Liferay users, and get involved in the open source project. « Voltar para Web Content...
AJAX Loaded Articles
(Redirecionado de Load content articles dynamically)
Table of Contents [-]
Introduction #
This describes a way to dynamically load content articles based upon a certain URL Parameter passed to a single page.
Explanation #
Given a URL:
http://www.myurl.com/mypage?id=34523&gid=10136
First a little Javascript can be used to parse out the id url parameter. This functon is taken from http://www.netlobo.com/url_query_string_javascript.html:
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}Next, this function uses AJAX to grab the contents of the article:
function grabArticle(articleId, groupId) {
jQuery.ajax({
url: "/c/journal/view_article_content?groupId=" + groupId + "&articleId=" + articleId + "&version=1.0&p_p_state=exclusive",
success: function(data) {
jQuery('#content').html(data);
}
});
}Lastly, the grabArticle function is run onDocumentReady:
jQuery(document).ready(function() {
var eid = gup('id');
var groupId = gup('gid');
grabArticle(eid, groupId);
});All of this Javascript can be placed in a JS file that is dynamically loaded into a Velocity template theme.
29014 Visualizações