Vtiger CRM: How I can load modified .tpl file? - file

I want to load a modified .tpl file vtigercrm\layouts\vlayout\modules\Vtiger\ListViewContents.tpl to a .php file from which I get HTML data after using AJAX and javascript . It's something feasible?

Im assuming that you want to view that template in the DetailView. In that case you can make a widget in module/Vtiger/models/DetailView.php in getWidget(). Just copy paste and change. The link you give here should go to a function in /module/Vtiger/views/Detail.php.
you should add your new function in the constructor.
$this->exposeMethod('Yourfunctionname');
Here you can copy any function and change it. you need to feed your variables to smarty with :
$viewer->assign('SMARTYVARNAME', $phpVar);
to fill the template. And finally you need to referance the template.
echo $viewer->view('tplname.tpl', $moduleName, 'true');
im not able to comment yet so i hope this is enough.

Related

Add javascript file at the end of the script block

i am using cakephp 3.7 and i load few .js file in my default.ctp layout. The problems comes when i try to add other .js in my view. These js files are added at the beginning of the js file list.
I do echo $this->fetch('script'); to print that block.
For example, i am using jquery, i load this library in default.ctp because i use it everywhere, the problem is that view js are loaded before jquery so i cannot use $
how can i "append" to script block, inside an action's view?
Thanks
In your layout put (before < /head> if you wish)
$this->fetch('my_head_script')
, then in your view use
$this->Html->script("jquery.js",['block' => 'my_head_script']);
Did You use script blocks, described here: https://book.cakephp.org/3.0/en/views/helpers/html.html#creating-inline-javascript-blocks?

Angularjs, how to structure my code across multiple files

I'm new to AngularJS and have a question regarding the structure of AngularJS.
Here is a simple working Plunker example I was working on, which displays the map.
So my question is:
how do you separate out <mapbox callback="callback"></mapbox> if I want to create a file in the view folder instead of putting it into app.js?
I have tried creating a show.html file inside of my view folder and pasted that line of code, but it didn't work.
Should I change 'template': '<mapbox callback="callback"></mapbox>' to
templateUrl: 'views/show.html'?
Your help is greatly appreciated.
Yes. I slightly modified your plunker to show how can you can do it.
http://plnkr.co/edit/Fpst5cd6gfIh30eOk447
Basically, what I did there was to create a new html file, name it mapbox.html and paste the html template there from app.js. Afterwards, I edited the app.js config block to use the templateUrl property pointing to the new file above and deleted the template property one, et voilĂ !

Load files that aren't within the Elements or View folders?

Hi I'm trying to make something like CMS with widgets so I have a folder widgets in my app folder there are my widgets for example app/Widgets/UsersOnline/UserOnline.php
I loading them from db with widgets model in beforefilter method in appController and there i pass them to the view, so with a widget helper I would like to render them on the position. But i can't get to the folder widgets/UserOnline/view.ctp with view->element() method this method require file to be in Elements/.
TLDR / Actual Question:
Is there any way to load files in view outside the view/ and /elements ? Thanks in advance.
You can use relative paths when calling the element:
<?php echo $this->Element('../../Widgets/UsersOnline/UserOnline'); ?>
Don't forget to name your element file 'UserOnline.ctp' too.

cakephp v2 layout not loading

Hi I want to add a new layout to my cakephp, but somehow the system keeps looking in the view folder from the controller instead of the /app/View/Layouts folder.
Error: The view for TestsController::desktop() was not found.
Error: Confirm you have created the file: /app/View/Tests/desktop.ctp
the desktop.ctp file is in /app/View/Layouts. The same place as the default.ctp
The code in the controller is:
public function desktop() {
$this->layout = 'desktop';
}
What is wrong here? I don't understand why cakephp keeps looking in the view/controller-name folder... I need this fixed because I want to use this layout for other controllers. Thanks.
If you read the message carefully, you'll see cake is telling you it cannot find your view, not your layout.
So, create an empty /app/View/Tests/desktop.ctp and see what happens. I'm hoping magic.. :)

How do I add an script to all actions of a controller?

I have an script file called 'game.js' which I want to add to all actions inside game_controller.php.
I think there is a better solution than copy and paste "Html->script('game', array('inline' => false)); ?>" inside all my ctp files. How do I do that?
I suggest that you create a sperate layout for given pages and put the script in the layout. If you simply MUST do this, then you can use the beforeRender() method like so:
cakephp: can I set $scripts_for_layout from within a controller?

Resources