XF 2.3 Rebuild cache for single template

eDaddi

Active member
I have a page template I’m updating in the DB and the changes don’t reflect until rebuilding cache.

Is there a way I can rebuild just that page’s cache vs doing them all?
 
As with most things, you should use entities to change them instead of using the database directly so that the application-level logic around them is triggered appropriately.
 
Just the preamble if it's a standalone script:
PHP:
<?php

$xfRoot = '/path/to/xf/root'; // adjust this

require $xfRoot . '/src/XF.php';

\XF::start($xfRoot);
\XF::setupApp(\XF\Pub\App::class);

From there you can do something like this (untested):
PHP:
$templateTitle = 'some_template'; // adjust this
$templateContent = '<xf:comment>Your template code</xf:comment>'; // adjust this

$template = \XF::em()->findOne(\XF\Entity\Template::class, [
    'style_id' => 0,
    'type' => 'public',
    'title' => $templateTitle,
);
$template->template = $templateContent;
$template->save();
 
Back
Top Bottom