Results 1 to 8 of 8

Thread: vardefs and current url hostname for iframe default

  1. #1
    bdoyle807 Guest

    Default vardefs and current url hostname for iframe default

    I have CE 6.4 running on different deployment environments and when I install a module or upgrade I would like to use the current hostname of the url it is getting installed on:


    $dictionary['Account']['fields']['reporting_iframe_index'] = array(
    'name' => 'reporting_iframe_index',
    'vname' => 'LBL_REPORTING_FRAME',
    'type' => 'iframe',
    'dbtype' => 'varchar',
    'default' => 'http://<the current hostname>/index.php?module=reportsengine&action=index&sugar_ body_only=true&portfolio={name}', //iframe url
    'len' => 255,//max size
    'ext3' => 1,
    'ext4' =>450, //height of the iframe
    'required' => false,
    'massupdate' => 0,
    'comments' => '',
    'help' => '',
    'importable' => true,
    'audited' => false,
    'reportable' => false,
    );

    Or do i do in pre_install.php?

    What is compatibility safe?

    Thank You

  2. #2
    jmertic's Avatar
    jmertic is offline Sugar Community Manager
    Join Date
    Dec 2007
    Posts
    3,996

    Default Re: vardefs and current url hostname for iframe default

    I would create a new Dashlet subclassed from an existing Dashlet and then build the URL you need from there.
    John Mertic
    Sugar Community Manager

  3. #3
    bdoyle807 Guest

    Default Re: vardefs and current url hostname for iframe default

    in custom\Extension\modules\Accounts\Ext\Vardefs\suga rfield_mychange.php

    I have

    $dictionary['Account']['fields']['reporting_index']['name']='reporting_index';
    $dictionary['Account']['fields']['reporting_index']['comments']='The iFrame to the Reporting Module';
    $dictionary['Account']['fields']['reporting_index']['type']='iframe';
    $dictionary['Account']['fields']['reporting_index']['vname']='LBL_REPORTING_FRAME';
    $dictionary['Account']['fields']['reporting_index']['len']=500;
    $dictionary['Account']['fields']['reporting_index']['default']='http://' . $_SERVER['HTTP_HOST'] . '/index.php?module=mitre_reportsengine&action=index& sugar_body_only=true&portfolio={name}';
    $dictionary['Account']['fields']['reporting_index']['ext3']=1;
    $dictionary['Account']['fields']['reporting_index']['ext4']=450;

    i do a repair then i get

    /* Table : accounts */
    /*COLUMNS*/
    /*MISSING IN DATABASE - reporting_index - ROW*/
    /* NAME IS MISSING IN VARDEF accounts::reporting_index_c */
    /* INDEXES */
    ALTER TABLE accounts add COLUMN reporting_index iframe DEFAULT 'http://sugar-daddy1.mitre.org/index.php?module=mitre_reportsengine&action=index& sugar_body_only=true&portfolio={name}' NULL ;

    which in turn gives
    Database failure. Please refer to sugarcrm.log for details.

    in log file
    Executing repair query: Query Failed: ALTER TABLE accounts add COLUMN reporting_index iframe DEFAULT 'http://sugar-daddy1.mitre.org/index.php?module=mitre_reportsengine&action=index& sugar_body_only=true&portfolio={name}' NULL: MySQL error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'iframe DEFAULT 'http://sugar-daddy1.mitre.org/index.php?module=mitre_reportseng' at line 1


    Thoughts?

  4. #4
    christianknoll's Avatar
    christianknoll is offline Sugar Community Member
    Join Date
    Nov 2008
    Location
    Vienna
    Posts
    1,382

    Default Re: vardefs and current url hostname for iframe default

    Why dont you use

    PHP Code:
    'default' => $GLOBALS['sugar_config']['site_url'] . '.......'
    That will parse the name of the site url in there.

    christian.

    Quote Originally Posted by bdoyle807 View Post
    I have CE 6.4 running on different deployment environments and when I install a module or upgrade I would like to use the current hostname of the url it is getting installed on:


    $dictionary['Account']['fields']['reporting_iframe_index'] = array(
    'name' => 'reporting_iframe_index',
    'vname' => 'LBL_REPORTING_FRAME',
    'type' => 'iframe',
    'dbtype' => 'varchar',
    'default' => 'http://<the current hostname>/index.php?module=reportsengine&action=index&sugar_ body_only=true&portfolio={name}', //iframe url
    'len' => 255,//max size
    'ext3' => 1,
    'ext4' =>450, //height of the iframe
    'required' => false,
    'massupdate' => 0,
    'comments' => '',
    'help' => '',
    'importable' => true,
    'audited' => false,
    'reportable' => false,
    );

    Or do i do in pre_install.php?

    What is compatibility safe?

    Thank You

  5. #5
    bdoyle807 Guest

    Default Re: vardefs and current url hostname for iframe default

    I dont think its the 'default' or the url that is causing the mysql to puke. If I create an iframe using studio them modify it i get something like this from the SugarCRM.log

    UPDATE fields_meta_data
    SET name='report1_c',vname='LBL_REPORT1_C',comments=NU LL,help=NULL,custom_module='Accounts',type='iframe ',len=255,required=0,default_value='http://sugar-daddy1.mitre.org/index.php?module=mitre_reportsengine&action=rpt_po rtfolio1&sugar_body_only=true&portfolio={name}',da te_modified='2013-01-28 14:42:25',audited=0,massupdate=0,duplicate_merge=0 ,reportable=1,importable='true',ext1=NULL,ext2=NUL L,ext3='1',ext4='400'
    WHERE fields_meta_data.id = 'Accountsreport1_c' AND deleted=0

    ALTER TABLE accounts_cstm modify COLUMN report1_c varchar(255) DEFAULT 'http://sugar-daddy1.mitre.org/index.php?module=mitre_reportsengine&action=rpt_po rtfolio1&sugar_body_only=true&portfolio={name}' NULL

  6. #6
    bdoyle807 Guest

    Default Re: vardefs and current url hostname for iframe default

    Update:
    it may be a bug in how the script for the iframe is generated. If i MANUALLY replace the iframe with varchar(255) in the db alter command it works fine during a repair.

    ALTER TABLE accounts add COLUMN reporting_index iframe DEFAULT 'http://sugar-daddy1.mitre.org/index.php?module=mitre_reportsengine&action=index& sugar_body_only=true&portfolio={name}' NULL ;

    ALTER TABLE accounts add COLUMN reporting_index varchar(255) DEFAULT 'http://sugar-daddy1.mitre.org/index.php?module=mitre_reportsengine&action=index& sugar_body_only=true&portfolio={name}' NULL ;

    But everytime I go into the studio Accounts->fields and try to change the default it puke on the alter script.

  7. #7
    jmertic's Avatar
    jmertic is offline Sugar Community Manager
    Join Date
    Dec 2007
    Posts
    3,996

    Default Re: vardefs and current url hostname for iframe default

    Quote Originally Posted by bdoyle807 View Post
    Update:
    it may be a bug in how the script for the iframe is generated. If i MANUALLY replace the iframe with varchar(255) in the db alter command it works fine during a repair.

    ALTER TABLE accounts add COLUMN reporting_index iframe DEFAULT 'http://sugar-daddy1.mitre.org/index.php?module=mitre_reportsengine&action=index& sugar_body_only=true&portfolio={name}' NULL ;

    ALTER TABLE accounts add COLUMN reporting_index varchar(255) DEFAULT 'http://sugar-daddy1.mitre.org/index.php?module=mitre_reportsengine&action=index& sugar_body_only=true&portfolio={name}' NULL ;

    But everytime I go into the studio Accounts->fields and try to change the default it puke on the alter script.
    Can you add a bug for this at Bug Portal | SugarCRM.com English (Americas) Thanks!
    John Mertic
    Sugar Community Manager

  8. #8
    bdoyle807 Guest

    Default Re: vardefs and current url hostname for iframe default

    I think I fixed the problem, some the fields were missing or incorrect.

    Couple things:
    added the dbtype = varchar that fixed the alter script to be correct
    added the gen field so that the {name} parameter is generate correctly see include/SugarFields/Fields/IFrame/DetailView.tpl to see why
    removed the ext3, ext4 fields
    set the height of the iframe using height


    $dictionary['Account']['fields']['reporting_index']['name']='reporting_index';
    $dictionary['Account']['fields']['reporting_index']['comments']='The iFrame to the Reporting Module';
    $dictionary['Account']['fields']['reporting_index']['type']='iframe';
    $dictionary['Account']['fields']['reporting_index']['dbtype'] = 'varchar';
    $dictionary['Account']['fields']['reporting_index']['vname']='LBL_REPORTING_FRAME';
    $dictionary['Account']['fields']['reporting_index']['len']=255;
    $dictionary['Account']['fields']['reporting_index']['default']='http://' . $_SERVER['HTTP_HOST'] . '/index.php?module=mitre_reportsengine&action=index& sugar_body_only=true&portfolio={name}';
    //$dictionary['Account']['fields']['reporting_index']['ext3']=1;
    //$dictionary['Account']['fields']['reporting_index']['ext4']=450;
    $dictionary['Account']['fields']['reporting_index']['height']=450;
    $dictionary['Account']['fields']['reporting_index']['gen']=1;

    Anyway, appears to work correctly.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to pass current user into home tab iframe?
    By Linnane in forum Developer Help
    Replies: 0
    Last Post: 2012-02-22, 12:41 AM
  2. Replies: 0
    Last Post: 2011-08-19, 10:46 PM
  3. Calculated default value in vardefs is cached
    By tedcowan in forum Developer Help
    Replies: 0
    Last Post: 2010-08-13, 05:41 PM
  4. Default value in vardefs.php in 4.5.1g
    By Rankie in forum Developer Help
    Replies: 1
    Last Post: 2008-02-11, 06:04 PM
  5. Problem with default value in vardefs.php
    By jobst in forum Developer Help
    Replies: 8
    Last Post: 2007-11-20, 07:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •