Forums | Mahara Community

Developers /
Not sure where to put plugin code


anonymous profile picture
Deleted user
Posts: 112

26 December 2013, 1:17 AM

I wanted to modify the internal text "textbox".  I just want to copy this plugin and do some custom modifications.  I copied the whole directory, and did my changes.  But when I tried to install it, it says 

nternal/img-textbox Not installable class PluginBlocktypeImg-textbox for type blocktype in plugin internal/img-textbox was missing.

I am assuming that I just need to move the directory, but I am not sure where I need to move it to.

Baiscally, I just want to change this internal plugin, so that the attached images are displayed instead of being attached.  But I don't want to change the actual internal plugin.

Thanks,

Melissa

 

Tobias Zeuch's profile picture
Posts: 99

03 January 2014, 4:09 AM

Hi Melissa,

usually all the plugins you create (or you copied and modified) go in one of these three folders: /artefact, /blocktype or /notification. Artefacts, however, can have depending blocktypes, that's the case with the textbox, for example. I think, I would still copy the textbox folder into the /blocktype-folder, but if someone with a deeper understanding of the plugin-system tells you differently, listen to him. 

You can, however, easily copy the textbox-folder and modify it. Only thing you have to do is changing the name of the PluginBlocktypeTextbox-class that you find in lib.php, to match the plugins name.

Also it seems that you have to stick to alphabetical-only plugin-names. I first used a dash to separate the names but when I tried to add the copied textbox, I got an error-message saying that the blocktype-parameter wasn't aplhabetical-only. 

Cheers

Tobias

anonymous profile picture
Deleted user
Posts: 112

08 January 2014, 3:54 PM

I copied the texbox folder into the blocktype.  I added the word "plus" to end of textbox whereever I saw it in the lib.php code.  My problem now is that my strings are messed up.  The button title and block default title is

[[title/blocktype/textboxplus]]

Not sure what exactly I did wrong and how do I go about fixing it.  I removed the word ".internal" from the textbox.

Thanks for any help.  When I am done with this plugin, I will submit it to the bug tracker to be implemented into the main core, because I think that it is a plug that others will find useful.  

Melissa

 

Tobias Zeuch's profile picture
Posts: 99

08 January 2014, 8:54 PM

I had forgotten about the language file. When you translate a string with the get_string("something", "blocktype.textbox")-function in the php-code or the {str tag="something" section="blocktype.textbox"} function in the templates, it looks for a blocktype.textbox.php-file in the folder lang/en.utf8/

So you should rename the blocktype.textbox.php file to blocktype.textboxplus.php to match your plugin name and the calls to get_string() and {str tag=...} accordingly

Tobias

anonymous profile picture
Deleted user
Posts: 112

09 January 2014, 6:01 AM

I renamed my language file (inside my plugin directory) to 

"blocktype/textboxplus/lang/en.utf8/blocktyp.textboxplus.php"

But I am still getting those "[[... " strings.  I know that i am probably doing something very stupid, but for the life of me, I cannot figure out what.  I also tried to clear my cache thinking that might be the problem. 

Do I need to uninstall and reinstall my plugin?  How exactly do I go about doing that?  I installed the plugin with the language filename not the correct one.

melissa

 

Robert Lyon's profile picture
Posts: 425

09 January 2014, 8:37 AM

Hi Melissa,

I note the line you posted

"blocktype/textboxplus/lang/en.utf8/blocktyp.textboxplus.php"

has a spelling mistake 'blocktyp'

To get the language file connecting you need to follow this pattern:

In the get_string() call the 2nd variable needs to be 'blocktype.nameofplugin' if the plugin lives in htdocs/blocktype/ directory.

E.g. to get the title of the myfriends block we have: get_string('title', 'blocktype.myfriends');

that uses the strings in htdocs/blocktype/myfriends/lang/en.utf8/blocktype.myfriends.php

If the plugin is part of an artefact then the 2nd variable needs to be 'blocktype.nameofartefact/nameofplugin'

E.g. to get the title of the textbox block, which is a part of the internal artefact type we have: get_string('title', 'blocktype.internal/textbox');

that uses the strings in htdocs/artefact/internal/blocktype/textbox/lang/en.utf8/blocktype.textbox.php

So to get your strings to work we need to know what directory you have put the textboxplus plugin into. Is it htdocs/blocktype/ or htdocs/artefact/internal/blocktype/ or somewhere else?

Cheers

Robert

 

anonymous profile picture
Deleted user
Posts: 112

09 January 2014, 4:46 PM

Than you, thank you, thank you.  Your post solved my problem.  For some reason, the plugin that I copied to use as a starting point has the get_text("title", "blocktype/pluginname") -- with a slash.  I changed all of the slashes to dots and everything now works.  Yea.

The guts of my new plugin works.  I just need to add a few bells and whistles, and then I can submit it to be added to the Mahara core (or at least put up for others to use).  I will post a link to the bug where I attach the code when I have done that, which will probably be on Sunday.  I want to test the plugin in regular use for a couple of days before I submit any code.

Thank you everybody who help me with this.   

Melissa Newman

 

7 results