Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#37 2014-01-05 08:07:37
- 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 #277792:
your code snippet in Method 2 is wrong. Try
<code><ul id="articles">...
Reason for limiting the section to ‘blog’ is that only articles from section blog are being counted and displayed. Other categories may have articles in other sections which I don’t want to include because they may be sermons, weblinks, events etc. and are not considered as real “articles” to the site visitors.
Have replaced the codes for Method 2 but results remain the same – categories without articles in section blog still appear.
Monica
Life with God is the purpose.
Offline
#38 2014-01-05 08:33:35
- 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 4 – using plugin mdn_count plus my own logic
code snippet
<txp:variable name="article_count" />
<txp:category_list section='blog' wraptag="ul" break="" class="directory">
<txp:variable name="article_count"><txp:mdn_count section="blog" category='<txp:category />' /></txp:variable>
<txp:if_variable name="article_count" value="0">
<txp:else />
<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:variable name="article_count" />]</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:if_variable>
</txp:category_list>
The outcome is what I want to achieve. See results on this URL. Scroll to the bottom of the page to see the results.
Method 4 - using mdn_count
...
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
Christianity [3]
The Christian and Poverty :: Steven Layson :: 13 Mar 2011
Whatever the moments, think of God :: Monica Hu :: 02 Sep 2009
Welcome to Thessalonica! :: Steven Layson :: 09 Aug 2009
Connect09 [4]
Ideas for Connecting :: Steven Layson :: 23 Aug 2009
Connect09 - Take the Hallway Challenge! :: St Peters :: 26 Jul 2009
Uptight about evangelism :: Steven Layson :: 22 Feb 2009
Preparing for Connect 09 :: Steven Layson :: 16 Oct 2008
...
- However, I do wish to know how to get other methods work.
- I also want a side menu on the same page just showing the categories with the count. When visitors click any category then only that category and the articles are shown in the main content area on the same page. See the original webpage here. You need to scroll down and pass the error messages.
- Another way of not having the side menu will be using jquery to collapse and expand the categories, just like the FAQ on the textpattern.com. But then, I need to learn how to do this as I’m not a true blue software developer.
I setup the website myself in 2009. Our church is small and can’t afford to pay the professionals to do it. You guys have been very helpful. Very much appreciated your time.
Monica
Life with God is the purpose.
Offline
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
monicahu wrote #277789:
PHP version 5.2.17 (seen from the diagnostics in my first post of this topic, page 1)
I have overlooked it, sorry, etc_query
needs at least 5.3.8 to work. Any chance of upgrading? IMO, that would be the best option, since other methods require two db queries (count + retrieve) per category. You could also count articles with Javascript, but this is client-depending.
To hide articles in the side menu (with id="sidemenu"
, say), a quick and dirty way is CSS #sidemenu li ul{display:none}
rule.
Offline
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
Here is a js way to append counts and make article lists collapsible (no plugin needed, but will not work in 2% js-disabled browsers):
- transform your snippet (mind linebreaks) into
<txp:category_list section='blog' wraptag="ul" break="" class="directory">
<txp:variable name="article_list"><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:variable>
<txp:if_variable name="article_list" value=""><txp:else />
<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" /></a>
<txp:variable name="article_list" />
</li>
</txp:if_variable>
</txp:category_list>
- include (if not yet done)
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
in the<head>
of your page form. - include the following script somewhere at the end of your page form:
<script>
$(function () {
$("ul.directory>li>a").after(function(){
var count = $(this).parent().children("ul").children("li").length;
return (count ? " ["+count+"]" :"");
}).click(function(){
$(this).parent().children("ul").toggle();return false;
}).click();
});
</script>
Offline
#41 2014-01-05 20:19:05
- 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 #277803:
Here is a js way to append counts and make article lists collapsible (no plugin needed, but will not work in 2% js-disabled browsers):
- transform your snippet (mind linebreaks) into
<code><txp:category_list section='blog' wraptag="ul" break="" class="directory">...
- include (if not yet done)
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
in the<head>
of your page form.- include the following script somewhere at the end of your page form:
<code><span class="pun"><</span><span class="pln">script</span><span class="pun">></span><span class="pln">...
Thank you Oleg, will try this today after finish work (holiday ends). Regarding jquery, shouldn’t the TXP 4.5.5 already include it in the library? This is from the release notes of 4.5.5:
Textpattern CMS 4.5.5 establishes compatibility with PHP 5.5, and updates the bundled jQuery library to version 1.8.3.
This is also found in the textpattern.com webpage. Is it the same as your suggested:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready( $(".none").click(function () { this.className = "onClick"; }));
</script>
Monica
Life with God is the purpose.
Offline
#42 2014-01-05 20:27:58
- 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 #277827:
Regarding jquery, shouldn’t the TXP 4.5.5 already include it in the library?
Yes, Textpattern comes bundled with jQuery, but no, you must include it (i.e. add etc’s code/path to jquery) in your page template in order to make his code work.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#43 2014-01-06 12:20:31
- 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 #277803:
Here is a js way to append counts and make article lists collapsible (no plugin needed, but will not work in 2% js-disabled browsers):
I followed your instructions and it works (Method 5). I also adapted your javascript and used it with Method 4 and it worked, too. See these on this url. Scroll down to the bottom to see Method 4 & Method 5 results.
THANK YOU very much for your time, Oleg!!
Monica
Life with God is the purpose.
Offline
#44 2014-01-06 12:21:56
- monicahu
- Member
- From: Sydney NSW
- Registered: 2009-03-07
- Posts: 69
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
uli wrote #277829:
Yes, Textpattern comes bundled with jQuery, but no, you must include it (i.e. add etc’s code/path to jquery) in your page template in order to make his code work.
Thanks Oli. So, when or how is this bundled jQuery being used on a TXP site?
Monica
Life with God is the purpose.
Offline
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
monicahu wrote #277836:
So, when or how is this bundled jQuery being used on a TXP site?
The version of jQuery bundled with Textpattern is for it’s own internal use within it’s admin control panel. You should not utilise that file in your public facing website – rather, you should add in your own copy of the jQuery file or link to one at a CDN (such as Google Hosted Libraries).
The reason for this is that it gives you, the site creator, full control over the version of jQuery your site will be using. For example if we update to a newer version of jQuery in a future Textpattern release that is not compatible with a certain script you have on your site, the site be broken. Also, we use an older version of jQuery for legacy (IE8) compatibility and you might want to use a newer release in your site.
Offline
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
monicahu wrote #277835:
I followed your instructions and it works (Method 5). I also adapted your javascript and used it with Method 4 and it worked, too. See these on this url. Scroll down to the bottom to see Method 4 & Method 5 results.
THANK YOU very much for your time, Oleg!!
You are welcome! In case you stay with Method 4, you can remove the .after(...)
part, it inserts nothing anyway.
Offline
#47 2014-01-07 09:56:27
- monicahu
- Member
- From: Sydney NSW
- Registered: 2009-03-07
- Posts: 69
Re: [solved] Site problem after upgrade from 4.2 to 4.5.5
philwareham wrote #277837:
The version of jQuery bundled with Textpattern is for it’s own internal use within it’s admin control panel. You should not utilise that file in your public facing website – rather, you should add in your own copy of the jQuery file or link to one at a CDN (such as Google Hosted Libraries).
The reason for this is that it gives you, the site creator, full control over the version of jQuery your site will be using. For example if we update to a newer version of jQuery in a future Textpattern release that is not compatible with a certain script you have on your site, the site be broken. Also, we use an older version of jQuery for legacy (IE8) compatibility and you might want to use a newer release in your site.
Thank you for the advice, it clears up my confusion.
etc wrote #277844:
You are welcome! In case you stay with Method 4, you can remove the
.after(...)
part, it inserts nothing anyway.
Thank you Oleg, that’s what I did on my test page for Method 4.
Monica
Life with God is the purpose.
Offline