XH 1.6: Consistent naming of IDs and Classes

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XH 1.6: Consistent naming of IDs and Classes

Post by cmb » Thu Oct 24, 2013 8:59 pm

Tata wrote:Would it be difficult to keep all old/new names in one file and having this included in cms.php the functions would use new/old names automatically?

I mean - if an function/plugin is used, it will use old name idnoring the included file. If a new function/plugin is used, it will read the replacement from the fiel. Or vice versa.
That would require the function/plugin to be rewritten. Usually, a plugin simply emits some (X)HTML using an hardcoded class or ID identifier, for instance:

Code: Select all

$o = '<div id="' . cmsimplecore_warning . '">'; 
We could introduce constants for the plugins, but these constants would not be available per se for JavaScript, and above all they won't be available in other versions of CMSimple.

Anyway, I did a search for id=" in all source files, and found the following IDs which are not prefixed:

Code: Select all

form#ta                         content editor
textarea#text                   content editor
div#cmsimple_mailform           mailform (outer DIV)
div#editmenu_scrolling          adminmenu (outmost)
div#editmenu_fixed              adminmenu (outmost)
div#editmenu                    adminmenu
ul#edit_menu                    adminmenu
form#login                      login form
input#passwd                    login form: password input
input#submit                    login form: submit button
div#searchbox                   searchbox (inside its form)
div#*_DLG                       config form(s): password dialog
a#tab_*                         page data tabs
div#pd_views                    page data tabs
div#PLTab_*                     page data tabs

form#rename_*                   cmsbrowser
div#folders                     cmsbrowser
div#subfolders                  cmsbrowser
div#files                       cmsbrowser

div#folders                     editorbrowser
div#files                       editorbrowser

textarea#*                      meta_tags: page data tab (* = field names)
input#*                         meta_tags: page data tab (* = field names)

input#show_last_edit_*          page_params: page data tab (* = 0-2)
input#use_header_location_*     page_params: page data tab (* = 0-2)
input#other_heading             page_params: page data tab
input#other_header_location     page_params: page data tab
input#publication_date          page_params: page data tab
input#expires page_params:      page data tab
Collisions of IDs are a potential problem with regard to JavaScript (even more so than for CSS), so I suggest that we also clean that up.
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XH 1.6: Consistent naming of IDs and Classes

Post by cmb » Fri Nov 01, 2013 12:21 am

I have cleaned this up somewhat with regard to compatibility with existing extensions, as CMSimple_XH 1.6 is a minor release. I suggest we finish it for CMSimple_XH 2.0, and so I put it on this roadmap to not forget about it.
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: XH 1.6: Consistent naming of IDs and Classes

Post by Tata » Fri Nov 01, 2013 7:42 am

+1 to leave it for 2.0
Last edited by Tata on Thu Nov 07, 2013 7:12 am, edited 2 times in total.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: XH 1.6: Consistent naming of IDs and Classes

Post by Holger » Wed Nov 06, 2013 11:12 pm

cmb wrote:I suggest we finish it for CMSimple_XH 2.0, and so I put it on this roadmap to not forget about it.
+1

Holger

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: XH 1.6: Consistent naming of IDs and Classes

Post by Tata » Thu Nov 07, 2013 7:12 am

Maybe it's nothing new, but here I would suggest this convention:
1. All classes and IDs used in core files assign by prefix core_
2. All classes and IDs used in plugins assign by prefix <plugin_name>_
3. All classes and IDs used in editors assign by prefix <editor_name>_
4. All classes and IDs used in webpage template assign by prefix tpl_

I think this would be enough to aovid any possible conflicts.
For backwaer compatibility with older versions it would be simple to use doubled classes/IDs in stylesheets.
E.g.
In css/core.css:
#editmenu_scrolling, #core_editmenu_scrolling{...}

in plugins/meta_tags/css/stylesheet.css:
#meta_tags hr, #core_meta_tags hr{...]

In plugins/tinymce/tiny_mce/themes/advanced/skins/default/img/ui.css:
.defaultSkin table, .tmc4_defaultSkin table{...]

In author's template:
#body, #tpl_body{...}

Inclusion of older <file>.css into a new one equivalent would also be possible.
E.g.

<file_1-6>.css with included <file>.css
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Post Reply