Manual installation of mods: Difference between revisions From Online Manual

Jump to: navigation, search
m (1 revision)
No edit summary
 
(17 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Originally Written by A.M.A.
__NOTOC__{{version specific
|version=2.0.x
|content=If you are running SMF 2.x, please try using the [[Package_manager#Advanced|emulate version]] function before editing the package.
}}


Mods are installed on the default theme's template files. It is hard for a Mod's author as well as a [[Theme] creater to make Mods work with other themes especially if they have several of their own template files. When a template file is not found in a custom non-default [[Theme] the [[Theme] will rollback and use the default theme's template file. But for the template files that the custom [[Theme] does use, you will need to manually install the mod on to your custom themes template files if the mod edited the same template file in the default theme. To apply a Mod to any [[Theme] manually use the following steps.
Mods are installed on the default theme's template files. It is hard for a Mod's author as well as a theme creator to make Mods work with other themes especially if they have several of their own template files. When a template file is not found in a custom non-default theme the theme will rollback and use the default theme's template file. But for the template files that the custom theme does use, you will need to manually install the mod on to your custom themes template files if the mod edited the same template file in the default theme. To apply a Mod to any theme manually use the following steps.


1. unzip the Mod package, and look for a file ending with .mod or .xml
# Unzip the Mod package, and look for the file ''[[package-info.xml]]'' and open it with a text editor
# Identify the files with the instructions to do the modifications (for details on package-info.xml structure, please see [http://www.simplemachines.org/community/index.php?topic=299669.0 Package SDK: package-info.xml]
# Search in the extracted package for the .mod or .xml file identified in the previous step and open it with a text editor.
# .mod and .xml files can have different syntax:
#* .mod files:
#** Open the .mod file with any text editor and search for <edit file>...</edit file> , you will find a file name after the tag. What we need here is looking for a template file i.e. index.template.php, BoardIndex.template.php ..etc.
#** If you locate any template after the <edit file> tag, you will find the <search for>...</search for> tag below it. It will contain a block of code that must be located in the specified template.
#** After the <search for> tag, you will find one of these: <add after>...</add after> , which add a block of code after the code found. <add before>...</add before> , which add a block of code before the code found. <replace>...</replace> , which replace a block of code with the code found.
#* .xml file: please see [http://www.simplemachines.org/community/index.php?topic=299670.0 Package SDK: modification.xml] for detailed instructions on how to read and use the instructions of a .xml file


2. open the .mod file with any text editor and search for &lt;edit file&gt;...&lt;/edit file&gt; , you will find a file name after the tag. What we need here is looking for a template file i.e. index.template.php, BoardIndex.template.php ..etc.


3. If you locate any template after the &lt;edit file&gt; tag, you will find the &lt;search for&gt;...&lt;/search for&gt;tag below it. It will contain a block of code that must be located in the specified template.
===Examples===
==== .mod files syntax example====
For example:
{{code|1=<nowiki><edit file>
Themes/default/Display.template.php
</edit file>


4. After the &lt;search for&gt; tag, you will find one of these: &lt;add after&gt;...&lt;/add after&gt; , which add a block of code after the code found. &lt;add before&gt;...&lt;/add before&gt; , which add a block of code before the code found. &lt;replace&gt;...&lt;/replace&gt; , which replace a block of code with the code found.
<search>
// Show the anchor for the top and for the first message. If the first message is new, say so.
</search>


For example:
<replace>
global $bar_exps, $bar_posts;


<div class="codeheader">: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a></div><code>&lt;edit file&gt;
// Show the anchor for the top and for the first message. If the first message is new, say so.
Themes/default/Display.template.php
</replace></nowiki>}}
&lt;/edit file&gt;


&lt;search&gt;
==== .xml files syntax example====
// Show the anchor for the top and for the first message.&nbsp; If the first message is new, say so.
{{code|1=<nowiki> <file name="$themedir/Display.template.php">
&lt;/search&gt;
<operation>
<search position="replace"><![CDATA[// Show the anchor for the top and for the first message. If the first message is new, say so.]]></search>
<add><![CDATA[global $bar_exps, $bar_posts;


&lt;replace&gt;
// Show the anchor for the top and for the first message. If the first message is new, say so.]]></add>
global $bar_exps, $bar_posts;
</operation>
</file></nowiki>
}}


// Show the anchor for the top and for the first message.&nbsp; If the first message is new, say so.
====Example explanation====
&lt;/replace&gt;</code>
In both examples the operations is the same, we need to open Display.template.php and look for:
And that means, we need to open Display.template.php and look for:


<div class="codeheader">: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a></div><code>// Show the anchor for the top and for the first message.&nbsp; If the first message is new, say so.</code>
{{code|1=<nowiki>// Show the anchor for the top and for the first message. If the first message is new, say so.</nowiki>}}
and replace it with:
and replace it with:


<div class="codeheader">: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a></div><code>global $bar_exps, $bar_posts;
{{code|1=<nowiki>global $bar_exps, $bar_posts;
 
// Show the anchor for the top and for the first message. If the first message is new, say so.</nowiki>}}
 


// Show the anchor for the top and for the first message.&nbsp; If the first message is new, say so.</code>
==See Also==
*[[Error in mod installation]]
[[Category:Customizing SMF]]

Latest revision as of 12:11, 23 October 2014

If you are running SMF 2.x, please try using the emulate version function before editing the package.

Mods are installed on the default theme's template files. It is hard for a Mod's author as well as a theme creator to make Mods work with other themes especially if they have several of their own template files. When a template file is not found in a custom non-default theme the theme will rollback and use the default theme's template file. But for the template files that the custom theme does use, you will need to manually install the mod on to your custom themes template files if the mod edited the same template file in the default theme. To apply a Mod to any theme manually use the following steps.

  1. Unzip the Mod package, and look for the file package-info.xml and open it with a text editor
  2. Identify the files with the instructions to do the modifications (for details on package-info.xml structure, please see Package SDK: package-info.xml
  3. Search in the extracted package for the .mod or .xml file identified in the previous step and open it with a text editor.
  4. .mod and .xml files can have different syntax:
    • .mod files:
      • Open the .mod file with any text editor and search for <edit file>...</edit file> , you will find a file name after the tag. What we need here is looking for a template file i.e. index.template.php, BoardIndex.template.php ..etc.
      • If you locate any template after the <edit file> tag, you will find the <search for>...</search for> tag below it. It will contain a block of code that must be located in the specified template.
      • After the <search for> tag, you will find one of these: <add after>...</add after> , which add a block of code after the code found. <add before>...</add before> , which add a block of code before the code found. <replace>...</replace> , which replace a block of code with the code found.
    • .xml file: please see Package SDK: modification.xml for detailed instructions on how to read and use the instructions of a .xml file


Examples

.mod files syntax example

For example:

<edit file>
Themes/default/Display.template.php
</edit file>

<search>
// Show the anchor for the top and for the first message. If the first message is new, say so.
</search>

<replace>
global $bar_exps, $bar_posts;

// Show the anchor for the top and for the first message. If the first message is new, say so.
</replace>

.xml files syntax example

	<file name="$themedir/Display.template.php">
		<operation>
			<search position="replace"><![CDATA[// Show the anchor for the top and for the first message. If the first message is new, say so.]]></search>
			<add><![CDATA[global $bar_exps, $bar_posts;

// Show the anchor for the top and for the first message. If the first message is new, say so.]]></add>
		</operation>
	</file>

Example explanation

In both examples the operations is the same, we need to open Display.template.php and look for:

// Show the anchor for the top and for the first message. If the first message is new, say so.

and replace it with:

global $bar_exps, $bar_posts;

// Show the anchor for the top and for the first message. If the first message is new, say so.


See Also



Advertisement: