블로그 이미지
윤영식
Full Stacker, Application Architecter, KnowHow Dispenser and Bike Rider

Publication

Category

Recent Post

2014. 5. 27. 09:24 Study Frameworks/Liferay Portal

Template을 공유하는 방법에 대해 알아보자 



Resource Importer App 설치 

  - 템플릿 적용을 위해서는 Template Importer를 사용하는데 이는 Resources Importer App의 일부 기능이다. 

  - Liferay Makketplace 에서 Resources Importer App 다운로드 설치한다. (v2.0.1 CE 버전)

    + 오른쪽의 [Free] 버튼 클릭

    + 가입하고 로그인후 개인적 용도로 사용 선택

    + 구매내역으로 이동하면 [Download] 버튼을 클릭

    + 최종파일 : Resources Importer CE.lpkg

    + 최종파일을 $LIFERAY_PORTAL/deploy 폴더에 넣고 start 하면 tomcat webapps로 자동 배포된다

      

    또는 Control Panel로 이동하여 선택해서 설치할 수도 있다 

     


  - Resource Importer App 개념 

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.



Sample Template 적용하기

  - mobiconsoft_template 라는 portlet을 eclipse에서 생성한다

    

  - maven 기반이므로 pom.xml을 이전 블로그를 참조하여 수정한다

    

  - liferay-plugin-package.properties 안에 다음을 첨부한다. 또한 기존에 설정된 name 값을 삭제한다  

name=

module-group-id=liferay

module-incremental-version=1

tags=

short-description=

change-log=

page-url=http://www.liferay.com

author=Liferay, Inc.

licenses=LGPL


required-deployment-contexts=resources-importer-web

resources-importer-developer-mode-enabled=true

module-incremental-version=1

  - portlet.xml에서 <display-name> 태그도 삭제한다 

  - WEB-INF/src 밑으로 templates-importer를 만든다. 그러나 지금은 maven 기반이므로 src/main/resources 밑에 templates-importer 폴더를 생성한다 

   


  - samples-template-importer-content.zip 파일을 다운로드 받아 templates-importer 폴더 안에 푼다.  

    


  - 폴더의 구조

  • templates-importer/
    • journal/
      • structures/ - contains structures (XML) and folders of child structures. Each folder name must match the file name of the corresponding parent structure. For example, to include a child structure of parent structure Parent 1.xml, create a folder named Parent 1/ at the same level as the Parent 1.xml file, for holding a child structures.
      • templates/ - groups templates (FTL or VM) into folders by structure. Each folder name must match the file name of the corresponding structure. For example, create folder Structure 1/ to hold a template for structure file Structure 1.xml.
    • templates/
      • application_display/ - contains application display template (ADT) script files written in either the FreeMarker Template Language (.ftl) or Velocity (.vm). The extension of the files, .ftl for FreeMarker or .vm for Velocity must reflect the language that the templates are written in.
        • asset_category/ - contains categories navigation templates
        • asset_entry/ - contains asset publisher templates
        • asset_tag/ - contains tags navigation templates
        • blogs_entry/ - contains blogs templates
        • document_library/ - contains documents and media templates
        • site_map/ - contains site map templates
        • wiki_page/ - contains wiki templates
      • dynamic_data_list/ - contains dynamic data list templates and structures
        • display_template/ - groups templates (FTL or VM) into folders by structure. Each folder name must match the file name of the corresponding structure. For example, create folderStructure 1/ to hold a template for structure file Structure 1.xml.
        • form_template/ - groups templates (FTL or VM) into folders by structure. Each folder name must match the file name of the corresponding structure. For example, create folder Structure 1/ to hold a template for structure file Structure 1.xml.
        • structure/ - contains structures (XML)
      • page/ - contains page templates (JSON)


  - 이제 프로젝트를 선택하고 contentx menu를 통해 mobiconsoft_template 포틀릿을 배포한다. 

   

   배포가 성공하면 deploy 폴더로 자동 복사된다. 

[INFO] --- liferay-maven-plugin:6.2.1:deploy (default-cli) @ mobiconsoft_template ---

[INFO] Deploying mobiconsoft_template-1.0.0-SNAPSHOT.war to /liferay_portal/portal-6.2-ce-ga2/deploy

     [null] Copying 1 file to /liferay_portal/portal-6.2-ce-ga2/deploy

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 10.980s

[INFO] Finished at: Tue May 27 08:51:31 KST 2014

[INFO] Final Memory: 34M/525M

[INFO] ------------------------------------------------------------------------

 

   - 로그인후 Admin의 Control Panel을 선택하고 "Site"에서 Global을 선택한다 

   

  - Configuration의 "Application Display Templates"을 선택한다  

   

  - 리스트에 보면 첨부한 내역을 볼 수 있다. 이후 처리에 대한 부분은 to be continue... (문서에 정확히 안나와 있음)

  - template의 layout은 templates/page/*.json 으로 정의한다 

{

"layoutTemplate": {

"columns": [

[

{

"portletId": "58"

}

],

[

{

"portletId": "47"

}

]

],

"friendlyURL": "/page-1",

"name": "Page 1",

"title": "Page 1"

},

"layoutTemplateId": "2_columns_ii"

}


  * ant 기반 해당 포틀릿 소스



<참조>

  - Creating plugin to share template

  - Theme 정의하기

  - Liferay Dev Guide in GitHub

posted by 윤영식