Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2009-01-26 20:59:58

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: display categories beloning to a section

What happens if you change this

<txp:if_section name='default','club'/>

into

<txp:if_section name=",club" />

Last edited by els (2009-01-26 21:01:11)

Offline

#14 2009-01-26 21:05:36

maartenD
Member
From: Warnsveld, The Netherlands
Registered: 2007-12-08
Posts: 47
Website

Re: display categories beloning to a section

Hi Els,

Changed the code, but still got the error message and everyting after the </txp:section> isn’t shown.


Kind regards,

Maarten

Offline

#15 2009-01-26 21:27:40

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: display categories beloning to a section

Can you post the tag trace of this page? (set Production status to debugging, the tag trace is in the source code, after the </html> tag)

Offline

#16 2009-01-26 21:51:28

maartenD
Member
From: Warnsveld, The Netherlands
Registered: 2007-12-08
Posts: 47
Website

Re: display categories beloning to a section

Below the tag trace of the “default” (front page) page

<!-- Runtime: 2.0055 --> <!-- Query time: 1.985574 --> <!-- Queries: 16 --> <!-- Memory: 2533Kb, <txp:category2/> --> <!-- txp tag trace: [SQL (0.141618013382): select name, data from bcztxp_lang as txp_lang where lang='en-gb' AND ( event='public' OR event='common')] [SQL (0.0564391613007): select name, code, version from bcztxp_plugin as txp_plugin where status = 1 AND type IN (0,1) order by load_order] [SQL (0.0702500343323): select page, css from bcztxp_section as txp_section where name = 'default' limit 1] [SQL (0.256281852722): select host from bcztxp_log as txp_log where ip='127.0.0.1' limit 1] [SQL (0.822416067123): insert into bcztxp_log set `time`=now(),page='/bczutphen/',ip='127.0.0.1',host='127.0.0.1',refer='',status='200',method='GET'] [SQL (0.168033838272): select user_html from bcztxp_page as txp_page where name='defaultbcz'] [Page: defaultbcz] <txp:output_form form="meta" /> [SQL (0.107048034668): select Form from bcztxp_form as txp_form where name='meta'] [Form: meta] <txp:css format="link" /> <txp:output_form form="header+nav" /> [SQL (0.00136399269104): select Form from bcztxp_form as txp_form where name='header+nav'] [Form: header+nav] <txp:section_list sections="Club,Uitslagen,Links,Bridgedrives,Downloads" include_default="1" default_title="Home" active_class="mainSelected" exclude="Artikelen" break="li" wraptag="ul" /> [SQL (0.000811100006104): select name, title from bcztxp_section as txp_section where name in ('Club','Uitslagen','Links','Bridgedrives','Downloads') order by field(name, 'Club','Uitslagen','Links','Bridgedrives','Downloads')] <txp:if_section name=",club"/> [<txp:if_section name=",club"/>: true] <txp:if_category name=''> [<txp:if_category name=''>: true] <txp:article_custom category='<txp:section/>' form="sticky" status="sticky" /> [attribute 'category'] <txp:section/> [/attribute] [SQL (0.146042108536): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from bcztextpattern as textpattern where 1=1 and Status = 5 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and (Category1 IN ('default') or Category2 IN ('default')) order by Posted desc limit 0, 10] </txp:if_category> <txp:else /> Tag error: <txp:else /> -> Textpattern Warning: tag does not exist on line 1104 <txp:article limit="5"/> [SQL (0.00116395950317): select name from bcztxp_section as txp_section where on_frontpage != '1'] [SQL (0.000980138778687): select count(*) from bcztextpattern as textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section != 'Club' and Section != 'Uitslagen' and Section != 'Links' and Section != 'Bridgedrives' and Section != 'Downloads'] [SQL (0.00224804878235): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from bcztextpattern as textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section != 'Club' and Section != 'Uitslagen' and Section != 'Links' and Section != 'Bridgedrives' and Section != 'Downloads' order by Posted desc limit 0, 5] [article 6] [SQL (0.0291340351105): select Form from bcztxp_form as txp_form where name='default'] [Form: default] <txp:title /> <txp:excerpt /> <txp:permlink class="permlink"> </txp:permlink> <txp:posted format="%H:%M:%S - " /> <txp:author /> [SQL (0.0712959766388): select RealName from bcztxp_users where `name` = 'admin' limit 1] <txp:category1/> <txp:category2/> [ ~~~ secondpass ~~~ ] -->

