Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-12-15 15:56:57

HAC
Member
From: Vietnam
Registered: 2009-06-05
Posts: 33
Website

Can't get article_custom tag works...

Hi everybody,

playing around without success, so, i need your help.

i have a section named “mysection” and a category named “mycategory”!

i have some articles belong to mysection, some belong to mycategory, some belong to both!

in my page template, i want to show a list of random articles belongs to mysection and mycategory, so i use the code:

<txp:article_custom section="mysection" category="mycategory" sort="rand()" />

but it doesn’t work! wondering.. if i did something wrong?!

BUT if i remove the atrribute category, it did work…

<txp:article_custom section="mysection" sort="rand()" />

Wondering.. why?

Note: i’m using TXP 4.2.0

Last edited by HAC (2009-12-15 16:05:24)

Offline

#2 2009-12-15 16:05:01

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,549
Website GitHub Twitter

Re: Can't get article_custom tag works...

Hi

Your code tell txp to show only articles from both section mysection and category mycategory.

I dont know if a plugin like smd_query can help you achieve what you are looking for!

Cheers

Offline

#3 2009-12-15 16:06:59

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,250
Website GitHub Mastodon Twitter

Re: Can't get article_custom tag works...

Hi HAC what happens if you use the article_custom tag in this way?

<ul><txp:article_custom section="mysection" category="mycategory" sort="rand()">
<li><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom></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

#4 2009-12-15 16:14:01

HAC
Member
From: Vietnam
Registered: 2009-06-05
Posts: 33
Website

Re: Can't get article_custom tag works...

colak wrote:

Hi HAC what happens if you use the article_custom tag in this way?

<ul><txp:article_custom section="mysection" category="mycategory" sort="rand()">
<li><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom></ul>

still doesn’t work! it shows nothing except the <ul></ul>

i’ve checked my articles… i ensure that i have articles belong to both mysection and mycategory!?

Last edited by HAC (2009-12-15 16:14:28)

Offline

#5 2009-12-15 16:46:36

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,250
Website GitHub Mastodon Twitter

Re: Can't get article_custom tag works...

Can you post a tag trace?

Also are you sure that you are using section and category names NOT titles?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#6 2009-12-16 03:36:35

HAC
Member
From: Vietnam
Registered: 2009-06-05
Posts: 33
Website

Re: Can't get article_custom tag works...

<txp:output_form form="f_header" />
	[SQL (0.000250101089478): select Form from txp_form where name='f_header']
	[Form: f_header]
	<txp:site_url />
	<txp:site_url />
	<txp:site_url />
	<txp:site_url />
	<txp:site_url />
	<txp:site_url />
	<txp:site_url />
	<txp:page_title />
		[SQL (0.000181913375854): select title from txp_section where name='jokes']
<txp:if_individual_article>
	[<txp:if_individual_article>: false]
</txp:if_individual_article>
<txp:output_form form="f_top_nav" />
	[SQL (0.000218868255615): select Form from txp_form where name='f_top_nav']
	[Form: f_top_nav]
	<txp:site_url />
	<txp:site_url />
<txp:output_form form="f_mainmenu" />
	[SQL (0.000216007232666): select Form from txp_form where name='f_mainmenu']
	[Form: f_mainmenu]
	<txp:link_to_home>
	</txp:link_to_home>
	<txp:site_url />
	<txp:site_url />
	<txp:site_url />
	<txp:site_url />
	<txp:site_url />
	<txp:site_url />
<txp:if_individual_article>
	[<txp:if_individual_article>: false]
	<txp:if_category>
		[<txp:if_category>: false]
		<txp:article_custom section="jokes" category="linh-tinh" sort="rand()">
			[SQL (0.00507593154907): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and (Category1 IN ('linh-tinh') or Category2 IN ('linh-tinh')) and Section IN ('jokes') and custom_5 like 'linh-tinh'  order by rand() limit 0, 10]
		</txp:article_custom>
		<txp:article_custom form="test" section="jokes" sort="rand()" break="li" />
			[SQL (0.0180680751801): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section IN ('jokes') order by rand() limit 0, 10]
			[article 262]
			[SQL (0.000977993011475): select Form from txp_form where name='test']
			[Form: test]
			<txp:permlink>
				<txp:title />
			</txp:permlink>
			[article 167]
			[Form: test]
			<txp:permlink>
				<txp:title />
			</txp:permlink>
			[article 131]
			[Form: test]
			<txp:permlink>
				<txp:title />
			</txp:permlink>
			[article 226]
			[Form: test]
			<txp:permlink>
				<txp:title />
			</txp:permlink>
			[article 237]
			[Form: test]
			<txp:permlink>
				<txp:title />
			</txp:permlink>
			[article 169]
			[Form: test]
			<txp:permlink>
				<txp:title />
			</txp:permlink>
			[article 105]
			[Form: test]
			<txp:permlink>
				<txp:title />
			</txp:permlink>
			[article 163]
			[Form: test]
			<txp:permlink>
				<txp:title />
			</txp:permlink>
			[article 130]
			[Form: test]
			<txp:permlink>
				<txp:title />
			</txp:permlink>
			[article 244]
			[Form: test]
			<txp:permlink>
				<txp:title />
			</txp:permlink>
	</txp:if_category>
