Skip to content

Commit

Permalink
Implementing Tours custom post page
Browse files Browse the repository at this point in the history
  • Loading branch information
Michel Moraes committed Sep 18, 2018
1 parent aac4bf3 commit 6c9fd94
Show file tree
Hide file tree
Showing 18 changed files with 225 additions and 79 deletions.
60 changes: 60 additions & 0 deletions app/config/wp/custom-posts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

// Register Custom Post Type Tour
// Post Type Key: tour
function create_tour_cpt() {

$labels = array(
'name' => __( 'Tours', 'Post Type General Name', 'base-camp' ),
'singular_name' => __( 'Tour', 'Post Type Singular Name', 'base-camp' ),
'menu_name' => __( 'Tours', 'base-camp' ),
'name_admin_bar' => __( 'Tour', 'base-camp' ),
'archives' => __( 'Tour Archives', 'base-camp' ),
'attributes' => __( 'Tour Attributes', 'base-camp' ),
'parent_item_colon' => __( 'Parent Tour:', 'base-camp' ),
'all_items' => __( 'All Tours', 'base-camp' ),
'add_new_item' => __( 'Add New Tour', 'base-camp' ),
'add_new' => __( 'Add New', 'base-camp' ),
'new_item' => __( 'New Tour', 'base-camp' ),
'edit_item' => __( 'Edit Tour', 'base-camp' ),
'update_item' => __( 'Update Tour', 'base-camp' ),
'view_item' => __( 'View Tour', 'base-camp' ),
'view_items' => __( 'View Tours', 'base-camp' ),
'search_items' => __( 'Search Tour', 'base-camp' ),
'not_found' => __( 'Not found', 'base-camp' ),
'not_found_in_trash' => __( 'Not found in Trash', 'base-camp' ),
'featured_image' => __( 'Featured Image', 'base-camp' ),
'set_featured_image' => __( 'Set featured image', 'base-camp' ),
'remove_featured_image' => __( 'Remove featured image', 'base-camp' ),
'use_featured_image' => __( 'Use as featured image', 'base-camp' ),
'insert_into_item' => __( 'Insert into Tour', 'base-camp' ),
'uploaded_to_this_item' => __( 'Uploaded to this Tour', 'base-camp' ),
'items_list' => __( 'Tours list', 'base-camp' ),
'items_list_navigation' => __( 'Tours list navigation', 'base-camp' ),
'filter_items_list' => __( 'Filter Tours list', 'base-camp' ),
);
$args = array(
'label' => __( 'Tour', 'base-camp' ),
'description' => __( 'Tours', 'base-camp' ),
'labels' => $labels,
'menu_icon' => 'dashicons-location-alt',
'supports' => array('title', 'editor', 'thumbnail', 'revisions', 'trackbacks', 'page-attributes', ),
'taxonomies' => array(),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 10,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => false,
'hierarchical' => false,
'exclude_from_search' => false,
'show_in_rest' => true,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'tour', $args );

}
add_action( 'init', 'create_tour_cpt', 0 );
10 changes: 10 additions & 0 deletions front-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@

$context['is_front_page'] = true;

$args = array(
'post_type' => 'tour',
'posts_per_page' => -1,
'orderby' => array(
'date' => 'DESC'
)
);

$context['tours'] = Timber::get_posts( $args );

Timber::render('front-page.twig', $context);
21 changes: 17 additions & 4 deletions resources/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,26 @@ new Vue({
}
]
},
};
slickOptionsTour: {
dots: true,
arrows: false,
fade: false,
autoplay: true,
slidesToShow: 1,
slidesToScroll: 1,
infinite: true,
appendDots: '.slick__dots',
focusOnSelect: false,
swipeToSlide: false,
touchThreshold: 50,
}
}
}
});
})

// Hide Page Loader when DOM and images are ready
$(window).on('load', () => $('.pageloader').removeClass('is-active'));
$(window).on('load', () => $('.pageloader').removeClass('is-active'))

// Toggle mobile menu
$('.navbar-burger').on('click', () =>
$('.navbar-burger, .navbar-menu').toggleClass('is-active'));
$('.navbar-burger, .navbar-menu').toggleClass('is-active'))
14 changes: 14 additions & 0 deletions resources/assets/sass/_common.sass
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,17 @@ body
font-size: 24px
color: $gray-dark
letter-spacing: 0.86px

.content
h2, h3
text-transform: uppercase
letter-spacing: 1px

h2
color: $blue
font-weight: 700

.single-tour__content
.slick__dots
text-align: center
margin-left: 0
68 changes: 1 addition & 67 deletions resources/views/front-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -53,76 +53,10 @@
<div class="container">
<div class="section-tours__headline has-text-centered">Rio de Janeiro Tours</div>

<div class="section-tours__cards">

<slick ref="slick" :options="slickOptions">
<div class="column">
<div class="section-tours__card">
<div class="section-tours__header" style="background-image: url('{{ theme.link }}/resources/assets/images/placeholder-tours-01.jpg')">
<div class="section-tours__card-title">Lorem Ipsum</div>
</div>
<div class="section-tours__footer">
<div class="section-tours__card-copy">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</div>
<a href="" class=" section-tours__card-cta">Read More</a>
</div>
</div>
</div>
<div class="column">
<div class="section-tours__card">
<div class="section-tours__header" style="background-image: url('{{ theme.link }}/resources/assets/images/placeholder-tours-02.jpg')">
<div class="section-tours__card-title">Lorem Ipsum</div>
</div>
<div class="section-tours__footer">
<div class="section-tours__card-copy">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</div>
<a href="" class=" section-tours__card-cta">Read More</a>
</div>
</div>
</div>
<div class="column">
<div class="section-tours__card">
<div class="section-tours__header" style="background-image: url('{{ theme.link }}/resources/assets/images/placeholder-tours-03.jpg')">
<div class="section-tours__card-title">Lorem Ipsum</div>
</div>
<div class="section-tours__footer">
<div class="section-tours__card-copy">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</div>
<a href="" class=" section-tours__card-cta">Read More</a>
</div>
</div>
</div>
<div class="column">
<div class="section-tours__card">
<div class="section-tours__header" style="background-image: url('{{ theme.link }}/resources/assets/images/placeholder-tours-03.jpg')">
<div class="section-tours__card-title">Lorem Ipsum</div>
</div>
<div class="section-tours__footer">
<div class="section-tours__card-copy">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</div>
<a href="" class=" section-tours__card-cta">Read More</a>
</div>
</div>
</div>
<div class="column">
<div class="section-tours__card">
<div class="section-tours__header" style="background-image: url('{{ theme.link }}/resources/assets/images/placeholder-tours-01.jpg')">
<div class="section-tours__card-title">Lorem Ipsum</div>
</div>
<div class="section-tours__footer">
<div class="section-tours__card-copy">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</div>
<a href="" class=" section-tours__card-cta">Read More</a>
</div>
</div>
</div>

</slick>

</div>
<div class="slick__dots"></div>
{% include 'partials/tours-carousel.twig' %}
</div>
</section>





<section class="section-about section">
<div class="container wrapper">
<div class="columns">
Expand Down
30 changes: 30 additions & 0 deletions resources/views/partials/tours-carousel.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

<div class="section-tours__cards">

<slick ref="slick" :options="slickOptions">

{% for tour in tours %}

{% set tour_featured_image = TimberImage(tour.thumbnail) %}

<div class="column">
<a href="{{ tour.link }}">
<div class="section-tours__card">
<div class="section-tours__header"
style="background-image: url('{{ tour_featured_image.src|resize(640)}}')">
<div class="section-tours__card-title">{{ tour.title }}</div>
</div>
<div class="section-tours__footer">
<div class="section-tours__card-copy">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</div>
<a href="{{ tour.link }}" class=" section-tours__card-cta">Read More</a>
</div>
</div>
</a>
</div>

