logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
Joe Payne2  
#1 Posted : Thursday, February 11, 2021 9:47:23 AM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
I need to create some custom sections to the admin dashboard. But I want to keep these changes in separate classes and folders from the base site files to minimize the impact on future updates.

I've set up a Custom folder under /Areas/Admin/Controllers/ and added a DashboardController.cs file. The original is modified to be 'partial'. Pretty sure this'll work for the controller.

Now I want to set up a Custom folder for /Areas/Admin/Views/. But Visual Studio isn't resolving the path to my custom views folder.

How would I add that /Custom/ folder to the MVC search path of the admin area? It looks like this might be done in the /Areas/Admin/AdminAreaRegistration.cs but that MVC routing stuff is still greek to me.

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

mazhar  
#2 Posted : Thursday, February 11, 2021 10:02:25 AM(UTC)
mazhar

Rank: Administration

Groups: Admin, Administrators, HelpDesk, System, Authorized User, Developers, Registered
Joined: 10/5/2018(UTC)
Posts: 175

Thanks: 8 times
Was thanked: 17 time(s) in 15 post(s)
What you are doing should work as you expected. I think it may be the namespace constraint creating an issue for you. If you look at the AdminAreaRegisteration.cs class and the very last route entry. Its the default route and it expects the controllers to be in AbleCommerce.Areas.Admin.Controllers namespace. Make sure to adjust AbleCommerce.Areas.Admin.Controllers.Custom namespace which Visual Studio may have created automatically when you added controller under /Controllers/Custom folder. Also, make sure that your Controller is extending AbleAdminController. Lastly, make sure your view is not setting the Layout to null, just remove the Layout statement and it will be set automatically.
thanks 1 user thanked mazhar for this useful post.
Joe Payne2 on 2/11/2021(UTC)
Joe Payne2  
#3 Posted : Thursday, February 11, 2021 10:39:45 AM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
Ooooooh ok.

Huge help Mazhar, thank you!
Joe Payne2  
#4 Posted : Thursday, February 11, 2021 10:46:06 AM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
hold on a sec.

I'm not making a new controller. I just created another public partial void DashboardController() and set the original to be a partial class.

Code:

namespace AbleCommerce.Areas.Admin.Controllers
{
    public partial class DashboardController 
    {
        private string _baseDocumentPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Areas\\Admin\\DocumentCenter\\Documents");

        [ChildActionOnly]
        public ActionResult CorporateDocuments()
        {
            CorporateDocumentsModel model = new CorporateDocumentsModel();
            model.DocumentData = GetDocuments();

            return PartialView(model);
        }
    }
}

Users browsing this topic
Guest
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.