Skip to content

Instantly share code, notes, and snippets.

@sudomaxime
Created January 29, 2019 18:40
Show Gist options
  • Save sudomaxime/6dde053f5966051ba1059898206b6c67 to your computer and use it in GitHub Desktop.
Save sudomaxime/6dde053f5966051ba1059898206b6c67 to your computer and use it in GitHub Desktop.
feilds : Page / docs
<?php
namespace Adapt\Fields;
function make_doc () {
$category = array(
'name' => 'category_doc',
'key' => 'category_doc',
'type' => 'text',
'label' => 'Catégorie',
);
$intro_text = array(
'name' => 'intro_text_doc',
'key' => 'intro_text',
'type' => 'text',
'label' => 'Text d\'intro',
);
$name = array(
'name' => 'name_doc_repeater_doc',
'key' => 'name_doc_repeater_doc',
'type' => 'text',
'label' => 'Nom du document',
);
$link = array(
'name' => 'link_doc_repeater_doc',
'key' => 'link_doc_repeater_doc',
'type' => 'file',
'label' => 'Fichier',
);
$video = array (
'name' => 'video_doc_repeater_doc',
'key' => 'video_doc_repeater_doc',
'type' => 'url',
'label' => 'Lien video youtube',
);
$categories = array(
'name' => 'categories',
'key' => 'categories',
'type' => 'post_object',
'label' => 'Utilisateurs',
'multiple' => '1',
'ui' => '1',
'post_type' => 'user',
'return_format' => 'id'
);
$repeater = array (
'name' => 'doc_list1',
'key' => 'doc_list1',
'type' => 'repeater',
'label' => 'Liste des documents',
'layout' => 'block',
'sub_fields' => array (
$name,
$link,
$video
)
);
$repeater1 = array (
'name' => 'cat_list_doc',
'key' => 'cat_list_doc',
'type' => 'repeater',
'label' => 'Liste de catégories',
'layout' => 'block',
'sub_fields' => array (
$category,
$intro_text,
$repeater,
$categories
)
);
$location = array ([
'param' => 'post_type',
'operator' => '==',
'value' => 'doc'
]);
return array (
'title' => 'Éléments',
'location' => array(
$location
),
'fields' => array (
$repeater1
)
);
}
----------------------------------
sub-category.twig
{% extends "base.twig" %}
{% block content %}
{% include 'module-header-doc.twig' %}
{% include 'module-hero.twig' %}
<div class="container-inset container-ouset">
<div class="container-fluid">
<div class="row justify-content-between">
{% include 'sidebar.twig' %}
<div class="col-12 col-lg-8 about-text-body">
{% for item_outer2 in post.meta('cat_list_doc') %}
{% if cookie in item_outer2.categories %}
<div class=" mb-5" id="{{item_outer2.category_doc|sanitize}}">
<div class="doc_info">
<h4 class="text-dark mb-3">{{item_outer2.category_doc}}</h4>
<p>{{item_outer2.intro_text_doc}}</p>
{% for item_inner2 in item_outer2.doc_list1 %}
{% if item_inner2.video_doc_repeater_doc|length %}
<div class="doc col-12 d-sm-flex align-items-center">
<i class="fas fa-video mr-3"></i> <p>{{item_inner2.name_doc_repeater_doc}}</p>
<span class="wrap-doc ml-auto">
<a target="_blank" href="{{ item_inner2.video_doc_repeater_doc }}" class="text-dark"><i class="fas fa-eye"></i></a>
</span>
</div>
{% else %}
<div class="doc col-12 d-sm-flex align-items-center">
<i class="fas fa-file-pdf mr-3"></i> <p>{{item_inner2.name_doc_repeater_doc}}</p>
<span class="wrap-doc ml-auto">
<a href="{{ item_inner2.link_doc_repeater_doc.url }}" class="mr-4 text-dark"><i class="fas fa-eye"></i></a>
<a href="{{ item_inner2.link_doc_repeater_doc.url }}" download class="mr-2 text-dark"><i class="fas fa-download" download></i></a>
</span>
</div>
{% endif %}
{% endfor %}
</div><!-- fin doc_info-->
</div><!-- fin col-12-->
{% endif %}
{% endfor %}
</div>
</div>
</div>
</div>
{% endblock %}
-----------------------------
bundle.scss
.doc-links {
padding: 15px;
padding-left: 25px;
cursor: auto;
background-color: #E3E9F2;
.card-body {
padding: 0px;
}
h5 {
text-transform: uppercase !important;
font-weight: 700;
font-size: 16px;
}
}
-----------------------------
single-doc.twig
{% extends "base.twig" %}
{% block content %}
{% include 'module-header-doc.twig' %}
{% include 'module-hero.twig' %}
<div class="container-inset container-ouset">
<div class="container-fluid">
<div class="row justify-content-between">
{% include 'sidebar.twig' %}
<div class="col-12 col-lg-8 about-text-body">
<h3 class="text-dark mb-3">{{ post.title }}</h3>
{{ post.content }}
{% for parent_page in sidebar_links %}
{% if parent_page.childs|length %}
{% if parent_page.ID == post.id %}
{% for child_page in parent_page.childs %}
<div class="card doc-links">
<div class="card-body">
<div class="row align-items-center">
<div class="col-12 col-md-6 text-center text-md-left">
<h5 class="mb-4 mb-md-0">
{{ child_page.post_title }}
</h5>
</div>
<div class="col-12 col-md-6 text-center text-md-right">
<a class="btn btn-dark" href="{{ function('get_permalink', child_page.ID) }}" class="text-dark">Voir catégorie</a>
</div>
</div>
</div>
</div>
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
</div>
</div>
</div>
</div>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment