Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2011-08-30 17:44:26
- milosevic
- Member
- From: Madrid, Spain
- Registered: 2005-09-19
- Posts: 390
rename custom fields labels per sections
Hello:
I own a site with quite different sections and kinds of contents. In order to use only de minimun number of custom fields i use the same custom field for differents issues per sections. For instance the same custom field stores a price for a kind of articles (a section) and in other section it is used for store other data such GPS coordinates.
Everythink ok but then publisers allways see “price” label for custom field 1, and they must remember that “price” really stores gps coordinates in the “places” section.
Is there a plugin for change the custom fields labels per section in the write tab? I cant find anything.
Thanks.
<txp:rocks/>
Offline
Re: rename custom fields labels per sections
i use the same custom field for differents issues per sections…
I don’t know about you, but if I don’t write down any special cases I have trouble fathoming out what I did even just 6 months later, especially if the tag does something different to what it says it does…
If you purchase glz_custom_fields (a one-off purchase), you can add as many custom fields as you need. With the help of bot_write_tab_customize you can also show/hide them depending on the section you are on. You have a cleaner write tab and cleaner code and the custom_field contains what it says.
Is there a plugin for change the custom fields labels per section in the write tab?
That said, you could probably achieve what you want with jQuery. You’ll need to write some custom jquery code for this that is called:
a) when the page loads, and
b) whenever the section select box is changed.
- detect the selected section
- find the custom field input field you want to change,
- replace its label text accordingly,
- repeat for each custom_field you wish to change.
To avoid having to cater for every “from”-situation (the label to change from will be different depending on the last section you were on), I would suggest you make jquery find the label next to the custom-x input (because custom-x doesn’t change even if the label does) and then change the text of the label. You can also use bot_write_tab_customize to include your jquery on the write tab.
Nevertheless, I would still strongly recommend the first approach.
TXP Builders – finely-crafted code, design and txp
Offline
#3 2011-08-30 19:21:53
- milosevic
- Member
- From: Madrid, Spain
- Registered: 2005-09-19
- Posts: 390
Re: rename custom fields labels per sections
Thanks Jakob:
I was trying to avoid the first aproach in order to have a better Data Base perform, because it will cause thousands of records with empty fields, but of course it is the cleaner and more reasonable approach.
So I will try the second option, i’m not a jquery expert but I think I will capable of try to do that stuff of script.
Thanks a lot!
Last edited by milosevic (2011-08-30 19:24:16)
<txp:rocks/>
Offline
Re: rename custom fields labels per sections
I think something like this would do it. bot_write_tab_customize is probably the easiest way to implement it.
<script type="text/javascript">
$(document).ready(function() {
$('#section').change(function() {
var custom_1 = $("label[for='custom-1']");
switch ($(this).text()){
case "places": //Section Name
custom_1.text("gps"); //Custom Field Label
break;
case "shop": //Section Name
custom_1.text("price"); //Custom Field Label
break;
default:
custom_1.text("default"); //Default Custom Field Label
}
});
});
</script>
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline