Jump to content
TNG Community

ModManager: how to replace big block of lines?


mjaro

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Ken, Ron,

following your advice I've created my own template.

I still needed to overwrite some TNG files: sprites (to create an additional tab) and text/alltext/admintext (because of dozens changes). Thus I prepared mods which make all changes outside index/topmenu and put a button that allow runing a script doing overwritings.

It was a really good decision: the new  template is quite simple and it is easy to make any further experiments with it. The supplementing mods are now also simple and all will be easier to maintain.

Anyway, I still don't understand why MM cannot safely overwrite files (creating backup1, backup2, etc. to be able to reverse the operations, like my script does).

Best regards,

Michal

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...