Results 1 to 10 of 10

Thread: html fields

  1. #1
    Meyer is offline Sugar Community Member
    Join Date
    Oct 2006
    Location
    south africa
    Posts
    646

    Wink html fields

    hi there.
    i am not a programmer so i appologise upfront for any easy questions etc.

    i have html files taht is used in conjuction with sugar. but to help the user i want to create an html field through studio with a link to the other html files, so they can just open the link, get the info and penter it in sugar. this should open in new window.

    Typically something like

    Http://core02:82/custom/files/ref1.html

    thank you

    paul

  2. #2
    clint's Avatar
    clint is offline Sugar Team Member | Forums Lead Moderator
    Join Date
    Aug 2004
    Location
    Silicon Valley
    Posts
    2,120

    Default Re: html fields

    Hi paul-

    Your example isn't clear enough. Can you put in a more detailed use case? For instance, is it just a static link to a URL or do you want it dynamic? In other words, if you enter a value like ref1 into the custom field, do you want the link to be Http://core02:82/custom/files/ref1.html and if you entered ref2 it would point to ref2.html?
    Sugar Developer Zone - developer resources | Sugar University - user and admin training
    Sugar Docs - user and admin documentation |
    Sugar Bug Tracker - Enter or view bugs
    SugarForge- open source modules, themes, lang packs | SugarExchange - commercial extensions

    Clint Oram
    Chief Technology Officer and Co-founder
    SugarCRM

  3. #3
    Meyer is offline Sugar Community Member
    Join Date
    Oct 2006
    Location
    south africa
    Posts
    646

    Default Re: html fields

    hi, just a static link

    on the left i have a tect field where they type in a value, but the value needs to be from anothe web page. so the right side is a straight forward link that opens in a new window to the other site.

    thanks

    paul

  4. #4
    clint's Avatar
    clint is offline Sugar Team Member | Forums Lead Moderator
    Join Date
    Aug 2004
    Location
    Silicon Valley
    Posts
    2,120

    Default Re: html fields

    Quote Originally Posted by Meyer
    hi, just a static link

    on the left i have a tect field where they type in a value, but the value needs to be from anothe web page. so the right side is a straight forward link that opens in a new window to the other site.

    thanks

    paul
    So have you tried creating a new custom field in Studio of type "HTML". This sounds like what you need.
    Sugar Developer Zone - developer resources | Sugar University - user and admin training
    Sugar Docs - user and admin documentation |
    Sugar Bug Tracker - Enter or view bugs
    SugarForge- open source modules, themes, lang packs | SugarExchange - commercial extensions

    Clint Oram
    Chief Technology Officer and Co-founder
    SugarCRM

  5. #5
    gtryonp is offline Sugar Community Member
    Join Date
    Dec 2007
    Posts
    11

    Default Re: html fields

    Mr Clint... That's cool, and open new doors to my imaginary!

    please, using this technique, how can I make a dynamic link envolving the unique id? something like:

    window.open("saywhat.php?record=7327-983298-7329","","top=0,left=0...")

    where 7327-983298-7329 is the id (call, contact,meeting or anyone else)?

    TIA,

    Grenville Tryon

  6. #6
    purplewave is offline Sugar Community Member
    Join Date
    Feb 2007
    Posts
    33

    Default Re: html fields

    I'm not sure if you can do that through Studio and I've yet to get an HTML field to display anything at all, so I've had to come up with my own workaround to do what you're wanting. This is how I got the functionality you're asking for. Note that this involves manually editing files. If you're not comfortable doing that, I'm sure someone else can provide a solution through Studio. As per usual, back up any files before making changes.

    From your root sugar directory, navigate to custom/modules/<MODULE NAME>/metadata. You should have a file named editviewdefs.php. Open that file in a text editor. Search for the name of the field the user is entering the information in (the left column in your previous post). It should look something like
    Code:
                0 => 
                array (
                  'name' => 'primary_address_street',
                  'label' => 'LBL_PRIMARY_ADDRESS',
                  'type' => 'address',
                  'displayParams' => 
                  array (
                    'key' => 'primary',
                  ),
                ),
    Copy that section of code from your file and paste it directly below itself. Change the 0 to a 1 so that it will display on the right column. Change the name and label fields as appropriate and remove all other fields. Then add the following line below the label field.
    Code:
    'customCode' => '<a href="saywhat.php?record={$fields.id.value}" target="_blank">Link text goes here</a>',
    Once you've saved the file, do a quick repair from the admin section in Sugar to clear the cache so you can see the new changes take effect.
    Last edited by purplewave; 2008-02-14 at 03:36 PM.

  7. #7
    gtryonp is offline Sugar Community Member
    Join Date
    Dec 2007
    Posts
    11

    Default Re: html fields

    Thanks for your reply, My PurpleWave. rigth now on the factory.

    About Mr Clint advice, I created a weblink field but in the listview doesnt seems to work (Does it only work in the detailview?)

  8. #8
    Billwobo is offline Sugar Community Member
    Join Date
    Mar 2008
    Posts
    33

    Cool Re: html fields

    Hey, I think this might help you, at least I hope.

    Steps to create a custom field with Sugar PHP parameters.

    1. Create a LINK field with enough characters. You can't just use a 'filler' by itself, it will cause it not to display.

    A link field will not create a database field, only in the PHP, so you save the creation of a field for no reason... An HTML field will also work.

    2. Put the new field in the Detail view of the needed module
    3. Save and deploy.
    4. Open the detailviewdefs.php file.

    File location

    * For a custom module: <sugarroot>\custom\modulebuilder\packages\PACKAGE_ NAME\modules\MODULE_NAME\metadata\detailviewdefs.p hp

    * For a Sugar Module: <sugarroot>\custom\modules\MODULE_NAME\metadata\de tailviewdefs.php


    5. Find the custom field you just created in the code...

    array (
    'name' => 'your_field_c',
    'label' => 'LBL_YOUR_FIELD',


    6. Put your custom Code underneath the 'label' line. In this fashion

    'customCode' => 'YOUR CODE...'


    So the whole field definition will look like this:

    array (
    'name' => 'your_field_c',
    'label' => 'LBL_YOUR_FIELD',
    'customCode' => 'YOUR CODE...'
    ),


    7. Save the detailviewdefs.php file.

    8. Do a Quick Repair & Rebuild for this particular module.

    9. Try the link or code in the detail view of the module. See if your code works...


    Please note

    1. If you need to do any changes to the code, you will need to do a Quick Repair on the Module.
    2. If you need to have the code field working in list view or edit view, you will need to put the code in listviewdefs.php and editviewdefs.php as well.

    Code Exemples


    Code for an IFRAME:

    array (
    'name' => 'your_field_c',
    'label' => 'LBL_YOUR_FIELD',
    'customCode' => '<iframe src="http://YOURPAGE.php?id={$id}" style=\"color:#0000FF;text-align:left\" height=\"400\" scrolling=\"yes\" width=\"100%\"></iframe>' ), ),


    Code for a link that passes a parameter:

    array (
    'name' => 'your_field_c',
    'label' => 'LBL_YOUR_FIELD',
    'customCode' => '<a href="http://YOURPAGE.php?id={$id}" style="color:#0000FF;text-align:left" target="_blank">THE LINK DISPLAY TEXT.</a>' ), ),



    Code for an IFRAME with google maps:

    It picks up the adress from the contact and sends it to google maps.

    array (
    'name' => 'your_field_c',
    'label' => 'LBL_YOUR_FIELD',
    'customCode' => '<iframe src="http://maps.google.com/maps?f=q&amp;hl=en&amp;geocode=&amp;q={$fields.pri mary_address_street.value}&nbsp;{$fields.primary_a ddress_city.value}&nbsp;{$fields.primary_address_c ountry.value}&ie=UTF8&z=12&iwloc=addr" style="color:#0000FF;text-align:left" height="500" scrolling="yes" width="100%"></iframe>'
    \\
    \\ For accounts adress, use {$fields.billing_address_street.value} or {$fields.shipping_address_street.value}

  9. #9
    Billwobo is offline Sugar Community Member
    Join Date
    Mar 2008
    Posts
    33

    Cool Re: html fields

    Oups, I didn't see that Mr. PurpleWave had answered you on this.

    Mr. PurpleWave, any comments on the way I do it? I'm not an experienced programmer either. I just pick up stuff here and there.

  10. #10
    clint's Avatar
    clint is offline Sugar Team Member | Forums Lead Moderator
    Join Date
    Aug 2004
    Location
    Silicon Valley
    Posts
    2,120

    Default Re: html fields

    Billwobo, this is a good tutorial you created here. You should post it in the Developer Tutorials forum.
    Sugar Developer Zone - developer resources | Sugar University - user and admin training
    Sugar Docs - user and admin documentation |
    Sugar Bug Tracker - Enter or view bugs
    SugarForge- open source modules, themes, lang packs | SugarExchange - commercial extensions

    Clint Oram
    Chief Technology Officer and Co-founder
    SugarCRM

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Adding HTML to fields
    By kirkholmes in forum Help
    Replies: 1
    Last Post: 2008-02-14, 04:48 PM
  2. Replies: 3
    Last Post: 2007-02-05, 09:43 PM
  3. Replies: 1
    Last Post: 2006-09-11, 03:38 PM
  4. Adding Custom Fields to a layout (3.5.1)
    By pSouper in forum Help
    Replies: 3
    Last Post: 2006-07-09, 02:10 PM
  5. new added fields don't appear
    By snue in forum Feature Requests
    Replies: 0
    Last Post: 2006-05-08, 08:19 AM

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
  •