Module: Scrivito::ControllerHelper

Included in:
ScrivitoHelper
Defined in:
app/cms/scrivito/controller_helper.rb

Overview

This helper contains methods, which are available in both your views and your controllers.

Instance Method Summary collapse

Instance Method Details

#scrivito_in_editable_view?Boolean

Note:

scrivito_in_editable_view? is also a helper method.

Returns whether the UI is in the editable view.

Returns:

  • (Boolean)

    true if the current visitor is an authenticated editor, the selected workspace is editable and the display mode is editing.

  • false otherwise.



55
56
57
# File 'app/cms/scrivito/controller_helper.rb', line 55

def scrivito_in_editable_view?
  EditingContextMiddleware.from_request(request).editable_display_mode?
end

#scrivito_path(target, options = {}) ⇒ String

Note:

scrivito_path is also a helper method.

Returns the (URL-)path of a CMS object.

Parameters:

  • target (Obj, Link, Array<Link>, Binary)

    If target is an Array of Links, it must be non-empty. Only the first Link of the Array is used.

  • options (Hash) (defaults to: {})

    include url settings such as path parameters or the protocol.

Returns:

  • (String)


22
23
24
# File 'app/cms/scrivito/controller_helper.rb', line 22

def scrivito_path(target, options = {})
  CmsRouting.new(request, self, scrivito_engine).path_or_url(target, "path", options)
end

#scrivito_url(target, options = {}) ⇒ String

Note:

scrivito_url is also a helper method.

Returns the absolute URL of a CMS object.

Parameters:

  • target (Obj, Link, Array<Link>, Binary)

    If target is an Array of Links, it must be non-empty. Only the first Link of the Array is used.

  • options (Hash) (defaults to: {})

    include url settings such as path parameters or the protocol.

Returns:

  • (String)


40
41
42
# File 'app/cms/scrivito/controller_helper.rb', line 40

def scrivito_url(target, options = {})
  CmsRouting.new(request, self, scrivito_engine).path_or_url(target, "url", options)
end

#scrivito_userScrivito::User

Note:

scrivito_user is also a helper method.

Returns the current user.

Returns:



70
71
72
# File 'app/cms/scrivito/controller_helper.rb', line 70

def scrivito_user
  Scrivito::EditingContextMiddleware.from_request(request).editor
end