Below the tag trace of the page “Club” which is a section with categories (Club (parent) – Afmelden & competitierooster (children of Club):

<!-- Runtime: 0.0797 --> <!-- Query time: 0.046218 --> <!-- Queries: 17 --> <!-- Memory: 2536Kb, <txp:category2/> --> <!-- txp tag trace: [SQL (0.00728297233582): select name, data from bcztxp_lang as txp_lang where lang='en-gb' AND ( event='public' OR event='common')] [SQL (0.00190019607544): select name, code, version from bcztxp_plugin as txp_plugin where status = 1 AND type IN (0,1) order by load_order] [SQL (0.00166988372803): select name from bcztxp_section as txp_section where `name` like 'club' limit 1] [SQL (0.000510931015015): select page, css from bcztxp_section as txp_section where name = 'club' limit 1] [SQL (0.00211906433105): select host from bcztxp_log as txp_log where ip='127.0.0.1' limit 1] [SQL (0.00843691825867): insert into bcztxp_log set `time`=now(),page='/bczutphen/Club/',ip='127.0.0.1',host='127.0.0.1',refer='',status='200',method='GET'] [SQL (0.00220084190369): select user_html from bcztxp_page as txp_page where name='defaultbcz'] [Page: defaultbcz] <txp:output_form form="meta" /> [SQL (0.00176405906677): select Form from bcztxp_form as txp_form where name='meta'] [Form: meta] <txp:css format="link" /> <txp:output_form form="header+nav" /> [SQL (0.000481843948364): select Form from bcztxp_form as txp_form where name='header+nav'] [Form: header+nav] <txp:section_list sections="Club,Uitslagen,Links,Bridgedrives,Downloads" include_default="1" default_title="Home" active_class="mainSelected" exclude="Artikelen" break="li" wraptag="ul" /> [SQL (0.00086784362793): select name, title from bcztxp_section as txp_section where name in ('Club','Uitslagen','Links','Bridgedrives','Downloads') order by field(name, 'Club','Uitslagen','Links','Bridgedrives','Downloads')] <txp:if_section name=",club"/> [<txp:if_section name=",club"/>: true] <txp:if_category name=''> [<txp:if_category name=''>: true] <txp:article_custom category='<txp:section/>' form="sticky" status="sticky" /> [attribute 'category'] <txp:section/> [/attribute] [SQL (0.00335001945496): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from bcztextpattern as textpattern where 1=1 and Status = 5 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and (Category1 IN ('club') or Category2 IN ('club')) order by Posted desc limit 0, 10] [article 2] [SQL (0.000507116317749): select Form from bcztxp_form as txp_form where name='sticky'] [Form: sticky] <txp:body /> </txp:if_category> <txp:else /> Tag error: <txp:else /> -> Textpattern Warning: tag does not exist on line 1104 <txp:article limit="5"/> [SQL (0.000880002975464): select count(*) from bcztextpattern as textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section IN ('club')] [SQL (0.00137281417847): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from bcztextpattern as textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section IN ('club') order by Posted desc limit 0, 5] [article 5] [SQL (0.000459909439087): select Form from bcztxp_form as txp_form where name='default'] [Form: default] <txp:title /> <txp:excerpt /> <txp:permlink class="permlink"> </txp:permlink> <txp:posted format="%H:%M:%S - " /> <txp:author /> [SQL (0.0021538734436): select RealName from bcztxp_users where `name` = 'admin' limit 1] <txp:category1/> <txp:category2/> [article 3] [Form: default] <txp:title /> <txp:excerpt /> <txp:permlink class="permlink"> </txp:permlink> <txp:posted format="%H:%M:%S - " /> <txp:author /> <txp:category1/> <txp:category2/> [ ~~~ secondpass ~~~ ] -->


Kind regards,

Maarten

Offline

#17 2009-01-26 22:58:15

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: display categories beloning to a section

Next time you post a lot of code, would you mind using bc. or bc..? Just to make it a bit more readable :)

