Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#31 2007-07-29 19:30:21

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 816
Website

Re: [plugin] [ORPHAN] chh_if_data

That doesn’t work either!

<div class="search">
<txp:rss_if_search_results>
<h4><txp:permlink><txp:title /></txp:permlink></h4>
<p><txp:search_result_excerpt /></p>
<txp:else />
<h4>Oops ... no results!</h4>
<p>Try another search ... :)</p>
</txp:rss_if_search_results>
</div>

Offline

#32 2007-07-29 20:00:10

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: [plugin] [ORPHAN] chh_if_data

Joop, this will achieve the same and it will work :)

On the page:

<txp:if_search>
<div class="search">
<txp:chh_if_data> (or <txp:rss_if_search_results>)
<txp:article form="search_results" />
<txp:else />
<h4>Oops ... no results!</h4>
<p>Try another search ... :)</p>
</txp:chh_if_data> (or </txp:rss_if_search_results>)
</div>
</txp:if_search>

Form ‘search_results’:

<h4><txp:permlink><txp:title /></txp:permlink></h4>
<p><txp:search_result_excerpt /></p>

Offline

#33 2007-07-31 12:09:10

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 816
Website

Re: [plugin] [ORPHAN] chh_if_data

Els, <txp:chh_if_data> is working. With <txp:rss_if_search_results> TXP is asking for an article tag … !? Thanks for help.

Offline

#34 2007-10-22 10:12:59

Minde
New Member
Registered: 2007-10-22
Posts: 1

Re: [plugin] [ORPHAN] chh_if_data

Brilliant plugin. Just what I’ve been looking for. Thanks!

Offline

#35 2007-12-27 21:05:54

obeewan
Archived Plugin Author
From: Stockholm, Sweden
Registered: 2004-08-12
Posts: 319
Website

Re: [plugin] [ORPHAN] chh_if_data

This plugin is one I wish I’d thought of. Brilliant, just brilliant. Two thumbs up and some toes aswell since it has saved me from alot of workarounds and hacks doing some TXP magic.

The multiple tag feature as mentioned earlier would make it sweeter. But it’s sweet allready.


Plugins: ob1_advanced_search 1.032b, ob1_search_score 1.0, ob1_pagination 2.5, ob1_title 4.1, ob1_modified 2.1

“Let your plans be dark and as impenetratable as night, and when you move, fall like a thunderbolt.”
— Sun Tzu

Offline

#36 2008-06-27 05:46:06

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: [plugin] [ORPHAN] chh_if_data

This plugin was exactly what I was looking for except it was failing because blank lines were being counted as “data”. I don’t know why blank lines are appearing, but in this particular situation they are simply whitespace on the web page.

I tweaked the chh_if_data code as follows:

Line 2, changed to:

$atts = lAtts(array('debug' => 0,'ignore' => 0), $atts);

Insert line:

if ($atts['ignore']) $parsed = trim($parsed);

before:

$parsed_len = strlen($parsed);

Now I can call chh_if_data with an extra attribute:

<txp:chh_if_data ignore="1">
<txp:article_custom ...... />
<txp:else />
<p>Nothing today</p>
</txp:chh_if_data>

Extraneous whitespace is now ignored and the “Nothing today” message is displayed when there’re no articles.

Offline

#37 2008-10-17 15:25:40

maxvoltar
Member
From: Machelen, Belgium
Registered: 2007-08-16
Posts: 76
Website

Re: [plugin] [ORPHAN] chh_if_data

Nevermind, I’m such an idiot… Great work!

Last edited by maxvoltar (2008-10-17 15:32:38)


Textpattern projects: Maxvoltar, Made by Elephant, Twunch

Offline

#38 2009-02-09 17:08:18

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: [plugin] [ORPHAN] chh_if_data

Similar to some earlier comments in this thread, I’d love to be able to use this around multiple txp tags, and specify which one to check for data. In my case, I only want to check the <txp:article /> tags. The plugin code looks so short and simple, but I don’t know where to begin to achieve something like that…can anyone help? Or is there another plugin that might serve this function?

Edit: Okay, simple except for this:

$f = '/<txp:(\S+)\b(.*)(?:(?<!br )(\/))?'.chr(62).'(?(3)|(.+)<\/txp:\1>)/sU';

Any experts care to break that down?

Last edited by nabrown78 (2009-02-09 17:12:10)

Offline

#39 2009-02-09 19:34:35

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: [plugin] [ORPHAN] chh_if_data

Have you tried to achieve what you want with the variable and if_variable tags?

Offline

#40 2009-02-14 15:41:01

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: [plugin] [ORPHAN] chh_if_data

Hmm…okay, I see that maybe I could output some piece of the article into a <txp:variable />, and then check for data in that variable…is that what you’re thinking? I’ll try it out.

Offline

#41 2009-02-14 19:11:37

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: [plugin] [ORPHAN] chh_if_data

nabrown78 wrote:

…is that what you’re thinking?

Yes. Similar to the code in this TXP Tip.

Offline

#42 2011-02-10 16:12:53

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [plugin] [ORPHAN] chh_if_data

It should work, what’s your code?


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#43 2011-02-10 16:16:06

gfdesign
Member
From: Argentina
Registered: 2009-04-20
Posts: 401

Re: [plugin] [ORPHAN] chh_if_data

Gracias Maniqui por responder tan rápido.
Tenía mal la sintaxis en mi código.
(Por eso borré mi mensaje, hasta que lo descubrí)
:P

Offline

#44 2011-02-14 19:45:51

gfdesign
Member
From: Argentina
Registered: 2009-04-20
Posts: 401

Re: [plugin] [ORPHAN] chh_if_data

Help again.
I´ve created this form but when I hide this article (or delete all text), whom calls to this form, the static texts display anyways.
Any idea?

<txp:chh_if_data>
<div class="module06">
<h2>SERVICES</h2>
<div class="contenido">
<txp:article_custom form="resume" pgonly="0" limit="1" section="services" sort="Posted asc" status="5" />
<div class="bt01"><a href="<txp:site_url />services">See all</a></div>
</div>
</div>
</txp:chh_if_data>

Thanks

Offline

#45 2011-02-14 19:56:01

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [plugin] [ORPHAN] chh_if_data

That’s because <txp:site_url /> will always return something (some ‘data’), so it will make chh_if_data to evaluate to true…
You could simple do:

<a href="/services">...

if your TXP site lives on the root of your domain.
Or:

<a href="/folder/services">...

If it lives in /folder/.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB