Drupal hook not being called - drupal-7

I'm new to Drupal making a plugin that hooks into the ckeditor widget. I absolutely can't figure out why my implementation of a hook that is defined in ckeditor is never called.
Here are some details
my module is enabled
I'm able to use more basic hooks like exceltohtml_plugin instead of exceltohtml_ckeditor_plugin and reach my test statement.
I'm can't think of any more troubleshooting ideas to reveal the issue so any help would be greatly appreciated.
exceltohtml.module
<?php
error_log("TEST: this will print to log");
// implementation of hook_ckeditor_plugin()
function exceltohtml_ckeditor_plugin()
{
error_log("TEST: but this will never run");
return array(
'exceltohtml' => array(
'name' => 'exceltohtml',
'desc' => t('Excel sheet upload'),
'path' => drupal_get_path('module', 'exceltohtml') .'/plugins/exceltohtml',
'buttons' => array(
'excel_to_html' => array('label' => 'Insert spoiler','icon' => '/images/image.gif' ),
)
)
);
}
ckeditor.api.php (the file in ckeditor that Im basing my hook on)
/**
* Hook to register the CKEditor plugin
*/
function hook_ckeditor_plugin() {
return array(
'plugin_name' => array(
// Name of the plugin used to write it.
'name' => 'plugin_name',
// Description of the plugin - it would be displayed in the plugins management section of profile settings.
'desc' => t('Plugin description'),
// The full path to the CKEditor plugins directory, with the trailing slash.
'path' => drupal_get_path('module', 'my_module') . '/plugin_dir/',
'buttons' => array(
'button_name' => array(
'icon' => 'path to button icon',
'label' => 'Button Label',
)
)
)
);
}

If the function in your module is new, then the slightly older version of your module code might be cached.
Visit the module listing page in Drupal, that should reload the modules PHP code:
admin/modules

Related

How to dynamically load a component with settings in CakePHP 2?

I understand that we can pass settings for a component when we define the component at the start of a controller. Example from the CakePHP 2.0 Cookbook
public $components = array(
'Auth' => array(
'authorize' => array('controller'),
'loginAction' => array(
'controller' => 'users',
'action' => 'login'
)
),
'Cookie' => array('name' => 'CookieMonster')
);
But I usually load components on the fly like so (also from the Cookbook)
$this->OneTimer = $this->Components->load('OneTimer');
While using the second method (loading a component on the fly), how can I pass settings to it so that I can use them in the constructor to correctly setup the component based on the settings?
Any help would be greatly appreciated.
2 minutes after asking the question I looked at the load function in the library and found that settings is the second argument for the function.
public function load($component, $settings = array())
So I just need to supply the settings as the second parameter when I load components on the fly.

how to delete terms in plugin? woocommerce

i am creating a plugin with plugin hooks when plugin activate it creating product attributes it working fine also i adding attributes terms it also working fine and on plugin deactivate i am deleting it but i see only attributes deleting but terms not delete.
i using this code for deleting attributes it working fine
enter code here
// attributes parameters
$wpm_attributes = array(
array(
'label' => 'Size',
'name' => 'size',
'type' => 'select',
),
array(
'label' => 'Color',
'name' => 'color',
'type' => 'select',
)
);
foreach ( $wpm_attributes as $attr ) {
$attribute = array(
'attribute_label' => $attr['label'],
'attribute_name' => $attr['name'],
'attribute_type' => $attr['type'],
'attribute_orderby' => 'menu_order'
);
$wpdb->delete( $wpdb->prefix . 'woocommerce_attribute_taxonomies', $attribute );
delete_transient( 'wc_attribute_taxonomies' );
}
I recommend not deleting the terms at the point of deactivation.
Instead why don't you delete the terms at the point of uninstallation?
You can use the uninstall hook:
http://codex.wordpress.org/Function_Reference/register_uninstall_hook
Or bypass that.
The plugin should create a file named 'uninstall.php' in the base plugin folder. This file will be called, if it exists, during the uninstall process bypassing the uninstall hook.
This may be easier to manage code wise and sometimes people would like to deactivate a plugin and not lose all their data.

want to remove action name from url CakePHP

i am working on a Cakephp 2.x.. i want to remove the action or controller name from url ... for example i am facing a problem is like that
i have a function name index on my Messages controller in which all the mobile numbers are displaying
the url is
www.myweb.com/Messages
now in my controller there is a second function whose name is messages in which i am getting the messages against the mobile number
so now my url becomes after clicking the number is
www.myweb.com/Messages/messages/823214
now i want to remove the action name messages because it looks weired...
want to have a url like this
www.myweb.com/Messages/823214
When connecting routes using Route elements you may want to have routed elements be passed arguments instead. By using the 3rd argument of Router::connect() you can define which route elements should also be made available as passed arguments:
// SomeController.php
public function messages($phoneNumber = null) {
// some code here...
}
// routes.php
Router::connect(
'/messages/:id', // E.g. /messages/number
array('controller' => 'messages', 'action' => 'messages'),
array(
// order matters since this will simply map ":id"
'id' => '[0-9]+'
)
);
and you can also refer link above given by me, hope it will work for you.
let me know if i can help you more.
REST Routing
The example in the question looks similar to REST routing, a built in feature which would map:
GET /recipes/123 RecipesController::view(123)
To enable rest routing just use Router::mapResources('controllername');
Individual route
If you want only to write a route for the one case in the question
it's necessary to use a star route:
Router::connect('/messages/*',
array(
'controller' => 'messages',
'action' => 'messages'
)
);
Usage:
echo Router::url(array(
'controller' => 'messages',
'action' => 'messages',
823214
));
// /messages/823214
This has drawbacks because it's not possible with this kind of route to validate what comes after /messages/. To avoid that requires using route parameters.
Router::connect('/messages/:id',
array(
'controller' => 'messages',
'action' => 'messages'
),
array(
'id' => '\d+',
)
);
Usage:
echo Router::url(array(
'controller' => 'messages',
'action' => 'messages',
'id' => 823214 // <- different usage
));
// /messages/823214
in config/routes.php
$routes->connect('/NAME-YOU-WANT/:id',
['controller' => 'CONTROLLER-NAME','action'=>'ACTIOn-NAME'])->setPass(['id'])->setPatterns(['id' => '[0-9]+']
);
You can use Cake-PHP's Routing Features. Check out this page.

