Replies: 3 comments 4 replies
-
|
Agree on all counts +1 |
Beta Was this translation helpful? Give feedback.
-
|
...I wanted to revive this idea, with the glimmer of hope that maybe something could happen with it for Craft 5.9 😇 I recently upgraded a massive Craft 4 site to Craft 5. As part of the upgrade, I was able to get rid of several sections by moving their entries to Matrix fields using the Cards view mode (this move made all the sense in the world, as these sections should've been nested from the start). The client loves the new nested entry setup, except for one thing: On Craft 4, I had set up custom preview targets for the mentioned sections (whose entries had no URLs). And as it turned out, even if the client loved the content now being nested, they really missed being able to preview these entries "standalone"! I was able to bring back the preview targets for the relevant nested entry types when they are being edited via their dedicated edit pages, with a little bit of code: Event::on(
Entry::class,
Entry::EVENT_REGISTER_PREVIEW_TARGETS,
static function (RegisterPreviewTargetsEvent $event) {
/** @var Entry $element */
$element = $event->sender;
if ($element->getType()->handle !== 'tripSchedule') {
return;
}
$event->previewTargets[] = [
'label' => Craft::t('app', 'Preview'),
'url' => UrlHelper::siteUrl("preview/trip-schedule/$element->uid"),
'refresh' => true,
];
}
);Which is great, and helped a lot. BUT, it would be extremely awesome if a) it was possible to define that preview target via the Craft UI; not only via a custom module and |
Beta Was this translation helpful? Give feedback.
-
|
Hi again @mmikkel! Not your main point, but why not set a url via the UI for those nested entries? Wouldn't that give you the preview on dedicated edit pages for free, without custom code? Of course you should make that url only available for previewing purposes. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It'd be awesome if Preview was made available in element slideouts.
In lieu of Matrix-in-Matrix, and particularly since slideouts were introduced in Craft 3.7, I've leaned pretty hard into the "entries as nested modular content" approach.
With nested entries and element cards in Craft 5.0, this approach to content modelling is likely only going to become more popular. This means that going forward, a lot more content editing is likely going to happen in slideouts.
Slideouts are great, and everybody loves them. The one thing they're missing, and pretty much the only thing that has been reported to me from clients as a frustration with the slideout AX, is that the slideouts offer no way for authors to preview work in progress.
In Craft 3 and 4, I've generally taken the care to add custom preview targets to all my "faux-nested entries" sections. In reality this has been almost meaningless work, since authors generally interface with this content via slideouts 90% of the time (opening a slideout entry in its dedicated entry page, just to access Preview, makes for a very disjointed workflow; nobody does that).
Adding Preview to slideouts for "bona fide" entries seems pretty straight-forward. If an entry belongs to a section, and that section has URLs and/or preview targets defined, Craft knows what to preview, and adding the "Preview" button at the top of the slideout modal should probably be doable?
Then there's Craft 5, which introduces a core concept of nested entries. From a previewing perspective, these entries are going to be even worse off than my faux-nested entries, since they won't be attached to a section and thus have no way of being previewed at all, outside of closing their slideout and opening the owner element's preview (again, a pretty disjointed workflow) (and, their dedicated edit pages won't have a preview).
I guess the primary problem w/ preview for nested entries is probably "how will Craft know what to render".
Element partial templates could potentially be surfaced as previews for nested entries – i.e. if an entry using an entry type that has a partial template, Craft has something to render for that element and a "preview" rendering that partial template could potentially be exposed.
In reality, I'm not sure if that approach is viable, as element partial templates might not always be developed to render "standalone".
Possibly the better option would be to basically treat entry types (and other field layout providers) as "sections light", adding a "Preview Targets" setting to them. This would enable developers to add previews to nested entries where appropriate and/or needed, with full flexibility in terms of what gets rendered; even making it possible to have multiple different preview targets for a single nested entry (I can think of the use cases for that!). This approach isn't as streamlined as simply rendering an element partial for the preview, and the setting might seem a little bit awkward for entry types specifically created for inline-editable Matrix fields (where preview for nested entries make less sense) – but I'll stop typing now :)
Beta Was this translation helpful? Give feedback.
All reactions