สอบถาม Template events : วิธีเรียกไฟล์ CSS / JS มาใช้งานในการพัฒนา Extension

HTML Basic
สำหรับนักพัฒนาเว็บไซต์มือใหม่ HTML , CSS และการใช้ Tools ต่างๆ ในการพัฒนาเว็บไซต์

Moderator: mindphp

User avatar
thatsawan
PHP VIP Members
PHP VIP Members
Posts: 22695
Joined: 31/03/2014 10:02 am
Contact:

สอบถาม Template events : วิธีเรียกไฟล์ CSS / JS มาใช้งานในการพัฒนา Extension

Post by thatsawan » 18/11/2014 2:41 pm

Template events

Template events allow extensions to insert template code into event locations found throughout the template structure. Template events found inside phpBB’s template files look like:

Code: Select all

<!-- EVENT overall_header_head_append -->
To use a template event, simply name your template file exactly the same as the template event you want to use, and place your template event files in an event/ directory inside your style’s template directory.
For example, the above template event could be used to add some CSS style script to the header. The template file would be located at:

acme/demo/styles/prosilver/template/event/overall_header_head_append.html

A special case for including CSS files and JS files exists. These use the <!-- INCLUDECSS --> and <!-- INCLUDEJS --> syntax, respectively.

For example, to add a new custom.css file in prosilver, a template event would need to be created at:

acme/demo/styles/prosilver/template/event/overall_header_head_append.html

It would contain the following line of code:

Code: Select all

<!-- INCLUDECSS ../theme/custom.css -->
To include a JS file in all styles, e.g.: acme/demo/styles/all/js/scripts.js

A template event would be created at:

acme/demo/styles/all/template/event/overall_footer_after.html

It would contain the following line of code:

Code: Select all

<!-- INCLUDEJS @acme_demo/js/scripts.js -->
จาก http://www.phpbb.com

User avatar
thatsawan
PHP VIP Members
PHP VIP Members
Posts: 22695
Joined: 31/03/2014 10:02 am
Contact:

Re: สอบถาม Template events : วิธีเรียกไฟล์ CSS / JS มาใช้งานในการพัฒนา Extension

Post by thatsawan » 18/11/2014 2:43 pm

ที่นี่หนูลองทำตามค่ะ เเต่ผลที่ได้คือ Twig_Error_Loader'
18-11-2557 14-40-03.jpg
18-11-2557 14-40-03.jpg (28.81 KiB) Viewed 918 times

Code: Select all

<!-- INCLUDECSS ../theme/menu.css -->
<div id="cssmenu">
    <ul>
       <li><a href='#'>***</a></li>
       <li class='active has-sub'><a href='#'>xx</a>
          <ul>
            <li><a href='#'>***</a></li>
            <li><a href='#'>***/แข่ง</a></li>
            <li><a href='#'>***</a></li>
          </ul>
       </li>
Fatal error: Uncaught exception 'Twig_Error_Loader' with message 'Unable to find template "../theme/menu.css" (looked into: ./styles/prosilver/template)

User avatar
thatsawan
PHP VIP Members
PHP VIP Members
Posts: 22695
Joined: 31/03/2014 10:02 am
Contact:

Re: สอบถาม Template events : วิธีเรียกไฟล์ CSS / JS มาใช้งานในการพัฒนา Extension

Post by thatsawan » 18/11/2014 3:19 pm

อีก 1 ตัวอย่าง
18-11-2557 15-25-43.jpg
18-11-2557 15-25-43.jpg (42.31 KiB) Viewed 917 times

Code: Select all

{# Use the space below to include external CSS and JS files
# Here are some example usages:
#
# local files relative to this template file (when stored inside phpBB's style directories):
# <!-- INCLUDEJS script.js -->
# <!-- INCLUDECSS ../theme/style.css -->
#
# hosted on external sites:
# <!-- INCLUDEJS http://code.jquery.com/jquery-migrate-1.2.1.min.js -->
# <!-- INCLUDECSS https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css -->
#
# local files stored inside the Pages extension:
# <!-- INCLUDEJS @phpbb_pages/script.js -->
# <!-- INCLUDECSS @phpbb_pages/../theme/style.css -->
#
#}
<!-- INCLUDECSS @phpbb_pages/../theme/pages_controller.css -->
<!-- INCLUDE overall_header.html -->

<div class="content pages-content">

	{PAGE_CONTENT}

</div>

<!-- EVENT pages_after_page_content -->

<!-- INCLUDE overall_footer.html -->

Post Reply

Return to “HTML CSS”

Who is online

Users browsing this forum: No registered users and 82 guests