• Welcome to Simple Machines Community Forum. Please login or sign up.
October 26, 2021, 03:01:48 PM

News:

Wondering if this will always be free?  See why free is better.


How to make mods work with themes?

Started by A.M.A, April 28, 2005, 07:20:30 PM

Previous topic - Next topic

A.M.A

April 28, 2005, 07:20:30 PM Last Edit: April 29, 2005, 06:53:01 AM by A.M.A
Mods are mostly done to work with the default theme. It is hard for a Mod's author as well as a theme crater to make Mods work with each theme. However you can still apply a Mod to any theme manually using the following steps.

1. unzip the Mod package, and look for a file ending with .mod

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

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

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

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>

And that means, 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.


Notice by: MikeMill
Please note that not all Mods use the .mod file but instead use .xml files.

For the most part they are the same.
Instead of <edit file>...</edit file> it will be <file name="...">
The second difference is that <search for> will be <search position="...">.

Now this is where it can be confusing.  If the position="before" that means what you are searching for will be before what you insert with the <add> block.  If position="after" that means what you are searching for will be after what you insert with the <add> block.  If position="replace" that means you will replace what you searched for with what you <add>.  Finally you may see a position="end".  That means what you <add> should go right before the ?> characters at the end of the file.

Addition:
A german translation of this text is here:
Wie wende ich Mods auf Themen (Skins) an?
Really sorry .. real life is demanding my full attention .. will be back soon hopefully :)

Nitro

where can i find this Mod package? thanks man!
MPF Rocks!!!

dtm.exe

Quote from: mrichard on April 28, 2005, 07:46:55 PM
where can i find this Mod package? thanks man!

That code that A.M.A posted is only to make a mod compatible with an incompatible theme.  To download the actual mods, click on the link below.

http://mods.simplemachines.org/index.php

-Dan The Man

Miraenda

Very helpful A.M.A., thanks for posting this. :)

Thantos

To add:

Not all mods use the .mod file but instead use .xml files.

For the most part they are the same.
Instead of <edit file> _ </edit file> it will be <file name="_">

The second difference is that <search for> will be <search position=" ">.
Now this is where it can be confusing.  If the position="before" that means what you are searching for will be before what you insert with the <add> block.  If position="after" that means what you are searching for will be after what you insert with the <add> block.  If position="replace" that means you will replace what you searched for with what you <add>.  Finally you may see a position="end".  That means what you <add> should go right before the ?> characters at the end of the file.

andrea

Very nice FAQ, just translated it into german language, posted in the german language support forum:
Wie wende ich Mods auf Themen (Skins) an?

Added the link to the german transl. at the bottom of the 1st post.

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



Mystica

April 29, 2005, 03:52:09 AM #6 Last Edit: April 29, 2005, 03:55:44 AM by Mystica
Quote from: A.M.A on April 28, 2005, 07:20:30 PM
Please note that not all Mods alter templates files only, some may require adding new template(s) to the theme for them to work.

doesn't the forum use the default theme's template files for the files that are not included in an additional theme? therefor after installing a mod it should only be necessary to modify the files that are already in the other themes. or am i missing something?
~ there's nothing wrong with me, this is how I'm supposed to be ~

A.M.A

Thnaks OIDanTheManIO for explaining.

Glad you find it of use Miraenda.

Thanks MikeMil for the addition.

Thanks andrea for translating it.

Yes Mystica it sounded confusing so I deleted it. I was refereeing to what to do in case of manual installation of the Mod, not applying it to the default theme then changing other themes.
Really sorry .. real life is demanding my full attention .. will be back soon hopefully :)

Mystica

~ there's nothing wrong with me, this is how I'm supposed to be ~

IamV

Thanks for posting this.  I just followed it step by step with the gmail mod & found it really simple and easy to do.  :D

vdubbia

Okay... can you tell me what I'm supposed to add out of the following two instructions... I'm getting confused with all of the brackets tacked onto the beginnings and ends of the code and the 'CDATA' syntax...

Quote<add><![CDATA[ (empty($context['spiders']) ? '' : $context['num_spiders'] . ' ' . ($context['num_spiders'] == 1 ? $txt['ob_googlebot_spider'] : $txt['ob_googlebot_spiders']) . ', '), ]  ]></add>


