I need to add a plain text page to the site, but it needs to use the same overall template as the shop pages.
I tried adding a DocType and a Template and set the layout to the "master.cshtml" file in the Bazaar theme but I get an error:
Cannot cast source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to view model type Merchello.Bazaar.Models.ViewModels.MasterModel.
What is the correct way to add extra content types to Bazaar?
Cannot cast source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to view model type Merchello.Bazaar.Models.ViewModels.MasterModel.
Create a DocType (e.g. NormalContentPage), I created mine under BazaarMaster. Don't create a template. Allow it to be created where necessary, e.g. under BazaarStore.
In Visual Studio, create a ViewModel called NormalContentPage:
public class NormalContentPage : MasterModel
{
public NormalContentPage(IPublishedContent content) : base(content)
{
}
public string PageContent {
get
{
return Content.GetPropertyValue<string>("pageContent");
}
}
}
Create a Controller called NormalContentPageController:
public override ActionResult Index(RenderModel model)
{
var viewModel = new NormalContentPage(model.Content) {CurrentCustomer = CurrentCustomer};
return View(viewModel.ThemeViewPath("normalContentPage"), viewModel);
}
Create a view called NormalContentPage.cshtml. I created mine in my Bazaar Theme views folder:
I'm looking to do something similar with the bazaar, where i create my own Views outside of the app_plugin themes folder so i can fit the store in with the rest of the site, i added the bazaar source into my solution but when i try to use:
Cannot cast source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to view model type Merchello.Bazaar.Models.ViewModels.ProductCollectionModel
In a new class project, I create a file ContactFormSurfaceController.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Umbraco.Web.Mvc;
using RedTechNet.CittdelSoleStore.Models;
namespace RedTechNet.CittdelSoleStore.Controllers
{
public class ContactFormController : SurfaceController
{
public ActionResult Contact()
{
return PartialView("_ContactForm", new ContactFormViewModel());
}
}
}
So in view, you need to call the surface controller action:
Still can't get a normal text page working using any of the above methods; it's apparent we don't know as much as we should.
Would someone be so kind as to zip up their successful process for us to examine; with detail on physical location and how to reference the new model/controller? We're just looking for a basic content page (RTE alias pageContent.)
Add a normal text page to Bazaar theme
I need to add a plain text page to the site, but it needs to use the same overall template as the shop pages.
I tried adding a DocType and a Template and set the layout to the "master.cshtml" file in the Bazaar theme but I get an error:
Cannot cast source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to view model type Merchello.Bazaar.Models.ViewModels.MasterModel.
What is the correct way to add extra content types to Bazaar?
The view model of Bazaar and Umbraco are different.
Read here for you help:
our.umbraco.org/projects/collaboration/merchello/merchello/67120-add-umbraco-pages-to-merchello-bazaar-navigation#comment-223349
I created a simple page like this:
And I get this error:
:-(
Where Have you created the page? In Umbraco template?
I created a DocType under BazaarMaster and the template in Templates (Views folder in VS project).
Here an example of a page.
So in the page you can use all Umbraco API and you can access to Merchello data.
http://merchello.com/documentation/getting-started/how-to/Single-Product-Page
No ... still can't add a "normal" text page and make it use the Bazaar layout :-(
Rusty - what was that clever way you showed me yesterday?!
OK, managed it with Rusty's help:
Create a DocType (e.g. NormalContentPage), I created mine under BazaarMaster. Don't create a template. Allow it to be created where necessary, e.g. under BazaarStore.
In Visual Studio, create a ViewModel called NormalContentPage:
Create a Controller called NormalContentPageController:
Create a view called NormalContentPage.cshtml. I created mine in my Bazaar Theme views folder:
That should be everything. Create a node / page in Umbraco and it should use the same template as your Bazaar site.
There are probably other ways to achieve the same result, but it worked fine for my limited needs (just simple, simple text pages).
Hoping someone can lend some guidance here. Followed Gordon's solution above, but getting the error:
xxx.Controllers.NormalContentPageController.Index(Umbraco.Web.Models.RenderModel)': no suitable method found to override
What are we missing? TIA
Hi,
I've added a new view and I call it by a surface method. The view is under umbraco standard folder view.
I'm looking to do something similar with the bazaar, where i create my own Views outside of the app_plugin themes folder so i can fit the store in with the rest of the site, i added the bazaar source into my solution but when i try to use:
I get the following error:
Has anyone else tried to do this and succeeded?
Thanks, Owen
Use a partial View called with a surface method and with a View under a Bazaar
Thanks for the response Biagio, do you have an exmaple of what you mean by surface method?
In a new class project, I create a file ContactFormSurfaceController.cs:
So in view, you need to call the surface controller action:
Read here for more info:
https://our.umbraco.org/documentation/reference/routing/surface-controllers
http://creativewebspecialist.co.uk/2013/07/22/umbraco-mvc-what-on-earth-is-a-surface-controller/
@Biagio, thank you for confirming - that is the approach i took on friday to try and get this going.
Still can't get a normal text page working using any of the above methods; it's apparent we don't know as much as we should.
Would someone be so kind as to zip up their successful process for us to examine; with detail on physical location and how to reference the new model/controller? We're just looking for a basic content page (RTE alias pageContent.)
Thanks so much in advance.
Which error do you have?
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.