Two things I notice, though I fear that it’s not the cause of the problem, but clearing that up will at least exclude it as a possible cause.

  1. You are using section and category names with capitals. Don’t do that, it often causes problems. So you’ll have to change the section and category names as well in the section and category tabs as in your tag attributes.
  2. This tag <txp:if_section name=",club" /> is causing the article_custom tag on the front page to look for articles in category ‘default’, and I don’t think they exist. So you’d better take the comma out, and later (when we’ve solved this) you can add a separate conditional for the front page.

Otherwise, I just don’t see why the <txp:else /> is not accepted… Which TXP version are you using?

Offline

#18 2009-01-26 23:40:09

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,729
Website

Re: display categories beloning to a section

Els, hope I’m not digressing here, but is there something special about using name=""?

<txp:if_category name=""><!-- if we are not on a category page -->
	<txp:article_custom category='<txp:section />' />
<txp:else />
	<txp:article />
</txp:if_category>

Can you not turn it around as follows:

<txp:if_category>
	<!-- we ARE on a category page: show list of articles in this category -->
	<txp:article />
<txp:else />
	<!-- we ARE NOT on a category page: show list of articles belonging to the category with the same name as this section -->
	<txp:article_custom category='<txp:section />' />
</txp:if_category>

Is there a difference here in the way it behaves?

Don’t think it has anything to do with the problem, but in maartenD’s code above, it says <txp:if_category name=''>. It helps to be consistent with your quotes: generally-speaking you only need single quotes if the content within them is another tag that should be parsed (= I want the result of this tag to be used here). If it’s just normal content use double quotes as always.


TXP Builders – finely-crafted code, design and txp

Offline

#19 2009-01-27 00:02:47

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: display categories beloning to a section

jakob wrote:

Is there a difference here in the way it behaves?

No, I don’t think so. So it should be as good a solution as mine :) (A little bit less code, so even better.)

Don’t think it has anything to do with the problem, but in maartenD’s code above, it says <txp:if_category name=''>.

Ah, I overlooked that! Thanks for your eagle eyes. I’m not so sure that it won’t have anything to do with the problem, let’s hope that Maarten will tell us tomorrow that you solved it!

Offline

#20 2009-01-27 19:26:12

maartenD
Member
From: Warnsveld, The Netherlands
Registered: 2007-12-08
Posts: 47
Website

Re: display categories beloning to a section

Hi all,

Thanks for all the replies. Unfortunately i don’t have much time tonight to work on this problem. I will let you know later this week what progression i made with my issue.

I really appreciate all your help!!!


Kind regards,

Maarten

Offline

#21 2009-02-01 07:28:33

maartenD
Member
From: Warnsveld, The Netherlands
Registered: 2007-12-08
Posts: 47
Website

Re: display categories beloning to a section

Hi all,

Let’s start with the good news, PROBLEM SOLVED!!! The code Els and Jakob posted works fine. The only reason i can think about why it wasn’t working at first, is that i worked with an updated version of TXP (from 4.0.6 to 4.0.8). Yesterday a started from scratch with a clean install of TXP 4.0.8. and there it worked right away.

All, thx again for the great support.


Kind regards,

Maarten

Offline

Board footer

Powered by FluxBB