Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-05-02 20:36:31

LFlo
New Member
Registered: 2013-05-02
Posts: 2

Help with <txp:variable/> inside <txp:article/> (Duplicated articles)

Hi I’m working with a variant of the “articles inside table” example found in the reference page for the tag <txp:variable/>. <txp:variable/> reference

I’m able to build this DIV structure for every two articles:

<div class="row-fluid">
          <div class="span6">
                    <!-- Article goes here -->
          </div>
          <div class="span6">
                    <!-- Article goes here -->
          </div>
</div>
<!-- rinse and repeat every two articles -->

The problem that I have is that TXP is publishing the articles twice!

This is the txp code:


<div class="container">
<txp:article limit="6">
<txp:if_variable name="contador">
   <txp:if_variable name="contador" value="1">
      <txp:variable name="contador" value="2" />
   </txp:if_variable>
   <txp:else />
   <txp:variable name="contador" value="1" />
</txp:if_variable>

<!-- -->
<txp:if_variable name="contador" value="2">
<div class="span6">
<h2><txp:title/></h2>
<txp:excerpt/>
<p class="bt"><txp:permlink>Read more</txp:permlink></p>
</div>

</div>
<txp:variable name="contador" value="1" />
</txp:if_variable>

<!-- -->
<txp:if_variable name="contador" value="1" />
<div class="row-fluid">
<div class="span6">
<h2><txp:title/></h2>
<txp:excerpt/>
<p class="bt"><txp:permlink>Read more</txp:permlink></p>
</div>

<txp:if_last_article>
</div>
</txp:if_last_article>
</txp:if_variable>
</txp:article>
</div>

I don’t now what’s wrong, any help will be appreciated!, I’m using TXP 4.5.4. Thanks!

Offline

#2 2013-05-02 21:02:31

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

Re: Help with <txp:variable/> inside <txp:article/> (Duplicated articles)

It’s not a <txp:variable> problem :)
It’s just because you have <txp:title> and <txp:excerpt> twice in <txp:article>.

Should be :

<txp:if_variable name="contador">
 <txp:else />
   <txp:variable name="contador" value="1" />
</txp:if_variable>
<!-- If you are sure that "contador" doesn't exist, juste write <txp:variable name="contador" value="1" /> to initialize -->

<div class="container">
  <txp:article limit="6">

    <txp:if_variable name="contador" value="1" />
      <div class="row-fluid">
    </txp:if_variable>

    <div class="span6">
      <h2><txp:title/></h2>
      <txp:excerpt/>
      <p class="bt"><txp:permlink>Read more</txp:permlink></p>
    </div>

    <txp:if_variable name="contador" value="2" />
      </div>  <!-- .row-fluid -->
      <txp:variable name="contador" value="1" />
    <txp:else />
      <txp:variable name="contador" value="2" />
    </txp:if_variable>

  </txp:article>

</div>  <!-- .container -->

You don’t need <txp:if_last_article>

Offline

#3 2013-05-02 22:02:49

LFlo
New Member
Registered: 2013-05-02
Posts: 2

Re: Help with <txp:variable/> inside <txp:article/> (Duplicated articles)

Thank you very much CeBe you saved me!

Now it works perfectly!

Offline

Board footer

Powered by FluxBB