How can I add CAPTCHA (version 6.x-2.0-rc3) to custom form in Drupal 6?
Is it just me or is it really difficult to find any good documentation on Drupal....
A quick search in the CAPTCHA issues queue led me here.
The key example code seems to be:
$form['captcha'] = array(
'#type' => 'captcha',
'#captcha_type' => 'captcha/Math',
);
There is also some good information in the module readmes.
what do you mean by 'custom form' as there's many interpretations of those words ..
meanwhile did you find this
captcha/drupal video tutorial ?
Related
I am using a plugin in wordpress but it does not provide a option to which page i what to show that plugin.
What i done? I am showing you.Firstly i get menus names through this wordpress function:
$defaults = array(
'theme_location' => 'main-menu',
'depth' => 1,
);
wp_nav_menu( $defaults );
It shows menus like this:
While I feel like your question is incredibly incomplete, and I'm not sure of your technical level, I would highly recommend using one of two frameworks to create the options panel for the plugin.
They will provide an easy way to work with the settings api and create various field types etc.
have a look at the Redux framework or at CMB
So i need the ability to have a featured or "sticky" post in wordpress, and it occurred to me! Why not use the Sticky Posts facility, but after doing a bit of reading it seems that Wordpress decided to not include support for it in latest releases and they don't seem to be pushing any solution for future releases.
Now that leaves me in a predicament i wish to have the ability to have a featured post or custom post without using a category of such.
I've also seen a few people state they have hacked wordpress with possibly a function to add the ability of sticky posts to custom post types, shame they didn't share the source!
How would this be done?
You can do it with a custom field (post_meta) on the custom post type. Then fire a custom query that selects for the meta_value:
$args = array('post_type' => 'my_custom_post_type', 'post_status' => 'publish', 'meta_query' => array('relation' => 'AND', array('key' => 'is_sticky', 'value' => '1', 'compare' => '=', 'type' => 'CHAR')));
$sticky_posts = new WP_Query($args);
Should return an array of published posts of post_type: my_custom_post_type that have the sticky flag set.
Although I haven't tested the above code, I'm doing something similar and it works fine.
You can use this plugin, it has it's own limitations, but works pretty well if you don't need something elaborate.
You can save a custom meta with the name of "sticky" and add it the value "on" when the post is sticky. That can be done with a custom metabox and a checkbox.
Wordpress will automatically add the word "Sticky" on the backend posts listing table
You can retrieve a loop with your sticky custom posts by adding the values 'meta_key' => 'sticky' and 'meta_value' => 'on' to the args of your query
I posted a working solution as of WordPress 4.2 here:
https://wordpress.stackexchange.com/questions/90958/adding-sticky-functionality-to-custom-post-type-archives/185915#185915
Basically, it implies installing a small plugin and add a code snippet.
I have Wordpress 3.2.1, the latest version and I can sticky posts. It works for me on my site.
I have a custom form that I have written with the Form API. We have the WYSIWYG module and TinyMCE implemented on the site that this module will be used on. How do I implement the WYSIWYG api on my custom form text areas?
Thanks!
This should help integrate WYSIWYG with your custom module forms: http://drupal.org/node/358316
Basically, you need to add the format key to each of your form fields and use filter_form()
Just in case anybody working with Drupal 7, here's the link to it that should help integrate WYSIWYG TinyMCE with your custom form fields: http://drupal.org/node/1087468
Thanks
In case you are working in drupal 7. Use the following.
$form['FIELD'] = array(
'#type' => 'text_format',
'#title' => t('TITLE'),
'#format' => 'full_html' //the format you used for editor.
);
In your form submit handler, you can access the value as follows.
$form_state['values']['FIELD']['value'];
I'm looking for some beginners resources for drupal. I've been writing my own module as a way of teaching myself the basics of development as I like the idea of having Drupal to go to when Wordpress can't manage. (Although wordpress is fast becoming as accomplished as Drupal, but that's not what the questions about.)
I have the module showing up in the enable/disable screen and the module.install file works a treat. What I'm stuck on is generating an admin area to edit entries in the table I'm using. I have a module_admin_settings() function in module.admin.inc, plus module.menu () in module.module.
But it isn't appearing in the menus and I'm stumped as to why that is. So I'm hoping someone knows a good tutorial that explains how to generate admin options.
If you want to become serious with Drupal development, I would advice you to go through the Pro Drupal developemnt book. It has been the single most helpful Drupal book I have ever read.
As for your question, to create a admin section is not much different from creating a view some where. What you need to do is.
Implement hook_menu to register the url you want to use, in your case admin/settings/name should be fine
Implement a call back function that should be called when a user go to the your. In your case you don't need to implement one as you should use drupal_get_form, but instead you need to create the form that the user should see using the form API.
You need to place this info in your hook_menu like this:
function modulename_menu() {
$items = array();
$items['admin/settings/modulename'] = array(
'title' => 'Menu item',
'description' => 'The description of the menu item. It is used as title attribute and on the administration overview page.',
'page callback' => 'drupal_get_form',
'page arguments' => array('form_id'),
'access arguments' => array('administer modulename'), // access restriction to admins only
);
return $items;
}
Then you need to implement validation and submit handlers for your form, is you use a system_settings_form, you can get a lot of the work done for you.
Whenever you make changes to hook_menu, you need to clear the (menu) cache, as Drupal caches this information to optimize performance.
That's it. Now you don't need to use different files in your module. If the module is small all could just go into the .module file. But for bigger modules, you can place some of your code in .inc files to organize your code a bit. Fx modulename.admin.inc for your admin callbacks/functions, modulename.page.inc for your regular callback/functions etc.
http://drupal.org/node/206761 is what I use as a starting point.
I'm a drupal newbie who needs some advice...
I have a news list block at homepage, created with View Module. It is listing all added news' title and link. Everything is cool so far. Now I need to add an ON/OFF option at admin side for homepage news block. When the setting is ON, it will work as it is. When it is OFF, only the titles will be listed with no linking to news detail page.
So, now where should I add this ON/OFF option? I have only add/edit/delete pages for each news, there is no common news page to add such option. Should I create an admin page with such ON/OFF option in? Also I think I need to create a db table to keep this ON/OFF status. and controlling this value at homepage block, if it is 1 or 0, and displaying links according to db value :/
it looks too long way
Create db table
Create an page with ON/OFF option in
add php codes to update db for admin's choice
get the db value in homepage block to display links, etc.
is there any shorter, better way to do what I need?
Appreciate helps so much!!! Thanks a lot!!
You definitely don't need to create any database tables for something like that. If you want a basic admin page, you will need to write a simple module though. First follow this quick start guide for setting up a basic module. (Note: You don't need to add those database queries in your .install file)
Once you have your module enabled...
1) In your mynewmodule.module file, add a menu entry to tell Drupal where your admin page can be accessed:
function mynewmodule_menu() {
return array(
'admin/settings/mynewmodule' => array(
'title' => 'My New Module',
'description' => 'Change settings for news display.',
'page callback' => 'drupal_get_form',
'page arguments' => array('mynewmodule_admin_form'),
'acces callback' => 'user_access',
'access arguments' => array('administer site configuration'),
),
);
}
2) Also in your mynewmodule.module file, add a function to create the form you just referenced in the menu entry:
function mynewmodule_admin_form() {
$form = array();
$form['mynewmodule-on-off-switch'] = array(
'#type' => 'checkbox',
'#title' => t('Enable news links'),
'#description' => t('Control whether news items are linked to stories'),
'#default_value' => variable_get('mynewmodule-on-off-switch', 1),
);
return system_settings_form($form);
}
3) Clear your cache to make Drupal recognize your admin page (you need to clear any time you make changes to mynewmodule_menu()). You can clear it here: admin/settings/performance
4) Visit admin/settings/mynewmodule to see your admin form. The way it works is when you save the configuration, Drupal will save a variable called "mynewmodule-on-off-switch" (same name as the array key in the form) to the variables table in the database. You can get this value anywhere by using variable_get().
create a form at admin/settings/on-off-switch.
on the form submit function, variable_set('on/off switch', $value) (try using booleans for the value).
then on the view theme, check for variable_get('on/off switch', $default_value) before printing the links.
Drupal's weakness, IMHO, is the sheer number of admin settings to configure to get a site up, and you don't want to be adding to that.
What I would do is to have the view expose two different blocks, one with the full view, one with the abbreviated view. Then all the configuration can be done through the block interface, which will be much more flexible in the long run. By, for example: using wildcards or php code for block visibility; showing different views to users with different roles; allowing visitors to control which view they see; exposing the two views to the theming engine more cleanly; and integration with any other module that works with blocks.