Add template preview functionality: Introduced TemplatePreviewController and TemplatePreviewService for rendering dynamic previews of header, footer, and section templates. Updated form schemas to include preview components and enhanced real-time content updates. Added configuration for template assets and integrated preview functionality into the admin panel.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\TemplatePreviewService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TemplatePreviewController extends Controller
|
||||
{
|
||||
/**
|
||||
* Render template preview
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function preview(Request $request)
|
||||
{
|
||||
$content = $request->input('content', '');
|
||||
$type = $request->input('type', 'section'); // header, footer, section
|
||||
|
||||
// Validate type
|
||||
if (!in_array($type, ['header', 'footer', 'section'])) {
|
||||
$type = 'section';
|
||||
}
|
||||
|
||||
$html = TemplatePreviewService::getPreviewHtml($content, $type);
|
||||
|
||||
return response($html)
|
||||
->header('Content-Type', 'text/html; charset=utf-8');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user