Forums | Mahara Community
Developers
/
GUI textarea
25 December 2013, 15:16
I am trying to modify a plugin, the image plugin. I wanted to add an item to the GUI box, a mutliline text box. How do I go about doing this?
I founnd the corresponding code in lib.php file, and I was able to get as far as creating a text box that is 150 characters long. When I try to set it as textarea with a width of 255, only one line is displayed with a width of 10 characters. I am not sure what I am doing wrong.
Melissa
03 January 2014, 3:46
Hi Melissa,
I guess you are trying to add something like a description-text to the displayed image? Here's how you could do that:
in lib.php, in the function instance_config_form, add an element like this:
'description' => array(
'type' => 'textarea',
'title' => 'Description', // better use get_string() for internationalisation
'cols' => '150',
'rows' => '5',
'description' => 'Enter a description for the image', // better use get_string()
'defaultvalue' => (isset($configdata['description'])) ? $configdata['description'] : '',
),
That get's you the edit-box when you click the configure-icon.
To display the content, edit the render_instance function in the same file and access the saved value in configdata, like in the second-last line of the example above. Assign the text to a new variable in the smarty_core object and edit the image.tpl file accordingly.
Tobias