How does one edit the content of a Snippets in the Panel?

How does the Panel work with snippets?

  • Given that I have a footer.php snippet located in /site/snippets/ that has text and links.
  • How do I add this in the Panel so that I can change the text in the footer at once for all pages (500+).
  • What would be a good structure?
  • Panel does not work with snippets, unless you add some custom plugin to make the snippet files editable (as far as I know)
  • if you call the snippet via snippet('footer'), if the file is updated, every call to any page that uses it will use the updated file
  • as for editability via panel, you can do:
    • create specific page for the footer fields, which just redirects home, and then call $pages->get('footer-page') and pull the data from there
    • or add the fields you want to site blueprint, and then you use it via $site variable in the snippet.

I’d do this, or maybe you already have a contact page? Depends on the data you use in the snippet.

Thank you Adam and Texnixe for helping me out!

I’ve set up the following file:

site.yml contains:

title: Site

columns:
  - width: 1/2
    fields:
      footer-text: 
        label: footer-text
        type: text
      footer-text-1: 
        label: footer-text-1
        type: text

So footer-text does give back the content as a label, but it’s not editable (obviously). The content is in a language file /site/languages/en.php.

What would be a good strategy for moving the content from the php file to a text file so that is editable?

In the root of content add site.txt and put the content there? I’m not sure if I can still use the ‘snippet’ on other page(s).

There’s a problem with your blueprint, you can’t use dashes in field names, use camelCase or underscores. That’s why it is not editable.

This is completely independent. The contend lives in the content files and is edited via the Panel. In your templates and snippets, you just fetch the code from the content files.