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
#13 2006-10-17 01:10:34
- deronsizemore
- Member

- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: Changed a few things and now clicking catgories does nothing....
Ahhhhh! (Light Bulb goes off in Deron’s head). I believe I’m finally starting to get it Els! Sorry I’ve not posted back for a while…just been reading and re-reading trying to take it all in. I actually got it to work using the if_category statements inside the maincontent of my site so that when a category is clicked it takes you to an article list of excperts for that category. I did the same thing for the middle area of my site (with the site search). I did this for the middle content area:
<code>
<div id=“middlecontent”>
<div>
<txp:output_form form=“site_search” />
</div>
<txp:if_category>
<txp:else />
<div id=“recent_pictures”>
Recent Pictures
<txp:wet_thumbfilter section=“courses” limit=“4” first=“1” wraptag=“ul” break=“li” />
</div>
<div class=“clear”></div>
<div id=“categories”>
Article Categories
<ul>
<li><a href=”#”>General</a></li>
<li><a href=”#”>Clubs</a></li>
<li><a href=”#”>Balls</a></li>
<li><a href=”#”>Fitness</a></li>
<li><a href=”#”>Accessories</a></li>
</ul>
</div>
</txp:if_category>
</div>
</code>
<br />
I could not get ruud’s example of simply using a second if_category conditional to work (would have worked but later after I already changed it and got it working, I noticed that the closing forware slash in his <txp:if_category /> was in the wrong place) so all I did was enclosed every bit of code inside the original if_category statement you gave me Els, so now it looks as so:
<br/>
<code>
<div id=“maincontent”>
<txp:if_category> <!— this is for the category page —>
<div id=“cat_list”>
Articles in category <txp:category title=“1” />
<txp:article form=“default” listform=“excerpt” limit=“5” />
</div>
<txp:else /> <!— this is for the front page —>
<div id=“featured_course”>
Featured Course
<txp:article_custom form=“excerpt_featured_course” limit=“1” section=“featured-course” />
</div>
<div class=“clear”></div>
<div id=“featured_article”>
Featured Article
<txp:article_custom form=“excerpt” limit=“1” section=“article” />
</div> <!— closing either cat_list or featured_article —>
<div id=“recent_articles”>
Recent Articles
<txp:article_custom form=“recent_posts” offset=“2”/>
<p class=“more_articles”><a href=”#”>View all Articles</a></p>
</div>
<div id=“popular_articles”>
Popular Articles
<ul>
<li><a href=”#”>General</a></li>
<li><a href=”#”>Clubs</a></li>
<li><a href=”#”>Balls</a></li>
<li><a href=”#”>Fitness</a></li>
</ul>
</div>
</txp:if_category>
</div> <!— closing maincontent —>
</code>
<br />
One thing I did have to do to get this to work is add another </div> to close <div id="cat_list">. Do you know why that is? If I leave it out and click on the category “courses” the layout is all messed up.
I believe I’m finally starting to understand conditionals! I know what you’re thinking (IT’S ABOUT TIME)! Right? lol. I think (err..know) I was making things harder than it is. See, I always for whatever reason understood a conditional statement to be when you clicked on something. Like if I use if_category, in my head it was registering as “if I click a category link then do this, else, do this other thing” which is right in a sense. But when I tried to take that logic and put it toward say, an article list it doesn’t make one bit of sense! I kept thinking of it like this: “if I click an article list then do this, else, do this” and I know you can’t click on an article list, it’s not a link. So finally today after hours of reading this thread over and over again a big light buld went off and I realized that you’re just dealing with the template. Saying that if an article list (category list) shows up in this page template, then display it like this, else show this instead.
Sorry this is so long…last question I’ve come up with for right now. You helped me out over at <a href=“http://forum.textpattern.com/viewtopic.php?id=19061”>THIS THREAD</a> a couple days ago with how to create a a template or a place for txp to navigate to when “full article” is clicked below the article excerpt. I used what at the time I thought was an easier method of just creating a new page template and named it “article” and used <txp:article form="default" /> in the page template and my featured article tag is <txp:article_custom form="excerpt" limit="1" section="article" />. So, with that said…if I didn’t want to create that extra page template named “article” for the featured individual articles, could have have used your other suggestion something like this and just added this below the if_category statment?:
<code>
<txp:if_individual_article>
<txp:article form=“featured_course” />
<txp:else />
<div id=“featured_course”>
Featured Course
<txp:article_custom form=“excerpt_featured_course” limit=“1” section=“featured-course” />
</div>
<div class=“clear”></div>
<div id=“featured_article”>
Featured Article
<txp:article_custom form=“excerpt” limit=“1” section=“article” />
</txp:if_individual_article>
</code>
<br />
I’m sorry for the code being so sloppy. I have no idea how to use this forum and write code out so that it keeps the formatting, like line breaks, returns, etc… I’m using <code> right now and it doesn’t keep any formatting at all…it’s just all jumbled together. Also don’t understand why when I type code using <code> that half the looks like it’s in times new roman and the other looks like arial.
THANKS A BUNCH!
Last edited by deronsizemore (2006-10-17 14:25:27)
Offline
#14 2006-10-17 13:46:13
- 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:
One thing I did have to do to get this to work is add another
</div>to close<div id="cat_list">. Do you know why that is? If I leave it out and click on the category “courses” the layout is all messed up.
That’s because I originally had this closing </div> outside the conditional, so it would close whichever one was opened. You moved it to before </txp:if_category>.
I know what you’re thinking (IT’S ABOUT TIME)! Right?
Wrong ;) It took you no more than a couple of days, right? That’s not too bad :)
So, with that said…if I didn’t want to create that extra page template named “article” for the featured individual articles, could have have used your other suggestion something like this and just added this below the if_category statment?:
<code>
<txp:if_individual_article>
<txp:article form=“featured_course” />
<txp:else />
<div id=“featured_course”>
Featured Course
<txp:article_custom form=“excerpt_featured_course” limit=“1” section=“featured-course” />
</div>
<div class=“clear”></div>
<div id=“featured_article”>
Featured Article
<txp:article_custom form=“excerpt” limit=“1” section=“article” />
</txp:if_individual_article>
</code>
I think that should work. Don’t forget to assign the default page to section ‘article’ again then. And in case you have articles in other sections that you want to display in a different way, you can always throw in some more conditionals… you haven’t used if_section yet, right? ;)
I’m sorry for the code being so sloppy. I have no idea how to use this forum and write code out so that it keeps the formatting, like line breaks, returns, etc… I’m using
<code>right now and it doesn’t keep any formatting at all…it’s just all jumbled together. Also don’t understand why when I type code using<code>that half the looks like it’s in times new roman and the other looks like arial.
The < code > tags don’t handle empty lines in the code very well. For those cases you can use bc.., like this:
This is some code
and some more
and more...
(How do I post tags and code on the forum?)
Good luck with your site, I’m sure it will go fast from now on!
Offline
#15 2006-10-17 18:03:23
- deronsizemore
- Member

- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: Changed a few things and now clicking catgories does nothing....
Els wrote:
I think that should work. Don’t forget to assign the default page to section ‘article’ again then. And in case you have articles in other sections that you want to display in a different way, you can always throw in some more conditionals… you haven’t used if_section yet, right? ;)
When I asked that question it was just a hypothetical “what if” type thing. I’m not planning on changing what I have because as it is right now I understand what’s going on with the site and I don’t want to confuse myself more right now (I’ll save that for a later date).
But I did just want to clarify, when you say “Don’t forget to assign the default page to section ‘article’ again then”, what do you mean? My default section has never been set to use page ‘article’, so don’t know why I would set it ‘back’ to article when it’s not every been that way. My default section has always used ‘default’ style and page.
No, I have not used if_section yet. So if I were to use an if_section statement, I would just put it below my other if statements? Something like this:
<div id="maincontent">
[txp:if_category]
[txp:else /]
[/txp:if_category]
[txp:if_section]
[txp:else /]
[/txp:if_section]
[txp:if_article_list]
[txp:else /]
[/txp:if_article_list]
</div>
And I could just use one if statement right after the other?
Are their any specifications on how many of the same if statements I can use on one template?
Like Ruud was saying earlier, that since my ‘recent_article’, ‘popular_article’ and ‘recent_forum_topics’ lists were not in the original txp:if_category statement, they will always show up at the bottom of whatever content is there, so to remedy this, I could either make a second txp:if_category statement like this:
[txp:if_category]
Do nothing
[txp:else /]
My recent articles, popular articles, and recent forum topics code
[/txp:if_category]
Or I could simply move those recent article, popular article, and recent forum topics areas up into the original txp:if_category statement (which is what I did) So with that example, I’ve got two txp:if_category statements on the page, and I’ve also got one controlling the middle content area of my site where txp:if_category then right now it’s only showing the search input bar, else if it’s on the default page, it’s showing ‘recent pictures’, ‘categories’. So I’ve got two if_category statements on that template right now…can I have more? Can I have more than one if section statement? Or more than one if article list statement?
Last edited by deronsizemore (2006-10-17 18:05:19)
Offline