Bagaimana Cara merubah Inline string js/json/style jadi punya url/ internal url? #266
Replies: 4 comments 17 replies
-
Bagaimana cara merubah rute js/css yang tersimpan di folder layout dan cara menghilangkan filemtime yang ada di urlnya? Misal: untuk saat ini ane cuma bisa menyimpan file nya dalam folder projectnya jika ingin membuat seperti |
Beta Was this translation helpful? Give feedback.
-
Konsepnya sama seperti yang pernah Saya jelaskan di artikel ini: https://mecha-cms.com/article/case-google-font Cuma versi 3.x.x kan kelas Hook::set('route', function ($content, $path) {
if ('/manifest.json' === $path) {
status(200);
type('application/json');
return To::JSON((array) State::get('x.f3h', true));
}
return $content;
}, 0); |
Beta Was this translation helpful? Give feedback.
-
kalau mau bikin route dengan Hook::set('route', function ($content, $path) {
if ('/trending' === $path) {
type('text/html');
status(200);
if (!empty($page)) {
$out = file_get_contents(LOT . D . 'y' . D . 'model-1' . D . 'test.php');
return strtr($content, ['</body>' => $out . '</body>']);
}
}
return $content;
}, 0); Hook::set('route', function ($content, $path) {
if ('/trending' === $path) {
type('text/html');
status(200);
function trending($content) {
extract($GLOBALS, EXTR_SKIP);
if (!empty($page)) {
$out = '<h2>Trending</h2>';
return strtr($content, ['</body>' => '</body>' . $out]);
}
return $content;
}
Hook::set('content', __NAMESPACE__ . "trending", 0.5);
}
return $content;
}, 0); Hook::set('route', function ($content, $path) {
if ('/trending' === $path) {
type('text/html');
status(200);
function trending($content) {
extract($GLOBALS, EXTR_SKIP);
if (!empty($page)) {
return layout::test(); // Ambil test.php
}
return $content;
}
Hook::set('content', __NAMESPACE__ . "trending", 0.5);
}
return $content;
}, 0); Hook::set('route', function ($content, $path) {
if ('/trending' === $path) {
type('text/html');
status(200);
return Hook::set('content', function () {
$content = layout::test();
return $content;
});
}
return $content;
}, 0); cuma kode diatas yang terpikirkan sama ane kang, bantu sempurnakan kang. untuk penambahan |
Beta Was this translation helpful? Give feedback.
-
kalau mau nulis kode di atas dimana, mas? |
Beta Was this translation helpful? Give feedback.
-
misalnya ane pake inline json f3h yang di hasilkan dari kode dibawah, dijadikan internal url seperti localhost/manifest.json. dan juga sama halnya seperti inline js/ css diubah jadi internal url js/ css. apa memungkinkan kang?
Beta Was this translation helpful? Give feedback.
All reactions