Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Default Category by Section
I use plugin rah_default_category to set a default category, but that sets a default category site wide (any section selected gets the same default category).
On a site with many sections and categories, a default category based on section would be most useful.
Is there a way?
Offline
Re: Default Category by Section
You can use Javascript for that (including jQuery),
find your favorite why to insert Javascript into TXP write-tab (after jQuery)
and then use this code, and change the sections names and your desired category name
for this code you must use names, not titles:
$(function(){
$('#section').change(function(){
var section = $(this).val(),
defaultCategory1;
// Creating a switch statement
switch(section){
case 'news': defaultCategory1 = 'your_category_name1'; break;
case 'blog': defaultCategory1 = 'your_category_name2'; break;
case 'videos': defaultCategory1 = 'your_category_name3'; break;
}
// Select the category from Category-1 and trigger a change event
if(defaultCategory1){
$('#category-1').val(defaultCategory1);
$('#category-1').change();
}
}).change();
});
Offline
Pages: 1