drupal-7

How to generate translation file for a custom Drupal 7 module?

半腔热情 提交于 2019-12-03 02:27:44
问题 I'm using CentOS 5.5 Linux (without X), PHP 5.3 and Drupal 7.0. The core language of my site is Russian (not English)! I've created a game.info and the following game.module which generates 3 blocks for the front page: function game_block_info() { return array( 'game_main' => array( 'info' => t('Set FlashVars and show the flash game.'), 'cache' => DRUPAL_NO_CACHE, ), 'game_winner' => array( 'info' => t('Show the winner of the last week.'), 'cache' => DRUPAL_NO_CACHE, ), 'game_leader' => array

Drupal 7 Get image field path

北慕城南 提交于 2019-12-03 02:23:52
问题 I would like to get the image path of a field. I'm in a node and I need the Url of image in order to put it as a background-image in inline css. I can't find the solution. Can you help me? 回答1: To get just the path of an image from it's URI: file_create_url($node->field_image['und'][0]['uri']); More information on file_create_url() can be found here: http://api.drupal.org/api/drupal/includes%21file.inc/function/file_create_url/7 To get the path of an image created using an image style from it

Using JQuery in Drupal 7

时间秒杀一切 提交于 2019-12-03 02:20:20
问题 I'm writing my own Drupal 7 module, and like to use JQuery in it. $('#field').toggle(); But I'm getting this error: TypeError: Property '$' of object [object DOMWindow] is not a function It seems that JQuery is not loaded. Otherwise $ should be defined. Though I actually include it in the header: <script type="text/javascript" src="http://rockfinder.de/misc/jquery.js?v=1.4.4"></script> Do I have to do anything else to activate JQuery in Drupal? Is $ being overwritten by Drupal? That's the

How to insert a block into a node or template in Drupal 7?

房东的猫 提交于 2019-12-03 00:40:42
问题 In Drupal 6, it was easy to insert a block into a template with the following code: $block = module_invoke('views', 'block', 'view', 'block_name'); print $block['content']; However, using the same instructions in Drupal 7 does not seem to work. I have looked around and cannot find the new method. Does Drupal 7 have a routine that can allow for programmatically inserting a block into a template or node? 回答1: With wrburgess's answer you may get an error if your server is using a newer version

drupal sql conditional clauses for multiple tables?

泪湿孤枕 提交于 2019-12-02 19:50:54
问题 I have the below query for FAQ search module modified that works in Drupal 7, which searches in two tables: 1) title 2) body but don't manage to include one more. $term = strip_tags(drupal_substr($_POST['keyword'], 0, 100)); $query = "SELECT DISTINCT fq.title, fq.nid FROM {node} AS fq, {field_data_body} AS f WHERE fq.title LIKE :term OR fq.type LIKE :term OR f.body_value LIKE :term AND f.entity_id = fq.nid"; $result = db_query($query, array(':term' => '%%' . $term . '%%',':term' => '%%' .

Drupal Commerce Line Items: alter the price?

寵の児 提交于 2019-12-02 19:35:22
I have to add to my cart some line items with a custom amount. The commerce product is saved with price = 0, and my module compute the price and add the line item to the cart/order, but i dont understand how to set programmatically the price. I've read about using Rules, but I need my module to be able to set/alter the price, without invoking rules . I've tryed with an entity wrapper, i tryed to alter the line item created with commerce_product_line_item_new(), but nothing, when the line item gets into the cart always has the original product price (in my case, 0). How to alter a line item

How to change image save location in CKeditor Drupal 7?

做~自己de王妃 提交于 2019-12-02 19:32:53
问题 I use ckeditor module for my project. In ckfinder folder > config.php, the default image saved folder is ... 'baseUrl' => '/ckfinder/userfiles/', My project folder path is... MAMP > htdocs > drupal > sites > all > themes > bootstrap > images When I upload the image, ckfinder image folder create the location in ... MAMP > htdocs > ckfinder So, the level of drupal theme folder and ckfinder folder is the same.. I don't want to be like this. I want to create the htdocs folder inside the theme

Username as a path

人走茶凉 提交于 2019-12-02 19:19:25
问题 I would like to have a user's name as a part of a URL, e.g. mysite.com/username. This should redirect to the user profile. I use Profile 2 and Pathauto, but I am not sure how to do this. 回答1: With pathauto, you just have to configure user paths with a user token, e.g. [user:name] . 回答2: Pathauto pattern of [user:name] under User paths should do the trick. 来源: https://stackoverflow.com/questions/5961990/username-as-a-path

Menu path in Pathauto

喜欢而已 提交于 2019-12-02 18:58:57
How do I get pathauto under Drupal 7 to generate a URL alias by the full menu path? Just an update in case anyone comes across this with a more recent version of Pathauto/Token. This worked for me: [node:menu-link:parents:join-path]/[node:menu-link] I ended up using: [node:menu-link:parent:url:path]/[node:menu-link] Heavy caution though: If the node does not have a menu link, you'll end up without an automatically aliased page. On the bright side, this might make you aware of orphan pages. (Consider it a feature!) Note that using the pattern: [node:menu-link:url:path]/[node:menu-link] will

Drupal 7: Best Practice for a Dynamic Select List in Drupal 7

爱⌒轻易说出口 提交于 2019-12-02 17:44:42
What is the best practice for a dynamic select list in Drupal 7? Create a Field with dummy options via the UI and overriding the options with hook_form_FORM_ID_alter or Creating a dynamic select list from scratch via a custom module with the hook_form or different approach? Thanks You could use Form API's #ajax (it used to be called #ahah in Drupal6) to do that. Here is an example for Drupal 7 (based on Examples for Developers ) that shows two dropdowns where the first dropdown modifies the list of options of the second dropdown: Source of file mymodule.module : <?php /** * Implementation of