Results 1 to 8 of 8

Thread: custom PHP integration

  1. #1
    alex3232 is offline Senior Member
    Join Date
    May 2009
    Posts
    73

    Question custom PHP integration

    Hi,

    I'm new to Sugar and I've gone through the Developer Guide 5.2 just recently...
    I've a very simple PHP code, and I just need a quick reference and some clue on how to include it into Sugar

    For instance having a page like "Hello Word" which files shall I modify to include it into the new Tab "Welcome" ?

    many thanks

  2. #2
    sapmin is offline Sugar Community Member
    Join Date
    Sep 2007
    Location
    USA
    Posts
    69

    Default Re: custom PHP integration

    Could you explain why you want to change the code instead of using the Studio or Module Builder?

  3. #3
    alex3232 is offline Senior Member
    Join Date
    May 2009
    Posts
    73

    Default Re: custom PHP integration

    Module Builder is great to create custom modules from within SugarCRM but, in my case , I already have a small application which create and print Invoices and I just need to include that into Sugar .
    Could you please give me some clue on this..

    many thanks

  4. #4
    lucasnomail is offline Member
    Join Date
    Nov 2009
    Posts
    15

    Default Custom PHP integration

    Hi. I would have two suggestions for you. Try to play with what module builder creates for you and pick how it creates it on the way. 2. Get yourself (I don't care how ;o) THE BOOK "The definitive Guide to SugarCRM" it is a must for what you are tring to do. Trust me on that I started studying sugarCRM some time ago and picking clues from around the network is just realllllllllly slow process. Btw Developers documentation is also great source but requires much, much (have I said that ?), much more reading..
    But if you want to put some PHP into your application right now try this (but beware that is not clean,acceptable,intelligent,really useful way - oh and don't tell anyone I told you):

    1. create your (package and inside) Module in Module builder (save,deploy!). (this takes less than minute)
    2. go to custom/modules/<packageKey_moduleName>/
      if it doesnt exist create it (btw this won't work if you haven't done the first step) packageKey is the 3letter prefix from step 1
    3. create file index.php
    4. put inside your php code like (or something from below "Some more ugly php")
      PHP Code:
      <?php 
      echo 'helloworld';
    5. go to your sugarCRM and then find Tab of Module you created by module builder probably will be under Others if not go to url like below and add it
      Code:
      index.php?module=Administration&action=ConfigureTabs
      5.(version2) or just login to your sugar and after you login put to address bar something like this
      Code:
      index.php?module=packageKey_moduleName&action=index


    Some more ugly php
    to get forms working this(ugly,ugly) way you will need to hack around the action in the form and URLs it might be
    Code:
     index.php?module=packageKey_module&action=index
    or
    Code:
    custom/module/<packageKey_module>/index.php?module=packageKey_module&action=index
    or maybe something like this would take you closer (try yourself but THE BOOK would show you how to do it the sugar-way)

    PHP Code:
    echo '<form action="index.php" method="get">';
    echo 
    '<input name="module" type="hidden" value="packageKey_module"/>';
    echo 
    '<input name="action" type="hidden" value="index"/>';
    echo 
    '</form>'
    anyway here is my last idea about "hacking to the system the ugly way" and I'm sure you will love it
    PHP Code:
    var_dump($current_user);
    var_dump($sugar_config); 
    Are you asking yourself where to get more of dumpAble variables? look in all php files for
    Code:
     global $current_user;
    "where is one usually are others as well"

    that is all.
    to create module from scratch you need a lot of reading and bit of understanding, there is no easy to do way even templates if you find them on this forum needs lot of changes.

    hope some of what I wrote helped.
    Last edited by lucasnomail; 2009-12-04 at 02:37 PM. Reason: improvement

  5. #5
    vbondoux is offline Sugar Community Member
    Join Date
    Feb 2007
    Posts
    50

    Default Re: custom PHP integration

    lucasnomail, since 1 year I was searching your answer, nobody explain that with this simplicity. So many thanks, my sugar Universe has been transformed !

  6. #6
    alex3232 is offline Senior Member
    Join Date
    May 2009
    Posts
    73

    Default Re: custom PHP integration

    Hi Lucas,

    GREAT answer, I got the book
    many thanks

  7. #7
    ilke_etf is offline Member
    Join Date
    Dec 2009
    Posts
    5

    Default Re: custom PHP integration

    First of all, sorry for my bad english.
    Ok, is there another way to access custom php page?

    Is it possible to have some custom php page within one tab in sugarcrm where i could have some of my stuff like and be able to access directly by clicking on the link and not by typing in browser:

    Code:
     index.php?module=packageKey_module&action=myphppage
    I think this option with typing it in browser is very user hostile. It must be another solution

    thanks in advance
    Last edited by ilke_etf; 2009-12-09 at 08:04 AM.

  8. #8
    lucasnomail is offline Member
    Join Date
    Nov 2009
    Posts
    15

    Default Re: custom PHP integration

    Try following
    But you should realize few things
    Code:
    Tabs Group == (collection of modules or tabs if you want)
    Code:
    Tab == module == Module
    Code:
    (inside module resides) Action == View
    about tabs you can find more HERE
    if after review the post about tabs you are sure tabs are not the way for you,than try this(not tested)

    create
    Code:
    custom/module/<packageKey_module>/controller.php
    PHP Code:
    class packageKey_moduleController extends SugarController
    {
        function 
    action_myphppage()
        {
            
    $this->view 'myphppage';
        }
        function 
    action_myphppage2()
        {
            
    $this->view 'myphppage2';
        }
         function 
    action_index()
        {
            
    $this->view 'index';
        }

    after that maybe create this
    Code:
    custom/module/<packageKey_module>/views/view.index.php
    or this(but this maybe overrides controller)
    Code:
    custom/module/<packageKey_module>/index.php
    inside put this
    PHP Code:
     $page '<h1>Navigation page</h1>
    <a href="index.php?module=packageKey_module&action=myphppage">My Page</a>
    <a href="index.php?module=packageKey_module&action=myphppage2">My Page2</a>'
    ;
    echo 
    $page
    and than create these pages(from navigation)
    Code:
    custom/module/<packageKey_module>/views/view.myphppage.php
    PHP Code:
    your php here 
    Code:
    custom/module/<packageKey_module>/views/view.myphppage2.php
    PHP Code:
    other php 
    if this isn't working be polite and share your solution

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Opinion Wanted - Integration with custom App
    By architect3145 in forum Help
    Replies: 2
    Last Post: 2009-11-29, 11:56 AM
  2. Sugar CRM integration with custom PHP applications
    By gopalkalasa in forum General Discussion
    Replies: 4
    Last Post: 2008-12-24, 03:49 AM
  3. Need help on custom appllication integration
    By sjilumudi in forum Developer Help
    Replies: 4
    Last Post: 2007-04-20, 02:18 PM
  4. Help Needed - Custom Joomla Integration
    By tibbeeshock in forum Classifieds
    Replies: 0
    Last Post: 2006-06-11, 08:52 PM
  5. Custom Mambo/Sugar Integration South Florida
    By atapi in forum Classifieds
    Replies: 0
    Last Post: 2005-03-21, 02:07 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
  •