</txp:if_individual_article>
<txp:output_form form="f_block_topright" />
	[SQL (0.000441074371338): select Form from txp_form where name='f_block_topright']
	[Form: f_block_topright]
	<txp:article_custom id="19" />
		[SQL (0.000385046005249): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status >= 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and ID IN (19) order by Posted desc limit 0, 10]
<txp:output_form form="f_block_latestupdate" />
	[SQL (0.000209093093872): select Form from txp_form where name='f_block_latestupdate']
	[Form: f_block_latestupdate]
	<txp:recent_articles limit="20" label="" break="li" wraptag="ul" />
		[SQL (0.00382685661316): select *, id as thisid, unix_timestamp(Posted) as posted from textpattern where Status = 4   and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00')  order by Posted desc limit 0,20]
<txp:output_form form="f_block_articles_mostread" />
	[SQL (0.00038480758667): select Form from txp_form where name='f_block_articles_mostread']
	[Form: f_block_articles_mostread]
<txp:output_form form="f_block_statistics" />
	[SQL (0.000246047973633): select Form from txp_form where name='f_block_statistics']
	[Form: f_block_statistics]
<txp:output_form form="f_block_comments" />
	[SQL (0.000195980072021): select Form from txp_form where name='f_block_comments']
	[Form: f_block_comments]
	<txp:recent_comments limit="10" break="li" wraptag="ul" />
		[SQL (0.000402927398682): select d.name, d.email, d.web, d.message, d.discussid, unix_timestamp(d.Posted) as time, t.ID as thisid, unix_timestamp(t.Posted) as posted, t.Title as title, t.Section as section, t.url_title from txp_discuss as d inner join textpattern as t on d.parentid = t.ID where t.Status >= 4 and (now() <= t.Expires or t.Expires = '0000-00-00 00:00:00')  and d.visible = 1 order by d.posted desc limit 0,10]
<txp:output_form form="f_block_randomimage" />
	[SQL (0.00018310546875): select Form from txp_form where name='f_block_randomimage']
	[Form: f_block_randomimage]
<txp:output_form form="f_block_ebook" />
	[SQL (0.000266075134277): select Form from txp_form where name='f_block_ebook']
	[Form: f_block_ebook]
<txp:output_form form="f_footer" />
	[SQL (0.00021505355835): select Form from txp_form where name='f_footer']
	[Form: f_footer]
	<txp:site_url />
	<txp:site_url />
	<txp:site_url />
<txp:output_form form="googleanalytics" />
	[SQL (0.000204086303711): select Form from txp_form where name='googleanalytics']
	[Form: googleanalytics]
[ ~~~ secondpass ~~~ ]
 -->

mysection is jokes
mycategory is linh-tinh

i’m sure that i’m using names NOT titles!

ps: sorry for my trace.. it’s alot.. _

Last edited by HAC (2009-12-16 03:40:27)

Offline

#7 2009-12-16 03:52:27

HAC
Member
From: Vietnam
Registered: 2009-06-05
Posts: 33
Website

Re: Can't get article_custom tag works...

after review the trace code, i see there’s a strange! … WHY the query string has and custom_5 like 'linh-tinh' ?? is it the problem?

<txp:article_custom section="jokes" category="linh-tinh" sort="rand()">
			[SQL (0.00507593154907): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and (Category1 IN ('linh-tinh') or Category2 IN ('linh-tinh')) and Section IN ('jokes') and custom_5 like 'linh-tinh'  order by rand() limit 0, 10]
		</txp:article_custom>

Last edited by HAC (2009-12-16 03:52:53)

Offline

#8 2009-12-16 03:59:33

HAC
Member
From: Vietnam
Registered: 2009-06-05
Posts: 33
Website

Re: Can't get article_custom tag works...

OKKKKK…. thank you for all support! I solved it myself

the story is….

i named custom_5 field is Category

so when i use <txp:article_custom section="mysection" category="mycategory" sort="rand()" />

the TXP added to the SQL query string and custom_5 like 'linh-tinh'

in this case, it shows nothing! so never set name to custom field like system keyworks such as section, category and so on

am i right? _ cheers

Last edited by HAC (2009-12-16 04:00:44)

Offline

#9 2009-12-16 19:39:31

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

Re: Can't get article_custom tag works...

Have a look at the reserved names that should not be used for custom fields: Textbook :)

Offline

Board footer

Powered by FluxBB