Page Templates with default widgets

Yowaraj Chhetri asked on December 21, 2020 04:20

Hi All,

My use case is as follows:

I got 3 page types with pagebuilder enabled, where we put widgets. I got 1 different page types "Article" which is pagebuilder enabled but should use templates "Article Template". This is a custom template with image widget placed as default. So whenever an Article page is created we use this template which has image widget already as part of the template.

However, this image widgets displays image which it gets from the article page unlike getting from the widgets properties. This may not work as data will get lost as the image widgets is dependent to article page for data.

Is there a work around to this, where the Article template has an image widgets whose image coming from article page and also its widgets properties can be modified too.

Thanks in advance

Recent Answers


Brenden Kehren answered on December 21, 2020 04:47

If you have Article specific structured data, that can be part of your view. You can so enable page builder on that structured page data as well if you wish.

0 votesVote for this answer Mark as a Correct answer

Yowaraj Chhetri answered on December 21, 2020 05:50 (last edited on December 21, 2020 05:50)

Hi Brenden,

Thank you for the reply, but I did not get you properly.

Article Page has a structured data as well, bu has no views of its own. Article page has Article template.

As article page is page builder enabled we can put widgets to it. However, the image widget which is a part of article template should get data (i,e image) from the article page structure content. Furthermore, this image widgets has its own widget properties, which can be modifiable too.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on December 21, 2020 06:39

Why would you force an editor to place a widget to display structured article data on it for every new article? Use the properties of the article that are already populated with custom widgets which gather those values

0 votesVote for this answer Mark as a Correct answer

Yowaraj Chhetri answered on December 21, 2020 06:55 (last edited on December 21, 2020 06:57)

Image widget has got few widgets properties including imagePath. This is a generic widget and can be placed to any page content. But when applied to article template it gets the imagePath value from respective article page type field "Image".

That means when we create new article page with Article Template, the image widget will get image from article page and put it into imagePath property and with other widgets property content editor can modify that.

I have reached my limitation thinking how to achieve this as this is a difficult use case. The solution I was thinking is in the image widget controller, check if its article page, then properties.imagePath is the image from article page image field. but then this will not work, as user might use image widget elsewheere on the article page and should get image from imagePath of the widgets property.

This has to happen only to the image widget placed to the custom article template.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.