Job Details

In order to do this you will need to make changes in the following places:

  • ./Views/Job/Details.cshtml
  • ./Models/Pages/JobPage.cs
  • ./Controllers/JobController.cs
  • ./CouchDBManager.cs
  1. Create your cshtml file with the static content in it

    At the time of writing our designer is Russ, you will need to get the static HTML design for your new page from him. Once you have this you will need to cut all of the content between the <main></main> tags (including the <main> tags) and put them in a new file located in the ./Views/Main/ folder, the naming scheme is PageName.cshtml with each word in the filename having a capital letter.

  2. Create your model

    Next you will need to create a model that will contain all of the parts of the page that can be modified a good example of a basic model can be found in ./Models/Pages/ArchivePage.cs.
    You need to create regions* that will show up in the manager view when you go to edit the page, these should be stored in ./Models/Regions/<PageName>/ with the filename in this format <PageName><RegionName>.cs again with each word having a capital letter. Each region is made up of fields these fields will have values put into them later from the manager view.

  3. Add your model to your cshtml page

    Next you will need to add a reference to your model in your cshtml file, this is done by putting @model <MyModel> at the top of your file, now you can reference the values stored in the fields using @Model.<regionName>.<fieldName>, this will render them into your HTML before it is sent to the client. You should aim to make as much of the page editable this way as possible. If you are using a MarkdownField or HtmlField then you will need to put your field inside Html.Raw() otherwise the code will be rendered as plaintext.

  4. Register your page with Piranha

    In ./Startup.cs you will need to add .AddType(typeof(Models.Pages.)) into var pageTypeBuilder = new Piranha.AttributeBuilder.PageTypeBuilder(api).
    The final code change that you need is in ./Controllers/MainController.cs, here you will need to add your route, to do this you should copy one of the existing routes**.

  5. Create your page in the manager view

    Finally you need to go to the manager view, you will need to login to access it. Once you are logged in you will need go to the pages tab and click Add (located on the right) your new page should show up as an option in the dropdown that appears, from here you can populate your fields and then you'll need to press publish (click the arrow next to the save button) and then you're done!

  6. Make yourself a coffee

    You've earned it ☕


*at the time of writing (01/08/2019) there is a known bug in Piranha where regions must have more than one field for them to be displayed
**It is cruicial that the route in MainController.cs and the PageTypeRoute in your model match as this is how the controller gets the page

Documented by.. You know who I am and by you might know who I am