Automatic way of export / import pages from liferay - liferay

I have created portlets for liferay and prepare couple of pages. Now I want to create installation script, which create pages definition in customer liferay server. I know that pages export/import is possible using LAR file, but this could be done only manualy, or using remote publishing which i am not able to do.
I was searching on net and found ddm tool. Which should be able to do that. Unfortunately i'm not able to get it work as it export only web content, blogs, wikis, etc, but not pages with portlets. It is probably because one of the condition is "Every Template must be assigned to a Structure. Don't create any templates on the Liferay server which does not have a structure connected to it.
". But how can I assign page to structure ? Cant find anything.
Or is there any other option for automatic page creation, which could be used ?

In case you created a custom theme, you can easily use the "resources importer" to create an entire site via the "sitemap.json" file (define pages: choose layout, assign portlets to the columns, ...). You can also export existing content as xml from the current instance and import them via the theme. Same thing for web content structures and templates.
for more details: https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-1/importing-resources-with-your-themes

Unfortunately theme is produced by another supplier, so this solution isn't suitable for me.
at the end i find working solution which consist of following steps:
create plugin hook
in hook setup upgrade process
in the upgrade process create pages with appropriate layout, friendlyUrl, etc. All these is possible to do using liferay api
Don't have enough reputation, so at least two links
https://www.liferay.com/de/web/james.falkner/blog/-/blogs/7cogs-is-dead-long-live-7cogs-
https://github.com/azzazzel/liferay-official-plugins/tree/master/hooks/sevencogs-hook/docroot/WEB-INF/src/com/liferay/sevencogs/hook/upgrade

Related

How can I create Liferay web content structure's outside of Liferay configuration?

I'm very new to Liferay theme development and i'm trying to find the most optimal workflow for development.
So I've been experimenting with creating Web Content Templates and Web Content Structures within Liferay CMS configuration.
What I would ideally like to do is create my view "Web Content Structure" outside of Liferay configuration and instead have it as a view/template inside my theme files so that I can have my code peer reviewed and version controlled in Bitbucket.
Is this possible?
Alternatively is there a way to output the values of a given web content instance within my theme?
I'm building a theme for Liferay 7 by the way.
Thanks in advance
Richard
You can copy and paste the structure when you create them form the LFR editors into your source code repository.
Also if you know how to define the JSON you can do it straight in the file. The free market templates are even easier to edit in file format. When you're done, you need to go and upload the artefacts to the portal via the editor/file upload option.
You can't stick it into the theme because that approach would not allow you to do updates.
You can search for a community plugin or write your own one that would do structure/template updates during deploy.

Liferay: How can I get the pages of the site in a web content?

I have a portal in Liferay 6.2, and need to design the velocity template of a web content that must have a menu listing the pages (linked names) of the site where is present.
My questions are:
Is this possible?
What would be the correct way to do this?
Would it be better to make a portlet instead of a web content for this purpose?
Thanks for the help.
It feels a bit like you are trying to solve many problems in a single template - consider to compose the UI from many different elements (e.g. custom portlets) rather than building the one structure/template that fits all requirements.
That being said, as there's also the chance that your template doesn't do more than just displaying the current navigation: You have two options: The out-of-the-box Navigation portlet is quite configurable, you might be able to utilize that one instead of implementing anything yourself (check the configuration options).
And lastly, if you want to implement for yourself: Get hold of the themeDisplay object. With getLayout() you'll get the current page, while getLayouts() you'll get all pages of the current site and can enumerate them. However, there's one problem: You typically don't have access to the themeDisplay object from a CMS template. But there are several ways to still get to the data (search the Liferay forums for cms template themedisplay). Also, an Application Display Template will be a lot more powerful - and you can also check how the layouts collection is built - just search for usage of ThemeDisplay.setLayouts in Liferay's source code. But with ADT we're diverting from your original question.
Liferay offers a sitemap portlet out-of-the-box which lists pages of a site. You can configure it and define your own application display template (ADT).

Liferay create site / page programmatically

