News:

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

Main Menu

Smf user Menu Beta Mod

Started by Faevilangel, August 11, 2009, 07:02:08 AM

Previous topic - Next topic

Faevilangel

hmmm that needs some thought then

i have made my modification.xml and just wondering have i done it right, (used a basic one i found and modified it)
<?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://www.simplemachines.org/redirect/manual_mod_install

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

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:faevilangel</id>
<version>1.0</version>

<!-- Edit a specific file.. -->
<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[
"block" : "none";
}
}
]]></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[
function profile_menu() {
  var d = document.getElementById('',$message['id'],'');
  if(d.style.display == 'none') {
    d.style.display = 'block';
  } else {
    d.style.display = 'none';
  }
}
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[
<b>', $message['member']['link'], '</b>
]]></search>
<add><![CDATA[
<a href="#" onclick="profile_menu(); return false;">',$message['member']['name'],'</a>
<br />
<div class="menu" id="',$message['id'],'">
<ul id="menu2">
<li><a href="', $scripturl, '?action=profile;u=',$context['member']['id'],'">View Profile</a></li>
<li><a href="', $scripturl, '?action=pm;sa=send;u=', $context['member']['id'], '">Send Mesage</a></li>
<li><a href="', $scripturl, '?action=buddy;u=', $context['member']['id'], ';sesc=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a> </li>
</ul>
</div>

]]></add>
</operation>
</file>
</modification>


i thought doing the packaging would be daunting but seems to be prety simple (i know a little xml)
I am available for theme work, pm me for info

Arantor

First up, the id should be <id>faevilangel:name_of_mod</id>

That looks fine for modification.xml. Don't forget you also need to make package-info.xml.

Faevilangel

Quote from: Arantor on August 11, 2009, 06:30:14 PM
First up, the id should be <id>faevilangel:name_of_mod</id>

That looks fine for modification.xml. Don't forget you also need to make package-info.xml.

oops ... will add that, and yes im doing that one now

I am available for theme work, pm me for info

Faevilangel

ok done the package-info.xml so do i just zip it up ? no other files i need ?
I am available for theme work, pm me for info

Arantor

If the package-info.xml is complete, you just zip it up, then go to the Mod Site, and Submit New Mod :)

Faevilangel

Quote from: Arantor on August 11, 2009, 06:55:06 PM
If the package-info.xml is complete, you just zip it up, then go to the Mod Site, and Submit New Mod :)
im gonna test it on my forum first
I am available for theme work, pm me for info


Faevilangel

Quote from: Antechinus on August 11, 2009, 07:06:55 PM
Mind if I take a look?

getting errors  :(

Quote
1. Execute Modification     ./themedir/default/script.js     File not found
2. Execute Modification    ./themedir/default/display.template.php File Not Found

modification.xml file

<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>faevilangel:user_drop_menu</id>
<version>1.0</version>

<!-- Edit a specific file.. -->
<file name="themedir/default/script.js">
<!-- 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[
"block" : "none";
}
}
]]></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[
function profile_menu() {
  var d = document.getElementById('',$message['id'],'');
  if(d.style.display == 'none') {
    d.style.display = 'block';
  } else {
    d.style.display = 'none';
  }
}
]]></add>
</operation>
</file>
<file name="themedir/default/display.template.php">

<operation>
<search position="replace"><![CDATA[
<b>', $message['member']['link'], '</b>
]]></search>
<add><![CDATA[
<a href="#" onclick="profile_menu(); return false;">',$message['member']['name'],'</a>
<br />
<div class="menu" id="',$message['id'],'">
<ul id="menu2">
<li><a href="', $scripturl, '?action=profile;u=',$context['member']['id'],'">View Profile</a></li>
<li><a href="', $scripturl, '?action=pm;sa=send;u=', $context['member']['id'], '">Send Mesage</a></li>
<li><a href="', $scripturl, '?action=buddy;u=', $context['member']['id'], ';sesc=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a> </li>
</ul>
</div>

]]></add>
</operation>
</file>
</modification>

I am available for theme work, pm me for info

Arantor

When you specify the theme dir, you do it with:
<file name="$themedir/script.js">

Sorry was looking more at everything else not the file names.


Antechinus

What Arantor said. Example from a mod:

