Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#25 2014-01-04 03:57:42
- monicahu
- Member
- From: Sydney NSW
- Registered: 2009-03-07
- Posts: 69
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
colak wrote #277763:
Check out this txp tip which will solve the rss_supaarchive problem which is no longer supported. If you do not want to use consistent urls delete
section="default"
.
I’ve tried this tip before, but don’t know how to limit just the categories of the articles from certain sections only, ie no category be listed without articles and no category should be from other sections. At the same time, I’d like to retrieve the count of the articles of each category listed next to the category title (as shown in my previous post), and I don’t need to show them as nested, ie children categories are shown without their parents.
Following is the code snippet but I’m unable to remove the category title which bears no articles nor add an article count.
<ul id="menu">
<txp:category_list section="blog" children="1" break="li">
<txp:category title="1" />
<txp:article_custom category='<txp:category />' section="blog" break="li" wraptag="ul" limit="999">
<txp:permlink><txp:title /> :: <txp:author /> :: <txp:posted format="%d %b %Y" /></txp:permlink>
</txp:article_custom>
</txp:category_list>
</ul>
Last edited by monicahu (2014-01-04 04:55:58)
Monica
Life with God is the purpose.
Offline
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
You can pass your snippet through etc_query
:
<txp:variable name="menu">
<ul id="menu">
<txp:category_list section="blog" children="0" break="li">
<txp:category title="1" />
<txp:article_custom category='<txp:category />' section="blog" break="li" wraptag="ul" limit="999">
<txp:permlink><txp:title /> :: <txp:author /> :: <txp:posted format="%d %b %Y" /></txp:permlink>
</txp:article_custom>
</txp:category_list>
</ul>
</txp:variable>
<txp:etc_query data='<txp:variable name="menu" />'
replace="ul/li[count(ul)=0];ul/li/ul^= ({count(li)})" />
Offline
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
Or you could try it with native tags:)
<ul id="articles">
<txp:variable name="hasarticles" value='<txp:article_custom category=''<txp:category />'' limit="1" />' />
<txp:if_variable name="hasarticles" value="">
<txp:else />
<txp:category_list section='<txp:section />' break="li">
<txp:category title="1" />
<txp:article_custom category='<txp:category />' section='<txp:section />' break="li" wraptag="ul" limit="999">
<txp:permlink><txp:title /> :: <txp:author /> :: <txp:posted format="%d %b %Y" /></txp:permlink>
</txp:article_custom>
</txp:category_list>
</txp:if_variable>
</ul>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#28 2014-01-04 11:55:59
- monicahu
- Member
- From: Sydney NSW
- Registered: 2009-03-07
- Posts: 69
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
etc wrote #277777:
I guess it’s the same letter-case problem. If you can edit the plugin code, try to replace all occurrences of
...['excerpt']
by...['Excerpt']
or...['Excerpt_html']
on the line 426, though I wonder why the plugin worked before. If it does not help, here is how to create “Archive by dates” menu:
Hacking the codes is a bit scary and I couldn’t locate the ['excerpt']
in the plugin yet.
etc wrote #277781:
You can pass your snippet through
etc_query
:
colak wrote #277783:
Or you could try it with native tags:)
WOW, you two are very helpful. Thank you very much :). I shall try both.
Monica
Life with God is the purpose.
Offline
#29 2014-01-04 13:08:27
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
monicahu wrote #277784:
I couldn’t locate the
['excerpt']
in the plugin yet.
Also try different quotes: ["excerpt"]
.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
uli wrote #277785:
Also try different quotes:
["excerpt"]
.
Ah yes, thank you, Uli. But now that I have seen the code, I wouldn’t use rss_suparchive
without a minimal patching. It does about 300 unnecessary db queries on your archive page.
Offline
#31 2014-01-05 04:44:32
- monicahu
- Member
- From: Sydney NSW
- Registered: 2009-03-07
- Posts: 69
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
I’ve tried both methods from etc (Oleg) and colak (Yianni), but either getting tag errors or incorrect results (no article count and categories with nil articles being listed). I also tried the third method from TXP tips in an attempt to get the article count but having error when the count is zero.
The three methods are listed in below posts.
The results can be seen here
Last edited by monicahu (2014-01-05 04:55:28)
Monica
Life with God is the purpose.
Offline
#32 2014-01-05 04:48:55
- monicahu
- Member
- From: Sydney NSW
- Registered: 2009-03-07
- Posts: 69
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
Method 1 – etc using plugin etc_query
code snippet
<txp:variable name="menu">
<ul id="menu">
<txp:category_list section="blog" children="1" break="li">
<txp:category title="1" />
<txp:article_custom category='<txp:category />' section="blog" break="li" wraptag="ul" limit="999">
<txp:permlink><txp:title /> :: <txp:author /> :: <txp:posted format="%d %b %Y" /></txp:permlink>
</txp:article_custom>
</txp:category_list>
</ul>
</txp:variable>
<txp:etc_query data='<txp:variable name="menu" />'
replace="ul/li[count(ul)=0];ul/li/ul^= ({count(li)})" />
Outcome: No output and there are tag errors in debugging mode.
Tag error: <txp:etc_query data='<txp:variable name="menu" />'
replace="ul/li[count(ul)=0];ul/li/ul^= ({count(li)})" /> -> Warning: DOMDocument::saveHTML() expects exactly 0 parameters, 1 given while parsing form None on page test
textpattern/lib/txplib_misc.php(812) : eval()'d code:578 DOMDocument->saveHTML()
textpattern/lib/txplib_misc.php(812) : eval()'d code:312 etc_evaluate_string()
textpattern/lib/txplib_publish.php:426 etc_query()
textpattern/lib/txplib_publish.php:326 processTags()
textpattern/publish/taghandlers.php:3789 parse()
textpattern/lib/txplib_publish.php:426 if_section()
textpattern/lib/txplib_publish.php:339 processTags()
textpattern/publish.php:544 parse()
index.php:83 textpattern()
PHP version 5.2.17 (seen from the diagnostics in my first post of this topic, page 1)
Last edited by monicahu (2014-01-05 05:03:40)
Monica
Life with God is the purpose.
Offline
#33 2014-01-05 04:53:11
- monicahu
- Member
- From: Sydney NSW
- Registered: 2009-03-07
- Posts: 69
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
Method 2 – colak using native TXP tags
code snippet
<ul id="articles">
<txp:variable name="hasarticles" value='<txp:article_custom category=''<txp:category />'' status="live" section='blog' limit="1" />' />
<txp:if_variable name="hasarticles" value="">
<txp:else />
<txp:category_list section='blog' break="li">
<txp:category title="1" />
<txp:article_custom category='<txp:category />' section='blog' break="li" wraptag="ul" limit="999">
<txp:permlink><txp:title /> :: <txp:author /> :: <txp:posted format="%d %b %Y" /></txp:permlink>
</txp:article_custom>
</txp:category_list>
</txp:if_variable>
</ul>
Outcome: No article count (because there is no code to retrieve the count) and all categories are listed even when they don’t have articles in section called ‘blog’.
...
• Anglicans
• Apologetics
• Bible Study
• Children
• Of Ethics and Scripture :: Steven Layson :: 02 May 2010
• The Snow Queen :: Monica Hu :: 29 Oct 2009
• For Children - How to Pray :: Monica Hu :: 02 Sep 2009
...
Monica
Life with God is the purpose.
Offline
#34 2014-01-05 05:00:19
- monicahu
- Member
- From: Sydney NSW
- Registered: 2009-03-07
- Posts: 69
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
Method 3 – adopted from TXP Tips using PHP codes and native TXP tags
code snippet
<txp:hide>PHP code for retrieving the article counts of the category</txp:hide>
<txp:php>
global $cat_totals;
$rs2 = safe_rows_start('Category1, count(*) as num', 'textpattern', "Section='blog' group by Category1");
while ($a = nextRow($rs2)) {
$cat_totals[$a['Category1']] = $a['num'];
}
$rs2 = safe_rows_start('Category2, count(*) as num', 'textpattern', "Section='blog' group by Category2");
while ($a = nextRow($rs2)) {
$name = $a['Category2'];
$num = $a['num'];
if (isset($cat_totals[$name])) {
$cat_totals[$name] += $num;
} else {
$cat_totals[$name] = $num;
}
}
</txp:php>
<txp:category_list section='blog' wraptag="ul" break="" class="directory">
<li<txp:if_category name='<txp:category />'> class="active"</txp:if_category>>
<a href="<txp:site_url />test/?c=<txp:category />"><txp:category title="1" /> [<txp:php>global $cat_totals; echo $cat_totals[category(array())];</txp:php>]</a>
<txp:article_custom category='<txp:category />' section='blog' break="li" wraptag="ul" limit="999">
<txp:permlink><txp:title /> :: <txp:author /> :: <txp:posted format="%d %b %Y" /></txp:permlink>
</txp:article_custom>
</li>
</txp:category_list>
The output contains errors when there is no article for a listed category. In fact, I don’t want that category to be listed. I don’t know how to modify the PHP code to do the error check.
…
• Bible Study [
Tag error: <txp:php> -> Notice: Undefined index: bible_study while parsing form None on page test
textpattern/publish/taghandlers.php:3836 eval()
textpattern/lib/txplib_publish.php:426 php()
textpattern/lib/txplib_publish.php:339 processTags()
textpattern/publish/taghandlers.php:1209 parse()
textpattern/lib/txplib_publish.php:426 category_list()
textpattern/lib/txplib_publish.php:339 processTags()
textpattern/publish/taghandlers.php:3789 parse()
textpattern/lib/txplib_publish.php:426 if_section()
textpattern/lib/txplib_publish.php:339 processTags()
textpattern/publish.php:544 parse()
]
• Children [3]
• Of Ethics and Scripture :: Steven Layson :: 02 May 2010
• The Snow Queen :: Monica Hu :: 29 Oct 2009
• For Children - How to Pray :: Monica Hu :: 02 Sep 2009
Monica
Life with God is the purpose.
Offline
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
your code snippet in Method 2 is wrong. Try
<ul id="articles">
<txp:variable name="hasarticles" value='<txp:article_custom category=''<txp:category />'' status="live" section="blog" limit="1" />' />
<txp:if_variable name="hasarticles" value="">
<txp:else />
<txp:category_list section="blog" break="li">
<txp:category title="1" />
<txp:article_custom category='<txp:category />' section="blog" break="li" wraptag="ul" limit="999">
<txp:permlink><txp:title /> :: <txp:author /> :: <txp:posted format="%d %b %Y" /></txp:permlink>
</txp:article_custom>
</txp:category_list>
</txp:if_variable>
</ul>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
By the way… why did you change <txp:section />
to blog
?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline