Skip to content

Instantly share code, notes, and snippets.

@addisonhall
Created March 23, 2015 12:59
Show Gist options
  • Save addisonhall/556ed2bc90e8af760b0c to your computer and use it in GitHub Desktop.
Save addisonhall/556ed2bc90e8af760b0c to your computer and use it in GitHub Desktop.
Statamic partial for outputting replicator fieldset
{{#
Statamic partial for outputting this replicator fieldset:
https://gist.github.com/addisonhall/606290c70c7e8f20101e
#}}
{{#
Build FAQ menu, if necessary
Uses https://github.com/michaelhue/statamic-var
---------------------------------------
#}}
{{ standard_content }}
{{ if type == 'faq_set' AND faq_link }}
{{ unless { var:exists name='is_first_faq'} }}
<h2>Jump to FAQ for:</h2>
<ul class="list-inline s-list-jumplinks">
{{ var:is_first_faq is='true' }}
{{ /unless }}
<li class="jumplink-{{ index }}"><a class="btn btn-default" href="#{{ faq_title|slugify }}-faq">{{ faq_title }}</a></li>
{{ if last }}</ul>{{ /if }}
{{ /if }}
{{ /standard_content }}
{{#
Build header menu, if necessary
Uses https://github.com/michaelhue/statamic-var
---------------------------------------
#}}
{{ standard_content }}
{{ if type == 'header_set' AND hdr_link }}
{{ unless { var:exists name='is_first_hdr'} }}
<h2>Jump to section for:</h2>
<ul class="list-inline s-list-jumplinks">
{{ var:is_first_hdr is='true' }}
{{ /unless }}
<li class="jumplink-{{ index }}"><a class="btn btn-default" href="#{{ hdr_text|slugify }}">{{ hdr_text }}</a></li>
{{ /if }}
{{ if last }}</ul>{{ /if }}
{{ /standard_content }}
{{#
Output everything else!
------------------
#}}
{{ standard_content }}
{{ if type == 'header_set' }}
<{{ hdr_type }} id="{{ hdr_text|slugify }}">{{ hdr_text }}</{{ hdr_type }}>
{{ elseif type == 'text_set' }}
{{ content }}
{{ elseif type == 'img_set' }}
<figure class="{{ img_layout }} s-img-half">
<img class="img-responsive" src="{{ img }}" alt="{{ img_caption }}">
<figcaption>{{ img_caption }}</figcaption>
</figure>
{{ elseif type == 'table_set' }}
<div class="table-responsive">
<table class="table">
{{ table }}
{{ if first AND first_row_hdr }}
<thead>
<tr class="tr-{{ index }}">
{{ cells }}
<th class="th-{{ index }} th-total-{{ total_results }}">{{ value }}</th>
{{ /cells }}
</tr>
</thead>
<tbody>
{{ /if }}
{{ if !first AND first_row_hdr || !first_row_hdr }}
{{ if first }}
<tbody>
{{ /if }}
<tr class="tr-{{ index }}">
{{ cells }}
<td class="td-{{ index }} td-total-{{ total_results }}">{{ value }}</td>
{{ /cells }}
</tr>
{{ if last }}
</tbody>
{{ /if }}
{{ /if }}
{{ /table }}
</table>
</div>
<!--<p><a href="#top" class="btn btn-default">Back to top <i class="fa fa-angle-up"></i></a></p>-->
{{ elseif type == 'file_list_set' }}
<ul>
{{ file_list }}
<li><a href="{{ file }}" target="_blank">{{ description }}</a></li>
{{ /file_list }}
</ul>
{{ elseif type == 'faq_set' }}
<h2 id="{{ faq_title|slugify }}-faq">{{ faq_title }}</h2>
<ul class="list-unstyled list-faq">
{{ faq_list }}
<li class="s-append-btm">
<h3 class="s-lowercase">{{ faq_question }}</h3>
{{ faq_answer }}
<hr/>
</li>
{{ /faq_list }}
</ul>
<!--<p><a href="#top" class="btn btn-default">Back to top <i class="fa fa-angle-up"></i></a></p>-->
{{ elseif type == 'embed_set' }}
<div class="embed-responsive embed-responsive-16by9 s-append-btm">{{ embed }}</div>
{{ elseif type == 'directory_set' }}
{{ directory_list }}
<div class="row s-directory-block s-append-btm">
<div class="col-sm-3 col-md-2">
<img class="img-responsive" src="{{ photo }}" alt="{{ name }}">
</div>
<div class="col-sm-9 col-md-10">
<h2>{{ name }}</h2>
{{ description }}
{{ if phone or email }}
<ul>
<li>Phone: {{ phone }}</li>
<li>Email: {{ email|link|obfuscate }}</li>
</ul>
{{ /if }}
</div>
</div>
{{ /directory_list }}
{{ /if }}
{{ /standard_content }}
{{ if !standard_content }}
<p>Pages within this section:</p>
<ul>
{{ nav from="/{ segment_1 }" max_depth="2" exclude="disclaimer" }}
<li class="{{ if is_current }}active{{ endif }}"><a href="{{ url }}">{{ title }}</a></li>
{{ if !children }}
{{ else }}
<li class="dropdown {{ if is_current }} active {{ endif }}">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ title }} <b class="caret"></b></a>
<ul class="dropdown-menu">
{{ children }}
<li><a href="{{ url }}">{{ title }}</a></li>
{{ /children }}
</ul>
</li>
{{ endif }}
{{ /nav }}
</ul>
{{ /if }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment