Can't edit an area from an array field in the schema contextually on the page
Hey, for some reason I cant' edit/save content from the show.html but it does work in the control panel of the snippet. I do see the content I've added from the control, but when I edit the content in the show.html (in the frontend editor) it dosent get saved.
thanks.
Not sure why this happens. Something we'd like to fix, but if you really want contextual editing, think about basing your work on the apostrophe-blog-2 module, where each blog post is a proper page.
On Wed, Jul 9, 2014 at 6:39 AM, Danny Braunstein [email protected] wrote:
Hey, for some reason I cant' edit/save content from the show.html but it does work in the control panel of the snippet. I do see the content I've added from the control, but when I edit it in the show.html (frontend editor) it dosent get saved.
thanks.
— Reply to this email directly or view it on GitHub https://github.com/punkave/apostrophe/issues/144.
*THOMAS BOUTELL, *DEV & OPS P'UNK AVENUE | (215) 755-1330 | punkave.com
Hmm, well I've 2 area fields in my snippet one of them is array of area, I made that to split the content into pages( that is switchable by the url - GET), these are the fields,
{
name: 'short_description',
type: 'area',
label: 'Short Description'
}, {
name: 'body2',
label: 'Body',
type: 'array',
schema: [{
name: 'text',
label: 'Text',
type: 'area'
}]
}
this is how I fetch short_description (which can be edit and works very well)
{{ aposArea(item, 'short_description', {
edit: edit,
area: item.short_description
}) }}
and this is how I fetch body2
{% if query.page %}
{% if query.page <= item.body2.length and query.page > 0 %}
{% set page = (query.page-1) %}
{% else %}
{% set page = 1 %}
{% endif %}
{% else %}
{% set page = 1 %}
{% endif %}
{{ aposArea(item.body2[page], 'text', {
slug: page.slug + ':item.body2[page].text',
area: item.body2[page].text,
edit: edit
}) }}
which get saved only by the control panel, I've putted that code in the pageMacros.html as a macro (if it might be it for some reason). well, I was getting the idea I'm doing something wrong because the short_description field works very well, any idea how can I get this fixed ?
thank you very much!
Set edit: false in your template. We do not, yet, support editing areas in snippets on their show pages.
On Wed, Jul 9, 2014 at 2:07 PM, Danny Braunstein [email protected] wrote:
Hmm, well I've 2 area fields in my snippet one of them is array of area, I made that to split the content into pages( that is switchable by the url - GET), these are the fields,
{ name: 'short_description', type: 'area', label: 'Short Description' }, { name: 'body2', label: 'Body', type: 'array', schema: [{ name: 'text', label: 'Text', type: 'area' }] }
this is how I fetch short_description (which can be edit and works very well)
{{ aposArea(item, 'short_description', { edit: edit, area: item.short_description }) }}
and this is how I fetch body2
{% if query.page %} {% if query.page <= item.body2.length and query.page > 0 %} {% set page = (query.page-1) %} {% else %} {% set page = 1 %} {% endif %} {% else %} {% set page = 1 %} {% endif %}
{{ aposArea(item.body2[page], 'text', { slug: page.slug + ':item.body2[page].text', area: item.body2[page].text, edit: edit }) }}
which get saved only by the control panel, I've putted that code in the pageMacros.html as a macro (if it might be it for some reason). well, I was getting the idea I'm doing something wrong because the short_description field works very well, any idea how can I get this fixed ?
thank you very much!
— Reply to this email directly or view it on GitHub https://github.com/punkave/apostrophe/issues/144#issuecomment-48511966.
*THOMAS BOUTELL, *DEV & OPS P'UNK AVENUE | (215) 755-1330 | punkave.com
Well that's sad to hear :( Hope you guys will get it asap it seems to be like really critic thing as all the cms based on frontend editing.
Thanks.
Have you evaluated apostrophe-blog-2?
On Wed, Jul 9, 2014 at 2:19 PM, Danny Braunstein [email protected] wrote:
Well that's sad to hear :( Hope you guys will get it asap it seems to be like really critic thing as all the cms based on frontend editing.
Thanks.
— Reply to this email directly or view it on GitHub https://github.com/punkave/apostrophe/issues/144#issuecomment-48513545.
*THOMAS BOUTELL, *DEV & OPS P'UNK AVENUE | (215) 755-1330 | punkave.com
I have to second Danny on this, we should look into this sooner than later, I'm dealing with some client confusion myself
There's likely a middle ground between these two extremes: snippets are global and therefore edited in a global context, blog-2 related content types are local as in bound to a page and therefore edited on a page. The global context is useful, especially for publishing in multiple places and managing in one. The local, page context is incredibly intuitive for editing, but difficult to manage (you need to remember where a particular blog post was published in order to find and edit it). My preference would be for the local editing with a simple convenience for globally managing them (a modal that shows all blog posts). I.e. Use blog-2 for things that have robust show pages but be able to access (link to) all of the blog posts in a global modal experience. This would conflate things for most clients, but that's probably ok as the distinction matters more for us as developers.
On Thu, Jul 10, 2014 at 5:41 PM, Stuart Romanek [email protected] wrote:
I have to second Danny on this, we should look into this sooner than later, I'm dealing with some client confusion myself
Reply to this email directly or view it on GitHub: https://github.com/punkave/apostrophe/issues/144#issuecomment-48668449
The question is whether blog-2 is as easily extendable as snippets are for all the same purposes.
If It can literally replace snippets - it would be better to indicate so and fully invest in it.
If it can't , snippets should be enabled for front end editing at least on show.html
Clients get confused when they're advertised a front end editing cms and half of it isn't editable
They serve different needs. Neither is going away.
Some things don't even need a "show" page or it doesn't tend to show everything in the same way you'd edit it. For these cases something global like snippets is really handy.
Other things are basically pages, but with a need for reuse around the site and an approach to pagination that isn't just a list of subpages. For these, blog-2 is great.
And you can construct other middle grounds yourself using apostrophe-fancy-page as a building block. In fact, blog-2 is built on fancy-page.
All that being said, editing areas and singletons on a "show" page of a snippet ought to work, and it's on my to-do list.
On Fri, Jul 11, 2014 at 2:59 AM, Danny Povolotski [email protected] wrote:
The question is whether blog-2 is as easily extendable as snippets are for all the same purposes.
If It can literally replace snippets - it would be better to indicate so and fully invest in it.
If it can't , snippets should be enabled for front end editing at least on show.html
Clients get confused when they're advertised a front end editing cms and half of it isn't editable
— Reply to this email directly or view it on GitHub https://github.com/punkave/apostrophe/issues/144#issuecomment-48700033.
*THOMAS BOUTELL, *DEV & OPS P'UNK AVENUE | (215) 755-1330 | punkave.com
(Danny, you should really dig into fancy-page and blog-2 at this point. If you care this much about these use cases, then you should invest that much effort in order to give more informed feedback.)
On Fri, Jul 11, 2014 at 11:12 AM, Tom Boutell [email protected] wrote:
They serve different needs. Neither is going away.
Some things don't even need a "show" page or it doesn't tend to show everything in the same way you'd edit it. For these cases something global like snippets is really handy.
Other things are basically pages, but with a need for reuse around the site and an approach to pagination that isn't just a list of subpages. For these, blog-2 is great.
And you can construct other middle grounds yourself using apostrophe-fancy-page as a building block. In fact, blog-2 is built on fancy-page.
All that being said, editing areas and singletons on a "show" page of a snippet ought to work, and it's on my to-do list.
On Fri, Jul 11, 2014 at 2:59 AM, Danny Povolotski < [email protected]> wrote:
The question is whether blog-2 is as easily extendable as snippets are for all the same purposes.
If It can literally replace snippets - it would be better to indicate so and fully invest in it.
If it can't , snippets should be enabled for front end editing at least on show.html
Clients get confused when they're advertised a front end editing cms and half of it isn't editable
— Reply to this email directly or view it on GitHub https://github.com/punkave/apostrophe/issues/144#issuecomment-48700033.
*THOMAS BOUTELL, *DEV & OPS P'UNK AVENUE | (215) 755-1330 | punkave.com
*THOMAS BOUTELL, *DEV & OPS P'UNK AVENUE | (215) 755-1330 | punkave.com
Tom, no problem. However I did find apostrophe-snippet the best for some of my use cases, and repeatedly asked for some kind of pointer to even go and submit my own PR fixing this.
That would be an option too :) I realise that you have more on your tasklist than fixing every use case.
I can edit an area on a show page and it sticks. I will try a singleton next On Jul 11, 2014 12:24 PM, "Danny Povolotski" [email protected] wrote:
Tom, no problem. However I did find apostrophe-snippet the best for some of my use cases, and repeatedly asked for some kind of pointer to even go and submit my own PR fixing this.
That would be an option too :) I realise that you have more on your tasklist than fixing every use case.
— Reply to this email directly or view it on GitHub https://github.com/punkave/apostrophe/issues/144#issuecomment-48751791.
I just tried this with the default show.html template of the events module, which is very plain and ordinary (:
It works for both areas and singletons.
For areas I edited the area that is already there.
For singletons I added this code:
{{ aposSingleton(item, 'thumbnail', 'slideshow') }}
Inside the renderEvent macro (in eventMacros.html).
Both worked fine.
So I need to ask for a simple demonstration of where and when this doesn't work.
Thanks!
On Fri, Jul 11, 2014 at 12:43 PM, Tom Boutell [email protected] wrote:
I can edit an area on a show page and it sticks. I will try a singleton next On Jul 11, 2014 12:24 PM, "Danny Povolotski" [email protected] wrote:
Tom, no problem. However I did find apostrophe-snippet the best for some of my use cases, and repeatedly asked for some kind of pointer to even go and submit my own PR fixing this.
That would be an option too :) I realise that you have more on your tasklist than fixing every use case.
— Reply to this email directly or view it on GitHub https://github.com/punkave/apostrophe/issues/144#issuecomment-48751791.
*THOMAS BOUTELL, *DEV & OPS P'UNK AVENUE | (215) 755-1330 | punkave.com
@danny-Weebo was working on a project with me, I think he can post some (not)working code.
I just updated the standard templates for the snippets, events, blog and map modules to include an "edit" button on every show page. That "edit" button opens the modal for that particular snippet, and on save, refreshes the content on the page.
This is what I'd recommend in most cases with snippets. So I also explicitly set edit: false for the body areas now in order to avoid confusing edit buttons that only cover part of what can be changed about that snippet. With the edit button, you get to a modal that lets you change anything you wish to change about that object, including title, tags, etc.
However, on a case by case basis, it often makes sense to let users edit areas and singletons in context on the show page and you should go right ahead and do that (just don't set edit: false).
On Fri, Jul 11, 2014 at 1:09 PM, Danny Povolotski [email protected] wrote:
@danny-Weebo was working on a project with me, I think he can post some (not)working code.
— Reply to this email directly or view it on GitHub https://github.com/punkave/apostrophe/issues/144#issuecomment-48756990.
*THOMAS BOUTELL, *DEV & OPS P'UNK AVENUE | (215) 755-1330 | punkave.com
(I'll leave this issue open for now in case we get a reproducible bug.)
On Fri, Jul 11, 2014 at 1:38 PM, Tom Boutell [email protected] wrote:
I just updated the standard templates for the snippets, events, blog and map modules to include an "edit" button on every show page. That "edit" button opens the modal for that particular snippet, and on save, refreshes the content on the page.
This is what I'd recommend in most cases with snippets. So I also explicitly set edit: false for the body areas now in order to avoid confusing edit buttons that only cover part of what can be changed about that snippet. With the edit button, you get to a modal that lets you change anything you wish to change about that object, including title, tags, etc.
However, on a case by case basis, it often makes sense to let users edit areas and singletons in context on the show page and you should go right ahead and do that (just don't set edit: false).
On Fri, Jul 11, 2014 at 1:09 PM, Danny Povolotski < [email protected]> wrote:
@danny-Weebo was working on a project with me, I think he can post some (not)working code.
— Reply to this email directly or view it on GitHub https://github.com/punkave/apostrophe/issues/144#issuecomment-48756990.
*THOMAS BOUTELL, *DEV & OPS P'UNK AVENUE | (215) 755-1330 | punkave.com
*THOMAS BOUTELL, *DEV & OPS P'UNK AVENUE | (215) 755-1330 | punkave.com
I've posted the code(my second comment).
Thanks
Oh I see. That is a completely different issue having nothing to do with snippets (:
You can't currently edit an area/singleton from an array schema contextually.
I have renamed this issue accordingly.
It should be doable to make this work at some point. Arrays are pretty new and we are still exploring everything they allow us to get away with ourselves (:
This works now. However do not try to pass the "slug" option yourself as in your current code. That is now unnecessary for existing areas (and areas in arrays are always existing areas).
Example of working code:
In app.js:
'apostrophe-events': {
addFields: [
{
type: 'array',
name: 'chapters',
label: 'Chapters',
schema: [
{
type: 'string',
name: 'heading',
label: 'Heading'
},
{
type: 'area',
name: 'text',
label: 'Text'
}
]
}
]
},
In renderEvent:
{% for chapter in item.chapters %}
<h4>{{ chapter.title | e }}</h4>
{{ aposArea({ area: chapter.text, edit: item._edit }) }}
{% endfor %}