Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Getting txp:article to list n show articles in different div's
Hello,
I am kind of new to Textpattern, but have fallen in love with it for its simplicity.
I am now using it for my own website where I am building our portfolio page.
The tag for which I am using now, goes as follows:
CODE:
<div class=“hfeed”>
<txp:article listform=“portfolio_listing” form=“portfolio” limit=“6” />
</div>
Portfolio_listing form:
CODE:
<li>
<txp:permlink><txp:upm_article_image type=“thumbnail” limit=“1” /></txp:permlink>
<div class=“info”>
<h3><txp:title /></h3>
<txp:permlink>View</txp:permlink>
</div>
</li>
Portfolio form:
CODE:
<TABLE width=“980px”>
<TR>
<TD valign=“top” style=“padding-right:10px; width:300px;”>
<h3><txp:title /></h3><br />
<txp:body />
</TD>
<TD>
<txp:if_article_image>
<div id=“slider”>
<txp:upm_article_image />
</div>
<txp:else />
</txp:if_article_image>
</TD>
</TR>
</TABLE>
(The reason I am using table here is, some css was breaking the layout :(
I was forced to use tables.)
So in my case,
since the listing and article display is taking inside class hfeed, I’ve to use to use two different containers for listing articles and showing them.
Problem comes when I need to arrange the thumbnails of the list on the right side by leaving some left margin. This is particularly important need for the site’s design.
After weeks of brain storming and applying various possible solutions of CSS, what I’ve understood is, it’d make it very easy for me if I can get the article listing in a different container and the article in another.
txp:article_custom might be one the solutions but I dont know how as I am still a newbie in TXP.
What I need to achieve is, for example,
if my articles are listed in <div class=“portfolio_list”> then, the article should open in <div class=“portfolio”> while the portfolio_list div is not shown.
Can anyone help me just to get the list and the articles to show in different containers?
Offline
Re: Getting txp:article to list n show articles in different div's
I’m not sure if I followed all that correctly, but would this solve it for you?
<txp:if_article_list>
<!-- portfolio list view -->
<div class="portfolio_list">
<txp:article listform="portfolio_listing" limit="6" />
</div>
<txp:else />
<!-- portfolio profile view -->
<div class="portfolio">
<txp:article form="portfolio" />
</div>
</txp:if_article_list>
The above shows clearly the principle of using txp:if_article_list
to output different markup depending on whether you are in list view or not.
You could, however simplify things even further: because txp:article
senses the context you are in and uses the listform or form depending on the view, the only thing that really changes between list view and individual article view is the _list
bit in the div name. So you should also be able to do the following:
<div class="portfolio<txp:if_article_list>_list</txp:if_article_list>">
<txp:article listform="portfolio_listing" form="portfolio" limit="6" />
</div>
It’s much shorter but arguably not as readable.
PS: I’m sure if you persevere, you can do want you want to achieve without tables.
Last edited by jakob (2011-11-10 21:59:53)
TXP Builders – finely-crafted code, design and txp
Offline
Re: Getting txp:article to list n show articles in different div's
@jakob
Hey, thanks for the reply. Also thanks for simplifying things for me. :)
I was also thinking about the txp:if_individual_article trick. That should work as I need….
but
<div class="portfolio<txp:if_article_list>_list</txp:if_article_list>">
<txp:article listform="portfolio_listing" form="portfolio" limit="6" />
</div>
seems a real clever trick, that will definitely work for me I think. I’ll just have to change some css….
Thanks a ton….you really helped me a lot.
Offline