Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>AFAIK, there is no <em>natual</em> way to make that happen. A portlet <strong>need not</strong> always be installed on a page. So, the behaviour is quite normal.</p> <p>One rather <em>hacky</em> solution I could think of:</p> <ol> <li><p>Get hold of the <code>ThemeDisplay</code> object in a JSP using <code>&lt;liferay-theme:defineObjects /&gt;</code> which would expose the implicit object <code>themeDisplay</code> in the JSP scope.</p></li> <li><p>Get hold of the type settings string using:</p> <pre><code>String typeSettings = themeDisplay.getLayout().getTypeSettings(); </code></pre></li> <li><p>Type settings will have values like the below:</p> <pre><code>layout-template-id=foobar_2column sitemap-include=1 column-1=foo_WAR_barportlet,abc_WAR_barportlet,56_INSTANCE_K4Vv, column-2=baz_WAR_xyzportlet, sitemap-changefreq=daily </code></pre></li> <li><p>So if you have a non-instanceable portlet with ID <code>foo</code> inside WAR file <code>bar</code>, the portlet's unique ID on the layout will be <code>foo_WAR_barportlet</code>.</p></li> <li><p>Once you know the portlet ID that you're expecting to be present, it's just a matter of string contains check.</p> <pre><code>&lt;% if(!typeSettings.contains("foo_WAR_barportlet")) { %&gt; &lt;h3 style="color: red"&gt;Alert! Portlet foo_WAR_barportlet not installed.&lt;/h3&gt; &lt;% } %&gt; </code></pre></li> </ol> <p>You can do the above steps even inside a theme, but you'll have to do it in Velocity instead of Java then. Hope that helps.</p> <p><em><strong>EDIT</em></strong></p> <p>You can add this line inside your <code>portal_normal.vm</code></p> <pre><code>#if(!$layout.getTypeSettings().contains("foo_WAR_barportlet")) &lt;h3 style="color: red"&gt;Alert! Portlet foo_WAR_barportlet not installed.&lt;/h3&gt; #end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload