Coder Social home page Coder Social logo

kryslin / t3x-contexts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from netresearch/t3x-contexts

0.0 1.0 0.0 1 MB

Contexts for TYPO3 – can be used to modify page behaviour in the frontend based on several conditions

Home Page: http://forge.typo3.org/projects/extension-contexts

License: GNU Affero General Public License v3.0

PHP 99.86% CSS 0.10% TypeScript 0.03%

t3x-contexts's Introduction

Multi-channel contexts

https://api.travis-ci.org/netresearch/t3x-contexts.png

Show and hide pages and content elements based on configurable "contexts". With the use of contexts, TYPO3 is able to do multi-channel output.

Examples for contexts:

  • Screen size < 500px
  • Browser runs on a tablet or mobile phone
  • Location is 15km around a certain place
  • User is from one of certain countries
  • User entered website with GET-Parameter affID=foo
  • User IP matches a given rule
  • A session variable is set
  • A combination of any other rules

Apart from the context rules, this extension also provides an API to use contexts in your own extensions.

  1. Install and activate extension contexts
  2. Clear TYPO3 cache

Optional: Install extensions contexts_geolocation for location-based context rules (continent, country, area) and contexts_wurfl for device-based rules (type check: phone, tablet, TV, ...; screen sizes, device/browser type).

  1. Log into the TYPO3 backend as administrator
  2. Goto Web/List view, root page (ID 0)
  3. Create a new record: TYPO3 contexts -> Context
    • Give it a title, e.g. "Affiliate ID: foo"
    • Select a type: "GET parameter"
    • GET parameter name: affID
    • Parameter value: foo
    • Activate "Store result in user session"
    • Save and close
  1. Goto Web/Page, select a page
  2. Edit a content element
  3. Select the "Contexts" tab
  4. For Context "Affiliate ID: foo", select "Visible: yes"
  5. Save

View the page. The content element is not visible.

Now add ?affID=foo to the URL and load it. The content element will be visible now.

You can visit other pages now. When you come back, the content element will still be visible - even though the GET parameter is not in the URL anymore - because "Store result in user session" had been activated.

The contexts extension ships with a number of simple contexts. All of them get stored in table tx_contexts_contexts.

A domain context matches when the domain the user visits is in the configured list.

This is helpful if the site is available on several domains, or when it is deployed on development/stage/live systems - you may choose to show a content element on the development system only.

You may use one domain per line.

When the domain does not begin with a dot, it will only match fully: www.example.org will not match the configured domain example.org.

It is possible to use a dot in front of the domain name. In this case, all subdomains will match: some.www.example.org matches the configured domain .example.org.

Checks if a GET parameter is available and has a certain value.

Activate "Store result in user session" to keep the context when navigating between pages.

When leaving the parameter values field empty, any non-empty parameter value will activate the context.

Matches the user's IP address. IPv4 and IPv6 are supported.

Supported notations:

  • Full addresses: 80.76.201.32
  • Prefix: 80.76.201.32/27, FE80::/16
  • Wildcards: 80.76.201.*, 80.76.*.37, 80.76.*.*

Checks if a HTTP header is available and has a certain value.

Activate "Store result in user session" to keep the context when navigating between pages.

When leaving the parameter values field empty, any non-empty parameter value will activate the context.

Combines other contexts with logical operators.

Contexts are referenced via their alias and can be combined with the following signs:

  • logical and: &&
  • logical or: ||
  • negation: !
  • parentheses to group parts of expressions: (...)

This context checks if a session variable with the given name is set (is not NULL).

The implementation of a context query in fluid templates looks like:

<div xmlns="http://www.w3.org/1999/xhtml" xmlns:contexts="http://typo3.org/ns/Tx_Contexts_ViewHelpers">
    <f:if condition="{contexts:matches(alias:'mobile')}">
        <f:then>is Mobile</f:then>
        <f:else>is not Mobile</f:else>
    </f:if>
</div>

The implementation of a context query in TypoScript looks like:

[userFunc = user_contexts_matches("mobile")]
    # do something, it's a mobile browser
[global]

t3x-contexts's People

Contributors

bmack avatar copitz avatar cybottm avatar just-tobi avatar kryslin avatar loco8878 avatar magicsunday avatar mbrodala avatar thoemel42 avatar

Watchers

 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.