Community Documentation

Very Basic Custom Token with Domain Access

Last updated March 19, 2012. Created by mgladding on January 31, 2012.
Edited by bfr. Log in to edit this page.

Here is a simple way to create a custom token that you can use with Domain Access. In this case there are only 2 domains, but you could easily adapt this as many domains as you want. To find out what domain uses which domain id go to Admin > Structure > Domains

1. Go to Admin > Structure > Custom Token, click on Add Token
2. Enter a Token Name and Description
3. Choose "Custom Tokens" for the Token Type
4. In the PHP Replacement text area enter something like this:

global $_domain;
if ($_domain['domain_id'] == 1 ) {
  $basic_token = 'Some text for domain one';
  return $basic_token;
  }
else {
  $other_basic_token = 'Some text for domain two';
  return $other_basic_token;
  }

5. Hit "Save Token"

Back on the Custom Token main page you will now see your custom token outputted in the "demo" column. You can use this new token as an input filter if you have the Token Filter module installed.

The tokens will be [custom:basictoken] and [custom:otherbasictoken] respectively.

Comments

newbie

Hi guys!

Question:

I wanna "print" [node:field_term_x] or [node:field_term_y] depending on the [node:content_type].

The problem is that i don't know how to implement it! :(

Could anyone help me to translate this to php language please?

if [node:content_type] = "page";

"print" [node:field_term_x];

THANKS!!

Imagecache Tokens

I need to use imagecache tokens in some rules.

Can this be done with this module and can an example be given?

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 7.x
Level
Beginner
Keywords
Custom Tokens
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here