Conditional selection on a Weblog
Posted: 15 June 2007 08:05 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  439
Joined  05-15-2007

Hi,

I wonder if anyone can help with a little question?

In one of my earlier posts I mentioned that I was setting up a product catalogue weblog with the following fields:

- Product Name (text input)
- Product Description (textarea)
- Product Type (dropdown)
- Product Picture(s)
- Product PDF(s) (manuals, product specs, etc)
- User Voting

I’ve done this but am now thinking about my sites navigation. I have a keyword search for products and this works fine but I also want to use a browse option as well.

Basically I’m trying to achieve this…. If a user clicks ‘Browse’ in the nav menu they are taken to a page that has a list of product types. The user can then select a product type and they will then see related products of that type.

At the moment I have this:

<ul>
{exp:weblog:entries orderby="{title}" sort="asc" weblog="products" dynamic="off" disable="pagination|custom_fields|categories|member_data|trackbacks"}
<li><a href="{title_permalink=products/index}">{title}</a></li>
{/exp:weblog:entries}
</ul>

This just gives me a list of products. This was fine but now I want to break the list down by product type.

So, been searching on this forum and reading documentation etc. to find a solution. Best I could come up with is this (product_type is a weblog field that is a dropdown list):

<ul>
{exp:weblog:entries orderby="{title}" sort="asc" weblog="products" dynamic="off" disable="pagination|custom_fields|categories|member_data|trackbacks"}
{if product_type
== "Stationary"}
<li><a href="{title_permalink=products/index}">{title}</a></li>
{/if}
{
/exp:weblog:entries}
</ul>

However, this doesn’t work at all and I get no output at all. If I use the following:

<ul>
{exp:weblog:entries orderby="{title}" sort="asc" weblog="products" dynamic="off" disable="pagination|custom_fields|categories|member_data|trackbacks"}
{if product_type
!= "Stationary"}
<li><a href="{title_permalink=products/index}">{title}</a></li>
{/if}
{
/exp:weblog:entries}
</ul>

It outputs all entries with no selection at all.

Any ideas? Where am I going wrong?

thanks,

Ste

 Signature 

 
Stephen McIver | Zest Web Design | Merseyside, UK | Twitter

Profile
 
 
Posted: 15 June 2007 10:27 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  566
Joined  06-13-2006

Why not simply use categories to organize your products by type (where each category corresponds with a product type)?

BTW, love the avatar.

 Signature 

Firespring - Senior Web Developer

Profile
 
 
Posted: 18 June 2007 06:11 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  439
Joined  05-15-2007
opuszine - 15 June 2007 10:27 AM

BTW, love the avatar.

thanks grin

I’d thought about using categories and will perhaps use them. I just wanted to try and avoid the users having to select the ‘categories’ tab when adding a new product and just use the weblog fields. I know it’s not really a big deal but I’m just concerned that people will sometimes forget to do it!

 Signature 

 
Stephen McIver | Zest Web Design | Merseyside, UK | Twitter

Profile
 
 
Posted: 18 June 2007 11:37 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  566
Joined  06-13-2006
sm9 - 15 June 2007 08:05 AM

Any ideas? Where am I going wrong?

Is “product_type” a custom field?  If so, you’ll want to change the “disable” attribute in your {exp:weblog:entries} to “pagination|categories|member_data|trackbacks”.  Right now, “custom_fields” is being disabled, which means that you can’t use any custom fields for anything, including sorting and displaying.

Still think categories would be the ideal way to go.  Sure, there’s a little more of a learning curve for your users, but I’d think the resulting flexibility would be worth it.

 Signature 

Firespring - Senior Web Developer

Profile
 
 
Posted: 19 June 2007 06:03 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  439
Joined  05-15-2007

Schoolboy error on my part there!  red face

I think i’m going to go with the conditional selection for now but take you point about the categories. The first phase of the project is quite small scale so may revise things during phase two.

 Signature 

 
Stephen McIver | Zest Web Design | Merseyside, UK | Twitter

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120603 Total Logged-in Users: 66
Total Topics: 126642 Total Anonymous Users: 36
Total Replies: 665701 Total Guests: 410
Total Posts: 792343    
Members ( View Memberlist )
Newest Members:  bell143paololukDarleneChadbourneRashadSargIvar89HonschowmtRetliffherzigerjudith