Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-10-13 20:22:00
- deronsizemore
- Member
- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Changed a few things and now clicking catgories does nothing....
<a href=“http://www.kentuckygolfing.com”>Kentucky Golfing</a>
Els was helping me with some other aspects of my site earlier at <a href=“http://forum.textpattern.com/viewtopic.php?id=19061”>THIS THREAD</a> and I’ve got all that working now the way that I wanted it to but after making the suggested revisions, now when I click on a category link, it does nothing.
Example being, under the “Featured Article” area on the homepage, if you click on the “Filed In:” link of “courses”, it doesn’t take you anywhere. Where as before, if I clicked on the category name it would take me to a page with every article with the category “courses” or whatever the category happen to be.
Can someone tell me what I’ve done? Really the only thing that I changed was used article_custom instead of an article tag. The old article tag had a form and listform for the excerpts, now the article custom tag does not. I’m sure that’s the problem, but don’t know where or how to fix it.
Offline
Re: Changed a few things and now clicking catgories does nothing....
It’s because you’re using article_custom in your default template, which is what the category, homepage, and (out of the box) search results use. You want to use txp:article
for categories and searches, since they’re sensitive. Using the glx_if plugin, you could use:
<code>
<txp:glx_if_frontpage>
<txp:article_custom section=“courses” />
</txp:glx_if_frontpage>
<txp:if_category>
<txp:article />
</txp:if_category>
</code>
Offline
#3 2006-10-13 22:30:43
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Changed a few things and now clicking catgories does nothing....
Ah yes, I overlooked that part, sorry. You don’t need a plugin, on the front page:
<code>
<txp:if_category>
<txp:article /></code> (this is for the category page)
<code><txp:else />
<txp:article_custom /></code> (one ore more, for the front page)
<code></txp:if_category>
<txp:if_search>
<txp:article /></code> (for the search results)
<code></txp:if_search>
</code>
Offline
#4 2006-10-13 22:44:11
- deronsizemore
- Member
- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: Changed a few things and now clicking catgories does nothing....
Thanks again Els!
Seems easy enough, but when I started to dig into it, I get lost. Below is the html for the homepage template in the main content area. I’ve tried to incorporate what you gave me…but not sure if I’m doing it right?
<div id="maincontent">
<div id="featured_course">
<h1>Featured Course</h1>
<txp:if_category>
<txp:article />
<txp:else />
<txp:article_custom form="excerpt_featured_course" limit="1" section="featured-course" />
</txp:if_category>
<txp:if_search>
<txp:article />
</txp:if_search>
</div>
<div class="clear"></div>
<div id="featured_article">
<h1>Featured Article</h1>
<txp:if_category>
<txp:article />
<txp:else />
<txp:article_custom form="excerpt_featured_article" limit="1" section="article" />
</txp:if_category>
</div>
<div id="recent_articles">
<h3>Recent Articles</h3>
<txp:article_custom form="recent_posts" offset="2"/>
<p class="more_articles"><a href="#">View all Articles</a></p>
</div>
Offline
#5 2006-10-14 11:07:53
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Changed a few things and now clicking catgories does nothing....
I’m not sure how you want the category page to look, but here is my go at it.
<div id="maincontent">
<txp:if_category> <!-- this is for the category page -->
<div id="cat_list">
<h1>Articles in category <txp:category title="1" /></h1>
<txp:article form="?" listform="?" limit="?" />
<txp:else /> <!-- this is for the front page -->
<div id="featured_course">
<h1>Featured Course</h1>
<txp:article_custom form="excerpt_featured_course" limit="1" section="featured-course" />
</div>
<div class="clear"></div>
<div id="featured_article">
<h1>Featured Article</h1>
<txp:article_custom form="excerpt_featured_article" limit="1" section="article" />
</txp:if_category>
</div> <!-- closing either cat_list or featured_article -->
<txp:if_search> <!-- you can also leave this out and give the search it's own section and page template -->
<div id="search">
<h1>Search results</h1>
<txp:article />
</div>
</txp:if_search>
</div> <!-- closing maincontent -->
<div id="recent_articles">
<h3>Recent Articles</h3>
<txp:article_custom form="recent_posts" offset="2"/>
<p class="more_articles"><a href="#">View all Articles</a></p>
</div>
I may be overlooking other things now, but you could use this as a starting point. Let me know if it works the way you intended, and which parts need adjusting.
Offline
#6 2006-10-14 20:05:02
- deronsizemore
- Member
- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: Changed a few things and now clicking catgories does nothing....
That seems to work exactly the way that I wanted. I guess I just learn things weird. Like, I never would have been able to write all that out myself, but after seeing it and going through the code step by step I actually understand what’s going on! :-)
One thing I didn’t understand was the "</div> <!-- closing either cat_list or featured_article -->"
code you gave. That div was to close either cat_list or featured_article…why would it be “or”. I want to close both tags right? So I would close the cat_list and featured_article both, not one or the other.
Last thing I need to do is change the template used when a category is clicked. Right now if you click the category “courses” it takes you to the category list, but it using the hompage/default template. Is their an easy way to change that?
Thanks again for all your help.
Offline
#7 2006-10-14 21:41:50
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Changed a few things and now clicking catgories does nothing....
deronsizemore wrote:
That seems to work exactly the way that I wanted. I guess I just learn things weird. Like, I never would have been able to write all that out myself, but after seeing it and going through the code step by step I actually understand what’s going on! :-)
That seems a good way to learn :)
One thing I didn’t understand was the
"</div> <!-- closing either cat_list or featured_article -->"
code you gave. That div was to close either cat_list or featured_article…why would it be “or”. I want to close both tags right? So I would close the cat_list and featured_article both, not one or the other.
Only one of these divs is opened, depending on the condition (front page or category page), so only one needs to be closed.
Last thing I need to do is change the template used when a category is clicked. Right now if you click the category “courses” it takes you to the category list, but it using the hompage/default template. Is their an easy way to change that?
Yes, you can do that, show the category lists on their own section page, you can find instructions here. Please post here again if you need help with it.
You can also drop the if_category conditional if you do so :)
Offline
#8 2006-10-14 22:28:36
- deronsizemore
- Member
- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: Changed a few things and now clicking catgories does nothing....
Well if you couldn’t have guessed beforehand…I need help with it. I’ve sat here for a good half hour trying to figure out it but I just can’t comprehend what thebombsite is trying to say with his post. I used the code <a href="<txp:site_url /><txp:section />/?c=<txp:category1 />"><txp:category1 title=1 /></a>
in place of the <txp:category1 link="1" />
(which I had originally) in the from below
<txp:permlink><txp:title /></txp:permlink>
<div class="comment_time_author">
<span class="posted_by">Posted by <txp:author link="0" /></span> | <span class="filed_in">Filed in <a href="<txp:site_url /><txp:section />/?c=<txp:category1 />"><txp:category1 title=1 /></a></span> | <span class="date">Published on <txp:posted /></span> | <txp:if_comments><span class="comment_invite_icon"><a href="<txp:permlink />#discuss"><txp:comments_count /> comments</a></span><txp:else /><span class="comment_invite_icon"><a href="<txp:permlink />#discuss"><txp:comments_count /> Add a Comment</a></span></txp:if_comments>
</div>
<txp:if_excerpt>
<div class="homepage_article_body">
<p class="mainbodytext"><txp:excerpt /></p>
<p style="clear: left;"><txp:permlink>Full Article <span class="right_left_arrows">»</span></txp:permlink></p>
</div>
<txp:else />
<div class="homepage_article_body">
<p class="mainbodytext"><txp:body /></p>
</div>
</txp:if_excerpt>
but from there I don’t see what I need to do to get a different page template for the article list for the category. When I added the code from thebombsite’s thread in place of what I already had and clicked on the category name “courses” to test it, it took me to the same place that clicking “Full Article” does, like I’m trying continue reading the rest of the article.
I don’t know what <txp:site_url /><txp:section />
does. I mean, is the word “section” just filler text and I am suppose to input something in place of them, like instead of “section” am I suppose to put the name of one of my current sections?
I noticed in his post he “So here is a way of making your category links stay in the same section and use the same template as the original articles.” Well, I’m not sure if this is what I’m trying to do? I don’t want to use the same template as the original articles…cause the original articles use the default template which is the problem I’m running into currently, with when you click on the category name, it takes you to the category list with their excerpts, but also is using the default template…see what I mean? I’m sure I’m just misunderstanding.
Thanks
Offline
Re: Changed a few things and now clicking catgories does nothing....
Assumptions:
category1 = ‘your_category’
section = ‘your_section’
<code><txp:category1 link=“1” /></code> would give you this link:
<code><a href=“http://www.kentuckygolfing.com/category/your_category”>your_category</a></code>
That would link to the frontpage, limiting the article listing there to match your_category.
Sometimes you want to stay within a section, even when clicking a category link, so:
<code><a href=”<txp:site_url /><txp:section />/?c=<txp:category1 />”><txp:category1 title=1 /></a></code> will give you a link like this:
<code><a href=“http://www.kentuckygolfing.com/your_section/?c=your_category”>your_category</a></code>
<code><txp:site_url /></code> is replaced with http://www.kentuckygolfing.com/
<code><txp:section /></code> is replaced with the section you’re currently in (your_section)
Offline
#10 2006-10-15 00:40:56
- deronsizemore
- Member
- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: Changed a few things and now clicking catgories does nothing....
I’m still so lost it’s not funny. The way I have it now with <txp:category1 link="1" />
when clicked takes me to a listing of articles by a certain category and it uses the default template and section.
And from what you’re saying, when you use <a href="<txp:site_url /><txp:section />/?c=<txp:category1 />"><txp:category1 title=1 /></a>
that will allow you to stay within the current section. To me, it seems like they both do the same exact thing? I’m staying within the “default” section and “default” page template either way.
All I’m wanting to do is create a new page template, that we’ll call “category” or whatever, and when a category link is clicked and it takes you to a page with the articles with that category with a separte page template that the homepage was using. I’m basically just trying to get rid of the “Recent Articles” list, “Popular Articles” list, and “Recent Forum Posts” list that show up underneith the articles when a category is clicked (from still using the default homepage template.)
I guess I’m just not putting two and two together here to see how <a href="<txp:site_url /><txp:section />/?c=<txp:category1 />"><txp:category1 title=1 /></a>
will allow me to change the page template for the category article list.
Thanks
Offline
Re: Changed a few things and now clicking catgories does nothing....
When you’re on the frontpage, the two links are the same. That is correct.
You cannot create a new ‘page’ template and assign that to a ‘category’. Only sections can have their own ‘page’ templates. In your case, you’re staying within the default section/page.
To make the page look different when you’re inside a category, use the <code><txp:if_category>…<txp:else />….<txp:if_category /></code> construct as Els explains above. In her example, the difference between the frontpage and the category page is that the frontpage shows the featured course and featured article, while the category page shows just the article list…. but below that if/else construct, there’s still the search box and the recent articles part. Because they are not inside that if/else construct, they are shown at all times. You can use another if_category/else construct at the bottom of the template:
<pre><code>
<txp:if_category>
/* don’t show anything here */
<txp:else />
<div id=“recent_articles”>
<h3>Recent Articles</h3>
<txp:article_custom form=“recent_posts” offset=“2”/>
<p class=“more_articles”><a href=”#”>View all Articles</a></p>
</div>
/* add other code here that you only want to show when you’re NOT on the category page. */
<txp:if_category />
</code></pre>
Last edited by ruud (2006-10-15 08:32:52)
Offline
#12 2006-10-15 10:44:21
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Changed a few things and now clicking catgories does nothing....
Ruud (and Deron), about this:
<txp:section />
is replaced with the section you’re currently in (your_section)
Maybe for clarity you should say that when used in an article form it is replaced with the section the article is in.
When used on a page, it is replaced with the current section.
So Deron, what changing the category1 links does, is showing the category list on the page template that you use for the section this article is in (‘article’ in this case I think).
When I added the code from thebombsite’s thread in place of what I already had and clicked on the category name “courses” to test it, it took me to the same place that clicking “Full Article” does, like I’m trying continue reading the rest of the article.
When you go to kentuckygolfing.com/article/?c=Courses, it looks like a single article, but it is an article list. You problably have something like <txp:article form="single-article-form" limit="1" />
on the ‘article’ page template. Just add listform=“your-list-form”, and either leave out the limit attribute or give it a higher value (it’s only meant for article lists).
NOTE: either use Ruud’s example above (which is for displaying the category list on the default page while giving it a different look) or mine (which is for displaying the category list on the ‘article’ section page.
I’m afraid we’re confusing you even more…
Last edited by els (2006-10-15 10:58:49)
Offline