拆解html技巧?
有數十支php的html結構如下<body>
<section></section>
<nav></nav>
<section></section>
...
</body>
其中<nav></nav>是共用部份,
而nav裡頭的選單內容也使用到php的樣板語法<?php xxxx ?>
我把內容裝到另一支nav.php,放在view/common/nav.php
請教依照 https://codeigniter4.github.io/userguide/outgoing/index.html
希望從這邊安插code
<body>
<section></section>
安插code進來
<section></section>
...
</body>
保留 html完整度,
不使用 include,應該怎麼做會最好
为什么不使用 include 呢? 因為我自己的想法是
第一點,
CI4的base_url被強迫使用url格式,
不像ci3還可使用檔案路徑替換,
一但使用 include base_url,會違反allow_url_include=0 php安全性規則,不能使用。
第二點,
假使直接在樣版寫 include 絕對檔案路徑.檔名,
一旦部屬到其他主機時的修改就很囉嗦,
實不妥當。
第三點,
使用相對路徑,
我測試皆失敗,failed to open stream: No such file or directory,
不知道CI4該怎麼做。
請教hex,我應該怎麼做?
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| If this is not set then CodeIgniter will try guess the protocol, domain
| and path to your installation. However, you should always configure this
| explicitly and never rely on auto-guessing, especially in production
| environments.
|
*/
public $baseURL = 'http://127.0.0.1/myproject/';
页:
[1]