Forums | Mahara Community

Developers /
How to add fields to the "My goals" page in /artefact/resume/goals.php

17 March 2009, 9:37 PM

Hi, all.

I'm afraid I'm having an awfully hard time understanding how to use Artefacts. I've added a few new fields to the My Goals form (/artefact/resume/goals.php), but I'm not able to update the database. Perhaps I don't understand what's going on.

Now, I made the appropriate modifications to goals.php and lib.php. In goals.php, I added the lines

try {
    $bestemployer1 = artefact_instance_from_type('bestemployer1goal');
catch (Exception $e) {}


        'bestemployer1goal' => array(
            'type' => 'text',
            'rows' => 1,
            'cols' => 100,
            'defaultvalue' => ((!empty($bestemployer1)) ? $bestemployer1->get('description') : null ),
            'title' => get_string('bestemployer1goal', 'artefact.resume'),

to the $gform array. In lib, php, I added


to what get_artefact_types() returns, 


to what get_goalandskill_artefact_types() returns in the class ArtefactTypeResumeGoalAndSkill, the new class

class ArtefactTypeBestemployer1goal extends ArtefactTypeResumeGoalAndSkill { },

and, finally, to the catch clause in goalandskillform_submit(), I added

           try {
               $a = new $classname(0, array(
                  'owner' => $USER->get('id'),
                  'title' => get_string($key),
                  'description' => $value,
            catch (Exception $e) {
                $form->json_reply(-1, 'Unable to find artefact '. $key .' for owner '.$USER->get('id') .' e = '.$e);

I also made appropriate additions to the language file.

Anyway,  with this new try-catch block I added, I was able to discover that, when new $classname is invoked, a new artefact is NOT created in the artefact table -- as I would expect the framework to do -- because the $id is not null.

So, what I wanted to know is this. If forms like goals.php don't insert new entries into the artefact table when none existed before, when are artefacts like personalgoal, careergoal and academicgoal created? How can I create these artefacts when none exist yet? What am I not understanding??

Your assistance in the past has been nothing short of awesome. So, a big thanks, yet again! 



18 March 2009, 5:36 PM

Hahaaaah! I fixed it!

I didn't realise that identifiers of installed Artefact Types were located in the table artefact_installed_types. I simply added the appropriate pairs to the table and was done. That is,

INSERT INTO artefact_installed_types (name,plugin)

       VALUE ('bestemployer1goal','resume');

is what was left for me to do. All is well now.

Nigel's profile picture
Posts: 1643

18 March 2009, 6:18 PM

Heh - you can make the upgrade system add them too, if I recall correctly. Just bump the version number of the artefact plugin (version.php), and then run the upgrade. I believe it will re-scan your plugin and add any new artefact types.
samana s's profile picture
Posts: 1

04 January 2011, 2:13 PM


I was looking for an example of how I could rename existing fields, add new fields and probably also whole new tables to the database...the info here and on the artefact plugins page lookis helpful, I'm going through those as I type this message :)

But any additional help/support/advice will be greatly appreciated...

FYI: I'm a newbie researching for my firm!

Thanks in advance!


4 results