This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Blogs » Core Development team » Platform weekly 2015#48

By

Platform weekly 2015#48

Sunday 29 November 2015 10:06:20 pm

  • Currently 3 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

This post is intended to give news, on a weekly basis, about the latest developments on Platform from a technical perspective. For this first weekly post, we will cover major structure changes that happened on Platform, and affect project creators.

The ezsystems/ezplatform meta repository has undergone a major cleanup last week. As this change will affect the way any developer gets started on a project, we will cover the changes a bit in this post.

 

First, the demo is gone from eZ Platform. The goal is that ezplatform is a clean slate you can start from, without having to first clean it up. A new meta-repository will be created in the next weeks, that contains ezplatform with a demo project, but it won't impact projects anymore. You can see the full list of changes this came up with in the demobundle removal pull-request. This also means that clean is now the only option available for ezplatform:install. It imports the cleandata.sql dump, that contains the very minimum data: basic content types (user, user group, folder, article, media and image), as well as the root folder, and the administrator and anonymous users.

 

In addition to this, the configuration in ezpublish/config has also been reworked. The repository now contains a default ezplatform.yml file, with the minimal configuration (one siteaccess, named "site". We think that this config will match most new projects. Instead of being loaded by the kernel, it is now simply imported from config.yml, like the other files. If you need to change this file for whatever reason: just do. This is a topic we will write about soon, but as we see it, projects should not be based on a bundle that gets imported into ezplatform. Instead, ezplatform itself should be versioned, including the ezpublish folder. If we change this file, and you merge the latest version on top of it, you will get a conflict. But this config doesn't really have reasons to change that much, and having to merge the vendor changes when upgrading is a normal procedure.

 

The last thing to mention is how project we recommend projects are organized. Templates should go into the ezpublish/Resources/views directory. They can be referenced using their relative path: ezpublish/Resources/views/pagelayout.html.twig file it can be loaded as "pagelayout.html.twig". eZ Platform now comes with a default bundle that you can use for your project. We decided to tag along with symfony-standard on this: in the src folder, you will find an AppBundle. It should be used for custom code required by the application itself. Configuration can either go in the AppBundle's Resources folder,  

 

With those changes, getting started with a project is easier than ever. We will end this post by walking you through the customization of the homepage view. Let's create a template first: in ezpublish/Resources/views, create a "home.html.twig" file:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Home</title>
</head>
<body>
<div id="content">
    <h1>{{ ez_content_name(content) }}</h1>
    <p>{{ ez_render_field(content, "description") }}</p>
</div>
</body>
</html>

 Now, let's configure ezplatform to use this template. Open ezpublish/config/ezplatform.yml, and at the end add:

ezpublish:
    system:
        default:
            content_view:
                full:
                    folder:
                        template: "home.html.twig"
                        match: {"Id\Location": 2}

Reload your site's homepage, and your template should be used.

Adding a custom controller is also very simple. First, let's add a controller in the AppBundle. Create the src/AppBundle/Controller/MyController.php file:

<?php
namespace AppBundle\Controller;
 
class MyController extends Controller
{
    public function viewHomeAction(View $view)
    {
        $view->addParameters(['whatever' => 'we want']);
 
        return $view;
    }
} 

Modify the view configuration above to add the custom controller:

folder:
    template: "home.html.twig"
    controller: AppBundle:My:viewHome
    match: {"Id\Location: 2}

So, how do these new possibilities sound ? Do you think it makes it easier to get started on an eZ Platform project ?

Proudly Developed with from