Hide "Add content" or "Add layout" button where no content or layout are available?

Is there a way to do that ?
I’m asking that because, if no content is available, an nearly empty modal is displayed, it’s a bit weird :
Uploading Capture d’écran 2015-11-29 à 18.43.56.png…

Hmm, no not currently I think. It would be possible to hide them all with a custom CSS file and some display:none; attributes, but I don’t think that’s what you’re looking for? Could you elaborate a bit on the use case you’re dealing with so I can better understand how you don’t have any fields/layouts available at all? :stuck_out_tongue:

Yeah sure. I’m creating a template that is almost fixed. My pages are calibrated for specific contents, and users who will fill the resources forms will not have the possibility to build the pages the way they want.

The other thing is that I can’t only use default ContentBlocks contents. The users will not understand what I mean with only “Title” or “Richtext”, they need to know which of the specific content is expected as each part of the template.
That’s why I created custom fields called “Name of product”, “Solution description” etc., that fields give sense for the user, he know exactly that he has to put the solution description in the “Solution description” field for example.

And for that custom fields, I use constraints, because there is only one “Name of product”, I have to cancel the possibility for the user to reusing this component (it’s not true at 100% because the “Repeat” button can duplicate any layout without seing components restrictions, it’s a bit annoying. Maybe I will probably hide this button in CSS).

I made this for all the fields in my template, and I deleted all default components that users will not have to use. That’s why the list of components is empty. But I can’t remove with CSS this buttons, because, on some resources, there is no video or testimonies (for example) to include, so the user will have the possibility to remove the layout related. But if 2 weeks later, he got a video, it is necessary for him to have the possibility to reinclude this layout.

An other thing : can we have the possiblity to restrict templates uses like we can for layouts and components ? In my case, my template is build with will components that can be in my resource. The users must only have the possibility to remove a layout if they have no contents for it or adding the removed layout if it changes in future.

I’m not sure if this are really understandable, if not, tell me what is not clear.

I second the questions from Romain. Or in a more general way: are there any thoughts about restrictions to end users?

As for my first impression I had from Content Blocks: it’s awesome! And I suggest the following improvements/changes:

  • Possibility to name the Layout and/or fields. It would be easier for end users to see where exactly in the document they are playing around
  • Possibility to restrict or lock some blocks. E.g. one section is the code for a google map. It would be nice if the end user is not able to alter this entry.

Best regards
Fabian

You can already name fields by creating a new field in the ContentBlocks manager (Extras > ContentBlocks).
Simply click on the “Add field” button and fill the “name” field to name the field (huhu).

For blocking and restricts elements, I used css to hide the buttons. The only thing I didn’t perform to do is to disable the ability to drag and drop fields in a layout. Fortunately for us (not for the users), there is nothing that indicates that a field can by dragged and dropped (my clients never tried to do this). Here is what my layout look like after my “css lock” :

Hope this can help you for now.

Thanks, Romain!
Did you modify the contentblocks.css directly or did you inject another css-file to the manager?
If the latter, would it be possible to add this css only when a certain user, e.g. an editor with role “Editor” logs into the manager?

Best
f.

Aside from what Romain already mentioned, ContentBlocks 1.3 also allows you to rename a layout in the canvas. So instead of “Main & Sidebar”, you can click the title and change it to “Primary Content” for that particular instance of the layout.

The CSS inject instructions are here: https://www.modmore.com/contentblocks/faqs/#faq_56 just use the browsers inspector add use .contentblocks-add-content-here { display:none; }. The only problem is this injects for all fields.

@mhamstra, I see there is a data-part="my_fields_key" and data-field="96" identifier could you use the $modx->regClientScript(' <some ext.js function? > '); plugin to find the data-part or data-field and only apply the .contentblocks-add-content-here { display:none; } if found?

It seems a bit hacky as there will be times when you might need to apply this to multiple data-parts. I’m sure something built-in to CB would be much better.