Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: etc_query: all things Textpattern
Version 0.88: enhanced special patterns with sanitizer functions (many thanks to Gocom for alerting me). Dropped preparse attribute.
Offline
Re: etc_query: all things Textpattern
Is there a way to do both numbered links and prev/next links in article_custom pagination? I’d like to use it for that, but thought I’d ask first.
Offline
Re: etc_query: all things Textpattern
maruchan wrote:
Is there a way to do both numbered links and prev/next links in article_custom pagination? I’d like to use it for that, but thought I’d ask first.
You mean prev/next page? With one query it is tricky (in the current version), since we have to display some nodes twice, with different attributes. But with two queries it is possible (takes less than 0.005 extra seconds).
Suppose the navigation is driven by some url variable, say pgc. We firstly create the pagination list and store it in some variable:
<txp:variable name="pgc_list">
<txp:etc_query
data='<txp:article_custom limit="999"><a href=''<txp:permlink />''><txp:title /></a></txp:article_custom>'
query="a[position() mod 10 = 1]"
>
<a href="?pgc={#row}">{#row}</a>
</txp:etc_query>
</txp:variable>
Then in the article form put
<txp:if_individual_article>
<txp:variable name="pgc_list" />
<txp:else />
<txp:etc_query
data='<txp:variable name="pgc_list" />'
query="a[{?pgc|1|intval}]"
globals="_GET"
replace="preceding-sibling::a[position()=1]=Previous;following-sibling::a[position()=1]=Next"
>
{preceding-sibling::a[position()=1]}
<txp:variable name="custom_list" />
{following-sibling::a[position()=1]}
</txp:etc_query>
</txp:if_individual_article>
The article form can be completed with current page articles, enhanced with first/last links, restricted to showing at most n page links, and so on Please feel free to experiment, I will be glad to help .
Offline
Re: etc_query: all things Textpattern
Version 0.89: some minor (but annoying) bugfixes, please update.
Offline
Re: etc_query: all things Textpattern
Thank you, I’m trying that code out now. I’m going to try to troubleshoot, but I’m getting this error. Any advice is appreciated.
Tag error: <txp:etc_query
data='<txp:variable name="pgc_list" />'
query="a[{?pgc|1|intval}]"
globals="_GET"
replace="preceding-sibling::a[position()=1]=Previous;following-sibling::a[position()=1]=Next"
> -> Warning: DOMDocument::saveHTML() expects exactly 0 parameters, 1 given on line 369
textpattern/lib/txplib_misc.php(653) : eval()'d code:369 DOMDocument->saveHTML()
textpattern/publish.php:1188 etc_query()
textpattern/publish.php:1113 processTags()
textpattern/publish/taghandlers.php:3219 parse()
textpattern/publish.php:1188 if_individual_article()
textpattern/publish.php:1113 processTags()
textpattern/lib/txplib_misc.php(653) : eval()'d code:42 parse()
textpattern/publish.php:1188 rah_output_section_form()
textpattern/publish.php:1100 processTags()
textpattern/lib/txplib_misc.php(653) : eval()'d code:18 parse()
Tag error: <txp:variable name="custom_list" /> -> Notice: Undefined index: custom_list on line 4465
textpattern/publish.php:1188 variable()
textpattern/publish.php:1100 processTags()
textpattern/lib/txplib_misc.php(653) : eval()'d code:380 parse()
textpattern/publish.php:1188 etc_query()
textpattern/publish.php:1113 processTags()
textpattern/publish/taghandlers.php:3219 parse()
textpattern/publish.php:1188 if_individual_article()
textpattern/publish.php:1113 processTags()
textpattern/lib/txplib_misc.php(653) : eval()'d code:42 parse()
textpattern/publish.php:1188 rah_output_section_form()
Offline
Re: etc_query: all things Textpattern
What is your os and php version? I had this error on wamp until v4.3.10.
Offline
Re: etc_query: all things Textpattern
Oh my, I have a typo in the example, sorry, this should be <txp:variable name="pgc_list" />, and not <txp:variable name="custom_list" />. But this alone would not cause the problem.
Last edited by etc (2012-05-26 20:42:11)
Offline
Re: etc_query: all things Textpattern
Thanks for checking. I thought I was running PHP 5.3.8 but it was 5.2.17. So I’ve sent support a request, because I know it’s available. For the pagination, what I’m looking for is:
[Prev] 1 2 _3_ 4 5 6 7 [Next] [View All]
So “Next” would take you to page 4 if you were on page 3…etc. But the number links still work.
Last edited by maruchan (2012-05-26 22:59:56)
Offline
Re: etc_query: all things Textpattern
Yes, that’s what this part
<txp:etc_query
data='<txp:variable name="pgc_list" />'
query="a[{?pgc|1|intval}]"
globals="_GET"
replace="preceding-sibling::a[position()=1]=[Prev];following-sibling::a[position()=1]=[Next];@@class=current"
>
{preceding-sibling::a[position()=1]}
<txp:variable name="pgc_list" />
{following-sibling::a[position()=1]}
<a href="???">[View All]</a>
</txp:etc_query>
will do, additionally setting the class of the current page to “current”. But that’s all it will do, you will still have to display the articles of the current page using the pgc value in some way (offset?), which depends on your context.
Offline
Re: etc_query: all things Textpattern
Thanks for your help. I was able to switch to PHP 5.3.8 so the error is gone.
I admit to being quite lost at this point though, probably because I don’t understand xpath syntax well enough.
you will still have to display the articles of the current page using the pgc value in some way (offset?), which depends on your context.
It seems that is the meat of the problem—I’m not sure how to do that. I think I will try the method described in the TXP tip for now.
Offline
Re: etc_query: all things Textpattern
This is quite easy to do if your url contains only one variable (?id or ?pgc). Define a variable for navigation, say “pgc_list”:
<txp:variable name="pgc_list">
<txp:etc_query
data='<txp:article_custom limit="999"><a href="#">#</a></txp:article_custom>'
query="a[position() mod 10 = 1]"
>
<a href="?pgc={#row}">{#row}</a>
</txp:etc_query>
</txp:variable>
Then put something like this in the page form:
<txp:if_individual_article>
<nav><txp:variable name="pgc_list" /></nav>
<txp:else />
<txp:etc_query
data='<txp:variable name="pgc_list" />'
globals="_GET"
query="a[{?pgc|1|intval}]"
replace="@@class=current"
>
<!-- current page articles -->
<txp:article_custom wraptag="div" offset="{?pgc|0|intval,-1,*10}" limit="10" />
<!-- navigation links, with prev/next -->
<nav>
{preceding-sibling::a[1]=[Prev]}
<txp:variable name="pgc_list" />
{following-sibling::a[1]=[Next]}
<a href="???">[View All]</a>
</nav>
</txp:etc_query>
</txp:if_individual_article>
Be sure to use v0.9 or above.
Last edited by etc (2012-05-30 21:28:18)
Offline
Re: etc_query: all things Textpattern
Now it is even easier to create the navigation list with etc_url:
<txp:variable name="pgc_list">
<txp:etc_query
data='<txp:article_custom limit="999"><a href="#">#</a></txp:article_custom>'
query="a[position() mod 10 = 1]"
>
<a href='<txp:etc_url query="pgc={#row}" />'>{#row}</a>
</txp:etc_query>
</txp:variable>
will preserve the url, just appending pgc=n to it.
Offline
Re: etc_query: all things Textpattern
Version 0.97 is out, certainly the last step towards 1.0. More robust parser, implying small syntax changes in function patterns ($[...]$ -> {$...}).
Offline
#29 2012-08-01 14:42:46
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
Re: etc_query: all things Textpattern
The following line of … umpteen posts was transferred over here from the adi_gps_topic as it had only to do with etc_query. Its essence is a new topic in the How-tos-and-Examples forum, “Front End Search: Filter Articles With Drop-Down and Multi-Select Menu”. You might want to skip all of the dialogue between etc and progre55 and read on here in the etc_query topic.
Uli
ORIGINAL POST FROM ADI_GPS TOPIC:
–––––––––––––––––––––––––––––––––––––
Hope someone can assist.
I have used the following as a guide and it worked perfectly. I customized it to fit my project and the url displays the specific data and the search results displayed properly. My problem is that I have been unsuccesful in adding a third drop down into the mix (and in fact I will have many more). I tried numerous combinations with no success – see one example below.
I am trying to give the end user the option of selecting Color and getting results; selecting Model and getting results; selecting Price and getting results and/or any Combination.
Below is the unsuccesful code I am using:
<txp:adi_gps name="Color" quiet="1" />
<txp:adi_gps name="Model" quiet="1" />
<txp:adi_gps name="Price" quiet="1" />
<txp:if_variable name="Price" value="">
<txp:if_variable name="Color" value="">
<txp:if_variable name="Model" value="">
<txp:article />
<txp:else />
<txp:article_custom Model='<txp:variable name="Model" />' />
</txp:if_variable>
<txp:else />
<txp:if_variable name="Model" value="">
<txp:article_custom Color='<txp:variable name="Color" />' />
<txp:else />
<txp:article_custom Model='<txp:variable name="Model" />' Color='<txp:variable name="Color" />' />
</txp:if_variable>
<txp:if_variable name="Model" value="">
<txp:article_custom Price='<txp:variable name="Price" />' />
<txp:else />
<txp:article_custom Model='<txp:variable name="Model" />' Color='<txp:variable name="Color" />' Price='<txp:variable name="Price" />'/>
</txp:if_variable>
</txp:if_variable>
</txp:if_variable>
Any guidance would be greatly appreciated.
progre55
Last edited by uli (2012-08-07 19:34:03)
Offline
Re: etc_query: all things Textpattern
I don’t know why it does not work, sorry (maybe upper/lowercase problem?), but I wouldn’t do so much code replication anyway. Once you have assigned variables with adi_gps, something like this should work:
<txp:etc_query globals="variable" data="{?Color,Model,Price}">
<txp:article_custom
{$?({?Model}|Model='<txp:variable name="Model" />'|)}
{$?({?Color}|Color='<txp:variable name="Color" />'|)}
{$?({?Price}|Price='<txp:variable name="Price" />'|)}
/>
<txp:else />
<txp:article />
</txp:etc_query>
Offline