News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Add Modify to Quick Buttons menu

Started by GL700Wing, September 25, 2024, 01:29:46 AM

Previous topic - Next topic

GL700Wing

Link to the mod

Add Modify to Quick Buttons menu
v1.1

This mod will add the Modify button to the Quick Buttons menu and provide an option to remove the Quick Edit button from the Quick Buttons menu.

Release History
v1.0 - 25-Sep-24
o Initial release as Replace Quick Edit with Modify.

v1.1 - 28-Sep-24
o As per this request made removal of the Quick Edit button from Quick Buttons menu optional.
o Renamed to Add Modify to Quick Buttons menu.

License
Copyright 2024 Kathy Leslie

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

JRMBelgium

For some reason I can't review this mod so just letting you know here it works perfectly!

I modified the code a little for me so that it not replaces the button, but simply adds it. This way anyone can choose which options fits best for their needs.

Steve

Quote from: JRMBelgium on September 25, 2024, 02:29:20 PMI modified the code a little for me so that it not replaces the button, but simply adds it.
How? I would like that option as well.
My pet rock is not feeling well. I think it's stoned.

GL700Wing

Quote from: Steve on September 26, 2024, 07:27:59 AM
Quote from: JRMBelgium on September 25, 2024, 02:29:20 PMI modified the code a little for me so that it not replaces the button, but simply adds it.
How? I would like that option as well.
Simples - just comment out the following line in ./Sources/Subs-RQEwM.php
    unset($output['quickbuttons']['quick_edit']);

Might update the mod to include a setting that gives the option to just move the 'Modify' button (ie, also keep the 'Quick Edit' button) ...
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Steve

My pet rock is not feeling well. I think it's stoned.

JRMBelgium

Quote from: Steve on September 26, 2024, 07:27:59 AM
Quote from: JRMBelgium on September 25, 2024, 02:29:20 PMI modified the code a little for me so that it not replaces the button, but simply adds it.
How? I would like that option as well.

<?php
//============================================================================================================
// Function for adding the 'Modify' button from the 'More' menu to the main view without removing the 'Quick Edit' button.
// Called as hook by 'integrate_prepare_display_context' in ./Sources/Display.php.
//============================================================================================================
function RQEwM_displayContext(&$output)
{
    global 
$context$scripturl$txt;

    
// 'Modify' button definition copied from ./Sources/Display.php
    
$modifyButton = array(
        
'modify' => array(
            
'label' => $txt['modify'],
            
'href' => $scripturl '?action=post;msg=' $output['id'] . ';topic=' $context['current_topic'] . '.' $context['start'],
            
'icon' => 'modify_button',
            
'show' => $output['can_modify']
        ),
    );

    
// Add the 'Modify' button to the quick buttons menu.
    // This places 'Modify' immediately after 'Quick Edit'.
    
$quickButtonsKeys array_keys($output['quickbuttons']);
    
$index array_search('quick_edit'$quickButtonsKeys);
    
    if (
$index !== false) {
        
// Insert 'Modify' after 'Quick Edit'
        
$index += 1;
        
$output['quickbuttons'] = array_merge(
            
array_slice($output['quickbuttons'], 0$index),
            
$modifyButton,
            
array_slice($output['quickbuttons'], $index)
        );
    } else {
        
// If 'Quick Edit' is not found, append 'Modify' at the end
        
$output['quickbuttons'] = array_merge($output['quickbuttons'], $modifyButton);
    }

    
// Remove the 'Modify' button from the 'More' menu to prevent duplication
    
if (isset($output['quickbuttons']['more']['modify'])) {
        unset(
$output['quickbuttons']['more']['modify']);
    }

    
// Note: The line below has been removed to retain the 'Quick Edit' button
    // unset($output['quickbuttons']['quick_edit']);
}
?>


GL700Wing

Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Steve

Thanks GL. Is there supposed to be any settings somewhere?
My pet rock is not feeling well. I think it's stoned.

GL700Wing

Quote from: Steve on September 28, 2024, 08:51:04 AMThanks GL. Is there supposed to be any settings somewhere?
In Modification Settings (hopefully) ...


Just updated the mod package file to redirect to the Modifications Settings page after mod is installed.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Steve

I had totally missed the setting the first time I looked. Sorry about that.

Thanks for the update.  :)
My pet rock is not feeling well. I think it's stoned.

Steve

There seems to be a glitch somewhere ... when modifying a post and saving it, I get a message at the top of the page that says 'Loading' and the page is never refreshed. But if I manually refresh the page, the post shows with any changes I've made.  ???
My pet rock is not feeling well. I think it's stoned.

GL700Wing

Quote from: Steve on September 30, 2024, 10:37:27 AMThere seems to be a glitch somewhere ... when modifying a post and saving it, I get a message at the top of the page that says 'Loading' and the page is never refreshed. But if I manually refresh the page, the post shows with any changes I've made.  ???
That seems like a JS issue and this mod doesn't do any JS stuff - wondering if it's because of this issue which you also reported.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Steve

Possible I guess. I know nothing about coding so you could very well be right.
My pet rock is not feeling well. I think it's stoned.

Advertisement: