สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network
Moderator: mindphp, ผู้ดูแลกระดาน
-
M034
- PHP Super Member
- โพสต์: 258
- ลงทะเบียนเมื่อ: 28/03/2016 10:21 am
-
ติดต่อ:
โพสต์ที่ยังไม่ได้อ่าน
โดย M034 »
เขียนโค๊ดตามวิดีโอแล้ว ตามโค๊ดด้านล่าง
โค้ด: เลือกทั้งหมด
public function base($page = 1)
{
$page_title = $this->user->lang('index');
$this->template->assign_block_vars('navlinks', array(
'FORUM_NAME' => $page_title,
'U_VIEW_FORUM' => $this->helper->route('m_kaset_controller', array ('name' =>'mindphp')),
));
return $this->helper->render('index.html', $this->user->lang('M_KASET'));
}
ผลที่รันเป็นแบบในภาพด้านล่าง ต้องทำไงค่ะ
- Selection_234.png (5.55 KiB) Viewed 761 times
ผิดตรงไหนค่ะ ถึงไม่สามารถสร้าง url ได้
-
M034
- PHP Super Member
- โพสต์: 258
- ลงทะเบียนเมื่อ: 28/03/2016 10:21 am
-
ติดต่อ:
โพสต์ที่ยังไม่ได้อ่าน
โดย M034 »
หน้า routing.yml
โค้ด: เลือกทั้งหมด
mindphp_m_kaset_controller:
path: /m_kaset/index
defaults: { _controller: mindphp.m_kaset.index:base}
requirements:
หน้า services.yml
โค้ด: เลือกทั้งหมด
services:
mindphp.m_kaset.index:
class: mindphp\m_kaset\controller\index
arguments:
- @config
- @dbal.conn
- @request
- @template
- @user
- @controller.helper
- %core.root_path%
- %core.php_ext%
ค่ะ
-
thatsawan
- PHP VIP Members
- โพสต์: 28508
- ลงทะเบียนเมื่อ: 31/03/2014 10:02 am
-
ติดต่อ:
โพสต์ที่ยังไม่ได้อ่าน
โดย thatsawan »
โค้ด: เลือกทั้งหมด
'U_VIEW_FORUM' => $this->helper->route('m_kaset_controller', array ('name' =>'mindphp')),
ชื่อที่เรียกใช้ มันคนละชื่อกับที่ประกาศใน yml
โค้ด: เลือกทั้งหมด
mindphp_m_kaset_controller:
path: /m_kaset/index
defaults: { _controller: mindphp.m_kaset.index:base}
requirements:
path: /m_kaset/index
ไม่ได้มีการประกาศรับตัวแปร จะใส่ array ('name' =>'mindphp') ไปก็รับไม่ได้
เปลี่ยนเป็น
โค้ด: เลือกทั้งหมด
'U_VIEW_FORUM' => $this->helper->route('mindphp_m_kaset_controller'),
-
M034
- PHP Super Member
- โพสต์: 258
- ลงทะเบียนเมื่อ: 28/03/2016 10:21 am
-
ติดต่อ:
โพสต์ที่ยังไม่ได้อ่าน
โดย M034 »
ได้แล้วค่ะ ขอบคุณมากๆค่ะ
- Selection_236.png (43.42 KiB) Viewed 743 times
-
-
- 2 ตอบกลับ
- 833 แสดง
-
โพสต์ล่าสุด โดย บุคคลทั่วไป
08/11/2022 8:53 pm
สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 135