I defined a few display templates for classes and they work well when I put them in views/shared/DisplayTemplates. However after I move them into an area, looks like ASP.NET MVC won't look inside Area to find the templates.
How to reference the DisplayTemplates defined in an Area from main project? Is that a good practise?
I don't think you can reference display templates that exist inside an area from the main project or a different area.
This is very logical and I think you should follow this constraint and not try to workaround it. Think of an area as a separated logical part of your application - it should have all its resources inside the area. However, when you have a resource like a master layout or a logo image that should be used from other areas as well, then this resource should be placed on the main project folders and not in specific areas to make it available to all.
I don't totally agree with Shay -- in case of a shared reusable area, templates can be specified as default and overruled in the main website project if needed. The TemplateHelper class should take areas in account when locating templates.
This is quite easy to fix, tho -- see my other post here
Related
I am a little bit confused. How do we reuse areas from another page? Lets say I created an article in an articles area on my index page. How do I display that same content in another page?
Ive read the following https://documentation.magnolia-cms.com/display/DOCS53/Reusing+area+content
Seems kind of complex. I dont understand the pom file.
Cant we acccomplish this purely in light modules? If not, could someone show me an example of a simple content reuse scenario?
Yes you can do it purely w/ light modules. Look at this article. Example there is custom "quotation" app and the quotes you create you can render and reuse in as many different pages/page-types you want.
However it is slightly different than what you ask. In your question you want to reuse content from the page, which is also possible (you just need to address that content and feed it to appropriate cms tag in your page template (you can forget all about maven and so on, just focus on your templates). In the example I point you to, you create custom app for stories, articles or any kind of content and then just refer it from all pages where you want to render it. This allows you not only to share the content, but also separate it's editing from the page structure which makes life of editors easier in long run.
I am exploring the use of Sections to create optional content in my site's layout, as explained quite neatly in ScottGu's article here:
http://weblogs.asp.net/scottgu/asp-net-mvc-3-layouts-and-sections-with-razor
However, what I'm trying to do is add a sidebar to the views related to a specific controller, where the sidebar contains static information relevant to the controller. The data won't be tied to the model - it'll just be some links to external pages, and some static 'helper' text.
I don't want the Sidebar on every page / view - just on some views (in my case, it's the view related to a specific controller).
What I don't want to do is have to declare the same Section and content for each view that needs this. I was trying to find some way of creating a 'shared section' - that I could reference neatly in the views that require it, and pass back to the _Layout when the View is returned by the controller.
Partial Views seemed to be the way forward with this:
Injecting content into specific sections from a partial view ASP.NET MVC 3 with Razor View Engine
But I'm not sure if this is the right way to go about this, or if there's more succinct way to achieve what I'm aiming for.
I have been searching for answers on this, but as ever with this sort of thing, I am 100% sure I am not using the correct terminology in my search attempts for this - so apologies if this is duplicate post, basic stuff, or has already been answered elsewhere.
Any pointers on this - even if it's just to give me some direction on the terms to search on - would be welcome !
I've not provided any example code here, but could possibly knock something up if it helps articulate things.
Cheers
It sounds like you need Layout nesting, rather than sections.
You can create a master layout, then have a layout that contains the sidebar, making it's Layout property point to your master layout. Then, you can choose which layout for your content pages to use, simply by specifying Layout = Master.cshtml or Layout = Sidebar.cshtml
I think the approach outlined in the link you provided is very feasible.
Another alternative, depending on the complexity involved in getting the sidebar in your layout, you could create a separate layout.
I am having difficulty navigating to different MXML pages in my Flex application. I checked some other questions on SO about it but they seemed to be to do with tab navigation.
I am trying to navigate from one MXML page to another via Actionscript code. How is this possible?
Cheers
Edit:
I am a real beginner in Flex and I worked out that I actually needed to use States, and have now discovered how to use them. Thanks for your help.
You don't navigate between MXML pages. MXMLs are not pages to begin with. Instead they are components, that are displayed in the application. So if you want to change the current display, then you need to remove the already added components, and add others that should be displayed now.
There are different approaches to do this. The very raw way of manually removing elements is rarely used, instead there are two main methods: ViewStacks and display states. Display states should be used when there are not many different changes in a view, for example when you click a checkbox that adds new options to an existing formular. If you want to change the whole displayed content (this does not have to be the whole application content though, think in components instead), you can use ViewStacks.
ViewStacks are like a stack of paper, where each paper reflects a single view. So if you want to display something else, you move the new view to the top, hiding all others below. Many components, including TabNavigators, are just ViewStacks with an additional menu to select the view that should be displayed. But you can also just use a ViewStack and manually change to what you want to show.
Flex is not sidebased like html.
You have to instantiate or remove classes, components or all this stuff.
i would use the states.
You can register handler to buttons and swap the state.
Then you are able to instatiate or remove components via the tsates.
Which flex version dou you use? The management of the states are changing between flex3 and flex4
Assume, you have one app with two content areas, home and gallery. First you have to create these two areas with project->new->component and named there related.
After that, you instanciate both components in your app.
Define two states, home and gallery and swap these with a button or two.
set the propert excludefrom or include with the name of the states. finally, you have an app with two content areas, but you never swap pages, you instanciate or remove components in runtime.
br
Frank
BR
Frank
I just started out with Flex, and while I have worked with Actionscript2 for a few years, I'm still getting my head around Actionscript3. I've been diving into Flex for the past week, and can't figure this one thing out.
I am looking into the best way (or 'a' way) to allow me and other folks working on this project to easily create new themes for kind-of an video player. I show two videos, and need to be able to reposition them, style them, add images and anything else, really. I'm not looking to create a full-on templating engine, but if I could have a separate file/folder for each template, that would totally make my day.
I imagined having a solution in which I would have a folder inside src/templates/, and inside that folder I would have view.mxml that contains everything I need to display the videos. I would then be able to add other files such as images and such to make this template look the way it should.
Which template should be used should be defined by a variable in the main video file. This will either be provided to the swf file on playback, or provided by the video loading an external configuration file (but this is not part of my question :).
So, in short; How do I include mxml files that are inside one or two sub-folders inside src, and how do I do this in a way that the file I wish to include can be chosen via a variable.
Thanks so much in advance!
-Dave
You'd be surprised to what degree a Flex application can change its appearance through styling. Check out the following project:
http://www.fillcolors.com/
If you need more flexibility still, you could have an application with multiple views, one for each theme you want to show. An easy way to do this in Flex is to make use of the ViewStack component which basically layers view displays, showing only one at a given time.
As a very simple example, you could have something along these lines:
<mx:ViewStack selectedIndex="{currentIndex}">
<themes:CustomTheme1/>
<themes:CustomTheme2/>
<themes:CustomTheme3/>
</mx:ViewStack>
Here, currentIndex is a variable bound to the ViewStack, determining which of the three children is currently visible, each of which represent a custom MXML component (in your case, a theme).
Response to comment:
Yes, the above example is designed to do exactly that, but it's really not a feature of Flex, but of AS3. The CustomThemeX components are located using the themes namespace. The namespace is defined within the parent components root tag. In this example, the parent is a Canvas component:
<mx:Canvas xmlns:themes="themes">
This tells the compiler to look for these custom components within the themes sub-folder of your application; in other words, the src/themes folder, which contains the CustomThemeX components.
If the preceding paragraph didn't really sense to you, I'd recommend picking up a book/reading through the documentation about AS3/Flex and learning more about some of the core concepts of AS3 and object oriented programming. I wish I could help out more, but this question is starting to get a little too broad. I hope you understand. :)
I'm not an expert on Flex. But I've seen a tutorial on skins in Flex on gotoAndLearn.com. Maybe that kan give you some hints: Introduction to Flex: Part 3
I'm hoping my cryptic title isn't too cryptic, but I'll try to explain what it is I actually want to do.
I have a master page 'A' which has child pages 'B' and 'C'.
This is implemented with the standard master page model in ASP.NET just fine.
My site has two themes 'T1' and 'T2'.
They actually represent different partners, T1 being our own company and T2 is a partner.
I want to display specific things on pages 'B' and 'C' depending upon which theme I'm using. For instance I may want to insert additional buttons or graphics on page 'B' specific to partner for theme 'T2'. This content would be at an arbitrary point on the page depending upon the page itself. Some partners may not even use this feature.
The problem is I want to do this as declaratively as possible, and minimize the knowledge that the pages have about the theme.
This is where the 'reverse' master page concept comes in. I want to define an area on a child page into which 'theme' specific content can be inserted. (I'm saying 'theme' because thats what ASP.NET uses - and most likely what I'd tie the content to).
So you may be wondering :
Why can't you just use a master page for this and add extra content sections? Reason is that the content may appear anywhere on the page in a location that is specific to that page.
Why can't you use a 'nested' master page? Essentially the same reason.
Possible solution:
I'm wondering about creating some kind of user control that would have a textual key representing what type of content would be inserted there. The user control would have to know what to display for each 'theme' - probably by dynamically creating the relevant additional user control.
This seems a little clumsy - so I'm wondering what kind of solutions others may have created for similar situations.
you can use CSS to position your content sections anywhere on your page. so i wouldnt worry about page locations, etc.
if it were me, i'd just dynamically load the 2 different css files into the one masterpage and based on the same logic render the different content into the placeholders.
I'm currently working on a site that has similar requirements that are too much for CSS. In one layout the login is horizontal towards the top of the render order, and in another its in the right hand column.
We're using standard ASP.NET themes to push out CSS, logo URLs via SkinID, etc.
To obtain the custom layout I've created a "Loader" control that loads UserControls via a list specified in a Loader attribute. The attribute can be defined directly in the loader markup, or via a .skin file in the theme.
Each key in the list is just the base name of a UserControl (I add the path and extension). The controls are created via Page.LoadControl().
Do you have fix layout for different partners ? Or do you want the partners to choose the layouts on runtime ?
If the layouts are fixed than 1 way is to create zen style CSS (http://www.csszengarden.com/) and than dynamically load it as per the client/partner. If you want the partners to modify the layouts on runtime than probably you might want to use Webparts.
Hope this helps.
You CAN use nested master pages in VS2008!
See here --
Scott Guthrie's Blog