<file name="$sourcedir/Memberlist.php">
<operation>
<search position="replace"><![CDATA[ $context['num_members'] = $modSettings['totalMembers'];


ETA: That's for a Sources file, obviously.

Faevilangel

ok a different error  :(

Quote
1.     Execute Modification     ./Themes/default/script.js     Test failed

i guess its where i have did the add to end js part
I am available for theme work, pm me for info

Arantor


Faevilangel

it worked weee

now error on the other one though  >:(

Quote2.     Execute Modification     ./Themes/default/Display.template.php     Test failed
I am available for theme work, pm me for info

Arantor

Is there an end of line before the <b> in the replace? It counts whitespace exactly, and you don't have to have a blank line there unless the original file does.

Faevilangel

Quote from: Arantor on August 11, 2009, 07:28:23 PM
Is there an end of line before the <b> in the replace? It counts whitespace exactly, and you don't have to have a blank line there unless the original file does.

removed the <br /> and still fails

code i added is

<a href="#" onclick="profile_menu(); return false;">',$message['member']['name'],'</a>
<div class="menu" id="',$message['id'],'">
<ul id="menu2">
<li><a href="', $scripturl, '?action=profile;u=',$context['member']['id'],'">View Profile</a></li>
<li><a href="', $scripturl, '?action=pm;sa=send;u=', $context['member']['id'], '">Send Mesage</a></li>
<li><a href="', $scripturl, '?action=buddy;u=', $context['member']['id'], ';sesc=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a> </li>
</ul>
</div>
I am available for theme work, pm me for info

Arantor

So what's the current code looking like in the modification.xml?

Faevilangel

Quote from: Arantor on August 11, 2009, 07:34:50 PM
So what's the current code looking like in the modification.xml?


<?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://www.simplemachines.org/redirect/manual_mod_install

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

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>faevilangel:user_drop_menu</id>
<version>1.0</version>

<!-- Edit a specific file.. -->
<file name="$themedir/script.js">
<!-- 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="end"><![CDATA[
"block" : "none";
}
}
]]></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[
function profile_menu() {
  var d = document.getElementById('',$message['id'],'');
  if(d.style.display == 'none') {
    d.style.display = 'block';
  } else {
    d.style.display = 'none';
  }
}
]]></add>
</operation>
</file>
<file name="$themedir/Display.template.php">

<operation>
<search position="replace"><![CDATA[
<b>', $message['member']['link'], '</b>
]]></search>
<add><![CDATA[
<a href="#" onclick="profile_menu(); return false;">',$message['member']['name'],'</a>
<div class="menu" id="',$message['id'],'">
<ul id="menu2">
<li><a href="', $scripturl, '?action=profile;u=',$context['member']['id'],'">View Profile</a></li>
<li><a href="', $scripturl, '?action=pm;sa=send;u=', $context['member']['id'], '">Send Mesage</a></li>
<li><a href="', $scripturl, '?action=buddy;u=', $context['member']['id'], ';sesc=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a> </li>
</ul>
</div>

]]></add>
</operation>
</file>
</modification>



it would have been easier to let you have made the mod haha
I am available for theme work, pm me for info

Antechinus

Is using <div class="menu" id="',$message['id'],'"> a good idea? Wont that generate duplicate ID validation errors?

Arantor

First mod:


<search position="end"><![CDATA[
"block" : "none";
}
}
]]></search>


Replace with:
<search position="end" />


<operation>
<search position="replace"><![CDATA[
<b>', $message['member']['link'], '</b>
]]></search>
<add><![CDATA[
<a href="#" onclick="profile_menu(); return false;">',$message['member']['name'],'</a>
<div class="menu" id="',$message['id'],'">
<ul id="menu2">
<li><a href="', $scripturl, '?action=profile;u=',$context['member']['id'],'">View Profile</a></li>
<li><a href="', $scripturl, '?action=pm;sa=send;u=', $context['member']['id'], '">Send Mesage</a></li>
<li><a href="', $scripturl, '?action=buddy;u=', $context['member']['id'], ';sesc=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a> </li>
</ul>
</div>

]]></add>
</operation>


Should likely be replaced with:

<operation>
<search position="replace"><![CDATA[<b>', $message['member']['link'], '</b>
]]></search>
<add><![CDATA[<a href="#" onclick="profile_menu(); return false;">',$message['member']['name'],'</a>
<div class="menu" id="profile',$message['id'],'">
<ul id="menu2">
<li><a href="', $scripturl, '?action=profile;u=',$context['member']['id'],'">View Profile</a></li>
<li><a href="', $scripturl, '?action=pm;sa=send;u=', $context['member']['id'], '">Send Mesage</a></li>
<li><a href="', $scripturl, '?action=buddy;u=', $context['member']['id'], ';sesc=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a> </li>
</ul>
</div>]]></add>
</operation>



If I'd have done it, I would have done it fairly differently, I think, but it's still a good learning process. Your next one will not be so tricky, I can guarantee you that.

@Antechinus: It shouldn't do unless there are DOM ids with that value. I did suggest earlier using profile as a prefix - I've added that to the above.

Faevilangel

thanks arantor, that worked, i added the styling to the style.css but it just shows the menu, clicking the link doesn't hide it (its supposed to be hidden from the start)

see http://garethgillman.co.uk/forum/index.php/topic,1.0.html#
I am available for theme work, pm me for info

Advertisement: