Jump to content
TNG Community

Mod Manager Parameter for a mod


lahem

Recommended Posts

My Married Name mod needs to have a local override to modify the SQL with extra custom conditions. After reviewing the %parameter% option I thought the task was almost over. But it seems that if you add code, in this case to globally.php which has a parameter and you then add the parameter to the mod code (after the edits) it sends the mod manager slightly insane.

From what I have seen when it is tinkering with the mod cfg file, as is mentioned in the handler code, it blindly changes all occurrences of the name in the file. Hohum, now I realise I can add a custom option to customconfig.php but that seems a bit of overkill when all I did in the mod code (or planned to do) is have a variable 'extraWhere' and add it..... Now I need to define a global for a variable in the custom config which is now going to be included everywhere unnecessarily.

	// Larry's display married name mod helper code
	if( $row['sex'] == 'F' )
	{
		$extraWhere = '';
		$personID = ucfirst( $row['personID'] );
		$sql = "SELECT p.`lastname`, p.`lnprefix`
		// etc
	}

What I think is needed is either the 'parameter' code be able to handle a 'local' variable or the mod manager needs to learn about local variable setting. Obviously I am not waiting I will use the custom config and add a variable with an ugly long name and include it as a global 😎 bugger I just realised I am back to the same issue.... More digging I suppose

Link to comment
Share on other sites

Well more digging, it seriously lost its mind because I showed an example of what could be put into the variable and it didn't like it at all, in case you want to do something similar;

%target:globallib.php%
%fileoptional:%
%parameter:$extraWhere:%
%desc:Additional instructions to the query to find the maiden name<br />
&nbsp;Default is empty('')<br />
&nbsp;&nbsp;&nbsp;&nbsp;Example: AND &#40;f.marrtype = '' OR f.marrtype IS NULL&#41;<br />
&nbsp;BE CAREFUL ... raw SQL is used literally%
%end:%

 

Link to comment
Share on other sites

Mod Manager parameters are more to control or offer how the mod can take 2 different paths within the mod code.  I would NOT recommend using the Mod Manager parametes to modify the TNG processing paths.

If you need to do something different than TNG does for you mod, then it is sometimes better for the mod to provide its own function rather than modify a TNG function that may impact processing elsewhere.

While you married name mod initially looked interesting, I backed it off because it changes maiden name information to married name.  The French Canadian and Acadian communities always maintained their maiden names in official records so I am not interested in changing my maiden name displays to married name ones.

Not sure where you are finding the example you show since you do not identify any mod names.  The %fileoptional parameter is also dubious on globallib.php since that is an integral file required by TNG.  The %fileoptional parameter should only be used for files that some users insist on deleting or not copying to their hosting service such as the language files or maybe the template files.

Link to comment
Share on other sites

My usage was as per the MediaWiki one, I think it is now fine, the usage is just fiddly.

As for your usage case, the mod is obviously intended for where the wife takes the husband's family name. I realise that is not universal but where it is used (and common) it is helpful so that each female record is left recorded with their original birth family name and only shown as the mod does for married name.

 

Link to comment
Share on other sites

Can you provide the URL for the TNG Wiki article, so I can double check the context? 

Link to comment
Share on other sites

Thanks.  I see no mention in that article of using the Edit parameter to modify TNG core file behavior.  I personally would not use it that way because of the possibility of impacting other parts of TNG.

The following information is dated

    The Default value should also be specified as a single-quoted value within parentheses as part of the %desc keyword, such as Defaults to ('png') in the example below. The single-quoted value within the parentheses will be used to restore the default value. 
    When a user wants to clear the value of a variable, they will need to provide 2 single-quotes in the edit parameter field.

in that values should not be specified in quotes.  Looks like something I wrote in the early days when the Mod Manager as a mod in TNG v7

Quotes should not be used for values.

Updated:  I have updated the TNG Wiki article to remove the single-quoted requirement.  Parameter values should not use quoted values

Link to comment
Share on other sites

I have changed it to default() to reflect your guide, though default('') does work as well.

There is not much latitude for allowing a substitution of the mod code, I will change the variable name to be hugely unlikely to cause a conflict but the method to allow the end user to change a variable is defined there isn't an alternative what else am I supposed to do?

Variable now named $MarriedModExtraWhere which would never conflict with an internal name unless someone was trying to be cute.

Link to comment
Share on other sites

