Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-03-20 01:19:39

carrotrope
Member
From: Edinburgh
Registered: 2007-03-16
Posts: 39

Separating category1/category2 with commas IF necessary

Hi all,

Though I have found a few articles in the forums regarding this idea (if an article is listed in one category, that category is listed alone; if the article belongs to two categories, both are shown with a comma between them) none of the solutions I have found worked or were extremely unclear to me.

What methods/plugins does everybody use to achieve this?

Thanks in advance,
Jez.

Offline

#2 2007-03-20 08:49:33

juanjonavarro
Plugin Author
From: Valencia, Spain
Registered: 2005-05-16
Posts: 485
Website

Re: Separating category1/category2 with commas IF necessary

I use a modified version of dak_categories_edited, but I can create a simple plugin to achieve this functionality (categories separated by “separator” if second exists).

Are you interested?

Last edited by juanjonavarro (2007-03-20 08:50:39)

Offline

#3 2007-03-20 09:25:11

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: Separating category1/category2 with commas IF necessary

I’m guessing that several hundred people would be :)

It’s one of the oldest feature request for the core in the book :)

Something that test if in current context Cat2 isn’t null, and output whatever in that case.

Last edited by Jeremie (2007-03-20 09:25:53)

Offline

#4 2007-03-20 11:38:27

juanjonavarro
Plugin Author
From: Valencia, Spain
Registered: 2005-05-16
Posts: 485
Website

Re: Separating category1/category2 with commas IF necessary

Ok, I’m preparing an information page. Meanwhile you can copy and paste the following plugin:

YTo5OntzOjQ6Im5hbWUiO3M6MTQ6ImpubV9jYXRlZ29yaWVzIjtzOjc6InZlcnNpb24iO3M6
MzoiMC4xIjtzOjY6ImF1dGhvciI7czoxNDoiSnVhbmpvIE5hdmFycm8iO3M6MTA6ImF1dGhv
cl91cmkiO3M6Mjk6Imh0dHA6Ly93d3cuanVhbmpvbmF2YXJyby5jb20vIjtzOjExOiJkZXNj
cmlwdGlvbiI7czo1NDoiRGlzcGxheSBhcnRpY2xlJ3MgY2F0ZWdvcmllcywgc2VwYXJhdGVk
IGJ5ICdzZXBhcmF0b3InIjtzOjQ6InR5cGUiO2k6MDtzOjQ6ImhlbHAiO3M6MTk0OiIKRGlz
cGxheSBhcnRpY2xlJ3MgY2F0ZWdvcmllcywgc2VwYXJhdGVkIGJ5ICdzZXBhcmF0b3InLgoK
QXR0cmlidXRlczoKCllvdSBjYW4gdXNlIHRoZSBzYW1lIGF0dHJpYnV0ZXMgYXMgdHhwOmNh
dGVnb3J5MSBhbmQgdHhwOmNhdGVnb3J5Mi4gWW91IGNhbiBhbHNvCnNldCB0aGUgc2VwYXJh
dG9yIGF0dHJidXRlIChkZWZhdWx0ICcsICcpCiI7czo0OiJjb2RlIjtzOjkzNzoiCmZ1bmN0
aW9uIGpubV9jYXRlZ29yaWVzKCRhdHRycykgewogICBleHRyYWN0KGxBdHRzKGFycmF5KAog
ICAgJ3RpdGxlJyAgICAgICAgPT4gMCwKICAgICdsaW5rJyAgICAgICAgID0+IDAsCiAgICAn
c2VjdGlvbicgICAgICA9PiAnJywKICAgICd0aGlzX3NlY3Rpb24nID0+IDAsCiAgICAnY2xh
c3MnICAgICAgICA9PiAnJywKICAgICd3cmFwdGFnJyAgICAgID0+ICcnLAogICAgJ3NlcGFy
YXRvcicgICAgPT4gJywgJwogICksJGF0dHJzKSk7CgogICRjYXQxPWNhdGVnb3J5MShhcnJh
eSgndGl0bGUnICAgICAgICA9PiAkdGl0bGUsCiAgICAgICAgICAgICAgICAgICAgICAgICds
aW5rJyAgICAgICAgID0+ICRsaW5rLAogICAgICAgICAgICAgICAgICAgICAgICAnc2VjdGlv
bicgICAgICA9PiAkc2VjdGlvbiwKICAgICAgICAgICAgICAgICAgICAgICAgJ3RoaXNfc2Vj
dGlvbicgPT4gJHRoaXNfc2VjdGlvbiwKICAgICAgICAgICAgICAgICAgICAgICAgJ2NsYXNz
JyAgICAgICAgPT4gJGNsYXNzLAogICAgICAgICAgICAgICAgICAgICAgICAnd3JhcHRhZycg
ICAgICA9PiAkd3JhcHRhZykpOwoKICAkY2F0Mj1jYXRlZ29yeTIoYXJyYXkoJ3RpdGxlJyAg
ICAgICAgPT4gJHRpdGxlLAogICAgICAgICAgICAgICAgICAgICAgICAnbGluaycgICAgICAg
ICA9PiAkbGluaywKICAgICAgICAgICAgICAgICAgICAgICAgJ3NlY3Rpb24nICAgICAgPT4g
JHNlY3Rpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICd0aGlzX3NlY3Rpb24nID0+ICR0
aGlzX3NlY3Rpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICdjbGFzcycgICAgICAgID0+
ICRjbGFzcywKICAgICAgICAgICAgICAgICAgICAgICAgJ3dyYXB0YWcnICAgICAgPT4gJHdy
YXB0YWcpKTsKCiAgcmV0dXJuICgkY2F0Mj09JycpID8gJGNhdDEgOiAkY2F0MS4kc2VwYXJh
dG9yLiRjYXQyOwp9CiI7czozOiJtZDUiO3M6MzI6IjQzNTM0MTg1MzU4NDIyNzZmZDMxZjRi
YzNmODI4ODUwIjt9

Use:

<txp:jnm_categories title="1" link="1"/>

You can also set the separator string.

Offline

#5 2007-03-20 13:31:46

carrotrope
Member
From: Edinburgh
Registered: 2007-03-16
Posts: 39

Re: Separating category1/category2 with commas IF necessary

Thanks so much juanjonavarro! That’s absolutely perfect – lightweight and does exactly what I need. Brilliant.

Offline

#6 2007-03-21 00:02:04

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Separating category1/category2 with commas IF necessary

Offline

#7 2007-03-22 17:43:05

juanjonavarro
Plugin Author
From: Valencia, Spain
Registered: 2005-05-16
Posts: 485
Website

Re: Separating category1/category2 with commas IF necessary

Ok. I created the plugin information page. Here it is

Offline

#8 2007-05-05 19:37:09

telstar
New Member
Registered: 2007-05-05
Posts: 5
Website

Re: Separating category1/category2 with commas IF necessary

Just came across jnm_categories, perfect little plugin. Thanks for creating and sharing!

Offline

Board footer

Powered by FluxBB