[web2py] Re: Help making nav menu work please!

2011-10-24 Thread noremac
Anthony you champion! thank you so much!! I can not believe that I
have been scratching my head for so long over something so simple
hehe. thanks again mate :)

On Oct 24, 10:54 am, Anthony abasta...@gmail.com wrote:
 On Sunday, October 23, 2011 6:47:45 PM UTC-4, noremac wrote:

  On Oct 24, 7:42 am, Christopher Steel chris...@gmail.com wrote:
   Are you looking to generate navigation menu's using table data?

   If so, you can try a search for web2py generate menu. Make sure to
  check
   out the web2pyslices as well, I think one of the very first slices was
   related to creating dynamic menus.

  Thanks for the reply mate but I already have the menu generating from
  the table data. Im looking to make the menu work.  It is for an online
  store selling many different products. For example.

  Animal
      Dog
      Cat
      Bird

  Animal is the main category and dog, cat and bird are subcategories.

  When I click on Dog I would like to be able to pass animal and dog as
  parameters to a function of some sort that will generate a query with
  those parameters, something like this.

  products = db((db.products.category=='animal') 
  (db.products.subcategory=='dog')).select(db.products.all)

 def products():
     products = db((db.products.category==request.args(0)) 
         (db.products.subcategory==request.args(1)).select()
     return dict(products=products)

 Then construct your menu so the links include the category and subcategory
 as arguments. For dogs, the link should be:

 URL('your_controller', 'products', args=['animal', 'dog'])

 Which will generate the URL /your_app/your_controller/products/animal/dog.

 Anthony


[web2py] Re: Help making nav menu work please!

2011-10-23 Thread noremac


On Oct 24, 7:42 am, Christopher Steel chris.st...@gmail.com wrote:
 Are you looking to generate navigation menu's using table data?

 If so, you can try a search for web2py generate menu. Make sure to check
 out the web2pyslices as well, I think one of the very first slices was
 related to creating dynamic menus.

Thanks for the reply mate but I already have the menu generating from
the table data. Im looking to make the menu work.  It is for an online
store selling many different products. For example.

Animal
Dog
Cat
Bird

Animal is the main category and dog, cat and bird are subcategories.

When I click on Dog I would like to be able to pass animal and dog as
parameters to a function of some sort that will generate a query with
those parameters, something like this.

products = db((db.products.category=='animal') 
(db.products.subcategory=='dog')).select(db.products.all)


I hope that it makes for sense for people now :) I am not looking for
someone to write me code, I am just very new to web2py and not sure
how to go about achieving this.

I will have a look into web2pyslices and see if there is anything in
there that can help me out :)


[web2py] Help making nav menu work please!

2011-10-22 Thread noremac
Hey guys I am in the process of making an online store. My products
are stored in the db with basic table.

db.define_table('products',
Field('MainCategory', 'string'),
Field('SubCategory', 'string'),
Field('Title', 'string'),
Field('Price', 'double'),
Field('image', 'upload', uploadfield='image_field'),
Field('image_field', 'blob')
)

Every product has a main category and a subcategory.  for the means of
a simple example lets say ANIMAL is a main category, CAT and DOG are
subcategories.

In my view I have a jQuery accordion style navigation menu that has my
MainCategory and under them their SubCategories.
I need the navigation menu to take the MainCategory and the
SubCategory and then query the DB to select only the products that
belong to those categories.  Then loop through the results placing
them in a table in a div of my page.

I have no troubles setting everything statically to achieve what I
want to do. But I would love to setup a function that i can pass
arguments to to achieve the desired results. So that the website is
easily expandable in the future.

Thank you in advance to anyone that helps me out I will be forever
greatful!