- See also Configuration for Video Tutorial (eZPlatform 4-working with bundles and Multisite) at https://gist.github.com/ramzi-arfaoui/abbf0cdcfb3bf29c9a293e76b352d455
- Discover the eZPlatform Video tutorial at: https://www.youtube.com/playlist?list=PLjJ-Vvy1P3FuUikg6rvdAtXeJG00Ynh_z
- More on ezplatform commands at https://github.com/dspe/ez5_cheatsheet
Last active
August 25, 2017 12:15
-
-
Save arfaram/797e56d25f203420ee1634db09c58a55 to your computer and use it in GitHub Desktop.
#you will often use the following commands when you are working with eZPlatform or Symfony2
php app/console assetic:dump --env=dev web php app/console assetic:dump --env=prod web php app/console assetic:watch
php app/console cache:clear --env=dev php app/console cache:clear --env=prod
php app/console assets:install web
OR as symlink
php app/console assets:install web --symlink
php app/console debug:router
php app/console generate:bundle
php app/console translation:update --force --output-format=xlf en ProjectAppBundle
- This will create following file: src/Project/AppBundle/Resources/translations/messages.en.xlf
- Check folder write access bevor
{% block content %}{% endblock %}
From /view folder:
{% include 'ProjectAppBundle::page_head_style.html.twig' %}
From subfolder: /view/subfolder
{% include 'ProjectAppBundle:subfolder:page_head_style.html.twig' %}
using parameters:
{% include 'ProjectAppBundle::page_head_style.html.twig' with {'foo' : bar} %}
- {{'text'|trans}} - {{ '< h3 >foo<\ h3 >' | trans | raw }} - {% trans %}Search for "%searchText%" returned %searchCount% matches{% endtrans %}
TextLine[ezstring]
{{ ez_content_name(content) }} or {{content.getFieldValue('FILED-NAME')}} see also: {{content.getField('FILED-NAME')}}
RichText[ezrichtext]
{{ ez_render_field(content, 'FILED-NAME') }}
Text Block[eztext]
{{ ez_render_field(content, 'FILED-NAME') }} Have you saved HTML code in eztext? javascript , iframe code ? then use the magic raw filter: {{content.getFieldValue('FILED-NAME')|raw('html')}}
Selection[ezselection]
{{content.getFieldValue('FILED-NAME')}}
Image[ezimage]
{{ ez_render_field(content, 'FILED-NAME') }} You need your own < img > Tag ? then: < img src="{{contentElement.getFieldValue('image').uri}}" alt="{{contentElement.getFieldValue('image').alternativeText}}" / >
content Relation (multiples)[ezobjectrelationlist]
{{content.getFieldValue('images')}} -> Return only the objectIds (content IDs)
{{ render( controller( "ProjectAppBundle:ObjectList:getObjectData", { 'tpl': "ProjectAppBundle::target.html.twig", 'siteaccess': ezpublish.siteaccess, parameters:{'foo': bar } } )) }}
Correspondant Controller:
namespace Portal\MainBundle\Controller; use eZ\Bundle\EzPublishCoreBundle\Controller; use Symfony\Component\HttpFoundation\Response; //... class ObjectListController extends Controller{ //... public function getObjectDataAction( $tpl, $siteaccess , $parameters ){ $response = new Response; //... $data = $somedata ; //... return $this->render( $tpl, array( 'content' => $data, 'parameters' => $parameters, ),$response ); } }
$response = new Response; $response->setPublic(); $response->setSharedMaxAge( 86400 );
Or also:
$response = new Response; $response = $this->render( $tpl, array( 'content' => $content) ); $response->setPublic(); $response->setSharedMaxAge( 86400 ); return $response ;
$response = new Response; $response->setPrivate(); //something like user data $response->headers->addCacheControlDirective('no-cache', true); $response->headers->addCacheControlDirective('max-age', 0); $response->headers->addCacheControlDirective('must-revalidate', true); $response->headers->addCacheControlDirective('no-store', true);
In parametres.yml: parameters: settings.site.email: me@ez.no In controller: $resolver = $this->getConfigResolver(); $to = $resolver->getParameter( 'email', 'settings', 'site' );
another way:
In parametres.yml: parameters: to: me@ez.no In controller: $to = $container->getParameter('to' );
In parametres.yml:
parameters: to: me@ez.no
In config.yml:
twig: globals: version: '%to%'
In Twig Template
{{ to }}
$locationService = $this->getRepository()->getLocationService(); $location = $locationService->loadLocation($LocationId);
$content = $this->getRepository()->getContentService()->loadContent( $ObjectId );
$content = $this->getRepository()->getContentService()->loadContent( $ObjectId ); $xmlTextValue = $content->getFieldValue( 'THE-RICHTEXT-FIELD-NAME' ); /** @var \eZ\Publish\Core\FieldType\XmlText\Converter\Html5 $html5Converter */ $html5Converter = $this->get( 'ezpublish.fieldType.ezxmltext.converter.html5' ); $html = $html5Converter->convert( $xmlTextValue->xml );
OR without HTML format:
$content->getFieldValue('THE-RICHTEXT-FIELD-NAME')->xml->textContent;
try{ .... }catch ( Exception $e ) { $this->get( 'logger' )->error( "MyControllerName: Oh Error : {$e->getMessage()}" ); ... }
/** * @Route("/hello/{name}", name="hello") */ public function indexAction($name) { return new Response('Hello '.$name.'!'); }
acme_privacy: path: /privacy defaults: _controller: FrameworkBundle:Template:template template: static/privacy.html.twig
return $this->redirect(($this->generateUrl('acme_privacy')));
// $_GET parameters $request->query->get('name'); // $_POST parameters $request->request->get('name');
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment