1. Go to this page and download the library: Download snowsoft/nlktheme library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
snowsoft / nlktheme example snippets
// Controller'da
use Theme;
public function index()
{
return Theme::view('home');
}
// Veya helper ile
return theme()->view('home');
// Belirli tema kullan
Theme::uses('tema2')->layout('main')->view('home');
// Helper ile
theme('tema2', 'main')->view('home');
// Veri set et
theme()->setData('user', $user);
theme()->setMultipleData(['key1' => 'val1', 'key2' => 'val2']);
// Veri al
$user = theme()->getData('user');
$allData = theme()->getAllData();
// Helper
theme_set('key', 'value');
$value = theme_get('key', 'default');
// Tüm cache'i temizle
theme()->clearCache();
// Belirli temanın cache'ini temizle
theme()->clearThemeCache('tema2');
// Temayı yeniden yükle
theme()->reload();
// Helper
theme_cache_clear();
theme_cache_clear('tema2');
// View var mı kontrol et
if (theme()->viewExists('home')) {
return theme()->view('home');
}
// Theme'deki tüm view'ları listele
$views = theme()->getThemeViews();
// Helper
if (has_theme_view('partial.header')) {
{!! theme_partial('partial.header') !!}
}
// Varsa render et
render_if_exists('partial.header', [], 'Default content');
// Metin kısaltma
theme_truncate('Long text here...', 50);
// Output: "Long text here..."
// Time ago
time_ago('2024-01-01 12:00:00');
// Output: "2 hours ago"
// Number format
number_format_short(1000);
// Output: "1K"
number_format_short(1500000);
// Output: "1.5M"
// Active class
active_class('home', 'active');
// Returns: 'active' if current route is 'home'
// Blade'de
<li class="{{ active_class('home') }}">Home</li>
// Region set et
theme()->set('meta', '<meta name="keywords" content="...">');
// Region append
theme()->append('scripts', '<script>...</script>');
// Region prepend
theme()->prepend('styles', '<link>...</link>');
// Region al
$meta = theme()->get('meta', 'default');
// Region var mı kontrol et
if (theme()->has('meta')) {
echo theme()->get('meta');
}
// Blade'de
@get('meta')
@getIfHas('meta')