Highlight plugin calls

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
Tata
Posts: 2879
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Highlight plugin calls

Post by Tata » Sat Dec 27, 2014 5:54 pm

Little idea:
how would it be possible to have all calls styled by a pre-defined colour different from the pre9-defined webpage text color?
Or even with a tooltip with configurable hint, warning etc.
E.g.
Heading
{{{COMMENT: plugin-call();}}}
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat."
Last edited by cmb on Sat Dec 27, 2014 6:10 pm, edited 1 time in total.
Reason: moved to new topic
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: 12926
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Highlight plugin calls

Post by cmb » Sat Dec 27, 2014 6:20 pm

Tata wrote:how would it be possible to have all calls styled by a pre-defined colour different from the pre9-defined webpage text color?
That would be nice. I have seen this several times done by users, not rarely causing the plugin call to fail due to markup inside the {{{ }}}.

However, this would have to be done for each editor individually to be working before the page is saved, and I'm not sure if it's feasible at all. If it would be okay to highlight the plugin call only after saving, we could do that similar to replacing a surrounding <p> with a <div>. In both cases adding an appropriate CSS class (which would have to be styled in the template's stylesheet) might be sufficient.

A quick draft: find the following in cmsimple/adminfuncs.php (line 922ff):

Code: Select all

    $text = preg_replace(
        '/<p>({{{.*?}}}|#CMSimple .*?#)<\/p>/isu', '<div>$1</div>', $text
    );
Replace with:

Code: Select all

    $text = preg_replace(
        '/<(?:p|div)>({{{.*?}}}|#CMSimple .*?#)<\/(?:p|div)>/isu', '<div class="xh_plugin_call">$1</div>', $text
    );
Anyhow, I'll put it on the roadmap for XH 1.7.
Christoph M. Becker –Plugins for CMSimple_XH

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

Re: Highlight plugin calls

Post by Tata » Sat Dec 27, 2014 10:10 pm

Tested with 1.6.4 - works but only with the comment "PLUGIN:". With pure {{{plugincall();}}} it doesn't work at all.
However, the plugin output is then styled too. E.g. the call

Code: Select all

{{{twocents('guestbook');}}}
makes the Guestbook styled the same way as defined in xh_plugin_call.
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: 12926
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Highlight plugin calls

Post by cmb » Sun Dec 28, 2014 12:12 pm

Tata wrote:Tested with 1.6.4 - works but only with the comment "PLUGIN:". With pure {{{plugincall();}}} it doesn't work at all.
I had tested with {{{slideshow('slides', 'order=fixed');}}}, and that worked. However, it won't work, if the plugin call is written inline or if it is put in an already styled element, for instance. There is room for improvement, even though we may not be able to catch all cases.
Tata wrote:However, the plugin output is then styled too.
Yes, indeed. To avoid that, the styling of the plugin call must not be put into the template's stylesheet, but rather in a separate stylesheet, which has to be referenced in plugins/tinymce/inits/init_*.js. For instance,replace:

Code: Select all

    content_css : "%STYLESHEET%",
with:

Code: Select all

    content_css : "%STYLESHEET%, ./plugins/tinymce/inits/editor.css",
AFAIK for CKEditor there is a similar mechanism.
Christoph M. Becker –Plugins for CMSimple_XH

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

Re: Highlight plugin calls

Post by Tata » Sun Dec 28, 2014 1:23 pm

Works fine but still only with "PLUGIN: ". At least on my website.
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.

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

Re: Highlight plugin calls

Post by Tata » Wed Apr 05, 2017 3:16 pm

Tested right now with v1.6.9.
Adjusted the above suggested code to

Code: Select all

   if(!$adm == "true"){
        $text = preg_replace('/<(?:p|div)>({{{.*?}}}|#CMSimple .*?#)<\/(?:p|div)>/isu', '<div class="xh_plugin_call">$1</div>', $text);
    }else{
        $text = preg_replace('/<(?:p|div)>({{{.*?}}}|#CMSimple .*?#)<\/(?:p|div)>/isu', '<div>$1</div>', $text);
    }
    and saving editor.css in ./plugins/tinymce/inits

Code: Select all

.xh_plugin_call{display: inline-block; background: yellow; color: red; border: 1px solid red;}
.xh_plugin_call:before{content: "PLUGIN CALL: "; color: red; font-weight: bold;}
.xh_plugin_call:after{content: " DON'T TOUCH!!!"; color: red; font-weight: bold;} 
I get
[ external image ]
As you see, it works without "PLUGIN" and it acts only while logged in. Normally the plugin call is executed.
However, it doesn't work if there are other plugins installed. Or it seems that the problem is somewhere in content.htm. With Original content file it works. When I add a content from another website, it doesn't work.
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: 2898
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany
Contact:

Re: Highlight plugin calls

Post by Holger » Wed Apr 05, 2017 4:56 pm

Another idea:
what about something like this: http://sdk.ckeditor.com/samples/placeholder.html ?
Once you have entered a PluginCall it gets highlighted and you can only edit the contents with a double click.

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

Re: Highlight plugin calls

Post by Tata » Wed Apr 05, 2017 5:34 pm

Well, this would be fine. But it would require to use CKRditor instead of tinyMCE, which is somehow more flexible to me.
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: 12926
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Highlight plugin calls

Post by cmb » Wed Apr 05, 2017 9:55 pm

Holger wrote:what about something like this: http://sdk.ckeditor.com/samples/placeholder.html ?
Great! IMHO much better than just highlighting plugin calls. Thank!
Tata wrote:But it would require to use CKRditor instead of tinyMCE, which is somehow more flexible to me.
There might be a similar solution readily available for TinyMCE (I couldn't find one, though), or we may write one ourselves (Calleditor_XH is actually somewhat similar). Note, however, that TinyMCE 3 (our default editor so far) is going to be replaced by TinyMCE 4 in XH 1.7, which is quite different to TinyMCE 3, it seems.
Christoph M. Becker –Plugins for CMSimple_XH

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

Re: Highlight plugin calls

Post by Tata » Thu Apr 06, 2017 6:30 am

This method seems not to work with v1.7.0. There are no warnings returned, but the styling is not adopted by the editor.
The Calleditor would be fine. But it didn't read all plugins installed, instead it offered some plugins I don't have installed at all. Also the problem is not in writing the plugin call. The purpose is in styling already inserted plugin call.
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