I want to know whether multiple master pages can be used in MVC 3. please give me a example how to use.
You can have as many master pages (Layout) as you want. Add them under Views -> Shared folder and mention the layout which you want to use in your view as
Layout = "~/Views/Shared/_myLayout.cshtml";
Related
I have several pages on my blog that are quite specific and I know exactly what links I would like to appear on the sidebar of each page.
The only way I know how to control sidebar content is to designate certain asides to appear with certain layouts.
In my case, these pages do not each need a unique layout (per-se), they just need a different set of asides. So I am reluctant to create a separate layout for each page just so I can control the asides with more precision.
You are correct, you'll need a new layout in which you can specify specific page_asides. There's a good example of the customizations you'll need to make here: New Plain Page Layout for Octopress
I have an action called index that returns a view and I've defined 3 views: index.cshtml, index.fr.cshtml and index.sv.cshtml, each of which contains my page in a different language. I expected my app would automatically find these views and serve them according to the browser language preference set, but it doesn't seem to.
is there some switch I have to turn on to make this work? I did add <globalization uiCulture="auto" culture="auto" /> to the <system.web> section of my web.config
TIA - e
If you go down this road, make a view per language you will end up with a lot a views and DUPLICATE code. something you want to avoid. A better approuch is the use of resources.
You can decide how far you go with globalisation : javascript / urls / tekst. The key is to make use of resources and put the key value pair there. Please look at http://channel9.msdn.com/Events/aspConf/aspConf/How-To-Achieve-World-Ready-Domination-In-ASP-NET-MVC-4
The index.mode.cshtml is for browser display mode of the ViewEngine.
You have to create a custom ViewEngine for localization. Here is one for WebForm. Just modify it to your needs and inherit from RazorViewEngine instead of WebFormViewEngine.
I have just setup a new Sitecore 6.6 MVC application and all is going well.
I need a breadcrumb trail and found this:
http://nuget.org/packages/MvcSiteMapProvider
I have set it up and it renders the
#Html.MvcSiteMap().SiteMap() correctly
but
it doesn't render anything for bread crumb:
#Html.MvcSiteMap().SiteMapPath()
If I debug into the SiteMapPathHelperModel.cshtml I can see that there are no nodes in my Model.
First question is, can and should I use:
http://nuget.org/packages/MvcSiteMapProvider
in MVC with Sitecore.
Second question is:
If you think it is ok to use this, do you have any idea why it doesnt render my bread crumb but it renders the menu?
I have never used SiteCore, so I don't know how it is set up exactly. However, MvcSiteMapProvider is flexible and can accommodate many scenarios.
The SiteMapPath() will render if you navigate to one of the URLs that are registered in the Mvc.sitemap XML file. Note that in most cases you need to register them with a controller and action attribute set. The whole principle is based on matching a unique node within the sitemap to a route, so you need to ensure that both the node and the route of the request have matching RouteValues dictionaries.
See the MvcMusicStore demo in the source code download if you need to see a working implementation to get started, or have a look at this tutorial:
http://www.shiningtreasures.com/post/2013/08/07/MvcSiteMapProvider-40-a-test-drive
I've read a couple of articles on using asp.net mvc3 razor (which I am fairly new to). I have a couple of .cshmtl pages which are like shared content (e.g. header). They are basically just html pages with one or two divs etc.
To embed this in my main page, do I just use #renderPage("page address"). Do I also need a call to #renderbody? Do I need to specify the/a page in the layout property?
Thanksa
I would put the common elements in a layout (or perhaps a partial view rendered by the base layout). In fact, that's what I did in an application I am now building and it works quite nicely. The one issue is whether or not you need View Model data populated by the controller and passed to that partial view. I did, so I used a base controller and populated the common elements in the view model (all of those also inherited from a base class that had the common properties) and used sections and then in the sections renderered the partial view or not, depending on the view's need.
You can create a Partial View for each of these and call:
#Html.Partial("ViewName")
Or you can use sections, or this article on sections might help too.
As you may or may not know, ASP.NET accepts HTML tagging.
So why not include your .aspx file with the HTML include tag?
Here's how:
<!-- #include virtual="path to file/include-file.html" -->
Ex:
<!--#include virtual="header.aspx"-->
I do this all of the time when writing an ASP.NET website.
Just place it wherever you want the code, from the included page, to show up.
CodeIgniter + Template howto design a portal like behavior.
I'm not getting the concept of how to design bigger sites with CodeIgniter and Templates.
The templates I'm using is Template Library for CodeIgniter. I'm having problems solving the following.
What I can see I need is some MasterTemplate that provides "MainRegion" for ProductCatalogue browsing and Account management etc. Then I would like to have a concept of "Widgets" loaded from the MasterTemplate that the user does not interact directly with instead it is simply informative. Ex: ShoppingCartWidget, TopNews etc...
Example of problems:
A) Widget - A shopping cart widget exposes a minimalistic resume of what user has added when browsing the the product catalog in the "MainRegion".
B) Hierachival view structure - When navigating to the "Account section" of the site the site renders a sub-view of the account system in the "MainRegion". My problem is that the state of the AccountSection is lost when I for example leave the "AccountSection" in to "ProductCatalogue" and the back to "Accountsection". I want to be able to render each subsection independtly smothly insterted into the "MainRegion" in the master template.
I really don't get the architecture. I need help to bring real modularity into the design.
I would like to achive the following:
1) View fragments should render from a its own model. Ex: ShoppingCartWidget always reads its state from ShoppingCartModel.
3) View fragments should have a display[on/off] in some MasterTemplate concept. So that I can Ex: Start showing the ShoppingCartWidget when there is something in the ShoppingCart. (I don't want to render '').
4) Stateful views. Ex: UserLoggedIn/UserNotLoggedIn
I'm missing the complex design principles for bigger sites or best practices for CI.
Very greatful for any help!
Thanks
Niclas
HMVC for Codeigniter does what you want: https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home