Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gordon Saxby 1347 posts 1608 karma points
    Jul 19, 2015 @ 21:10
    Gordon Saxby
    0

    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?

  • Biagio Paruolo 1494 posts 1635 karma points c-trib
    Jul 20, 2015 @ 10:19
    Biagio Paruolo
    0

    The view model of Bazaar and Umbraco are different.

    inherits Umbraco.Web.Mvc.UmbracoViewPage<MasterModel>
    @using Merchello.Bazaar
    @using Merchello.Bazaar.Models.ViewModels
    

    Read here for you help:

    our.umbraco.org/projects/collaboration/merchello/merchello/67120-add-umbraco-pages-to-merchello-bazaar-navigation#comment-223349

  • Gordon Saxby 1347 posts 1608 karma points
    Jul 20, 2015 @ 16:29
    Gordon Saxby
    0

    I created a simple page like this:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<MasterModel>
    @using Merchello.Bazaar
    @using Merchello.Bazaar.Models.ViewModels
    
    @{
    }
        <p>hello</p>
    

    And I get this error:

    Cannot cast source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to view model type Merchello.Bazaar.Models.ViewModels.MasterModel.
    

    :-(

  • Biagio Paruolo 1494 posts 1635 karma points c-trib
    Jul 20, 2015 @ 17:50
    Biagio Paruolo
    0

    Where Have you created the page? In Umbraco template?

  • Gordon Saxby 1347 posts 1608 karma points
    Jul 20, 2015 @ 18:05
    Gordon Saxby
    0

    I created a DocType under BazaarMaster and the template in Templates (Views folder in VS project).

  • Biagio Paruolo 1494 posts 1635 karma points c-trib
    Jul 20, 2015 @ 18:43
    Biagio Paruolo
    0

    Here an example of a page.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using Umbraco.Core
    @using Merchello.Web
    

    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

  • Gordon Saxby 1347 posts 1608 karma points
    Jul 22, 2015 @ 17:54
    Gordon Saxby
    0

    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?!

  • Gordon Saxby 1347 posts 1608 karma points
    Jul 23, 2015 @ 16:47
    Gordon Saxby
    1

    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:

    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:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<path to .NormalContentPage>
    @{
        Layout = "Master.cshtml";
    }
    
    <div class="row">
        <div class="col-md-12">
            <h1>@Model.Name</h1>
            @Html.Raw(Model.PageContent)
        </div>
    </div>
    

    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).

  • J. B. 15 posts 88 karma points
    Nov 17, 2015 @ 17:42
    J. B.
    0

    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

  • Biagio Paruolo 1494 posts 1635 karma points c-trib
    Nov 17, 2015 @ 20:25
    Biagio Paruolo
    0

    Hi,

    I've added a new view and I call it by a surface method. The view is under umbraco standard folder view.

  • Owen Pattison 18 posts 39 karma points
    Dec 04, 2015 @ 13:21
    Owen Pattison
    0

    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:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<Merchello.Bazaar.Models.ViewModels.ProductCollectionModel>
    
    @{
        Layout = "Common.cshtml";
    }
    

    I get the following error:

    Cannot cast source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to view model type Merchello.Bazaar.Models.ViewModels.ProductCollectionModel
    

    Has anyone else tried to do this and succeeded?

    Thanks, Owen

  • Biagio Paruolo 1494 posts 1635 karma points c-trib
    Dec 04, 2015 @ 13:34
    Biagio Paruolo
    0

    Use a partial View called with a surface method and with a View under a Bazaar

  • Owen Pattison 18 posts 39 karma points
    Dec 04, 2015 @ 13:46
    Owen Pattison
    0

    Thanks for the response Biagio, do you have an exmaple of what you mean by surface method?

  • Biagio Paruolo 1494 posts 1635 karma points c-trib
    Dec 07, 2015 @ 09:08
    Biagio Paruolo
    0

    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:

    @Html.Action("Contact", "ContactForm")
    

    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/

  • Owen Pattison 18 posts 39 karma points
    Dec 07, 2015 @ 09:54
    Owen Pattison
    0

    @Biagio, thank you for confirming - that is the approach i took on friday to try and get this going.

  • J. B. 15 posts 88 karma points
    Dec 16, 2015 @ 15:55
    J. B.
    0

    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.

  • Biagio Paruolo 1494 posts 1635 karma points c-trib
    Dec 18, 2015 @ 09:13
    Biagio Paruolo
    0

    Which error do you have?

  • 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.

Please Sign in or register to post replies