XF 2.3 Rebuild cache for single template

eDaddi

Active member
Licensed customer
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.
 
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.
I did see your recent post about that. I'm running this script outside the public available folder so what all files do I need to include from XF to allow that to work?
 
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