PDA

View Full Version : Display the contents of PHP $_SESSION var



bozzoz
26 Jul 2010, 4:21 AM
Ok now i have designed my interface with one panel inside a viewport. In the panel I have one toolbar with button, menu and one simple text with welcome msg. How I can write the name of the user contained in the php var $_SESSION on the simple text of the toolbar?

The code of my interface:


applicationUi = Ext.extend(Ext.Viewport, {
layout: 'fit',
initComponent: function() {
this.items = [
{
xtype: 'panel',
title: 'Arta Abruzzo, gestione pratiche VAS',
style: 'padding:10px',
tbar: {
xtype: 'toolbar',
id: 'vas_menu',
items: [
{
xtype: 'button',
text: 'Pratiche',
id: 'vas_pratiche',
menu: {
xtype: 'menu',
items: [
{
xtype: 'menuitem',
text: 'Elenco pratiche',
icon: 'media/icon16/table.png',
ref: '../../../../ar_elenco_pratiche',
id: 'vas_elenco_pratiche'
},
{
xtype: 'menuitem',
text: 'Nuova pratica',
icon: 'media/icon16/new.png',
ref: '../../../../ar_nuova_pratica',
id: 'vas_nuova_pratica'
}
]
}
},
{
xtype: 'tbfill'
},
{
xtype: 'tbtext',
text: 'Benvenuto:',
ref: '../../ar_user',
id: 'welcomeMsg'
},
{
xtype: 'tbseparator'
},
{
xtype: 'button',
text: 'Admin home',
icon: 'media/icon16/home.png',
ref: '../../ar_admin'
},
{
xtype: 'tbseparator'
},
{
xtype: 'button',
text: 'Logout',
icon: 'media/icon16/logout.png',
ref: '../../ar_logout'
}
]
},
bbar: {
xtype: 'toolbar',
id: 'vas_status_bar',
items: [
{
xtype: 'tbtext',
text: 'Pronto',
width: 355,
height: 22,
ref: '../../ar_status',
id: 'vas_status_text'
},
{
xtype: 'tbseparator'
},
{
xtype: 'tbtext',
text: 'Author:',
ref: '../../ar_author',
id: 'vas_author'
}
]
}
}
];
applicationUi.superclass.initComponent.call(this);
}
});


thank you!

jarrednicholls
26 Jul 2010, 5:34 AM
Maybe this?



<script type="text/javascript">
Ext.onReady(function(){
var viewport = new applicationUi();
viewport.ar_user.setText("<?php echo $_SESSION["username"]; ?>");
});
</script>


replace "username" obviously with whatever your session variable name is. Hope that helps.

bozzoz
26 Jul 2010, 6:50 AM
Yes it's ok, thank you!