Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-01-15 06:21:16

deronsizemore
Member
From: Kentucky
Registered: 2005-11-02
Posts: 324

Cannot seem to get excerpts to work after FAQ...

I tried to follow this link: http://textpattern.com/faq/24/how-do-i-show-only-an-excerpt-in-article-lists

I read all the methods and chose 1 as it looked the easiest to implement. What I’m trying to do is this: I want on each article on my homepage to show excerpts first with a “read more” link and “Leave a Comment” link at the bottom. This would show excerpts only when something is actually left in the “excerpts” box in the write tab. When nothing is wrote in the excerpts box i would just like the full article to show up with no “read more” link, only the “leave a comment” link.

I created a new article form as the FAQ said and called it “excerpt.” The code for this article form is:

<code>
<h4><txp:permlink><txp:title /></txp:permlink></h4>
<span class=“comment_time”><txp:comment_time /></span>
<br /><br />
<txp:excerpt />
<br /> <txp:comments_invite wraptag=“p” /> | <txp:permlink>Read More</txp:permlink>
<div align=“center”><img src=”<txp:site_url />images/1.gif” style=“height:1px;width:400px” class=“divider” alt=”“ />
</div>
<br />
</code>

And the code which is in my html for default page is : <code><txp:article form=“default” listform=“excerpt” /></code>

Works like a charm when I actually write and excerpt, but when no excerpt is left, it doesn’t show the article at all. :(

Last thing would be that I want to have the words “Read More” right next to “Leave a Comment…” not one above the other.

Thanks
Deron

Last

Last edited by deronsizemore (2006-01-15 06:32:10)

Offline

#2 2006-01-15 16:20:46

mstwntd
Member
From: Melbourne, Australia
Registered: 2004-12-25
Posts: 52

Re: Cannot seem to get excerpts to work after FAQ...

This is where the if_excerpt conditional tag comes in handy:

<txp:if_excerpt>
<txp:excerpt />
<txp:permlink>Read More...</txp:permlink> |
<txp:else />
<txp:body />
</txp:if_excerpt>
<txp:comments_invite />

Last edited by mstwntd (2006-01-15 16:27:42)

Offline

#3 2006-01-16 03:47:16

deronsizemore
Member
From: Kentucky
Registered: 2005-11-02
Posts: 324

Re: Cannot seem to get excerpts to work after FAQ...

Is that you Egor?? Didn’t know you used TXP.

Thanks for the help! I figured that an if conditional tag was called for, but wasn’t exactly sure how to use it. It worked fine, but after I used it, another small problem arose. When an excerpt is included it displays right, but when I don’t write an excerpt and just use the full article it displays incorrectly.

www.deronsizemore.com/images/preview1.gif (displays correctly)

www.deronsizemore.com/images/preview2.gif (displays incorrectly)

You can see on the incorrect one, that the “Leave a Comment…” line is up next to the article. I’d like there to be a space in between the article and the leave a comment link as there is in the preview1 where it displays correct.

This is the code I’m using to display the articles:

<code>
<h4><txp:permlink><txp:title /></txp:permlink></h4>
<span class=“comment_time”><txp:comment_time /></span>
<br />
<br />
<txp:if_excerpt>
<txp:excerpt />
<br />
<br />
<txp:permlink>Read More…</txp:permlink> |
<txp:else />
<txp:body />
</txp:if_excerpt>
<txp:comments_invite />
<br />
</div>
</code>

Last edited by deronsizemore (2006-01-16 03:49:51)

Offline

#4 2006-01-16 11:53:12

mstwntd
Member
From: Melbourne, Australia
Registered: 2004-12-25
Posts: 52

Re: Cannot seem to get excerpts to work after FAQ...

Hey Deron,

Yeah, I haven’t actually used it on anything live yet (although I can’t wait to!). Only really got into it a month ago.

Anyway, here:
...
<txp:if_excerpt>
<txp:excerpt />
<p><txp:permlink>Read More...</txp:permlink> | <txp:comments_invite /></p>
<txp:else />
<txp:body />
<txp:comments_invite wraptag="p" />
</txp:if_excerpt>
...

Basically, if an excerpt is present above, the Comment Invite and Read More Link display below wrapped in a <p>, and if there isn’t, just the Comment Invite shows up, again, wrapped in a <p> (see: wraptag="p"). Hopefully that will solve it.

Edit: If you want to give that Comment/Read More area a unique class:

<p class="classname"><txp:permlink>Read More...</txp:permlink> | <txp:comments_invite /></p>
<p class="classname"><txp:comments_invite /></p>

Last edited by mstwntd (2006-01-16 11:59:43)

Offline

#5 2006-01-16 15:40:58

deronsizemore
Member
From: Kentucky
Registered: 2005-11-02
Posts: 324

Re: Cannot seem to get excerpts to work after FAQ...

Worked like a charm Egor!

Yeah I’ve been using txp for about a month also, although it seems you’re lightyears ahead of me in learning it. :) Are there any special sites you’ve been visiting to to learn txp? I feel like I’m just now getting a handle on a lot of the basics, but even this little problem that I had here I couldn’t fix on my own after trying for about an hour, and it was easy…so I’ve got a ways to go. I think it’s just that I have a hard time sometimes visualizing the txp tags in html form.

Looks like I also need to start getting into the habit of using <code><p></code> tags also. Since I started with txp I’ve gone back to using <code><br /></code> tags as you can see from my code above, and it’s making the html in my site look sloppy.

Last edited by deronsizemore (2006-01-16 15:41:48)

Offline

#6 2006-01-16 16:37:17

mstwntd
Member
From: Melbourne, Australia
Registered: 2004-12-25
Posts: 52

Re: Cannot seem to get excerpts to work after FAQ...

> Yeah I’ve been using txp for about a month also, although it seems you’re lightyears ahead of me in learning it. :) Are there any special sites you’ve been visiting to to learn txp? I feel like I’m just now getting a handle on a lot of the basics, but even this little problem that I had here I couldn’t fix on my own after trying for about an hour, and it was easy…so I’ve got a ways to go. I think it’s just that I have a hard time sometimes visualizing the txp tags in html form.

Hey,

Oh, I don’t know about that. I’m still getting my head around it. For example, I sat there banging my head for the past two days trying to figure out how to give the “Category Archive” a unique look (as it uses the default page template), when all I needed was a simple <txp:if_category> conditional!

As for sites, I’ve found the Official FAQ and the TextBook Tag Reference somewhat helpful, but for the most part, it’s been trial-and-error. Oh, and this forum itself, of course!

Offline

#7 2006-01-17 01:27:15

deronsizemore
Member
From: Kentucky
Registered: 2005-11-02
Posts: 324

Re: Cannot seem to get excerpts to work after FAQ...

Ah, nice. It’s usually the easy things that take so long because you’re making them harder then they have to be. I do that frequently. As for Category Archive, I’ve not even looked into that yet. I’m thinking about including one for my site, but don’t know. I don’t plan on having a ton of updates or anything, but I guess if I started getting some freelance work or whatever it might be nice to categorize them. I’ll definitely need to read up on categories though if I’m going to add a section for that on say the right side of my two column site.

Do you like TextPattern better than Wordpress so far? I know you tried wordpress for you other site.

Offline

#8 2006-01-17 13:30:14

mstwntd
Member
From: Melbourne, Australia
Registered: 2004-12-25
Posts: 52

Re: Cannot seem to get excerpts to work after FAQ...

> Do you like TextPattern better than Wordpress so far? I know you tried wordpress for you other site.

Oh yeah, absolutely.

Offline

Board footer

Powered by FluxBB