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.
|
|
|
|
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.
|
1 user thanked mazhar for this useful post.
|
|
|
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!
|
|
|
|
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);
}
}
}
|
|
|
|
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