Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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.
Morgan Aldridge
http://www.makkintosshu.com/
Offline
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.
Morgan Aldridge
http://www.makkintosshu.com/
Offline
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
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
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.
Morgan Aldridge
http://www.makkintosshu.com/
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
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
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
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
Re: category1 & category2 attributes for article_custom tag
I see. Makes sense. Eventually:
- Mantain cat1, cat2 + multicat?
- Use custom_fields instead of cat1 & cat2 and switch to multicat.
Rationale for having cat1 and 2 (and n, but 2 at least):
- 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.
- 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
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
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.
Offline