Author Archive for Benny



09
Jan

symfony backend: displaying thumbnail or photo in listing

if you are using the admin generator to generate your backend application and want to show thumbnail or photo in your listing, you can try the following steps.

Here’s an example of how it will looks like when the thumbnail is showing on the listing page.

Before you add it in, you need to check the variable name of the row that the admin generator uses.

To check the variable name, go to the cache folder for the module and open the _list.php file with a notepad.
Take note of the row

\\cache\backend\dev\modules\autoContestphoto\templates\_list.php
...
        <?php foreach ($pager->getResults() as $i => $contest_photo): $odd = fmod(++$i, 2) ? 'odd' : 'even' ?>
          <tr class="sf_admin_row <?php echo $odd ?>">
            <?php include_partial('contestphoto/list_td_batch_actions', array('contest_photo' => $contest_photo, 'helper' => $helper)) ?>
            <?php include_partial('contestphoto/list_td_tabular', array('contest_photo' => $contest_photo)) ?>
            <?php include_partial('contestphoto/list_td_actions', array('contest_photo' => $contest_photo, 'helper' => $helper)) ?>
          </tr>
        <?php endforeach; ?>
...

In my case, the variable name for the row is $contest_photo

Next, create a partial call _thumbnail.php in the template folder of the module.
In this partial, echo the path of the thumbnail or the photo with a img html tag

\\apps\backend\modules\contestphoto\templates\_thumbnail.php
<img src="<?php echo $contest_photo->getThumbnailPath() ?>"/>

Then, edit the generator file to include the _thumbnail column for your list

\\apps\backend\modules\contest\config\generator.yml

...

      list:
        title: Contest Photo Management
        display: [=title, contest, category, user, title, isDeleted, _thumbnail]
        sort: [created_at, desc]
        max_per_page: 50

...

Clear your cache and see if the thumbnail loads.

VN:F [1.9.7_1111]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.7_1111]
Rating: 0 (from 0 votes)
27
Dec

Symfony error : Call to undefined method myUser::setReferer.

If you have this error

Call to undefined method myUser::setReferer.

and if you are using sfGuard plugin, go to

apps\[project]\lib\myUser.class.php

and change


class myUser extends sfBasicSecurityUser
{
}

to


class myUser extends sfGuardSecurityUser
{
}
VN:F [1.9.7_1111]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.7_1111]
Rating: +1 (from 1 vote)
23
Oct

You are not allowed to access this file. Check frontend_dev.php for more information.

If you had deployed to production/LIVE environment and encounter this error message when you tried to access fontend_dev.php, it is due to a security IP check in fontend_dev.php to check for 127.0.0.1 before it continue.

Thus, you need to add your public IP address in fontend_dev.php to tell symfony to let you through in the production environment. Here’s how to do it

In your fontend_dev.php file, put in the below line to print out your public ip address

echo $_SERVER['REMOTE_ADDR']. &quot;&lt;br/&gt;&quot;

Access frontend_dev.php and copy the IP address as shown.

Edit frontend_dev.php and change the line

if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')))

to

if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1', '111.222.333.444')))

Where 111.222.333.444 is the IP address you copied.

Upload back the frontend_dev.php and try again

VN:F [1.9.7_1111]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.7_1111]
Rating: +1 (from 1 vote)
10
Oct

Non-Unicode program displaying Chinese characters as box/square in Windows 7

If you have a chinese/non-unicode program that is displaying funny/box/square/garbage characters in Windows 7, you may want to try this method to display it properly.

Continue reading ‘Non-Unicode program displaying Chinese characters as box/square in Windows 7′

VN:F [1.9.7_1111]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.7_1111]
Rating: +2 (from 2 votes)
30
Sep

building new app with symfony : week 1

Going to build a new photography website which will be maintain by my friend and myself.

Am looking at the current popular PHP frameworks which need to fufil the following requirement

  1. rapid development
  2. easy maintainance
  3. user account management
  4. file upload
  5. able to integrate easily with image manipulation library (GD lib)
  6. Suitable for a shared-hosting environment

Currently shortlisted

  1. CakePHP (which I have some experience with version 1.2)
  2. Symfony

Had do some googling and below are the pros and cons for each frameworks

CakePHP

Pro

  1. easy to code
  2. built in security access
  3. access of data via arrays

Cons

  1. Quite new as compare to Symony
  2. No (or little?) test functionality?

Symfony

Pros

  1. able to build an enterprise app (otherwise why would yahoo use it?)
  2. access of data via propel or doctrine (i.e. object oriented) as they are well supported
  3. Able to reload data easily
  4. Able to create test cases

Cons

  1. steep learning curve
  2. Complicated?

I decided to give myself a week to learn Syfmony before I decide which framework to use.

VN:F [1.9.7_1111]
Rating: 8.0/10 (1 vote cast)
VN:F [1.9.7_1111]
Rating: +1 (from 1 vote)



Search Website

www.lingeriesg.com

www.lingeriesg.com

Sponsored Ads

Sponsored Links

www.asiadolly.com

www.asiadolly.com

About Me

Me

Hello, Im Benny Chong. This blog is a proof that I have too much spare time to burn. 

I will be writing topics mainly on web design, application development, photography and other rubbish. Cheers