e107 Developer Guide
  • Welcome
  • Getting Started
    • Hello world example
    • Folder structure
    • Database structure
    • Debugging & problem solving
  • Classes and methods
    • Introduction
    • Alerts
    • Cache
    • CSS
    • Database
    • Date
    • Events
    • Forms
    • Javascript
    • Language
    • Logging
    • Meta
    • Parser
    • Plugins
    • Preferences
    • Redirection
    • Render
    • Route
    • URLs
    • User Data
  • Plugin development
    • Introduction
    • Plugin Builder
    • Admin-UI (User Interface)
    • Installation & configuration
    • Plugin shortcodes
    • Internationalisation (LAN)
    • Extending core functionality (addons)
    • Upgrading legacy plugins
  • Theme development
    • Introduction
    • Installation & configuration
    • Layout & templates
    • Theme Shortcodes
    • Styling (CSS)
    • Upgrading legacy themes
  • Templates, shortcodes & constants
    • Introduction
    • Templates
    • Shortcodes
    • Core Shortcodes
    • Constants
  • How-to's / FAQs
    • How to...
Powered by GitBook
On this page
  • Introduction
  • Examples
  • Example 1: Forum topic URLs
  • Example 2: Using optional parameters

Was this helpful?

Export as PDF
  1. Classes and methods

URLs

Please note: This page is under construction and has not been finished yet.

Introduction

You can generate a Search Engine Friendly (SEF) URLs using the following method:

e107::url($plugin, $key, $row, $options);
Parameter
Type
Description
Mandatory?

plugin

string

Yes

key

string

Unique key

Yes

row

array

Array of variable data such as id, title etc. eg. user_id, user_name

No

options

array

An associative array of additional options, with the following elements:

  • mode: abs | full (returning the absolute path or full URL)

  • query: an array of query key/value-pairs (without any URL-encoding) to append to the URL.

  • fragment: a fragment identifier (named anchor) to append to the URL. Do not include the leading '#' character.

(optional)

No

Examples

Example 1: Forum topic URLs

In this example we will generate search-engine-friendly URLs for a forum topic with the following code: .

// these values are usually loaded from the database. 
$data = array(
	'forum_sef'		=>	'my-sef-forum-name', 
	'thread_id'		=>  2, 
	'thread_sef'	=>	'my-forum-topic'
); 

$url = e107::url('forum','topic', $data);

The code above loads the following file: e107_plugins/forum/e_url.php and generates a URL from the following array data with the unique key topic:

$config['topic'] = array(
	'regex'    => '^forum/(.*)/(d*)-([w-]*)/???(.*)',
	'sef'      => 'forum/{forum_sef}/{thread_id}-{thread_sef}/',
	'redirect' => '/e107_plugins/forum/forum_viewtopic.php?id=$2'
 );

Only the value of 'sef' is used in this array. it substitutes the values {forum_sef}, {thread_id} and {thread_sef} with the variables in the $data array.

Example 2: Using optional parameters

TODO: Add examples using the options parameter

PreviousRouteNextUser Data

Last updated 2 years ago

Was this helpful?

Folder name of the plugin. (will use data from )

The end result would look something like this:

http://sitename.com/forum/my-sef-forum-name/2-my-forum-topic
e_url.php