สอบถามเปลี่ยนเรียกตัวเทมเพล email จากในโฟลเดอร์ language ไปเป็น Extension ตัวเอง

พูดคุย phpBB3, SMF ปัญหา การติดตั้ง ปัญหา การลง Mod การแก้ไข หน้าตาบอร์ด การใช้งาน Joomla 1.5, 1.6, 1.7, 2.5 ,3.x รวมถึง Joomla 4 การใช้งาน wordpress และ CMS อื่นๆ
การตั้งคำถาม ควรระบุรุ่นที่ใช้ ในการตั้งคำตามด้วย นะ เช่น SMF 1.1.4 หรือ SMF2.0, OpenERP, Odoo และ รายละเอียดของ server OS, php เวอร์ชั่นไหน ฐานข้อมูลอะไร

Moderator: mindphp

กฎการใช้บอร์ด
คำถามหมวดนี้ ควรระบุ รายละเอียดของ Server OS, เวอร์ชั่น ของ PHP, CMS ที่ท่านใช้
รวมถึง Hosting หรือ Control Panel Hosting
ภาพประจำตัวสมาชิก
eange08
PHP VIP Members
PHP VIP Members
โพสต์: 16019
ลงทะเบียนเมื่อ: 22/12/2020 10:09 am

สอบถามเปลี่ยนเรียกตัวเทมเพล email จากในโฟลเดอร์ language ไปเป็น Extension ตัวเอง

โพสต์ที่ยังไม่ได้อ่าน โดย eange08 »

จะเปลี่ยนตัวไฟล์ภาษาอีเมล์ จากในโฟลเดอร์ language/th/email ของ phpBB เปลี่ยนมาเรียกจากใน ext/***/extension_name/language/th/email ได้อย่างไรค่ะ
- เบื้องต้นเอาไฟล์ภาษา email เข้ามาใน extension แล้วค่ะ
- พอไล่ที่ module ที่จะส่งเมล์ ส่วนที่เรียกไฟล์ภาษา email จะใช้ตัว functions_messenger

โค้ด: เลือกทั้งหมด

include_once($this->phpbb_root_path . 'includes/functions_messenger.' . $this->phpEx);

            $messenger = new \messenger(FALSE);
            $messenger->template($email_template, 'th');  
- อันนี้ function ที่ชื่อ template เหมือนจะมีการกำหนด path ไว้ 'language/' . $template_lang . '/email' . $template_dir_prefix, เราสามารถแก้ไข path หรือจะระบุ path ประมาณไหน และจากพารามิเตอร์ตัวไหนนะคะ

โค้ด: เลือกทั้งหมด

function template($template_file, $template_lang = '', $template_path = '', $template_dir_prefix = '')
	{
		global $config, $phpbb_root_path, $user;

		$template_dir_prefix = (!$template_dir_prefix || $template_dir_prefix[0] === '/') ? $template_dir_prefix : '/' . $template_dir_prefix;

		$this->setup_template();
                              
		if (!trim($template_file))
		{
			trigger_error('No template file for emailing set.', E_USER_ERROR);
		}

		if (!trim($template_lang))
		{
			// fall back to board default language if the user's language is
			// missing $template_file.  If this does not exist either,
			// $this->template->set_filenames will do a trigger_error
			$template_lang = basename($config['default_lang']);
		}

		$ext_template_paths = array(
			array(
				'name' 		=> $template_lang . '_email',
				'ext_path' 	=> 'language/' . $template_lang . '/email' . $template_dir_prefix,
			),
		);

		if ($template_path)
		{  
			$template_paths = array(
				$template_path . $template_dir_prefix,
			);
                        //print_r($template_paths);exit();
		}
		else
		{    
			$template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/';
			$template_path .= $template_lang . '/email';

			$template_paths = array(
				$template_path . $template_dir_prefix,
			);

			$board_language = basename($config['default_lang']);

			// we can only specify default language fallback when the path is not a custom one for which we
			// do not know the default language alternative
			if ($template_lang !== $board_language)
			{
				$fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/';
				$fallback_template_path .= $board_language . '/email';

				$template_paths[] = $fallback_template_path . $template_dir_prefix;

				$ext_template_paths[] = array(
					'name'		=> $board_language . '_email',
					'ext_path'	=> 'language/' . $board_language . '/email' . $template_dir_prefix,
				);
			}
			// If everything fails just fall back to en template
			if ($template_lang !== 'en' && $board_language !== 'en')
			{
				$fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/';
				$fallback_template_path .= 'en/email';

				$template_paths[] = $fallback_template_path . $template_dir_prefix;

				$ext_template_paths[] = array(
					'name'		=> 'en_email',
					'ext_path'	=> 'language/en/email' . $template_dir_prefix,
				);
			}
		}

		$this->set_template_paths($ext_template_paths, $template_paths);

		$this->template->set_filenames(array(
			'body'		=> $template_file . '.txt',
		));

		return true;
	}
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41127
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: สอบถามเปลี่ยนเรียกตัวเทมเพล email จากในโฟลเดอร์ language ไปเป็น Extension ตัวเอง

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

เช็คโครงสร้างของ ภาษาใน extension ว่าได้สร้างไฟล์ template ภาษาสำหรับส่งเมลไว้ ภายใต้โครงสร้างนี้หรือยัง
extension_name/language/th/email/short/
extension_name/language/en/email/short/
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ภาพประจำตัวสมาชิก
eange08
PHP VIP Members
PHP VIP Members
โพสต์: 16019
ลงทะเบียนเมื่อ: 22/12/2020 10:09 am

Re: สอบถามเปลี่ยนเรียกตัวเทมเพล email จากในโฟลเดอร์ language ไปเป็น Extension ตัวเอง

โพสต์ที่ยังไม่ได้อ่าน โดย eange08 »

mindphp เขียน: 10/08/2021 3:54 pm เช็คโครงสร้างของ ภาษาใน extension ว่าได้สร้างไฟล์ template ภาษาสำหรับส่งเมลไว้ ภายใต้โครงสร้างนี้หรือยัง
extension_name/language/th/email/short/
extension_name/language/en/email/short/
ได้สร้างตามโครงสร้างนี้แล้วนะคะ
ปัญหาการใช้ phpBB3, SMF, Joomla, Wordpress, CMS, CRM-1.png
ปัญหาการใช้ phpBB3, SMF, Joomla, Wordpress, CMS, CRM-1.png (36.04 KiB) Viewed 701 times
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: Bing [Bot] และบุคลทั่วไป 50