Advertisement:

Author Topic: Smf user Menu Beta Mod  (Read 20964 times)

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #40 on: August 11, 2009, 06:23:22 PM »
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)
Code: [Select]
<?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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,372
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #41 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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #42 on: August 11, 2009, 06:36:03 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

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #43 on: August 11, 2009, 06:53:10 PM »
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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,372
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #44 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 :)
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #45 on: August 11, 2009, 06:59:32 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

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,432
  • Master of BBC Abuse
Re: adding menu to the display.template / display.php
« Reply #46 on: August 11, 2009, 07:06:55 PM »
Mind if I take a look?

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #47 on: August 11, 2009, 07:08:56 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
Code: [Select]
<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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,372
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #48 on: August 11, 2009, 07:12:14 PM »
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.

Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,432
  • Master of BBC Abuse
Re: adding menu to the display.template / display.php
« Reply #49 on: August 11, 2009, 07:14:05 PM »
What Arantor said. Example from a mod:

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

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

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #50 on: August 11, 2009, 07:20:41 PM »
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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,372
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #51 on: August 11, 2009, 07:22:41 PM »
Use:
<search position="end" />
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #52 on: August 11, 2009, 07:27:04 PM »
it worked weee

now error on the other one though  >:(

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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,372
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #53 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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #54 on: August 11, 2009, 07:34:15 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
Code: [Select]
<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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,372
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #55 on: August 11, 2009, 07:34:50 PM »
So what's the current code looking like in the modification.xml?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #56 on: August 11, 2009, 07:38:17 PM »
So what's the current code looking like in the modification.xml?

Code: [Select]
<?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

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,432
  • Master of BBC Abuse
Re: adding menu to the display.template / display.php
« Reply #57 on: August 11, 2009, 07:41:31 PM »
Is using <div class="menu" id="',$message['id'],'"> a good idea? Wont that generate duplicate ID validation errors?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,372
    • StoryBB/StoryBB on GitHub
Re: adding menu to the display.template / display.php
« Reply #58 on: August 11, 2009, 07:42:35 PM »
First mod:

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

Replace with:
Code: [Select]
<search position="end" />
Code: [Select]
<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:
Code: [Select]
<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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Faevilangel

  • Jr. Member
  • **
  • Posts: 231
    • Gareth Gillman Freelacing
Re: adding menu to the display.template / display.php
« Reply #59 on: August 11, 2009, 08:02:40 PM »
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