I see. If you want to add a new child view, you'll...
# suitecommerce
s
I see. If you want to add a new child view, you'll need to step through your site's rendered source and find the
data-view
attribute for the view you want to add to
c
@Steve Goldberg If I want to add extension in home page after banner Images how can we achieve. we don't have childviews in the home page.How can we add child views?
l
c
Yes but we should have at least one child view to bind a child view as a extension but in the home page there are no data views are there to bind an extension
l
message has been deleted
i saw our home page have data-view
s
add a data-view to your template?
c
@Steve Goldberg I have tried to add a custom data-view property and tried to bind my extension to that view.still I'm unable to see my extension there. If I add my extension to standard data-views and data-cms-area then I'm able to see my extension.
s
OK, I'm not precisely sure how the method works. The home view doesn't have any child view instances, so it's entirely possible that it is not set up to accept them. You may need to extend it to add that property
c
Thanks @Steve Goldberg Is there any article to extend and add the property?
c
Can we extend and add the property in extension rather then in source?
s
yah
Typically you shouldn't
But in this situation I don't see a workaround
c
Ok thanks Steve for the information
s
OK I've just tested it and adding
<div data-view="Home.View"></div>
to the home template and then doing something like
Layout.addChildView('Home.View', function () {return new SimpleView()});
works just fine
c
@Steve Goldberg I have added the same but I'm seeing empty div after adding my extension. Here is the snippet that I was trying to add. layout.addChildView('Home.View', function() { return new FeaturedProductsView({ container: container }); });
s
What version are you using? Also, I'm assuming that you've tested your view in other containers, eg,
Header
c
I'm using SCA 2019.1 version.I'm testing it in home page. I have deployed as well but I'm unable to see the changes.
The same line working for CMS area
ex:/*layout.addChildView('cms:home_cms_area_4', function() { return new FeaturedProductsView({ container: container }); });*/
s
OK alternative tactic
Can you do:
Copy code
layout.registerView('Featured.Products.View', function() {
   return new FeaturedProductsView({ container: container });
})
c
Thanks Steve I will try this and will let you know
s
and then in your template add a div like this:
<div data-view="Featured.Products.View"></div>
c
Sure will do this.
s
I should also point out that if you are writing featured product functionality, I'd strongly recommend using our SuiteCommerce extension for it: http://suiteapp.com/SuiteCommerce-Featured-Product
c
No I'm just testing the cases.
@Steve Goldberg finally registerview worked. Thanks @Steve Goldberg