redirectoid 2.1.0-rc1

redirectoid 2.1.0-rc1

Released Aug 20, 2016 by sepiariver

A simple snippet that redirects to any Resource specified by ID, or a random child of a specified parent(s).

Redirectoid supports various response codes described here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

It also exposes the arguments for the $modx->makeUrl() method for further customization.

Thanks for using MODx Revolution.

Download 31kb (1079 downloads)
Downloads: 3,458
License: GPLv2
Requires Revolution 2.2.x or greater
Supports mysql

A simple snippet that redirects to any Resource specified by ID, or a random child of a specified parent(s).

Redirectoid supports various response codes described here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

It also exposes the arguments for the $modx->makeUrl() method for further customization.

GitHub repo: https://github.com/sepiariver/redirectoid

Installation Instructions

USE CASES:

Why wouldn't you use a WebLink? You may have Resources that have content, but are only displayed as sections or blocks in the parent Resource, so the child Resources aren't meant to be viewed on their own. Redirectoid can be called in the child Resources' Template like so: [[Redirectoid? &id=`[[*parent]]`]] to solve this.

As of version 2, you can redirect to a random child of a given parent(s) Resource, so the use cases expand dramatically: split testing, randomization of content or redirects, etc.

PARAMETERS:

&id              ID of target Resource. Can be a string: 'random'. Default: site_start system setting

&context         Context of target Resource. Default: ''

&urlParamString  URL parameter string to send with the redirected request. Default ''

&scheme          Scheme for $modx->makeUrl to use. Default: -1

&parents         Comma-separated list of parent IDs for random child mode. Defaults to current Resource

&showHidden      Set to 1 to include Resources hidden from menus, in random child mode. Defaults to 0

&showDeleted      Set to 1 to include deleted Resources, in random child mode. Defaults to 0

&showUnpublished      Set to 1 to include unpublished Resources, in random child mode. Defaults to 0

&responseCode    '302', '303' or '307'. Set this to modify the response code sent to the client. Default: '' which sends '301'

&useCtxMap            Set to 1 to use Context Map in random child mode. Faster but doesn't allow queries like showDeleted. Defaults to 0.

&depth                Depth param to pass to getChildIds() in random child mode when useCtxMap is true. Default to 1.

USAGE EXAMPLES:

This redirects to the Resource ID specified in the site_start system setting, with a '301 Moved Permanently' response:

[[Redirectoid]]

This redirects to Resource ID '12' with a '307 Temporary Redirect' response:

[[Redirectoid?id=`12` &responseCode=`307`]]

This redirects to Resource ID '55' in the 'custom' context, with a url parameter 'service=logout':

[[Redirectoid?id=`55` &context=`custom` &urlParamString=`service=logout`]]

This redirects to a random child Resource of the current Resource with a '307 Temporary Redirect' response:

[[!Redirectoid?id=`random` &responseCode=`307`]]

This redirects to a random child Resource of the specified parent, even if hidden from menus:

[[!Redirectoid?id=`random` &parents=`3,56,821` &showHidden=`1`]]

2.1.x RC

  • Optimizations
  • Github repo

2.0.0-pl Initial public release.

* Added 'random' feature.

* Added $modx->makeUrl() options.

* Tested with Revo 2.3

1.0.0-beta1 Initial beta release.

Version Released Author Downloads
4 Versions 1 Contributors 3,462 Downloads
2.0.0-pl1 Jul, 21 2014 sepiariver 346
2.0.1-pl1 Jul, 20 2014 sepiariver 1,191
1.0.0-beta1 Feb, 11 2013 sepiariver 846