Hello,
Can anyone please make a mod which would search for a specific word in all messages and replace it with another one?
It would be very useful when changing usernames (to change the author field in the quote tag) and to replace smiley bbcode.
Thanks
Nobody willing to help me? :(
up!
Up
I started working on it, should be ready by the weekend.
Thanks man! ;)
By the way, how can I learn how to integrate my code in the SMF system/admin panel?
I would like to be able to write some modifications. :)
Well, I can show you what I was doing now for this mod:
To add a link in the admin menu open up the Subs.php and search the adminindex() function.
This will add the link below the "Error log" link.
'view_errors' => '<a href="' . $scripturl . '?action=viewErrorLog;desc">' . $txt['errlog1'] . '</a>',
'find_replace' => '<a href="' . $scripturl . '?action=findreplace">' . $txt['find_replace'] . '</a>', //- Find & Replace MOD-
Define the action, in index.php:
add int he actions array
'findreplace' => array('FindAndReplace.php', 'Main'), //- Find & Replace MOD-
Write the action: Create a file called FindAndReplace.php in the Source directory and define the Main() function inside
<?php
if (!defined('SMF'))
die('Hacking attempt...');
function Main()
{
//Everything in here is admin ONLY. No exceptions.
isAllowedTo('admin_forum');
$subActions = array(
'all' => array('ViewReplacelist'),
);
// Default to sub action 'index' or 'settings' depending on permissions.
$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'all';
$subActions[$_REQUEST['sa']][0]();
}
function ViewReplaceList()
{
global $txt, $scripturl, $db_prefix, $context, $modSettings, $sourcedir;
adminindex('find_replace'); //this will load up the admin menu with the replace link highlighted as active
loadTemplate('FindAndReplace'); //this loads up a template to work with
/**
* do stuff here
*/
}
?>
This is the basic idea behind adding an admin area. Look at how the ManageMembers.(template).php, and other Manage... files are written to learn more.
The file you are writing (FindAndReplace.php) will be included by another one which is the main template of the admin panel, right?
For example, the function isAllowedTo is in one of the sources file which is included in the main admin template, am I correct?
How is made the automatic installation? With a xml file?
I will see if I learn the SMF structure when I finish a project I am currently working on.
How is it going? :)
Well, anybody else would like to do this mod? Why is it so difficult to get support here?
up
Sorry, I had some troubles with my computer last weeks. Yesterday I reinstalled my system and I think I will be able to finish it this week.
Ok, sorry for my lack of patience, but I've been asking for this for a long time. :)
Finally I made it to an initial release. It is in Beta, which means that you should thread carefully.
If you have the time and means to do some testing it would be awsome.
PLease see the topic [BETA] Find and Replace MOD (http://www.simplemachines.org/community/index.php?topic=185762.msg1182242#msg1182242) and report any issues or feedback in there?
Thanks,
Rudolf
Thanks. I will try to do some tests today, on the forum I have installed on my PC. ;)
nice mod. thanks to you both