In laravel 11 / livewire 3 app I have a page with component with route in web routes/web.php :
Route::get('/news-show/{slug}', NewsShowPage::Class)->name('news.show');
and component class which shows page ok :
namespace AppLivewire;
...
class NewsShowPage extends Component
{
public function render(): View
{
return view('livewire.news.news-show-page',
['newsItem' => $this->newsItem])->layout('components.layouts.frontend');
Until I remade with page cached – if there is a cached page data I read this cached page and show it:
public function render(): string | View
{
// There is cached data in REDIS or DB
if (($this->useDataCaching === UseDataCaching::DB || $this->useDataCaching === UseDataCaching::REDIS) && !empty($this->cachedData)) {
return $this->convertCachingData($this->cachedData);
}
$renderedCode = view('livewire.news.news-show-page', // Need to retrieve data in view if cache is OFF or empty
['newsItem' => $this->newsItem])->layout('components.layouts.frontend')->render();
if ($this->useDataCaching === UseDataCaching::DB || $this->useDataCaching === UseDataCaching::REDIS) { // There is cached data in REDIS or DB
$this->keyDataService->write(keyDataIdentifier: $this->keyDataIdentifier,
cachingTimeInSeconds: $this->getCachedNewsShowDays(DataCachingType::NEWS_SHOW_PAGE), // Save rendered new template into
data: $renderedCode);
}
return $renderedCode;
}
so cached string is returned (not view)
and opened news details page has no auth-nav and footer blocks visible, which I set inside of layout file.
How to fix it ? Can I in some way to put cached string into view object and return it(with layout file used)?