Uutiset:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu
Advertisement:

Installing a MOD deleted the template file data that should be edited

Aloittaja Randem, joulukuu 19, 2013, 04:41:31 AP

« edellinen - seuraava »

Randem

I created a mod that works fine for install, uninstall and operations. I decided to add to it and found that any edits to a template from the install.xml file causes the template file to only have the additions that were added in the install.xml file, all the other code is gone... It happens every time. Is there some other way to change a template on install? It happened when I used search position="after" or search position="end". Here is an excerpt of the install.xml file that relates to the template file. Is there another method that I should be using instead?



      <file name="$themedir/Stats.template.php">
      <operation>
         <search position="after"><![CDATA[</script>';
   }]]></search>
         <add><![CDATA[
   // Randem Systems - RJ-20131218 - Start   
   global $sourcedir;
   include $sourcedir . '/StatsVisits.php';
   showtopicvisitstats();
   // Randem Systems - RJ-20131218 - End
   ]]></add>
      </operation>
   </file>
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

All Colours Sam

Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Randem

Here it is... NTIWH

<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
   <id>Randem:TopicVisits</id>
   <version>1.0</version>
   <file name="$sourcedir/Display.php">
      <operation>
         <search position="before"><![CDATA[// Get each post and poster in this topic.]]></search>
         <add><![CDATA[
   // Randem Systems - RJ-20131217 - Start
   require_once($sourcedir . '/TopicVisits.php');
   logtopicvisit($board, $topic, $user_info['id'],$user_info['ip']);   
   // Randem Systems - RJ-20131217 - End
   ]]></add>
      </operation>
   </file>
      <file name="$sourcedir/Stats.php">
      <operation>
         <search position="before"><![CDATA[// No daily stats to even look at?]]></search>
         <add><![CDATA[
   // Randem Systems - RJ-20131218 - Start   
   global $sourcedir;
   require_once($sourcedir . '/TopicVisitsStats.php');      
   gettopicvisitstats();   // Get the topic visit stats from our view table
   // Randem Systems - RJ-20131218 - End
   ]]></add>
      </operation>
   </file>
      <file name="$themedir/Stats.template.php">
      <operation>
         <search position="after"><![CDATA[</script>';
   }]]></search>
         <add><![CDATA[
   // Randem Systems - RJ-20131218 - Start   
   global $sourcedir;
   include $sourcedir . '/StatsVisits.php';
   showtopicvisitstats();
   // Randem Systems - RJ-20131218 - End
   ]]></add>
      </operation>
   </file>   
</modification>
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Arantor

Fairly sure you have before and after mixed up.

position="before" means to put the matched content *before* what you're adding, and position="after" means to put the matched content *after* what you're adding.

So in your case, the edit to Stats.template.php will be pushed inside the JavaScript, which won't help. But I can't obviously see anything wrong with the XML.
Holder of controversial views, all of which my own.


Randem

No I do not... As I stated I tried other entries for that option and none worked (besides after is EXACTLY where I need it to be). I do manually test where code should be before actually making the MOD. What you are seeing is the last attempt to see if ANYTHING worked and EVERY one of them resulted in the same results, all the data was gone from the template. This only happens to templates not any other file as I can tell. So, I have to believe that there is a bug in the system that does this for templates or this needs to be done another way. Either way this is a bad thing for the file to get it's content deleted on an installation of a MOD using the approved method of installation.

So, how to get past this aside from a manual installation or complete file replacement?
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Arantor

Holder of controversial views, all of which my own.


Randem

That is TOTALLY incorrect... I actually test so I know where it goes.
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Arantor

No it isn't, if you follow what I said before.

position=before puts the matched content before what you insert. position=after puts the matched after what is to be inserted.

SMF has done it this way since long before I came along and joined the dev team, the first time I wrote a mod in 2008 it was doing this...

But this is why I pretty much always use position=replace when writing mods (like I did in the 2.0.6 patch)
Holder of controversial views, all of which my own.


Randem

Who cares? This is written to where I need it to be... You do understand what development testing is, Yes? I test then I write the MOD to duplicate what I already have tested. It does not matter what anyone else thinks unless they have actually tested what I wrote. But it seems that you always need to have the last word even if it is ABSOLUTELY wrong...
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Arantor

So I don't know how SMF mods work? That's the line you're going with?

(I've only written about 75 mods for SMF, including the helpdesk mod for this very site, and I work on SMF's core as a core developer. I would hope I know how mods work by now, but I double checked before advising you.)

Good luck to you.
Holder of controversial views, all of which my own.


Randem

I really don't care... That's what I am going with! You don't know anything about what I am doing and you seem to NEVER answer the questions at hand and take the conversation of topic. The original question still stands, Please use your overwhelming knowledge to answer that question instead of attempting to give lessons and answers to question no one asks...

What is the answer to the original question???? If you don't have the answer you are just wasting other peoples time...
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Arantor

So first, use the proper XML and see if that makes a difference...

As in:

<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
   <id>Randem:TopicVisits</id>
   <version>1.0</version>
   <file name="$sourcedir/Display.php">
      <operation>
         <search position="after"><![CDATA[// Get each post and poster in this topic.]]></search>
         <add><![CDATA[
   // Randem Systems - RJ-20131217 - Start
   require_once($sourcedir . '/TopicVisits.php');
   logtopicvisit($board, $topic, $user_info['id'],$user_info['ip']);   
   // Randem Systems - RJ-20131217 - End
   ]]></add>
      </operation>
   </file>
      <file name="$sourcedir/Stats.php">
      <operation>
         <search position="after"><![CDATA[// No daily stats to even look at?]]></search>
         <add><![CDATA[
   // Randem Systems - RJ-20131218 - Start   
   global $sourcedir;
   require_once($sourcedir . '/TopicVisitsStats.php');     
   gettopicvisitstats();   // Get the topic visit stats from our view table
   // Randem Systems - RJ-20131218 - End
   ]]></add>
      </operation>
   </file>
      <file name="$themedir/Stats.template.php">
      <operation>
         <search position="before"><![CDATA[</script>';
   }]]></search>
         <add><![CDATA[
   // Randem Systems - RJ-20131218 - Start   
   global $sourcedir;
   include $sourcedir . '/StatsVisits.php';
   showtopicvisitstats();
   // Randem Systems - RJ-20131218 - End
   ]]></add>
      </operation>
   </file>   
</modification>
Holder of controversial views, all of which my own.


Randem

I reiterate... That is not proper for what I need to do and there is no way you are going to change it! You just have no clue... As I already stated TWICE that change made no difference. Please read...
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Arantor

Holder of controversial views, all of which my own.


Randem

And when search position="end" the same thing happens so, I guess SMF doesn't expect that...

And I guess SMF expect my code where it wants it too...
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Arantor

No, search position=end should find the end of the file. But only if the PHP file ends in a ?> and if it doesn't... all manner of strange things could happen.
Holder of controversial views, all of which my own.


Randem

I know and as I stated several times, the same thing happens no matter which option that I use the file only contains the changes, all other data is removed from the file. That is the original issue... It only happens with the template files, all other files modified are fine.
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Randem

Found the problem. the issue was with the package-info.xml file. Once that was taken care of the changes were made and the template file was not empty.
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Burke ♞ Knight

So, why don't you apologize for your rude attitude?
I can understand getting mad, but you did get a bit carried away.

People need to realize, when staff tell how the coding for SMF is, then by all means, BELIEVE it, because they know what the heck they are talking about.

So what if Arantor did not see all of what you were doing? He was telling you the CORRECT way to do the coding, to get the code you want, into the different areas.

Next time you ask for help, READ what is said, and don't get rude attitude when you THINK the other person does not know what YOU want.

Randem

Well, if you noticed the problem was NOT where anyone said it was. Giving someone wrong information does not make you right. It maybe right for another issue but those who read the post should realize that people ask for information they don't have. beating them over the head with information that obviously does not help is not right no matter how right the information is. It does not fit the question. AS you can see I found the answer to the issue myself without anyone mentioning the correct place to look... A bad answer does not make everything ok. In order to help you must provide something that is actually helpful to the one you hope to help. Giving information that in no way helped does not help at all...

BTW, my install.xml file was Absolutely correct so a lesson on that was not helpful...
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Advertisement: