开发者

Linking to a Page that "contains" a specific Web Content Article in Liferay 6

I'm building a Portlet for a site powered by Liferay EE 6.0 SP1 that will suggest related or otherwise interesting content depending on what the user is currently looking at.

For example, suppose the user is on a Page that contains a Web Content Display portlet that is displaying Web Content Article 5. My portlet will contain HTML links to the Pages where the user can view Web Content Articles 6 and 7 (which contain content that is determined to be similar to the content in Web Content 5).

The problem comes in because I don't want my portlet to display HTML links to Web Content Articles 6 and 7 (assuming such a concept is even valid), I want my portlet to display links to the Pages on w开发者_StackOverflow社区hich those items are displayed (i.e., links to the Pages that contain Web Content Display portlets configured to show those Web Content Articles).

Is there a way to:

  • Associate a Web Content Article with a Page so that if I have the former, I can fetch the latter?
  • Or, determine the page(s) that contain portlets that display a Web Content Article?

Alternatively, if there were a way to get all portlet instances associated with a particular page, that might lead to a solution as well.


One approach to this problem appears to be to add a "Link to Page" control to the Web Content Article's Structure. Content managers can use this to create many-to-one relationships between Web Content Articles and Pages.

This solution is problematic, though, because there is no constraint on what page is selected when the Web Content is edited.

For example, a content manager might create a Web Content Article entitled "Our History", but specify the "Products" page as the value of that Article's "Link to Page" control. When the related content portlet renders the "Our History" Article, it will create a hyperlink to the "Products" page which in this case does not display the "Our History" Article anywhere.

Arguably, this could be considered a feature, but perhaps there is a better way to do it.


I afraid this is a feature that does not exist yet on Liferay. At least on Liferay pages there is an feature request on the very same topic. Dates on the discussion are on March 2011 so probably something is coming soon :)


Another solution that we are currently considering is to create a custom view mode for the portal (i.e., "VIEW", "PRINT", etc.) called "XML". When the portal detects that the browser is requesting the XML mode (similarly to how Sitecore detects which device to use), it bypasses the theme, and all portlets that support this XML mode would render their content in XML format.

The output might look something like this:

<?xml version="1.0" encoding="utf-8" ?>
<portal>
  <portlet id="..." title="..." ...>
    <JournalArticle>
      <uuid_>...</uuid_>
      ...
    </JournalArticle>
    ...
  </portlet>
</portal>

A periodic process would then crawl the site in XML mode and update a Lucene index.

The obvious problem with this approach is that it requires that every portlet we use on the site be custom-developed. For various reasons (some would call it an over-ambitious creative department; I call it a significantly deficient existing feature set), we might end up having to go this route anyway.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