I have tried with duplicating a Liferay web page using existing web page and followed these steps to duplicate a Liferay web page.
Log in to the Liferay -> Add (Click on the plus image) -> Select Page -> Enter the new page name -> Select any page layout -> Select Copy of a Page of This Site -> Select an existing page from the drop down menu -> Add Page
After duplicating the web page I have edited the contents of new web page.After edit I have found that original page web contents also updating the same time.How can I duplicate a Liferay web page without referencing the existing web page contents? I need to have new set of contents in the new page.My Liferay version is 6.2 CE GA4.
I have found a partial solution for this issue.I have to manually duplicate each web content and replace existing contents with new contents in the new page.
For duplicate each web content,
Log in to the Liferay -> Admin -> Content -> Click on down arrow icon in each web content -> Click on the copy option
Then change the title of each new content.(To identify duplicated contents separately)
EditLayoutsActionYes,
I have found solution for this particular situation where you want the clone of the web content which doesn't change that original page web content if you change the content in web content display portlet on cloned page.
I have done it through ext,
Create a ext plugin and then copy the below file,It contains the changes which will need to copy the web content as well.Deploy this ext and clone the page again. You have to override "EditLayoutsAction.java" (package is com.liferay.portlet.layoutsadmin.action) file which contains the clone logic.
In updateLayout(actionRequest, actionResponse) method find below code
if (copyLayout != null) {
if (copyLayout.isTypePortlet()) {
ActionUtil.copyPreferences(
actionRequest, layout, copyLayout);
Copy below code under found code
long companyId = themeDisplay.getCompanyId();
long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT;
int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT;
for (String portletId : portletllist) {
if(portletId.startsWith("56_INSTANCE"))
{
javax.portlet.PortletPreferences prefs = PortletPreferencesLocalServiceUtil.getPreferences(companyId,
ownerId,
ownerType,
copyLayout.getPlid(),
portletId);
String articleId = prefs.getValue("articleId", "1234");
if(!(articleId.equalsIgnoreCase("1234"))){
JournalArticle jArticle=JournalArticleServiceUtil.copyArticle(themeDisplay.getScopeGroupId(), articleId, "0", true, Double.parseDouble("1"));
javax.portlet.PortletPreferences newPrefs = PortletPreferencesLocalServiceUtil.getPreferences(companyId,
ownerId,
ownerType,
layout.getPlid(),
portletId);
newPrefs.setValue("articleId", jArticle.getArticleId());
PortletPreferencesLocalServiceUtil.updatePreferences(ownerId, ownerType, layout.getPlid(), portletId , newPrefs);
Then create ext and deploy it and follow the same clone process but now this time it will generate copy of the article so changes to cloned web content will not be reflected to original page.
Related
I have a custom themed orchard site - I am new to Orchard.
All pages have the same header with primary navigation, and footer. I have set header & footer up as Zones.
There are 4 main sections, 2 require a second navigation on the left; Information & FAQ.
I would like to dynamically create pages for those sections in the CMS - and have the page added to the appropriate second navigation menu, then when clicked navigate to that page (showing the correct navigation menu on the left - with the right styling for the rest of the page).
In simple steps what's the best way to do this - and does it need me to edit the Layout or other files in Visual Studio (I can if required).
I have found several articles on this online - but they all apply to completed themes, not one being created from scratch.
(I also don't have this 'map' of the site on the widgets page - how / should I create one somehow?):
Thanks.
As i understood what you are after is creating a Widget. Basically to show any content in your page you must create appropriate ContentType and attach required parts to it , and to display it you must enter url of that content in browser's address bar or click in a link for that content which in either case it will navigate to a new page and will display content inside [Content] Zone. but if you want to display a Content in a special Zone and special pages, Creating a Widget is the way to go.to create a widget the only thing required is to add a WidgetPart to it and give it Stereotype of 'Widget'.you can do this by making following changes in Migration file for your desired ContentType :
ContentDefinitionManager.AlterTypeDefinition("MyType", cfg => cfg
.WithPart("WidgetPart")
.WithPart("CommonPart")
.WithSetting("Stereotype", "Widget"));
this will turn your Content Type into a widget which can be placed in any Zone you want.
to add your widget to a Zone navigate to widgets from dashboard.
and then select the zone which you want to place your widget in :
and then select your widget
and finally select the layer in which your widget will be shown.a layer is set of rules which determine in which pages your widget will be displayed.for example selecting homepage will display your widget only in home page, selecting default will display your widget in all pages and so on.to define your own rule check here.
Edit :
to create new zone in your theme just include the Zone name in theme.txt file then open up Layout.cshtml (one resides in your custom theme's view directory) , and do following :
given your zone name is SecondaryNavigation then add following code inside your theme
#if (Model.SecondaryNavigation != null)
{
<div id="secondary-navigation" class="group">
<div class="inner">
#Zone(Model.SecondaryNavigation)
</div>
</div>
}
with this an additional Zone will be displayed in zone list and then you can put your widget inside your newly created zone.and about that picture you asked about.it is an image file which created by author of the theme and named 'Theme.png' and will displayed as a preview in manage widget screen , you can create it for your own theme and put it in your theme view directory.
EDIT 2
The migration file itself is not important.the only thing which is important is to define a class which drives from DataMigrationImpl , orchar will pick your migration file and run it automatically , migration file has firstly a Create method which returns 1 , and for each further update you must define a method called UpdateFromN in which N is current version your module is in, that will return 2 , 3 , ... what you can do in a migration file is creating database tables , creating ContentTypes , ContentParts , ContentFields , etc. there is already couple of modules shipped with orchard , check them and get the idea.
I am using JDeveloper 11.1.2.3.0
I have to show a popup by clicking a link that is located in the page template. For this I created a popup within the pageTemplate then inserted a dialogBox and within the dialog box I dragged and dropped my VO from the DataControl panel and inserted it as an ADF form. The problem is that when I run and click the link (that contains the "ShowPopupBehavior") I am getting this error:
//C:/Oracle/Middleware/jdeveloper/jdev/system11.1.2.3.39.62.76.1/MyNew/ViewControllerWebApp.war/WEB-INF/templates/myTemplates.jsf #58,118 value="#{bindings.TypeName.inputValue}": Target Unreachable, 'TypeName' returned null
ADF_FACES-60097:For more information, please see the server's error log for an entry beginning with: ADF_FACES-60096:Server Exception during PPR, #2
This happens for every View that I can insert here. Is this comming because I am not allowed to insert ADF forms within the page template?
If so please give me a hint to achieve what I explained in the first sentence.
I just figured out the solution to this problem. Each page has its own bindings, so a page that uses the templates (or if want to use bindings from other pages) has to declare that page in the Executables section of the page Bindings. The new executable should have the ID of the page (of the template in this case) and the path of the page. Then the bindings of the template can be accessed as explained here:
public String cb1_action() {
BindingContext bctx = BindingContext.getCurrent();
DCBindingContainer bindings =
(DCBindingContainer)bctx.getCurrentBindingsEntry();
//access the page template Pagedef file reference in the
//Executable section of the consumer page's Pagedef file
DCBindingContainer templateBinding =
(DCBindingContainer)bindings.get("ptb1");
//get the MethodBinding
OperationBinding printMethod =
(OperationBinding)templateBinding .get("printThis");
//invoke the print method exposed on the template's PageDef file
printMethod.getParamsMap().put("message","Hello World");
printMethod.execute();
return null;
}
https://blogs.oracle.com/jdevotnharvest/entry/how_to_invoke_adf_bindings
ps: Pay attention not to bind the value of the template in your page ex: value="#{bindings.ptb1}" - it is a bit strange but in this case you will not get the page bindings and will get only the template ones.
The value property containing #{bindings.ptb1} should be removed from the pageTemplate tag but the ptb1 reference has to be in the pages PageDef file.
I'm trying to use a Web content Display to show all the files in a particular folder of document library.
I would like to keep customize the choice of the folder.
Do you know if exist a dynamic element in template that point to a folder not to a specific field in the document library?
If is not possible someone know a different way to do that?
thanks in advance
Sabrina
You can create structure that holds text field for folderId named "folderId".
Than create template
#set($service = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService"))
#set($gid = $getterUtil.getLong($request.get("theme-display").get("scope-group-id")))
#set($fid = $getterUtil.getLong($folderId.getData()))
#set($files = $service.getFileEntries($gid, $fid))
#foreach($doc in $files)
#set($uet = $httpUtil.encodeURL($htmlUtil.unescape($doc.getTitle())))
$doc.getTitle()<br />
#end
Create article by that template/structure and enter folder id that you want to display. Add "Web content display" portlet that displays this article.
UPDATE:
For Liferay 6.1 method signature was changed and is
List<DLFileEntry> getFileEntries(long groupId, long folderId, int start, int end, OrderByComparator obc)
So for liferay 6.1 you should change call to be at least
#set($files = $service.getFileEntries($gid, $fid, -1, -1, null))
or change for start/end/sort.
You could use the Document Library Display portlet to accomplish this.
I'm trying to make the Liferay (6.0.6) Asset Publisher publish all changes across multiple communities on the portal homepage. By clicking on a link the user is supposed to be redirected to another community and see the new web content. The problem is that the default behaviour of asset publisher (even with the hook to gather info from all communities) tries to get the url by searching the group of the current page (in which the content is not).
I decided to change the jsp showing the page to search all pages across all communities and find the first one containing the portlet with the desired web content. So
How could I get the portlet containing the web content by journal id of the web content?
How could I get the page containing the portlet?
Thanks
The PortletPreferences table in the database contains the configurations of each portlet in the system. The configuration of an articleId for a Web Content Display portlet is stored as a preference in this table. If you look at that table, there are 3 important columns:
plid contains the id of the Layout (=page) on which the portlet was dropped.
portletid contains the instance id of the portlet. For Web Content Display portlet, this ID has the format 56_INSTANCE_XXXX where XXXX is a unique hash.
preferences is an XML formatted string of all preferences and their values for this portlet.
An example of the preferences XML:
<portlet-preferences>
<preference><name>group-id</name><value>10139</value></preference>
<preference><name>article-id</name><value>14295</value></preference>
</portlet-preferences>
So it's just a question of getting your SQL queries right. As far as I know, there is no service you can call directly for this.
SELECT l.friendlyURL
FROM PortletPreferences p, Layout l
WHERE p.plid=l.plid
AND p.portletid LIKE '56_INSTANCE_%'
AND p.preferences LIKE '<preference><name>article-id</name><value>14295</value></preference>';
Something like the following allows you to find the Layout on which an article is Rendered.
List<Long> layoutIds = JournalContentSearchLocalServiceUtil.getLayoutIds(groupId, false, articleId);
long layoutId = 0;
if (!layoutIds.isEmpty()) {
layoutId = layoutIds.get(0).longValue();
Layout layout = LayoutLocalServiceUtil.getLayout(groupId, false, layoutId);
String url = PortalUtil.getLayoutURL(layout, themeDisplay);
...
}
I have a custom webpart and when it first renders I want to give link to open modify shared webpart properties as we generally get when we open OOB webparts like Content editor or XML webpart? Any one is having idea on this ...I was using this but when I m clicking on it, its showing following error
I m using this:
LiteralControl lctrl = new LiteralControl();
lctrl.Text=string.Format("<a id='MsoFrameworkToolpartDefmsg_{0}' href=\"javascript:MSOTlPn_ShowToolPane2Wrapper('Edit','129','{0}');\">Open the tool pane</a> and enter a valid value.",this.ID);
Controls.Add(lctrl);
ERROR: A Web Part you attempted to change is either invalid or has been removed by another user.Click to refresh it.(This its showing in my toolpane)
Taken from a working webpart:
myvar = "Open the toolpanel"
"ID" is the webpart ID. I use a UserControl to hold my WebPart code, so I use Parent.ID