Archive

Archive for February, 2009

Accessing sfUser from template

February 3rd, 2009

It’s very easy - just use the $sf_user variable

Example.:

<?php if($sf_user->isAuthenticated()):? >
     < ?php echo "User is authenticated"?>
<?php else:?>
     <?php echo "User is not authenticated"?>
<?php endif?>

Mariusz View

Creating thumbnails with sfThumbnailPlugin and doctrine

February 3rd, 2009
 
public function set($name, $value, $load = true)
{
            parent::set($name, $value, $load);
            if($name == 'file')
                $this->generateThumbnail($value);
            }
 
public function generateThumbnail($value)
{
            $uploadDir = sfConfig::get('sf_upload_dir');
            $loadDir = $uploadDir;
            $thumbnail = new sfThumbnail(150, 150);
            $thumbnail->loadFile($loadDir.$value);
            $thumbnail->save($uploadDir.'/thumbs/'.$value, 'image/jpeg');
     }

Mariusz Model ,

Hello World!

February 3rd, 2009
 
<?php echo 'Hello World!'?>

Mariusz View