<%~set widgets_loop = Plugins::UI::fetch_widgets('subcategory', $ID)%>
<%~set widget_start = 1%>
<%~set widget_end   = 3%>

<%~if paging.current_page == 1 or not $paging%>
<section class="section featured section-has-widgets remove-sidebar clearfix">
<div class="sidebar-b">
  <%~set adsize = '300x600'%>
  <%include include_ad.html%>
</div><!-- end sidebar -->
<div class="content content-has-sidebar">
  <div class="grid">
    <div class="col-1-1">
      <h1><%Name%></h1>
    </div>
    <%~if $category_loop.length%>
    <%~set split = Links::Utils::column_split($category_loop.length, 2)%>
    <div class="subcategory">
        <h3>Sections</h3>
        <div class="clearfix">
        <%~loop category_loop%>
            <%~if Number_of_Links%>
            <%~set splitmod = $row_num % $split%>
            <%~if row_num == 1 or splitmod == 1 or split == 1%><dl><%endif%>
            <li><a href="<%URL%>"><%Name%></a></li>
            <%~if row_num == $category_loop.length or splitmod == 0%></dl><%endif%>
            <%~endif%>
         <%~endloop%>
         </div>
    </div>
    <div class="widget-divider"></div>
    <%~endif%>

    <%~set max_hits = 3%>
    <%~if category_loop.length > 4%><%set max_hits = 1%><%endif%>

    <%~set featured_articles_loop = Plugins::UI::fetch_links(ids => $Featured_Links, max_hits => $max_hits)%>
    <%~if not featured_articles_loop.length%>
        <%~init array featured_articles_loop%>
        <%~set index = 0%>
        <%~loop links_loop%>
            <%if row_num > $max_hits%><%lastloop%><%endif%>
            <%~set featured_articles_loop.$index = $loop_value%>
            <%~set index += 1%>
        <%~endloop%>
    <%~endif%>

    <%~if featured_articles_loop.length%>
    <%~if not Featured_Links%><%set skip_top_three = 1%><%endif%>
    <%~if max_hits == 1%><%~set show_ad = 1%><%else%><%set show_ad = 3%><%endif%>
    <%~set get_thumbnail_url  = 1%>
    <%include include_featured_articles.html%>
    <%~endif%>
  </div>
</div><!-- end content -->
</section><!-- end section -->
<div class="section-divider"></div>
<%~endif%>

<%~set list_view = ''%>
<%~set num_links = $links_loop.length%>
<%~set num_page_break = 9%>

<section class="section archive section-has-widgets section-reverse">
<div class="sidebar-b">
    <%include include_widgets.html%>
</div>
<div class="content content-has-widgets">
    <div class="grid">
        <div class="clearfix<%if paging.current_page > 1%> relative<%endif%>">
            <%~if paging.current_page > 1%>
            <div class="col-1-1 toolbar-b">
                <h1><%Name%></h1>
                <%include include_paging.html%>
            </div>
            <%~endif%>
            <%~loop links_loop%>
            <%if skip_top_three and $row_num <= $max_hits%><%nextloop%><%endif%>
            <%~rewrite_detail_url%>
            <%~set thumbnail_url = Plugins::UI::fetch_thumbnail($loop_value)%>
            <%include link.html%>
            <%~if row_num == $num_page_break%><%lastloop%><%endif%>
            <%~endloop%>
        </div>
    </div>
    <div class="section-divider mobile"></div>
</div><!-- end content -->
</section><!-- end section -->
<div class="clearall"></div>
<div class="section-divider"></div>

<%~include include_featured_photo_video.html%>

<%~if num_links > $num_page_break%>
<section class="section archive section-has-widgets section-reverse">
<div class="sidebar-b">
  <%~set widget_start = 4%>
  <%~set widget_end   = 5%>
  <%include include_widgets.html%>
</div>
<div class="content content-has-widgets">
  <div class="grid">
    <div class="clearfix">
      <%~loop links_loop%>
      <%~if row_num <= $num_page_break%><%nextloop%><%endif%>
      <%~rewrite_detail_url%>
      <%~set thumbnail_url = Plugins::UI::fetch_thumbnail($loop_value)%>
      <%include link.html%>
      <%~endloop%>
      <div class="toolbar right">
          <%~set page_button = 'page_button2'%>
          <hr class="line">
          <%include include_paging.html%>
      </div>
    </div><!-- end column -->
  </div>
  <div class="section-divider mobile"></div>
</div><!-- end content -->
</section><!-- end section -->
<%~endif%>