I have been using Liferay for work for 2 weeks. I noticed that it's a bit difficult to find good documentation and tutorials.
Until now I created pages from the web portal. After I create them, I drag and drop portlets. I don't really like this approach, I would prefer to use a coding approach. Is there a way to create a website or page programmatically by defining a project as I do to create portlets?
Moreover, I am using Liferay with WebLogic 10.3.6. I want to know where liferay puts pages I created via web-portal on the file system. I suppose that a file, or something similar, is created when I declare a new site on the Liferay web-portal.
Thank you all,
Marco
Yes Liferay has it's Database, all data of any Liferay object is stored in the database and / or on the file system depending on your configuration.
However, one of the functionality of Liferay is to let you create pages / sites through the UI. As documented in the Java Portal Specification and Liferay Server Documents your approach to create pages in an alternative way is possible but it is part of Liferay's Portal Services. You can use Liferay's Service (HTTP REST) API to call the related service. To access those APIs you need to configure your Liferay Server.
In case you want to do programmatically you still need to configure, enable and call those external HTTP services from your code. You should not create Liferay Objects from your own code hosted as an extension inside your Liferay Instance as that will result inconsistency in your Liferay Database / filesystem. (As in case of page creation Liferay creates a set of other related objects in it's database / filesystem.)
In your liferay bundle you will find two plugins of interest.
First is resources-importer-web for which description says
The Resources Importer app allows front-end developers to package web
content, portlet configurations, and layouts together in a theme
without saving it as a compiled .LAR file thereby allowing for greater
flexibility in its usage between Liferay Portal versions.This app will automatically create associated content when other
plugins are deployed that are configured to make use of the Resource
Importer app.This app installs as a Liferay service.
Second is welcome-theme which declares resources to be created by resources-importer-web. This on should be example how to create your own. Take a look at
welcome-theme\WEB-INF\src\resources-importer\*
welcome-theme\WEB-INF\liferay-plugin-package.properties
This feature is described at importing-resources-with-themes
As mentioned by gabor_the_kid, Liferay stores all objects in its tables. For example, User related objects would be in user table. Liferay exposed services or API's to change the default/to add new behaviors by program but not easier than achieving it through UI. Also maintenance should be considered for going program way of creating pages or layouts etc.
You can describe your changes using xml and use the Liferay Portal DB Setup core to create the changes in DB.
The library defines the list of available xml configurations.

Replicate pages from OpenCms to Liferay

I know this is a duplicate post but I needed help here. I had posted about my query before on how should I approach to migrate a website which is currently in OpenCms into Liferay.
I will share whatever I have found on internet and a reply that I got in one of the forums here on stackoverflow.
I was suggested to use ftl templates. but won't it be like executing the code everytime the user makes changes to a web page?
The website has static as well as dynamic pages. I need a way to recreate them in liferay so that in future if the users wish to change the data content of website they can do so easily. IN case of dynamic pages they will upate their database. IN case of static pages they would want to change data (if required) from liferay framework.
How should I create templates and add pages that use a particular template and also add content to the pages?
SHould I write a code or can I do directly from the liferay UI ? Is there a quick way to do this?
Regards

Which is the better approach in custom pages?

I want to create a custom new item page for sharepoint but there are two approached that I
can use and I want to share your experience in determining which is better.
The first: is to create a page in a library then create a C# library project to handle
the events of the controls on the page.
The second: is to define a feature of the content type of my list and specify the new
item form to be my custom form, then create a website containing the custom form and put
this site at the layouts folder.
for me the first approach is fine but the problem is that a user may access the default
sharepoint new item form which I don't want to happen.
but I don't like the idea of placing the form in a library on the site.
so which is better in your opinion ?
thanks
i suggest you to go with your second approach ...
Create a completely new feature that allows you add your functionalty of page creation and any customization realted to that and deploy this one to the 12 hive features folder as a new feature and every time you want have such a page created you can you this template and create the page...
Well, frankly, I'm confused by both of your suggestions.
I don't see how the first one would ever work.
And the second one; you don't "put sites in the layouts folder".
Here's what I would suggest you to do:
Download and install the WSS Extensions for Visual Studio.
Create a List Definition using these new templates.
Copy the NewForm.aspx from the 12 hive and Customize it.
Download and install the WSP Builder from Codeplex.com
Add your custom list definitions and files to a new Feature project in WSP Builder.
Package the Feature up to a .wsp using WSP Builder and you are good to go.
Your custom page(s) should be placed in your custom folders in my opinion.
Hope this helps.
Your concern in the first approach is that people will still be able to access the default form. If you are not opposed to using a custom control template for a content type definition, I recommend creating a very simple redirect control template and assigning it to the content type's "New Form". Such a control template need only contain one custom control, which has an OnInit or OnLoad method that contains little more than a Page.Response.Redirect call. Make that redirect point to the page you create in your first approach, and now whenever anyone tries to access the default new form for that content type, they will instead be directed to your custom page with all of your custom code. It is perhaps a bit of a hack, but it's definitely functional.

Resources