Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-23807

Unable to preview first draft of a content if controller uses viewLocation()

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: High High
    • Resolution: Fixed
    • Affects Version/s: 5.2, 5.4.0, 5.3.4
    • Fix Version/s: 2015.09
    • Labels:
      None
    • Environment:

      eZ Publish 5.2

      Description

      This issue makes it impossible to preview the first draft of a content if the controller uses viewLocation() method.
      For example, as follows, the showBlogPostAction function used to display blog posts uses the viewLocation() method, and this will not work when previewing the first draft of a blog post, since a location doesn't exist yet.

          public function showBlogPostAction( $locationId, $viewType, $layout = false, array $params = array() )
          {
              // We need the author, whatever the view type is.
              $repository = $this->getRepository();
              $location = $repository->getLocationService()->loadLocation( $locationId );
              $author = $repository->getUserService()->loadUser( $location->getContentInfo()->ownerId );
       
              // TODO once the keyword service is available, load the number of keyword for each keyword
       
              // Delegate view rendering to the original ViewController
              // (makes it possible to continue using defined template rules)
              // We just add "author" to the list of variables exposed to the final template
              return $this->get( 'ez_content' )->viewLocation(
                  $locationId,
                  $viewType,
                  $layout,
                  array( 'author' => $author )
              );
          }
      

      The result can be viewed in the attached screenshot.

        Issue Links

          Activity

          Hide
          André Rømcke added a comment - - edited

          Changed to improvement since remaining issue needs a behaviour change.

          The suggested change was to deprecate viewLocation and standardize on always passing content id with optional location id param as extra context. This solves the root issue by not allowing people to pass only location id around, and always expecting it to work, something it also won't do if content does not have location at all in addition to before it is published.

          This is fully possible to do in custom code already as of EZP-23784 which fixed the specific issue in Preview controller, and we would be interested in creating a spec with someone that tries it a bit to move this forward.

          Show
          André Rømcke added a comment - - edited Changed to improvement since remaining issue needs a behaviour change. The suggested change was to deprecate viewLocation and standardize on always passing content id with optional location id param as extra context. This solves the root issue by not allowing people to pass only location id around, and always expecting it to work, something it also won't do if content does not have location at all in addition to before it is published. This is fully possible to do in custom code already as of EZP-23784 which fixed the specific issue in Preview controller, and we would be interested in creating a spec with someone that tries it a bit to move this forward.
          Hide
          Bertrand Dunogier added a comment -

          This is fixed by the view API changes in EZP-24869.

          Show
          Bertrand Dunogier added a comment - This is fixed by the view API changes in EZP-24869 .

            People

            • Assignee:
              Unassigned
              Reporter:
              Ricardo Correia (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: