Skip to content

Commit

Permalink
DEMO-111: [Product] - Full view (ezsystems#74)
Browse files Browse the repository at this point in the history
* DEMO-111: [Product] - Full view

https://jira.ez.no/browse/DEMO-111
  • Loading branch information
damianz5 committed Mar 21, 2018
1 parent c3ac4de commit 2f9e75e
Show file tree
Hide file tree
Showing 15 changed files with 429 additions and 0 deletions.
135 changes: 135 additions & 0 deletions app/Resources/views/themes/tastefulplanet/full/product.html.twig
@@ -0,0 +1,135 @@
{% extends "@ezdesign/pagelayout.html.twig" %}

{% block page_head %}
{% set title = ez_content_name(content) ~ " - " ~ content.contentInfo.publishedDate|localizeddate('short', 'short', app.request.locale) %}
{{ parent() }}
{% endblock %}

{% block content %}
{% include '@ezdesign/parts/product_modal_dialog.html.twig' %}

<section class="content-type-product full-view">
<div class="breadcrumb">
<div class="container">
<a href="{{ path( ezpublish.rootLocation() ) }}">{{ ez_content_name(ezpublish.rootLocation().contentInfo) }}</a> &gt;
<a href="{{ path('ez_urlalias', {locationId: location.parentLocationId}) }}">{{ ez_content_name(app_content_info_by_location_id(location.parentLocationId)) }}</a> &gt;
<a class="product" href="{{ path('ez_urlalias', {locationId: location.id}) }}">{{ ez_content_name(content) }}</a>
</div>
</div>
<div class="container product-main">
<div class="row">
<div class="col-md-7 product-main-image">
{% if not ez_is_field_empty(content, 'image') %}
{{ ez_render_field(content, 'image', {
'parameters': {
'alias': 'product_large',
'class': 'img-responsive'
}
}) }}
{% endif %}
</div>
<div class="col-md-5">
<div class="product-main-title">
<h2>{{ ez_content_name(content) }}</h2>
</div>
<div class="row product-main-details">
<div class="col-md-4 product-main-price">$ {{ ez_field_value(content, 'price').value|number_format(2, '.') }}</div>
<div class="col-md-3 product-main-serving">
<div class="product-main-serving-icon"></div>
<div class="serving-label">
{{ ez_render_field(content, 'serving') }} {{ 'servings'|trans }}
</div>
</div>
<div class="col-md-5 product-main-spicy">
{% set spicy_level = ez_field_value(content, 'spicy').selection.0 %}
<div class="spicy-label">{{ 'Spicy Level:'|trans }}</div>
{% for level in 1..spicy_level %}
<div class="product-main-spicy-pepper"></div>
{% endfor %}
</div>
</div>
<div class="product-main-description">
{{ ez_render_field(content, 'description') }}
</div>
<div class="product-main-add">
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#addModal">
<i class="fa fa-shopping-basket fa-lg"></i> {{ 'Add to cart'|trans }}
</button>
</div>
<div class="product-dietary-list">
<h3>{{ 'Dietary restrictions'|trans }}</h3>
{% if ez_field_value(content, 'dairy').bool %}
<div class="product-main-dietary">
<div class="product-main-dietary-icon product-main-dietary-dairy-icon"></div> {{ 'Dairy'|trans }}
</div>
{% endif %}

{% if ez_field_value(content, 'egg').bool %}
<div class="product-main-dietary">
<div class="product-main-dietary-icon product-main-dietary-egg-icon"></div> {{ 'Egg'|trans }}
</div>
{% endif %}

{% if ez_field_value(content, 'nuts').bool %}
<div class="product-main-dietary">
<div class="product-main-dietary-icon product-main-dietary-nuts-icon"></div> {{ 'Nuts'|trans }}
</div>
{% endif %}

{% if ez_field_value(content, 'gluten').bool %}
<div class="product-main-dietary">
<div class="product-main-dietary-icon product-main-dietary-gluten-icon"></div> {{ 'Gluten'|trans }}
</div>
{% endif %}

{% if ez_field_value(content, 'seafood').bool %}
<div class="product-main-dietary">
<div class="product-main-dietary-icon product-main-dietary-seafood-icon"></div> {{ 'Seafood'|trans }}
</div>
{% endif %}
</div>
</div>
</div>
<div class="col-md-12 product-main-info">
<ul class="nav nav-tabs nav-justified">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#ingredients" role="tab">{{ 'Ingredients'|trans }}</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#instructions" role="tab">{{ 'Cooking instructions'|trans }}</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade in show active" id="ingredients" role="tabpanel">
<div class="product-main-ingredients">
{{ ez_render_field(content, 'ingredients') }}
</div>
</div>
<div class="tab-pane fade" id="instructions" role="tabpanel">
<div class="product-main-instruction">
{{ ez_render_field(content, 'cooking_instructions') }}
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 content-tags">
<span class="tags-label">Tags</span>
<div class="tags-list">
{{ ez_render_field(content, 'tags') }}
</div>
</div>
<div class="col-md-6 content-share">
<span class="share-buttons-label">Share</span>
<div class="share-buttons-list">
{% set url = url(location) %}
{% set title = ez_content_name(content)|url_encode %}
<a href="https://twitter.com/intent/tweet?original_referer={{ url }}&amp;atext={{ title }}&amp;url={{ url }}&amp;via=ezsystems" target="_blank">Twitter</a>
<a href="https://www.facebook.com/sharer/sharer.php?s=100&amp;p[url]={{ url }}&amp;p[title]={{ title }}" target="_blank">Facebook</a>
<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url={{ url }}&amp;title={{ title }}" target="_blank">LinkedIn</a>
</div>
</div>
</div>
</div>
</section>
{% endblock %}
@@ -0,0 +1,18 @@
<div class="modal fade" tabindex="-1" role="dialog" id="addModal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">{{ 'Hungry?'|trans }}</h4>
</div>
<div class="modal-body">
<p>{{ 'This is a bittersweet moment. This is a demo site, but we are happy we made you feel hungry.' }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'Close'|trans }}</button>
</div>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions app/config/ezplatform.yml
Expand Up @@ -103,6 +103,7 @@ assetic:
- 'assets/css/folder.css'
- 'assets/css/place.css'
- 'assets/css/place_list.css'
- 'assets/css/product.css'
- 'assets/css/blog.css'
- 'assets/css/blog_post.css'
- 'assets/css/subscribe.css'
4 changes: 4 additions & 0 deletions app/config/image_variations.yml
Expand Up @@ -15,3 +15,7 @@ ezpublish:
reference: null
filters:
- {name: geometry/scaleexact, params: [505, 400]}
product_large:
reference: null
filters:
- {name: geometry/scaleexact, params: [633, 500]}
5 changes: 5 additions & 0 deletions app/config/services.yml
Expand Up @@ -49,3 +49,8 @@ services:
- '@templating'
- '%app.contact_form.sender_email%'
- '%app.contact_form.recipient_email%'

