ต้องการจะสร้างไฟล์ HTML เเต่นำค่า php ไป HTML โดย Twig เขียนใน phpbb จะทำยังไงคะ
ตอนนี้ลองทำเเล้ว เป็นหน้าที่ส่งตัวแปล มาทาง url เสร็จเเล้ว จะใช้วิธีเรียกเหมือน Template เเต่ติดปัญหา คือบุคคลภายนอกจะเข้ามาใน url นี้ไม่ได้
ต้องการจะสร้างไฟล์ HTML เเต่นำค่า php ไป HTML โดย Twig เขียนใน phpbb จะทำยังไงคะ
Moderators: mindphp, ผู้ดูแลกระดาน
- thatsawan
- PHP VIP Members
- Posts: 28523
- Joined: 31/03/2014 10:02 am
- Contact:
- thatsawan
- PHP VIP Members
- Posts: 28523
- Joined: 31/03/2014 10:02 am
- Contact:
Re: ต้องการจะสร้างไฟล์ HTML เเต่นำค่า php ไป HTML โดย Twig เขียนใน phpbb จะทำยังไงคะ
Code: Select all
protected function setup_template()
{
global $phpbb_container, $phpbb_dispatcher;
if ($this->template instanceof \phpbb\template\template)
{
return;
}
$template_environment = new \phpbb\template\twig\environment(
$phpbb_container->get('config'),
$phpbb_container->get('filesystem'),
$phpbb_container->get('path_helper'),
$phpbb_container->getParameter('core.template.cache_path'),
$phpbb_container->get('ext.manager'),
new \phpbb\template\twig\loader(
$phpbb_container->get('filesystem')
),
$phpbb_dispatcher,
array()
);
$template_environment->setLexer($phpbb_container->get('template.twig.lexer'));
$this->template = new \phpbb\template\twig\twig(
$phpbb_container->get('path_helper'),
$phpbb_container->get('config'),
new \phpbb\template\context(),
$template_environment,
$phpbb_container->getParameter('core.template.cache_path'),
$phpbb_container->get('user'),
$phpbb_container->get('template.twig.extensions.collection'),
$phpbb_container->get('ext.manager')
);
}
/**
* Set template paths to load
*/
protected function set_template_paths($path_name, $paths)
{
$this->setup_template();
$this->template->set_custom_style($path_name, $paths);
}
Code: Select all
$this->set_template_paths($ext_template_paths, $template_paths);
$this->template->set_filenames(array(
'body' => $template_file . '.txt',
));
- thatsawan
- PHP VIP Members
- Posts: 28523
- Joined: 31/03/2014 10:02 am
- Contact:
Re: ต้องการจะสร้างไฟล์ HTML เเต่นำค่า php ไป HTML โดย Twig เขียนใน phpbb จะทำยังไงคะ
ถ้าจาก ตัวอย่าง
เปลี่ยน เป็นไฟล์ HTML ของเรา ต้่องสร้างไว้ใน Template ก่อน
จากนั้นจะได้
$this->template_filename
URL สำหรับ HTML ที่ต้องการ
file:///D:/xampp/htdocs/phpbb/styles/thaivi/template/receipt.html
แต่ยังส่งค่าไปไม่ได้
Code: Select all
$template = new \phpbb\template\twig\twig(
$phpbb_container->get('path_helper'),
$phpbb_container->get('config'),
new \phpbb\template\context(),
new \phpbb\template\twig\environment(
$phpbb_container->get('config'),
$phpbb_container->get('filesystem'),
$phpbb_container->get('path_helper'),
$phpbb_container->getParameter('core.cache_dir'),
$phpbb_container->get('ext.manager'),
new \phpbb\template\twig\loader(
$phpbb_filesystem
)
),
$phpbb_container->getParameter('core.cache_dir'),
$phpbb_container->get('user'),
$phpbb_container->get('template.twig.extensions.collection'),
$phpbb_extension_manager
);
$template->set_style();
$template->set_filenames(array('bbcode.html' => 'bbcode.html'));
$this->template_filename = $template->get_source_file_for_handle('bbcode.html');
เปลี่ยน เป็นไฟล์ HTML ของเรา ต้่องสร้างไว้ใน Template ก่อน
Code: Select all
$template->set_filenames(array('receipt.html' => 'receipt.html'));
$this->template_filename = $template->get_source_file_for_handle('receipt.html');
$this->template_filename
URL สำหรับ HTML ที่ต้องการ
file:///D:/xampp/htdocs/phpbb/styles/thaivi/template/receipt.html
แต่ยังส่งค่าไปไม่ได้
- Sirayu
- PHP Sr. Member
- Posts: 91
- Joined: 12/06/2019 11:30 am
- Contact:
-
- Similar Topics
- Replies
- Views
- Last post
-
- 4 Replies
- 333 Views
-
Last post by eange08
15/01/2021 10:22 am
-
- 1 Replies
- 1991 Views
-
Last post by tsukasaz
17/08/2013 1:40 am
-
-
อยากทราบวิธีการดึงรูปภาพที่เป็นไฟล์แนบจาก phpbb มาใน html
by Ittichai_chupol » 11/06/2019 5:20 pm » in Programming - PHP - 1 Replies
- 303 Views
-
Last post by mindphp
11/06/2019 5:36 pm
-
-
-
อยากทราบวิธีการ สร้างไฟล์ html ขึ้นมาเมื่อมีการกดปุ่ม ใน phpbb
by Ittichai_chupol » 08/06/2019 7:05 pm » in Programming - PHP - 1 Replies
- 353 Views
-
Last post by thatsawan
08/06/2019 7:28 pm
-
-
-
การสร้างไฟล์ event ในรูปแบบ html สำหรับ phpbb
by Ittichai_chupol » 29/01/2019 5:33 pm » in PHP Knowledge - 0 Replies
- 1250 Views
-
Last post by Ittichai_chupol
29/01/2019 5:33 pm
-
-
-
อยากทราบวิธีการ ดึงไฟล์รูปภาพที่แนบไว้แต่ยังไม่ได้เอามาใช่ใน phpbb มาแสดงใน html ปกติ
by Ittichai_chupol » 15/06/2019 2:14 pm » in Programming - PHP - 1 Replies
- 299 Views
-
Last post by mindphp
16/06/2019 3:03 am
-
-
-
วิธีการส่งค่าจาก Extension phpbb ไปยัง ่javascript โดยผ่าน html
by Ittichai_chupol » 05/03/2019 3:39 pm » in PHP Knowledge - 0 Replies
- 1414 Views
-
Last post by Ittichai_chupol
05/03/2019 3:39 pm
-
-
- 3 Replies
- 613 Views
-
Last post by putcharaporn_tan
19/08/2015 12:18 pm
Who is online
Users browsing this forum: No registered users and 13 guests