Storyblock editor

46 views
Skip to first unread message

Xander Steinmann

unread,
Oct 17, 2022, 6:00:29 AM10/17/22
to dotCMS User Group
Hi all,

I'm playing around with the Storyblock editor and I can't figure out how to render a contentlet in a storyblock field. I have the content type "Button"; Should I create a VTL called /application/storyblock/Button.vtl? And should it countain something like <a href="$linkUrl>$linkText</a>?

I'm also a bit confused as to why you need to configure a for loop when overriding the heading1.

Kind regards,

Xander

Xander Steinmann

unread,
Oct 17, 2022, 6:01:36 AM10/17/22
to dotCMS User Group
Sorry, it's callede the block editor :)
https://www.dotcms.com/docs/latest/block-editor

Op maandag 17 oktober 2022 om 12:00:29 UTC+2 schreef Xander Steinmann:

Fishsmith

unread,
Oct 17, 2022, 11:12:06 AM10/17/22
to dotCMS User Group
Xander,
Try these steps and see if this helps: 
  1. in the Block Editor field variables add (This limits the list of content types that show. Each block field can have its own list):
    Value: contentTypes
    Key: Button
  2. Create a VTL called: dotContent-button.vtl in the  "/application/storyblock/default/" (I like to add a subfolder incase I want to render the output differently for different blocks)
  3. Your code should look something like this:
    #set ($content = $item.attrs.data)
    <a href="$content.linkUrl">$content.linkText</a>
  4. Last in the VTL or container you need to add the path to the folder and render the output as html:
    $!{myBlock.toHtml('/application/storyblock/')}
Let me know if you run into any issues.

Jason

Xander Steinmann

unread,
Oct 18, 2022, 4:06:57 AM10/18/22
to dotCMS User Group
Hi Jason,

It's almost working. I have:
  1. The field variables as you described. This is more for convenience to the content manager
  2. I have a VTL file called dotContent-Button.vtl in /application/storyblock/
  3. dotContent-Button.vtl contains :
    #set ($content = $item.attrs.data)
    $item.class $item
    Button: <a href="$content.linkUrl">$content.linkText</a>
  4. I have a container which contains the code $dotContentMap.get('body').toHtml('/application/storyblock/'). My content field is called body, and this is what dotCMS generated for me except for the /application/storyblock/ folder. I don't use a /default folder (yet).
The result is:
class com.dotmarketing.util.json.JSONObject {"type":"dotContent","attrs":{"data":{"hostName":"default","modDate":"2022-10-17 09:43:25.965","publishDate":"2022-10-17 09:43:25.965","language":"en-US","title":"Test button","type":"default","contentTypeIcon":"event_note","baseType":"CONTENT","inode":"7ba550d8-cfa6-459d-9838-2cb28d367f33","archived":false,"titleDotcmsInternal":"Test button","host":"8a7d5e23-da1e-420a-b4f0-471e7da8ea2d","working":true,"locked":false,"stInode":"ac4c1b1b-6911-414b-90d3-2b4e713e039b","contentType":"Button","live":true,"owner":"dotcms.org.1","identifier":"191db649cfbb117995ce9d4c7cc0923c","languageId":1,"__icon__":"contentIcon","url":"/content.8409808a-6fea-4fd3-9b51-2f84e89d3024","target":"_blank","titleImage":"TITLE_IMAGE_NOT_FOUND","modUserName":"Admin User","hasLiveVersion":true,"folder":"SYSTEM_FOLDER","hasTitleImage":false,"sortOrder":0,"modUser":"dotcms.org.1"}}} Button: $content.linkText

It shows the "Button:" but the fields aren't filled yet, and that's because they aren't in the $item object as you can see in the first part.

5. And a last thing: I noticed that when updating the content and/or velocity that the page isn't always updated and requires a cache flush of republish. Is this a known issue?

Kind regards,

Xander


Op maandag 17 oktober 2022 om 17:12:06 UTC+2 schreef Fishsmith:

Fishsmith

