คอมไพล์เทมเพลทของคุณ

เมื่อคุณคอมไพล์เทมเพลทของคุณ การคอมไพล์จะสร้างเพจ HTML แบบสแตติกสำหรับเพจแต่ละเพจในไฟล์ structure.json สำหรับไซต์ภายในเทมเพลท

ขั้นตอนการคอมไพล์จะรวมเมตะดาต้าของเพจ (เช่น 100.json) กับเลย์เอาต์ของเพจ (เช่น about.html) เพื่อให้คุณมีเพจ HTML ที่จะแสดงผลได้ทันทีโดยไม่ต้องใช้คอนโทรลเลอร์ขณะรันไทม์ คอมไพเลอร์ที่กำหนดเองช่วยให้คุณสามารถลดรันไทม์ของการรัน JavaScript โดยการคอมไพล์รายการแบบไดนามิคก่อนหน้าลงในเพจ เช่น การนาวิเกตและองค์ประกอบ

คำสั่ง cec compile-template จะใช้การดำเนินการต่อไปนี้กับเพจแต่ละเพจในไซต์

  • อ่านข้อมูลในไซต์และเมตะดาต้าของเพจ
  • อ่านข้อมูลในเลย์เอาต์ของเพจและใช้คอมไพเลอร์เลย์เอาต์ของเพจต่างๆ
  • สำหรับแต่ละสล็อตบนเพจ ให้ทำดังนี้
    • ขยายสล็อตด้วยกริดที่กำหนดในไฟล์ page.json
    • สำหรับแต่ละองค์ประกอบภายในสล็อต ให้ทำดังนี้
      • ใช้คอมไพเลออร์ขององค์ประกอบต่างๆ
      • แทรกมาร์คอัปขององค์ประกอบที่สร้างในตำแหน่งที่สอดคล้องกันภายในสล็อต
  • ขยายมาโครใดๆ ในมาร์คอัปที่คอมไพล์ แล้วแทรกออบเจกต์ SCS JavaScript ที่ตัวแสดงผลของ Oracle Content Management ใช้ขณะรันไทม์
  • บันทึกมาร์คอัปของเพจที่คอมไพล์ภายใต้โฟลเดอร์ src/templates/<template>/static

ในการคอมไพล์ไซต์ของคุณ ให้รัน:

> cec compile-template BlogTemplate
Compile Template: compiling template BlogTemplate
Oracle Content Management Site Compiler

createPage: Processing pageId 100. Preview URL: 
http://localhost:8085/templates/BlogTemplate/index.html 
createPage: Processing pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail.html 
createPage: Processing pageId 401. Preview URL: 
http://localhost:8085/templates/BlogTemplate/about.html 
createPage: Processing pageId 402. Preview URL: 
http://localhost:8085/templates/BlogTemplate/search.html 
createPage: Processing pageId 403. Preview URL: 
http://localhost:8085/templates/BlogTemplate/authors.html 
All page creation calls complete.

Creating detail pages: 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063051-developing-content-layout- for-content-and-experience-cloud
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063052-dynamic-dom- manipulation-in-content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063045-getting-media-url-in- the-content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063053-getting-reference- items-in-content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063048-navigating-to-a- search-page-with-search-query 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063050-alex-read 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063047-jerrold-summers 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063049-kelly-emerson 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063043-samantha-howard 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063046-raising-triggers-from- content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063044-rendering-the-content- layout-using-mustache-template 
All detail page creation calls complete.

ข้อผิดพลาดการคอมไพล์

