Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#133 2010-06-24 14:49:10
Re: bot_write_tab_customize: rearrange and style items in the write tab
I will love to know how can I make a links-menu instead of the regular section select-box?
I got a code that let me changing the options of the select-box,
but it’s not hiding the fields/change positions as if I’m selecting it regularly from the select-box.
(of course after it will work I will just hide the select-box using CSS)
<script type="text/javascript">
function sselect(v) {
document.article.section.value = v;
}
</script>
<a href="#" onclick=\'sselect("default");\'>default</a>
<a href="#" onclick=\'sselect("articles");\'>articles</a>
Offline
#134 2010-06-26 15:37:52
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: bot_write_tab_customize: rearrange and style items in the write tab
JanDW wrote:
…This plugin + glz_custom_fields = manna from the txp heavens.
Thank you, but it seems to be not so manna-ish to me, if it continues to sport such silly bugs!
I was sure I fixed it but I was wrong – grrrr…
Anyway I think I found why. Can you help me to fix it definitely with a little test if you have two minutes to spend?
Edit the plugins code and replace this line (around line 649):
$bot_wtc_script = get_magic_quotes_gpc() ? $bot_wtc_script : mysql_real_escape_string($bot_wtc_script) ;
with these two lines:
$bot_wtc_script = get_magic_quotes_gpc() ? stripslashes($bot_wtc_script) : $bot_wtc_script ;
$bot_wtc_script = mysql_real_escape_string($bot_wtc_script);
Then try to insert your original js (non escaped) in the plugins jquery box. It should work now (I hope!)
Last edited by redbot (2010-06-26 15:39:22)
Offline
#135 2010-06-26 16:44:57
Re: bot_write_tab_customize: rearrange and style items in the write tab
redbot wrote:
[…]Edit the plugins code and replace this line (around line 649):[…]
Redbot, you might want to look into some Textpattern’s core functions:
doSlash()
– escapes the querygps()
– returns GET and POST with magic quotes removed. Will cause no conflicts with doSlash().ps()
– same but only for POST.gpsa()
– fetches an array of POST and GET variables.
All of those do what you are doing by checking PHP’s configuration and might make the code cleaner and easier to implement :-)
Hope it helps :-)
Offline
#136 2010-06-26 17:23:27
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: bot_write_tab_customize: rearrange and style items in the write tab
Gocom wrote:
…Hope it helps :-)
Yes, it helps indeed. Thanks Jukka! I’ll use these functions for sure in the next release, together with your other useful coding suggestions.
Thanks again!
Offline
#137 2010-06-26 18:17:00
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: bot_write_tab_customize: rearrange and style items in the write tab
THE BLUE DRAGON wrote:
..I will love to know how can I make a links-menu instead of the regular section select-box?
1) Your js doesn’t work because the plugin is based on the change() event
2) Why did you put the links outside the <script> tag? it works but it’s sort of a hack. Create the links within the script and append them where you like instead.
I’m more familiar with Jquery nowadays so I’ll do this way
<script type="text/javascript">
$(document).ready(function() {
var sections=["default", "articles"]; // add sections here
var string = '';
for(var i=0; i<sections.length; i++) {
string += '<li><a class="sectionLinks" href="#">' + sections[i] + '</a></li>';
}
$("#section").parent().append('<ul>'+string+'</ul>');
$(".sectionLinks").click(function(){
selectedText = $(this).text();
$("#section").val(selectedText);
$("#section").change();
return false;
})
});
</script>
You have to add the sections you want to use in the array (look for the comment in the code).
In this example I appended the links to the same paragraph which is surrounding the sections list and wrapped them in a ul.
If you want the links to appear in another place or with another markup change the code accordingly (or ask here).
P.S. this could be easily automated (automatically build a list of links for each section) but this would override the hidden sections settings (it’a doable but it will require some more thinking).
Last edited by redbot (2010-06-26 18:30:01)
Offline
#138 2010-06-26 20:36:41
Re: bot_write_tab_customize: rearrange and style items in the write tab
redbot wrote:
I’m more familiar with Jquery nowadays so I’ll do this way
Sweeeettt!!! thanks :)
And yea jQuery is our best friend LOL ;)
Now the write tab is even more customize, and we can also drop these links into the regular main menu nav.
Offline
#139 2010-06-26 21:13:34
Re: bot_write_tab_customize: rearrange and style items in the write tab
I want to add an “active” style to the chosen link(section)
something like: $(this).css({color: '#f00'});
how can I do this right please?
Last edited by THE BLUE DRAGON (2010-06-26 21:14:09)
Offline
#140 2010-06-27 01:35:19
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: bot_write_tab_customize: rearrange and style items in the write tab
THE BLUE DRAGON wrote:
I want to add an “active” style to the chosen link(section)
<script type="text/javascript">
$(document).ready(function() {
$(function() {
var sections=["default", "articles"]; // add sections here
var string = '';
for(var i=0; i<sections.length; i++) {
string += '<li><a class="sectionLinks" href="#">' + sections[i] + '</a></li>';
}
$("#section").parent().append('<ul>'+string+'</ul>');
$(".sectionLinks").click(function(){
$(".sectionLinks").css("color", "");
$(this).css("color", "#f00");
selectedText = $(this).text();
$("#section").val(selectedText);
$("#section").change();
return false;
}).click();
});
});
</script>
This is a little more complicated… but why all this? can’t you use rah_write_each_section?
Last edited by redbot (2010-06-27 12:03:21)
Offline
#141 2010-06-27 06:31:27
Re: bot_write_tab_customize: rearrange and style items in the write tab
Thanks again! works great!
redbot wrote:
This is a little more complicated… but why all this? can’t you use rah_write_each_section?
I prefer to create my own custom menu, and thanks to you now I got it =)
Offline
#142 2010-06-27 12:26:15
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: bot_write_tab_customize: rearrange and style items in the write tab
No problem. BTW I was re-reading my code and realized it was too rushed (there are two unnecessary lines). This is better:
<script type="text/javascript">
$(document).ready(function() {
var sections=["default", "articles"]; // add sections here
var string = '';
for(var i=0; i<sections.length; i++) {
string += '<li><a class="sectionLinks" href="#">' + sections[i] + '</a></li>';
}
$("#section").parent().append('<ul>'+string+'</ul>');
$(".sectionLinks").click(function(){
$(".sectionLinks").css("color", "");
$(this).css("color", "#f00");
selectedText = $(this).text();
$("#section").val(selectedText);
$("#section").change();
return false;
}).click();
});
</script>
Offline
#143 2010-06-27 14:09:05
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: bot_write_tab_customize: rearrange and style items in the write tab
JanDW wrote:
Hi redbot – I’m trying to add some additional js:
… when I clickupdate
to save it then I get the following error:
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 '}); ', html='textarea' where name = 'bot_wtc_script'' at line 2 update txp_prefs set val= ' ', html='textarea' where name = 'bot_wtc_script' C:\xampp\htdocs\tiatxp.dev\textpattern\lib\txplib_misc.php(594) : eval()'d code:650 safe_update() in C:\xampp\htdocs\tiatxp.dev\textpattern\lib\txplib_db.php on line 85
Version 0.6.2 should definetely fix this issue.
Offline
#144 2010-06-27 15:07:56
Re: bot_write_tab_customize: rearrange and style items in the write tab
Hi again Redbot – sorry I haven’t been able to get back to you before. Thanks for the updated version!
I’m experiencing another problem — I’m doing this:
which results in this
Any idea what the problem is? Thanks – Jan
TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX
Offline