Coder Social home page Coder Social logo

helpfulrobot / zanderwar-silverstripe-thankfully Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zanderwar/silverstripe-thankfully

0.0 2.0 0.0 9 KB

A module designed to reduce the potentially thousands of Thank You pages that can be sometimes needed for large sites

License: MIT License

PHP 95.62% Scheme 4.38%

zanderwar-silverstripe-thankfully's Introduction

silverstripe-thankfully

If you're tired of having to continuously create dozens of different "Thank You" pages then thankfully this module exists!

With this module you can easily create a dynamic "Thank You" page that is optionally configurable in the CMS for any page type that you assign this module to.

Features

  • You can configure the Thank You page title, content and URL from the CMS if the extension is added to the page type
  • As a developer you can configure the Thank You page programmatically and redirect the user there
  • Page creates itself on dev/build
  • Query string support for conversion tracking etc, also configurable from the CMS

Installation

Installation is supported via composer only:

$ composer require zanderwar/silverstripe-thankfully

Run a dev/build afterwards

Extension

  1. Create a mysite/thankfully.yml file
  2. Add:
    ContactPage:
        extensions:
            - 'ThankfullyExtension'
            
    ContactPage_Controller:
        extensions:
            - 'ThankfullyControllerExtension'
  3. Run a ?flush=1
  4. Open the page that has ContactPage (in this example) as the type within the CMS and you will now see a "Thank You" tab

In your controller (in this example ContactPage_Controller) you now have access to the method $this->getThankYouPage() which you can then immediately return $this->redirect($this->getThankYouPage()->Link()). This would most commonly be done in a form processing method

If the page title and/or content is not set in the page with the extension, it will fallback to the values set in the Thank You (Generic) that the dev/build created in the root of your site tree, if no defaults are configured, then the visitor will get a bit of an ugly experience

Standalone

You can configure the root Thank You page simply like so:

// ThankfullyPage::prepare($title, $content, $returnTo = null, array $queryStringPairs = array())
// $title: Represents the Title of the page
// $content: Represents the Content of the page
// $returnTo: Define a URL that a user should return to - This exposes a template method $ReturnTo which a developer can use to provide a button to return that user (optional)
// $queryStringPairs: Accepts an array of key/value pairs and will be built into a query string when Link() is called (optional)
$thanks = ThankfullyPage::prepare(
    array(
        'My Cool Title',
        '<p>We are quite thankful for whatever you have done to be brought here</p>'   
    )
);

return $this->redirect($thanks->Link());

Contributing

If you would like to contribute to this repository, please follow the contributing guide.

License

Click here for more information about the licensing of this module

Issues

To report issues with this module, please use our issue tracker.

zanderwar-silverstripe-thankfully's People

Contributors

zanderwar avatar

Watchers

James Cloos avatar helpfulrobot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.