I have two custom modules: cm_product, cm_item
with one to many relationship: cm_product -> cm_item
I want to disable the search page for cm_item, so the only way to see the items for customer is through it's parent reference: cm_product.
I need to accomplish it through the code.
This is my temporary solution if somebody interested in, file - custom/modules/cm_item/views/view.list.php:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once 'include/MVC/View/views/view.list.php';
class cm_itemViewList extends ViewList
{
public function preDisplay() { }
public function display() {
echo <<<HTML
<h1>Por favor seleccione la Oportunidad para ver sus correspondientes ventas e items.</h1>
HTML;
}
function prepareSearchForm(){ }
function listViewProcess(){ }
}
SugarCRM VersiĆ³n 6.5.11 (Build 8754) Pro edition.
it can be possible via add the blank array line at the end of file i.e.
custom/modules/cm_item/metadata/searchdefs.php
$searchdefs[$module_name] = array();
It sounds like you really just need the module tab for cm_item that links to the search and list view to not be displayed so that cm_items are only accessible through the subpanel of a cm_product. To do that you don't need code (unless you are doing it in a distributable module). Simply drag the cm_item module to the Hidden Modules list in Admin->Display Modules and Subpanels. If you are mass distributing the module then you would set tab to true in the beans definition in your manifest.php (see http://support.sugarcrm.com/04_Find_Answers/03_Developers/Module_Loader/Introduction_to_the_Manifest_File#tab)
You can remove the top module menu link by making sure the module isn't listed in the global array $moduleList
Related
Working with typo3 v 10.4, I have the requirement of some back-end user groups not to be allowed to move pages around. I was able to hide the arrow-actions shown in the page list view using the RecordListHookInterface. But drag and drop in the page tree still allows moving pages. Is there any TypoScript setting I can use to disable drag 'n' drop functionality of the page tree?
Unfortunately, there is no TypoScript configuration for this. But this can be done extending the "TreeController" from core with the "XClass" method:
<?php
namespace My\Namespace\XClass;
use TYPO3\CMS\Backend\Controller\Page\TreeController;
class XPageTreeController extends TreeController {
protected function isDragMoveAllowed(): bool {
if (!parent::isDragMoveAllowed()) {
return false;
}
$beUser = $this->getBackendUser();
return $beUser->isAdmin() || $beUser->isMemberOfGroup(123)
|| $beUser->isMemberOfGroup(234);
}
}
XClasses must be registered in the ext_localconf.php like so:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][TYPO3\CMS\Backend\Controller\Page\TreeController::class] = [
'className' => My\Namespace\XClass\XPageTreeController::class
];
Note that extending core classes has some disadvantages. For example, when switching to a newer Typo3 version, functionality might silently fail.
Using the infos in this link:
https://docs.typo3.org/typo3cms/ExtbaseFluidBook/8-Fluid/9-using-php-based-views.html
I try to create an action to output a JSON.
I have a normal controller with the list action:
public function listAction()
{
$storelocators = $this->storelocatorRepository->findAll();
$this->view->assign('storelocators', $storelocators);
}
And in ext/my_storelocator/Classes/View/Storelocator I have a class List.php:
<?
class Tx_MyStorelocator_View_Storelocator_List extends Tx_Extbase_MVC_View_AbstractView {
public function render() {
return 'Hello World';
}
}
All I get is:
Sorry, the requested view was not found.
The technical reason is: No template was found. View could not be resolved for action "list" in class "My\MyStorelocator\Controller\StorelocatorController".
So I guess there is something wrong with the paths. Or where is the Problem?
Edit: Extensioninfos
Vendor: My
key: my_storelocator
controller: NOT SURE (I created it with the extension_builder so I guess my controllers name is Storelocator)
action: list
From my understanding a classname like Tx_MyStorelocator_View_Storelocator_List should be correct. But its not working
You will need to create an empty file for the HTML view for your controller, e.g. Resources/Private/Template/Storelocator/List.html, even if you do not plan to use the HTML view or if you just return the content yourself (which is perfectly fine).
The reason for this is simply technical limitation.
First of all, TYPO3 now has a built-in JSON view, described thoroughly here: https://usetypo3.com/json-view.html. It lets you easily define which properties you'd like to render.
The error message means that your Controller is still pointing to the TemplateView - because thats the error the TemplateView throws if it can't find the defined template file.
You can specify which view to use to render within your controller. You can either set a default view via the $defaultViewObjectName property, like so:
/**
* #var string
*/
protected $defaultViewObjectName = '\TYPO3\CMS\Fluid\View\TemplateView';
You can also set it from within the Controller inside initialization actions like so:
public function initializeExportPDFAction(){
$this->defaultViewObjectName = 'Vendor\Extension\View\FileTransferView';
}
(I have, however, not yet found a way to define the template from within actions, any tips in the comments would be appreciated)
Your path syntax is probably out of date. Instead of writing a render() function in Classes/View/Storelocator/List.php, try writing a listAction() function in a Classes/Controller/StorelocatorController.php file. Extension Builder should have created this file for you, if you made an aggregate model with the usual "list, create, edit ..." and such actions.
Review A journey through the Blog Example and the following chapter, Creating a first extension, for tips.
Keep in mind that there is a mismatch between the documentation and the Extension Builder generated PHP code files. Developing TYPO3 Extensions with Extbase and Fluid has some parts up to date, and other parts still using old syntax.
I want to show some customized content in the left panel which usually contains the treeview.
As the stuff in this panel will be an editable Gridfield wich should be related to the EditForm, I tried to built a new EditFormTools panel in this way:
I copied the CMSMain_Content.ss in mysite/templates/Includes and changed $Tools into $EditFormTools
I created the file CMSMain_EditFormTools.ss in the same directory with this code:
<div class="cms-content-tools west cms-panel" data-expandOnClick="true" data-layout-type="border" id="cms-content-tools-CMSMain">
<div class="cms-panel-content west">
<% include Test %>
</div>
</div>
I created a Test.php with:
class Test extends CMSMain{
public $var = 'test';
public function testfunction(){
$variable = 'hakuna matata';
return $variable;
}
}
Then I created a Test.ss with this code:
some Text
$var
$testfunction
$variable
The Panel appears in my CMS now but it only contains "some Text". So the include of Test.ss works perfectly fine but passing variables from Test.php to Test.ss doesn't.
Can anybody help?
Greetings
It may not directly answer your question but may give you direction.
You need to extend a controller class.
Then you can use a called functions to tell controller which template file it should use using renderWith().
for example,
public function index(){
return $this->renderWith("Test");
}
Then your function references in Test.ss will call functions in Test.php given it is the controller.
If Test class is not the controller rendering the template, the template doesnt know where your variable returning function is.
By the way, you can pass variables from layout to include template.
I created a model in SugarCRM and I need to print the details view. But this must be printed with a different layout.
It must have the company logo for example, if I just wanted do print the bean information, the default print would be sufficient, but I need something closer to a report, because this info will be given to the costumer.
I would like to know if there is a way to create a printing template, and if there is, how can I create one?
Thanks for your help, if you need more information please comment.
rfnpinto
Even in SugarCRM CE you can leverage the included Sugarpdf class, which is an extension of TCPDF.
If you have SugarCRM Professional you can find examples of this in the Quotes module. If not, you're flying blind, so I can give you the gist of it.
Using the Contacts module as an example, create /custom/modules/Contacts/views/view.sugarpdf.php with contents like the following:
<?php
require_once('include/MVC/View/views/view.sugarpdf.php');
/**
* this defines the view that will drive which PDF Template we use
*/
class CustomContactsViewSugarpdf extends ViewSugarpdf{
public function display(){
$this->sugarpdfBean->process();
$this->sugarpdfBean->Output($this->sugarpdfBean->fileName,'D');
sugar_die('');
}
}
Create /custom/modules/Contacts/sugarpdf/sugarpdf.pdfout.php with contents like the following:
$contact = BeanFactory::getBean($_REQUEST['record_id']);
if(empty($contact->id)){
sugar_die('Could not load contact record');
}
$name_str = "<p><strong>Name: {$contact->name}</strong></p>";
$this->writeHTML($name_str);
$this->drawLine();
}
function buildFileName(){
$this->fileName = 'ContactPDFOut.pdf';
}
}
From there, you can print a PDF document per your format if you hit the URI index.php?module=Contacts&action=sugarpdf&sugarpdf=pdfout&record_id=1234
Once that's working in the way you want, you can add a button the Contacts Detailview to access that URI more easily. Dig into /custom/modules/Contacts/metadata/detailviewdefs.php and find the existing buttons array. It'll look something like this:
'buttons'=>array('EDIT', 'DUPLICATE', 'DELETE', 'FIND_DUPLICATES'
Just enhance this with your own button and hidden input
'buttons'=>array('EDIT', 'DUPLICATE', 'DELETE', 'FIND_DUPLICATES',array(
'sugar_html'=>array(
'type' => 'submit',
'value' => '(Wrongfully Hardcoded Label) Print PDf',
'htmlOptions'=>array(onclick => 'this.form.action.value=\'sugarpdf\';this.form.sugarpdf.value=\'pdfout\'')
)
)
...
The hidden array should be part of $viewdefs['Meetings']['DetailView']['templateMeta']['form'] and defined like so:
'hidden' => array('<input type="hidden" name="sugarpdf">'),
I haven't tested this recently but this is the general idea of adding custom Print PDF abilities to any particular screen within SugarCRM. TCPDF options are pretty extensive and forming the template just right is going to be very tedious, but I think once the "plumbing" is working here you'll figure that bit out, but feel free to ask followup questions.
I want to remove the Modules Tab (module list and sub-module list) from my custom module.
I have tried some solutions but in vain. e-g:
options['show_header'] = false;
It removes all header but I want to remove Logo and Global Links.
Disable all modules and change "tab=>false" in manifest.php file of custom module.
There's not an official way to do this through the configuration or anything, but you could use a custom logic hook for this to inject some javascript to hide the module list.
Say your custom module is abc_CustomModule, create a logic_hooks.php or add to it if it doesn't exist custom/modules/abc_CustomModule/logic_hooks.php
<?php
$hook_version = 1;
$hook_array = Array();
$hook_array['after_ui_frame'] = Array();
$hook_array['after_ui_frame'][] = Array(1, 'Hide Modules', 'custom/modules/abc_CustomModule/abc_CustomModule_custom.php','abc_CustomModule_custom', 'hide_modules');
At the end of each page load for your custom module, it'll run the following code in custom/modules/abc_CustomModule/abc_CustomModule_custom.php
<?php
class abc_CustomModule_custom
{
function hide_modules($bean, $event)
{
echo "<script>$('#ajaxHeader').hide()</script>";
}
}
This simply outputs some javascript that will hide the div that contains the modules.