(->1.6) meaningful colors for page tags

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
svasti
Posts: 1659
Joined: Wed Dec 17, 2008 5:08 pm

(->1.6) meaningful colors for page tags

Post by svasti » Wed Sep 12, 2012 2:00 pm

Hello everbody,

Christoph once proposed moving the setting of pages to memberpage into the page data. However this makes it difficult to see right away, if a page has been set as members page or not. one would have to open the page data dialogue first.

What do you think about the possibility that a possible page tag for memberpages would be colored, let's say red, when a page is a memberpage. In this case you could see right away whether a pages is set as memberpage or not.

A colored page tags could also be used to show whether a page is hidden. Instead of a grey page tag "Page" there could be a red page tag, meaning, some important value is set different for this page. (Now I find myself often opening the page settings dialog to check, whether I set the page as hidden or not.)

Haven't thought about how to code it, just wanted to know what others think about it.

svasti

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

Re: (->1.6) meaningful colors for page tags

Post by cmb » Wed Sep 12, 2012 4:38 pm

Hi svasti,

IMO that would be a very nice addition! :)
svasti wrote:Haven't thought about how to code it
Just a quick idea: the tabs are created from the plugin by calling e.g.:

Code: Select all

$pd_router -> add_tab($plugin_tx['page_params']['tab'], $pth['folder']['plugins'].'page_params/page_params_view.php'); 
An optional third parameter $color might already suffice as information for page_data to change the color.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

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

Re: (->1.6) meaningful colors for page tags

Post by Tata » Wed Sep 12, 2012 7:42 pm

Without thinking about coding...
in cms.php (?)

if adm
if page is memberpage <h?> = <h? class="mebmerpage">
if page is hidden <h?> = <h? class="hiddenpage">
if page is not published <h?> = <h? class="not published">
...
etc.
This way the page would have stylable heading for admin mode.
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.

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

Re: (->1.6) meaningful colors for page tags

Post by cmb » Wed Sep 12, 2012 7:51 pm

Tata wrote:in cms.php (?)
That would inject a dependency on plugins into the core. If a new plugin will be written, which wants to use the feature, the core had to be adapted. I'd rather avoid that.

But indeed, a CSS class offers more flexibility as a fixed color (good idea!). So what about:

Code: Select all

$pd_router->add_tab($name, $view_file, $css_class);
Then this class can be added in page_data to the page tab.
Christoph M. Becker – Plugins for CMSimple_XH

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

Re: (->1.6) meaningful colors for page tags

Post by Tata » Wed Sep 12, 2012 9:03 pm

Whatever... I have on my TODO list with bold letters "Learn more about PHP and CMSimple!!!" but never had found the time and personal power to learn the basics. Also because of studying ready-made scritps and testing which change brings which result. Now I only thought about (at least for me) logical principles. And I am happy to add this hint. The class seems to me to be very pracital and flexible. The colors are then adjustable to the template (.e.g. different colors must be used for "negative" pages etc. So each webmaster can set the colors after his needs.
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.

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

Re: (->1.6) meaningful colors for page tags

Post by cmb » Tue Oct 02, 2012 7:31 pm

We don't have to wait for XH 1.6 to have the feature :!:

It can easily be done in the plugin. Basically a single line of js is enough:

Code: Select all

document.getElementById('tab_Page').firstChild.style.color = 'red';
One has to adapt that to the current language, as the ID of this tab is 'tab_Seite' in German. In Slovak it's 'tab_Stránka'. Unfortunately this is invalid HTML 4.01 resp. XHTML 1.0 (might be valid HTML5, though):
http://www.w3.org/TR/html401/types.html wrote:ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
So IMO we should mangle the tab title for it's use as ID. bin2hex() seems to come in handy here. I suggest the following changes to plugins/pluginloader/page_data/page_data_views.php line 47ff:

Code: Select all

        foreach($this -> tabs as $title => $code){
            $id = bin2hex($title);
            $view .= "\n\t".'<a class="inactive_tab" id="tab_'.$id.'" onclick="toggle_tab(\''.$id.'\');"><span>'.$title.'</span></a>';
        }
        
        $view .= "\n</div>\n".'<div id="pd_views">';

        foreach($this -> tabs as $title => $file){
            $id = bin2hex($title);
            $view .= "\n".'<div id="PLTab_'.$id.'" class="inactive_view">'. "\n\t".'<a id="pd_editor_toggle" class="pd_open" onclick="toggle_tab(\''.$id.'\');">&nbsp;</a>';  
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1659
Joined: Wed Dec 17, 2008 5:08 pm

Re: (->1.6) meaningful colors for page tags

Post by svasti » Fri Nov 23, 2012 6:16 pm

Hi Christoph:

Thanks to your hints Memberpages_XH 3.1 now changes the pagetab designation and color dynamically.

svasti

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

Re: (->1.6) meaningful colors for page tags

Post by cmb » Sat Nov 24, 2012 7:12 pm

Hi svasti,
svasti wrote:Memberpages_XH 3.1 now changes the pagetab designation and color dynamically
That's a nice and useful feature.

So obviously it's not necessary to make any changes to the XH core regarding the stylability of the page data tabs. :)

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

manu
Posts: 1090
Joined: Wed Jun 04, 2008 12:05 pm
Location: St. Gallen - Schweiz
Contact:

Re: (->1.6) meaningful colors for page tags

Post by manu » Thu Dec 20, 2012 12:52 pm

with bin2hex() the id becomes pretty unreadable by developers, but who cares...

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

Re: (->1.6) meaningful colors for page tags

Post by cmb » Thu Dec 20, 2012 1:16 pm

Alternatively we could use the basename() of the file containing the view's definition. This will hopefully consist of allowed characters only, and is at not subject to i18n, so it would be even easier for plugin developers to access it.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply