modalbox javascript onclose event

Today after along period writing a post. I tried a new javascript library called modalbox js. Was working very good, but i had to run other javascript when the box was closed. Found some help at http://code.google.com/p/modalbox/wiki/MethodsReference but didn’t found the exact syntax.

After some trial and error finally succeeded, so thought to post on to the blog. Here is the syntax for javascript as well as for symfony (in case you are working with symfony)

Syntax for symfony:

<?php echo m_link_to(‘link_name’,
‘url’,
array(‘title’ => ‘title’),
array(‘width’ => 630, ‘height’ => 180, ‘afterHide’ => ‘afterhidealert‘)); ?>

here afterhidealert is the javascript function that will be called on the closing of the modalbox popup.

Syntax for javascript:

<a href=”url” onclick=”Modalbox.show(this.href, {afterHide:afterhidealert, height:180, title:this.title, width:630}); return false;” title=”title”>link_name</a>

here afterhidealert is the javascript function that will be called on the closing of the modalbox popup.

Thanks,

samsami2u

http://www.avidindiainc.com

Couldn’t get short alias for (

The below query didn’t worked for me and gave me the error “Couldn’t get short alias for ( re” and so i did removed the spaces from between every ‘or’ and brackets ‘(‘. i have added the modified query below the original query.

$restaurant = Doctrine_Query::create()
->select(‘re.*’)
->from(‘ReservationHoursSetting re’)
//->where(“re.id <> ? AND re.reservation_setting_id = ? AND ( (re.hr_from > {$hourFrom} AND re.hr_from < {$hourTo}) OR (re.hr_to > {$hourFrom} AND re.hr_to < {$hourTo}) )”, array($HourID, $restaurantSettingID) )
//->where(“re.id <> ? AND re.reservation_setting_id = ? AND ( ( re.hr_from BETWEEN {$hourFrom} AND {$hourTo} ) OR ( re.hr_to BETWEEN {$hourFrom} AND {$hourTo} ) OR ( {$hourFrom} BETWEEN re.hr_from AND re.hr_to )  OR ( {$hourTo} BETWEEN re.hr_from AND re.hr_to ) )”, array($HourID,$restaurantSettingID) )
->where(“re.id <> ? AND re.reservation_setting_id = ? “, array($HourID,$restaurantSettingID) )
->andWhere(“((re.hr_from > {$hourFrom}  AND re.hr_from< {$hourTo})

OR (re.hr_to > {$hourFrom} AND re.hr_to < {$hourTo})

OR (re.hr_to > {$hourFrom}  AND re.hr_from < {$hourFrom})

OR (re.hr_to < {$hourTo}  AND re.hr_from > {$hourTo})

OR (re.hr_to = {$hourTo}  AND re.hr_from = {$hourFrom}))”)
->fetchArray();

====================

$restaurant = Doctrine_Query::create()
->select(‘re.*’)
->from(‘ReservationHoursSetting re’)
//->where(“re.id <> ? AND re.reservation_setting_id = ? AND ( (re.hr_from > {$hourFrom} AND re.hr_from < {$hourTo}) OR (re.hr_to > {$hourFrom} AND re.hr_to < {$hourTo}) )”, array($HourID, $restaurantSettingID) )
//->where(“re.id <> ? AND re.reservation_setting_id = ? AND ( ( re.hr_from BETWEEN {$hourFrom} AND {$hourTo} ) OR ( re.hr_to BETWEEN {$hourFrom} AND {$hourTo} ) OR ( {$hourFrom} BETWEEN re.hr_from AND re.hr_to )  OR ( {$hourTo} BETWEEN re.hr_from AND re.hr_to ) )”, array($HourID,$restaurantSettingID) )
->where(“re.id <> ? AND re.reservation_setting_id = ? “, array($HourID,$restaurantSettingID) )
->andWhere(“((re.hr_from > {$hourFrom}  AND re.hr_from< {$hourTo}) OR (re.hr_to > {$hourFrom} AND re.hr_to < {$hourTo}) OR (re.hr_to > {$hourFrom}  AND re.hr_from < {$hourFrom}) OR (re.hr_to < {$hourTo}  AND re.hr_from > {$hourTo}) OR (re.hr_to = {$hourTo}  AND re.hr_from = {$hourFrom}))”)
->fetchArray();

setAuthenticated in symfony for frontend and backend

The problem:

i had two applications 1) frontend and 2) backend.

but when i login into backend i was automatically login into the frontend application.

The Solution:

the solution is simple you have to define the session name for both the application or atleast one. so that the sessions for both of them differ from each other.

you can define the session name in the “\apps\backend\config\factories.yml” file

here

cli:
controller:
class: sfConsoleController
request:
class: sfConsoleRequest
response:
class: sfConsoleResponse

test:
storage:
class: sfSessionTestStorage

all:
#  controller:
#    class: sfFrontWebController
#
#  request:
#    class: sfWebRequest
#
#  response:
#    class: sfWebResponse
#
#  user:
#    class: myUser
#
storage:
class: sfSessionStorage
param:
session_name: symfonyBack
#
#  view_cache:
#    class: sfFileCache
#    param:
#      automaticCleaningFactor: 0
#      cacheDir:                %SF_TEMPLATE_CACHE_DIR%

i have given a name for the backend application (symfonyBack).

database connection in symfony 1.0

There are two files that needs to be configure database connection in symfony 1.0:

Both the below files as found in <project>\config\         directory(folder)

1) database.yml:

all:
propel:
class:      sfPropelDatabase
param:
phptype:  mysql
hostspec: localhost
database: symfonycms
username: root
password:
#port: 80
encoding: utf8 # Default charset for table creation
#persistent: true # Use persistent connections

or as a short hand for the above

all:
propel:
class:      sfPropelDatabase
param:
phptype:  mysql
dsn: mysql://root:password@localhost/databas
#port: 80
encoding: utf8 # Default charset for table creation
#persistent: true # Use persistent connections

2)propel.ini

propel.targetPackage       = lib.model
propel.packageObjectModel  = true
propel.project             = symfonycms
propel.database            = mysql
propel.database.createUrl  = mysql://localhost/
propel.database.url        = mysql://root:@localhost/symfonycms

propel.addGenericAccessors = true
propel.addGenericMutators  = true
propel.addTimeStamp        = false

propel.schema.validate     = false

; directories
propel.home                    = .
propel.output.dir              = /var/www/production/sfweb/www/cache/symfony-for-release/1.0.20/sf_sandbox
propel.schema.dir              = ${propel.output.dir}/config
propel.conf.dir                = ${propel.output.dir}/config
propel.phpconf.dir             = ${propel.output.dir}/config
propel.sql.dir                 = ${propel.output.dir}/data/sql
propel.runtime.conf.file       = runtime-conf.xml
propel.php.dir                 = ${propel.output.dir}
propel.default.schema.basename = schema
propel.datadump.mapper.from    = *schema.xml
propel.datadump.mapper.to      = *data.xml

; builder settings
propel.builder.peer.class              = addon.propel.builder.SfPeerBuilder
propel.builder.object.class            = addon.propel.builder.SfObjectBuilder

propel.builder.objectstub.class        = addon.propel.builder.SfExtensionObjectBuilder
propel.builder.peerstub.class          = addon.propel.builder.SfExtensionPeerBuilder
propel.builder.objectmultiextend.class = addon.propel.builder.SfMultiExtendObjectBuilder
propel.builder.mapbuilder.class        = addon.propel.builder.SfMapBuilderBuilder
propel.builder.interface.class         = propel.engine.builder.om.php5.PHP5InterfaceBuilder
propel.builder.node.class              = propel.engine.builder.om.php5.PHP5NodeBuilder
propel.builder.nodepeer.class          = propel.engine.builder.om.php5.PHP5NodePeerBuilder
propel.builder.nodestub.class          = propel.engine.builder.om.php5.PHP5ExtensionNodeBuilder
propel.builder.nodepeerstub.class      = propel.engine.builder.om.php5.PHP5ExtensionNodePeerBuilder

propel.builder.addIncludes = false
propel.builder.addComments = false

propel.builder.addBehaviors = false

Fatal error: Unsupported operand types in lib\symfomy\util\spyc.class.php on line 667

