daniel__
daniel__

Reputation: 11845

Add custom token in joomla 2.5

I need to add a custom token in this JS script, when using Joomla 2.5. What is the correct way to add a token? This (**CUSTOM_TOKEN**) doesn't work and I can't find relevant documentation about this.

I don't know if is relevant, bus I am using the language manager and the section Overrides to add the string value.

if (element) {
    $('.content').after('<div><a id="scrollUp" href="#">▲</a><a id="scrollDown" href="#">▼</a></div><span>'**CUSTOM_TOKEN**'</span>');
}

Upvotes: 1

Views: 125

Answers (1)

Valentin Despa
Valentin Despa

Reputation: 42622

Load the Joomla JavaScript framework

<?php
JHtml::_('behavior.framework', true);

Make string available to Javascript (you need to define all strings you want to use (I don't know if it's somehow possible to load them all. I just needed 2-3 so I didn't bother to search further.

JText::script('COM_HELLOWORLD_TEXT_DEMO');

Use it in JavaScript

Joomla.JText._('COM_HELLOWORLD_TEXT_DEMO')

I've seen once a docu page with this stuff, but I can't seem to find it how.

Let me know if this helps.

Upvotes: 1

Related Questions