ระหว่างการคอมไพล์ คุณจะได้รับข้อความสามประเภทดังนี้ ข้อมูล คำเตือน และข้อผิดพลาด

  1. ข้อความแจ้งข้อมูลเป็นรายการเกี่ยวกับปัญหาที่คุณควรทราบ แต่ข้อความเหล่านี้อาจเป็นส่วนหนึ่งของการคอมไพล์ที่คาดหวังอยู่แล้ว
    • รายการเนื้อหาตัวจองพื้นที่ที่จะแสดงขณะรันไทม์
    • ไม่มีคอมไพเลอร์เลย์เอาต์ของเพจ เลย์เอาต์ของเพจอาจไม่มีอีลิเมนต์แบบไดนามิค ดังนั้นจึงไม่ถือว่าเป็นปัญหา หากเลย์เอาต์เหล่านั้นขาดหายไป
    • รายการต่างๆ ได้รับการทำเครื่องหมายเป็น "แสดงเมื่อเข้าใช้" ซึ่งหมายความว่า ผู้พัฒนาไซต์ต้องการให้แสดงองค์ประกอบนี้แบบไดนามิคขณะรันไทม์ แม้ว่าจะมีการคอมไพล์เพจก็ตาม
  2. ข้อความเตือนเป็นรายการเกี่ยวกับปัญหาซึ่งอาจส่งผลกระทบต่อประสิทธิภาพของไซต์ที่กำลังรันอยู่ และควรได้รับการแก้ไขหากเป็นไปได้ รายการในชนิดนี้ประกอบด้วย
    • ไม่มีคอมไพเลอร์เลย์เอาต์ของเนื้อหาหรือองค์ประกอบที่กำหนดเอง เมื่อไม่มีคอมไพเลอร์เหล่านี้ องค์ประกอบต่างๆ จะแสดงแบบไดนามิคไปยังเพจเช่นเดียวกับที่เคยทำก่อนหน้านี้
    • ไม่มีการแมปเลย์เอาต์ของเนื้อหา เป็นไปได้ว่าคุณแทบไม่จำเป็นต้องใช้เลย์เอาต์ของเนื้อหาดีฟอลต์ของระบบในการแสดงรายการเนื้อหาต่างๆ
  3. ข้อความแสดงข้อผิดพลาดเป็นรายการเกี่ยวกับปัญหาซึ่งระบุความล้มเหลวในการคอมไพล์ เพจต่างๆ จะดำเนินการคอมไพล์ต่อเมื่อเป็นไปได้ แต่การคอมไพล์โดยรวมจะออกจากการทำงานเมื่อมีข้อผิดพลาด
    • โดยมากแล้วปัญหานี้มักเกิดจากข้อผิดพลาดของ JavaScript ในคอมไพเลอร์ที่กำหนดเอง และข้อผิดพลาดต่างๆ ต้องได้รับการแก้ไข

หมายเหตุ:

หากต้องการลดจำนวนข้อความซ้ำ ข้อความที่เหมือนกันจะปรากฏเพียงข้อความเดียวต่อการคอมไพล์หนึ่งครั้ง โดยไม่คำนึงถึงว่าการคอมไพล์จะเกิดขึ้นบนเพจจำนวนมาก

ตัวอย่างก่อนหน้ามีสถานะการออกจากการคอมไพล์ต่อไปนี้

Compilation completed with 0 errors and 3 warnings. 
to display warnings, run with --verbose (-v) option.

หากคุณรันขั้นตอนการคอมไพล์อีกครั้งด้วยตัวเลือก "-v" คุณจะเห็นเอาต์พุตต่อไปนี้

> cec compile-template BlogTemplate --verbose
Compile Template: compiling template BlogTemplate 
Oracle Content Management Site Compiler

createPage: Processing pageId 100. Preview URL: 
http://localhost:8085/templates/BlogTemplate/index.html 
createPage: Processing pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail.html
Info: no content item specified for placeholder: a890a65c-c0fc-451b-966b-e606ca18a1f4 
component will render at runtime. 
Info: no content item specified for placeholder: c90bbc10-c9d8-4a54-8dd4-7a8251e8efbb 
component will render at runtime. 
Info: no content item specified for placeholder: f12691e1-79ab-4d1f-a8b9-3af8c638dd26 
component will render at runtime.
createPage: Processing pageId 401. Preview URL: 
http://localhost:8085/templates/BlogTemplate/about.html 
createPage: Processing pageId 402. Preview URL: 
http://localhost:8085/templates/BlogTemplate/search.html
Info: Component: "fdfd0392-e901-48f6-8044-36803c836aa1" of type "scs-contentlist" marked as 
"render on access", will not be compiled. 
Info: Component: "ba9f3711-4367-444e-ae38-71289fc10e73" of type "scs-contentlist" marked as 
"render on access", will not be compiled. 
createPage: Processing pageId 403. Preview URL: 
http://localhost:8085/templates/BlogTemplate/authors.html 
All page creation calls complete. 

Creating detail pages: 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063051-developing-content- layout-for-content-and-experience-cloud 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063052-dynamic-dom- manipulation-in-content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063045-getting-media-url-in- the-content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063053-getting-reference- items-in-content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063048-navigating-to-a- search-page-with-search-query 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063050-alex-read 
Warning: failed to find content layout map entry for: Starter-Blog-Author:header. Will compile 
using the system default layout.
Warning: failed to find content layout map entry for: Starter-Blog-Author:content. Will compile 
using the system default layout. 
Warning: failed to find content layout map entry for: Starter-Blog-Author:sidebar. Will compile 
using the system default layout.  
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063047-jerrold-summers 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063049-kelly-emerson 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063043-samantha-howard 
createPage: Processing detail pageId 105. 
Preview URL: http://localhost:8085/templates/BlogTemplate/post-detail/1481786063046-raising-triggers-from- content-layout 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063044-rendering-the-content- layout-using-mustache-template 
All detail page creation calls complete. 

Compilation completed with 0 errors and 3 warnings. 

*** compiled template is ready to test 
*** to render non-compiled pages, remove compiled files from under: /private/tmp/cec-
src/src/templates/BlogTemplate/static

การคอมไพล์เพจรายละเอียด

