Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-06-16 02:42:41

claywso
Member
From: Durham, NC USA
Registered: 2004-12-20
Posts: 57
Website

Problem with if_variable - need some help!

Hey everyone. Staring at this for a few hours and can’t find anything. Feedback appreciated.

for some reason, the if_variable always returns as false, and shows the <h1> tag on the page with no list underneath (because it’s empty, so it should have been false!)

it’s reading the category2 thing corectly, and there are no files in that category, but it’s still coming across as false. don’t quite know what i’m missing.

<txp:variable name="file_downloads" value='<txp:file_download_list form="file-check" category='<txp:article form="article-category2" />-Other' />' />
<txp:if_variable name="file_downloads" value="">
<txp:else />
  <div class="newLineBorder"> </div>
  <div class="copyBlock">
      <h1 id="pageTitle">Additional Resources</h1>
      <div class="downloadList">
          <txp:file_download_list form="files-copy" category='<txp:article form="article-category2" />-Other' />
      </div>
  </div>
</txp:if_variable>

here are the forms

form=“file-check”

<txp:file_download_link><txp:file_download_name /></txp:file_download_link>

form=“article-catetory2”

<txp:category2 />

Offline

#2 2013-06-16 07:05:58

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

Re: Problem with if_variable - need some help!

Hi Clay,

linebreaks are usual suspects in these cases, check if you have none in file-check form. I would also put two single quotes ('') around <txp:article form="article-category2" />-Other, just in case.

Edit: additionally, replace the illegal <txp:article form="article-category2" /> with <txp:category2 />

<txp:variable name="file_downloads" value='<txp:file_download_list form="file-check" category=''<txp:category2 />-Other'' />' />

Last edited by etc (2013-06-16 08:05:56)

Offline

#3 2013-06-16 08:14:29

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

Re: Problem with if_variable - need some help!

Another suggestion: don’t call <txp:file_download_list /> twice:

<txp:variable name="file_downloads" value='<txp:file_download_list form="files-copy" category=''<txp:category2 />-Other'' />' />
<txp:if_variable name="file_downloads" value="">
<txp:else />
  <div class="newLineBorder"> </div>
  <div class="copyBlock">
      <h1 id="pageTitle">Additional Resources</h1>
      <div class="downloadList">
          <txp:variable name="file_downloads" />
      </div>
  </div>
</txp:if_variable>

Edit: wow, that was my 600th post, I got nu now! Embarrassing for posting on French forum. :)

Last edited by etc (2013-06-16 08:34:56)

Offline

#4 2013-06-16 08:19:04

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: Problem with if_variable - need some help!

1 – Make sure that file category really ends with -Other. I would say that it is rather -other (all lowercase)

2 – As etc says, use directly <txp:category2 />

3 – If it helps, you can use <txp:variable /> as a container :

<txp:variable name="file_downloads">
  <txp:file_download_list form="file-check" category='<txp:category2 />-other' />
</txp:variable>

Offline

#5 2013-06-16 14:12:07

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Problem with if_variable - need some help!

CeBe wrote:

<txp:variable name="file_downloads">
  <txp:file_download_list form="file-check" category='<txp:category2 />-other' />
</txp:variable>

I’ve learned a lesson too time-devouring to not remark it at first sight: That way var “file_downloads” were never empty, it would always contain two spaces and two returns.

Edit: Sorry, forgot to post the correct application of the container tag variant:

<txp:variable name="file_downloads"><txp:file_download_list form="file-check" category='<txp:category2 />-other' /></txp:variable>

Last edited by uli (2013-06-16 14:18:59)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#6 2013-06-16 15:53:39

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: Problem with if_variable - need some help!

uli a écrit:

I’ve learned a lesson too time-devouring to not remark it at first sight: That way var “file_downloads” were never empty, it would always contain two spaces and two returns.

Ah right, thank you ! I’ve already seen this a long, long time ago >.<

Last edited by CeBe (2013-06-16 15:54:04)

Offline

#7 2013-06-16 17:47:40

claywso
Member
From: Durham, NC USA
Registered: 2004-12-20
Posts: 57
Website

Re: Problem with if_variable - need some help!

Brilliant – thanks everyone, problem solved using the txp:variable as a container and keeping it all on one line.

Offline

Board footer

Powered by FluxBB