We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Variables in text keys | Forum

Sean
Sean Sep 12 '13
Okay so this is confusing me, I've seen some text keys contain {$variables} to display dynamic data - how do they do it!


Whenever I put them in it literally just displays {$variable} not the variable data.


I've developed a few plugins (basic ones to get the hang of the programming language) but being able to put variables into text keys would help a lot!


Specifically showing variables in feedback boxes.

Alia Team
Alia Sep 16 '13
Sean, here comes the magic =)

You have to "tell" system what are the variables within the .php code of your plugin.
Format: OW::getLanguage()->text($prefix, $key, $vars)

Example:
Existing text key is:

File {$file_name}

{text key='mailbox+upload_file_name'}


The code within the .php file ( in this case mailbox/bol/conversation_service.php)


$language->text('mailbox', 'upload_file_name', array('file_name' => $fileList['name'][$i])) . " " . $message);


where


$prefix= mailbox

$key=upload_file_name

$vars= file_name



Structure in terms of format might vary. As you have noticed in the given example there is no OW::get part. All depends on how your plugin is developed.


If you are the type of person who can learn by comparing existing code, you can easily figure things out just by looking into existing code within existing plugins.


I am sure that the variable you would like to add to your plugin is already used in other places, just find needed text key in admin panel, copy the part after + sign in the text key. Find needed .php file and search by the copied part, you will see the needed code that you can just copy/paste.

Alia Team
Alia Sep 16 '13
If you get a specific question while developing your plugin, create a topic under "Custom Code Modifications" section of our forum. Daisy specializes in custom modifications and will be able to help you more then me.
Sean
Sean Sep 16 '13
Aliia, this is fantastic! Thank you so much!
Alia Team
Alia Sep 16 '13
Topic was moved from General Questions.