drupal-7

Drupal 7 FAPI - ajax image preview

僤鯓⒐⒋嵵緔 提交于 2019-12-21 06:38:56
问题 I am trying to preview the uploaded image using ajax in my D7 module but don't know why it's not working. Here is what I am trying to do:- function create_ad_form($form, &$form_state) { $form['image_file'] = array( '#title' => t('Upload Banner:'), '#type' => 'file', ); $form['submit'] = array( '#type' => 'submit', '#value' => 'Submit', '#submit' => array('create_ad_form_submit'), '#ajax'=> array( 'callback'=>'create_ad_form_submit', 'wrapper'=> 'im-area', 'method'=> 'replace', 'effect'=>

Drupal 7 views filter by dynamic taxonomy term

有些话、适合烂在心里 提交于 2019-12-21 06:22:14
问题 I have a few pages (services), each with it's own taxonomy term. I would like to add a view to the bottom. It should contain all nodes (references) with the same term as the main node (service). Could it be done by views? Read something about and tried contextual filter with no success. Image is bellow 回答1: I think you are on the right track. Try changing your validator to "Term Id" instead of "Term Name". I created a block view with the settings you have (with "Term Id" as the validator) and

Add Class to Image Field in Drupal 7

瘦欲@ 提交于 2019-12-21 06:01:01
问题 I have added an image field to content type "Basic Page" and using the "Manage Displays" option have it displayed at the top of the page. However there is no styling on the image and I can't for the life of me figure out how I add a class to the image so that I can add styles. 回答1: If you're using CCK there's almost certainly a class already associated with the image (or at least a class on a div that wraps it). CCK wraps just about everything in a class. Try right clicking the image and

Drupal 7 save user picture programmatically

本秂侑毒 提交于 2019-12-21 05:38:15
问题 I have found this script http://d.danylevskyi.com/node/7 which I have used as a starter for the below code. The goal is to be able to save a user picture: <?php define('DRUPAL_ROOT', getcwd()); require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); $uid = 99; $account = user_load($uid); // get image information $image_path = 'public://avatars/upload/b8f1e69e83aa12cdd3d2babfbcd1fe27_4.gif'; $image_info = image_get_info($image_path); // create file object

Drupal 7 hook_node_view add a form to the content of a node

送分小仙女□ 提交于 2019-12-21 04:23:15
问题 function example_module_node_view($node, $view_mode, $langcode) { $f = drupal_get_form('example_module_form', $node); $node->content['data_collection_form'] = array('#value' => $f, '#weight' => 1); } Why doesn't the form display? Am I doing something wrong? The form object is being populated. I can do #markup => 'Something' and it works. 回答1: The return from drupal_get_form is actually a render array itself so you could just do this: $f = drupal_get_form('example_module_form', $node); $f['

Style Drupal 7 log-in page

余生长醉 提交于 2019-12-20 14:11:51
问题 How do I style the login-page of Drupal 7? I used different methods like page-user-login.tpl or user-login.tpl of page-login.tpl but with no results. Is there an easy way to theme your login page in Drupal 7 in his own .tpl -file? 回答1: You can override any page template by naming your templates in the following convention: For page 'user/login': page--user--login.tpl.php For page 'foo/bar/' page--foo--bar.tpl.php See Core templates and About overriding themable output for more information.

drupal alter node edit form

可紊 提交于 2019-12-20 10:27:13
问题 How can I add a custom configuration area to a node edit form just beneath the Authoring Information & Publishing Options section? 回答1: You can use hook_form_FORM_ID_alter(). Example below: function my_module_form_node_form_alter(&$form, $form_state) { // if you are targeting a specific content type then // you can access the type: $type = $form['#node']->type; // Then if ($type == 'my_content_type') { // use a contact settings for the sake of this example $form['contact'] = array( '#type' =>

Drupal 7 Browser specific css

时光毁灭记忆、已成空白 提交于 2019-12-18 18:04:13
问题 How can i have a browser specific css in Drupal 7 . I would like to load chrome.css if browser is chrome . Please help 回答1: You can do this in your template.php file with a preprocess_html theme hook and drupal_add_css function. You will find example in drupal 7 theme, for example in bartik : // Add conditional stylesheets for IE drupal_add_css(path_to_theme() . '/css/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE)); drupal

How can a custom Drupal date format be added?

为君一笑 提交于 2019-12-18 14:03:41
问题 How do you add a custom Drupal date format. I want to display the date without hours and minutes, but the options don't include it. 回答1: Do the following: Administration » Configuration » Regional and language » Date and Time There you will see a tab for format. Create a new format string "Y-M-d". Make this as your default for all date fields and you won't see the seconds any more. You don't need the date module for basic formatting. Cheers, Vishal Below is the image so that you know where it

403 error with message:Access Not Configured. Please use Google Developers Console to activate the API for your project

旧城冷巷雨未停 提交于 2019-12-17 22:42:20
问题 Can't overcome this situation: created a project in the Google developers console they created "Client ID for web application" and "Key for server applications". In the console requests have completed successfully, but when I send from the server I get the following error: 403: { "error": { "errors": [ { "domain": "usageLimits", "reason": "accessNotConfigured", "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project." } ], "code": 403,