Search

A new Extension, “Dynamic Event Redirect” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

Adds an event and an event filter that allows you to build up a combination of both URL and GET parameters from POST data to append to your form redirects.

Download

Usage

Standlone Event

  1. Attach the ‘Dynamic Event Redirection’ event to your desired page.
  2. Add any combination of the options listed below:

Event Filter

  1. Attach the ‘Dynamic Event Redirection’ filter to your desired event.
  2. Add any combination of the options listed below:

Options

URL Parameters

To use URL parameters in your redirect output, you need to add a hidden input field to your form with the name der-url-params and set its value as a / seperated list of parameters you wish to include. Like so:

    <input type="text" name="category" value="books-and-magazines"/>
    <input type="text" name="book-id" value="1234"/>
    <input type="hidden" name="der-url-params" value="category/book-id"/>
    <input type="hidden" name="redirect" value="http://amazon.com/"/>

The example above would result in the following URL: http://amazon.com/books-and-magazines/1234/. If a parameter isn’t set in the POST data its key (i.e., category in the example above) will be used in its place.

GET Parameters

You can use GET parameters with or without URL parameters. The usage is pretty much the same: add a hidden input field to your form that has the name der-params and set its value to a comma separated list of parameters you wish to include. Like so:

    <input type="text" name="category" value="books-and-magazines"/>
    <input type="text" name="book-id" value="1234"/>
    <input type="hidden" name="der-get-params" value="category,book-id"/>
    <input type="hidden" name="redirect" value="http://amazon.com/"/>

The would result in the user being redirected to: http://amazon.com/?category=books-and-magazines&book-id=1234.

Things to note

  • You’ll need to specify a redirect URL, else the filter won’t do anything.
  • Entry fields have priority over normal POST data. That is, data from the fields[] array will be used in place of identically named indexes from the POST data.
  • When using as a filter, you can pass on the ID of the entry you’re creating by adding id to your list of params.
  • You can also output values directly by using key:value pairs in the der-params value.
  • Does not work with events with ‘Allow multiple’ filters, requires some changes to the core.
  • If you’re using Rowan’s Clean URL Params extension you can set the output to use clean syntax by adding the following to your form:

    <input name="der-format" type="1" />
    

To do

  • Make work with ‘Allow multiple’
  • Add #anchor links

Updated: Now includes a standalone event and lets you append both URL and GET parameters.

This is great. Allowed me to have a simple search box pass URL params to a search results page w/ Google CSE datasource. Nice and clean. Big ups!

Really cool!

You have some examples of use? you developed it to implement what?

I don't have too many examples of use yet, but there are a whole range of things it could be used for. I'm using it on a shopping site to redirect a select dropdown to a URL:

<select name="product_id">
    <option value="1234">Product A</product>
    <option value="5678">Product B</product>
</select>
<input type="hidden" name="der-url-params" value="add/product_id"/>
<input type="redirect" value="http://shop-cart.com/"/>

This example would redirect the user to http://shop-cart.com/add/1234/ instead of http://shop-cart.com/add/?product_id=1234. Because using it as a filter lets you pull out the id of a newly created entry, you could use that to redirect users more intelligently after frontend create/editing events.

I have not played with it yet (but I will) but I thought things like multipage forms would be easier. Also, I think it would allow developers to extrapolate events so that they do one thing and you could use this extension to send specific information to each. Just thinking out loud...

That's exactly right, Lewis. It would allow you to use multiple sections and events over multiple pages and pass information between them. As you say, would allow you to have multipage forms and do proper validation on them (required fields, etc) while keeping everything linked together.

Also, I've just realised it'd be really useful to be able to pass #anchors in as well, so I'll get onto that at some point.

Makenosound, if possible I would like to hear more about that shoppingsite, I always wanted to find out if symphony is up to snuf for ecommerce, it seesm no-one here build a large shoppingsite uptill now?

@newnomad: Send me an email if you like, I'm not sure how much I'll be able to share with you but definitely send through your questions and I'll let you know what I can.

Does it provide support for passing the ID of a newly-created entry?

So on the first page I'd create the new entry, then pass this System ID on to the second page where more fields are updated, or the value is used to link the next entry to the first.

<input type="hidden" name="der-url-params" value="system:id"/>

@nickdunn: It does, you should be able to pass the ID on by using id rather than system:id. I might look at changing that in a future version to make it more clear.

Max, I have sent you an email ;-)

Just added a bug report at the issue tracker.

Dynamic Event Redirect updated to version 1.0.0 on 8th of June 2010.

Cheers mate, I’ve fixed that and pushed a new version (and bumped to 1.0.0 for good measure).

Thanks for updating the extension. But sadly it didn’t solve the problem. The extension still prevents the execution of other EventPostSaveFilters unless its filter is called as the last of all the EventPostSaveFilters. I fixed it temporarily by adding an order clause to the notifyMembers function in the extensionManager class. It stops the other filters because the redirect function exits the current script.

So the question is if there is either a way to redirect without terminating the current script or if there is a way to define the order of the execution of the filters.

Could the redirect itself be moved into another delegate callback, perhaps the last one that fires during a page load?

There is the EventFinalSaveFilter delegate with access to event data. That did the trick. Thanks for the tip, Nick.

Are there any drawbacks/side effects to use the EventFinalSaveFilter instead of the EventPostSaveFilter?

Dynamic Event Redirect updated to version 1.0.1 on 9th of June 2010

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details