(888) 685-3101 ext. 2

Liferay Resources Importer
I’m going to share with you some tips and tricks I’ve used to keep track of changes with web content during the development stage of a project. To set up the scene, I’m a Front-End developer on a small project with a few back-end developers. The client has a lot of starter content existing in their mock-ups that they want created on the development server and then moved to the QA environment. During these beginning stages of development other developers may want their local environment to be as close to the development server as possible. This is where we can let Resources Importer do the heavy lifting to help us generate a .LAR file that can be imported to each developer’s local environment.

If you are not familiar with resources importer, it allows you to package content, pages, documents, and configurations inside a Liferay theme. Then when the theme is deployed it will create a site template or a site depending on the configurations. In Liferay, web content can be created using structures and templates. As the client gives feedback these structures and templates may change over time. During the development stage of the project, it’s a good idea to put these structures and templates into your source control system (svn, git). The resources importer uses a common pattern to organize the files in a way that the dependencies make sense. The folder structure explains which templates are linked to which structures, then which template to use for the web content article.

Ok now I’m going to get into the technical steps to using the resources importer.

Step One – require resources importer dependency and set to developer mode.
/WEB-INF/liferay-plugin-package.properties add the following properties.


required-deployment-contexts=
resources-importer-web

resources-importer-developer-mode-enabled=true

the developer mode will delete and rebuild the site template when the theme is deployed. (Note: don’t apply the site template to a site until all of the development is done, the developer mode can not delete a site template when it is being used by a site)

Step Two – organize folders (the folders below are for maven)


sample-theme
  - src
    - main
    - resources
      - resources-importer
        - document_library
          - documents
            - journal
              - articles
              - structures
              - templates


 

Step Three – define your pages/layouts in sitemap.json file
Create a sitemap.json file located at sample-theme/src/main/resources/resources-importer/


{
  "layoutTemplateId": "1_column",
  "publicPages": [
    {
      "friendlyURL":"/home",
      "name":"Home",
      "title":"Home"
    }
  ]
}

Step Four – create web content with structures and templates

First create the structure .xml for the web content. Place the file in sample-theme/src/main/resources/resources-importer/journal/structures/Basic Web Content.xml.
When creating the structure you must use Documents and Media for any images in order to reference them later in the journal article. Place the template file within the templates folder and have a folder match the structure name. sample-theme/src/main/resources/resources-importer/journal/templates/Basic Web Content/Basic Web Content.xml

Share This