drupal

jQuery replace all HTML

Deadly 提交于 2019-12-23 05:05:29
问题 I'm trying to replace all the HTML (including the HTML tags) with another page. What I'm trying to do is having a website acting as an app even when navigating the another page. Here is the code : (function($) { Drupal.behaviors.loadingPage = { attach: function(context,settings) { $('a').click(function(event) { event.preventDefault(); // Create the loading icon // ... $.ajax({ url: $(this).attr('href'), success: function(data) { $('html').replaceWith(data); } }); }); } }; })(jQuery); I've

How to add new fields to user profile in Drupal 7 programmatically

爱⌒轻易说出口 提交于 2019-12-23 04:45:18
问题 I want to develop a module that add fields to user profile in drupal 7, like phone number and CV ... and I don't know how to do that (using Database or using fields API) pls help me. Any clear tutorials will be appreciated. 回答1: Try to follow the following code $myField_name = "NEW_FIELD_NAME"; if(!field_info_field($myField_name)) // check if the field already exists. { $field = array( 'field_name' => $myField_name, 'type' => 'text', ); field_create_field($field); $field_instance = array(

How to add an HTML attribute to a CCK image field

和自甴很熟 提交于 2019-12-23 03:58:27
问题 I am trying to add an attribute of "id="background" to the actual image tag. <?php print render($content['field_bg_image']); ?> I've looked up tons of articles and they are all concerned with hook_form_alter and this is not a form. This is simply just an image field, I just need an ID attribute on it with a value of background. I know I can use javascript but I want to use Drupal and not add any more javascript. 回答1: The image render is run through theme_image_formatter() which doesn't let

Drupal: multilanguage.. looking for the right module to build multiple versions of the node

南笙酒味 提交于 2019-12-23 03:48:31
问题 I have a multi-language website. I want a module to add multiple version of my nodes and selecting the right one for each language of my website. In other terms, for each node, I want to have more versions, a version for each language. I don't want to create new nodes, in order to avoid confusion for my customer. I want to be able to fill the content for each language version of the same node. If I'm not wrong, the core module Content Translation allows me to select for each node to which

How to just show NodeQueue block on included nodes?

可紊 提交于 2019-12-23 02:03:20
问题 On my blog I have a series of posts on a common subject that I'd like to link together with a common navigation block, so that readers can easily jump forwards or backwards through the series. I've used NodeQueue to collect all the blog entries together in sequence. Putting the associated block in my sidebar gives me the navigation that I want BUT the block appears on every page of my site. What I want to do is limit the visibility of the block so that it only appears on pages that are

Drupal 8's SMTP Authentication module could not connect to SMTP Host [closed]

£可爱£侵袭症+ 提交于 2019-12-23 01:54:35
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 months ago . I've found other threads online that deal with this specific problem, but none have helped. I have two questions: One with Drupal 8, the other with telnet. Background: A client is using a third party company to handle all of their emails. I manage a Drupal 8 site for them that sends some emails with PHP's mail(

How to hide a field on node data entry form in drupal?

自作多情 提交于 2019-12-23 01:18:35
问题 I'm using hook_node_presave to pre-populate taxonomy field with group's audience value. Thus, I'm trying to hide taxonomy field on a node data entry form. I tried hook_form_alter, but it didn't work for me. Is it possible to hide it? 回答1: <?php function mymodule_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'contenttype_node_form') { unset($form['somefield']); } } ?> This works for me just fine. Just change the form id and key of the form field you are targeting, and the field

Add a function to OnLoad in Drupal

泄露秘密 提交于 2019-12-22 18:33:04
问题 I have a HTML/text default module in the left bar of one of my skins/themes. I have some Javascript in there I'm trying to set today date to my javascript date dropdowns. I am unable to use 'body.onLoad' because Drupal is blocking it somehow? I found a solution saying I can add my javascript function here: if (isJsEnabled()) { addLoadEvent(yourCustomJSFunction); } How can I add that if I'm just using a default HTML/text module? Thanks! 回答1: Drupal uses the jQuery JavaScript library. Any

Add a function to OnLoad in Drupal

旧巷老猫 提交于 2019-12-22 18:33:04
问题 I have a HTML/text default module in the left bar of one of my skins/themes. I have some Javascript in there I'm trying to set today date to my javascript date dropdowns. I am unable to use 'body.onLoad' because Drupal is blocking it somehow? I found a solution saying I can add my javascript function here: if (isJsEnabled()) { addLoadEvent(yourCustomJSFunction); } How can I add that if I'm just using a default HTML/text module? Thanks! 回答1: Drupal uses the jQuery JavaScript library. Any

Session variables disappear for some users (drupal)

泄露秘密 提交于 2019-12-22 18:21:53
问题 I have this problem in my site that haunts me for months. I keep getting around it, but now I seem not to be able to find such a way, so I figured why not tackle the root problem? My root problem is that sometimes (not always) session data disappears for some of my users. I know most of them for sure have cookies enabled. I thought maybe it's a session expiry thing, but I don't think that's it. I set the expiration for very long, plus the amount of users that their session gets erased is just