Comments (6)
Current behavior is not intentional, no. The idea is that you can render an Entity Model with another View than what the Entity Model's MVC data says (for whatever reason). This was intended to be a temporary override, though.
Can you further clarify why you want to render the same Entity Model with multiple different (hard-coded) Views, though?
from dxa-web-application-dotnet.
The HTML must look the same as the old site and there is two entities within the same div-tag. This to be able to reuse the CSS. The way I do it now is by simply using @Html.Partial()
, so the code looks something like this now:
@model RegionModel
@{
var header = Model.Entities.Single(m => m.MvcData.ViewName == "Header");
}
<div class="header">
<div class="menu">
<div class="menu-content">
@Html.DxaEntity(Model.Entities.Single(m => m.MvcData.ViewName == "Navigation"))
</div>
@Html.Partial("_Utility", header)
</div>
@Html.Partial("_Logo", header)
</div>
If there is a better way doing it I'm all ears!
from dxa-web-application-dotnet.
Interesting! It looks like you need nested Regions. :-)
However, since you're already finding the "Header" Entity by its (original) View name first, would you actually suffer from the quirk/bug that it affects the MVC data of the Entity? That is: will above Region View not work properly if you use @Html.DxaEntity
with View override instead of @Html.Partial
?
Or are you also rendering the entity with its original View somewhere else?
from dxa-web-application-dotnet.
I tried that but no, since it is just referencing to the entity it wont help. So the following code wont work:
@model RegionModel
@{
var header = Model.Entities.Single(m => m.MvcData.ViewName == "Header");
}
<div class="header">
<div class="menu">
<div class="menu-content">
@Html.DxaEntity(Model.Entities.Single(m => m.MvcData.ViewName == "Navigation"))
</div>
@Html.DxaEntity(header, "_Utility") @* This changes the MvcData.ViewName *@
</div>
@Html.DxaEntity(header, "_Logo") @* Argument Null Exception *@
</div>
This code will work though:
@model RegionModel
<div class="header">
<div class="menu">
<div class="menu-content">
@Html.DxaEntity(Model.Entities.Single(m => m.MvcData.ViewName == "Navigation"))
</div>
@Html.DxaEntity(Model.Entities.Single(m => m.MvcData.ViewName == "Header"), "_Utility")
</div>
@Html.DxaEntity(Model.Entities.Single(m => m.MvcData.ViewName == "_Utility"), "_Logo")
</div>
from dxa-web-application-dotnet.
TSI-1767 (internal issue ID for tracking purposes)
from dxa-web-application-dotnet.
Fixed in DXA 1.6.
from dxa-web-application-dotnet.
Related Issues (20)
- Sdl.Web.Common.Models.PageModel.GetXpmMarkup() calls unused XpmMetadata HOT 2
- DXA1.6 web solution (dxa-web-application-dotnet-DXA_1.6_Release.zip) HOT 1
- Language selector URL does not expect null page id HOT 2
- Use precompiled views HOT 1
- Have DXA sources in a symbol server HOT 2
- Only possible to embedded MediaItem entities in Rich Text fragments HOT 2
- Component Link mapping fails after link depth reached in web application. HOT 2
- Model Service (R2) ComponentTemplate missing from DCP(s) HOT 3
- ModelServiceClient ArgumentNullException crash HOT 2
- HtmlHelper null pointer exceptions HOT 3
- Ambiguous DXA exception for PCA DXA model addon
- Keyword Model extensions are not supported without a Metadata Schema
- RichText model extensions are not supported
- Output Cache is caching even if there is an error on the page HOT 1
- can DXA Container Framework be extended to support DXA 2.2 on Tridion 9/9.1
- Images with spaces return 404
- BinaryFileManager - StripDimensions UrlDecode ran only when no dimensions HOT 1
- MimeMapping.GetMimeMapping returns wrong mime types
- reuse HttpClient object / SNAT port exhaustion HOT 1
- Outputcache empty content after redirect HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dxa-web-application-dotnet.