view is 'missing' orchard header

Topics: Customizing Orchard, Writing modules
Aug 27, 2015 at 9:59 AM
I have a view that has an HTML.ActionLink on it, and when clicked it calls a method in the controller, which returns an action result, calling up a new view. It looked great, until I realised that the new view appears to be 'missing' the standard Orchard header and footers...

Anyone seen anything like this before?

First view - represents a session, which has a list of materials attached to it. That list is made up of links to details about those materials. This view shows the expected Orchard header and footer, so I could get into the dashboard, sign in/out etc
        <th>Session Name</th>
        <th>Start Date</th>
        <th>End Date</th>
        <td>@String.Format("{0:dd-MMM-yyyy HH:mm}", Model.StartDate)</td>
        <td>@String.Format("{0:dd-MMM-yyyy HH:mm}", Model.EndDate)</td>

    @foreach (var material in Model.Materials)
        string title = material.Title;
            @Html.ActionLink(title, "Details",  new { controller="Material", area = "Session", materialId = material.Id },null)
Second View - shows material information, but 'loses' orchard's headers/footers, the only way back is the browser back button
@using Orchard.ContentManagement
@model Session.ViewModels.MaterialViewModel

<h2>@Model.Title </h2>
using Material.Models;
using Orchard.Data;
using Session.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Session.Controllers
    public class MaterialController : Controller
        private readonly IRepository<MaterialPartRecord> _materialRepository;

        public MaterialController(IRepository<MaterialPartRecord> materialRepository)
            _materialRepository = materialRepository;

        // GET: Material
        [HttpGet ]
        public ActionResult Details(int materialId)
            return MaterialDetails(() => _materialRepository.Get(materialId));

        private ActionResult MaterialDetails (Func<MaterialPartRecord > getMaterial)
            var material = getMaterial();
            if (material== null)
                return HttpNotFound();

            var viewModel = new MaterialViewModel { Title= material.Title , Description=material.Description , 
                MaterialID=material.Id  };

            return View("Details", viewModel);

I'm about ready to tear my hair out with this - help????
Aug 27, 2015 at 10:08 AM
The solution is simple, yet elegant :)

Decorate your controller (or a controller action) with the 'Themed' attribute to place your view in the 'Content' zone of Orchard (so it uses your theme, layout etc.)
public class MaterialController : Controller
    private readonly IRepository<MaterialPartRecord> _materialRepository;

    // rest of code

Marked as answer by eRuth on 8/27/2015 at 3:16 AM
Aug 27, 2015 at 10:17 AM
Thank you - I didn't know it would be something that simple - I'll try not to forget that one in the future!
Sep 1, 2015 at 8:44 AM
Then also remember the [Admin] attribute, which you can use for admin actions. (if you name your controller AdminController, by convention the [Admin] isn't necessary, but if you name it other than that it is necessary)