News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

How to make mods work with themes?

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

Previous topic - Next topic

ShopHRM

I have a question, i pretty much have this all figured out except for one thing. When looking for the file in the theme that you were told to go to when searching the mod "modification" file. If the mod.xml or .mod file lists a file that is not in my theme what do i do there? do i just leave it alone? Also if I need to find a code in the theme file i was directed to and the code is not there does that mean i dont have to replace it?

fwitt

if the file is not in your theme then the theme uses the one from the default theme which should be automatically updated when you install the theme.

if the replace code doesnt exist in your theme this means that your theme does it differently to the default, this is the reason why the package manager doesnt install onto non default themes, what you need to do is find the code that does the same job in the theme you are using, and replace it with code that does the same job as the code the default code get replaced with.

the simplist example of this is adding links to mods in the menu in custom themes.
ie "FORUM HELP SEARCH PROFILE..."
to "FORUM MODLINK HELP SEARCH PROFILE..."

in some themes these will be images so you will need to make a image for the mod link and make sure it appears in the right place with the correct borders/spacing between links etc. to match the rest of the buttons from that theme. but in themes where the links are text you may only have to add a simple text link into the code for that mod.

If the code does not appear in your custom theme but the file it should be in does I would first look for similar code, (in the case of the menu i would search for the calender button and copy the code for that changing calender to the name of your mod every time it appears), and then if you cant work out where it goes first ask the mod author then the mods author, the themes author should be able to tell you where the code that does the same job as that in the default is and the mods author should be able to tell you what the changes to the code do.

Phoenix Omega

Is there perhaps a way to create a mod that will do all the steps necessary to make another mod compatible with another theme?

fwitt

there is a way and its not that hard to do one that installs a particular version of a mod on a particular version of smf with this particular list of other mods installed into a particular theme.

but the reason that they dont generally get made is that there are so many combinations that it very quickly becomes impractical to do it for all cases.


jeamen

hi
how to search for codes in theme settings
examle...I can't install smf shop...
I can't find some code

tallpaul

i'm lost too, i've been changing bits to get this to work on my theme but no luck, it works on the standard default theme but not the board's default which is set to helios multi, which bits do i change???

<!-- Edit a specific file.. -->
   <file name="$boarddir/index.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="after"><![CDATA['activate' => array('Register.php', 'Activate'),]]></search>
         <!-- Add this text when we find it.  Note that it's on it's own line on purpose, and the CDATA keeps things clean. -->
         <add><![CDATA['usercp' => array('usercp.php', 'usercp'),]]></add>
      </operation>

   </file>

<file name="$themedir/index.template.php">
   <operation>
      <search position="after"><![CDATA[if ($context['current_action'] == 'search2')]]></search>
           <add><![CDATA[if ($context['current_action'] == 'usercp')
      $current_action = 'usercp';
      ]]></add>
   </operation>
      <operation>
      <search position="replace"><![CDATA[if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm')))]]></search>
           <add><![CDATA[if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'usercp', 'mlist', 'register', 'login', 'help', 'pm')))
      ]]></add>
   </operation>
   <operation>
      <search position="replace"><![CDATA[<a href="', $scripturl, '?action=profile">' , $txt[79] , '</a>]]></search>
           <add><![CDATA[<a href="', $scripturl, '?action=usercp">' , $txt['usercp'] , '</a>
      ]]></add>
   </operation>
</file>

