statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
3.7k stars 508 forks source link

Collection next/previous doesn't work in live previews #4805

Closed tao closed 9 months ago

tao commented 2 years ago

Bug description

I believe the {{ collection:next }} and {{ collection:previous }} tags require the current ID to function. So if you open live preview without saving it first then it fails? because it has no ID field has been generated yet?

The prev/next methods attempt to fetch $this->currentEntry() however this returns null on live preview. If you die dump the value it just returns null.

    public function next()
    {
        $this->params['from'] = $this->currentEntry()->collection()->handle();

        return $this->output(
            $this->entries()->next($this->currentEntry())
        );
    }

So the collection next or previous need a soft failure mode so you can live preview?

How to reproduce

Try live preview with {{ collection:next }} or {{ collection:previous }}.

Logs

No response

Versions

Statamic 3.2.16 Pro Laravel 8.64.0 PHP 8.0.6 elvenstar/statamic-meilisearch 0.1.3 statamic/ssg 0.9.0

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

duncanmcclean commented 9 months ago

The "Live Preview" button is no longer shown when creating entries, it's only visible when editing existing entries.