Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#481 2007-08-27 02:55:50
Re: [plugin] [ORPHAN] rss_unlimited_categories - Unltd. Article Categories
So you are saying somewhere <txp:article /> is referenced and should be replaced with rss_uc_article_list? Or less rss_unlimited_categories_filedunder / rss_unlimited_categories_cloud will not return the right result?
If I am not asking too much, where exactly should I change this? I am less a week old with textpattern.Offline
#482 2007-08-27 03:24:03
Re: [plugin] [ORPHAN] rss_unlimited_categories - Unltd. Article Categories
I add
<txp:if_article_list>
<txp:rss_uc_article_list />
</txp:if_article_list>
<txp:if_individual_article>
<txp:article />
</txp:if_individual_article>
To my default page template. This solves the problem for me. Thanks
Offline
#483 2007-08-27 03:26:18
Re: [plugin] [ORPHAN] rss_unlimited_categories - Unltd. Article Categories
I actually had to add only
<txp:if_article_list>
<txp:rss_uc_article_list />
</txp:if_article_list>
Since there is already
<txp:if_individual_article>
…code…
</txp:if_individual_article>
Offline
#484 2007-08-30 20:06:00
Re: [plugin] [ORPHAN] rss_unlimited_categories - Unltd. Article Categories
swati.miniyar wrote:
if i am having categories like..a,b,c,d ..
after using this plugin i am getting result —-a(3),b(4),c(5),d(6)
where the no. in bracket is its article count..
but the article count is not correct…
category a is having 4 article..When i click on a(3)..its showing 4 article correctly
means..its showing correct listing..
I’m having this issue too on PImpMyCamino – the article counts are +1 what they really are. Anyone else come across this?
Cheers,
Jon VC#9
Offline
#485 2007-08-30 21:41:21
Re: [plugin] [ORPHAN] rss_unlimited_categories - Unltd. Article Categories
Ramen Angel wrote:
3. Original Bug. Yes, I guess I zoomed past your original complaint. Unsaved categories vanish because the plugin’s special multi-select box isn’t part of TXP. Just before viewing Preview or HTML, TXP grabs the values of all the fields and stores them. The values are restored when the page is redrawn after leaving Preview or HTML. Since TXP doesn’t know about the multi-select box, it isn’t stored & restored like the others. The select box is redrawn with saved categories from the database, and all unsaved selections are lost.
I’m pretty sure this can be remedied, but I’m not sure I’m the one to do it.
In my testing of Ramen’s patch, I have found that that the unsaved selections are in fact saved to the database when switching to the Preview or HTML tabs. I believe the first line in the original patch may have been the culprit:
if (!gps(‘save’) && !gps(‘publish’)) return;
With that line removed, I am no longer losing categories and when I switch tabs, the selected categories are automatically saved to the database.
Offline
#486 2007-09-04 07:08:12
- Ramen Angel
- New Member
- Registered: 2007-07-11
- Posts: 8
Re: [plugin] [ORPHAN] rss_unlimited_categories - Unltd. Article Categories
That looks like one way of getting it done, but saving the selected categories to the database during preview is not what I wanted. Apparently it works, but my opinion is that a save like that shouldn’t be made unless the user has pressed the Save button. It’s more like a general principle than anything specific.
One of the virtues of this kind of software is that we can chose our own way of solving some problems. I offer the following as another way of solving the problem of losing unsaved categories during preview. This does things the Texpattern way, by storing the selected categories in a hidden field when the preview starts, then restoring the selections on return to the text view.
Comment out the existing rss_admin_catlist()
and insert the following:
function rss_admin_catlist($event, $step) {
extract(gpsa(array('view','from_view','step')));
if (!$view) $view = "text";
// -- begin new code by rma 2007-09-03 --
// store selected categories in hidden field during preview/html
if ($view == 'preview' or $view == 'html') {
// if nav is text-to-preview or -html, get cats from multi-select box
if ($from_view == 'text') {
$cats_array = ps('Cats');
$cats_list = (!empty($cats_array)) ? implode(',', $cats_array) : '-1';
$cats_store = hInput('cats_store', $cats_list);
echo dom_attach('article-main', $cats_store);
}
// if nav is preview-to-html or vice versa, get cats from hidden field
if ($from_view == 'preview' or $from_view == 'html') {
$cats_list = ps('cats_store');
if (!empty($cats_list)) {
$cats_store = hInput('cats_store', $cats_list);
echo dom_attach('article-main', $cats_store);
}
}
}
// use stored categories if available (and applicable)
if ($view == 'text' and ($from_view == 'preview' or $from_view == 'html')) {
$cats_list = ps('cats_store');
if (!empty($cats_list)) {
$tmp = explode(',', $cats_list);
$rsc = array();
foreach ($tmp as $catid) {
$cat = array('category_id' => $catid);
$rsc[] = $cat;
}
}
}
// -- end new code --
if (empty($rsc)) { // rma 2007-09-03
$ID = rss_getID();
$rsc = array();
if ($ID) $rsc = safe_rows("category_id", "textpattern_category", "article_id=".$ID);
} // rma 2007-09-03
$rs = getTree("root", 'article');
$mtsi = "";
if ($rs) {
$mtsi = rss_multiTreeSelectInput('Cats',$rs,$rsc);
}
$catsel = ($view == 'text') ? graf(gTxt('categorize'). ' ['.eLink('category','','','',gTxt('edit')).']'.br.$mtsi) : '';
$js = <<<EOF
<script language="javascript" type="text/javascript">
<!--
var side = document.getElementById('write-sort');
var div = document.createElement('div');
div.innerHTML = '$catsel';
side.appendChild(div);
// -->
</script>
EOF;
echo $js;
}
Last edited by Ramen Angel (2007-09-04 07:26:17)
Offline
#487 2007-09-05 07:17:28
- Logoleptic
- Plugin Author
- From: Kansas, USA
- Registered: 2004-02-29
- Posts: 482
Re: [plugin] [ORPHAN] rss_unlimited_categories - Unltd. Article Categories
I’m having some trouble with the <txp:rss_if_article_unlimited_category>
tag. In plain English, here’s what I’d like my page template to do:
- Are we on the section front page? If so, then show the first sticky article; if not…
- Are we in the “foo” category? If so, then display the current article using the “foo_article” form; if not…
- Display the current article using the “single” form.
Instead of displaying the expected article, however, I get the very earliest article posted. It is displayed with the requested form, though.
I should probably mention that the navigation for this site is set up so that users will either be looking at a section or an individual article. Category list pages don’t come into play. I’m also using the stm_article_order plugin, which is why you’ll see me sorting by “position” in the next code block.
Here’s the relevant chunk of code:
<txp:glx_if_section_frontpage>
<txp:article form="single" status="sticky" sort="position asc" limit="1" />
<txp:else />
<txp:rss_if_article_unlimited_category name="asa-course-levels">
<txp:asy_wtag><txp:rss_uc_article_list id="<txp:article_id />" form="asa_course_standards" /></txp:asy_wtag>
<txp:else />
<txp:article form="single" />
</txp:rss_if_article_unlimited_category>
</txp:glx_if_section_frontpage>
And here’s the corresponding tag trace:
<txp:glx_if_section_frontpage>
[<txp:glx_if_section_frontpage>: false]
<txp:rss_if_article_unlimited_category name="asa-course-levels">
[SQL (0.003785): SELECT name as catname FROM textpattern_category as tc
LEFT JOIN txp_category as c ON tc.category_id = c.id
WHERE article_id=15]
[<txp:rss_if_article_unlimited_category name="asa-course-levels">: true]
<txp:asy_wtag>
<txp:article_id/>
<txp:rss_uc_article_list id="15" form="asa_course_standards" />
[SQL (0.001845): SELECT DISTINCT t.ID FROM textpattern as t
LEFT JOIN textpattern_category as tc ON t.ID = tc.article_id
LEFT JOIN txp_category as cat ON cat.id = tc.category_id
WHERE Status=4 and t.ID = '15' and Posted <= now()]
[SQL (0.002599): select *, unix_timestamp(Posted) as uPosted from textpattern where 1=1 and Posted <= now()]
[article 2]
[SQL (0.000466): select Form from txp_form where name='asa_course_standards']
[Form: asa_course_standards]
</txp:asy_wtag>
</txp:rss_if_article_unlimited_category>
</txp:glx_if_section_frontpage>
What stands out to me here is the second SQL query being run (I presume) by rss_uc_article_list
:
[SQL (0.002599): select *, unix_timestamp(Posted) as uPosted from textpattern where 1=1 and Posted <= now()]
What’s up with that? Is the result I’m getting a consequence of pushing the “magic” in asy_wondertag too far, or is this a bug in rss_unlimited_categories?
Update:
About fifteen minutes after posting this, I realized that I’d made things more complicated than necessary. This, of course, works just fine:
<txp:glx_if_section_frontpage>
<txp:article form="single" status="sticky" sort="position asc" limit="1" />
<txp:else />
<txp:rss_if_article_unlimited_category name="asa-course-levels">
<txp:article form="asa_course_standards" />
<txp:else />
<txp:article form="single" />
</txp:rss_if_article_unlimited_category>
</txp:glx_if_section_frontpage>
I mean, duh.
(Proceeds to write “I will not over-think my templates” 100 times on the blackboard.)
Last edited by Logoleptic (2007-09-06 21:24:14)
Offline
#488 2007-09-05 07:20:42
- Logoleptic
- Plugin Author
- From: Kansas, USA
- Registered: 2004-02-29
- Posts: 482
Re: [plugin] [ORPHAN] rss_unlimited_categories - Unltd. Article Categories
Ramen Angel wrote:
Comment out the existing rss_admin_catlist() and insert the following:
Wow, thanks for that. You’re really on top of this thing!
Does this new function also solve the problem of already-saved categories getting removed from the database during a preview?
Offline
#489 2007-09-17 07:10:59
- Ramen Angel
- New Member
- Registered: 2007-07-11
- Posts: 8
Re: [plugin] [ORPHAN] rss_unlimited_categories - Unltd. Article Categories
“Does this new function also solve the problem of already-saved categories getting removed from the database during a preview?”
Sorry, I missed this question the first time. If you mean, does this by itself solve the problem, no it doesn’t. You definitely need the new version of rss_admin_catlist_save()
that I posted earlier. That will solve the problem of silent deletion of saved categories during preview. This new replacement function deals with the lesser problem of selected categories getting unselected during preview.
Offline
#490 2007-09-18 16:34:37
- Logoleptic
- Plugin Author
- From: Kansas, USA
- Registered: 2004-02-29
- Posts: 482
Re: [plugin] [ORPHAN] rss_unlimited_categories - Unltd. Article Categories
Ramen Angel wrote:
You definitely need the new version of
rss_admin_catlist_save()
that I posted earlier. That will solve the problem of silent deletion of saved categories during preview.
Thanks for the clarification, RA. I recently had a chance to use your version of rss_admin_catlist_save()
on a client’s site, but found that it caused an odd new problem: though it prevented category deletion during preview, it also caused articles to lose their category selections the first time they were saved. They had to be saved twice in order for the categories to “stick.” Any idea what could be causing that?
Offline
#491 2007-09-19 06:23:31
- Ramen Angel
- New Member
- Registered: 2007-07-11
- Posts: 8
Re: [plugin] [ORPHAN] rss_unlimited_categories - Unltd. Article Categories
Yes, I’m pretty sure I know what’s wrong. Look for this line:
if (ps('ID') && ps('Cats')) {
Replace it with this:
if ($ID) {
This was caused by my earlier editing of the function. The long story short: ps('ID')
will fail on a newly published article, so use $ID
instead. ps('Cats')
isn’t necessary, and makes it impossible in certain situations to delete all the article’s categories.
Offline
#492 2007-09-19 20:31:31
Re: [plugin] [ORPHAN] rss_unlimited_categories - Unltd. Article Categories
I tried this and it seems to delete categories for existing articles as soon as they are viewed. Did you test this patch before posting it?
Offline