Should page.add.tpl and page.edit.tpl be merged?

95% 57
5% 3

60 Date 2012-12-07 10:08

Forums / Cotonti / Core Labs / Ideas / Poll: Merge pade.add and page.edit

Getting rid of redundant code

Trustmaster
#1 2012-12-07 10:08

Now that page management is unified underneath, the functionality of page.add and page.edit is almost identical. Therefore they can be merged to reduce code duplication.

Pros:

  • Maintain just page.edit.tpl instead of page.add.tpl and page.edit.tpl.
  • Reduces code redundancy.

Cons:

  • If you need different sets of fields for adding and editing a page, you need to use IFs in the template or still make 2 different templates for add and edit.

What do you think?

May the Source be with you!
lukgoh
#2 2012-12-07 10:52

I dont see any problem with merging them but keeping 2 different templates for the seperate pages. At least this way it wont confuse new people using the CMF. 

Kingsley
#3 2012-12-07 11:25

So in the end it will be more work for coders? Meh.. Do not like combined tpl's.. Like the one of the polls; it's a freaking nightmare..

Macik
#4 2012-12-07 12:39

Vote for  «YES», but have several questions…

Is there ability to use one function with different TPLs?  I speak about using 2 tpl - one for add and one for edit.

Or some compromise solution to pass TPL path as a parameter, so (when we adding a page) first we can check is there separate «add» template, otherwise use standart «edit» one.

By the way, is this merge consider any «add/edit.first/tags» hooks? Would it be backwards compatible so old plugins still works?

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F
Trustmaster
#5 2012-12-07 12:51

@Kingsley

No, it's different from polls. Polls actually have several templates mixed in 1 file. What we propose here is having 1 template (1 MAIN block) for both adding and editing. Which is less work for coders.

@Macik

Yes, support for pade.add.tpl still should be there if the template exists. But by default it would fall back to page.edit.tpl otherwise.

As for hooks, I think they still should be different because some actions are done when a page is added for the first time but not when editing, and vice versa. But e.g. page.add.tags and page.edit.tags can be merged. In other words, each hook needs individual consideration.

May the Source be with you!
Kingsley
#6 2012-12-07 16:24

@ trust. ok, then I am cool with that :)