-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Post Templates #9060
Comments
Updated to reflect changes in API design:
The For reference the client will fetch
The request made when opening the editor could be optimised if it's possible to query |
refs TryGhost/Ghost#9060 - extract `templates` object - all templates - custom templates
refs TryGhost/Ghost#9060 - extract `templates` object - all templates - custom templates
refs TryGhost/Ghost#9060, requires TryGhost/Ghost#9073 - add `{{gh-psm-template-select}}` component - allows selection of a custom template for a post if the active theme has custom templates - loads themes on render, only hitting the server if not already in the store - disables select if post slug matches a `post-*.hbs` or `page-*.hbs` template - adds `customTemplate` attr to `Post` model - adds `templates` attr to `Theme` model with CPs to pull out custom vs post/page override templates - add `.gh-select.disabled` styles to make disabled selects look visually disabled
refs TryGhost/Ghost#9060 - extract `templates` object - all templates - custom templates
This is really awesome!! |
I see a couple of small problems with the spec/implementation. From the spec:
Doing my best to articulate what the problems are, but they are a little bit circular:
I don't think these are big problems to address, but I do feel they'd be harder to fix later. |
This is an issue with the spec wording, "available templates" was meant as "available custom templates", I'd unintentionally omitted the clarification in places as the spec was only dealing with custom templates.
This was a later decision made during implementation, the spec wasn't updated to match.
It doesn't get used by the client, I thought it already existed which is why it's in the spec. It can safely be removed if there are no use cases.
Earlier versions of the spec did have |
Was removed. I thought it's used. See.
I've added a TODO here. We discussed that we don't know where we should filter custom templates at the moment. We have to wait for a second use case. For now, as soon as you receive your theme response from GScan, it will tell you which of your templates are custom.
If we add an endpoint to fetch the active theme e.g. /themes/active, we need a special permission in the db (e.g. READ_ACTIVE_THEME), plus the format of the endpoint does not follow a common API pattern. These kind of requests should be fetched via query params If we keep /themes/:name or use query params, we have to add a hardcoded permission condition to say "only author and editor can read the active theme". It's the same if you would like to fetch a post with the status "scheduled" and you don't want authors to be able to read them. Furthermore, themes don't live in the database. They are not able to redefine permissions in the permissible fn. So the concept of attribute based permissions does only exists for models who redefine permissions in the permissible fn. I have added a comment to describe the browse theme endpoint a bit better, see. |
refs TryGhost/Ghost#9060, requires TryGhost/Ghost#9073 - add `{{gh-psm-template-select}}` component - allows selection of a custom template for a post if the active theme has custom templates - loads themes on render, only hitting the server if not already in the store - disables select if post slug matches a `post-*.hbs` or `page-*.hbs` template - adds `customTemplate` attr to `Post` model - adds `templates` attr to `Theme` model with CPs to pull out custom vs post/page override templates - add `.gh-select.disabled` styles to make disabled selects look visually disabled
refs TryGhost/Ghost#9060 - add `{{gh-psm-template-select}}` component - allows selection of a custom template for a post if the active theme has custom templates - loads themes on render, only hitting the server if not already in the store - disables select if post slug matches a `post-*.hbs` or `page-*.hbs` template - adds `customTemplate` attr to `Post` model - adds `templates` attr to `Theme` model with CPs to pull out custom vs post/page override templates - add `.gh-select.disabled` styles to make disabled selects look visually disabled
So is this feature available now in production build? |
@edarioq Yes, it was released with Ghost 1.13.0 |
@DINESHKARPE sorry to hear you're having trouble, make sure you have some custom templates available in your theme, the template dropdown won't appear unless you do. If you're still having issues please swing by our Slack channel for support. |
Hi,brother, is this feature available in ghost v2.10? |
I find the reason, seems docker has cache the site, I restart docker container, it works!!! |
Feature overview
Some blogs have various "post types" that should be rendered differently to standard blog posts.
It's currently possible to do this in a round-a-bout way by using (internal) tags, partials, and conditionals in
post.hbs
but it's not ideal for certain site structures and can become unwieldy with many post types. When using such a setup the availability of different post types is hidden from authors by overloading the tags feature with theme/site-specific functionality.With the Custom Post Templates feature theme authors will be able to create individual templates that are recognised as custom templates and exposed in the admin interface for selection by post authors.
Design
UI:
Technical:
custom-{{dasherized-name}}.hbs
dasherized-name
will be titleized toDasherized Name
for display in the UI/themes/
and/themes/:name/
endpointspost/page-{{slug}}.hbs
templates and "shared" custom templates so that the client dropdown can display only the shared templatespost-{{slug}}.hbs
orpage-{{slug}}.hbs
template exists and matches the post slug then that template has precedence and will override any custom template selectionpost.hbs
orpage.hbs
template/themes/
&/themes/:name/
endpoint formatWhen fetching multiple or single themes the available templates will be included as an attribute on each member in the collection. Example fetching themes where one theme is installed and it contains a single custom, post, and page template:
GET /themes/
custom-*.hbs
templates are automatically assigned to both posts and pagespost-*.hbs
templates are automatically assigned to posts, with the slug calculated from the filenamepage-*.hbs
templates are automatically assigned to pages, with the slug calculated from the filenameThe
filename
attribute acts as a unique identifier.The
name
attribute will be auto-generated from the filename by titleizing after removing thecustom/post/page-
prefix and file extension.The
for
attribute will be used by the client to determine when custom templates aren't available due to a slug-based template (post-*.hbs
,page-*.hbs
) taking precedence.TODOs
templates
attribute containing list of custom templates and anypost/page-*
templates as part of the/themes/
and/themes/:name/
responsescustom-template
field to the post modelcustom-template
to be set during savingThe text was updated successfully, but these errors were encountered: