displaying nested items

Agile IT asked on April 18, 2017 16:06

I have following content structure

-YearlyContainer 
   - YearDetailContent
      --files to download
   - YearDetailContent
      --files to download
 -YearlyContainer 
    - YearDetailContent
     --files to download

I need to display this in the same order. I am trying to use hierarchical transformation, but the result is not as expected. I have following transformations under it

 - header, level:0, apply to sublevels:false; (to print yearlyContainerDetail)
 - header, level:1, apply to sublevels: false; (to print yearDetail)
 - footer, level 0, false (to close yearlyContainerDetail)
 - footer, level 1, false (to close yearDetail)
 - item, level 2, true, documenttype: files

Correct Answer

Rui Wang answered on April 20, 2017 18:19

I just realized, you miss used the header and footer transformation. Your case should not have header and footer, instead you should use 3 level of Item Transformation only.

Level 0

<section class="row expanded first-download" style="background-color:'<%# Eval("BackgroundColor") %>'">
<div class="first-download-block result-block-report">  
<h2 class="secondary-title-text"><%# Eval("Year") %> Results <span class="according_arrow"></span></h2>
 <div class="wf-pNewsTwoCol">
  <cms:SubLevelPlaceHolder runat="server" ID="plcSub" />
 </div>
</div>
</section>

Level 1

 <div class="wf-pNewsTwoCol__col">
  <div class="wf-card-block red-block-report">
    <div class="red-block-report__date"><%# Eval("Date", "{0:dd MMM yyyy}") %></div>
    <p><%# Eval("Title") %></p>
    <div class="report_btn_wrapper">
    <cms:SubLevelPlaceHolder runat="server" ID="plcSub" />
  </div>
</div>
</div>

Level 2

 <script runat="server" >
  protected string GetTarget(object isExternalLink){
    if(!(isExternalLink is DBNull) && Convert.ToBoolean(isExternalLink)){
      return "_blank";
    }
    return "";
  }
</script>
<%# IfEmpty(Eval("Link"), "<a href='"+GetFileUrl("File")+"' target = '_blank'  class='Button'>"+Eval("Title")+"</a>",  "<a href='"+Eval("Link")+"' target ='"+GetTarget(Eval("IsExternalLink"))+"' class='Button'>"+Eval("Title")+"</a>") %>
1 votesVote for this answer Unmark Correct answer

Recent Answers


Rui Wang answered on April 18, 2017 16:40

What does you result look like? Should there be a level above all the YearlyContainers? The hierarchical viewer should be point to that as the path. Then your level may need to shift down one level each.

0 votesVote for this answer Mark as a Correct answer

Agile IT answered on April 18, 2017 17:10

Current Output is as

-YearlyContainer 
 - YearDetailContent
  --files to download
  --files to download (from 2nd yearDetailContent)
 -yearDetailContent
  -- all files to download from all yearDetailContent within another yearly content.

Basically, yearlyContainer is not separting in two row for different yearlyContainer. and yearDetailContent from another yearlyContainer is also comming in first yearlyContainer. and files from all yearDetailContent are comming under first yearDetailContent section.

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on April 18, 2017 17:15

Can you paste your transformation for the YearlyContainer and YearDetailContent here?

0 votesVote for this answer Mark as a Correct answer

Agile IT answered on April 19, 2017 07:34 (last edited on April 19, 2017 07:37)

This is the list of transformations Image Text

custom.FinancialResultYearlyContainer.Trans_FinanacialHirerachicalResultHeader

<section class="row expanded first-download" style="background-color:'<%# Eval("BackgroundColor") %>'">
<div class="first-download-block result-block-report">  
<h2 class="secondary-title-text"><%# Eval("Year") %> Results <span class="according_arrow"></span></h2>
<div class="wf-pNewsTwoCol">

custom.FinancialResultYearlyContainer.Trans_FinancialYearlyContainer_footer

</div>
</div>
</section>

custom.FinancialResults.Trans_financialResult_header

 <div class="wf-pNewsTwoCol__col">
  <div class="wf-card-block red-block-report">
    <div class="red-block-report__date"><%# Eval("Date", "{0:dd MMM yyyy}") %></div>
    <p><%# Eval("Title") %></p>
    <div class="report_btn_wrapper">

custom.FinancialResults.Trans_FinancialResult_footer

</div>
</div>
</div>

custom.FinancialResultAttachment.Trans_financialResultAttachement_Item

 <script runat="server" >
  protected string GetTarget(object isExternalLink){
    if(!(isExternalLink is DBNull) && Convert.ToBoolean(isExternalLink)){
      return "_blank";
    }
    return "";
  }
</script>
<%# IfEmpty(Eval("Link"), "<a href='"+GetFileUrl("File")+"' target = '_blank'  class='Button'>"+Eval("Title")+"</a>",  "<a href='"+Eval("Link")+"' target ='"+GetTarget(Eval("IsExternalLink"))+"' class='Button'>"+Eval("Title")+"</a>") %>

The final html expected is as

Image Text

The prototype html is as for one yearly container. such section should be repeated.

<section class="row expanded third-download">
 <div class="first-download-block result-block-report">  
    <h2 class="secondary-title-text">2016 Results <span class="according_arrow"></span></h2>
    <div class="wf-pNewsTwoCol">
        <div class="wf-pNewsTwoCol__col">
            <div class="wf-card-block red-block-report">
                <div class="red-block-report__date">21 FEB 2017</div>
                <p>2016 Annual Financial Report</p>
                <div class="report_btn_wrapper">
                    <a href="#" class="Button">Pdf </a>
                    <a href="#" class="Button">Pdf </a>
                    <a href="#" class="Button">Pdf </a>
                    <a href="#" class="Button">Pdf </a>
                </div>
            </div>
        </div>
        <div class="wf-pNewsTwoCol__col">
            <div class="wf-card-block red-block-report">
                <div class="red-block-report__date">21 FEB 2017</div>
                <p>2016 Annual Financial Report</p>
                   <div class="report_btn_wrapper">
                    <a href="#" class="Button">Pdf </a>
                    <a href="#" class="Button">Pdf </a>
                    <a href="#" class="Button">Pdf </a>
                    <a href="#" class="Button">Pdf </a>
                </div>
            </div>
        </div>
    </div>
  </div>
</section>

The content structure on admin is as

Image Text

0 votesVote for this answer Mark as a Correct answer

Agile IT answered on April 19, 2017 10:32

Rui, also I need to built this sections based on search result by keyword and year value, so if this can be handled in different way then please consider that point too. Thanks

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on April 19, 2017 16:16 (last edited on April 19, 2017 17:44)

Dilip, first thing I notice missing from your transformation is the placeholder for the child level.

<cms:SubLevelPlaceHolder runat="server" ID="plcSub" />

You need to place that in the parent level so the child level know that's the place to go. So you top two level transformation should look like these

<section class="row expanded first-download" style="background-color:'<%# Eval("BackgroundColor") %>'">
<div class="first-download-block result-block-report">  
<h2 class="secondary-title-text"><%# Eval("Year") %> Results <span class="according_arrow"></span></h2>
<div class="wf-pNewsTwoCol">
<cms:SubLevelPlaceHolder runat="server" ID="plcSub" />

and

 <div class="wf-pNewsTwoCol__col">
  <div class="wf-card-block red-block-report">
    <div class="red-block-report__date"><%# Eval("Date", "{0:dd MMM yyyy}") %></div>
    <p><%# Eval("Title") %></p>
    <div class="report_btn_wrapper">
    <cms:SubLevelPlaceHolder runat="server" ID="plcSub" />

As for the search part, are you talking about use the smart search to find the result? That's very different from what the hierarchical viewer and transformation can do. Search results are flat, so there won't be the hierarchical structure that you can utilize.

0 votesVote for this answer Mark as a Correct answer

Agile IT answered on April 20, 2017 08:52 (last edited on April 20, 2017 10:52)

Placing the placeholder also produce the same output as below:

Image Text

Based on content structure as below

Image Text

The output should be different for 2016 results and 2014 year results also each year has two financial result.

Regarding search I want to implement the smart search on this yearly container, financial result and attachement titles. How should I do if it has to be done differently(I have no experience on smart search) Also, I have asked the question related to search at here!

Thanks!

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on April 20, 2017 18:31

Here are the screen shots

Image Text

Image Text

Image Text

1 votesVote for this answer Mark as a Correct answer

Agile IT answered on April 21, 2017 07:18 (last edited on April 21, 2017 09:13)

Thanks Rui that is really helpful!

One more request. I have to implement search on such documents as well. also filter by year from year value in yearlyContainer. How could I achieve searching on this kind of structure and show the result. I have asked the question here, since you know the expected output and content structure, can you please guide over this.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.