From 884f181bb66b4250419b26fd600cb5fc5ff11e1b Mon Sep 17 00:00:00 2001 From: mere-teresa Date: Fri, 31 Jul 2015 16:25:42 +0200 Subject: [PATCH 1/2] Step 2 - part 2 and 2 : adding controller and YAML config files from my working copy Inclusion of YAML files in the main ezpublish.yml --- ezpublish/config/ezpublish.yml | 56 +++++++++++++++++++ .../Controller/DefaultController.php | 55 ++++++++---------- .../BikeBundle/Resources/config/ezpublish.yml | 2 + .../BikeBundle/Resources/config/routing.yml | 6 +- .../Resources/config/template_rules.yml | 18 ++++++ 5 files changed, 104 insertions(+), 33 deletions(-) create mode 100644 ezpublish/config/ezpublish.yml create mode 100644 src/EzTutorial/BikeBundle/Resources/config/ezpublish.yml create mode 100644 src/EzTutorial/BikeBundle/Resources/config/template_rules.yml diff --git a/ezpublish/config/ezpublish.yml b/ezpublish/config/ezpublish.yml new file mode 100644 index 0000000..0c37304 --- /dev/null +++ b/ezpublish/config/ezpublish.yml @@ -0,0 +1,56 @@ +# import the ezpublish.yml from your Bundle +imports: + - {resource: @EzTutorialBikeBundle/Resources/config/ezpublish.yml} + +ezpublish: + repositories: + demo_repository: + engine: legacy + connection: default + + siteaccess: + # Available siteaccesses + list: + - demo_site + - gobike + + # Siteaccess groups. Use them to group common settings. + groups: + demo_site_group: [demo_site, gobike] + default_siteaccess: demo_site + match: + URIElement: 1 + + imagemagick: + enabled: false + + # System settings, grouped by siteaccess and/or siteaccess group + system: + demo_site_group: + repository: demo_repository + var_dir: var/ezdemo_site + languages: + - eng-GB + session: + name: eZSESSID + default: + content: + view_cache: true + ttl_cache: true + # TTL cache (http) in seconds + # Note that Http cache for a given content is always invalidated when publishing that content + default_ttl: 300 + +# Stash is used for persistence cache +stash: + caches: + default: + drivers: + # When using multiple webservers, you must use Memcache or Redis + - FileSystem + inMemory: true + registerDoctrineAdapter: false + # On Windows, using FileSystem, to avoid hitting filesystem limitations + # you need to change the keyHashFunction used to generate cache directories to "crc32" + # FileSystem + # keyHashFunction: crc32 \ No newline at end of file diff --git a/src/EzTutorial/BikeBundle/Controller/DefaultController.php b/src/EzTutorial/BikeBundle/Controller/DefaultController.php index 4046114..04e7571 100644 --- a/src/EzTutorial/BikeBundle/Controller/DefaultController.php +++ b/src/EzTutorial/BikeBundle/Controller/DefaultController.php @@ -2,7 +2,6 @@ namespace EzTutorial\BikeBundle\Controller; -use Doctrine\Common\Collections\Criteria; use eZ\Bundle\EzPublishCoreBundle\Controller; use eZ\Publish\API\Repository\Values\Content\LocationQuery; use eZ\Publish\API\Repository\Values\ValueObject; @@ -15,42 +14,34 @@ class DefaultController extends Controller { - public function indexAction($name) - { - $rideList = $this->findRidesAction(65); - return $this->render('EzTutorialBikeBundle:Default:index.html.twig', array('name' => $name, 'rideList' => $rideList)); - } - /** * @return Response */ - public function listRidesAction() + public function indexAction() { - $response = new Response(); - $rides = null; - - - // Using the criteria helper (a demobundle custom service) to generate our query's criteria. - // This is a good practice in order to have less code in your controller. - $criteria = new Criteria(); - - // Generating query - $query = new Query(); - $query->criterion = $criteria; - $query->sortClauses = array( - new SortClause\Field('ride', 'creation_date', Query::SORT_DESC) - ); + $folderId = 124; + $rideList = $this->findRidesAction($folderId); + return $this->render('EzTutorialBikeBundle:Default:index.html.twig', array('rideList' => $rideList)); + } - $rides = $this->searchService->findContent($query); - return $this->render( - 'EzTutorialBikeBundle:frontpage.html.twig', - array( - 'content' => $rides, - ), - $response + /** + * Renders article with extra parameters that controls page elements visibility such as image and summary + * + * @param $locationId + * @param $viewType + * @param bool $layout + * @param array $params + * @return \Symfony\Component\HttpFoundation\Response + */ + public function showRideAction($locationId, $viewType, $layout = false, array $params = array()) + { + return $this->get('ez_content')->viewLocation( + $locationId, + $viewType, + $layout, + array() + $params ); - } /** @@ -78,7 +69,7 @@ public function findRidesAction($folderId) $criteria = array(); $criteria[] = new Criterion\Visibility(Criterion\Visibility::VISIBLE); $criteria[] = new Criterion\Subtree($location->pathString); - $criteria[] = new Criterion\ContentTypeIdentifier(array('ride')); + $criteria[] = new Criterion\ContentTypeIdentifier(array('ride2')); $criteria[] = new Criterion\LanguageCode($languages); // Generating query to retrieve only Rides @@ -86,7 +77,7 @@ public function findRidesAction($folderId) $query->criterion = new Criterion\LogicalAnd( array( new Criterion\ParentLocationId($folderId), - new Criterion\ContentTypeIdentifier(array('ride')) + new Criterion\ContentTypeIdentifier(array('ride','ride2')) ) ); $searchService = $repository->getSearchService(); diff --git a/src/EzTutorial/BikeBundle/Resources/config/ezpublish.yml b/src/EzTutorial/BikeBundle/Resources/config/ezpublish.yml new file mode 100644 index 0000000..90db690 --- /dev/null +++ b/src/EzTutorial/BikeBundle/Resources/config/ezpublish.yml @@ -0,0 +1,2 @@ +imports: + - { resource: @EzTutorialBikeBundle/Resources/config/template_rules.yml } \ No newline at end of file diff --git a/src/EzTutorial/BikeBundle/Resources/config/routing.yml b/src/EzTutorial/BikeBundle/Resources/config/routing.yml index 7838847..9c2c10b 100644 --- a/src/EzTutorial/BikeBundle/Resources/config/routing.yml +++ b/src/EzTutorial/BikeBundle/Resources/config/routing.yml @@ -1,3 +1,7 @@ ez_tutorial_bike_homepage: - path: /hello/{name} + path: /hello defaults: { _controller: EzTutorialBikeBundle:Default:index } + +ez_tutorial_bike_ride_full: + path: /ride/:id + defaults: { _controller: EzTutorialBikeBundle:Default:ride } \ No newline at end of file diff --git a/src/EzTutorial/BikeBundle/Resources/config/template_rules.yml b/src/EzTutorial/BikeBundle/Resources/config/template_rules.yml new file mode 100644 index 0000000..caabec4 --- /dev/null +++ b/src/EzTutorial/BikeBundle/Resources/config/template_rules.yml @@ -0,0 +1,18 @@ +ezpublish: + system: + default: + location_view: + line: + ride_line: + template: "EzTutorialBikeBundle:line:ride.html.twig" + match: + Identifier\ContentType: [ride, ride2] #I had to recreate the Contenttype so I am using ride2 + poi: + template: "EzTutorialBikeBundle:line:poi.html.twig" + match: + Identifier\ContentType: [poi] + full: + ride: + template: "EzTutorialBikeBundle:full:ride.html.twig" + match: + Identifier\ContentType: [ride, ride2] From 7d2d7d11217fc162453672ce8214ae2e111f34e7 Mon Sep 17 00:00:00 2001 From: mere-teresa Date: Fri, 31 Jul 2015 16:26:47 +0200 Subject: [PATCH 2/2] Step 2 - part 2 and 3 : adding Twig templates, line, full and parts * Templates for full Ride, line Ride, line Point Of Interest (not finished) * Templates parts for navigation, header, footer, javascript, CSS --- .../Resources/views/Default/index.html.twig | 124 ++------ .../Resources/views/footer.html.twig | 41 +++ .../Resources/views/full/ride.html.twig | 277 ++++++++++++++++++ .../Resources/views/header.html.twig | 15 + .../Resources/views/line/poi.html.twig | 1 + .../Resources/views/line/ride.html.twig | 9 + .../Resources/views/navigation.html.twig | 28 ++ .../Resources/views/page_head_css.html.twig | 13 + .../Resources/views/page_javascript.html.twig | 22 ++ 9 files changed, 425 insertions(+), 105 deletions(-) create mode 100644 src/EzTutorial/BikeBundle/Resources/views/footer.html.twig create mode 100644 src/EzTutorial/BikeBundle/Resources/views/full/ride.html.twig create mode 100644 src/EzTutorial/BikeBundle/Resources/views/header.html.twig create mode 100644 src/EzTutorial/BikeBundle/Resources/views/line/poi.html.twig create mode 100644 src/EzTutorial/BikeBundle/Resources/views/line/ride.html.twig create mode 100644 src/EzTutorial/BikeBundle/Resources/views/navigation.html.twig create mode 100644 src/EzTutorial/BikeBundle/Resources/views/page_head_css.html.twig create mode 100644 src/EzTutorial/BikeBundle/Resources/views/page_javascript.html.twig diff --git a/src/EzTutorial/BikeBundle/Resources/views/Default/index.html.twig b/src/EzTutorial/BikeBundle/Resources/views/Default/index.html.twig index c7e58c7..9cd7e7e 100644 --- a/src/EzTutorial/BikeBundle/Resources/views/Default/index.html.twig +++ b/src/EzTutorial/BikeBundle/Resources/views/Default/index.html.twig @@ -1,7 +1,6 @@ - @@ -10,63 +9,20 @@ Beginners Tutorial - Bike Rides + {{ include('EzTutorialBikeBundle::page_head_css.html.twig') }} - - {% stylesheets filter='cssrewrite' - '@EzTutorialBikeBundle/Resources/css/bootstrap.min.css' - '@EzTutorialBikeBundle/Resources/css/bootstrap-theme.css' - '@EzTutorialBikeBundle/Resources/css/style.css' - '@EzTutorialBikeBundle/Resources/css/normalize.css' %} - - {% endstylesheets %} + + + + + - - - - -
-
- -
-
@@ -79,9 +35,9 @@ {% image '@EzTutorialBikeBundle/Resources/images/3.jpg' %} - 3 - {% endimage %} + 3 + {% endimage %} Name Starting Point Length @@ -90,15 +46,12 @@ {% for ride in rideList %} - - - {{ ride.title }} - - {{ ride.starting_point }} - {{ ride.length }} Km - {{ ride.difficulty }} - + {#{{ ez_render_field( #} + {#ride, #} + {#'ride',#} + {#{ 'template': 'EzTutorialBikeBundle:line:ride.html.twig' }#} + {#) }}#} + {{ include('EzTutorialBikeBundle:line:ride.html.twig') }} {% endfor %} @@ -107,46 +60,7 @@
- - - +{{ include('EzTutorialBikeBundle::footer.html.twig') }} +{{ include('EzTutorialBikeBundle::page_javascript.html.twig') }} \ No newline at end of file diff --git a/src/EzTutorial/BikeBundle/Resources/views/footer.html.twig b/src/EzTutorial/BikeBundle/Resources/views/footer.html.twig new file mode 100644 index 0000000..2193736 --- /dev/null +++ b/src/EzTutorial/BikeBundle/Resources/views/footer.html.twig @@ -0,0 +1,41 @@ + + diff --git a/src/EzTutorial/BikeBundle/Resources/views/full/ride.html.twig b/src/EzTutorial/BikeBundle/Resources/views/full/ride.html.twig new file mode 100644 index 0000000..c6b7ee9 --- /dev/null +++ b/src/EzTutorial/BikeBundle/Resources/views/full/ride.html.twig @@ -0,0 +1,277 @@ + + + + + + + + + + + Beginners Tutorial - Bike Rides + {{ include('EzTutorialBikeBundle::page_head_css.html.twig') }} + + + + + + + + + + +{{ include('EzTutorialBikeBundle::navigation.html.twig') }} + + +
+
+
+
+
+

Ride:

+
+
+

{{ ez_content_name( content ) }}

+
+
+
+
+
+ +
+
+
+
+
+ {{ ez_render_field( + content, 'starting_point', { 'parameters':{ 'showInfo':false, 'width': '100%', 'height' : '400px', 'zoom' : 16 } } + ) + }} +
+
+
+
+
+ +
+
+
+
+

+
+
+
+
+

{{ ez_field_value( content, "length" ) }} Km

+ +

Level

+ +

+ +

1h 27 min

+
+
+
+
+

Name:

+
+
+

{{ ez_field_value( content, "author" ) }}

+
+
+

Start:

+ +

End:

+
+
+

{{ ez_field_value( content, "starting_point" ) }}

+ +

{{ ez_field_value( content, "ending_point" ) }}

+
+
+
+
+

Description:

+
+
+

{{ ez_field_value( content, "name" ) }}

+
+
+
+
+
+
+ + +
+
+
+ + +
+
+
+ + +{{ include('EzTutorialBikeBundle::footer.html.twig') }} + + + + + + + + + +{{ include('EzTutorialBikeBundle::page_javascript.html.twig') }} + + diff --git a/src/EzTutorial/BikeBundle/Resources/views/header.html.twig b/src/EzTutorial/BikeBundle/Resources/views/header.html.twig new file mode 100644 index 0000000..824defb --- /dev/null +++ b/src/EzTutorial/BikeBundle/Resources/views/header.html.twig @@ -0,0 +1,15 @@ + +
+
+ +
+
diff --git a/src/EzTutorial/BikeBundle/Resources/views/line/poi.html.twig b/src/EzTutorial/BikeBundle/Resources/views/line/poi.html.twig new file mode 100644 index 0000000..4b7d002 --- /dev/null +++ b/src/EzTutorial/BikeBundle/Resources/views/line/poi.html.twig @@ -0,0 +1 @@ +Point of interest line \ No newline at end of file diff --git a/src/EzTutorial/BikeBundle/Resources/views/line/ride.html.twig b/src/EzTutorial/BikeBundle/Resources/views/line/ride.html.twig new file mode 100644 index 0000000..95b7e0b --- /dev/null +++ b/src/EzTutorial/BikeBundle/Resources/views/line/ride.html.twig @@ -0,0 +1,9 @@ + + + {{ ride.title }} + + {{ ride.starting_point }} + {{ ride.length }} Km + {{ ride.difficulty }} + \ No newline at end of file diff --git a/src/EzTutorial/BikeBundle/Resources/views/navigation.html.twig b/src/EzTutorial/BikeBundle/Resources/views/navigation.html.twig new file mode 100644 index 0000000..be144bc --- /dev/null +++ b/src/EzTutorial/BikeBundle/Resources/views/navigation.html.twig @@ -0,0 +1,28 @@ + + \ No newline at end of file diff --git a/src/EzTutorial/BikeBundle/Resources/views/page_head_css.html.twig b/src/EzTutorial/BikeBundle/Resources/views/page_head_css.html.twig new file mode 100644 index 0000000..9464abe --- /dev/null +++ b/src/EzTutorial/BikeBundle/Resources/views/page_head_css.html.twig @@ -0,0 +1,13 @@ + +{% stylesheets filter='cssrewrite' +'@EzTutorialBikeBundle/Resources/css/bootstrap.min.css' +'@EzTutorialBikeBundle/Resources/css/bootstrap-theme.css' +'@EzTutorialBikeBundle/Resources/css/style.css' +'@EzTutorialBikeBundle/Resources/css/normalize.css' %} + +{% endstylesheets %} + + + \ No newline at end of file diff --git a/src/EzTutorial/BikeBundle/Resources/views/page_javascript.html.twig b/src/EzTutorial/BikeBundle/Resources/views/page_javascript.html.twig new file mode 100644 index 0000000..1c972b0 --- /dev/null +++ b/src/EzTutorial/BikeBundle/Resources/views/page_javascript.html.twig @@ -0,0 +1,22 @@ + + + +{% javascripts %} + 'extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js' + 'extension/ezjscore/design/standard/javascript/jquery-1.10.2.min.js' + 'extension/ezjscore/design/standard/javascript/jquery-ui-1.10.3.custom.min.js' + '@eZDemoBundle/Resources/public/js/ezflyout.js' + '@eZDemoBundle/Resources/public/js/ezgallery.js' + '@eZDemoBundle/Resources/public/js/ezgallerynavigator.js' + '@eZDemoBundle/Resources/public/js/ezsimplegallery.js' + '@eZDemoBundle/Resources/public/js/handle_transition.js' + '@eZDemoBundle/Resources/public/js/heightresize.js' + '@eZDemoBundle/Resources/public/js/init_ua.js' + '@eZDemoBundle/Resources/public/js/insertmedia.js' + '@eZDemoBundle/Resources/public/js/toggle_class.js' + '@eZDemoBundle/Resources/public/js/video.js' + '@eZDemoBundle/Resources/public/js/hinclude.js' + +{% endjavascripts %}