Personally, I would not allow users to provide SQL in a mod parameter.   To me the mod parameter would be whether to use the parameter for the extra where clause as a true or false value and put the SQL code as part of the modification to the TNG code where it gets executed if the variable = true and bypass if false.

my 2 cents

Link to comment
Share on other sites

If the Mod Manager parameter could be set to true or false, could you not put the SQL extrawhere in the modification to the TNG code so that it is added to the SQL select statement when set to true and the extrawhere is a null string when the value of the edit parameter is set to false 

Link to comment
Share on other sites

Larry,

I still think you are asking for problems when you want the TNG Users to add SQL code in the Edit Options screen.

I was not able to test your new version because it now conflicts with the Living Color Mod since you now modify admin_people.pp

line 7: %target:admin_people.php% verified
line 8: %location:% #1 Bad target

Not sure why you are now modifying that location.

I also don't how you are running your development environment, but the cfg file date is 8 May 2063, which always causes your mod .cfg file to sort to the top when I sort by modified date in descending order

Also, your TNG Wiki article indicates that you modify genlib.php when in fact you are modifying globallib.php   Some of us do use the categories on the TNG Wiki to find which mods are modifying what TNG files.

Link to comment
Share on other sites

Larry,

In your Wiki article you note in the Usage Section:

"The order of the 'marriages' decides which male name to use, make sure that your marriages are ordered correctly by date"

You might wish to add that spouses can be sorted by marriage date in Admin:Import/Export: Secondary Processes:  Sort Spouses.

I agree with Ken that giving the user an option to add SQL code might be troublesome for support.

 

Link to comment
Share on other sites

On 3/31/2019 at 1:06 PM, Ken Roy said:

If the Mod Manager parameter could be set to true or false, could you not put the SQL extrawhere in the modification to the TNG code so that it is added to the SQL select statement when set to true and the extrawhere is a null string when the value of the edit parameter is set to false 

That would be possible, especially if someone click 'I want option X ' then that triggered  a change to a variable to be used ... yes that's doable . 

7 hours ago, tngrlkrz said:

You might wish to aï»żdd that spouses can be sorted by marriage date in Admin:Import/Export: Secondary Processes:  Sort Spouses. ï»ż

Added

 

9 hours ago, Ken Roy said:

I was not able to test your new version because it now conflicts with the Living Color Mod since you now modify admin_people.pp


line 7: %target:admin_people.php% verified
line 8: %location:% #1 Bad target

Not sure why you are now modifying that location.

Because 'sex' is not included in the SQL query for the individual and is needed to treat the person as a 'wife'

9 hours ago, Ken Roy said:

I also don't how you are running your development environment, but the cfg file date is 8 May 2063, which always causes your mod .cfg file to sort to the top when I sort by modified date in descending order

I do not know why MacOS is creating zips with stoopid dates, just built it with cli zip and updated the file.

9 hours ago, Ken Roy said:

Also, your TNG Wiki article indicates that you modify genlib.php when in fact you are modifying globallib.php   Some of us do use the categories on the TNG Wiki to find which mods are modifying what TNG files.

Fixed

Link to comment
Share on other sites

I guess I did not ask the question correctly - why does your mod require a change to admin_people.php which is used to Edit persons.  I do not see admin_people.php being called for your display of the Married name instead of maiden name for married women. 

Since I was not able to install your mod dues to the conflict with Living Color Mod, I cannot tell whether you are also modifying the name display for the women when editing.

Link to comment
Share on other sites

Thanks Larry,

I guess I do not understand the code in your mod since I do not see getName() being used in the changes you make to globallib.php

Note that I did look at where you are making that modification in the TNG version of globallib.php

Link to comment
Share on other sites

globallib has getNameUniversal() (called by getName() & getNameRev()) and it renders the surname, the change modifies the return to have the maiden name included, that's the whole point of the mod.

Link to comment
Share on other sites

Thanks Larry,

It might be helpful to add comments within the .cfg file to show what function is being modified by a %location or target

Note that there are not any comment characters as such used by the Mod Manager, but it treats any lines entered between %target:  and %location as comments   Some developers enter  the comment line starting with the php comment characters ( // or ## ) but that is not a requirement.

 

Link to comment
Share on other sites

Might I suggest that if there is a custom to the formatting for a mod cfg that the etiquette should be a wiki page so that newbies have a chance?

The zip date, still trying to work out about to go through the fun of reporting an issue with the zip compressor, did notice that OSTicket when they pumped out their latest release the zip permissions were all screwed up maybe something weird is happening.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...