Quote<add><![CDATA[

   if (!empty($context['spiders']))
   {
      if ($modSettings['ob_googlebot_display_own_list'])
         echo '
            <br />
            ', $txt['ob_googlebot_spiders_last_active'], ':<br />';
      else
      {
         if (empty($context['users_online']))
            echo '
            ', $txt[140], ':<br />';
         else
            echo ', ';
      }
      
      echo implode(', ', $context['spiders']);
   }]]></add>



Thanks

forsakenlad

You should ignore the "![CDATA[" and the "]]>" tags ;)
Eren "forsakenlad" Yaşarkurt
SMF Friend & Former Team Member

crev

im trying to install smf shop mod on another theme - 'igoh' and after being sat here for over 2 hours ive still not got anywhere. im no good the codes and this is really confusing me. could some one pls help me. i dont know where to start or finsih.

help appreciated.
Thank alot, Crev
hxxp:www.zillionhosting.co.nr [nonactive]

<a href="hxxp:www.resellerspanel.com/?a=username [nonactive]"><img src="hxxp:www.resellerspanel.com/banners/468x60_03.gif [nonactive]" width="468" height="60" border="0"></a>

crev

dont matter finally done it after hours of learning lol
  :D
crev
hxxp:www.zillionhosting.co.nr [nonactive]

<a href="hxxp:www.resellerspanel.com/?a=username [nonactive]"><img src="hxxp:www.resellerspanel.com/banners/468x60_03.gif [nonactive]" width="468" height="60" border="0"></a>

chaking

So if you have an xml file (or .mod I suppose), couldn't you just extract that, change the $themedir to something that actually refers to the theme you want it installed on, compress it and use the package manager? The problem is I don't know what to change $themedir to... any suggestions?

forsakenlad

You can but all the themes don't have the same layout so it might and with themes that change the layout much it would not work ;)
Eren "forsakenlad" Yaşarkurt
SMF Friend & Former Team Member

plezops

AHHH, im trying to install the XFire mod (.xml) file and after about 2 hours of work, it still doesnt work. If anyone could be of assistance on how to make it work with the Helios theme that would be great!

Thanks

Prasad007

this was most certainly very helpful! Thank you! :)

NiCr0

Ok i'm having some complications here. I'm decent at coding mostly in HTML with minor minor php exp. so from reading this topic and all posts, i'm still a bit confused.

I'm trying to install the XFire and Teamspeak packages/mods for my site forums. www.HeadlessHorsemen.org or www.HeadlessHorsemen.org/forums for direct forum link.

In the Teamspeak (most important at this time for me) its using the .xml file. I have on Lines 23-25 (using Dreamweaver 8 Pro) <!-- Edit a specific file.. -->
<file name="$themedir/Profile.template.php">
<!-- A seach operation, with search rules and code to modify the file with. -->


Then again on lines 44-45 i have.
<file name="$themedir/Display.template.php">
<!-- A seach operation, with search rules and code to modify the file with. -->


in my display.template.php file i have Lines 1-9 displaying this
<?php
// Version: 1.0; Display

function template_main()
{
global $context$settings$options$txt$scripturl$modSettings;

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


I'm totaly confused on what to add or change. perhaps im just not comprehending the way i change/edit this? i do apologize if this has been answerd which obviously it has im sure. the Teamspeak thread (located: Here didnt really help much either).

The skin that i'm using is:
Daze Skin by Diplomat | Unofficial Grey Version modified by maCe
version: SMF 1.1 RC2

Thanks in advance for any advice, solutions, help, suggestions or anything else.

NiCr0

Ok I do appologize for the spam, after i took the time to "think" and re read and study the way the code worked for this,

the code i needed to find was
<file name="$themedir/Display.template.php">
<!-- A seach operation, with search rules and code to modify the file with. -->
<operation>
<!-- Search for this text before the code we add.  You can also search for after, and the end of the file. -->
<search position="before"><![CDATA[ // Show their personal text?
if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')
echo '
', $message['member']['blurb'], '<br />
<br />';]]></search>


What confused me, the position="before" and the <![CDATA[ tag's. Once i looked it over for a few moments, i realized what the orginal post said.

if the statement says,
postition="before" then, what ever it is searching for, the <add></add> will be placed before the text shown.  the texted that im looking for isn't starting with <![CDATA[ it starts after that second [ and ends after the ;


Advertisement: