This topic is locked
[SOLVED]

 How to dynamically hide menu, breadcrumbs, blocks etc when using page as an iframe

5/9/2018 3:42:02 PM
PHPRunner General questions
G
Galco author

Hi.
I would like to be able to use the same page design in different formats, within an application and also as iframes within other external web pages.

  1. Normal with Menus and Breadcrumbs.
  2. No Menus or Breadcrumbs - for use within an iframe.
    I know I can use a different template to achieve the result, editing Layout and calling 'bootstrap1_iframe_only' as follows:

@version=3

@template=bspage1

beginblock center

begincontainer column center

begincontainer align=left bsgrid grid

brick bsgrid

endcontainer

endcontainer

endblock


So I would like to get a URL variable such as iframe=yes and HIDE BLOCKS in a similar way as hiding fields or alternatively selecting a different template dynamically.
How can I achieve this?
Thanks.

admin 5/10/2018

This can be done but you need to be looking into HTML source of the page on Visual Editor.
For instance, here is the block that defines breadcrumbs:

{BEGIN breadcrumbs}

<OL class="breadcrumb">

<LI>

<A href="{$home_link}">

<SPAN class="glyphicon glyphicon-home">

</SPAN>

</A>

{$crumb_dropdown}

</LI>

{BEGIN crumb}

<LI class="{$crumb_item_class}">

{BEGIN crumb_title_link}

<A {$crumb_attrs}>

{$crumb_title}

</A>

{END crumb_title_link}

{BEGIN crumb_title_span}

<SPAN {$crumb_attrs}>

{$crumb_title}

</SPAN>

{END crumb_title_span}

{$crumb_dropdown}

</LI>

{END crumb}

</OL>

{END breadcrumbs}


What comes after BEGIN is a block name (breadcrumbs). To hide this block all together add the following code to BeforeDisplay event:

$xt->assign("breadcrumbs", false);
G
Galco author 5/11/2018

Thank you.
Working code:
Before Process:

if(isset($_GET['iframe']) AND $_GET['iframe'] !== '' )

{ $_SESSION['iframe'] = $_GET['iframe'];}

Else { unset($_SESSION['iframe']);}


Before Display:

if($_SESSION['iframe']=='y')

{

$xt->assign("container_menu", false); // Turn off container_menu

$xt->assign("breadcrumbs", false); // Turn off breadcrumbs

}