Okay
  Public Ticket #2960798
Remove prefix on sum shortcode
Closed

Comments

  • Todd McMahon started the conversation

    I'm using the sum shortcode for a column outside of the chart and it always displays with "∑ =" before the value. I would like it to just display the value.  

    For instance, I place [wpdatatable_sum table_id=16 col_id=133] on my page and the result is ∑ = 121. How can I remove the ∑ = and just display 121?

    I’d also like to do this when using the average shortcode and assume the solution will be similar.

  •  1,684
    Miloš replied

    Hello, Todd.

    Sorry for the delayed response.

    - To remove the SUM/Total symbol, you need to open and edit a little bit of code from three files using any text editor of your choice; find them inside your WordPress folder :

    - The PHP file :

    ../wp-content/plugins/wpdatatables/controllers/wdt_functions.php

    use "CTRL+F"  in the editor to search for this: " #8721 "

    You will find part of a line that looks like this :

    echo ((isset($wdtSumFunctionsLabel) && $wdtSumFunctionsLabel != '') ? $wdtSumFunctionsLabel : '& #8721; = ')
    
    5611304872.png

    - Remove "& #8721; = " from the end, so it looks like this:

    echo ((isset($wdtSumFunctionsLabel) && $wdtSumFunctionsLabel != '') ? $wdtSumFunctionsLabel : ' ')
    

    - Do the same for this Javascript file, 

    which is located here : 

    /wp-content/plugins/wpdatatables/assets/js/wpdatatables/wpdatatables.js

    you will find something like this :

    var sumLabel = tableDescription.sumFunctionsLabel ? tableDescription.sumFunctionsLabel : '& #8721; = ';

    Once "& #8721; = "  is removed, should look like this :

    var sumLabel = tableDescription.sumFunctionsLabel ? tableDescription.sumFunctionsLabel : ' ';
    

    - Same with this PHP file :

    wp-content/plugins/wpdatatables/templates/frontend/table_footer.inc.php

    ;

    Once you are finished, the SUM/Total symbol should be gone from the Front End.

    Also, make sure to disable "Use minified wpDataTables Javascript" slider in the wpDataTables settings/Custom JS and CSS tab, as on this screenshot :

    6740649174.png

    ;

     2.

    • For the Average symbol/prefix; it should be the same, they are all close to each other in the code; as you can see here as (   'Avg =';    )
    8465111561.png

    - I will double-check with the developers and get right back to you when they respond, just to be sure; but in my opinion, it should be safe for you to try the same with the "Average prefix" in the meantime if you make a copy of all three files : (

    ../wp-content/plugins/wpdatatables/controllers/wdt_functions.php

    /wp-content/plugins/wpdatatables/assets/js/wpdatatables/wpdatatables.js

    wp-content/plugins/wpdatatables/templates/frontend/table_footer.inc.php

    )

    That way, even if a mistake happens, you would have a backup to revert to. So, you can give it a go if you wish, and in the meantime, I will double-check and get back to you as well.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Todd McMahon replied

    Thanks for the info. I'll give it a shot. Since I'll be editing plugin files, will my changes be overwritten when the plugin is updated? Should I move these files into a child theme first?

  •  1,684
    Miloš replied

    Hello again, Todd

    Apologies for another late response.

    - That is correct, during update time, all the core/code files are deleted, and rewritten to "default lines", so you would have to do this process again to remove any symbols that you need to.

    - I confirmed it should be the same procedure for "SUM, Average, or MIN" removal of the prefixes.

    - Regarding moving the files into a child theme, the information I have is that this would not be possible/ but I will double-check that as well and will post back just to confirm additionally.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  1,684
    Miloš replied

    Hi, Tod.

    - We have additional information that might be very useful; depending on how you would like to insert the calculation functions on the WP page(s).

    - Editing those 3 files I showed you is one way of doing this; this is necessary if you need to use the SUM / Average, or Min as part of the table, with the box checked on the column settings;

    but in case you use a shortcode - you don't have to edit those 3 files, and this will not be deleted during updates;

    what you would do is add parameter "label" at the end of the Calculation shortcode, and put an empty value in it, like this:

    [wpdatatable_sum table_id=1 col_id=10 label='']
    [wpdatatable_avg table_id=1 col_id=10 label='']
    [wpdatatable_min table_id=1 col_id=10 label='']
    [wpdatatable_max table_id=1 col_id=10 label='']

    ( Of course, replace the 'table_id', and 'col_id' with the respective values for your table/column).

    Additional note: you can set a custom label for functions, if needed, in the main settings of the wpDataTables plugin from the WP Admin Dashboard -

    2314914039.png

    Hopefully, this information should make it easier for you to use this functionality. If you need more details, please contact us further.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Todd McMahon replied

    Thanks. The shortcode solution is perfect. Now to go a little further, is it possible to append the value? For instance, the average would display AVG = 82.68. Now that I can remove the label it just displays 82.68. Is it possible to display it like 82.68%

    It looks like a shortcode is treated as a block element because if I add % after the shortcode, it displays, but it's on the next line.

     <h1>[wpdatatable_avg table_id=13 col_id=240 label='']%</h1>

    Displays like:

    82.68
    %

    Thanks again for your help

  •  1,684
    Miloš replied

    Hi, Todd

    - I experimented with adding Average shortcode to a test WP page; and when I added this custom CSS to the WP page , it  has made the shortcode stay on the same line as the % sign;

    .wdt-column-avg {   
     display: inline-block;
    }
    
    3882026319.png

    If that doesn't work, could you give me a link to the page where you put this shortcode, so that I can take a closer look? I have an idea what to do, possibly with some custom CSS added to the page; but not sure yet.

    And if you want to save time, I could access the page editor in your WP Admin, to try and directly test a solution; if you provide me a temporary WP-admin (administrator) user for your site where this happens, so we could log in and take a look ‘from the inside’ as that’s the most efficient way to see and resolve the issue. 

    We do not interfere with any data or anything else except for the plugin (in case that’s a production version of the site), and of course, we do not provide login data to third parties. 

    You can write credentials here just check PRIVATE Reply so nobody can see them except us.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables