Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#256 2015-11-21 23:28:04

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

Re: etc_query: all things Textpattern

Right, sorry, try to nest duplicated single quotes:

<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'>
...

Offline

#257 2015-11-21 23:55:23

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

Re: etc_query: all things Textpattern

Unfortunately duplicate single quotes fail silently.

<txp:output_form form="alpha_list_display" />
				[SQL (0.000259876251221): select Form from txp_form where name='alpha_list_display']
				[Form: alpha_list_display]
				<txp:variable name="currentcategory" value='<txp:category />' />
					[attribute 'value']
					<txp:category />
					[/attribute]
				<txp:variable name="currentcategory" />
				<txp:variable name="ids" />
					[<txp:variable>: Unknown variable 'ids']
				<txp:variable name="currentcategory" />
[txp:etc_query SHOULD APPEAR HERE but NOTHING everything after this point is dumped]
				<txp:site_url />
				<txp:section />

Offline

#258 2015-11-22 02:01:58

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

Re: etc_query: all things Textpattern

Oleg

Even if we can’t solve the variable issue. I thought I would point out that this works
URL …textpattern455/books/drama/?alpha=E for me when hardcoded and beautifully if I might add.

I am not using a plugin to get there, unless it is an unintended consequence (I don’t think so) and I don’t think I am using a rewrite rule, see below. But to be frank I have been piecing/adding/improving this code together for years I forget how some parts happened. At one point I noticed that instead of coding for this “http://textpattern.site/section/?c=sitemaps” I could code for this “http://textpattern.site/section/sitemaps” and it passed the category through.

I had just thought it was a new feature.

In the same way this works on textpattern tip site:
http://textpattern.tips/category/tutorials = http://textpattern.tips/?c=tutorials
Probably only when your preference for permanent link mode is /section/title (maybe/maybe not/haven’t tried)

Here is my .htaccess

#DirectoryIndex index.php index.html

#Options +FollowSymLinks
#Options -Indexes
#ErrorDocument 403 default

<IfModule mod_rewrite.c>
	RewriteEngine On
	#RewriteBase /relative/web/path/

	RewriteCond %{REQUEST_FILENAME} -f [OR]
	RewriteCond %{REQUEST_FILENAME} -d
	RewriteRule ^(.+) - [PT,L]

	RewriteCond %{REQUEST_URI} !=/favicon.ico
	RewriteRule ^(.*) index.php

	RewriteCond %{HTTP:Authorization}  !^$
	RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

#php_value register_globals 0

# SVG
AddType image/svg+xml  svg svgz
AddEncoding gzip       svgz

Last edited by lazlo (2015-11-22 02:03:43)

Offline

#259 2015-11-22 10:39:13

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

Re: etc_query: all things Textpattern

lazlo wrote #296744:

URL …textpattern455/books/drama/?alpha=E for me when hardcoded and beautifully if I might add.

In the same way this works on textpattern tip site:
http://textpattern.tips/category/tutorials = http://textpattern.tips/?c=tutorials

It’s different: category has a special meaning (in English) for Textpattern, it’s not a section name. If you go to www.textpattern.tips/articles/?c=css, you will get all CSS tips from articles section. But www.textpattern.tips/articles/css will output all articles.

Back to variables, could you post the relevant code block? Looks like a syntax error somewhere.

Offline

#260 2015-11-22 17:59:56

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

Re: etc_query: all things Textpattern

The code below brings back this error:

textpattern/publish.php:551 trigger_error()
index.php:83 textpattern()
<!-- alpha list display A-Z-->
<txp:variable name="currentcategory" value='<txp:category />' />
<txp:variable name="currentcategory" />
<txp:variable name="ids" />

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

And the relevant mysql from page source above

Offline

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

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

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>

Offline

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

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

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

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>?

Offline

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

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

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: 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,680
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,680
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

Board footer

Powered by FluxBB