You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m currently working on a simple plugin to add an "Edit Page Entry" link to the frontend, and I was wondering if there’s a way to inject a dynamically rendered template into the frontend via a plugin, so that even cached entries would receive this link. I understand your time is very valuable, and I don't want to take too much of it, but I’d really appreciate any guidance you could provide.
After writing this, I tried to put the code into the Craft::$app->onInit() function and now I get the correct html back. Yeyy, but my variables are not working properly :(
My code is now:
$cpEditUrl = $entry->getCpEditUrl();
$canEdit = Craft::$app->getElements()->canSave($entry); // does update here$blitzVariable = Craft::createObject(BlitzVariable::class);
$html = $blitzVariable->includeDynamic('craft-quick-edit/_settings.twig', [
'cpEditUrl' => $cpEditUrl, // works as expected'canRender' => $canEdit, // does not update in the _settings component
]);
Craft::$app->getView()->registerHtml($html, View::POS_END);
Can you provide a simple example so I can test locally? Be sure to clear the cache any time you make changes during testing, otherwise you’ll be viewing stale versions of the page.
Support Request
Hi Ben,
I hope you're doing well.
I’m currently working on a simple plugin to add an "Edit Page Entry" link to the frontend, and I was wondering if there’s a way to inject a dynamically rendered template into the frontend via a plugin, so that even cached entries would receive this link. I understand your time is very valuable, and I don't want to take too much of it, but I’d really appreciate any guidance you could provide.
Here’s what I’ve tried so far:
This is the content of my
_settings.twig
:But when I test it, this is the output I get:
Any insights or suggestions you might have would be greatly appreciated!
Thanks so much!
Plugin Version
5.9.9
The text was updated successfully, but these errors were encountered: