Skip to content

Instantly share code, notes, and snippets.

View dfritschy's full-sized avatar

Donat Fritschy dfritschy

View GitHub Profile
@dfritschy
dfritschy / Build download link for a file field
Created November 7, 2013 17:46
This snippet builds the download link for a file field (formerly attribute) of the current content object
@dfritschy
dfritschy / file.html.twig
Created October 18, 2013 14:05
TWIG embed template for files, corresponding override rules
{# Embed File View
{{ ez_render_field( content, 'file') }} would be easier, but renders the file name instead of the object name
#}
<div class="content-view-embed">
{% if content.fields['file'] is defined %}
{% set uri = 'content/download/' ~ content.contentInfo.id ~ '/' ~ content.getField('file').id
~ '/version/' ~ content.contentInfo.currentVersionNo ~ "/file/"
~ content.getField('file').value.fileName|escape( 'url' ) %}
@dfritschy
dfritschy / file.tpl
Created October 18, 2013 09:18
for Jérôme: site_xxx/design/xxx/override/templates/embed
{* File - List embed view *}
<div class="content-view-embed">
<div class="class-file">
{if $object.data_map.file.has_content}
{def $file = $object.data_map.file}
<div class="content-body attribute-{$file.content.mime_type_part}">
<a href={concat("content/download/", $file.contentobject_id, "/", $file.id, "/file/", $file.content.original_filename)|ezurl}>{$object.name|wash("xhtml")}</a> {*$file.content.filesize|si(byte)*}
</div>
{undef $file}
{else}
@dfritschy
dfritschy / override.yml
Created October 18, 2013 09:15
for Jérôme
# We explicitly prepend config for "ezpublish" namespace in service container extension,
# so no need to repeat it here
system:
drucknatuer_user:
location_view:
full:
full_ps_produkt:
template: WebmanufakturSiteDruckformBundle:full:ps_produkt.html.twig
match:
Identifier\ContentType: ps_produkt
@dfritschy
dfritschy / config.yml
Created October 18, 2013 09:14
for Jérôme...
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
esi: ~
translator: { fallback: %locale_fallback% }
# The secret parameter is used to generate CSRF tokens
secret: %secret%
router:
@dfritschy
dfritschy / MyController.php
Created September 17, 2013 14:42
eZ Publish 5: Is this a viable pattern for handling sub-items of a content object, for example children of a folder?
/**
* Renders sub-items of the current location
*
* TODO: add content type filtering, and possibly more
* TODO: add template to be used for rendering
*
* @param int $locationId
* @return \Symfony\Component\HttpFoundation\Response
*/
public function subItemsAction( $locationId )