Freebie

Introduction

Tell EE to ignore certain segments when routing. Put useful segments into your URI without getting 404s, bad templates, or messing up the routing Structure uses.

Installation

Prerequisites

Make sure your system meets the minimum requirements:

Installation Instructions

Update instructions

Known Issues

Template caching

Since Freebie spoofs the URI that EE uses for template caching, it can cause problems with caching. It is recommended that you don’t use Freebie for functionality that you’ll need to cache using EE’s native caching methods.

“The URI you submitted has disallowed characters.”

This message can occur when using some modules, or during member account activation. The current known fix is to change your $config[‘permitted_uri_chars’] to include ?, =, and &.

$config[‘permitted_uri_chars’] = ‘a-z 0-9~%.:_\\-&?=’;

Template Tags

Freebie Segment Tags

Inside a template, you can access the original, un-effed-with URL segments using {freebie_1}, {freebie_2}, etc. These will return the segments you see in your browser’s location bar — however, if you use {segment_1} instead, you’ll get back the segments EE is actually parsing. For example, if you set “preview” and “comments” as Freebie segments, and visit…

/blog/preview/my-favorite-post/comments/

…your template vars will return the following:

Freebie:any

Use {exp:freebie:any name="segment_name"} to see if any segment matches the “name” string. Example:

/blog/preview/my-favorite-post/comments/

{exp:freebie:any name="blog"} == "true"

{if "{exp:freebie:any name="comments"}" == "true"}<h2>Show comments</h2>{/if}

Freebie:is_number

Use {exp:freebie:is_number segment="3"} to see if a segment is numeric or not. This is useful when you’re ignoring numeric segments, but want to test for their presence.

Freebie:category_id, _name, _description, _image

Use {exp:freebie:category_id segment="3"} to get the category_id of a segment. Useful in a number of ways. {exp:freebie:category_name segment="3"} will return the name of the category, and similar requests for category_description and category_image will do the same.

If you want to specify a group and/or site ID to pull the category from, use the following syntax: {exp:freebie:category_id segment=“3” group_id=“2” site_id="1"}

To get the category ID for a channel:entries tag, make sure to parse inward and use single quotes for the freebie arguments. Example:

{exp:channel:entries channel="news" category="{exp:freebie:category_id segment='2'}" parse="inward"}

A few more

{freebie_last} will get you the last segment from the original URI.

{freebie_break_1}, {freebie_break_2}, etc will return the segments after a break segment.

Settings

Basic settings

preview|success|error

preview success error

Wildcards

march|april|may|ju*|august

The wildcard in ju* means that both june and july will be freebie segments.

Numbers

You can set an option to automatically ignore all number-only segments – this is useful for using urls like blog/2010/20/ in Structure.

Break segments

Break segments are entered just like Freebie segments, but instead of being ignored, break segments tell EE to ignore all following segments. Example: You’re working in Structure, and want to use author urls and dates to control a blog, like so: /blog/lucille/2010/10. If you set “blog” as a break segment, you can throw whatever you want into the URI after this point without it affecting the template or page routing.

Break on category URL indicator

If you set this option, Freebie will automatically ignore your category URL indicator and any segments past it.

Always parse pagination

This will cause Freebie to always parse pagination.

Always parse

Freebie isn’t very subtle, so sometimes it can screw with existing EE functionality or plugins (especially when you set it to ignore numeric segments). That’s why there’s ‘Always Parse’, which acts like an override, telling Freebie to stop messing with this segment and any segments after it. This is especially useful with ‘search’ templates.

Where credit is due

Doug Avery is the brain behind freebie for EE2.

Changelog

3.0.0 (05-12-2017)

2.0.4 (12-06-2017)

2.0.3 (15-03-2017)

2.0.2 (28-02-2017)

2.0.1 (23-02-2017)

2.0.0 (16-12-2016)