Enhance placeholder picker functionality: Added support for custom placeholders in the placeholder picker component, allowing dynamic loading of custom blade files. Updated localization for both English and Turkish languages to include new placeholder types, improving user experience and flexibility in template customization.

This commit is contained in:
Ümit Tunç
2025-11-04 12:08:31 -03:00
parent 01ef804c03
commit 9dd1bde863
6 changed files with 36 additions and 38 deletions
@@ -1,6 +0,0 @@
<div class="custom-example-component my-4 p-4 bg-gray-100 rounded-lg">
<h4 class="text-lg font-bold mb-2">Örnek Custom Component</h4>
<p class="text-gray-700">Bu component'i template içinde <code>{custom.example}</code> yazarak kullanabilirsiniz.</p>
<p class="text-sm text-gray-500 mt-2">Bu dosyayı dilediğiniz gibi özelleştirebilir ve yeniden kullanabilirsiniz.</p>
</div>
@@ -14,4 +14,4 @@
</li>
</ul>
<!-- /.navbar-nav -->
</div>asdad
</div>
@@ -1,6 +0,0 @@
<div class="custom-test-component">
<h3>Custom Test Component</h3>
<p>Bu bir örnek custom component'tir. Bu dosyayı dilediğiniz gibi özelleştirebilirsiniz.</p>
<p>Template içinde <code>{custom.test}</code> yazarak bu component'i çağırabilirsiniz.</p>
</div>
@@ -26,6 +26,37 @@
'tags' => ['label' => __('placeholder-picker.type_tags'), 'examples' => ['tags', 'keywords', 'labels']],
];
// Custom klasöründeki blade dosyalarını tespit et ve placeholder types'a ekle
$customPlaceholders = [];
$customPath = resource_path('views/components/custom');
if (is_dir($customPath)) {
$files = scandir($customPath);
foreach ($files as $file) {
// . ve .. dizinlerini atla
if ($file === '.' || $file === '..') {
continue;
}
// Sadece .blade.php uzantılı dosyaları al
$filePath = $customPath . DIRECTORY_SEPARATOR . $file;
if (is_file($filePath) && str_ends_with($file, '.blade.php')) {
$name = str_replace('.blade.php', '', $file);
$customPlaceholders[] = $name;
}
}
sort($customPlaceholders);
// Custom placeholder'ları placeholder types'a ekle
if (!empty($customPlaceholders)) {
$placeholderTypes['custom'] = [
'label' => __('placeholder-picker.type_custom'),
'examples' => $customPlaceholders
];
}
}
// Field name'i component'ten al
$fieldName = $fieldName ?? 'html_content';
@endphp
@@ -105,31 +136,6 @@
</div>
</template>
<!-- Özel placeholder'lar -->
<div x-show="hasSpecialPlaceholders" class="pt-3 border-t fi-border-color">
<h4 class="fi-section-header-heading text-xs font-semibold uppercase tracking-wide mb-2">
{{ __('placeholder-picker.special_placeholders') }}
</h4>
<div class="flex flex-wrap gap-2">
<x-filament::button
size="sm"
color="primary"
outlined
x-on:click="window.insertPlaceholder('{{ $fieldName }}', 'menu')"
>
<code class="text-xs font-mono">{menu}</code>
</x-filament::button>
<x-filament::button
size="sm"
color="primary"
outlined
x-on:click="window.insertPlaceholder('{{ $fieldName }}', 'staticMenu')"
>
<code class="text-xs font-mono">{staticMenu}</code>
</x-filament::button>
</div>
</div>
<!-- No Results -->
<div
x-show="Object.keys(filteredCategories).length === 0 && !hasSpecialPlaceholders"