I used Drupal 6 and admin menu module. Im need hide admin menu in admin panel. I write module, but it doesn't work. Help me please
Module code:
<?php
/**
* Implements hook_init().
*/
function YOURMODULE_init() {
global $theme_key;
if ($theme_key == 'rootcandy') {
module_invoke('admin_menu', 'suppress');
}
}
?>
The problem is that the theme globals aren't set by the time you're referring to them in hook_init(). You could call theme_init() before you check for the $theme_key value, but I'm not sure if this has unintended side-effects.
Related
I am trying to add a hook in my custom module but it is not fired after I add a customer both in prestashop backoffice or by using the webservice.
The hook name I am trying to register is "actionCustomerAccountAdd".
This is the relevant code of the module. Please could you help me? I am a PHP developer but it is the first time I develop in Prestashop side.
/**
* Don't forget to create update methods if needed:
* http://doc.prestashop.com/display/PS16/Enabling+the+Auto-Update
*/
public function install()
{
return parent::install()
&& $this->createRequiredDBTables()
&& $this->registerHook('actionCustomerAccountAdd');
}
I have this code to check in logs files or page but it is not fired:
public function hookActionCustomerAccountAdd($params)
{
$this->logger->info('Hook action customer account add fired');
echo 'hook fired';
die();
}
Thank you.
The thing is that hook actionCustomerAccountAdd is fired only on front-office, you will need to use actionObjectCustomerAddAfter, dynamic hook executed in classes/ObjectModel.php
I have created one custom submenu inside the lead menu as "Process Leads" and now i want to call one custom function with the help of that menu item. i have defined it as:
$menu_item[]=Array("index.php?module=Leads&action=callCustom", "Process Leads", "");
Now the question is that where should i have to defined this callCustom function in the code?
index.php should never be changed in SuiteCRM - its a framework not a simple php script. So you have a proper way to do things.
Now to the code.
Actions are defined in the controller, in your case its the Lead module.
What I usually do is go to modules/Leads folder and I copy controller.php to custom/modules/Leads.
Edit the file and create your custom action like
function action_customaction() {
global $mod_string;
if (isset($_REQUEST['yourParameter'])) {
// Your awesome code here
}
}
Good luck with that
I was unable to login to wp-admin "You don't have sufficient privileges" so I added this code to my themes functions.php
/*
* Add your own functions here. You can also copy some of the theme functions into this file.
* Wordpress will use those functions instead of the original functions then.
*/
function codelight_all_permissions( $allcaps, $cap, $args ) {
$allcaps[$cap[0]] = true;
return $allcaps;
}
add_filter( 'user_has_cap', 'codelight_all_permissions', 0, 3 );
Then I was able to get in as site admin, I went to users and noticed there are no roles assigned. In the database I have level 10 and a:1:{s:13:"administrator";s:1:"1";} assigned.
If I create a new user I cannot choose a role for that user from the dropdown. I only get the option "No role for this site". Does anyone know how I can troubleshoot this issue?
i am making a online book store in codeigniter.when user logging in, i am using
localhost/folder/index.php/User_controller.
my qustion is when admin is logging in one extra menu should come for approval, rest of the view is same as that of user.so what should i do,when i make seperate controller in different application folder,i have to run different in url, ie localhost/foldername/admin.php/admin_controller
.i am really confused.please help............
You can build a custom library where you may write function for checking if_admin(). After that you can use this function in any view file or controller and load content as required.
Create Custom Library
So doesn't need to create different controller for admin. Just check with is_admin() in menu to load extra menu.
A demo method is look like (in custom library)
public function is_admin() {
$type = (int) $this->CI->session->user_type;
if ($type === 4) {//4 is admin type
return TRUE;
} else {
return FALSE;
}
}
Now check in view file as
if($this->custom_lib->is_admin()){
//load extra menu items
}
I'm writing my own module and the essential option is to control controller from the module options.
I know how to control tpl and js via module options but I can't get the way to control Prestashop controller from the module php file.
Simply I want to know the way how to do it.
I want to have four checkboxes with options to enable or disable module in four controllers like index, cms, category, product.
I have right now:
$values = array('index','product','cms','category');
if(in_array(Tools::getValue('controller'), $values)){
return $this->display(__FILE__, 'mymodule.tpl');
}
And this code display tpl file content in this four controllers in homepage (index), cms, category and the product pages.
But how to put there some trigger to enable/disable values from the array?
Make a configuration field for the controllers:
public function getContent()
{
if (Tools::isSubmit('MY_CONTROLLERS_LIST')) {
Configuration::updateValue('MY_CONTROLLERS_LIST', (string)Tools::getValue('PS_MY_CONTROLLERS'));
}
$value = Configuration::get('MY_CONTROLLERS_LIST');
return '<form action="" method="POST"><input name="PS_MY_CONTROLLERS" value="'.$value.'"><input type="submit" value="Save"></form>';
}
public function hookDisplayTop()
{
$value = Configuration::get('PS_MY_CONTROLLERS');
$controllers = explode(',', $value);
if(in_array(Tools::getValue('controller'), $controllers)){
return $this->display(__FILE__, 'mymodule.tpl');
}
return false;
}
This will appear in Modules > Modules > Configure (of your module). There are form helpers which can render PrestaShop forms, but this is simplified example showing that you will need aform that submits to the same page.
Controllers value for this example should be index,category,cms,product.
Another way
Go to Modules > Positions Find your hook (for example displayTop) and your module, click Edit. Then selected the pages where you don't want to show the block.
Generating Options Form
The correct way (but more complicated) would be to generate the form using HelperForm or HelperOptions classes that come with PrestaShop