Jump to content
TNG Community
mjaro

ModManager: how to replace big block of lines?

Recommended Posts

mjaro

In my mod I'm going to replace 55 lines of the original php file.

What is the best way to achieve this? Is it the only way to put the whole block of lines in the %location% ... %end% statement? (I know that it could be line fragments, but still fragments of ALL lines).

Please give any suggestions.

Best regards

Michal

Share this post


Link to post
Share on other sites
Ken Roy

Michal,

Do you really need to replace 55 lines of the original code?  Depending on the module you are replacing code in, you are likely to cause conflicts with other mods

27 minutes ago, mjaro said:

%location% ... %end% statement

%location:% and %end:% is the verification where you want to Insert or replace code

You should read the TNG Wiki article on Avoiding Mod Conflict although it appears that another user had changed the beginning of the article, which used to indicate How to Avoid Mod Conflicts, as opposte to how to detect them.  Other articles in the Mod Manager category might also be helpful

Share this post


Link to post
Share on other sites
mjaro

Thanks, Ken.

My private mods are replacing several parts of the 55-lines block. I'd love having a kind of "from..to" construct in ModManager.

I'm using modified Template 7,  in particular I'm changing upper and left part of every page. Actually I have a layout identical in all pages visible by users. I do this with the use of a few private mods. I understand well "Avoiding Mod Conflict" topic and a dozen of v13 mods I consider interesting remained compatible with my site since v8 (incl. Signature Display ;) )

But after your advice I decided to replace complete index.php and topmenu.php by hand to avoid so many particular changes inside... I'll use a Windows script to avoid human error.

(BTW ModManager could allow deleting/overriding files saving their backup copies for case of uninstalling mod).

Best regards,

Michal

 

Share this post


Link to post
Share on other sites
tngrlkrz

Each has their own technique, but while I have many mods which modify php modules, none of them modify template files. For those I work directly  outside of MM with a copy of index, topmenu, footer,etc files, renaming the originals with some suffix, such as 'O'.  I know also I can get the original from the distribution zip at any time.  I also make use of mytngstyle.css for css changes.  I do this for all the templates I support.  With TNG updates, I do not replace the template folders, but examine what might have changed (usually no changes, or very little).

You are taking a similar approach by making your own topmenu and index php files. That is a better approach since it becomes too cumbersome to use MM for so many changes when you do extensive template revisions.

 

Share this post


Link to post
Share on other sites
Ken Roy

Michal,

I answered the way I did because you had not specified where you were making changes.  I personally use the Mod Manager to replace parts of the template files, so if you block of 55 lines was in the index.php file, it would be perfectly acceptable to replace large blocks especially since it is a private mod.  I have also created mods for where I change the TNG defaults in the different configuration files, mainly as documentation so I don't have to wonder where I saved my document that tracked my changes.

As Ron, said we all have our own way of doing things.   You could take things further and create your own template.

Share this post


Link to post
Share on other sites
mjaro

Ken, Ron,  thank you for all your comments, very important for me - layman.

I run some scripts on PC side (before I import gedcom to TNG), and MM scripts on server side. I also run a PHP script doing some site modifications independent of MM (I call it via link inserted at admin page). It could be much better if I can do all the things in one place on server side (for obvious reasons). It seems to me that the only missing critical MM property is a possibility of overwriting files (in a reversible way, like any other MM operations). I've read an explanation why MM cannot do that but ...I don't understand it. Could you comment the problem in your words?

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

×