Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Different header content on every category page

Vote:
 

Hello, it will be probably very basic question for EPi developers

What I'd like to achieve is a MVC structure for:

FrontPage
        Division1FrontPage
        Division2FrontPage
        Division3FrontPage
        Division4FrontPage

Every division page will be one page type, lets say: DivisionPage, which I'd like to have "header" tab in EditMode with properties like:
    Logo
    LogoText

I'd like my editors to have possibility to change logo and text next to logo for every division specifically.

As far as I know all of those pages should have one _layout. How to make header from root layout for FrontPage to take values from DivisionPage model??? Can you suggest any solution?

#180659
Jul 20, 2017 8:16
Vote:
 

Hi,

If I understood you correctly - you should look other way around. Child page should "bubble up" necessary values to be displayed in layout page (theoretically you can also have multiple layout pages and each child page can specify which layout page to use - but that's I guess another topic).

One of the easiest way to achieve this is to use ViewData dictionary for instance. Child page will add their own values from their page instances to `ViewData` dictionary under specific keys and then layout page can reach these values and render in necessary placeholders.

Another approach would be to use `CurrentPage` approach. You can reach page currently being rendered via `IPageRouteHelper` interface. This guy has `Page` property that will point to the `PageData` object (this is base class for all pages). Problem with this approach is that you have to somehow extract values frorm the page. One way is to use "stringly typed" approach - `IPageRouteHelper.Page["LogoText"]` (which sucks). Another approach would be to cast this `PageData` to some known interface that only Division pages implement (e.g. IDivisionPage) and then if result != null (meaning that current page is DivisionPage, as there might be other pages "running through" layout page code) you can get values from that page via interface (which also sucks a bit, but less).

#180723
Jul 23, 2017 21:48
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.