文章
顯示從 8月, 2024 起發佈的文章
create custom page with twig & custom module
- 取得連結
- X
- 電子郵件
- 其他應用程式
Create a custom module: Create a new folder in the modules/custom directory of your Drupal installation. Name it something like mypage. Inside the mypage folder, create a new file called mypage.info.yml and add the following code: name : 'My Page' type : module core_version_requirement : ^9 || ^10 package : Custom Create another file called mypage.routing.yml and add the following code: mypage.page : path : '/mypage' defaults : _controller : '\Drupal\mypage\Controller\MyPageController::mypage' _title : 'My Page' requirements : _permission : 'access content' mypage.module <?php function mypage_theme ( $existing , $type , $theme , $path ) { return [ 'my_page_template' => [ 'variables' => [ 'test_var' => NULL ], ], ]; } ? > Create a custom controller: Inside the my_module folder, create a new folder called src. Inside the src folder, create another folder called Con...