Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Different names for fields in Write tab per section?
Not every entry on my website is best entered with the default Write tab, so I’ve made some changes. I am using bot_write_tab_customize to rearrange the elements. I also altered the en-gb.txt language file to reflect the actual information I am entering into the fields (changed Excerpt and Body to History and Findings, for example).
Now what if I want to change the names of the fields depending on what section I’m entering a post for? For example, instead of History and Findings I want to change it to display Questions and Answers instead. Is this possible using multiple language files or some other way?
Last edited by aswihart (2009-12-17 10:35:34)
Offline
Re: Different names for fields in Write tab per section?
Hi
Personnaly I use stm_javascript and jmd_admin_js to custom wrtie tab, you can then some jquery stuf to make changes like you want.
Cheers
Offline
Re: Different names for fields in Write tab per section?
Cool man, thanks I hadn’t discovered these yet, sounds like they will do the trick.
Offline
Re: Different names for fields in Write tab per section?
Well, a couple issues. First, I don’t know how I can use javascript to change those fields when I select different sections from the drop-down menu. I’m sure it’s possible, as sed_section_fields seems to apply different javascript when you select sections. Any guidance here is much appreciated.
Once I can target the various sections, I run into a second issue: I really don’t know jack about writing javascript. I described essentially what I want to do in my first post. I just want to change the “excerpt” and “body” fields depending on what section I have selected from the drop-down list. I need help with this too if anyone knows the answer.
On a side note (and this is likely asking too much), even better for my situation is if I could apply different javascript based on if different custom fields are selected using a select drop-down with glz_custom_fields!
Last edited by aswihart (2009-12-18 09:41:55)
Offline
Re: Different names for fields in Write tab per section?
Simple example how it basically works. Doesn’t require than just two lines of Javascript. Code is not tested and probably doesn’t work at all.
$(document).ready(function(){
var section = $("#section option[selected='selected']").val('value');
/*
Do not remember if this works (jQuery):
var section = $('#section option:selected').val('value');
Or (jQuery):
var section = $("#section option[selected='selected']").val('value');
With basic js:
var elm = document.getElementById('section');
var section = elm.options[elm.selectedIndex].value;
*/
switch(section) {
/*
Cases are sections,
'somes' are the content inside label
*/
case 'section1':
$("label[for='body']").html('some');
$("label[for='excerpt']").html('some');
break;
case 'section2':
$("label[for='body']").html('some2');
$("label[for='excerpt']").html('some2');
break;
/*
And so on...
*/
}
});
Last edited by Gocom (2009-12-18 09:54:40)
Offline
Re: Different names for fields in Write tab per section?
Sweet Gocom, I will play around with that and see what I can do. Unfortunately, I am completely clueless when it comes to anything but html and CSS, but I might just figure it out with your helpful code comments.
I guess the same logic could be applied to glz_custom_fields select drop-downs? Ideally, this is how I would like it, because I really don’t need or want to be using another section just to change the context of these couple fields.
Last edited by aswihart (2009-12-18 10:02:47)
Offline