Jump to content
TNG Community
Sign in to follow this  
Brett

Mod Paramenter - Option to show or hide Row

Recommended Posts

Brett

The Wiki page Mod Manager - Edit Parameters states: By setting a mod parameter a webmaster could, for example, prevent exposing information to certain users, or could conveniently change the color scheme for a custom form.

I have searched the Wiki and Forum but cannot find if Paramenter Options could do something similar to remove or show a row.

As an example, a Mod is installed that removes the Suffix Row on the Person page

%target:getperson.php%

%location:%
        if( $row['suffix'] )
            $persontext .= showEvent( array( "text"=>$text['suffix'], "fact"=>$row['suffix'], "event"=>"NSFX", "entity"=>$personID, "type"=>"I" ) );
%end:%
%replace:%
//        if( $row['suffix'] )
//            $persontext .= showEvent( array( "text"=>$text['suffix'], "fact"=>$row['suffix'], "event"=>"NSFX", "entity"=>$personID, "type"=>"I" ) );
%end:%

Rather than installing/uninstalling the Mod, could a show/remove option be available as a Mod option? If so, how might I code this?

Share this post


Link to post
Share on other sites
tngrlkrz

Brett,

The wiki article also states: %parameter: % is used to provide the variable whose value can be changed via the Edit function.  In the top of each edit option box is the name of the php variable ($xxxxxx) and the php file it expects to find that variable.   Since those variables are loaded every time the php file is executed, the php code simply has to test that variable and, in your example,depending on the value, include or bypass the code which displays the row.  I would suggest downloading or inspecting one of your installed mods with edit options to see how the variable is set and used.

The article doesn't really show an example of how the variable is tested, likely presuming the mod author knows how to do that.

 

Share this post


Link to post
Share on other sites
Brett
7 hours ago, tngrlkrz said:

the php code simply has to test that variable and, in your example,depending on the value, include or bypass the code which displays the row.  I would suggest downloading or inspecting one of your installed mods with edit options to see how the variable is set and used.

 

Thanks for the response Ron.

I have a couple of mods I am working on that I have options working. I had spent some time looking at mods with options that might add or remove rows but had not found any that did that.

Your words 'include or bypass the code' clicked something and I saw where my thinking was off. My mind kept thinking variable as one already set by TNG not one I set myself.

I will work with the new thoughts.

Thanks again Ron.

Share this post


Link to post
Share on other sites
Brett

I have coded the below. It works for the 2 options but the default always returns a nul field. Any ideas on what I may be doing incorrectly please.

This is a TNG mod directive file
%name:TestSuffix%
%version:v12.1.0.0%
%description:This is a test mod. Currently testing removal of the Suffix row on the person page.%
%author:Brett %
%wikipage:%

%target:getperson.php%

%location:%
        if( $row['suffix'] )
            $persontext .= showEvent( array( "text"=>$text['suffix'], "fact"=>$row['suffix'], "event"=>"NSFX", "entity"=>$personID, "type"=>"I" ) );
%end:%
%replace:%
//        ***** Begin changed by TestSuffix Mod *****
        $suffixrow = 1;
        if ($suffixrow==2){
//            if( $row['suffix'] )
//                $persontext .= showEvent( array( "text"=>$text['suffix'], "fact"=>$row['suffix'], "event"=>"NSFX", "entity"=>$personID, "type"=>"I" ));
        }
        else {
            if( $row['suffix'] )
                $persontext .= showEvent( array( "text"=>$text['suffix'], "fact"=>$row['suffix'], "event"=>"NSFX", "entity"=>$personID, "type"=>"I" ));
        }
//        ***** End changed by TestSuffix Mod *****
%end:%

%parameter:$suffixrow:1%
%desc:<em>Enter 1 to show the Suffix Row<br /> Enter 2 to remove the Suffix Row<br />Default is 1<br />Any other value, default is used<br />
Do not use quotes!</em>%

Share this post


Link to post
Share on other sites
Ken Roy

The default parameter value MUST be coded within parentheses so  it should be coded

%desc:<em>Enter 1 to show the Suffix Row<br /> Enter 2 to remove the Suffix Row<br />Default is (1)<br />Any other value, default is used<br />
Do not use quotes!</em>% 

Also since this appears to be a true of false then maybe you should code it as

%desc:<em>Enter true to show the Suffix Row<br /> Enter false to remove the Suffix Row<br />Default is (true)<br />
Do not use quotes!</em>% 

Of course your code in getperson.php also needs to change to check for your parameter

%location:%
        if( $row['suffix'] )
            $persontext .= showEvent( array( "text"=>$text['suffix'], "fact"=>$row['suffix'], "event"=>"NSFX", "entity"=>$personID, "type"=>"I" ) );
%end:%
%replace:%
//        ***** Begin changed by TestSuffix Mod *****
        $suffixrow = true;
        if( $row['suffix'] && $suffixrow)
            $persontext .= showEvent( array( "text"=>$text['suffix'], "fact"=>$row['suffix'], "event"=>"NSFX", "entity"=>$personID, "type"=>"I" ) );
//        ***** End changed by TestSuffix Mod *****
%end:% 

It is difficult to test and debug code snippets in the forum.  I do not have the time to modify getperson.php to validate that my new parameter changes are correct.

Share this post


Link to post
Share on other sites
Brett
31 minutes ago, Ken Roy said:

The default parameter value MUST be coded within parentheses

Thanks Ken, I must have looked at that for an hour and did not see I had not enclosed with brackets.

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
Sign in to follow this  

×