statamic / cms

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

Taxonomy term view returns 404, previewing does not. #8071

Closed jorisvan-ons closed 1 year ago

jorisvan-ons commented 1 year ago

Bug description

I cannot view taxonomy term entries in the front-end. Clicking the "Visit URL" button in CP shows a 404. Using "Live preview" does work, though.

I use a multisite setup and statamic/eloquent-driver package. Here is the output of the support:details command:

My eloquent-driver config is as follows:

<?php

return [

    'connection'   => env('STATAMIC_ELOQUENT_CONNECTION', ''),
    'table_prefix' => env('STATAMIC_ELOQUENT_PREFIX', ''),

    'assets' => [
        'driver'          => 'eloquent',
        'container_model' => \Statamic\Eloquent\Assets\AssetContainerModel::class,
        'model'           => \Statamic\Eloquent\Assets\AssetModel::class,
    ],

    'blueprints' => [
        'driver'          => 'file',
        'blueprint_model' => \Statamic\Eloquent\Fields\BlueprintModel::class,
        'fieldset_model'  => \Statamic\Eloquent\Fields\FieldsetModel::class,
    ],

    'collections' => [
        'driver'     => 'file',
        'model'      => \Statamic\Eloquent\Collections\CollectionModel::class,
        'tree'       => \Statamic\Eloquent\Structures\CollectionTree::class,
        'tree_model' => \Statamic\Eloquent\Structures\TreeModel::class,
    ],

    'entries' => [
        'driver' => 'eloquent',
        'model'  => \Statamic\Eloquent\Entries\EntryModel::class,
        'entry'  => \Statamic\Eloquent\Entries\Entry::class,
    ],

    'forms' => [
        'driver'           => 'eloquent',
        'model'            => \Statamic\Eloquent\Forms\FormModel::class,
        'submission_model' => \Statamic\Eloquent\Forms\SubmissionModel::class,
    ],

    'global_sets' => [
        'driver'          => 'eloquent',
        'model'           => \Statamic\Eloquent\Globals\GlobalSetModel::class,
        'variables_model' => \Statamic\Eloquent\Globals\VariablesModel::class,
    ],

    'navigations' => [
        'driver'     => 'eloquent',
        'model'      => \Statamic\Eloquent\Structures\NavModel::class,
        'tree'       => \Statamic\Eloquent\Structures\NavTree::class,
        'tree_model' => \Statamic\Eloquent\Structures\TreeModel::class,
    ],

    'revisions' => [
        'driver' => 'eloquent',
        'model'  => \Statamic\Eloquent\Revisions\RevisionModel::class,
    ],

    'taxonomies' => [
        'driver' => 'file',
        'model'  => \Statamic\Eloquent\Taxonomies\TaxonomyModel::class,
    ],

    'terms' => [
        'driver' => 'eloquent',
        'model'  => \Statamic\Eloquent\Taxonomies\TermModel::class,
    ],
];

How to reproduce

Create a taxonomy with the following blueprint:

title: 'Product categories'
template: product_categories/show
layout: layout
route: '/product-categories/{slug}'
preview_targets:
  -
    label: Term
    url: '{permalink}'
    refresh: true
sites:
  - default
  - de
  - nl
  - uk

Try to view an entry at the /product-categories/{slug} uri. It should return a 404.

Logs

No response

Environment

Environment
Application Name: {{ CENSORED }}
Laravel Version: 9.52.7
PHP Version: 8.2.3
Composer Version: 2.5.1
Environment: local
Debug Mode: ENABLED
URL: {{ CENSORED }}
Maintenance Mode: OFF

Cache
Config: CACHED
Events: NOT CACHED
Routes: CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 1
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 3.4.9 PRO

Statamic Addons
statamic/eloquent-driver: 1.2.0


### Installation

Starter Kit using via CLI

### Antlers Parser

None

### Additional details

_No response_
duncanmcclean commented 1 year ago

Just to check: the taxonomy term you're viewing is published, yes?

jorisvan-ons commented 1 year ago

Yes. The data stored in the "data" column is as follows: {"title": "Blood pressure monitoring", "status": "published", "published": 1}

edalzell commented 1 year ago

Do you have the appropriate views created?

jorisvan-ons commented 1 year ago

The problem was that my taxonomy's handle was product_categories and statamic expects the template to be at product-categories/show.blade.php. That explains!

Thanks for the help.

Would be a nice feature to be able to set the route for a taxonomy, like you can for a collection, though!

I'll close this issue.