make variables available to an iframe in a module

trying to use $current_user->user_name in an iframe. cannot figure how to make extra variables available for a module iframe.
I’m trying to put the logged-in user name in the url for an iframe in a detail view for Contacts. Absolutely no luck yet.
One work-around is to put the whole iframe tag in custom/modules/Contacts/metadata/detailviewdefs.php as customCode
I added an iframe using studio, then I edit detailviewdefs.php. I find the name of my iframe (‘quotes_c’ in this case) and add the customCode line. the {$fields.recid_c.value} brings in a variable available to the module. The ‘.$current_user->user_name.’ is the variable I cannot access directly from studio.
like this:

array (
            'name' => 'quotes_c',
            'customCode' => '<iframe src="http://digitaldeltec/designer/projectlist.php?&recid={$fields.recid_c.value}&goldmineid='.$current_user->user_name.' " style="height:500px; width:100%;"></iframe>',
            'label' => 'LBL_QUOTES',
),

Problem with this is, using studio will rewrite this file and delete the ‘.$current_user->user_name.’ portion or replace it with the value hardcoded into the url.
Any eye-openers would be helpful. thanks

Ha, figured it out!
I was wanting this variable to be available in all detail iframes…so…
I made custom/include/SugarFields/Fields/Iframe/DetailView.tpl
and added:

{capture assign=link}{$link|replace:'[current_user_user_name]':$current_user->user_name}{/capture}

thus giving me access to $current_user->user_name via the smarty var {current_user_user_name}

whew!

You might want to check out this different way to do it

https://www.suitecrm.com/forum/suitecrm-7-0-discussion/16297-iframe-field-how-to-embed-externale-web-page-with-context

Yeah, read that one already… but does’t seem that logged in user_name is available. I could only get it from $current_user (in this case $current_user->user_name)
if you try using an unavailable var in the url string it just replaces curly brackets with regular brackets
Pretty sure I found the way to do it.
Although… please enlighten if I’m missing something.
…and THANK YOU for responding

Ok, I understand your post better now - adding the missing var.

Thanks for sharing, nice solution.