การคอมไพล์เพจรายละเอียดจะตรวจเทียบรายการเนื้อหาทั้งหมดที่พบระหว่างการคอมไพล์ จากนั้น ระบบจะคอมไพล์เพจรายละเอียดอีกครั้งสำหรับรายการเนื้อหาที่พบแต่ละรายการ โดยใช้ค่า slug เพื่อกำหนด URL ให้กับเพจรายละเอียดใหม่

เอาต์พุตของการคอมไพล์ก่อนหน้าจะเกิดขึ้นในสองส่วนดังนี้

  1. การคอมไพล์เพจ
  2. การคอมไพล์เพจรายละเอียด

ในตัวอย่างก่อนหน้า คุณจะเห็นคำเตือนเกี่ยวกับการขาดรายการแมปเลย์เอาต์ของเนื้อหาสำหรับเพจ Starter-Blog-Author อย่างไรก็ตาม เราไม่ต้องการเพจรายละเอียดสำหรับ Starter-Blog-Author เนื่องจากเพจรายละเอียดมีไว้สำหรับรายการเนื้อหาของ Starter-Blog-Post เท่านั้น ในการย้ายข้อผิดพลาดเหล่านี้ออก เราสามารถแยกรายการเนื้อหาออกจากการคอมไพล์เพจรายละเอียด หากรายการเนื้อหาไม่มีเพจรายละเอียดที่แน่ชัดที่อ้างอิงในการตั้งค่า โดยมีตัวเลือกต่อไปนี้

--noDefaultDetailPageLink, -o  Do not generate compiled detail page for items/content lists
      that use the default detail page.

ดังนั้น การรันการคอมไพล์ใหม่ โดยแยกการสร้างเพจรายละเอียดที่ใช้เพจรายละเอียดดีฟอลต์ จะทำให้เกิดเอาต์พุตต่อไปนี้

> cec compile-template BlogTemplate --noDefaultDetailPageLink 
Compile Template: compiling template BlogTemplate 
Oracle Content Management Site Compiler 

createPage: Processing pageId 100. Preview URL: 
http://localhost:8085/templates/BlogTemplate/index.html 
createPage: Processing pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail.html 
createPage: Processing pageId 401. Preview URL: 
http://localhost:8085/templates/BlogTemplate/about.html 
createPage: Processing pageId 402. Preview URL: 
http://localhost:8085/templates/BlogTemplate/search.html 
createPage: Processing pageId 403. Preview URL: 
http://localhost:8085/templates/BlogTemplate/authors.html 
All page creation calls complete.

Creating detail pages: 
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063051-developing-content-
layout-for-content-and-experience-cloud
createPage: Processing detail pageId 105. Preview URL:
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063052-dynamic-dom -manipulation-in-content-layout
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063045-getting-media-url-in- the-content-layout
createPage: Processing detail pageId 105. Preview URL:  
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063053-getting-reference- items-in-content-layout
createPage: Processing detail pageId 105. Preview URL: 
http://localhost:8085/templates/BlogTemplate/post-detail/1481786063048-navigating-to-a- search-page-with-search-query
All detail page creation calls complete.

Compilation completed with no errors.

*** compiled template is ready to test 
*** to render non-compiled pages, remove compiled files from under: /private/tmp/cec-
src/src/templates/BlogTemplate/static

คอมไพล์เพจที่ระบุ

คุณไม่จำเป็นต้องคอมไพล์เพจทั้งหมดในเทมเพลท และคุณสามารถเลือกว่าจะคอมไพล์เพจใดได้ วิธีนี้มีประโยชน์หากคุณทำงานบนเพจเฉพาะที่คุณต้องการที่จะดีบักหรืออัปเดต แทนที่จะคอมไพล์ทั้งไซต์อย่างต่อเนื่อง

ในการคอมไพล์หน้าเฉพาะ ให้ใช้ตัวเลือก --pages (-p) ตามด้วยลิสต์ของเพจที่คุณต้องการคอมไพล์

หมายเหตุ:

หมายเหตุ: หากรายการเนื้อหาอยู่บนเพจในเพจรายละเอียดการอ้างอิงลิสต์ ระบบจะคอมไพล์เพจรายละเอียดด้วย แม้ว่าจะไม่มีการรวมเพจเหล่านั้นไว้อย่างชัดเจน

cec compile-template BlogTemplate --pages 401,402 
Compile Template: compiling template BlogTemplate 
Oracle Content Management Site Compiler

createPage: Processing pageId 401. Preview URL: 
http://localhost:8085/templates/BlogTemplate/about.html 
createPage: Processing pageId 402. Preview URL: 
http://localhost:8085/templates/BlogTemplate/search.html 
All page creation calls complete.

Compilation completed with no errors. 
*** compiled template is ready to test 
*** to render non-compiled pages, remove compiled files from under: /private/tmp/cec- 
src/src/templates/BlogTemplate/static