Change location of controller inside of Yii - yii

I want to change the location of my siteController from protected/controllers to protected/backOffice/controllers.
I have tried to do the following inside of the main config file but it gives me a CExxception error and its doesnt give the much of information
Unable to resolve the request "site/error". (C:\Users\steve\Sync\Frameworks\yii\framework\web\CWebApplication.php:286)
and i have the following inside of the import
'import'=>array(
'application.models.*',
'application.components.*',
'application.backoffice.*',
),
How i can do this i have found this little helper but still cant understand where i have to put it.
Link

According to your config file, it should look like:
'controllerPath'=>'protected/backoffice', <== Add this line
'import'=>array(
'application.models.*',
'application.components.*',
//'application.backoffice.*', <=== You don't need this
),
You can achieve the single controller in backoffice by:
Removing the controllerPath from main.php and add the following:
'controllerMap'=>array(
'booklet'=>array(
'class'=>'application.backoffice.Booklet', //<== Your controller name
),
),

Related

WHMCS how to find right tpl files in pages

i'm using WHMCS and i want to make some changes in part of the page but its so hard and takes so much time for me to find the right tpl file and edit it in the template.
for example for this "search for domains" tab in this url =>
example.com/cart.php?a=add&domain=register
where is the .tpl file.
For example.com/cart.php?a=add&domain=register the file is at templates/orderforms/standard_cart/adddomain.tpl
In general, when url has cart.php, the file in cart template.
Also, you can add the following to hooks to tell you which tpl file was used for current page.
1- Create file includes/hooks/tpl_locator.php
2- Add the following code:
<?php
add_hook('ClientAreaPage', 1, function($vars) {
error_log(print_r([$vars['currentpagelinkback'],$vars['templatefile']], true), 3, __DIR__.'/tpl_file_location.log');
});
3- Visit the page you want to know which tpl file is used.
4- Result will be at file includes/hooks/tpl_file_location.log, sample below:
Array
(
[0] => /cart.php?a=add&pid=1&
[1] => configureproductdomain
)
This was tested on WHMCS 8.0
The tpl for cart.php?a=add&domain=register is actually located at /whmcs/templates/orderforms/standard_cart/domainregister.tpl if I understand your question.

How to use a template view in prestashop?

I want to use an existing template in prestashop (product-list.tpl), i use this code in my module controller (method: initContent() ):
$this->setTemplate(_PS_THEME_DIR_ . 'templates/catalog/listing/product-list.tpl');
But prestashop return me that error :
[PrestaShopException]
No template found for C:\wamp64\www\prestashop/themes/classic/templates/catalog/listing/product-list.tpl
at line 68 in file classes/Smarty/TemplateFinder.php
Thank's you very much for you'r help !
The problem lies with the method setTemplate(), which is calling getTemplatePath(), a method that check if the desired template is located either in the module directory or in the module directory inside the current theme.
To make it work i would simply copy the product-list.tpl inside the directory :
"YourTheme"/modules/"Your module"/views/templates/front/

How to load module functions in custom Drupal theme

I'm not familiarly working with Drupal module. I installed,configured vegas module. There no problem in module. My actual question is how to i fetch module's PHP function in my custom.
For instance, vegas module only work on existing theme but it not working on my current theme (A known issue). I printed all images from inside vagas module and it gave me expected result.
print_r($backgrounds);
Array
(
[0] => Array
(
[src] => http://localhost/drupal/sites/default/files/vegas/slider1.jpg
)
[1] => Array
(
[src] => http://localhost/drupal/sites/default/files/vegas/slider1_0.jpg
)
[2] => Array
(
[src] => http://localhost/drupal/sites/default/files/vegas/slider1_1.jpg
)
)
My bad part is i cannot print that array inside my custom theme. How to get it.
Only the functions defined in module's .module file can be invoked from the theme. Please check if the function you are trying to use is in any other file of module.

app can't find module?

I am working on a project. It was fine until I installed new windows on my PC. But now project is same and when I access
Yii::app()->controller->module
It returns null. It also returns null for: Yii::app()->controller->module->id. When I viewed config file it had admin module in it. I don't know why is it's returning null. Can't find a way out.
Module in config file is like:
'modules' => array(
// uncomment the following to enable the Gii tool
'admin',
'gii' => array(
'generatorPaths' => array(
'bootstrap.gii'
),
'class' => 'system.gii.GiiModule',
'password' => '1234',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters' => array('127.0.0.1', '::1'),
),
),
When you access Yii::app()->controller->module then it will return the module that current controller belongs to. It returns null if the controller does not belong to any module. Please make sure the current controller you accessed which is belong to any module you configured.
You can see this link: http://www.yiiframework.com/doc/guide/1.1/en/basics.module to work with Module.
If you want to see which modules are loaded then use:
print_r(Yii::app()->getModules());
You are not 'in' a module and want to get a specific module (like admin module): you can do
Yii::app()->getModule('admin');

Yii multiselect widget

I have the following code that produces a jquery ech multiselect menu widget in Yii. (Eric Hynds multiselect).
I have downloaded the extension and unzipped in extensions folder
and my folder structure is My_lokal_Yii/protected/extensions/EchMultiSelect/EchMultiSelect
this is my view file code..
<?php $this->widget('ext.EchMultiselect.EchMultiselect', array(
'model' => $model,
'dropDownAttribute' => 'color',
'data' => $list,
'dropDownHtmlOptions'=> array(
'style'=>'width:378px;',
),
));?>
and in config/main.php i have imported the extension as
'import'=>array(
'application.models.*',
'application.components.*',
'application.extensions.EchMultiselect.*'
),
But i am getting error that "Alias "ext.EchMultiselect.EchMultiselect" is invalid. Make sure it points to an existing PHP file and the file is readable."
I have given all the permissions for the EchMultiselect file.
Please help me in this.. Thank you.. I tried a lot but did't get the exact result..
my folder structure is
My_lokal_Yii/protected/extensions/EchMultiSelect/EchMultiSelect
but in your config/main.php, there is:
... 'application.extensions.EchMultiselect.*'
------------------------------------^
It lacks the capital letter "s" and therefore the exact path/naming to/of your extension, I had the same "problem" with it ;-) , maybe it helps...
Greetings