is this possible?

Topics: Customizing Orchard, General
Apr 28 at 4:49 PM
I have a page that is made up of three shapes (razor views). One with a drop down list and a 'Go' link, another containing a title and the third some static text.

What I'd like to do is change a value in the drop down, click the link and change the text in the title view, but the static text stays as is.

On first load, the driver calls a service to get the data to fill the drop down and work out the title text, then returns a combined shape to put them all together on the page
    protected override DriverResult Display(SessionHomePagePart part, string displayType, dynamic shapeHelper)
        {
            var sessionTitle = _sessionService.GetCurrentUserSession(_workContext.CurrentUser.UserName);
            var title = string.Format("{0} - {1}", sessionTitle.SessionTitle, sessionTitle.SessionId);
            var listSessions = _sessionService.GetSessionList(_workContext.CurrentUser.UserName);
            return Combined(
                ContentShape("Parts_SessionHomePagePart", () => shapeHelper.Parts_SessionHomePagePart(SessionHomePagePart: part)),
                ContentShape ("Parts_SessionHomePagePart_Title", ()=>shapeHelper.Parts_SessionHomePagePart_Title(SessionHomePagePart: part,Title:title )),
                ContentShape ("Parts_SessionHomePagePart_Switcher", ()=>shapeHelper.Parts_SessionHomePagePart_Switcher(SessionHomePagePart: part,SessionList:listSessions))
            );
            
        }
When a user clicks the link in the switcher part, it calls into a controller, and I can look up what my new title is, and return just that shape.
[HttpGet]
        public ActionResult SessionHomePage(int sessionId)
        {
            var session = _sessionRepository.Fetch(s => s.SessionId == sessionId).SingleOrDefault();
            var viewModel = new SessionListViewModel { SessionId = session.SessionId, SessionTitle = session.Name };
            var title = string.Format("{0} - {1}", viewModel.SessionTitle, viewModel.SessionId);
            var listSessions = _sessionService.GetSessionList(_workContext.CurrentUser.UserName);

            var linkShape = _shapeFactory.Parts_SessionHomePagePart_Title(Title: title);
            
            return new ShapeResult(this, linkShape);
        }
What I want to know is can I combine shapes like in the driver file - I can't seem to find an example of this, but that doesn't mean it isn't possible. Or is there a better way to achieve this result? Help me please before I go mad ;)
Apr 29 at 4:04 PM
Sort of there....


My controller now looks a little like this
 [HttpGet]
        public ActionResult SessionHomePage(int sessionId)
        {
             
            var session = _sessionRepository.Fetch(s => s.SessionId == sessionId).SingleOrDefault();
            var viewModel = new SessionListViewModel { SessionId = session.SessionId, SessionTitle = session.Name };
            var title = string.Format("{0} - {1}", viewModel.SessionTitle, viewModel.SessionId);
            var listSessions = _sessionService.GetSessionList(_workContext.CurrentUser.UserName);
            SessionHomePagePart part = _contentManager.Get<SessionHomePagePart>(187);


            var linkShape = _shapeFactory.Parts_SessionHomePagePart_Title(SessionHomePagePart: part,Title: title);
            var switcherShape = _shapeFactory.Parts_SessionHomePagePart_Switcher(SessionHomePagePart: part,SessionList: listSessions);
            var mainShape = _shapeFactory.Parts_SessionHomePagePart(SessionHomePagePart:part);

             

            var parentShape = _shapeFactory.Create("SessionHomePage", Arguments.From(new Dictionary<string, object> {
                {"Parts_SessionHomePagePart_Title",linkShape  },
                {"Parts_SessionHomePagePart_Switcher",switcherShape  },
                {"Parts_SessionHomePagePart",mainShape  }
                }));


            return View(parentShape);
        }
And I have a view that looks like this
@Display(Model.Parts_SessionHomePagePart_Switcher)
@Display(Model.Parts_SessionHomePagePart_Title)
@Display(Model.Parts_SessionHomePagePart)
So my switcher part, which is a drop down list renders, along with the title, but not the main part even though I can see I've got it by stepping through the code. Just need to figure out that last missing bit, and then see if I can simplify that code.

Unless anyone can give me a hint