Skip to content

Instantly share code, notes, and snippets.

View dfritschy's full-sized avatar

Donat Fritschy dfritschy

View GitHub Profile
@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 )
@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 / 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 / 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 / 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 / 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 / anonymous_user.yml
Created March 6, 2014 14:20
eZ Publish Configuration with different Anonymous Users
ezpublish:
...
system:
...
ftswps_user__com:
anonymous_user_id: 503
languages:
- eng-US
ftswps_user__uk:
anonymous_user_id: 504
@dfritschy
dfritschy / gist:9600062
Created March 17, 2014 14:21
jvEmbed Youtube Custom Tag result
<div class="jvembed jvembed-youtube"><iframe width="560" height="315" src="//www.youtube.com/embed/MfOnq-zXXBw" frameborder="0" allowfullscreen=""></iframe></div>
@dfritschy
dfritschy / DefaultController.php
Created May 28, 2014 12:02
A sample frontpage controller which picks a random banner image from a list of related objects
public function indexAction( $locationId = 2 )
{
$response = new Response;
$response = $this->cacheResponse( $response, $locationId, 10 );
/** @var $repository \eZ\Publish\API\Repository\Repository */
$repository = $this->getRepository();
$contentService = $repository->getContentService();
$locationService = $repository->getLocationService();
@dfritschy
dfritschy / SearchController.php
Created November 14, 2014 10:15
Full Text Search in eZ Publish 5 using a legacy closure
$searchText = $request->query->get('SearchText');
$sort = array( 'modified' => 'false' );
$contentTypeIdenfiers = array( 31 );
$searchResult = $this->getLegacyKernel()->runCallback(
function () use ( $searchText, $sort, $contentTypeIdenfiers )
{
// eZFunctionHandler::execute is the equivalent for a legacy template fetch function
// The following is the same than fetch( 'content', 'search', hash(...) )
return eZFunctionHandler::execute(