
Biến API
API là một mảng được đóng vai trò như 1 biến cục bộ, chỉ sử dụng trong Nosine.Cú pháp:
api[var]Gồm các biến con:
- is_login -> kiểm tra sự tồn tại của người dùng, nếu có trả về tên người dùng đang đăng nhập.
- uri (array):
-- segments (array): phân đoạn URI
-- current (string): URL đầy đủ của trang hiện tại, bao gồm các get_get
- browser (array):
-- ip (string): IP của người dùng đang truy cập
-- user_agent (string): thông tin trình duyệt của người dùng đang truy cập
Ví dụ:
IP của bạn là:
{{api.browser.ip}}-----
Làm thế nào đề thêm chúng vào DorewSite?
- Trả lời: Dùng FTP manager truy cập vào /index.php tìm:
$twig->addExtension(new FormURI());
if ($type_db == 'phpSQLite3') {
$twig->addExtension(new phpSQLite3());
} else $twig->addExtension(new QuerySQL());
$twig->addExtension(new SomeFunctions());
$twig->addExtension(new SomeFilter());
$twigrender = $twig->render($pathTWIG, [
'dir' => ['css' => '/', 'js' => '/', 'img' => '/']
]);Sửa thành:
$FormURI = new FormURI();
$SomeFunctions = new SomeFunctions();
if ($type_db == 'phpSQLite3') {
$QuerySQL = new phpSQLite3();
} else $QuerySQL = new QuerySQL();
$twig->addExtension($FormURI);
$twig->addExtension($QuerySQL);
$twig->addExtension($SomeFunctions);
$twig->addExtension(new SomeFilter());
$twigrender = $twig->render($pathTWIG, [
'dir' => ['css' => '/', 'js' => '/', 'img' => '/'],
'api' => [
'is_login' => $GLOBALS['QuerySQL']->is_login(),
'uri' => [
'segments' => $GLOBALS['FormURI']->get_uri_segments(),
'current' => $GLOBALS['FormURI']->current_url()
],
'browser' => [
'ip' => $GLOBALS['SomeFunctions']->ip(),
'user_agent' => $GLOBALS['SomeFunctions']->user_agent()
],
]
]);
Biến API (đang đọc)
- BBcode:
- Markdown:
Tiếng Việt
English
中文
Français
العربية
עברית
Русский
Українська
Bahasa Indonesia
हिंदी
日本語
ภาษาไทย