dijkr / Copia

Laravel-project with CMS
0 stars 0 forks source link

Every category need a page at the CMS, since now no banner will be loaded if there isn't a page #22

Closed dijkr closed 1 year ago

dijkr commented 1 year ago

Probably a default banner should be shown. For now, for every category, a page need to be manually added in the CMS. Then the banner is set from there.

1) It would the nicest if this will automatically happen, once a new category exist in the database. 2) Keep them manually, and just find a solution to inform editors to create a new page. 3) Set a default value, if there isn't any value from the CMS (null). So that at least some default banner is shown.

More suggestions are welcome.

dijkr commented 1 year ago

A solution for 3. listed above. This will load the banner from the database, if there is not a page at the CMS yet. Using a if / else statement. https://statamic.dev/antlers#elseif-else

{{ collection:promotions :slug:is="segment_2" }}
        <div class="productbanner">
            <div class="productbanner-item">
                {{ if banner }}
                    {{# Banner from the CMS #}}
                    <img src="{{ banner }}">
                {{ else }}
                    {{# Banner placeholder from the database #}}
                    <img src='/images/banners/{{ category.banner }}'>
                {{ /if }}
                <div class="productbanner-text">
                    <h1> {{ category.name }} </h1>
                </div>
            </div>
        </div>
{{ /collection:promotions :slug:is="segment_2"  }}

This will require the CMS-editor to manually add a page at the CMS, and set the banner. But now the issue will be partly handled, by just temporarily using a placeholder-banner from the database.