This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.2 » Displaying based on
Displaying based on [message #103429] Mon, 02 August 2010 18:31 Go to next message
wigglesby85  is currently offline wigglesby85
Messages: 144
Registered: May 2009
Senior Member
Hi all

I have 2 tables, Category and Subcategory

I want to display something along the lines of

Category 1
Sub Cat 1
Sub Cat 2
Category 2
Sub Category 3
Category 3
Sub Category 4

How would I do this?

Re: Displaying based on [message #103432 is a reply to message #103429 ] Mon, 02 August 2010 18:45 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Do you want this to be rendered as html tables, or a select menu, or divs...?

Are you using Propel or Doctrine?

[Updated on: Mon, 02 August 2010 18:45]


Remember Palestine
Re: Displaying based on [message #103434 is a reply to message #103432 ] Mon, 02 August 2010 19:13 Go to previous message
wigglesby85  is currently offline wigglesby85
Messages: 144
Registered: May 2009
Senior Member
I've managed to do it now.

I looked at the Jobeet tutorial

I needed it outputting in json

Category.php
        public function getAllDoorStyles()
        {
          $criteria = new Criteria();
          $criteria->add(DoorStylePeer::CATEGORIES_ID, $this->getId());


          return DoorStylePeer::getDoorStyles($criteria);
        }


CategoryPeer.php
          public static function getAllDoorStyles()
          {
            $criteria = new Criteria();
            $criteria->addJoin(self::ID, DoorStylePeer::CATEGORIES_ID);

            $criteria->setDistinct();

            return self::doSelect($criteria);
          }



DoorStylePeer.php

        static public function getDoorStyles(Criteria $criteria = null)
        {
          if (is_null($criteria))
          {
            $criteria = new Criteria();
          }

          return self::doSelect($criteria);

        }


Is there a cleaner way of doing it, especially if i want the following:

3 tables: Category, Door Style, Hardware
Category 1
     Hardware 1
     Hardware 2
     Hardware 3
     Sub Cat 1
        Sub Cat Image
     Sub Cat 2
        Sub Cat Image 
Category 2
     Hardware 4
     Hardware 5
     Category 3
     Hardware 6
     Sub Category 3
        Sub Cat Image
     Sub Category 4
        Sub Cat Image
Previous Topic:I18N DOCTRINE BEHAVIOUR - HELP
Next Topic:User access to edit certain admin form fields
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software