If this is due to the change you had done in your project’s /config/schema.yml then the problem is the syntax in your schema.yml

possibly you have written

(incorrect)

cat_id:                    { type: INTEGER, required:true, primaryKey: true}

instead of

(correct)

cat_id:                    { type: INTEGER, required: true, primaryKey: true}

here the difference between the above two line of code is: the incorrect one is having no space between required: and true, while the correct one is having the space between the two.

so whatever attributes you write leave a space between the attribute name and attribute value.

I hope this will help you out.

::execute() must be compatible with that of sfComponent::execute()

This is since 1.1 or greater version of symfony:

class testAction extends sfAction{
public function execute() {

}

}

The above code will work fine for symfony 1.0, but for the versions above it; it won’t work.

Below given is the change you need to implement to make it work

class testAction extends sfAction{
public function execute($request) {

}

}

fatal error: call to a member function get children column() on a non-object

Below is given schema.yml of my project:

propel:
_attributes: {noXsd: false, defaultIdMethod: none, package: lib.model}
cms_admin:
_attributes:               { phpName: Admin, isI18N: true, i18nTable: cms_admin_i18n }
adm_id:                    { type: INTEGER, required: true, primaryKey: true, autoIncrement: true}
adm_email:                 { type: VARCHAR, size:100, required: true }
adm_passwd:                { type: VARCHAR, size:100, required: true }
adm_create_date:           { type: TIMESTAMP }
adm_last_login:            { type: TIMESTAMP }
adm_last_login_ip:         { type: VARCHAR, size:100 }

cms_admin_i18n:
_attributes:               { phpName: AdminI18n }
adm_id:                    { type: INTEGER, required: true, primaryKey: true  }
adm_culture:               { isCulture: true, type: varchar, size: 7, required:true, primaryKey: true }
adm_f_name:                { type: VARCHAR, size:100 }
adm_l_name:                { type: VARCHAR, size:100 }

when i tried to generate model with this schema.yml i throw me an error “fatal error: call to a member function getchildrencolumn() on a non-object”

but it was soon resolved. below is the changed schema.yml that generated a model without any errors:

propel:
_attributes: {noXsd: false, defaultIdMethod: none, package: lib.model}
cms_admin:
_attributes:               { phpName: Admin, isI18N: true, i18nTable: cms_admin_i18n }
adm_id:                    { type: INTEGER, required: true, primaryKey: true, autoIncrement: true}
adm_email:                 { type: VARCHAR, size:100, required: true }
adm_passwd:                { type: VARCHAR, size:100, required: true }
adm_create_date:           { type: TIMESTAMP }
adm_last_login:            { type: TIMESTAMP }
adm_last_login_ip:         { type: VARCHAR, size:100 }

cms_admin_i18n:
_attributes:               { phpName: AdminI18n }
adm_id:                    { type: INTEGER, required: true, primaryKey: true, foreignTable: cms_admin, foreignReference: adm_id }
adm_culture:               { isCulture: true, type: varchar, size: 7, required:true, primaryKey: true }
adm_f_name:                { type: VARCHAR, size:100 }
adm_l_name:                { type: VARCHAR, size:100 }

installing symfony plugins

To install any plugin in symfony you have to use command line interface. Here is an example how to install symfony plugins (here we’re using ‘sfGuardPlugin‘ installation) using command line interface:

1) Linux :   ./symfony plugin:install sfGuardPlugin

2) Windows:  php symfony plugin:install sfGuardPlugin

on windows if the php command is not executing you can check my blog for the same.

One more thing, if you are not having pear installed you won’t be able to install a symfony plugin through command line interface. In this case there is one more way to install symfony plugin which is given as below:

Download the plugin and extract it to the /plugin directory (folder) of the project. Now just run the following command from the command line interface:

1) Linux: ./symfony plugin:publish-assets

2) Windows: php symfony plugin:publish-assets

but before running this command you have to enable that plugin in the applications setting.yml file as below:

enabled_modules:        [default, sfGuardGroup, sfGuardUser, sfGuardPermission]
here we have enabled the sfGuardGroup, sfGuardUser and sfGuardPermission plugins.

hope this will help you out. if you have any doubt or query please contact me.