Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-22550 Added breadcrumb to navigate in Demobundle #87

Conversation

StephaneDiot
Copy link
Contributor

Description

The goal here was to add a breadcrumb to be able to naviguate in the Demobundle. For that I implemented a new bundle from white october named BreadCrumbsBundle ( see link to whiteoctober bundle ).
To work this bundle need to be registred in ezPublishKernel.php and in composer.json ( see link to ezpublish-community pull request ).

Links

Jira : https://jira.ez.no/browse/EZP-22550
Whiteoctober BreadCrumbsBundle : https://github.com/whiteoctober/BreadcrumbsBundle
Ezpublish-community pull request link : ezsystems/ezpublish-community#150

Screenshot

screenshot from 2014-05-14 13 53 59

$locationService = $this->getRepository()->getLocationService();
$path = $locationService->loadLocation( $locationId )->path;

for ( $i = 1; $i < count( $path ); $i++ )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the root location can be configured at the siteaccess level, so you should loop until the configured root location.

@ezrobot
Copy link

ezrobot commented May 19, 2014

This Pull Request does not respect our PHP Coding Standards, please, see the report below:

FILE: ...undle-Pull-Request-code-sniffer/workspace/Controller/DemoController.php
--------------------------------------------------------------------------------
FOUND 6 ERROR(S) AFFECTING 4 LINE(S)
--------------------------------------------------------------------------------
 313 | ERROR | A space is required after opening parenthesis of function call
 313 | ERROR | A space is required before closing parenthesis of function call
 319 | ERROR | Expected "if (...)\n...{\n"; found "if (...) ...{\n"
 319 | ERROR | Expected 1 space before closing bracket; none found
 320 | ERROR | Expected "if (...)\n...{\n"; found "if(...)...{\n"
 328 | ERROR | Expected "}\nelse\n...{\n"; found "}            else ...{\n"
--------------------------------------------------------------------------------

@StephaneDiot
Copy link
Contributor Author

Modifications done. ping @dpobel

@ezrobot
Copy link

ezrobot commented May 19, 2014

This Pull Request does not respect our PHP Coding Standards, please, see the report below:

FILE: ...undle-Pull-Request-code-sniffer/workspace/Controller/DemoController.php
--------------------------------------------------------------------------------
FOUND 3 ERROR(S) AFFECTING 3 LINE(S)
--------------------------------------------------------------------------------
 319 | ERROR | Expected "if (...)\n...{\n"; found "if (...) ...{\n"
 320 | ERROR | Expected "if (...)\n...{\n"; found "if (...) ...{\n"
 327 | ERROR | Expected "}\nelse\n...{\n"; found "} else ...{\n"
--------------------------------------------------------------------------------

@yannickroger
Copy link
Contributor

Not a single line of comment in your PR. The demo bundle is also here to tell people how to use the product. You should add some explanation here and there.

@StephaneDiot
Copy link
Contributor Author

ping @yannickroger

* @param $locationId
* @return \Symfony\Component\HttpFoundation\Response
*/
public function viewBreadcrumbAction ( $locationId )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"viewBreadcrumbAction (" -> "viewBreadcrumbAction("

@hghandri
Copy link

hghandri commented Jun 3, 2014

Hello,

How is managed cache to breadcrumb ? and how it is invalid if content is updated?

Thank.

@ezrobot
Copy link

ezrobot commented Jun 3, 2014

This Pull Request does not respect our PHP Coding Standards, please, see the report below:

FILE: ...undle-Pull-Request-code-sniffer/workspace/Controller/DemoController.php
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
 351 | ERROR | Expected "if (...)\n...{\n"; found "if(...)\n...{\n"
--------------------------------------------------------------------------------

@@ -298,4 +298,62 @@ public function viewStarRatingAction( Location $location )
);
}

/**
* Displays breadcrumb for a given locationId
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"For a given $locationId"

@bdunogier
Copy link
Member

And please fix the commit messages: "EZP-22550 Added breadcrumb to navigate in Demobundle" (typo + removed "impl/".

@bdunogier
Copy link
Member

What about caching, guys ?

As far as I can tell, it should be tweaked through smart cache rules, depending on the breadcrumb's max depth, but I might be missing something.

@StephaneDiot StephaneDiot changed the title impl/EZP-22550 Added breadcrumb to naviguate in Demobundle EZP-22550 Added breadcrumb to navigate in Demobundle Jun 4, 2014
{
$location = $locationService->loadLocation( $path[$i] );
// if root location hasn't been found yet
if ( $isRootLocation == false )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: that's a bit weird, !$isRootLocation is easier to grasp (IMHO)

@dpobel
Copy link
Contributor

dpobel commented Jun 4, 2014

besides the nitpick, it seems ok to me. For caching don't we need to use render_esi and to set the X-Location-Id header to the location id of the root location ?
ping @lolautruche

@bdunogier
Copy link
Member

Well, the thing is that by default, I don't believe the cache rules will trigger cache clearing for a child location at depth 4 (it's just children by default, is it not ?).

In any case, it's the DemoBundle. We can take care of caching later (and I believe we should) and merge it as is.

@@ -43,3 +43,5 @@ services:
class: %ezdemo.form.type.feedback.class%
tags:
- { name: form.type, alias: ezdemo_feedback }

white_october_breadcrumbs: ~
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must not be here. This is semantic configuration so, should be either in ezpublish/config/config.yml or in a configuration file loaded by this bundle, like for ez_comments.yml.

@lolautruche
Copy link
Contributor

As for caching, breadcrumbs are embedded in the main page and I'm not sure it worths it to use an ESI for that. So it would be expired with the current content.

@andrerom
Copy link
Contributor

andrerom commented Jun 6, 2014

Wouldn't it be more correct, and more what legacy users would expect if it is esi, tied to menu root, so normal viewcache.ini tweaks applies? if tied to current content this is kind of not what user would expect at all, if viewcache.ini tied, it is more inline with how eZ Publish docs currently tells you to deal witch such cache.

@lolautruche
Copy link
Contributor

@andrerom In ezdemo legacy, we have the following:

{cache-block keys=array( $module_result.uri, $user_hash, $extra_cache_key )}

So it's completely bound to the current URI (and therefore content), and user hash of course. So for me expectations should be the same.

@andrerom
Copy link
Contributor

true, so +1 from here then
But if low hanging fruit to do it the more correct way straight away now on new stack, it is faster to do it now then let it flower in the backlog ;)

@dpobel
Copy link
Contributor

dpobel commented Jun 11, 2014

on the cache thing: if the breadcrumb is tied to the page/content (ie not in an ESI), does not that mean that if for instance I rename the parent content, the breadcrumb will be wrong as the child pages cache will probably not be cleared ?

Given the cache-block example, I guess it's the same in legacy, so we can live with that for now, but this might be considered as a quite annoying bug.

So +1

@lolautruche
Copy link
Contributor

Yes @dpobel you're right.

dpobel added a commit that referenced this pull request Jun 18, 2014
…_naviguate_in_DemoBundle

EZP-22550 Added breadcrumb to navigate in Demobundle
@dpobel dpobel merged commit d4e52b9 into ezsystems:master Jun 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
8 participants