หน้า 1 จากทั้งหมด 1
ต้องการจะสร้างไฟล์ HTML เเต่นำค่า php ไป HTML โดย Twig เขียนใน phpbb จะทำยังไงคะ
โพสต์แล้ว: 24/06/2020 5:45 pm
โดย thatsawan
ต้องการจะสร้างไฟล์ HTML เเต่นำค่า php ไป HTML โดย Twig เขียนใน phpbb จะทำยังไงคะ
ตอนนี้ลองทำเเล้ว เป็นหน้าที่ส่งตัวแปล มาทาง url เสร็จเเล้ว จะใช้วิธีเรียกเหมือน Template เเต่ติดปัญหา คือบุคคลภายนอกจะเข้ามาใน url นี้ไม่ได้
Re: ต้องการจะสร้างไฟล์ HTML เเต่นำค่า php ไป HTML โดย Twig เขียนใน phpbb จะทำยังไงคะ
โพสต์แล้ว: 24/06/2020 6:03 pm
โดย thatsawan
โค้ด: เลือกทั้งหมด
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);
}
โค้ด: เลือกทั้งหมด
$this->set_template_paths($ext_template_paths, $template_paths);
$this->template->set_filenames(array(
'body' => $template_file . '.txt',
));
ถ้าดูจากตัวอย่างของ เมล จะประมาณนี้
Re: ต้องการจะสร้างไฟล์ HTML เเต่นำค่า php ไป HTML โดย Twig เขียนใน phpbb จะทำยังไงคะ
โพสต์แล้ว: 24/06/2020 6:11 pm
โดย thatsawan
ถ้าจาก ตัวอย่าง
โค้ด: เลือกทั้งหมด
$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 ก่อน
โค้ด: เลือกทั้งหมด
$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
แต่ยังส่งค่าไปไม่ได้
Re: ต้องการจะสร้างไฟล์ HTML เเต่นำค่า php ไป HTML โดย Twig เขียนใน phpbb จะทำยังไงคะ
โพสต์แล้ว: 25/06/2020 3:49 pm
โดย Sirayu
ตามครับ