Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-04-16 08:32:14

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Categories choice linked to section choice - backend

Hi,
When I publish an article, Is it possible to have a restricted choice of categories linked to section choice?

Ex.:
section1 > choice between cat.1 & cat2
section2 > choice between cat.3 cat.4 & cat.5
etc.

Thanks for your answers!

Last edited by NicolasGraph (2010-04-16 08:56:19)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#2 2010-04-17 07:47:37

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Categories choice linked to section choice - backend

Anyone?

I know smd_tags can link tags to a category.
Is it possible to link categories to a section?


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#3 2010-04-17 08:33:34

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: Categories choice linked to section choice - backend

As far as I know, it’s not possible :(

Offline

#4 2010-04-17 08:37:02

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Categories choice linked to section choice - backend

Ok, thank you for your answer Pieman.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#5 2010-04-17 08:42:08

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Categories choice linked to section choice - backend

NicolasGraph wrote:

Is it possible to link categories to a section?

Pieman’s right. At least, not directly possible. You’ll need a plugin for that. The tricky thing about it is the dynamic/AJAXy nature of the plugin. Each time you alter the section on the Write tab, you would need to dynamically alter the list of categories that are available. And if you’d already chosen a category that was not in the current section it would have to be emptied. It’s not beyond doable — I’ve written little unofficial plugins before to limit the available sections/categories based on user role/name for example — but it’s non-trivial, mainly in terms of configuration overhead.

btw, TXP 4.3.0 will make it easier to write this kind of thing. Not by an immense amount (the configuration panel on the back-end will still be the same song ‘n’ dance), but it should make the scripting side simpler and more robust

Last edited by Bloke (2010-04-17 08:42:30)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#6 2010-04-17 08:50:11

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Categories choice linked to section choice - backend

Ok, I understand.
Thanks a lot !


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#7 2010-04-24 13:18:40

JimJoe
Member
From: United States
Registered: 2010-01-30
Posts: 573
Website

Re: Categories choice linked to section choice - backend

I think I understand the difficulty comes in when having multiple users editing. The script to display the sub-categories could hiccup if more than one person was editing.

But I’m the only person editing on my site.

here is my related question

Thanks.

Offline

#8 2010-04-25 07:33:19

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: Categories choice linked to section choice - backend

If you are using categories only in 2 sections,
and only one category needed to be chosen while writing an article for each section,
so it’s not a problem.

I did it in my newest site and you can see it in action here and here (user&pass: TBD)

So how?
1. I used both Category1 & Category2 and just changed they labels to ‘Category’ using jQuery:

$("label[for='category-1']").replaceWith('<label for="category-1">Category</label>');
$("label[for='category-2']").replaceWith('<label for="category-2">Category</label>');

2. I used jQuery again for deleting the categories I don’t want to be shown in each c1 & c2:

$("select#category-1 option[value='dj']").remove();
$("select#category-1 option[value='live']").remove();
$("select#category-2 option[value='cds']").remove();
$("select#category-2 option[value='digital']").remove();

3. Using bot_write_tab_customize plugin to hide the entire c1 in section ‘Releases’ and hide the entire c2 in section ‘Artists’.

That’s it!
Of caurse a real good way of doing it will be better.
I think that we can somehow use the ‘bot_wtc’ plugin code for hiding fields base on sections to do the same with categories.
(after all isn’t it the same principle?)

Last edited by THE BLUE DRAGON (2010-04-25 07:54:39)

Offline

#9 2010-04-25 12:30:41

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: Categories choice linked to section choice - backend

THE BLUE DRAGON wrote:

…(after all isn’t it the same principle?)

Yes, it is indeed. To demonstrate here is a short and raw plugin that should do what you want. Of course it has no interface and you must configure it directly in the plugins code.
If you want to try just install it, press ‘edit’ in the ‘plugin’ tab and modify the lines under ‘configuration’.

# Name: bot_cat_per_section_hide v0.1 
# Type: Admin side plugin
# 
# Author: 
# URL: 
# Recommended load order: 5

# .....................................................................
# This is a plugin for Textpattern - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# .....................................................................

YToxMTp7czo0OiJuYW1lIjtzOjI0OiJib3RfY2F0X3Blcl9zZWN0aW9uX2hpZGUiO3M6Njoi
YXV0aG9yIjtzOjA6IiI7czoxMDoiYXV0aG9yX3VyaSI7czowOiIiO3M6NzoidmVyc2lvbiI7
czozOiIwLjEiO3M6MTE6ImRlc2NyaXB0aW9uIjtzOjA6IiI7czo0OiJjb2RlIjtzOjE4NDA6
Ii8vPD9waHANCmlmKCBAdHhwaW50ZXJmYWNlID09PSAnYWRtaW4nICl7DQoJcmVnaXN0ZXJf
Y2FsbGJhY2soJ2JvdF9jYXRfcGVyX3NlY3Rpb25faGlkZScsJ2FydGljbGUnKTsNCn0NCg0K
Z2xvYmFsICRib3RfY2F0X3Blcl9zZWN0aW9uX2hpZGU7DQoNCiMjIyMjIyMjIyMjIyMjIyMj
IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMNCg0KLy8gQyBPIE4gRiBJIEcgVSBSIEEgVCBJIE8g
Tg0KLy8gVW5jb21tZW50IHRoZSBzYW1wbGUgbGluZXMgYmVsb3cgYW5kIGFkZCAgb25lIGZv
ciBldmVyeSBzZWN0aW9uLg0KDQovLyAkYm90X2NhdF9wZXJfc2VjdGlvbl9oaWRlWyJzZWN0
aW9uMSJdID0gImNhdGVnb3J5MSxjYXRlZ29yeTIiOw0KLy8gJGJvdF9jYXRfcGVyX3NlY3Rp
b25faGlkZVsic2VjdGlvbjIiXSA9ICJjYXRlZ29yeTMsY2F0ZWdvcnk0IjsNCg0KIyMjIyMj
IyM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12:33:45

JimJoe
Member
From: United States
Registered: 2010-01-30
Posts: 573
Website

Re: Categories choice linked to section choice - backend

Well, I have 2 sections.

One section is ‘about’ for my faq files. No categories under this section.

The other section is ‘articles’ where I put my categories. The upper level categories are: General, poems, Route 66, states, uncategorized, and webring. Under ‘States’ is a list of 50 state categories. Under each state category is a list of towns and cities categories that had/have drive-in movie theaters.

An example of the format under there is:

Sigh, still trying to figure out how to format text in the forums.

Here is how the categories under section article are set up:

show

Just scrolling down, when I started the move over was easy; however, since there were from 3000 to 5000 drive-ins in the US at one time… scrolling down that long of a list would be very time consuming. Texas had about 300 – 500 drive-in movie theaters, I presently have categories set up for 149 towns and cities in Texas.

So a means of having only the towns and cities show up in category 2 for the state I select in category 1 would be incredibly helpful.

Last edited by JimJoe (2010-04-25 12:58:23)

Offline

#11 2010-04-25 13:08:10

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: Categories choice linked to section choice - backend

redbot wrote:

bot_cat_per_section_hide v0.1

Yummy!
I will give it a try very soon :)
Thanks for another bot-treat!

@JimJoe So what you are asking for is to have category2 base on category1 (Chained selects)
just like here and here .

Last edited by THE BLUE DRAGON (2010-04-25 13:09:01)

Offline

#12 2010-04-25 13:15:03

JimJoe
Member
From: United States
Registered: 2010-01-30
Posts: 573
Website

Re: Categories choice linked to section choice - backend

Well, if that was available in the ‘write’ area so I could select a series of categories for each article, and the first category determined what was in list 2/category 2, yes, that would work.

Offline

Board footer

Powered by FluxBB