Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

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

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: 5,132
Website GitHub

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)

Offline

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

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

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: 110

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: 5,132
Website GitHub

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?

Offline

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

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

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

#271 2015-11-22 21:37:05

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

Re: etc_query: all things Textpattern

But a line listing of this shows that the value is drama.
<txp:variable name=“currentcategory” value=“drama” />
<txp:variable name=“currentcategory” />

Offline

#272 2015-11-22 21:43:04

etc
Developer
Registered: 2010-11-11
Posts: 5,132
Website GitHub

Re: etc_query: all things Textpattern

lazlo wrote #296761:

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

Very weird. Have you set globals="_GET" or something like that? Try with globals="variable", thought it should work by default.

Edit: and could it be that you use some pre 4.0.8 txp version?

Last edited by etc (2015-11-22 21:44:48)

Offline

#273 2015-11-22 21:47:27

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

Re: etc_query: all things Textpattern

Very weird. Have you set globals="_GET" or something like that? Try with globals="variable", thought it should work by default.

I am embarrassed to say I have now idea where to do that. Which means I don’t think I have ever used such a setting unless some plugin has set those.

Last edited by lazlo (2015-11-22 21:47:52)

Offline

#274 2015-11-22 21:49:17

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

Re: etc_query: all things Textpattern

No using the latest version.
Textpattern version: 4.5.7 (r5900)
PHP version: 5.6.10

Offline

#275 2015-11-22 21:51:43

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

Re: etc_query: all things Textpattern

Testing on MAMP Pro install on OS X if that might mean anything?

Offline

#276 2015-11-22 21:54:42

etc
Developer
Registered: 2010-11-11
Posts: 5,132
Website GitHub

Re: etc_query: all things Textpattern

It’s like here

<!-- output alphalist and get articles ids when necessary -->
<txp:etc_query globals="_GET" data='<txp:variable name="alphalist" />'
...

Well, what is the output of just this:

<txp:variable name="currentcategory" value="drama" />
<txp:etc_query data='{?currentcategory}' />

Offline

Board footer

Powered by FluxBB