Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-10-13 19:22:52

ywickham
Member
Registered: 2005-06-11
Posts: 38
Website

Display category listing using "default" index.php page

When I started my site (http://www.aprettyrock.com/), I created sections for each type of item (Bracelets, Necklaces, Earrings). Since then, I’ve realized that I really want to have all these things listed under one section (Shop) and categorized by type (bracelets, necklaces, earrings). So, I’ve started recategorizing items I have listed.

However, I was under the wrong impression that the page template I created for my products would be the template that would list the items when a category link was clicked (http://www.aprettyrock.com/?c=Bracelets). I’ve since found out (someplace in the forums today), that category links use the default template to display all the articles. So, I modified the default template for the index page the way I thought I needed to in order to display the home page content when the section was “default” or “” and to display the appropriate category articles when the section was “shop” with a specific category. Instead, what I get is a blank page. Why am I getting a blank page? What am I misunderstanding?

Here is my code:

bc.. <txp:if_section name=”“> <h3>Latest Pieces</h3> <div id=“product_list”><txp:article_custom listform=“excerpt_products” limit=“9” category=“All Pieces” /></div> <br clear=“all” /> <txp:article form=“default” limit=“1” /> <p><a href=”/news”>Other news >></a></p> </txp:if_section>

<txp:if_section name=“shop”>

<txp:if_category name=“Bracelets”> <h3>Bracelets</h3> <div id=“product_list”><txp:article_custom listform=“excerpt_products” limit=“100” category=“Bracelets” /></div> <br clear=“all” /> <txp:if_category />

<txp:if_category name=“Necklaces”> <h3>Necklaces</h3> <div id=“product_list”><txp:article_custom listform=“excerpt_products” limit=“100” category=“Necklaces” /></div> <br clear=“all” /> <txp:if_category />

<txp:if_category name=“Earrings”> <h3>Earrings</h3> <div id=“product_list”><txp:article_custom listform=“excerpt_products” limit=“100” category=“Earrings” /></div> <br clear=“all” /> <txp:if_category />

</txp:if_section>

Last edited by ywickham (2005-10-13 19:24:22)

Offline

#2 2005-10-13 20:30:36

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Display category listing using "default" index.php page

When you are in a category list you are not in a section even though all the categories might be in the same section. The way I get around this is to grab osei’s glx_if plug-in which has the if_category_list tag and can also use the “else” tag then you could use something like:-

<code>
<txp:glx_if_category_list>
listing blah blah blah
<txp:else />
front-page blah blah blah
</txp:glx_if_category_list></code>
<br />

So the code for your listing followed by the code for your front-page.

Last edited by thebombsite (2005-10-13 20:32:20)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#3 2005-10-13 23:11:58

ywickham
Member
Registered: 2005-06-11
Posts: 38
Website

Re: Display category listing using "default" index.php page

Ah-ha! You rock, thebombsite! (It would also help if I was closing my txp tags correctly…) but that plug in did exactly what I needed. I wasn’t able to use the “else” tag with it, but with the other tags available to me, it did what I needed it to.

Thanks!

Offline

#4 2005-10-13 23:31:13

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Display category listing using "default" index.php page

Ha ha. I didn’t spot the bad closing. :grin:


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#5 2005-10-14 11:40:08

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Display category listing using "default" index.php page

ywickham, care to show how you got your page to work? Am doing something similar.

Offline

#6 2005-10-14 11:52:24

ywickham
Member
Registered: 2005-06-11
Posts: 38
Website

Re: Display category listing using "default" index.php page

Sure! It’s an e-commerce site: <a href=“http://www.aprettyrock.com”>A Pretty Rock</a>

Last edited by ywickham (2005-10-14 11:53:03)

Offline

#7 2005-10-14 12:29:59

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Display category listing using "default" index.php page

Hi! No, I meant the code! Good luck with the site. Are you the jewelry designer or the web designer? Or both? ;-)

Offline

#8 2005-10-14 13:21:04

ywickham
Member
Registered: 2005-06-11
Posts: 38
Website

Re: Display category listing using "default" index.php page

LOL I misunderstood. (I’m both…I’m one of those people that needs to be busy all the time and since I’m a girl I like shiny things… :) I can’t just sit and play World of Warcraft, I have to be doing something else…unless I’m in a dungeon, of course!) Ok, done yacking…

I can’t seem to get the txp:else tags to work on my install, so I couldn’t use conditional statements. Here’s what I did with the code using the glx_if plug-in. Works like a charm.:

bc.. <txp:glx_if_category_list> <h3><txp:c /></h3> <txp:if_category name=“Bracelets”> <div id=“product_list”><txp:article_custom listform=“excerpt_products” limit=“100” category=“Bracelets” /></div> </txp:if_category>

<txp:if_category name=“Necklaces”> <div id=“product_list”><txp:article_custom listform=“excerpt_products” limit=“100” category=“Necklaces” /></div> </txp:if_category>

<txp:if_category name=“Earrings”> <div id=“product_list”><txp:article_custom listform=“excerpt_products” limit=“100” category=“Earrings” /></div> </txp:if_category> <br clear=“all” /> </txp:glx_if_category_list>

<txp:glx_if_frontpage> <h3>Latest Pieces</h3> <div id=“product_list”><txp:article_custom listform=“excerpt_products” limit=“9” section=“shop” /></div> <br clear=“all” /> <txp:article form=“default” limit=“1” /> <p><a href=”/news”>Other news >></a></p> </txp:glx_if_frontpage>

Last edited by ywickham (2005-10-14 13:21:23)

Offline

#9 2005-10-15 12:21:02

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Display category listing using "default" index.php page

ywickham – thanks for code. It helped me work with a portfolio page I was doing. How do you get the http://www.aprettyrock.com/category/Bracelets/ to show, as opposed to http://www.aprettyrock.com/?c=Bracelets

I’d like to make the URL nicer. zem_rewrite?

Offline

#10 2005-10-15 13:03:54

ywickham
Member
Registered: 2005-06-11
Posts: 38
Website

Re: Display category listing using "default" index.php page

Actually, I upgraded to the latest Textpattern version. I think I was on 3.01 or something like that. When I upgraded, it updated the links for me.

Offline

#11 2005-10-15 13:24:57

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Display category listing using "default" index.php page

4.01 is the latest. Are you using the subversion development release, which is 4.02 if I am correct?

Offline

#12 2005-10-15 13:54:54

ywickham
Member
Registered: 2005-06-11
Posts: 38
Website

Re: Display category listing using "default" index.php page

No, I’m using 4.01 (r888) – at least that’s what the diagnostics say. :) Hmm…let’s see what other plug-ins I have…

No plug-ins for categories. I’m using txp:category_list to generate the links and I have Permanent Link Mode set to “/section/title”.

Offline

Board footer

Powered by FluxBB