Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#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
#16 2006-10-17 20:46:16
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Changed a few things and now clicking catgories does nothing....
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.
I meant it the other way around: you are using page template ‘article’ for section ‘article’, and in this hypothetical case you should change it back to page template ‘default’.
About the conditionals: you can use as many as you want, or move as much code as possible into one conditional, just do what works and what helps you best to keep the overview. On my site I’ve got about 10 sections and a number of categories, and I’m using only one page template. It’s quite full of conditionals, besides if_section and if_category I’m also using if_individual_article and if_custom_field, and whatever conditional I could find… ;) Now I still can find my way around, but I can imagine that others prefer less or no conditionals and separate page templates instead. At least I never noticed that all this is slowing down my site.
You can nest them, but not in themselves. So
<code>
<txp:if_section name=“x,y,z”>
blah
<txp:if_section name=“y”>
blah blah
</txp:if_section>
</txp:if_section>
</code>
is not possible. And I think you can’t use <txp:else />
more than once in one condition.
Last edited by els (2006-10-17 20:49:33)
Offline
#17 2006-10-20 23:06:39
- deronsizemore
- Member
- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: Changed a few things and now clicking catgories does nothing....
Els, sorry it’s taken me so long to reply to your post. I’ve not had time to work on my site or anything much here the last couple days.
I truely thank you for your help with my site! I think I’ve finally got a good handle on how it works. You answsered another question I had before I asked it even. I was going to say, the way I have my site set up right now, I have lots of sections and lots of pages, when hypothetically depending on how my site is set up, I could have one single page template and just throw all kinds of conditionals in there to display it how i want.
Say if I did that, and I’ve got a setup like my current site. I’m using one template and I have an <txp:if_section name="xyz">
blah@</txp:if_section> for the left content and then I have one in the middle area and then I also have one in the right content area of my site…that’s perfectly legal right?
Offline
#18 2006-10-20 23:10:36
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Changed a few things and now clicking catgories does nothing....
Yep, you can do that without a problem :)
Offline