1

How can I modify the code to show ONLY templates that have changed? I think it kind of ludicrous to show unchanged templates in the Synchronize Templates page.

1

You need to write an ExpressionEngine Accessory. Accessories allow you to inject code into Control Panel pages.

https://ellislab.com/expressionengine/user-guide/development/accessories.html

Please go that route, and not the "let's edit core files derp derp" route. You can use this method to inject some jQuery using a function like this:

ee()->cp->add_to_foot('
<script>
    $(document).ready(function(){
        $('.class-of-unchanged-template-rows-goes-here').remove();
    });
</script>
');

This answer has a more thorough example of how an accessory is structured:

Include custom JavaScript in the control panel

1
  • Had to modify the javascript, see edited original post but got it working.
    – MB34
    Aug 19 '15 at 20:26
1

This is the final working accessory for everyone to use. If you make mods, please post them here.

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * ExpressionEngine Developer Accessory
 *
 * @package     Synch Templates fix
 * @category    Accessory
 * @description Shows only CHANGED templates in Synchronize templates view
 * @author      MB34
 */


class Synch_templates_acc
{
    var $name           = 'Fix Synch Templates';
    var $id             = 'default_value';
    var $version        = '1.0';
    var $description    = 'Shows only CHANGED templates in Synchronize templates view';
    var $sections       = array();

    // --------------------------------------------------------------------

    /**
     * Constructor
     */
    function __construct()
    {
        $this->EE =& get_instance();
    } 

    // --------------------------------------------------------------------

    /**
    * Set Sections
    */
    function set_sections()
    {
        // hide accessory from footer tabs
        $this->sections[] = '<script type="text/javascript" charset="utf-8">$("#accessoryTabs a.default_value").parent().remove();</script>';

        // add css, js and html
        $this->EE->cp->add_to_foot('
        <script type="text/javascript">
            $(document).ready(function(){
                var table = document.getElementById("entries");
                for (var i = table.rows.length-1, row; row = table.rows[i]; i--) {
                    if(row.parentElement.nodeName != "THEAD") {
                        //iterate through rows
                        //rows would be accessed using the "row" variable assigned in the for loop
                        col = row.cells[5];
                        if(col.firstChild && col.firstChild.nodeType != 3) {
                            if(col.firstChild.nodeName != "INPUT") {
                                row.remove();
                            }
                        }
                    }
                }    
            });
        </script>
        ');
    }

}
// END CLASS

/* End of file acc.synch_templates.php */
/* Location: ./system/expressionengine/third_party/synch_templates/acc.synch_templates.php */

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.