Hi,
I’m trying to customize the view of a module, specifically the view of the Accounts module.
How can I insert custom code for a specific TAB in the view?
I created the TAB with Studio but now I would like to insert my own code.
From the file /custom/modules/Accounts/views/view.detail.php is it possible to add code in the display() method only for the tab I created with Studio?
You can load javascript to the page. Look at the file modules/Contacts/views/view.edit.php
as example.
As a variant you can edit custom/modules/Accounts/views/view.detail.php
manually and add to the field array customCode
.
Hi,
let me explain, I can customize the view but my goal is to customize the content of a tab, in the example the tab ‘Elinet’, how can I do that?
What do you mean by content of a tab? As a variants:
- add custom fields with custom code
- check some fields on a tab
- show different fields
- set buttons
- ect
For content of a tab I mean to be able to insert my php code that will be interpreted to populate the content of a specific TAB.
In the view.detail.php file I could modify the display() method eliminating the call to parent::display() and create my own TAB management, but this implies that I lose the actions menu and the buttons to scroll the tabs of the Companies.
So I prefer to create from Studio an empty tab and populate it with the data that interest me.
@web_elinet
There isn’t special mechanism working with tabs. I see three variants
- you create custom field type
custom/include/SugarFields/Fields/Specialtab
which has data processor and generate html code using smarty or without it. - you create custom Smarty function
custom/include/Smarty/plugins
and call it using arraycustomCode
for field indetailviewdefs.php
- insert the custom function into file
view.detail.php
. It will manipulate with$this->dv->sectionPanels
and calling it like this:
// your custom function
public function changeCustomPanel()
{
foreach ($this->dv->sectionPanels as $row => $columns)
{
// your code
}
}
public function display()
{
if (empty($this->bean->id))
{
sugar_die($GLOBALS['app_strings']['ERROR_NO_RECORD']);
}
$this->dv->process();
$this->changeCustomPanel(); // call your custom function
echo $this->dv->display();
}
Thanks for the suggestions,
I had tried to go with the third solution but checking the $this->dv->sectionPanels array I couldn’t figure out where to engage with the code.
I opted for a fourth solution, I insert via javascript the content I need directly into the tab panel.
parent::display();
?>
<script>
$('a#tab3').text('Hello');
$('#tab-content-3').html('<h2>Hello</h2>');
</script>
<?php
The code shown is only an example
@web_elinet
I wanted ask you about javascript but you wrote about php at once.
No problem, thanks