eZ Community » Forums » Developer » What is the best way to customize...
expandshrink

What is the best way to customize admin2 child listing?

What is the best way to customize admin2 child listing?

Monday 05 December 2011 10:41:51 am - 4 replies

Hi there,

We have a problem that we would need your help.
In admin2 we want to customize the way subitems are displayed (add an anchor next to the subitem name for subitems belonging to a specific class, under a specific parent node).

The current installation runs on eZPublish Community Project 2011.9 installation and comes as an upgrade from an 4.2.0 installation.

In the old admin interface (on 4.2.0) the solution was to overwrite the node/view/line.tpl template  with a custom template (for subitems belonging to a specific class, under a specific parent node) in order to include and additional anchor next to the subitem’s name.

In admin2 (on 2011.9)  the way subitems are displayed was changed and the above solution doesn’t work because the subitems table is populated in the design/admin2/javascript/ezajaxsubitems_datatable.js file with the initDataTable() function.

We considered the following solution :
- create an override for children.tpl template from the admin2 design (only for subitems of a certain class under a certain parent node). This template practically includes the ezajaxsubitems_datatable.js which does all the job of populating the subitems table.
- Create a similar ezajaxsubitems_datatable.js file (let say ezajaxsubitems_datatable_mod.js) which we will locate under our custom admin design and make sure it is included by the custom children.tpl

This way we can easily adapt the javascript code to build the subitems table as desired without affecting the original file.

What would be the best way/practice of doing this?

Thank you,
Virgil

Modified on Monday 05 December 2011 10:42:32 am by Virgil Ciobanu

Monday 05 December 2011 4:55:47 pm

Hi Virgil,

the safest bet (and the only way as I see it) would be to override ezajaxsubitems_datatable.js in your new mini admin design and modify the file to suit your needs. Your mini admin design would ofcourse be the main administration design (SiteSettings/SiteDesign), and admin2 would move to AdditionalSiteDesignList array in INI files.

In overriden javascript file, you would need to modify formatName function do display the link where you want it.

Something along these lines:

var formatName = function(cell, record, column, data) {
    if ( record.getData('parent_node_id') == 123 && record.getData('class_identifier') == 'my_class' )
        cell.innerHTML = '.....';
    else
        cell.innerHTML = ... original content ...;
}

Monday 05 December 2011 6:31:48 pm

Hi Edi, thank you for reply. 

We did not saw this solution to override only the JavaScript file even though we already use what you suggested (a new custom design folder that fall back onto admin2) as the site has many customisations on admin part. Sometimes the most evident things are hard to be noticed.

This solution has the advantage that only one file has to be modified but you will have to hardcode the part that decide when to show the modified version of table line.

We applied the solution I’ve described in the post which basically make use of the other mechanism to override templates to arrive to the same result (a bit indirectly, as you can only override templates) : having loaded a modified version of ezajaxsubitems_datatable.js.

Even though it seems like more work (we’ve added/modified 2 other files: children.tpl and override.ini.append.php ) what I like in this solution is that it uses the standard override mechanism to decide when the modified files to be loaded.

But, I should say, if I would have seen both solutions from beginning I would probably choose to modify only the js file.

Thank you very much for help,
Virgil

Modified on Monday 05 December 2011 6:32:24 pm by Virgil Ciobanu

Monday 05 December 2011 6:39:44 pm

Good to hear that you managed to do it happy.gif Emoticon

You see, I didn't think of the override.ini file to create a custom children.tpl, and in turn custom javascript file to do the modifications happy.gif Emoticon

About my solution, if you wanted to avoid hardcoded values, you can always put them in the ini file and pass the parameters to javascript in overriden children_detailed.tpl (not overriden through override.ini but by design priorities), much like all other parameters are passed in that template.

Modified on Monday 05 December 2011 6:41:05 pm by Edi Modrić

Monday 05 December 2011 7:11:52 pm

Thank you for sharing this. 

You've made our morning topic for tomorrow when my colleagues will come to office.

 

Great to have people like you around.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from