Error Loading Views After Changing Route Value of module.config.php - Zend Framework

This question is regarding Zend Framework application version: 2.1.3. I, the developer, am new to Zend Framework and would greatly value your assistance.
I was making a module for a 'Donor Management System' of a church. The module I am working on is called the 'QueryBuilder'. Previous modules were fine and works great. I use the Zend Helper for Sublime Text and it generated some thing similar for the module.config.php
<?php
/**
*
* #package QueryBuilder
*/
return array(
'controllers' => array(
'invokables' => array(
'QueryBuilder\Controller\QueryBuilder' => 'QueryBuilder\Controller\QueryBuilderController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'querybuilder' => array(
'type' => 'segment',
'options' => array(
'route' => '/querybuilder[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'QueryBuilder\Controller\QueryBuilder',
'action' => 'index',
//'action' => 'search',
//'action' => 'recent',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'querybuilder' => __DIR__ . '/../view',
),
),
);
?>
Determined to have a little bit of fun after making some successful modules, I changed the router as follows.
<?php
/**
*
* #package QueryBuilder
*/
return array(
'controllers' => array(
'invokables' => array(
'QueryBuilder\Controller\QueryBuilder' => 'QueryBuilder\Controller\QueryBuilderController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'querybuilder' => array(
'type' => 'segment',
'options' => array(
'route' => '/query-builder[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'QueryBuilder\Controller\QueryBuilder',
'action' => 'index',
//'action' => 'search',
//'action' => 'recent',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'querybuilder' => __DIR__ . '/../view',
),
),
);
?>
Note: Only the route value was changed from /querybuilder... to /query-builder.... When I tried to access the route http://konnections/query-builder I got some error but I didn't go through it.
Wondering why I wan't to be a hero, I changed the value back to its defaults. And tried to load http://konnections/querybuilder but it also gave an error.
Zend\View\Renderer\PhpRenderer::render: Unable to render template "query-builder/query-builder/index"; resolver could not resolve to a file
No where in the code of the module you could find the words query-builder. So common sense says there can be no way query-builder/query-builder/index needs to be accessed.
Thinking it might be some caching, I looked for it in the entire application folder. Then I restarted Apache, the computer, deleted and made a new Module with the same name QueryBuilder and still the error is there.
Note: This is a plugin that was done nothing with. I only changed the route value thinking it will make the URL look neater.
Here is what I end up with [Image]:
Nope, this is not IE, because I tried in Chrome (which didn't access the query-builder url) as well.
The whole of Zend Folder (the root of the website) has no reference to query-builder. Where does it come from and how can I change it?
Thanks in advance.
from ZF1 series (http://framework.zend.com/manual/1.12/en/zend.controller.basics.html), ZF2 is the same but not found this description on manual.
Case Naming Conventions
Since humans are notoriously inconsistent at maintaining case sensitivity when typing links, Zend Framework actually normalizes path information to lowercase. This, of course, will affect how you name your controller and actions... or refer to them in links.
If you wish to have your controller class or action method name have multiple MixedCasedWords or camelCasedWords, you will need to separate those words on the url with either a '-' or '.' (though you can configure the character used).
As an example, if you were going to the action in FooBarController::bazBatAction(), you'd refer to it on the url as /foo-bar/baz-bat or /foo.bar/baz.bat.
I am Ziyan, the one who asked the question in the first place.
After not finding a solution in Google, I wondered in to making another module and ended up with the same plight. Confused I made a new installation of Zend Framework and made a module with the same name.
Zend\View\Renderer\PhpRenderer::render: Unable to render template "query-builder/query-builder/index"; resolver could not resolve to a file did not go away.
Knowing it is not some thing like reconfiguration, I looked closer.
It seemed to put a dash between every word. I was like Zend is insane! But no, it seems to be splitting the Module name from each upper case letter and adjoining them using a '-' (dash).
In my case QueryBuilder becomes query-builder or plugin named HelloModules would be hello-modules.
So the view manager seems to be looking for ../views/query-builder/query-builder/index.
In my case, ZF Helper for Sublime text needs to look in to the situation. If you could fix the plugin at GitHub it would be great. I will give a try my self.
I couldn't find any proof for my claiming and no time to go through the source codes. Would be glad if some one provide some links.

CAKEPHP paginator custom link

I want an custom link for my paginator. I use the folowing code
$this->Paginator->options(array(
'url'=>array(
"/custom",24,"custom1"
),
'escape'=>false
)
);
This results in a link with the original controller in front of the link like this:
/controller/action/%2Fcustom/24/custom1
I want the linkt to be /custom/24/custom1. So without the escaped(/) and as a root.
How can I accomplish this?
Did you try
'url' => '/custom/24/custom1'
? The syntax that you use is not valid I think. The available formats are:
'url' => 'action'
or
'url' => '/controller/action'
or
'url' => array(
'controller' => 'your_controller',
'action' => 'your_action'
)
See http://book.cakephp.org/1.3/en/view/1387/options-url and http://book.cakephp.org/1.3/view/1448/url.
If none of these formats satisfies you, you can consider creating a custom route, see http://book.cakephp.org/1.3/view/948/Defining-Routes.
Cheers

Resources