Propably bug in Advancedform_xh 1.0rc2 with newsbox

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

Post Reply
learnandcode
Posts: 13
Joined: Sat Jan 07, 2012 8:37 pm
Location: Poland
Contact:

Propably bug in Advancedform_xh 1.0rc2 with newsbox

Post by learnandcode » Tue Jan 28, 2014 10:00 pm

Hi.
After many hours of thinking "what is wrong?" I have to admit that it was inappropriate question.
The correct one is "Why is this wrong?". I finally reproduce the bug and here is it.

When i put a code direct to page everything is ok. Styling is working.
But then I had to put form in newsbox. In that case .tpl is working but css no. I never tried js so I don't know is it working right way.



Sorry cmb for interrupting You so many times but I finally found why some of my test code is working and some no.

Best regards
Last edited by learnandcode on Thu May 15, 2014 2:25 pm, edited 1 time in total.

cmb
Posts: 13286
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Propably bug in Advancedform_xh 1.0rc2 with newsbox

Post by cmb » Tue Jan 28, 2014 10:14 pm

learnandcode wrote:When i put a code direct to page everything is ok. Styling is working.
But then I had to put form in newsbox. In that case .tpl is working but css no. I never tried js so I don't know is it working right way.
Ah, I see! The problem is that any stylesheet links (<link rel="stylesheet" ...>) should be put in the head element (<head>). But this is already written, when the newsbox is processed (it's the same as when advancedform() is called directly in the template). JS will have the same issue. Unfortunately, there's not much I can do to improve Advancedform in this regard (the JS issue would be solvable, but not the CSS issue), besides adding this as another limitation to the manual.

As a workaround you can put the style rules to the "global" stylesheet of Advancedform (plugins/advancedform/css/style.css). This should work even for multiple forms, due to the "namespacing". And at least when using a single form this is even slightly more efficient, if you delete the form's stylesheet (plugins/advancedform/data/css/cbk.css).
learnandcode wrote:Sorry cmb for interrupting You so many times but I finally found why some of my test code is working and some no.
It's no problem to "interrupt" me, and in this case I'm happy about the bug report -- even if I can't solve the problem, I can at least document it for the next release.
Christoph M. Becker – Plugins for CMSimple_XH

learnandcode
Posts: 13
Joined: Sat Jan 07, 2012 8:37 pm
Location: Poland
Contact:

Re: Propably bug in Advancedform_xh 1.0rc2 with newsbox

Post by learnandcode » Tue Jan 28, 2014 10:35 pm

Ok.
This will work. Thanks for quick response.

I am not familiar with engine of cmsimple_xh but maybe is possible to determine is function running in newsbox and append a code like that

Code: Select all

<script>$("head").append($("<link rel='stylesheet' href='./plugins/advancedform/data/css/*.css' type='text/css' media='screen' />"));</script>
or find how to do it without jquery. This should work with js too. ;)

br

cmb
Posts: 13286
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Propably bug in Advancedform_xh 1.0rc2 with newsbox

Post by cmb » Tue Jan 28, 2014 11:29 pm

While it's possible to detect if the stylesheet is already linked in the head and otherwise it could be inserted (pure JavaScript would definitely suffice as jQuery is written in JavaScript -- it's no magic), I'm most likely not going to do this, because this would easily fool the webmaster to believe everything is okay, but users who have JavaScript disabled won't see the desired styling. It seems to be better in this case if the webmaster moves the style rules to the general stylesheet instead.

I most likely will, however, make the required modifications so an according JS file will be included even if the plugin is called in a newsbox resp. the template directly, and offer a new demo form, where the technique you have suggested will be used.

Thanks for the nice idea. :)
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply