Module: Scrivito::RoutingHelper

Included in:
ScrivitoHelper
Defined in:
lib/scrivito/routing_helper.rb

Overview

The helper contains methods to generate URLs to CMS content. Use #scrivito_path or #scrivito_url when linking or redirecting to CMS objects. These methods are available in boths your views and your controllers.

Instance Method Summary collapse

Instance Method Details

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

Returns the (URL-)path for a cms object.

Parameters:

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

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

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

    include url settings such as path parameters or protocol.

Returns:

  • (String)


22
23
24
# File 'lib/scrivito/routing_helper.rb', line 22

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

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

Returns the absolute URL for a cms object.

Parameters:

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

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

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

    include url settings such as path parameters or protocol.

Returns:

  • (String)


38
39
40
# File 'lib/scrivito/routing_helper.rb', line 38

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