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:
@@ -4,6 +4,7 @@ return [
|
||||
'title' => 'Placeholder Variables',
|
||||
'click_to_insert' => 'Click to insert into editor',
|
||||
'special_placeholders' => 'Special Placeholders',
|
||||
'custom_placeholders' => 'Custom Placeholders',
|
||||
'search_placeholder' => 'Search placeholders...',
|
||||
'no_results' => 'No results found',
|
||||
|
||||
@@ -31,5 +32,6 @@ return [
|
||||
'type_toggle' => 'Toggle',
|
||||
'type_color' => 'Color',
|
||||
'type_tags' => 'Tags',
|
||||
'type_custom' => 'Custom',
|
||||
];
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ return [
|
||||
'title' => 'Placeholder Değişkenleri',
|
||||
'click_to_insert' => 'Tıklayarak editöre ekle',
|
||||
'special_placeholders' => 'Özel Placeholder\'lar',
|
||||
'custom_placeholders' => 'Özel Placeholder\'lar',
|
||||
'search_placeholder' => 'Placeholder ara...',
|
||||
'no_results' => 'Arama sonucu bulunamadı',
|
||||
|
||||
@@ -31,5 +32,6 @@ return [
|
||||
'type_toggle' => 'Aç/Kapa',
|
||||
'type_color' => 'Renk',
|
||||
'type_tags' => 'Etiketler',
|
||||
'type_custom' => 'Özel',
|
||||
];
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user