Jump to content
TNG Community
lahem

Mod Manager Parameter for a mod

Recommended Posts

lahem

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

Share this post


Link to post
Share on other sites
lahem

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:%

 

Share this post


Link to post
Share on other sites
Ken Roy

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.

Share this post


Link to post
Share on other sites
lahem

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.

 

Share this post


Link to post
Share on other sites
Ken Roy

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

Share this post


Link to post
Share on other sites
Ken Roy

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

Share this post


Link to post
Share on other sites
lahem

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.

Share this post


Link to post
Share on other sites
Ken Roy

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

Share this post


Link to post
Share on other sites
lahem

If the parameter widget allowed a method of selecting options perhaps I would but I am using what is available, 

Share this post


Link to post
Share on other sites
Ken Roy

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 

Share this post


Link to post
Share on other sites
Ken Roy

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.

Share this post


Link to post
Share on other sites
tngrlkrz

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.

 

Share this post


Link to post
Share on other sites
lahem
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

Share this post


Link to post
Share on other sites
Ken Roy

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.

Share this post


Link to post
Share on other sites
lahem

It uses getName() in multiple places hence sex is needed to display the maiden name where it shows the individuals

Share this post


Link to post
Share on other sites
Ken Roy

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

Share this post


Link to post
Share on other sites
lahem

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.

Share this post


Link to post
Share on other sites
Ken Roy

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.

 

Share this post


Link to post
Share on other sites
lahem

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×