Created
February 14, 2018 07:28
-
-
Save wiratama/234fe9f65d696713b1c32b69e49d13af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
public function itemproductAction(Request $request) | |
{ | |
$contentId = $request->get('content_id'); | |
$categoryId = $request->get('category_id'); | |
$isDefault = $request->get('is_default', false); | |
$isMini = $request->get('is_mini', false); | |
$category = null; | |
if (!empty($categoryId)) { | |
$category = $this->getCategoryManager()->getCategoryById($categoryId); | |
} | |
$content = null; | |
if ($contentManager = $this->getContentManager()) { | |
$content = $contentManager->getCacheContent($contentId); | |
} | |
if ($content) { | |
//$itemTemplate = sprintf("MoventContentBundle:Content/Layout/base/list%s:item.html.twig", ($isMini?'/mini':'')); | |
$itemTemplate = "MoventContentBundle:Content/Layout/base/list:itemproduct.html.twig"; | |
$response = $this->render($itemTemplate, | |
array( | |
'item' => $content, | |
'category' => $category, | |
'isDefault' => $isDefault, | |
'isMini' => $isMini | |
) | |
); | |
$response->setSharedMaxAge(600); | |
$response->setPublic(); | |
return $response; | |
} | |
// throw not found exception | |
throw new NotFoundHttpException(sprintf("Content '%s' cannot be found!",$contentId)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set CategoryCacheConfigPath = 'Movent\\CategoryBundle\\Services\\CategoryConfig' %} | |
{% set ContentEntityPath = 'Movent\\ContentBundle\\Entity\\Content' %} | |
{% if item.contentType == constant(ContentEntityPath ~ '::TYPE_ARTICLE') %} | |
{% set typeFileName = 'article' %} | |
{% set typeLabel = 'Article' %} | |
{% elseif item.contentType == constant(ContentEntityPath ~ '::TYPE_RECIPE') %} | |
{% set typeFileName = 'recipe' %} | |
{% set typeLabel = 'Recipe' %} | |
{% elseif item.contentType == constant(ContentEntityPath ~ '::TYPE_PRODUCT') %} | |
{% set typeFileName = 'product' %} | |
{% set typeLabel = 'Product' %} | |
{% endif %} | |
{% if category %} | |
{% set categoryId = category.id %} | |
{#<!-- Default context -->#} | |
{% if isDefault is defined and isDefault %} | |
{% if item.defaultCategory %} | |
{#<!-- get category children from cache if any --> #} | |
{% set childrenCat = movent_category_cached_config(categoryId, constant(CategoryCacheConfigPath ~ '::PROP_CAT_CHILDREN')) %} | |
{% set childrenCat = childrenCat|merge([categoryId]) %} | |
{#<!-- make sure that this default category is the current category or part of its children -->#} | |
{% if item.defaultCategory.id not in childrenCat %} | |
{#<!-- force to use the current category instead -->#} | |
{% set url = movent_content_slug_path(item.slug, category, true) %} | |
{% else %} | |
{#<!-- set url to the default category -->#} | |
{% set url = movent_content_slug_path(item.slug, item.defaultCategory, true) %} | |
{% endif %} | |
{% else %} | |
{#<!-- set url to the canonical instead -->#} | |
{% set url = movent_content_slug_path(item.slug, null, true) %} | |
{#<!-- use default layout -->#} | |
{% set categoryId = 0 %} | |
{% endif %} | |
{% else %} | |
{#<!-- set url to the current category -->#} | |
{% set url = movent_content_slug_path(item.slug, category, true) %} | |
{% endif %} | |
{% else %} | |
{% set categoryId = 0 %} | |
{#<!-- set url to the canonical instead -->#} | |
{% set url = movent_content_slug_path(item.slug, null, true) %} | |
{% if isDefault is defined and isDefault %} | |
{% if item.defaultCategory %} | |
{% set categoryId = item.defaultCategory.id %} | |
{% set url = movent_content_slug_path(item.slug, item.defaultCategory, true) %} | |
{% endif %} | |
{% endif %} | |
{% endif %} | |
{% if isMini is defined and isMini %} | |
{% set miniPath = '/mini' %} | |
{% else %} | |
{% set miniPath = '' %} | |
{% endif %} | |
{% set catTitle = movent_category_cached_config(categoryId, constant(CategoryCacheConfigPath ~ '::PROP_CAT_TITLE')) %} | |
{% set icon_path_hover = movent_category_cached_config(categoryId, constant(CategoryCacheConfigPath ~ '::PROP_CAT_ICON_23x23_HOVER')) %} | |
{% set desktop_banner = movent_category_cached_config(categoryId, constant(CategoryCacheConfigPath ~ '::PROP_CAT_BANNER_DESKTOP')) %} | |
{% set mobile_banner = movent_category_cached_config(categoryId, constant(CategoryCacheConfigPath ~ '::PROP_CAT_BANNER_MOBILE')) %} | |
{% set backgroundColor = movent_category_cached_config(categoryId, constant(CategoryCacheConfigPath ~ '::PROP_CAT_COLOR1')) %} | |
{% set layoutName = movent_category_cached_config(categoryId, constant(CategoryCacheConfigPath ~ '::PROP_CAT_LAYOUT_NAME')) %} | |
{% set contentTemplate = "MoventContentBundle:Content/Layout/default/%s/list%s:%s.html.twig"|format(layoutName, miniPath, typeFileName) %} | |
{% set defaultTemplate = "MoventContentBundle:Content/Layout/default/Default/list%s:%s.html.twig"|format(miniPath,typeFileName) %} | |
{% set baseTemplate = "MoventContentBundle:Content/Layout/base/list%s:base.html.twig"|format(miniPath) %} | |
{# <!-- Fallback template hierarchy --> #} | |
{% include [contentTemplate, defaultTemplate, baseTemplate] ignore missing with { category:category } %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'MoventContentBundle:Content/Layout/base:base.html.twig' %} | |
{% block content %} | |
{% include "MoventSiteBundle:Social:socialinit.html.twig" %} | |
<div class="main innerpage"> | |
<div class="wrapper-center"> | |
<div id="product-{{ object.id }}" class="productdetail"> | |
<div class="recipe-header-breadcrumbs"> | |
{{ sonata_block_render_event('breadcrumb', { 'context': 'content_view', 'category': category}) }} | |
</div> | |
<div class="productmain"> | |
<div class="productimage"> | |
<img class="main" alt="{{ object.imageMainLabel|raw }}" src="{{ movent_media_public_url(object.imageMain, 'image_395x527') }}" /> | |
{% if object.productGallery and object.productGallery|length >= 1 %} | |
<div class="productThumbs"> | |
<img alt="{{ object.imageMainLabel|raw }}" data-large="{{ movent_media_public_url(object.imageMain, 'image_395x527') }}" src="{{ movent_media_public_url(object.imageMain, 'image_113x151') }}" /> | |
{% set gallery = object.productGallery %} | |
{% set index = 1 %} | |
{% for image in gallery.galleryHasMedias if index < 3 %} | |
<img alt="{{ object.imageMainLabel|raw }}" data-large="{{ movent_media_public_url(image.media, 'image_395x527') }}" src="{{ movent_media_public_url(image.media, 'image_113x151') }}" /> | |
{% set index = index + 1 %} | |
{% endfor %} | |
</div> | |
{% endif %} | |
</div> | |
<div class="fleft-500px"> | |
<div class="productinfo"> | |
<h1>{{ object.title }}</h1> | |
{% if object.buyNowId is not null %} | |
<a data-sku-id="{{ object.buyNowId }}" class="productViewBuyNow buynow-btn"><span class="test">Beli Sekarang</span></a> | |
{% endif %} | |
{{ object.abstract }} | |
<div class="productBtnbox"> | |
{% if object.imageNutritionFact %} | |
<a href="{% path object.imageNutritionFact, 'reference' %}" class="infomasi">Informasi gizi</a> | |
{% endif %} | |
</div> | |
</div> | |
{#<div class="resellerbox"> | |
{% if object.productProductReseller|length %} | |
<h1>Reseller</h1> | |
<ul> | |
{% for reseller in object.productProductReseller %} | |
<li> | |
<!--<span class="resellerprice">Rp {{ priceFeed(reseller.priceFeed) }}</span>--> | |
<div class="resellerthumb"> | |
<img src="{{ movent_media_public_url(reseller.image, 'image_115x115') }}" /> | |
</div> | |
<div class="resellerinfo"> | |
<h2>{{ reseller.name }}</h2> | |
<p>{{ reseller.description }}</p> | |
{% if reseller.isPromo %} | |
<a href="{{ reseller.url }}" target="_blank" class="belisekarangpromo"></a> | |
{% else %} | |
<a href="{{ reseller.url }}" target="_blank" class="belisekarang"></a> | |
{% endif %} | |
</div> | |
</li> | |
{% endfor %} | |
</ul> | |
{% endif %} | |
</div>#} | |
</div> | |
{{ sonata_block_render({ 'type': 'relatedproduct.block.service' }, { | |
'itemId': object.id, 'maxItem': 4, 'relatedTo': contentType | |
}) }} | |
</div> | |
{% if object.allowComment %} | |
<div class="fbcommentbox"> | |
{% include "MoventContentBundle:Content/Layout/base:comment.html.twig" with {'width' : '857' } %} | |
</div> | |
{% endif %} | |
</div> | |
</div> | |
</div> | |
{% endblock content %} | |
{% block site_footer_scripts %} | |
{{ parent() }} | |
<script type="text/javascript"> | |
//<![CDATA[ | |
jQuery(document).ready(function($){ | |
$(".infomasi").fancybox(); | |
{#var buy_now = $(".productViewBuyNow"); | |
var lightbox = null; | |
if (buy_now.length) { | |
lightbox = new fusepump.lightbox.buynow(buy_now.attr('data-buynow-id')); | |
buy_now.click(function(e) { | |
e.preventDefault(); | |
lightbox.show(); | |
}); | |
}#} | |
$(".productThumbs img").click(function(){ | |
$(".productThumbs img").removeClass("active"); | |
$(this).addClass("active"); | |
$(".productimage img.main").attr('src',$(this).data('large')); | |
}); | |
}); | |
//]]> | |
</script> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{#{% include is_mobile() ? "MoventContentBundle:Content/Layout/default/Product/list:product.mobile.html.twig" : "MoventContentBundle:Content/Layout/default/Product/list:product.desktop.html.twig" %}#} | |
{% include "MoventContentBundle:Content/Layout/default/Product/list:productbaru.desktop.html.twig" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% block content %} | |
<div class="item" style="float:left;width: 200px;"> | |
<div class="mov-related-products_image"> | |
<img style="width:50%;" alt="{{ item.imageMainLabel|raw }}" src="{{ movent_media_public_url(item.imageMain, 'image_113x151') }}" /> | |
</div> | |
<h4>{{ item.title|raw|truncate(14, false, ' …') }}</h4> | |
<p>{{ item.abstract|raw|truncate(80, true, ' …') }}</p> | |
<div class="relatedProduct_buttons"> | |
<p><a href="{{ url }}" class="tab-link" style="background:red;">{{"Selengkapnya"|trans}}</a> | |
{% if item.buyNowId is not null %} | |
<a data-sku-id="{{ item.buyNow }}" class="productViewBuyNow tab-link buy-now-button buynow-btn" style="background:red;"> {{"Beli Sekarang"|trans}}</a></p> | |
{% endif %} | |
</div> | |
</div> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
path