you could create a new document type for the repeated content that you want to embed, and allow this type of node to be created underneath you main page doctype node, then write a macro with a razor/xslt that writes out the content from the repeating child nodes,and put this macro in the main page template in the position where you want the repeating content.to be embedded.
But when you insert razor into a page template, it has some sample razor implementations and the one you'd want to play around with is the ''list child pages with doctype' that looks a bit like this:
<umbraco:Macro runat="server" language="cshtml">
@inherits umbraco.MacroEngines.DynamicNodeContext
@*This snippet shows how simple it is to fetch only children of a certain Document Type using Razor. Instead of
calling .Children, simply call .AliasOfDocumentType in plural.
For instance .Textpages or .NewsArticles (you can find the alias of your Document Type by editing it in the
Settings section).
*@
@{
@*Build a query and return the visible items *@
var selection= Model.Textpages.Where(query).Where("Visible");
}
@*Determine if there are any nodes in the selection, then render list *@
var selection= Model.Textpages.Where(query).Where("Visible");
Error 148 The name 'query' does not exist in the current context d:\Projects\TestUmbracoProject\WebSite\Umbraco\Scripting\templates\cshtml\ListChildPagesWithDoctype.cshtml 13 39 WebSite
When Idoso,getother new errors( In other filesof thisfolder d:\Projects\TestUmbracoProject\WebSite\Umbraco\Scripting\templates\cshtml)
Like these:
Error 175 The name 'CurrentPage' does not exist in the current context d:\Taras\Mobulforbrug\WebSite\Umbraco\Scripting\templates\cshtml\ListDescendantsFromCurrentPage.cshtml 8 6 WebSite
Error 170 The type or namespace name 'Framework' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?) d:\Taras\Mobulforbrug\WebSite\Umbraco\Scripting\templates\cshtml\ListDescendantsFromCurrentPage.cshtml 4 16 WebSite
Error 172 The name 'CurrentPage' does not exist in the current context d:\Taras\Mobulforbrug\WebSite\Umbraco\Scripting\templates\cshtml\ListDescendantsFromCurrentPage.cshtml 8 6 WebSite
Why is it so?
Why is this directory(d:\Projects\TestUmbracoProject\WebSite\Umbraco\Scripting\templates\cshtml) in visual studio? When is it use?
How to create Embedded multiple type fields in document type,
Hi,
Can any one help me that how to craete Embedded multiple type fields in documnet type?
Thanks in advance
Priyank
Hi Priyank
You could take a look at using the 'Embedded Content' Datatype here:
http://our.umbraco.org/projects/backoffice-extensions/embedded-content
or
you could create a new document type for the repeated content that you want to embed, and allow this type of node to be created underneath you main page doctype node, then write a macro with a razor/xslt that writes out the content from the repeating child nodes,and put this macro in the main page template in the position where you want the repeating content.to be embedded.
This is a good introduction of how to do this in razor: http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets
But when you insert razor into a page template, it has some sample razor implementations and the one you'd want to play around with is the ''list child pages with doctype' that looks a bit like this:
<umbraco:Macro runat="server" language="cshtml">
@inherits umbraco.MacroEngines.DynamicNodeContext
@*This snippet shows how simple it is to fetch only children of a certain Document Type using Razor. Instead of
calling .Children, simply call .AliasOfDocumentType in plural.
For instance .Textpages or .NewsArticles (you can find the alias of your Document Type by editing it in the
Settings section).
*@
@{
@*Build a query and return the visible items *@
var selection= Model.Textpages.Where(query).Where("Visible");
}
@*Determine if there are any nodes in the selection, then render list *@
@if(selection.Any()){
<ul>
@foreach(var page in selection){
<li><a href="@page.Url">@page.Name</a></li>
}
</ul>
}
</umbraco:Macro>
Please, give me answer.
What is "query"?
I have error in visual studio in this line:
var selection= Model.Textpages.Where(query).Where("Visible");
Error 148 The name 'query' does not exist in the current context d:\Projects\TestUmbracoProject\WebSite\Umbraco\Scripting\templates\cshtml\ListChildPagesWithDoctype.cshtml 13 39 WebSite
Instead "query" has to be my alias type?
How fix this error?
Thanks.
Hi Taras,
If you haven't any conditions just remove this where.
var selection= Model.Textpages.Where("Visible");
When I do so, get other new errors( In other files of this folder d:\Projects\TestUmbracoProject\WebSite\Umbraco\Scripting\templates\cshtml)
Like these:
Error 175 The name 'CurrentPage' does not exist in the current context d:\Taras\Mobulforbrug\WebSite\Umbraco\Scripting\templates\cshtml\ListDescendantsFromCurrentPage.cshtml 8 6 WebSite
Error 170 The type or namespace name 'Framework' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?) d:\Taras\Mobulforbrug\WebSite\Umbraco\Scripting\templates\cshtml\ListDescendantsFromCurrentPage.cshtml 4 16 WebSite
Error 172 The name 'CurrentPage' does not exist in the current context d:\Taras\Mobulforbrug\WebSite\Umbraco\Scripting\templates\cshtml\ListDescendantsFromCurrentPage.cshtml 8 6 WebSite
Why is it so?
Why is this directory(d:\Projects\TestUmbracoProject\WebSite\Umbraco\Scripting\templates\cshtml) in visual studio? When is it use?
Can I disable the compilation of this directory? (d:\Projects\TestUmbracoProject\WebSite\Umbraco\Scripting\templates\cshtml). How do it?
There are files:
ListChildPagesFromCurrentPage.cshtml
ListChildPagesOrderedByDate.cshtml
ListChildPagesWithDoctype.cshtml
..and other standard files.
is working on a reply...