<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Wanted to add site programmatically in asset publisher scope.</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120594102" />
  <subtitle>Wanted to add site programmatically in asset publisher scope.</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120594102</id>
  <updated>2026-04-06T13:06:07Z</updated>
  <dc:date>2026-04-06T13:06:07Z</dc:date>
  <entry>
    <title>RE: Wanted to add site programmatically in asset publisher scope.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120663107" />
    <author>
      <name>Christoph Rabel</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120663107</id>
    <updated>2021-03-05T19:06:56Z</updated>
    <published>2021-03-05T19:06:56Z</published>
    <summary type="html">&lt;p&gt;Well, I can only guess what has to be done. I think, you have to
  iterate through all pages.&lt;/p&gt;
&lt;p&gt; List&amp;lt;Layout&amp;gt; pageLayouts = layoutLocalService.getLayouts(-1,-1);&lt;/p&gt;
&lt;p&gt;// That's probably too many, you probably want to fetch only layouts
  of a particular site&lt;/p&gt;
&lt;p&gt;for(Layout pageLayout : pageLayouts {&lt;/p&gt;
&lt;p&gt;// Now, you need to find the portlets on these pages&lt;br /&gt; 
  LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet)
  pageLayout.getLayoutType();&lt;br /&gt;  List&amp;lt;String&amp;gt; portletIds =
  layoutTypePortlet.getPortletIds();&lt;br /&gt;  for (String portletId :
  portletIds) {&lt;/p&gt;
&lt;p&gt;// Now, we need the portlet preferences for each of these
  portlets&lt;br /&gt;    PortletPreferencesIds portletPreferencesIds =
  PortletPreferencesFactoryUtil.getPortletPreferencesIds(pageLayout.getGroupId(),
  pageLayout.getUserId(), pageLayout, portletId);&lt;br /&gt;   
  PortletPreferences portletPreferences =
  portletPreferencesLocalService.getPreferences(portletPreferencesIds);&lt;br /&gt;    
  String values = portletPreferences.getPreferences();&lt;/p&gt;
&lt;p&gt;// Check what's in there, then update it&lt;br /&gt;  }&lt;/p&gt;
&lt;p&gt;I would try that on one page, to check if it even contains the
  relevant information. I could be totally off here, I just pieced it
  together from the API.&lt;/p&gt;</summary>
    <dc:creator>Christoph Rabel</dc:creator>
    <dc:date>2021-03-05T19:06:56Z</dc:date>
  </entry>
  <entry>
    <title>RE: RE: Wanted to add site programmatically in asset publisher scope.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120660934" />
    <author>
      <name>Sanat D</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120660934</id>
    <updated>2021-03-05T07:29:50Z</updated>
    <published>2021-03-05T07:29:50Z</published>
    <summary type="html">&lt;p&gt;I wanted to do achieve this for page where my asset publisher is
  there.Do you have any sample code?&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; regards.&lt;/p&gt;</summary>
    <dc:creator>Sanat D</dc:creator>
    <dc:date>2021-03-05T07:29:50Z</dc:date>
  </entry>
  <entry>
    <title>RE: Wanted to add site programmatically in asset publisher scope.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120611615" />
    <author>
      <name>Christoph Rabel</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120611615</id>
    <updated>2021-02-12T16:49:25Z</updated>
    <published>2021-02-12T16:49:25Z</published>
    <summary type="html">&lt;p&gt;Tricky. Do you need this for a specific page/asset publisher?&lt;/p&gt;
&lt;p&gt;In any case: You probably would need to add a listener for groups to
  notice when a site is added.&lt;/p&gt;
&lt;p&gt;https://help.liferay.com/hc/en-us/articles/360018170891-Model-Listener&lt;/p&gt;
&lt;p&gt;And then you would need to read the configuration for the relevant
  asset publishers and add the id of the group to the xml. But this is
  quite difficult since you won't find a lot of sample code for
  something like that.&lt;/p&gt;</summary>
    <dc:creator>Christoph Rabel</dc:creator>
    <dc:date>2021-02-12T16:49:25Z</dc:date>
  </entry>
  <entry>
    <title>Wanted to add site programmatically in asset publisher scope.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120594101" />
    <author>
      <name>Sanat D</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120594101</id>
    <updated>2021-02-08T12:20:40Z</updated>
    <published>2021-02-08T12:20:40Z</published>
    <summary type="html">&lt;p&gt;Hello Everyone,&lt;/p&gt;
&lt;p&gt;Actually i have task such that after creating site that site should
  be added directly to the asset publisher scope feature. Can i acheive
  this? If yes, please let me know how can i achieve this? and no, than
  please provide reason for it.&lt;/p&gt;
&lt;p&gt;Thanks and regards.&lt;/p&gt;
&lt;p&gt;Happy Learining!!&lt;/p&gt;</summary>
    <dc:creator>Sanat D</dc:creator>
    <dc:date>2021-02-08T12:20:40Z</dc:date>
  </entry>
</feed>