unread,
Oct 18, 2022, 12:16:16 PM10/18/22
to dotCMS User Group
Xander,
Can you confirm:
  1.  that the field variable names are correct in your content type (e.g. linkUrl and linkText)
  2. what version of dotCMS are you running

For #5 change the cache setting on the page. I believe we ship with 1 hour cache as the default (Not 100% sure about this) 

Will Ezell

unread,
Oct 18, 2022, 12:41:49 PM10/18/22
to dot...@googlegroups.com
Also Xander, take a look at how our blogs are rendered on our demo site.  They use the new Block Editor.  You can see the Blog detail page calls:

            $!{URLMapContent.get("blogContent").toHtml('/application/vtl/blog/blocks/')}

which then picks up the /application/vtl/blog/blocks/dotContent.vtl in that folder which you can see here:


--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b7c0689f-164b-4b1e-b572-18a78980cf70n%40googlegroups.com.


--



382 NE 191st St #92150
Miami, Florida 33179-3899
Main: 
305-900-2001 | Direct: 978.294.9429

Xander Steinmann

unread,
Oct 19, 2022, 3:08:06 AM10/19/22
to dot...@googlegroups.com
Hi Jason, Will,

I'm using dotCMS 22.09 - September 13, 2022. I think the issue that I've ran into is a caching issue. If you look at the JSON that is in my output then you won't see the linkText or linkUrl in there (note: those fields were empty when I first created the button). When I update the Button content then no fields are updated in the page/block (even in the edit mode), but when I remove and re-add the button to the block then everything is updated and works.

I've been able to reproduce it on the demo site. When you look at https://demo.dotcms.com/dotAdmin/#/edit-page/content?url=%2Fblog%2Fpost%2Ffrench-polynesia-everything-you-need-to-know then you'll see some products at the bottom of the page. If you edit any of these products (for instance Patagonias shorts) then it won't be updated on the French Polynesia page. If this is new for you then I'll create a bug report.

Kind regards,

Xander


You received this message because you are subscribed to a topic in the Google Groups "dotCMS User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dotcms/UUr3APDpcEs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dotcms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAPL0VyExuPh-_ZpKuWSkYd9oRokUOKD4q4ycJ%2BfZmG%2Bcstsmyg%40mail.gmail.com.

Will Ezell

unread,
Oct 19, 2022, 9:28:54 AM10/19/22
to dot...@googlegroups.com
Xander:

Is it this issue?  https://github.com/dotCMS/core/issues/22857   If so, a fix is going to be available here shortly.  If this is not the problem, it would be great if you entered a new github issue.  Thanks!

Xander Steinmann

unread,
Oct 19, 2022, 10:22:56 AM10/19/22
to dot...@googlegroups.com
Hi Will,

Yes, I believe so. I will wait for the fix before continuing my testing.

Kind regards,

Xander

Will Ezell

unread,
Oct 26, 2022, 1:08:11 PM10/26/22
to dot...@googlegroups.com
dotCMS 22.10 just went GA and is a recommended upgrade if you are currently using the block editor.  It has the nice capability of allowing you to convert a legacy WYSIWYG field to a Block Editor field.  It won't go back and re-write the content, it will just show the block editor control when adding/editing content, and will save the results as JSON.

From a front end perspective, you can check if the field is JSON and if so, render the block.  Or if it is html, just spit it out normally.

For more information see the changelogs: https://www.dotcms.com/docs/latest/changelogs#release-22.10

Xander Steinmann

unread,
Nov 8, 2022, 6:16:32 AM11/8/22
to dotCMS User Group
Hi Will,

Can you confirm that the fix is available in 22.10 and/or the current demo.dotcms.com site? Because I've tried 22.11_SNAPSHOT and I still have the issue that the linked content isn't updated.

Kind regards,

Xander

Op woensdag 26 oktober 2022 om 19:08:11 UTC+2 schreef Will Ezell:

Will Ezell

unread,
Nov 8, 2022, 10:21:14 AM11/8/22
to dot...@googlegroups.com
Xander:

Uggh, looks like the merge was missed in the final cut of 22.10 - we are working out next steps, whether it will be in 22.10.1 or 22.11.

We will let you know, sorry about that.


Will



--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages