Forum

Notifications
Clear all

Custom fields - saved!

Sheepcontrol
(@sheepcontrol)
Member Admin

Hi there,

there were questions regarding custom fields and so far, they would have gone lost in an upgrade (well, at least not copied, but you get the idea).

Now since that's not a desired behaviours, I added a custom field job to the entire process that can take care of this issue.
But therefore, it will need you help, because this thing is pretty much just a template.

There are examples in there, but I'll explain this stuff here:
Let's assume, you have a field named "songtext" for your stories (for the sake of an example), then this might look like this:

$fw->customFields['stories'][] =
[
"field" => "songtext",
"type" => "text",
"after" => "trans_to",
];
// If desired, add custom index
$fw->customIndex['stories'][] = "ADD KEY `songindex` (`songtext`(10));";
// Tell the script how to grab the data from the old table
$fw->customDataIn['stories'][] = "S.songtext";
// No need for a data out definition here
// $fw->customDataOut['stories'][] = "";

"customFields" is an array with MySQL field definitions to build an ADD FIELD.
"customIndex" obviously adds an index that is not within the regular table definition, this is optional
"customDataIn" tells the converter how to get the data - this field might have a different name of requires some SQL processing, all that is possible here
"customDataOut" depending on the module, this might or might not be required, should be stated in the section

In order for a table to recieve proper treatment, the section must be un-commented (removing the lines that say "<- remove to activate ->") and be edited to reflect the fields you want to preserve.
To copy multiple fields, duplicate the example blocks, they will automatically line up in their array - see example file.

Now because a new version of the installer would overwrite your custom stuff, the file provided is named "job_custom_examples.php" and will not be used. In order to activate it in the first place, rename to "job_custom.php".

See: wiki article @ https://efiction.org/wiki/Upgrade_Custom_Fields (which is a work in progress)

Quote
Topic starter Posted : 26/10/2017 9:31 pm
Share: