Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-01-22 20:54:54

morgant
Plugin Author
From: Vermont, United States
Registered: 2004-06-22
Posts: 63
Website

category1 & category2 attributes for article_custom tag

I recently ran into a problem where I coudn’t get a list of articles that had a specific category1 or category2 and was already using <txp:article_custom />. I looked at implementing a plug-in, but the problem was much more reasonably solved by adding category1 & category2 attribute support to doArticles() in textpattern/publish.php in 4.0.7.

This gives some extra functionality because you can basically do AND operations and/or OR operations with categories. I’d like to see my patch included in 4.0.8, if possible, because it seems like a useful addition to <txp:article_custom />. Example usage is as follows:

Category1 must contain “development” and Category2 must contain either “dev”, “textpattern”, or “patch”:

<txp:article_custom category1="development" category2="dev,textpattern,patch" />

The normal category attribute remains untouched.

I tried to join the txp-dev mailing list to submit the patch, but never received my confirmation, so I’ll submit here for now.

article_custom-category1_category2_addition-r3033.patch:

--- publish.php.original	2009-01-21 14:45:06.000000000 -0500
+++ publish.php	2009-01-21 14:44:41.000000000 -0500
@@ -567,6 +567,8 @@
 			'limit'     => 10,
 			'pageby'    => '',
 			'category'  => '',
+			'category1' => '',
+			'category2' => '',
 			'section'   => '',
 			'excerpted' => '',
 			'author'    => '',
@@ -667,6 +669,10 @@
 		$frontpage = ($frontpage and (!$q or $issticky)) ? filterFrontPage() : '';
 		$category  = join("','", doSlash(do_list($category)));
 		$category  = (!$category)  ? '' : " and (Category1 IN ('".$category."') or Category2 IN ('".$category."'))";
+		$category1 = join("','", doSlash(do_list($category1)));
+		$category1 = (!$category1) ? '' : " and (Category1 IN ('".$category1."'))";
+		$category2 = join("','", doSlash(do_list($category2)));
+		$category2 = (!$category2) ? '' : " and (Category2 IN ('".$category2."'))";
 		$section   = (!$section)   ? '' : " and Section IN ('".join("','", doSlash(do_list($section)))."')";
 		$excerpted = ($excerpted=='y')  ? " and Excerpt !=''" : '';
 		$author    = (!$author)    ? '' : " and AuthorID IN ('".join("','", doSlash(do_list($author)))."')";
@@ -713,7 +719,7 @@
 			$statusq = ' and Status = '.intval($status);

 		$where = "1=1" . $statusq. $time.
-			$search . $id . $category . $section . $excerpted . $month . $author . $keywords . $custom . $frontpage;
+			$search . $id . $category . $category1 . $category2 . $section . $excerpted . $month . $author . $keywords . $custom . $frontpage;

 		//do not paginate if we are on a custom list
 		if (!$iscustom and !$issticky)

Let me know if you find this useful and if you need me to submit it some other way.

Offline

#2 2009-01-22 21:00:38

morgant
Plugin Author
From: Vermont, United States
Registered: 2004-06-22
Posts: 63
Website

Re: category1 & category2 attributes for article_custom tag

Oops, it just took a full 15 mins for the txp-dev confirmation email to come through. I’ll submit there.

My sincerest apologies for the cross-post.

Offline

#3 2009-02-16 13:24:05

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: category1 & category2 attributes for article_custom tag

Thanks, GOOD patch!

Please, include this patch in next release.


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#4 2009-10-12 21:08:02

Zanza
Plugin Author
Registered: 2005-08-18
Posts: 699
Website

Re: category1 & category2 attributes for article_custom tag

Has this been included in some release or have been solved by a plugin? I’m running in a similar problem, and finding a simple way to list articles based on cat1 or cat2 (or a logic between the two). I suppose that with a bunch of smd_if i can make it, but I wonder if there is a more efficient way.

Offline

#5 2009-10-12 21:43:43

morgant
Plugin Author
From: Vermont, United States
Registered: 2004-06-22
Posts: 63
Website

Re: category1 & category2 attributes for article_custom tag

I did submit it to the txp-dev mailing list, but got no response on interest in it or whether it’d be included in a release.

Offline

#6 2009-10-12 23:54:07

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

Re: category1 & category2 attributes for article_custom tag

In the meanwhile I think smd_query could help

Offline

#7 2009-10-13 08:51:02

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

Re: category1 & category2 attributes for article_custom tag

morgant wrote:

I did submit it to the txp-dev mailing list, but got no response on interest in it or whether it’d be included in a release.

Sorry about that. By the time I joined, this thread had been buried and I missed it first time around. It’s a mighty handy mod. I’ll give it some thought based on where we think TXP is heading.

Many (belated) thanks for the patch submission.


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

#8 2009-10-13 10:46:39

Zanza
Plugin Author
Registered: 2005-08-18
Posts: 699
Website

Re: category1 & category2 attributes for article_custom tag

Bloke: nice to see the issue taken into account. I temporary made up a plugin using the Morgant code (thanks!) to avoid using patches. It is a feature that is very needed for my current project, and so I’m using a bos_article_custom tag. But hope to get rid of it as soon as possible! :) I’m not planning to release the plugin, unless someone is asking for it.

Offline

#9 2009-10-13 14:12:43

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: category1 & category2 attributes for article_custom tag

It’s a patch that makes it harder for TXP to switch to unlimited categories… if that is still a goal.

Offline

#10 2009-10-13 14:55:57

Zanza
Plugin Author
Registered: 2005-08-18
Posts: 699
Website

Re: category1 & category2 attributes for article_custom tag

I see. Makes sense. Eventually:

  1. Mantain cat1, cat2 + multicat?
  2. Use custom_fields instead of cat1 & cat2 and switch to multicat.

Rationale for having cat1 and 2 (and n, but 2 at least):

  1. they could be used with different meaning/scope. And combined in a sophisticated logic (all by cat1 value X, if not cat2 val Y). Not common, but sometimes needed.
  2. having some indipendent cat (2, 3 or a finite number) make easy to build facets: a cat can be used as a facets. If multicats is the only way to go, they would need a logic to filter inside.

Offline

#11 2009-10-13 15:03:50

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

Re: category1 & category2 attributes for article_custom tag

ruud wrote:

It’s a patch that makes it harder for TXP to switch to unlimited categories

… hence my coyness.


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

#12 2009-10-13 15:22:10

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: category1 & category2 attributes for article_custom tag

Maybe a new article tag in the future?
Like txp:article_custom_on_stereoids, inspired by some of the nifties smd_if and smd_query abilities, like “pairing” values on different attributes (like some kind of array), and “OR logic”.

Will try to come up with a good example (if exists!) of what i’m trying to suggest.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB