Textpattern CMS support forum

You are not logged in. Register | Login | Help

#261 2015-11-22 19:54:35

etc
Developer
Registered: 2010-11-11
Posts: 3,170
Website

Re: etc_query: all things Textpattern

lazlo wrote #296749:

The code below brings back this error…

That’s normal, you need single quotes for tags in tags. Please try

<!-- alpha list display A-Z-->
<txp:variable name="currentcategory" value='<txp:category />' />
<txp:variable name="currentcategory" />

<txp:etc_query wraptag="ul" class="pull-right breadcrumb" break="li" name="alphalist"
	data='SELECT DISTINCT UPPER(SUBSTRING(Title,1,1)) AS alpha FROM textpattern WHERE Status = 4 AND Section = ''books'' AND Category2 LIKE ''<txp:variable name="current category" />%'' ORDER BY alpha'
>
	<a href="<txp:site_url /><txp:section />/<txp:variable name="currentcategory" />/?alpha={alpha?}">{alpha?}</a>
</txp:etc_query>

<!-- output alphalist and get articles ids when necessary -->
<txp:etc_query globals="_GET" data='<txp:variable name="alphalist" />'
	query="//a[text() = '{?alpha|A}']"
	replace="&=<span class='active'>{?alpha|A}</span>"
>
	{//ul}
	<txp:etc_query name="ids" break="," globals="_GET"
		data='SELECT ID FROM textpattern WHERE UPPER(SUBSTRING(Title,1,1)) = ''{?alpha|A}'' AND Status = 4 AND Section = ''books'' AND Category2 LIKE ''<txp:variable name="currentcategory" />%'' ORDER BY Title' />
<txp:else />
	<txp:variable name="alphalist" />
</txp:etc_query>

etc_[ query | search | pagination | date | tree | cache ]

Offline

#262 2015-11-22 20:06:56

lazlo
Member
Registered: 2004-02-24
Posts: 102

Re: etc_query: all things Textpattern

That code brings back the same error.

textpattern/publish.php:551 trigger_error()
index.php:83 textpattern()

Last edited by lazlo (2015-11-22 20:07:19)

Offline

#263 2015-11-22 20:23:37

etc
Developer
Registered: 2010-11-11
Posts: 3,170
Website

Re: etc_query: all things Textpattern

Weird, it’s working for me… could it come from somewhere else? What if you comment out this code, wrapping it in <txp:hide>...</txp:hide>?


etc_[ query | search | pagination | date | tree | cache ]

Offline

#264 2015-11-22 20:26:12

lazlo
Member
Registered: 2004-02-24
Posts: 102

Re: etc_query: all things Textpattern

Excluding other code.

This works:

<txp:etc_query wraptag="ul" class="pull-right breadcrumb" break="li" name="alphalist"
	data="SELECT DISTINCT UPPER(SUBSTRING(Title,1,1)) AS alpha FROM textpattern WHERE Status = 4 AND Section = 'books' AND Category2 LIKE 'drama' ORDER BY alpha"
>

This doesn’t:

<txp:etc_query wraptag="ul" class="pull-right breadcrumb" break="li" name="alphalist"
	data="SELECT DISTINCT UPPER(SUBSTRING(Title,1,1)) AS alpha FROM textpattern WHERE Status = 4 AND Section = 'books' AND Category2 LIKE ''<txp:variable name="current category" />%'' ORDER BY alpha"
>

Is there a working example of a variable txp or any other type that I can pass through with etc_query?

Offline

#265 2015-11-22 20:30:07

lazlo
Member
Registered: 2004-02-24
Posts: 102

Re: etc_query: all things Textpattern

etc wrote #296754:

Weird, it’s working for me… could it come from somewhere else? What if you comment out this code, wrapping it in <txp:hide>...</txp:hide>?

Hold on. It may be coming from somewhere else just a sec.

Offline

#266 2015-11-22 20:31:10

etc
Developer
Registered: 2010-11-11
Posts: 3,170
Website

Re: etc_query: all things Textpattern

This (and delete the space in “current category”)?

<txp:etc_query wraptag="ul" class="pull-right breadcrumb" break="li" name="alphalist"
	data='SELECT DISTINCT UPPER(SUBSTRING(Title,1,1)) AS alpha FROM textpattern WHERE Status = 4 AND Section = "books" AND Category2 LIKE ''<txp:variable name="currentcategory" />%'' ORDER BY alpha'
>

Edit: you can also replace <txp:variable name="currentcategory" /> with {?currentcategory} here:

<txp:etc_query wraptag="ul" class="pull-right breadcrumb" break="li" name="alphalist"
	data="SELECT DISTINCT UPPER(SUBSTRING(Title,1,1)) AS alpha FROM textpattern WHERE Status = 4 AND Section = 'books' AND Category2 LIKE '{?currentcategory}%' ORDER BY alpha"
>

Last edited by etc (2015-11-22 20:34:28)


etc_[ query | search | pagination | date | tree | cache ]

Offline

#267 2015-11-22 20:46:31

lazlo
Member
Registered: 2004-02-24
Posts: 102

Re: etc_query: all things Textpattern

etc wrote #296757:

This (and delete the space in “current category”)?

<txp:etc_query wraptag="ul" class="pull-right breadcrumb" break="li" name="alphalist"...

Edit: you can also replace <txp:variable name="currentcategory" /> with {?currentcategory} here:

<txp:etc_query wraptag="ul" class="pull-right breadcrumb" break="li" name="alphalist"...

Ok will try these and report back. Much thanks.

Offline

#268 2015-11-22 21:13:01

lazlo
Member
Registered: 2004-02-24
Posts: 102

Re: etc_query: all things Textpattern

Still no go on my side.
By just inserting this {?currentcategory}

	data="SELECT DISTINCT UPPER(SUBSTRING(Title,1,1)) AS alpha FROM textpattern WHERE Status = 4 AND Section = 'books' AND Category2 LIKE '{?currentcategory}%' ORDER BY alpha"

The resulting sql call is below and the variable is not parsed, is there another step to that type of variable?

<txp:etc_query wraptag="ul" class="pull-right breadcrumb" break="li" name="alphalist"
	data="SELECT DISTINCT UPPER(SUBSTRING(Title,1,1)) AS alpha FROM textpattern WHERE Status = 4 AND Section = 'books' AND Category2 LIKE '{?currentcategory}%' ORDER BY alpha"

And the other version below still fails silently will no sql call happening at all when I look at page source, and no error (as the error above was from somewhere else and has been fixed)

<txp:etc_query wraptag="ul" class="pull-right breadcrumb" break="li" name="alphalist"
	data='SELECT DISTINCT UPPER(SUBSTRING(Title,1,1)) AS alpha FROM textpattern WHERE Status = 4 AND Section = "books" AND Category2 LIKE ''<txp:variable name="currentcategory" />%'' ORDER BY alpha'
>

Last edited by lazlo (2015-11-22 21:14:56)

Offline

#269 2015-11-22 21:22:33

etc
Developer
Registered: 2010-11-11
Posts: 3,170
Website

Re: etc_query: all things Textpattern

ok, let’s see step by step:

<txp:variable name="currentcategory" value="drama" />

<txp:etc_query wraptag="ul" class="pull-right breadcrumb" break="li"
	data="SELECT DISTINCT UPPER(SUBSTRING(Title,1,1)) AS alpha FROM textpattern WHERE Status = 4 AND Section = 'books' AND Category2 LIKE '{?currentcategory}%' ORDER BY alpha" />

outputs for me a A-Z list of drama books, can you confirm?


etc_[ query | search | pagination | date | tree | cache ]

Offline

#270 2015-11-22 21:34:26

lazlo
Member
Registered: 2004-02-24
Posts: 102

Re: etc_query: all things Textpattern

etc wrote #296760:

outputs for me a A-Z list of drama books, can you confirm?

Nope it outputs all categories. But if I type replace ‘{?currentcategory}%’ with ‘drama’ it outputs just an A-Z list of drama books.

Offline

Board footer

Powered by FluxBB