Skip to content

[RFC] Allow users to opt-out of Entry templates #83

@calumgunn

Description

@calumgunn

Summary

Currently, Entries are forced to use their parent's layout. This can be overridden by defining entry? to false, but this is undocumented and unintuitive.

Motivation

Often, we want to opt-out of Entry templates, as it isn't appropriate for the site in question. We already have the mechanism available to do this, we'd just like to expose this choice to the end user.

Detailed design

To opt-out of Entry templates, define the following in your Set Entry model:

# app/slices/foo_set/foo.rb
class Foo < Page
  def use_parent_layout?
    false
  end
end

When true:

  • Disable layout selection on individual entries
  • Enable Edit entry template and Placeholder slice capability

screen shot 2015-03-30 at 15 18 19

When false:

  • Enable layout selection on individual entries
  • Disable Edit entry template and Placeholder slice capability

screen shot 2015-03-30 at 15 20 44

Generators

The new generated entry model would like something like this:

# app/slices/foo_set/foo.rb
class Foo < Page
  # Set this to `false` to enable arbitrary layouts on individual entries.
  def use_parent_layout?
    true
  end

  def template
    "foo_set/views/show"
  end

  # Uncomment the as_json method if the page defines fields that are
  # shown in the admin UI. Pass a hash to merge() that contains each
  # field.
  #
  # def as_json(options = {})
  #   super.merge(published: published.to_s)
  # end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions