Wednesday, June 22, 2011

Setting Page Titles

Setting in action:
$this->getResponse()->setTitle($shopInfo->getName());

Retrieving in template:
$sf_response->getTitle();

Tuesday, June 21, 2011

Query and Call Database

$result = Doctrine::getTable('Shop')->findBySlug($name);

 public function findBySlug($name)
 {
  return Doctrine::getTable('Shop')
     ->createQuery('s')
     ->where('s.slug = ?', $name)
     ->fetchOne();
 }

Tuesday, May 24, 2011

Cross-Application Login

Scenario: You have two apps, frontend and backend. And you want to have only one single login page for frontend and backend applications, either you login from frontend or you login from backend.

Solution: Set both frontend and backend's factories to something like this:
all:
  user:
    class: myUser
    param:
      timeout:         18000
      logging:         %SF_LOGGING_ENABLED%
      use_flash:       true
      default_culture: %SF_DEFAULT_CULTURE%

  storage:
    class: sfSessionStorage
    param:
      session_name: application_name

Tuesday, May 3, 2011

Using Fixture

If you don't want the task to remove existing data in the database,
use the [--append|COMMENT] option:

[./symfony doctrine:data-load --append|INFO]

Monday, April 25, 2011

Using th native MySQL ENUM type in Symfony 1.4 and Doctrine

from: http://imanpage.com/code/using-th-native-mysql-enum-type-symfony-14-and-doctrine

To use the native MySQL ENUM type in Symfony and Doctrine you will have to update your "project/config/databases.yml" and add the "use_native_enum" directive under "attributes" i.e: 
      attributes:      
         use_native_enum: true
         use_dql_callbacks: true
         default_table_collate: utf8_general_ci
         default_table_charset: utf8

Full Version

all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn: 'mysql:host=localhost;dbname=mydb_prod'
      username: root
      password: 12345
      attributes:                
         use_native_enum: true
         use_dql_callbacks: true
         default_table_collate: utf8_general_ci
         default_table_charset: utf8

Thanks Iman! =)

Thursday, March 24, 2011

Getting Raw Data from Action to Template

Thanks St├ęphane of Google Groups

In a template, you can call $sf_data->getRaw('myActionProperty');
after init it like $this->myActionProperty = array('hey'=>'hoy'); inside an
action.
So you'll get your raw object : unescaped.

Wednesday, March 23, 2011

Clean Everything

php symfony doctrine:build --all-classes --sql
php symfony doctrine:migrate
php symfony plugin:publish-assets
php symfony cc