9

After played the DXA example a couple of times, I want to create my own DXA site from scratch, but couldn't find too much guide here.

What I want: a new MVC portal, with only one home page, which will display a list of News, with an navigation bar.

So far what I did are:

  • Created a new publication 120 MyBlog, which inherited from 100 Master

  • Created a new schema News, with only 2 fields: title & content.

  • Installed DXA Visual Studio Templates and create a new DXA site project;

  • Inside the DXA site project, added a new Area with name MyBlog

  • Under MyBlog, added a new folder Models with a class News, which map to the News schema;

After that I'm a bit lost.

Inside the MVC project:

  • Should I create my own controller? Inside the DXA example site, I see only one controller for Admin.

  • If I add controller, should I add inside the Area or outside the Area?

  • By default it will generate some folders under the Views folder: Entity, Page, Shared. How can we use them?

  • After I create the project based on the DXA Site Project, I notice it is a class library type instead of a web site type, which made the cshtml file doesn't work and there is no way to run it. Is it normal?

Inside the publication:

  • The DXA example site contains a list of Page Types inside the SG _Page Types, what are they used for? Do we need to copy them to other DXA sites?

Other confuse for the DXA Example site physical folder: it contains a lot of cshtml file under folder Areas\Core\Views, do we need to keep them for other DXA sites or we can just remove them and build our own? If we build our own, how can we link them to the Tridion side page?

Any comments are appreciated.

Thanks.

  • 1
    Not exactly what you're asking for... but this could be a good start: community.sdl.com/products-solutions/solutions/… – Nuno Linhares Sep 12 '16 at 22:23
  • I do read this doc before, which helped me create my own view / data model based on the DXA Example site. After that I want to establish a clean solution from scratch, without carry the demo schema / page from Dxa example, which not match our business needs. That's the point I'm not sure how to start. – qchen01 Sep 13 '16 at 19:53
  • Gotcha. No idea either :) maybe some of the answers below can help. – Nuno Linhares Sep 13 '16 at 22:24
  • @NunoLinhares Your link is 404 – Dominic Cronin Jun 9 '18 at 9:16
6

Next to the valuable answers from others, here as my answers/comments to your questions:

  • Created a new publication 120 MyBlog, which inherited from 100 Master

    • Consider keeping a Publication representing a Site Type in your BluePrint (like the example 110 DXA Site Type Publication); the Publication(s) representing Site(s) should be children of the Publication representing a Site Type. This facilitates use of the Site Wizard.
  • Installed DXA Visual Studio Templates and create a new DXA site project;

    • Note that the "DXA Visual Studio Templates" are not official part of the DXA distribution and are probably not up-to-date with the latest version of DXA; it may be better to use the DxaWebApp.sln as starting point.
  • Should I create my own controller? Inside the DXA example site, I see only one controller for Admin.

    • The DXA Framework provides default Page, Region, Entity, List and Navigation Controllers. You can get quite far without your own Controllers.
  • If I add controller, should I add inside the Area or outside the Area?

    • It doesn't really matter where you create the Controller class; ASP.NET MVC will find it anyways.
  • By default it will generate some folders under the Views folder: Entity, Page, Shared. How can we use them?

    • This is how ASP.NET MVC View resolving works; it searches for Views in a folder named after the Controller (hence Page(Controller), Region(Controller) and Entity(Controller)). If it can't find Controller-specific Views there, it will look in Shared.
  • After I create the project based on the DXA Site Project, I notice it is a class library type instead of a web site type, which made the cshtml file doesn't work and there is no way to run it. Is it normal?

    • No, that's not normal. See the official DxaWebApp.sln.
  • The DXA example site contains a list of Page Types inside the SG _Page Types, what are they used for? Do we need to copy them to other DXA sites?

    • Page Types (and Content Types) are XPM concepts; they are used to make it possible/easy to create new Pages and Component Presentations in XPM. They are associated with Schemas, so if you're creating your own set of Schemas, it's not likely that you can reuse DXA's example Page/Content Type (but you may want to reuse your own in several Sites, so that's one reason to create your own Site Type Publication).
  • Other confuse for the DXA Example site physical folder: it contains a lot of cshtml file under folder Areas\Core\Views, do we need to keep them for other DXA sites or we can just remove them and build our own?

    • Those Views are part of the "Core Module" which contains View Models and Views used in the DXA Example Site and which are associated with the DXA Core Schemas. Again, if you're going to create your own set of Schemas, you will also have your own set of View Models and Views and hence you won't need this "Core Module"; you can safely remove the Views in Area\Core\Views in that case. In DXA 1.6, the separation of this "Core Module" will be improved.
  • If we build our own, how can we link them to the Tridion side page?

    • Your Page uses a Page Template and this Page Template is associated with a Page View (through its metadata). If you create your own Page View you should also create your own associated Page Template and use that in your Pages.
  • DXA Visual Studio Templates's DXA Site project type is a class library. Since it is not official part of DXA distribution, I delete this solution and copy DxaWebApp.sln as start point. – qchen01 Sep 13 '16 at 19:45
  • I also found Sdl.Dxa.Framework.Web8 in Nuget, it can be installed in a normal ASP.NET MVC project. But it reference the old Tridion DLL and bring the assembly load error. – qchen01 Sep 13 '16 at 19:50
  • The Sdl.Dxa.Framework.Web8 NuGet package (which is used by the DxaWebApp.sln) uses the SDL Web 8 CIL and should not cause assembly load errors. – Rick Pannekoek Sep 13 '16 at 20:07
5

You don't need to add a new Controller, unless you want to add some added functionality that DXA doesn't provide.

Have you followed my Quick Start Guide here? You can simply ignore the mapping to my Web 8 Discovery and use your own instead Discovery Service. Also, you obviously do not need to download the Web Application from Azure as you are already working with your own.

The document does describe how you should set up the module, create the model and view and, just as important, the folder structure you need to apply. If you switch the example I used to match your own then you should be good to extend DXA.

Please let me know if I am off the mark here and I will try to help you further.

  • Quick Start Guide asks for user id and password, what is the process to get access to SDL community? may be a very basic question :( – user1453602 Mar 27 '17 at 13:32
3

There are different ways to implement DXA custom solution.

CMS

  • Create a new folder of desired name in Modules folder. eg MyBlog
  • Replicate folder structure from admin to site manager from core.
  • In Admin folder create a component from Module Configuration schema. provide mandatory fields information.
  • Create your content schema and templates in editor folder.
  • set template metadata, set entity view with MyBlog:news. here news is your view from Area(discussed below)
  • above template will be handled by default entity controller, so you dont need any controller.

    • Create page using exisitng core Page template, component of your editorial schema with above template and publish the page
    • also publish _system/Publish setting page

CDS:

following can be done in DXA Project or above Templates, but makes sure all following SdL.Web.* dlls reference are latest as per per your current DXA version with copy local false.

  • Create a new Area with name "MyBlog"
  • Create Views folder as per MVC specs
  • create new folder Entity in the Views folder
  • Create a view model class and map the fields of your schema. refer any core view model
  • add new view in the above Entity folder with @model viewModel
  • in AreaRegisteration register your view RegisterViewModel("article", typeof(MyBlogArticle));
  • build and deploy the module on website resolve any error (if i missed any step) Reference

Please raise separate question if you need any other details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.