<file name="$themedir/languages/Modifications.english.php">
   <operation>
      <search position="after"><![CDATA[?>]]></search>
           <add><![CDATA[

MeRcChRiS

#46
We should make something that will do this for us, instead of having to open to tons of files and search for a line replace, save, look for another file, search etc...

kamili34

For beginner is realy strange and confuse.

dailytalk

I already work with the procedure described above but unfortunately sometimes the default index.template.php and the index.template.php from the new theme are so different that I just cant find the codes before them or after them I should place something. Actually I have problems with the orange-lt theme and the add mod.

I only was able to add the codes for the header. For the skysrapers left and right and for the footer I couldn't add the add mod codes because couldn't find the codes "before" or "after" them I had to put the add codes.

Northerner

i have problems with the sig option mod
i can leave the box unchecked and
after i post, my sig will still show up. i am using Aa_New_Damage_111 theme.

here is the code if anyone can help please?

this code is from sig.xml

<?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>vbgamer45:SigPost/id>
<version>1.0</version>
<file name="$languagedir/Modifications.english.php">
<operation>
<search position="after"><![CDATA[
?>]]></search>
<add><![CDATA[
//Begin Sig Post Strings
$txt['show_sig'] = 'Show Signature';
$txt['sig_topic'] = 'Show Signature Checked?';
//END Sig Post Strings
]]></add>
</operation>
</file>

<file name="$themedir/Post.template.php">
<operation>
<search position="before"><![CDATA[<tr>
<td class="smalltext"><label for="check_back"><input type="checkbox" name="goback" id="check_back"' . ($context['back_to_topic'] || !empty($options['return_to_post']) ? ' checked="checked"' : '') . ' value="1" class="check" /> ' . $txt['back_to_topic'] . '</label></td>
<td class="smalltext">', $context['can_sticky'] ? '<input type="hidden" name="sticky" value="0" /><label for="check_sticky"><input type="checkbox" name="sticky" id="check_sticky"' . ($context['sticky'] ? ' checked="checked"' : '') . ' value="1" class="check" /> ' . $txt['sticky_after2'] . '</label>' : '', '</td>
</tr>]]></search>
<add><![CDATA[
<tr>
<td class="smalltext" colspan="2"><label for="check_sig"><input type="checkbox" name="showsig" id="check_sig"' . (!empty($modSettings['sig_topic']) ? ' checked="checked"' : '') . ' value="1" class="check" /> ' . $txt['show_sig'] . '</label></td>
</tr>
]]></add>
</operation>

</file>
<file name="$themedir/Display.template.php">
<operation>
<search position="replace"><![CDATA[// Show the member's signature?
if (!empty($message['member']['signature']) && empty($options['show_no_signatures']))]]></search>
<add><![CDATA[
// Show the member's signature?
if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $message['showSIG'] == 1)
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[<textarea cols="75" rows="7" style="width: 95%; height: 100px;" name="message" tabindex="1"></textarea><br />]]></search>
<add><![CDATA[
<label for="check_sig"><input type="checkbox" name="showsig" id="check_sig"' . (!empty($modSettings['sig_topic']) ? ' checked="checked"' : '') . ' value="1" class="check" /> ' . $txt['show_sig'] . '</label><br />
]]></add>
</operation>


</file>
<file name="$sourcedir/Post.php">
<operation>
<search position="before"><![CDATA['smileys_enabled' => !isset($_POST['ns']),]]></search>
<add><![CDATA[
'sig_enabled' => @$_POST['showsig'],
]]></add>
</operation>

</file>
<file name="$sourcedir/Subs-Post.php">
<operation>
<search position="before"><![CDATA[$msgOptions['smileys_enabled'] = !empty($msgOptions['smileys_enabled']);]]></search>
<add><![CDATA[
$msgOptions['sig_enabled'] = empty($msgOptions['sig_enabled']) ? 0 : (int) $msgOptions['sig_enabled'];
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[// Insert the post.
db_query("
INSERT INTO {$db_prefix}messages
(ID_BOARD, ID_TOPIC, ID_MEMBER, subject, body, posterName, posterEmail, posterTime,
posterIP, smileysEnabled, modifiedName, icon)
VALUES ($topicOptions[board], $topicOptions[id], $posterOptions[id], SUBSTRING('$msgOptions[subject]', 1, 255), SUBSTRING('$msgOptions[body]', 1, 65534), SUBSTRING('$posterOptions[name]', 1, 255), SUBSTRING('$posterOptions[email]', 1, 255), " . time() . ",
SUBSTRING('$posterOptions[ip]', 1, 255), " . ($msgOptions['smileys_enabled'] ? '1' : '0') . ", '', SUBSTRING('$msgOptions[icon]', 1, 16))", __FILE__, __LINE__);]]></search>
<add><![CDATA[
// Insert the post.
db_query("
INSERT INTO {$db_prefix}messages
(ID_BOARD, ID_TOPIC, ID_MEMBER, showSIG, subject, body, posterName, posterEmail, posterTime,
posterIP, smileysEnabled, modifiedName, icon)
VALUES ($topicOptions[board], $topicOptions[id], $posterOptions[id], $msgOptions[sig_enabled], SUBSTRING('$msgOptions[subject]', 1, 255), SUBSTRING('$msgOptions[body]', 1, 65534), SUBSTRING('$posterOptions[name]', 1, 255), SUBSTRING('$posterOptions[email]', 1, 255), " . time() . ",
SUBSTRING('$posterOptions[ip]', 1, 255), " . ($msgOptions['smileys_enabled'] ? '1' : '0') . ", '', SUBSTRING('$msgOptions[icon]', 1, 16))", __FILE__, __LINE__);
]]></add>
</operation>

</file>
<file name="$sourcedir/Display.php">
<operation>
<search position="before"><![CDATA[$messages_request = db_query("
SELECT
ID_MSG, icon, subject,]]></search>
<add><![CDATA[ showSIG,]]></add>
</operation>
<operation>
<search position="before"><![CDATA['counter' => $counter,]]></search>
<add><![CDATA[
'showSIG' => $message['showSIG'],
]]></add>
</operation>

</file>
<file name="$sourcedir/ModSettings.php">
<operation>
<search position="before"><![CDATA[array('check', 'who_enabled'),]]></search>
<add><![CDATA[
//Sig Option mod
array('check', 'sig_topic'),]]></add>
</operation>
</file>
</modification>

Northerner

can anyone please help me with the above problem??

Baracus

ok i've uploaded and installed "users online today mod" & "googlebot" and i can't get either working in the theme my site uses but they work fine in the default theme

I have got no idea how to do all this your all talking about, it's confusing the hell out of me now and driving me nuts

can someone please help me sort this out??  much appreciated :)

Baracus

anyone ?? please?

I really like this mod but really need it working in helios multi but i have no idea at all

SMSU

Daniel15 has a "Package Parser" here: http://dev.dansoftaustralia.net/projects/modparser/ [nofollow] which would tell you exactly what you needed to do to modify your custom theme to incorporate the Mod.

I used it a few times and it was good.

JiGs013



nice hmmm... after i download it that package parser .. do i need to install it on my SMF  Package Manager?

EJR

I finally found this MOD (thanks for the replies...)  I am using SMF 1.1.5 and appropriate MOD package 1.4.0 and I get this at the bottom of my forum (uses Babylon theme).  The bold text is where I am sure something is missing.  As well as there is nothing in the title bar:

QuoteUsers Online
  2 Guests, 1 User (0 Buddies)
Users active in past 60 minutes:
EJR

Most Online Today: 22. Most Online Ever: 70 ( June 21, 2008, 13:39:12) 

  : 3 (: 3, : 0)EJR, Smoke50, Kerry Asst.40 

I am also getting these recurring errors:

Quote8: Undefined index: uot_hidden (OR uot_visible..  total... etc..
File: /home/ejr19550/public_html/smf/Themes/babylon/BoardIndex.template.php (eval?)
Line: 442

I tried to follow everything I could find on this forum.   I am just not good at coding PHP.  Any help would be appreciated...

IchBin™

EJR, this topic is for teaching people how to manually add a mod to custom themes. It is not for the users online today mod. I would suggest you post your question in the topic for that mod, or on the authors site.
IchBin™        TinyPortal

swan

ok i am a bit lost (not hard)

I have done the search thing

and this is what i got

- <file name="$sourcedir/BoardIndex.php" error="fatal">
- <operation error="fatal">
- <search position="before" regexp="false" whitespace="exact">
- <![CDATA[ $context['num_users_online'] = count($context['users_online']) + $context['num_users_hidden'];

  ]]>
  </search>


- <add>
- <![CDATA[ // Load the users online today.
$date = @getdate(forum_time(false));
$midnight = mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']) - ($modSettings['time_offset'] * 3600);

$s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
$time_fmt = '%I:%M' . $s . ' %p';
else
$time_fmt = '%H:%M' . $s;

$result = db_query("
SELECT
mem.ID_MEMBER, mem.lastLogin, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP)) WHERE mem.lastLogin >= $midnight", __FILE__, __LINE__);

$context['num_hidden_users_online_today'] = 0;
$context['users_online_today'] = array();
$context['list_users_online_today'] = array();

while ($row = mysql_fetch_assoc($result))
{
if (empty($row['showOnline']))
{
$context['num_hidden_users_online_today'] = $context['num_hidden_users_online_today'] + 1;
if (!$user_info['is_admin']) continue;
}

$userday = strftime('%d', forum_time(true));
$loginday = strftime('%d', forum_time(true, $row['lastLogin']));
$yesterday = $userday == $loginday ? '' : $txt['uot_yesterday'];

$lastLogin = $yesterday . strftime($time_fmt, forum_time(true, $row['lastLogin']));
$title = ' title="' . $lastLogin . '"';

// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . ' style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . '>' . $row['realName'] . '</a>';

$is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']);
if ($is_buddy)
{
$link = '<b>' . $link . '</b>';
}

$context['users_online_today'][$row['lastLogin'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'is_buddy' => $is_buddy,
'hidden' => empty($row['showOnline']),
);

$context['list_users_online_today'][$row['lastLogin'] . $row['memberName']] = empty($row['showOnline']) ? '<i>' . $link . '</i>' : $link;
}
mysql_free_result($result);

krsort($context['users_online_today']);
krsort($context['list_users_online_today']);

$context['num_users_online_today'] = count($context['users_online_today']);
if (!$user_info['is_admin'])
{
$context['num_users_online_today'] = $context['num_users_online_today'] + $context['num_hidden_users_online_today'];
}
  ]]>
  </add>



BUT where do i put that code?

committed2u

i have a simpler way.
instead of jumping into the code manually, just edit the files in the mod zipped package (installer).

this is how i did it (my smf is v1.1.6):
my environment: smf v1.1.6 with Highway Theme installed.
mod to install: thank-o-matic.

the steps:
1. extract all file in the thank-o-matic zip file to a directory. name it the same like the file name, "thank-o-matic"
2. open package-info.xml. it has all the installation files info.
3. now, let's do this first: take a look at your theme directory structure (mine is Highway theme), mine looks like this: "forumbinaraga.com/Themes/Highway"
4. using your favorite program, replace all "$themedir" with "Themes/Highway" at the package-info.xml
5. also, still using your favorite program, search the whole thank-o-matic directory for files contain "$themedir" and change them all to "Themes/Highway"
6. zip the the whole directory back into hxxp:thank-o-matic.zip [nonactive].
7. install it using the package manager (using upload)
8. test it. it will spit some errors; something like this:
---24.     Execute Modification     ./Themes/HighWay/Admin.template.php     File not found  <---
---25.    Execute Modification    ./Themes/HighWay/Display.template.php    Test successful
---26.    Execute Modification    ./Themes/HighWay/ManageBoards.template.php    File not found  <---
---27.    Execute Modification    ./Themes/HighWay/Profile.template.php    File not found  <---
9. see, that's because those 3 files are not in the HighWay directory but instead in the default theme dir. so simply re-edit your files and change everything that has those three strings from "./Themes/HighWay" back to "$themedir".
10. repack the zip file and upload to server using package manager
11. retry to install. if all the test results are "successful" then you are ready to go.
12. don't forget to test it.
you can see the actual result at my site hxxp:www.forumbinaraga.com [nonactive].

ps:
important: don't forget to backup everything before you do any changes on production server. but, well... to be really really honest; i didn't do backup :P.
i haven't test this method with other mods yet. but i believe the principle is about the same.

fwitt

this method will only work for themes that are similar in code to the default theme.

I do personally work in a similar way though because it leaves a trail of exactly what i changed and makes it a lot easier to uninstall.

Advertisement: