In StarterKit, changed photography.php to blog.php. Now cover()->url()-> isn't working


Silly question. I started with the StarterKit. I wanted to use the photography page as the template for my blog

i changed photography.php to blog.php
i changed album.php to blog-post.php

I changed blueprints/pages/photography.yml to blog.yml
I changed blueprints/pages/album.yml to blog-post.yml
I changed blueprints/sections/albums.yml to blogposts.yml

I changed the folder name from 1_photography to 1_blog
I changed the .txt file in 1_blog to blog.txt
I changed the .txt files in 1_blog/1_example-post from albums.txt to blogposts.txt

Now, on my blog.php page, I try to do this, which was working before:

<div class="col-xs-12 blog-post-page-image" style="background-image: url('<?= $page->children()->first()->cover()->url() ?>');"></div>

But I get this error - it’s looking in for the cover in the root folder now.
GET http://localhost:8888/Stake/-%20last-tree-standing.jpg 404 (Not Found)

Why is it looking in my root folder?

Furthermore, in panel/pages/blog, the thumbnails no longer show up. They are supposed to be based off the cover. I can get the thumbnails to show up I go to blogposts.yml and change

query: page.cover


query: page.image

Although that’s not what I need. Why doesn’t it recognize that I have selected cover?

Here are my YML files for reference:


# Each page blueprint must have a title, the title may be different from the file name
title: Blog

# Each page can have an icon that is shown in page listings when no preview image is available.
icon: 🖼

# Here we extend two sections which are defined in `/site/blueprints/sections/albums.yml`
# They differ in their page status and the headline.
    extends: sections/blogposts
    headline: Drafts
    status: draft

    extends: sections/blogposts
    headline: Published Albums
    status: listed


# Each page blueprint must have a title, the title may be different from the file name
title: Album

# Each page can have an icon that is shown in page listings when no preview image is available.
icon: 🖼

# Page status can be limited, here to `draft` and `listed`.
# More about page status:
  draft: true
  listed: true

# Define the form layout with two columns
# Columns are optional but help structure the form layout
# The first column defines an files section, the second a set of fields
# More about different types of sections:
# More about columns:

  - width: 1/3
    # The first column contains a set of fields to store
    # information about the album.
    # List of all available field types:
      # If you need the same field in multiple locations, you can define them once and reuse whereever needed.
      # Here we use a files field defined in `/site/blueprints/field/cover.yml`
      cover: fields/cover
        type: text
        placeholder: "{{ page.title }}"
        help: Leave empty to use the title as headline
        type: text
        type: writer
      tags: true

  - width: 2/3
      # The `images` files section shows all images of
      # the current page that use the `image` template
        type: files
        layout: cards
        template: image
        info: "{{ file.dimensions }}"
          ratio: 5/4
          cover: true
        min: 1
        size: small


# This section blueprint defines a pages section that can be reused across multiple blueprints
# or multiple times within the same blueprint, see `/site/blueprints/pages/photography.yml`  and `/site/blueprints/site.yml`
# Sections can have different layouts and display additional information or a preview image
# More about pages sections:
type: pages
headline: Blog
size: small
info: "{{ page.images.count }} image(s)"
layout: cards
template: blog-post
empty: No albums yet
  query: page.cover
  cover: true
  ratio: 5/4

blog-post.txt example:

Title: 5 questions for Liam Hecht



- last-tree-standing.jpg


Headline: In our ongoing series "Five Questions for...", where we talk to those that are making Return on Rent come to life, we sat down with Liam Hecht.


Subheadline: Our friends with leaves


Text: <p>Hug them if you like. They might not appreciate it though.</p><p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum id ligula porta felis euismod semper. Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod.</p>



Thanks, and i apologize in advance for the crappy question. Hoping someone can point me to where I went wrong.

The issue you are having stems from the fact that there is also a album.php model with a cover method that you would have to rename, or you would have to fix your code like this:

<div class="col-xs-12 blog-post-page-image" style="background-image: url('<?= ($cover = $page->children()->first()->cover()->toFile()) ? $cover->url()  : '' ?>');"></div>

Using a conditional here to check if that file even exists before calling the url() method instead of simply chaining like you did is a best practice in any case.

There’s also a album.php controller that either have to rename or can delete if you don’t need it.

Thank you!!