Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Priyank Gupta 2 posts 22 karma points
    Mar 01, 2013 @ 09:06
    Priyank Gupta
    0

    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

     

     

     

  • Marc Goodson 2142 posts 14345 karma points MVP 8x c-trib
    Mar 04, 2013 @ 21:18
    Marc Goodson
    0

    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>

  • Taras 30 posts 151 karma points
    May 14, 2013 @ 11:14
    Taras
    0

    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.

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    May 14, 2013 @ 12:25
    Alex Skrypnyk
    0

    Hi Taras,

    If you haven't any conditions just remove this where.

    var selection= Model.Textpages.Where("Visible");

     

  • Taras 30 posts 151 karma points
    May 14, 2013 @ 12:53
    Taras
    0

    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?

  • Taras 30 posts 151 karma points
    May 14, 2013 @ 13:15
    Taras
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft