Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#73 2015-06-28 23:32:40

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

Re: etc_search: when the default search is not enough

Hi Oleg

Your old code managed to work perfectly with rah_repeat I only had to change the search field. Thank you very much. I think I just created a too complex call in my mind and went back to the simpler one where I just listed the contributors other books without sorting them by role.

regards
Les Smith

This is the rah_repeat from code

<txp:if_custom_field name="contributors">

<txp:rah_repeat value='<txp:custom_field name="contributors" />' delimiter="~||~">

<txp:rah_repeat value='<txp:rah_repeat_value />' delimiter="~|~" assign="onix_code,contributor_role,contributor_full_name,contributor_full_name_reversed, contributor_name_before_key,contributor_key_name,contributor_country" />

<h1>Also by<br /><txp:variable name="contributor_full_name" /></h1>
<txp:etc_search_results id="3"  form="book_title" limit="40"
	query='<txp:variable name="contributor_full_name" />' />
</txp:rah_repeat>


</txp:rah_repeat>

And this is the search call.

{custom_59} AND Section='Books' AND ID != <txp:page_url type="id" /> ORDER BY custom_4 DESC

with these parameters

{"OR":";"}

Offline

#74 2015-07-02 21:05:30

etc
Developer
Registered: 2010-11-11
Posts: 4,911
Website GitHub

Re: etc_search: when the default search is not enough

Glad it works, but it’s pity to use a full-power plugin just to filter out the current article. If article_custom had exclude attribute, you could call it this way:

...
<txp:rah_repeat value='<txp:rah_repeat_value />' delimiter="~|~" assign="onix_code,contributor_role,contributor_full_name,contributor_full_name_reversed, contributor_name_before_key,contributor_key_name,contributor_country" />
	<h1>Also by<br /><txp:variable name="contributor_full_name" /></h1>
	<txp:article_custom exclude='<txp:article_id />'
 		section="books" form="book_title" limit="40"
		contributors='%<txp:variable name="contributor_full_name" />%' />
</txp:rah_repeat>
...

Other than that, the format you’ve chosen looks suboptimal: for each book by Some Author you have to input Author, Some and other repetitive information. It might be better to store it in a separate table (smd_user_info?)

Last edited by etc (2015-07-02 21:19:10)

Offline

#75 2015-07-15 08:58:24

etc
Developer
Registered: 2010-11-11
Posts: 4,911
Website GitHub

Re: etc_search: when the default search is not enough

etc wrote #292523:

If article_custom had exclude attribute, you could call it this way …

Yo, my first pull contribution was merged into textpattern-master branch. If it stays there, one will be able to use <txp:article_custom /> as enhanced <txp:related_articles /> tag:

<txp:article_custom exclude='<txp:article_id />'
	keywords='<txp:meta_keywords format="" />' />

Offline

#76 2015-07-15 19:33:45

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,476
Website

Re: etc_search: when the default search is not enough

etc wrote #293224:

<txp:article_custom exclude='<txp:article_id />'...

I like that at a lot. Just yesterday I was looking to grab all articles except those in a certain category… Could something like that work here without doing an article_custom as a tag in tag? In the end I went with an if_article_category construction in the article_custom’s output which works but is sub-optimal.


TXP Builders – finely-crafted code, design and txp

Offline

#77 2015-07-15 20:09:26

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,126
Website GitHub

Re: etc_search: when the default search is not enough

etc wrote #293224:

If it stays there

No plans to remove it. A great contribution, thank you. Very handy indeed.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#78 2015-07-16 11:41:19

etc
Developer
Registered: 2010-11-11
Posts: 4,911
Website GitHub

Re: etc_search: when the default search is not enough

jakob wrote #293273:

I was looking to grab all articles except those in a certain category… Could something like that work here without doing an article_custom as a tag in tag?

No, I’m afraid, the current way would be

<txp:article_custom exclude='<txp:article_custom category="certain-category" break=","><txp:article_id /></txp:article_custom>' />

which is not optimal too, but cleaner and will respect the eventual limit attribute.

It is not difficult to extend exclude to something like ID : 1,2,3 | category : certain-category | ..., but it looks bloated. More general possibility is to instruct the parser to recognize “is different” patterns, say att!="value", and let each tag to decide what it does with it. But it’s mucho tags code rewrite, if we want to be coherent.

Offline

#79 2015-07-16 12:06:23

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: etc_search: when the default search is not enough

jakob wrote #293273:

<txp:article_custom exclude='<txp:article_id />'...
I like that at a lot. Just yesterday I was looking to grab all articles except those in a certain category… Could something like that work here without doing an article_custom as a tag in tag?

You can use the plugin aks_article , which supports SQL syntax where=

<txp:aks_article where="category1<>'certain-category' and category2<>'certain-category'"/>

You can specify additional attribute hideself="1" – Are excluded from the list of current article.


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#80 2015-07-16 12:17:41

etc
Developer
Registered: 2010-11-11
Posts: 4,911
Website GitHub

Re: etc_search: when the default search is not enough

Hey, but you can use etc_search too, while we are here. :)

Offline

#81 2016-02-28 09:27:50

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

Re: etc_search: when the default search is not enough

Hey Oleg (or others)

Is there a simple way to hide a search result that has no return?
“Sorry, no results found matching your search request”

EDIT: The answer for above question from Oleg is added here.
ANSWER:

<txp:etc_search_results id="8" form="book_title_only" limit="1" query='<txp:article_url_title />'>
<txp:else />
<!-- no match -->
</txp:etc_search_results>

Also maybe not so simple:
I have a Tab that is called “News” the code searches for related News using etc_search.
I would like to hide the tab as well.

<div class="tab-v1">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#profiles" data-toggle="tab">Contributor Profiles</a></li>
                        <txp:hide><li><a href="#reviews" data-toggle="tab">Reviews</a></li></txp:hide>
                        <li><a href="#news" data-toggle="tab">Recent News</a></li>
                        <li><a href="#events" data-toggle="tab">Upcoming Events</a></li>
                    </ul><!--=== End Tab Headers ===-->

further down is

<div class="class="col-md-12""><!--=== Interior Content ===-->
<txp:etc_search_results id="4" query='<txp:title/>' form="newslistExcerpt" />
</div><!--=== End Interior Content ===-->

Last edited by lazlo (2016-04-22 18:48:02)

Offline

#82 2016-02-28 16:35:34

etc
Developer
Registered: 2010-11-11
Posts: 4,911
Website GitHub

Re: etc_search: when the default search is not enough

lazlo wrote #298046:

Hey Oleg (or others)

Is there a simple way to hide a search result that has no return?
“Sorry, no results found matching your search request”

Hi Leslie,

if you mean the output of <txp:etc_search_results />, try to wrap it (and surrounding tags, if necessary) in <txp:if_search_results></txp:if_search_results>. For live search this is trickier, though.

Edit: Try rather this:

<txp:variable name="search_results" value='<txp:etc_search_results />' />
<txp:if_search_results>
... surrounding code ...
<txp:variable name="search_results" >/
... surrounding code ...
</txp:if_search_results>

Last edited by etc (2016-02-28 20:17:38)

Offline

#83 2016-04-21 20:30:58

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

Re: etc_search: when the default search is not enough

etc wrote #298052:

if you mean the output of <txp:etc_search_results />, try to wrap it (and surrounding tags, if necessary) in <txp:if_search_results></txp:if_search_results>. For live search this is trickier, though.

Edit: Try rather this:

I tried that code exactly I couldn’t get a result. I am not sure <txp:etc_search_results /> plays well with <txp:if_search_results>

I tried a version without the variable and couldn’t get <txp:if_search_results> to trigger but I could get <txp:if_search> to trigger.

<txp:etc_search_results />
<txp:if_search>
DISPLAYS TEXT
</txp:if_search>

but

<txp:etc_search_results />
<txp:if_search_results>
DISPLAYS NO TEXT
</txp:if_search_results>

They both should display text if there are search results but only <txp:if_search> does.

Offline

#84 2016-04-21 21:05:25

etc
Developer
Registered: 2010-11-11
Posts: 4,911
Website GitHub

Re: etc_search: when the default search is not enough

Sorry Les, can not reproduce. Are you sure the concerned <txp:etc_search_results /> is not preceded by <txp:article /> or other <txp:etc_search_results /> in this part?

Offline

Board footer

Powered by FluxBB