Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: John Slater on June 05, 2005, 01:27:51 PM

Title: Mod Help
Post by: John Slater on June 05, 2005, 01:27:51 PM
Hi i posted this a few minutes ago but in the wrong place, hopefully someone will delete the old one.

__________________________________________
ok here is the code i wrote using the template SMF has. I want to add some code to a file and as far as i know it should work, but it doesnt so something is wrong. I have uploaded it via the package manager and the file says fail when i try to install it. Please inform.

Its only a test mod but when i have it working i want to develop it more.

The code is below.

<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This is an example modification file for SMF packages.

ATTENTION: If you are trying to install this manually, you should try
the package manager.  If it will not work for you, please take a look
at the following for information on this format:
http://mods.simplemachines.org/docs/manual-install.php

================================================================================

Modification files can be used to modify files so that they do what
your package needs them to do to work properly.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<!-- This information needs to be the same as that in the package-info.xml. -->
<id>username:thesimpsonsjohn</id>
<version>1.1</version>

<!-- Edit a specific file.. -->
<file name="$themedir/Profile.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[
$context['member']['website']['url'], '" /></td>
]]></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[
</tr><tr>
<td><b>Real name: </b></td>
<td><input type="text" name="default_options[profile_real_name]" size="50" value="', @$context['member']['options']['profile_real_name'], '" /></td>
]]></add>
</operation>


</file>
</modification>


This is only step one, step two was deleted until i get step one working.

Hope you great guys can help.
Title: Re: Mod Help
Post by: rudoka on June 05, 2005, 11:16:26 PM

<search position="before"><![CDATA[
<td><input type="text" name="websiteUrl" size="50" value="', $context['member']['website']['url'], '" /></td>
]]></search>


This works for me.
Though it just changes the Profile.template.php. In the forum the real name is still not visible. If that is what you wanted.

Rudolf
Title: Re: Mod Help
Post by: [Unknown] on June 06, 2005, 04:17:07 AM
This:

<![CDATA[
$context['member']['website']['url'], '" /></td>


Means:

"\n\$context['member']['website']['url'], '\" /></td>"

What you want is:

<![CDATA[$context['member']['website']['url'], '" /></td>

Without the \n in the front.

-[Unknown]
Title: Re: Mod Help
Post by: John Slater on June 06, 2005, 05:02:31 AM
sorry to be a pain, not quite sure what you mean. :-( that code you posted is on my mod as far as i can see, what am i doing wrong? and where?

sorry :-)
Title: Re: Mod Help
Post by: rudoka on June 06, 2005, 10:32:04 AM
It means that or you use what I said or you put what [Unknown] said.

Something like this:

<search position="before"><![CDATA[$context['member']['website']['url'], '" /></td>]]>
</search>


Mine works because I practically search for the whole line. Having the line break caracter both at the beginning and the end.
The CDATA must be exactly as in the file, spaces, tabs, line break and other white space characters included. Yours is not.  ;)
Thanks [Unknown] for pointing that \n out. I had no idea why it wouldn't work.

Rudolf
Title: Re: Mod Help
Post by: John Slater on June 06, 2005, 11:15:26 AM
ok i will try it now. :-) thanks.
Title: Re: Mod Help
Post by: John Slater on June 06, 2005, 11:53:18 AM
Ok, using the SDK thing, how do i make the script add code before (the line above) a certain point?
Title: Re: Mod Help
Post by: rudoka on June 06, 2005, 02:10:18 PM

<search position="after"><![CDATA[
<td><input type="text" name="websiteUrl" size="50" value="', $context['member']['website']['url'], '" /></td>
]]></search>
<add><![CDATA[
<tr>
<td><b>Real name: </b></td>
<td><input type="text" name="default_options[profile_real_name]" size="50" value="', @$context['member']['options']['profile_real_name'], '" /></td></tr>
]]></add>



You will need to include the whole line if you want to insert it before. If you use only $context['member']['website']['url'], '" /></td> it will insert before that code, meaning in themiddle of the line there. Which is not good, right?  ;)

OR you can do:

<search position="replace"><![CDATA[
<td><input type="text" name="websiteUrl" size="50" value="', $context['member']['website']['url'], '" /></td>
]]></search>

<add><![CDATA[
<tr>
<td><b>Real name: </b></td>
<td><input type="text" name="default_options[profile_real_name]" size="50" value="', @$context['member']['options']['profile_real_name'], '" /></td></tr>
<td><input type="text" name="websiteUrl" size="50" value="', $context['member']['website']['url'], '" /></td>
]]></add>


But I'm just guessing here, since I don't know what you really want to do.

Rudolf
Title: Re: Mod Help
Post by: John Slater on June 06, 2005, 03:15:02 PM
Thanks mate, i thought of putting after but didnt know whether it would work. But i got the mod to work, i have submitted it.
Title: Re: Mod Help
Post by: rudoka on June 06, 2005, 03:54:13 PM
Submitted where?  ???
Title: Re: Mod Help
Post by: Gary on June 06, 2005, 03:56:14 PM
The Mod site. My guess is that its waiting to be approved.
Title: Re: Mod Help
Post by: rudoka on June 06, 2005, 04:04:57 PM
AHA!  :o
Well, I just finished my mod too. Two days ago.
   I was wondering how could I have it listed somewhere else then my own package server.
   But then I didn't saw much interest from people here, so I just dumped the idea. There is a mod already for what I wrote, and I don't care much anymore to have mine listed, anyway.

Hm, should I submit or should I go?  :-\
Rudolf
Title: Re: Mod Help
Post by: Gary on June 07, 2005, 02:33:08 AM
You can submit your mod here (http://mods.simplemachines.org/index.php?a=submit) it'd be great if you could share your mod with the community, I feel.
Title: Re: Mod Help
Post by: John Slater on June 07, 2005, 04:52:27 AM
my mod is submitted. When its approved i will make my Skype! mod.
Title: Re: Mod Help
Post by: John Slater on June 07, 2005, 11:42:30 AM
How long until my mod is accepted?  :)
Title: Re: Mod Help
Post by: dtm.exe on June 07, 2005, 11:48:58 AM
Quote from: John Slater on June 07, 2005, 11:42:30 AM
How long until my mod is accepted?  :)

When a Mod Developer dubs it safe for SMF, then it will be released.

-Dan The Man
Title: Re: Mod Help
Post by: rudoka on June 07, 2005, 12:02:18 PM
Quote from: OIDanTheManIO on June 07, 2005, 11:48:58 AM
Quote from: John Slater on June 07, 2005, 11:42:30 AM
How long until my mod is accepted?  :)

When a Mod Developer dubs it safe for SMF, then it will be released.

-Dan The Man

Maybe that's why my instinct says to don't bother submitting mine. lol
Title: Re: Mod Help
Post by: Gary on June 07, 2005, 12:03:09 PM
It varies, mine took a couple of days.
Title: Re: Mod Help
Post by: dtm.exe on June 07, 2005, 12:26:12 PM
Quote from: Solid Snake on June 07, 2005, 12:03:09 PM
It varies, mine took a couple of days.

As did my mod.

-Dan The Man
Title: Re: Mod Help
Post by: John Slater on June 08, 2005, 08:33:37 AM
My first mod took 1 day, my last 2 havent been varified yet.