AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
New retail controller and views with layout
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
I tried to create a new retail controller with a simple Test action and view using the existing _Base.layout.cshtml as the layout. It failed because of the whole CMS/Outer/Inner template system.
Let's say I create a new controller called GalleryController with an action ViewPhoto, and I want it to use the default /Gallery/ViewPhoto/{id} route, what is the easiest way to wire up the controller and views so they have the same layout as the rest of the website?
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
Note that adding new controllers and views works just fine in the admin. It is only on the retail side where I am having difficulty. If I set the Layout=null it works fine (it doesn't have the header/nav/footer/etc), so I'm 99.9% sure it is related to CMS/Outer/Inner template system.
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
Oh my!! After digging through the code I'm not even sure it is possible to use the existing base layout with custom controllers and views. My controller inherits from AbleController, which has a LayoutDataAttribute attached to it. That attribute that injects layout details (Outer/Inner template, Theme, DisplayUrl, etc) based on whether the controller is named "Webpage", "Product", or "Category" and the action called is "Index". Obviously, a new controller name is none of those, and my actions are not "Index".
At this point I feel stuck. I can create all the code to administer our photo gallery, but how to display it within the site template eludes me. I can create a separate base layout, but with all of the content boards/widgets/HTML Snippets, I'm not sure how that would work.
|
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System Joined: 10/11/2018(UTC) Posts: 110
Thanks: 19 times Was thanked: 18 time(s) in 18 post(s)
|
Quote:At this point I feel stuck. I can create all the code to administer our photo gallery, but how to display it within the site template eludes me. I can create a separate base layout, but with all of the content boards/widgets/HTML Snippets, I'm not sure how that would work. You can create a widget using your custom controller, views, etc., and then drag and drop that widget to a CMS page e.g. Category, content, or the product page. You can also create a new blank content page from the merchant admin and then drag and drop your custom widget onto it.
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
To make sure I am understanding... I would create a Content page for a list view and drop a GalleryList widget in there. Then create a Content page for individual gallery photo and drop a GalleryPhoto widget in there? Am I going to be able to create custom routes or static urls and have it all still work?
|
|
|
|
Rank: Advanced Member
Groups: Admin, Developers, Registered, HelpDesk, Authorized User Joined: 10/5/2018(UTC) Posts: 704
Thanks: 5 times Was thanked: 113 time(s) in 112 post(s)
|
Quote: I would create a Content page for a list view and drop a GalleryList widget in there. Then create a Content page for individual gallery photo and drop a GalleryPhoto widget in there? Yes, you are correct. Quote:Am I going to be able to create custom routes or static urls and have it all still work? Yes, you can assign your custom URL to a content page you will create. Hope it helps!
|
|
|
|
AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
New retail controller and views with layout
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close