Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#61 2010-01-29 14:37:03
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: bot_write_tab_customize: rearrange and style items in the write tab
mlarino wrote:
I am having problems inserting JS in the plugin, I am getting this warning:
Warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'text/javascript"> $(document).ready(function() { $(".collapse").click' at line 1 update txp_prefs set val= "", html="textarea" where name = "bot_wtc_script" in /home/sites/mlarino.com/public_html/asesoria/textpattern/lib/txplib_db.php on line 113
mlarino,
this is strange I never had such an issue and it was never reported before.
Just to be sure: you have pasted the code in the js box and got this error after pressing “submit”?
Of course I have tried it myself but all works correctly… it looks like an escaping problem
A couple of questions:
1) are you using the latest version of the plugin?
2) which version of txp are you using?
Has anybody else experienced this problem?
Offline
#62 2010-01-29 15:06:32
- mlarino
- Member
- Registered: 2007-06-29
- Posts: 367
Re: bot_write_tab_customize: rearrange and style items in the write tab
redbot wrote:
A couple of questions:
1) are you using the latest version of the plugin?
2) which version of txp are you using?
Has anybody else experienced this problem?
It happens as you say, I paste the code in the JS box and get the message when I hit the “submit” button.
I have Textpattern 4.2.0 and
bot_write_tab_customize 0.5.2
The rest of the plugins I have installed are:
gbp_admin_library
glz_custom_fields
l10n
lam_image_uploader
rah_replace
smd_admin_themes
wet_haystack
zem_contact_lang-mlp
Last edited by mlarino (2010-01-29 15:07:06)
Offline
#63 2010-01-29 15:28:57
- mlarino
- Member
- Registered: 2007-06-29
- Posts: 367
Re: bot_write_tab_customize: rearrange and style items in the write tab
Ok, testing and testing I found out that instead of using "
if I use '
in all the sintax, the plugin lets me save the javascript.
instead of this:
<script type="text/javascript"> $(document).ready(function() { $("toggle").click(function(){ $(this).parent().find("textarea").slideToggle(); }); }); </script>
I have to use this:
<script type='text/javascript'> $(document).ready(function() { $('toggle').click(function(){ $(this).parent().find('textarea').slideToggle(); }); }); </script>
Why do you think this hapends?
-Either way, the javascript is not doing anything to the custom field at all.
Last edited by mlarino (2010-01-29 15:29:46)
Offline
#64 2010-01-29 16:28:13
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: bot_write_tab_customize: rearrange and style items in the write tab
mlarino,
so if you use this code (escaping double quotes with “\”):
<script type=\"text/javascript\"> $(document).ready(function() { $(\".collapse label\").click(function(){ $(this).parent().find(\"textarea\").slideToggle(); }); }); </script>
it should also give no errors.
Anyway I’ll try to understand why it works for me and not for you…
-Either way, the javascript is not doing anything to the custom field at all.
What you mean? This code was an answer to this request (expland/collapse the escerpt box) while you are talking about custom fields…
Offline
#65 2010-01-29 16:31:47
- mlarino
- Member
- Registered: 2007-06-29
- Posts: 367
Re: bot_write_tab_customize: rearrange and style items in the write tab
mmm
yes, I guess you are right….
I just thought that adding the collampse calss to de cutom field, at least it would wrap that custom field… maybe I was wrong.
I will keep testing and trying and see if I can figure it out .
Thanks!
Offline
#66 2010-01-29 16:57:03
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: bot_write_tab_customize: rearrange and style items in the write tab
Just out of curiosity, what are you trying to accomplish? Maybe I can give some advice…
And keep in mind that now we are dealing with Jquery. It has little to do with the plugin which only inserts the js in the the “write” tab html.
edit
Anyway, if you want to expand/collapse a “normal” text input custom field you have to replace “textarea” with “input” in the code above.
If you want to expand/collapse a “select” custom field (via glz_custom) you have to replace “textarea” with “select”.
Last edited by redbot (2010-01-29 17:04:13)
Offline
#67 2010-01-29 17:02:21
- mlarino
- Member
- Registered: 2007-06-29
- Posts: 367
Re: bot_write_tab_customize: rearrange and style items in the write tab
Well, dont know much about JS Jquery, mootools or anything, I just use them, but dont really understand the sintax….
All I want to do is be able to Toggle the Custom_Field “Extras”
The “Extras” custom_field is a list of checkboxes, too long, so i wanted to be able to hide it, or show depending on the need.
Offline
#68 2010-01-29 17:33:29
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: bot_write_tab_customize: rearrange and style items in the write tab
mlarino wrote:
The “Extras” custom_field is a list of checkboxes, too long, so i wanted to be able to hide it, or show depending on the need.
Actually checkboxes are the most difficult type of custom fields to apply this effect because every checkbox is wrapped in a span. Anyway in this case you can try this
<script type="text/javascript"> $(document).ready(function() { $(".collapse label:first").click(function(){ $(this).parent().find("span").slideToggle(); }); }); </script>
It’s not elegant at all and tries to achieve the result in a sloppy way. Anyway stay assured that there is a better way to do it (thanks to jquery); if I find some time and have a better idea I’ll post here.
P.S. Given the ecaping issues you were having before, remember to prepend “\” to each double quote in the code I posted
Offline
#69 2010-01-29 19:14:17
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: bot_write_tab_customize: rearrange and style items in the write tab
mlarino wrote:
I am having problems inserting JS in the plugin, I am getting this warning:
Warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'text/javascript"> $(document).ready(function() { $(".collapse").click' at line 1 update txp_prefs set val= "", html="textarea" where name = "bot_wtc_script" in /home/sites/mlarino.com/public_html/asesoria/textpattern/lib/txplib_db.php on line 113
Hi again,
Regarding this issue you were perfectly right: this is really a naive error on my side (didn’t take in account if magic quotes were enabled or not) and I’ll fix it in the next release. Thank you for noticing!
As for the collapsible checkboxes you actually discovered a little issue with glz_custom. I’ll ask Gerhard to make glz_custom output a more manageable html for checkboxes.
Last edited by redbot (2010-01-29 19:18:24)
Offline
Re: bot_write_tab_customize: rearrange and style items in the write tab
redbot wrote:
you can achieve what you want adding some lines of jquery in the “additional js code” field. I can’t help you now but a similar – though simpler – request has already been answered here. The principle should be the same: first add the same class to items you want to expand/collapse together (for example .toggle1 for cf1 +cf2 and .toggle 2 for cf3+cf4) and then – through jquery – add somewhere in your “write” tab one or more texts or links or buttons which trigger the expand/collapse behaviour.
Thank you. I will take this as yet another prompt to lean more javascript and how the txp admin area is made up. :) Great plugin, as are your others. I’ve never been so close to having the ideal setup for clients. Fantastic! IMHO this should be txp core bound. Once it’s idiot proof to use of course. Maybe it would exist in a new sub-section of advanced prefs… Just a thought.
txtstrap (Textpattern + Twitter Bootstrap + etc…)
Offline
Re: bot_write_tab_customize: rearrange and style items in the write tab
Wow, this plugin is amazing!
I can do everything I used to hack txp_article.php for :)
Custom javascript box comes in very handy for some manual tweaks.
Good job redbot!
Kensington TXP powered rock
Offline
Re: bot_write_tab_customize: rearrange and style items in the write tab
Running into this problem…
After 13 custom fields have been hidden when I click “update” it dumps me back into the articles page.
Weird… any ideas?
Offline