app.twig.content_info_by_location_id_extension:
class: AppBundle\Twig\ContentInfoByLocationIdExtension
arguments:
- '@ezpublish.api.service.location'
5 changes: 5 additions & 0 deletions app/config/views.yml
Expand Up @@ -80,6 +80,11 @@ ezpublish:
match:
Identifier\ContentType: [subscribe]

product:
template: "@ezdesign/full/product.html.twig"
match:
Identifier\ContentType: [product]

home:
place_list:
controller: 'ez_query:ContentQueryAction'
Expand Down
62 changes: 62 additions & 0 deletions src/AppBundle/Twig/ContentInfoByLocationIdExtension.php
@@ -0,0 +1,62 @@
<?php
/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace AppBundle\Twig;

use eZ\Publish\API\Repository\Values\Content\ContentInfo;
use Twig_Extension;
use Twig_SimpleFunction;
use eZ\Publish\API\Repository\LocationService as LocationServiceInterface;

/**
* Twig helper for fetching ContentInfo Based on Location Id.
*/
class ContentInfoByLocationIdExtension extends Twig_Extension
{
/** var \eZ\Publish\API\Repository\LocationService */
private $locationService;

/**
* @param \eZ\Publish\API\Repository\LocationService $locationService
*/
public function __construct(LocationServiceInterface $locationService)
{
$this->locationService = $locationService;
}

/**
* Returns the name of the extension.
*
* @return string the extension name
*/
public function getName()
{
return 'app.content_info';
}

/**
* Returns a list of functions to add to the existing list.
*
* @return array
*/
public function getFunctions()
{
return [
new Twig_SimpleFunction('app_content_info_by_location_id', [$this, 'contentInfoByLocationId']),
];
}

/**
* Return ContentInfo based on Location Id
*
* @param $locationId int
*
* @return ContentInfo
*/
public function contentInfoByLocationId($locationId)
{
return $this->locationService->loadLocation($locationId)->getContentInfo();
}
}

0 comments on commit 2f9e75e

Please sign in to comment.