{% endfor %}

</slick>

</div>
<div class="slick__dots"></div>
37 changes: 37 additions & 0 deletions resources/views/single-tour.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% extends "base.twig" %}

{% block content %}

<section class="section">
<div class="container">

<div class="columns is-desktop">
<div class="column is-three-fifths-desktop">
<article class="single-tour__content content">

{% if tour_gallery %}
<slick ref="slick" :options="slickOptionsTour">

{% for image in tour_gallery %}
<img src="{{ image.url }}" alt="{{ image.alt}}">
{% endfor %}

</slick>
<div class="slick__dots"></div>
{% endif %}

<h2 class="">{{ post.full_title}}</h2>
{{ post.content }}
</article>
</div>
<div class="column">
<div class="single-tour__sidebar has-text-centered">
{{ post.book_iframe_code }}
</div>
</div>
</div>

</div>
</section>

{% endblock %}
11 changes: 11 additions & 0 deletions resources/views/template-tours.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "base.twig" %}

{% block content %}

<section class="section-tours section" id="post-{{ post.ID }}">
<div class="container">
{% include 'partials/tours-carousel.twig' %}
</div>
</section>

{% endblock %}
3 changes: 3 additions & 0 deletions single.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
$post = new TimberPost();
$context['post'] = $post;
$context['cancel_link'] = get_cancel_comment_reply_link(__('Cancel reply', 'base-camp'));
$context['tour_gallery'] = get_field('tour_gallery');
$cover_image_id = $post->cover_image;
$context['tours']['cover_image'] = new TimberImage($cover_image_id);

if (post_password_required($post->ID)) {
Timber::render('single-password.twig', $context);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7806,6 +7806,18 @@ body {
color: #595656;
letter-spacing: 0.86px; }

.content h2, .content h3 {
text-transform: uppercase;
letter-spacing: 1px; }

.content h2 {
color: #2376B3;
font-weight: 700; }

.single-tour__content .slick__dots {
text-align: center;
margin-left: 0; }

.woocommerce .products {
clear: both; }

Expand Down
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
16 changes: 9 additions & 7 deletions static/manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"admin.css": "css/admin.4a7e01efaf89bcf71b1f.css",
"admin.js": "js/admin.4a7e01efaf89bcf71b1f.js",
"app.css": "css/app.4a7e01efaf89bcf71b1f.css",
"app.js": "js/app.4a7e01efaf89bcf71b1f.js",
"login.css": "css/login.4a7e01efaf89bcf71b1f.css",
"login.js": "js/login.4a7e01efaf89bcf71b1f.js",
"vendor.js": "js/vendor.4a7e01efaf89bcf71b1f.js",
"admin.css": "css/admin.3e9ac7714c1d128be36f.css",
"admin.js": "js/admin.3e9ac7714c1d128be36f.js",
"app.css": "css/app.3e9ac7714c1d128be36f.css",
"app.js": "js/app.3e9ac7714c1d128be36f.js",
"login.css": "css/login.3e9ac7714c1d128be36f.css",
"login.js": "js/login.3e9ac7714c1d128be36f.js",
"vendor.js": "js/vendor.3e9ac7714c1d128be36f.js",
"images/icon-cart-white.png": "images/icon-cart-white.png",
"images/texture-blue-carnival.jpg": "images/texture-blue-carnival.jpg",
"images/base-camp-logo.png": "images/base-camp-logo.png"
}
20 changes: 20 additions & 0 deletions template-tours.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/*
* Template Name: Tours
*/

$context = Timber::get_context();
$post = new TimberPost();
$context['post'] = $post;

$args = array(
'post_type' => 'tour',
'posts_per_page' => -1,
'orderby' => array(
'date' => 'DESC'
)
);

$context['tours'] = Timber::get_posts( $args );

Timber::render('template-tours.twig', $context);

0 comments on commit 6c9fd94

Please sign in to comment.