SuiteCRM into iframe without top menu and sidebar

Goodmorning,
Is there the possibility to integrate SuiteCRM into iframe, limiting navigation within the CRM, for example by removing the sidebar on the left and the menu at the top?

So we would like to have an iframe that shows a particular entity (an Account, or Contact) and navigate only the entities connected.

Thank you in advice for tips.
B

Hhmm it might be difficult. But have a look at this:

Those are quite low-level settings that apply to every view in SuiteCRM. If you turn off those elements, then the page generation won’t output them.

You can find many examples of this being tweaked in several points in the code. For example, when there are AJAX calls, only a simple JSON output is desired, not a full HTML page. Or in other places the menus are turned off for some reason.

If you can build a complete solution please share it here when you’re finished! :wink:

Thank you for your reply, I tried to follow your tip, but if I set show_header = false, I lost the page shows informations without css. I think that is not the correct point to do this.

I found a point, into tpl, where I can insert my condition to show/hide ajaxHeader div in themes/SuiteP/tpls/header.tpl
but I’m not sure that is the correct way, and that all cases are cover

I would like hide sidebar and top navigation bar just when the page is show into my iframe (maybe using a custom parameter in the URL) in the other cases, the bars must show.
in your opinion is it possible to do into tpl? can it be a valid solution?

Thank you
B

I guess the displayHeader function should be more fine-grained to allow removing the top menus, but not the CSS…

The test for the option is made here:
https://github.com/salesagility/SuiteCRM/blob/master/include/MVC/View/SugarView.php#L217
And the function is this big chunk of code:
https://github.com/salesagility/SuiteCRM/blob/master/include/MVC/View/SugarView.php#L386

I think your tpl approach can be fine, you can create a custom tpl file, just try to get a condition that works only for this case.

Thank you so much for your tip. Today l’ll try to implement this solution:
1: add a custom parameter into URL open into iframe
2: into displayHeader method, check if the parameter exists and if true, invoke my custom header.tpl instead the standard header.tpl.

I told if this solution is fine for me.
Thank you so much
B.

1 Like

Hi @pgr,
My solution works at half. :confused:
It is ok, only for first page that will be visited. For example if I am into a contact detail, if I would like go to account, I loose my custom parameter and when arrive in the account detail, I unfortunately have the navigation bars.
I tried to use a global variable that I set with value = true, only if in the request I have my custom parameter. In the other cases I do nothing.
Maybe I’m not in the correct place to made this, but I don’t know.
Any suggestions?
Thank you
B

Have you tried saving it in a SESSION variable? I think these are all handed on from one request to the following request…

Thank you so much, it works! :wink:

:sunglasses: cool, I’m glad you got it working!

Maybe you can share your solution here in case anyone else comes looking for this in the future? Thanks!

Sure!
into: include/MVC/ViewSugarView.php
in displayHeader method substitute

$headerTpl =  $themeObject->getTemplate('header.tpl');

with:

if (isset($_REQUEST['fromIframe']) && $_REQUEST['fromIframe'] == true) { 
                            $_SESSION['fromIframe'] = true;
}
$headerTpl = isset($_SESSION['fromIframe']) && 
                   $_SESSION['fromIframe'] == true ?
                                  $themeObject->getTemplate('tHeaderIframe.tpl') :  
                                  $themeObject->getTemplate('header.tpl');

Create a custom tpl “tHeaderIframe.tpl” into /themes/SuiteP/tpls that is a clone of header.tpl into the same folder and substitute:

{if $AUTHENTICATED}
    <div id="ajaxHeader">
        {include file="_headerModuleList.tpl" theme_template=true}
    </div> 
{/if}

with

{if false}
    <div id="ajaxHeader">
          {include file="_headerModuleList.tpl" theme_template=true}
    </div> 
{/if}
2 Likes

Hi @pgr,
I opened a topic last week, but nobody answer :cry:
Can you help me?
This is the topic:

Thank you so much in advice.
B.

Hi @pgr!
I change my implementation and I opted for a javascript that check:
I add in /custom/themes/SuiteP/js/style.js file, follow code:

$(document).ready(function () {
try {
    console.log('SuiteCRM is open into an IFrame: ', window.self !== window.top);
    if (window.self !== window.top){
        var element = document.getElementById('ajaxHeader');
        element.parentNode.removeChild(element);
        var mainContent = document.getElementById('bootstrap-container');
        mainContent.setAttribute("margin",0);
        mainContent.setAttribute("class","col-md-12");
    document.getElementByTagName("footer").className = "collapsedSidebar";
	 
    }
} catch (e) {
    console.log('SuiteCRM check open into an IFrame error');
}
});
1 Like