Hey can anyone help point me to documentation or e...
# suitecommerce
b
Hey can anyone help point me to documentation or explain to me the correct way to add a view to the homepage in 20.2? I had an extension that was working perfectly fine in 20.1 and I was adding the view like this :
Copy code
_.extend(HomeView.prototype, {
      childViews: {
        'MyCustomView': function () {
          return new MyCustomView({
            application: this.options.application
          });
        }
      }
    });
However now the site won't load with the extension doing this. So I've been trying to do this with the extensibility api but I can't find the right way to do this in the documentation. For other extensions on the PDP its pretty clear and I can get it to work no issues using
Copy code
var pdp = container.getComponent('PDP');
          pdp.addChildView(
I thought possibly I would do this with the
Layout
component and
layout.registerView
but that doesn't seem to work for me either I just get a blank homepage. The only error I get in the console is
DevTools failed to load SourceMap: Could not load content for <https://mydomain.com/scs/cms.js.map>
which seems to be there whenever I try to run locally even when I'm not including this homepage extension.
s
did you add the <data-view=MyCustomView> in your theme?
If not, add it and then deploy and then in extension gulp fetch first
s
The homepage is very temporary in our base theme. Accordingly, it doesn't have any placeholders in it for child views. You will need to do as Roeg suggests and add in new placeholders.
f
wooow, adding a child view extending prototype is a bad practice
you should be using the layoutComponent
k
You can more than likely use the layout component add your childview to the home page.
s
Yes use the layout component, but one of the important things to keep in mind is that there are no placeholders in the base theme homepage template
👍 1
(or there wasn't last time I checked, we could have added in some recently)
So, as Roeg said, you need to markup some areas with `data-view`s
b
Yes, layoutComponent worked with the data-view added to the tpl.. was having issues because of a syntax error I had an event setup on the view
Copy code
events: {
        'click id="mlu-find"': 'searchItems'
that was missing the `[ ]`around the id= part