I created a new Netlify CMS website based on Jekyll and created new collections workshop and consultant
With the Netlify CMS interface, I can see, add, edit and delete the new collections, but I cannot retrieve them in the view.
--/_consultants
name.md
--/_workshops
title.md
config.yml
collections:
# WORKSHOPS
- name: "workshop" # Used in routes, ie.: /admin/collections/:slug/edit
label: "Workshop" # Used in the UI, ie.: "New Post"
folder: "_workshops" # The path to the folder where the documents are stored
sort: "title:desc" # Default is title:asc
create: true # Allow users to create new documents in this collection
slug: "{{slug}}"
output: true
permalink: /wokshop/:title
fields: # The fields each document in this collection have
- {label: "Title", name: "title", widget: "string", tagname: "h1"}
- label: "Consultant"
name: "consultant"
widget: "relation"
collection: "consultant"
searchFields: ["name"]
valueField: "name"
- {label: "Location", name: "location", widget: "string"}
- {label: "Duration", name: "duration", widget: "string"}
- label: "Category"
name: "category"
widget: "select"
options: ["Business", "Team & Culture", "Design"]
- {label: "Price", name: "price", widget: "string", required: false}
- {label: "Permalink", name: "permalink", widget: "hidden"}
- {label: "Blurb", name: "ws-blurb", widget: "string"}
- {label: "Description", name: "ws-description", widget: "markdown"}
# CONSULTANTS
- name: "consultant" # Used in routes, ie.: /admin/collections/:slug/edit
label: "Consultant" # Used in the UI, ie.: "New Post"
folder: "_consultants" # The path to the folder where the documents are stored
sort: "date:desc" # Default is title:asc
create: true # Allow users to create new documents in this collection
slug: "{{slug}}"
identifier_field: name
output: true
fields: # The fields each document in this collection have
- {label: "Permalink", name: "permalink", widget: "hidden"}
- {label: "Name", name: "name", widget: "string", tagname: "h1"}
- label: "Image"
name: "image"
widget: "image"
# default: "/uploads/chocolate-dogecoin.jpg"
media_library:
config:
multiple: false
- {label: "Bio", name: "bio", widget: "markdown"}
- {label: "References", name: "references", widget: "markdown"}
- {label: "Link", name: "link", widget: "string"}
- {label: "Workshops hosted", name: "ws-hosted", widget: "number"}
When I try to retrieve the newly created workshops and consultants I can't get it to work:
<ul>
{% for item in site.workshops %}
<li>
<h2>
{{ item.title }}
</h2>
</li>
{% endfor %}
</ul>
And when I try to debug the object, it returns NULL: {{ site.workshops | jsonify }}
What confuses me the most is that I can access the collections through the admin interface, but for the last 4 hours I failed at retrieving them in the view.
What am I missing?
I found the solution! So for anyone getting stuck at this point: the information below has to go to _config.yml and not (!) to config.yml
collections:
workshops:
output: true
consultants:
output: true
Related
The Navigator tool comes with the ability to display custom tables, defined through the frontend-config.js file. The quickstart example contains such a file that defines a custom list of contracts.
Is it also possible to display a custom list of templates?
To add a custom list of templates, add a custom view with source.type=="templates".
Here is an example of a custom view that would list all tempaltes that have "Iou:Iou" in their template ID:
iouTemplates: {
type: "table-view",
title: "Iou Templates",
source: {
type: "templates",
filter: [
{
field: "id",
value: "Iou:Iou",
}
],
search: "",
sort: [
{
field: "id",
direction: "ASCENDING"
}
]
},
columns: [
{
key: "id",
title: "Template ID",
createCell: ({rowData}) => ({
type: "text",
value: rowData.id
}),
sortable: true,
width: 80,
weight: 0,
alignment: "left"
}
]
}
I am trying to hook up my Jekyll installation with NetlifyCMS. I am using a custom theme that works fine without the CMS part, however when I integrate as per the NetflifyCMS docs I get this error.
~/.rvm/gems/ruby-2.5.1/gems/jekyll-3.4.1/lib/jekyll/collection.rb:158:in `sanitize_label': undefined method `gsub' for #<Hash:0x00007fed774d2a3
I am running this on a Mac OSX and here is my config.yml is. The relevant section is the collection section:
collections:
- name: 'docs'
output: true
label: 'Docs'
folder: '_docs/'
create: true
slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
editor:
preview: false
fields:
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
- { label: 'Title', name: 'title', widget: 'string' }
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
- { label: 'Body', name: 'body', widget: 'markdown' }
- name: 'faqs'
output: false
label: 'Faqs'
folder: '_faqs/'
create: true
slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
editor:
preview: false
fields:
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
- { label: 'Title', name: 'title', widget: 'string' }
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
- { label: 'Body', name: 'body', widget: 'markdown' }
- name: 'changelogs'
output: false
- name: 'blog'
output: true
label: 'Blog'
folder: '_posts/'
create: true
slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
editor:
preview: false
fields:
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
- { label: 'Title', name: 'title', widget: 'string' }
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
- { label: 'Body', name: 'body', widget: 'markdown' }
Found the problem. NetlifyCMS docs weren't so clear. These collections should have been put in the ./admin/config.yml and I was putting them in the main config.yml file.
So I've built a Jekyll site with the theme [Moon](Failed to persist entry: TypeError: Cannot read property 'sha' of undefined) and I've uploaded it to my GitHub repository. Then I want to add Netlify's admin panel to my site so I follow this guide which I modify the config.yml to the following code:
backend:
name: git-gateway
publish_mode: editorial_workflow
media_folder: "files"
display_url: https://ccsource.org
slug:
encoding: "ascii"
clean_accents: true
collections:
- name: "story"
label: "Story"
folder: "_posts"
extension: "md"
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
create: true
fields:
- {label: "Layout", name: "layout", widget: "hidden", default: "post"}
- {label: "Title", name: "title", widget: "string"}
- label: "tags"
name: "tags"
widget: "list"
allow_add: true
default: ["story"]
- {label: "Summary", name: "excerpt", widget: "string", required: false}
- {label: "comments", name: "comments", widget: "hidden", default: true}
- label: "Publish date"
name: "date"
widget: "datetime"
default: ""
format: "MMM Do YY"
- {label: "Body", name: "body", widget: "markdown", required: true}
Since I got markdown sample file like:
---
layout: post
title: "Sample"
date: 2016-03-15
excerpt: "Hello..."
tag:
- sample
- post
- video
comments: true
---
# Sample
But after all things setup and deployed I visit my site's admin panel and try to create a new post I keep getting the following error.
Failed to persist entry: TypeError: Cannot read property 'sha' of undefined
And I've googled and modified the branch value to site which match to my github repository, but the error keeps showing, how can I fix it?
For anyone else experiencing this, the issue was that Netlify Identity was enabled, but Git Gateway, a sub-feature of Netlify Identity, was not. Instructions for enabling Git Gateway here: https://www.netlify.com/docs/git-gateway/#getting-started
Here is my code:
var playerInstance = jwplayer("mySingleVideoWrapper").setup({
image: getCurrentPosterSrc,
sources: [
{
file: 'file-360.mp4',
label: "360p"
},{
file: 'file-480.mp4',
label: "480p"
},{
file: 'file-720.mp4',
label: "720p HD"
},{
file: 'file-1080.mp4',
label: "1080p HD"
}
],
width: "100%",
androidhls: 'true',
type: "hls",
fallback:true,
aspectratio: "16:9",
autostart: true,
logo: {
hide: true
},
tracks: [{
file: "/assets/captions-en.vtt",
label: "EN",
kind: "captions",
"default": true
},{
file: "/assets/captions-es.vtt",
label: "ES",
kind: "captions"
},{
file: "/assets/captions-fr.vtt",
kind: "captions",
label: "FR"
},{
file: "js/assets/captions-de.vtt",
label: "DE",
kind: "captions"
}]
});
And also here is a screenshot where I highlighted what I need
So I need that 'Auto' button which will autodetect which is the best quality for current user. Now with my code I see all 4 sources/qualities but 'Auto' button can't see. How can I add it ?
Amazon Support have me this useful article link http://www.jwplayer.com/blog/encoding-hls-with-amazon-elastic-transcoder/ and I could do what I want.
I have tried to create a new empty record without creating a model.
Accidentally I tried to run this:
new new storeComp.model()
and it actually works!
anyone know any solution for this or an answer to how is it working ?
Thanks!
Shalev
Stores that are not configured with a model will create an anonymous one implicitly. This is explained in the docs for the implicitModel private property (the store needs to know that because if it uses an implicit model, it must destroy it when it is itself destroyed).
In the end that means that you can safely expect any store to be backed with a model.
I faced the same problem for an associative store. For that i have used below JSON format to load project store. So automatically empty record is created in associative (project-resources) Store.
Store:
Ext.define('App.store.Projects', {
extend : 'Ext.data.Store',
model : 'App.model.Project'
});
Models:
Ext.define("App.model.Project", {
extend: 'Ext.data.Model',
idProperty : 'id',
uses : ['App.model.ProjectResource'],
fields: [
{ type: 'auto', name: 'id'},
{ type: 'number', name: 'customerid'},
{ type: 'string', name: 'projectcode'}
],
associations: [
{type: 'hasMany', model: 'App.model.ProjectResource', name: 'Resources', storeConfig: { remoteFilter: true }}
]
});
Ext.define("App.model.ProjectResource", {
extend: 'Ext.data.Model',
idProperty : 'id',
fields: [
{ type: 'number', name: 'id'},
{ type: 'string', name: 'name'},
{ type: 'number', name: 'projectid'},
{ type: 'auto', name: 'resourceid'}
],
associations : [
{type : 'belongsTo', model: 'App.model.Project'}
]
});
JSON Format:
[
{
"id": "105",
"customerid": "105",
"projectcode": "ALN01",
"Resources": {}
}
]
Loading store with empty object (like "Resources": {}) will create empty model.