texts: How to make form buttons call only javascript?

texts:
I'm experimenting with JavaScript and Drupal forms. Currently I'm trying to make a button in the administration form of a module that will use JavaScript to append options to a select list. The problem I'm running into is that when I click the button, my JavaScript gets called but the whole form refresh. I've looked at the Forms API reference thinking there was some kind of attribute I can set on the button to stop it from but found nothing. Is there any way I can stop the button from refreshing the page or is this a dead end?

$form['#attached']['js'] = array(
  drupal_get_path('module', 'test').'/js/test.js',
);

$form['list'] = array(
  '#type' => 'select',
  '#options' => array(),
  '#attributes' => array(
    'name' => 'sellist',
  ),
  '#size' => 4,
);

$form['add_button'] = array(
  '#type' => 'button',
  '#value' => 'Add',
  '#attributes' => array(
    'onclick' => "add_to_list(this.form.sellist, 'Append' + this.form.sellist.length);",
  ),
);

//JavaScript
function add_to_list(list, text) {
  try {
    list.add(new Option(text, list.length), null) //add new option to end of "sample"
  }
  catch(e) {
    list.add(new Option(text, list.length));
  }
}

My final code:

<?php
function jstest_menu() {
  $items['admin/config/content/jstest'] = array(
    'title' => 'JavaScript Test',
      'description' => 'Configuration for Administration Test',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('_jstest_form'),
      'access arguments' => array('access administration pages'),
      'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

function _jstest_form($form, &$form_state) {
  $form['list'] = array(
    '#type' => 'select',
    '#options' => array(),
    '#size' => 4,
  );

  $form['text'] = array(
    '#type' => 'textfield',
  );

  $form['add_button'] = array (
    '#type' => 'button',
    '#value' => t("Add"),
    '#after_build' => array('_jstest_after_build'),
  );
  return $form;
}

function _jstest_after_build($form, &$form_state) {
  drupal_add_js(drupal_get_path('module', 'jstest').'/js/jstest.js');
  return $form;
}

JavaScript
(function ($) {
  Drupal.behaviors.snmpModule = {
    attach: function (context, settings) {
      $('#edit-add-button', context).click(function () {
        var list = document.getElementById('edit-list');
        var text = document.getElementById('edit-text');

        if (text.value != '')
        {
          try {
            list.add(new Option(text.value, list.length), null);
          }
          catch(e) {
            list.add(new Option(text.value, list.length));
          }

          text.value = '';
        }

        return false;
      });
      $('#edit-list', context).click(function () {
        var list = document.getElementById('edit-list');

        if (list.selectedIndex != -1)
          list.remove(list.selectedIndex);

        return false;
      });
    }
  };
}(jQuery));


texts: Remove Domain Access fieldset from node forms

texts:
I would like to remove the Domain access options fieldset from my node forms.

How can I do this? Should I remove is using hook_form_alter()?


texts: display view mode on node based on field setting or taxonomy term of user profile

texts: I'm using Display Suite which is awesome and an easier solution if you're not a coder. Now that I have created several view modes I'd like to set a particular view mode that is based on a field setting (a taxonomy term in my case) in the viewing user's account setting (I guess that's also called the user's profile, right?). It seems that DS is mostly used in conjunction with Views but I simply want users to get a different view mode when viewing the node without Views. I think I'll have to create a separate module for that or add a preprocess function to my template file but I have no idea where to start. Can anyone share their suggestions with me on how to do this? I'm not a coder but I think I can implement some code, though. Cheers!


texts: Only show title of referenced node in a view if the node contains files in another field?

texts:
Content-type-A has files attached. Content-type-B has a node reference to multiple Content-type-A's.

I making a view which is attached to Content-type-B. It needs to show each Content-type-A title that is referenced and also the files attached to each Content-type-A.

This is easy to do with relationships however I need the Content-type-A title to not be shown if there are no files attached to it.

So if I have this:

NodeB has a node reference to NodeA, NodeA2 and NodeA3.

NodeA and NodeA2 have a file attached but NodeA3 does not.

Then I need my view to just be this:

NodeA
-File from NodeA
NodeA2
-File from NodeA2

But its currently this:

NodeA
-File from NodeA
NodeA2
-File from NodeA2
NodeA3


texts: Wrapping content in anchor tags with CKEditor

texts:
I am trying to wrap a block of HTML content in an  tag in a Drupal 8 installation:

Link 1

Subheader link 1

CKEditor changes it to:

Link 1

Subheader link 1

The Limit allowed HTML tags I have set are:

 <s>

How can I wrap content in an anchor tag with CKEditor?


texts:
I'm in a new position working on an existing Drupal 7 site that I didn't help build. None of the original devs are here. Amongst other modules, the site makes uses of panels, panelizer, aliases, and redirects.

I get requests from marketing to update or change a page, and they include a URL. The URL is often an alias, but sometimes it can be a panels page, or a drupal entity "overriden" by panelizer.

Is there an easy way to see what exactly a URL maps to when I get a URL from marketing?


texts: #upload_validators missing error message

texts:
[Update]

Upon further investigation it seems that the message isn't appearing due to the following javascript error:

"Uncaught TypeError: Cannot read property 'length' of undefined"

I'm not sure how to resolve this error, but the following issues may be related:

[D7] Duplicate HTML IDs are created for file_managed_file fields
Duplicate HTML IDs are created for file_managed_file fields

Description

I'm trying to create a custom form with some number of file upload fields (for now I'm using the hard-coded value 3).

I have added an #upload_validators attribute to the managed_file element that calls file_validate_extensions and passes in "doc" as the only valid filetype.

When I try to upload a .jpg, an error appears -- which is what I want. However, the error doesn't contain any text.

Any idea what I'm doing wrong?

Code

function mymodule_example1_form($form_state) {
  $num_docs = 3;

  // Build the number of name fieldsets indicated by $form_state['num_docs'].
  for ($i = 1; $i <= $num_docs; $i++) {
    $form['managed_file'][$i] = array(
      '#type' => 'managed_file',
      '#title' => 'Managed File' . $i,
      '#progress_indicator' => 'throbber',
      '#progress_message' => 'Upload successful!',
      "#upload_validators"  => array("file_validate_extensions" => array("doc")),
      '#upload_location' => 'public://doc/',
    );
  }

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );

  return $form;
}

Screeshot

Resources

Drupal Form API Reference - managed_file
Drupal API - function file_validate_extensions


texts: How can I add an argument in the URL that link from a content

texts:
I have been searching for the answer for so long but still none of the solution that I can finish my goal...
my content structure is as following:

I have Content-type that keep a list of Quotes - I named it [A]
I have Content-type that keep a list of Titles - I named it [B]
In a 'Quote', I have a field that refer to which 'Title' that it is referring.

EXAMPLE   (not codes)

Quote-1 have a field referring to Title-1
Quote-2 have a field referring to Title-1
Quote-3 have a field referring to Title-2
Quote-4 have a field referring to Title-3
Quote-5 have a field referring to Title-1
(multiple Quotes can referring to the same Title)

So...I used Views(block) to display this Quotes[A] in a page and...HERE is what I want...
I want each 'Quote' to link into another page which require 2 parameters...

node ID  (which is already sent by default Drupal (q=...))

Title ID (that is referring in a field of the Quote)
by default, the Drupal have value of 'q' sent to another page but ...

How can I add Title ID parameter into each 'Quote' link?


texts: If I delete openenterprise module from drupal module folder site is collapse

texts: I am wrongly paste the open enterprise module in drupal module folder. If I try to delete that folder total site is collapsed. How to fix this issue.


texts: Is it possible to set a taxonomy menu programmatically?

texts:
Is it possible to create set a taxonomy menu location programmatically? Ie, I have taxonomy_menu installed, have the taxonomy configured and the menu set up, and want to set the taxonomy menu location for the menu with php, something like:

taxonomy_menu_set_menu_location($menu, $menu_location)

which would then run the same function in the taxonomy_menu_vocab_submit() handler.

is there something existing, or should I DIY?


texts: I have a confusion regarding the hook and a normal function, So can any one tell me what is the significant difference between a Drupal hook and a normal PHP function in Drupal.


texts: How does Drupal check write permissions for a folder?

texts:
How does Drupal check the write permissions on a folder in Linux?

I am using php5-fpm and the web server is working as the user that owns the Drupal directory and I expect that even with a 700 the directories should be readable and writeable by the PHP process and there should be errors only when nginx itself needs access to files or folders.

Does Drupal just test the file permissions for the other user, or does it attempt to read and write as the PHP process itself? It appears to work only when o+rwx is set on the sites/default/files folder but r-x alone should work.

Can anyone point me to the exact routines that make that check?


texts: send REQUEST_URI with header location redirect via settings.php

texts:
I'm in predicament where I must use settings.php to do what I'd normally just do via mod_rewrite... the site is being hosted on Pantheon and I am referring to this article: http://helpdesk.getpantheon.com/customer/portal/articles/368354

I need to send the original requested path for reference. Trying to pass a the SERVER_URI as a parameter via header location in setting.php gets me an infinite loop.

My code:

if (preg_match('/article\/[0-9]?[0-9]\/[0-9]?[0-9]\/[aA-zZ].+/', $_SERVER['REQUEST_URI'])) {
    header('HTTP/1.0 301 Moved Permanently');

    header("Location: http://answers3x-ec-core-community.gotpantheon.com/catchall/?dest=" . urlencode($_SERVER["REQUEST_URI"]));  exit;
}

Anybody have any suggestions as to how I might accomplish passing the $_SERVER["REQUEST_URI"] via header location from settings.php without an infinite loop?


texts: Commerce- Is it possible to hide the radio button on payment select with only one payment type?

texts:
I just set up Drupal Commerce (not Kickstart) and am using the Commerce PayPal module to allow customers to pay for their orders.  This is the only payment method available; however, there is a radio button displayed next to PayPal, as if there was another option that could be selected (although there is not).

How can I hide this option?  I assume there is an option in the UI somewhere that I missed, because it is not standard practice to show a radio button when no choice is in fact possible.

It looks like this:


texts: How to read a Entity reference node's fields?

texts:
I had a field using entity reference in my site. I'm trying to develop a module can read/use it.

$wrapper = entity_metadata_wrapper('node',$node);
dpm($wrapper->myRefField->getPropertyInfo());

This returns a error page, but dpm($wrapper->myRefField) shows that it's a standard EntityDrupalWrapper, though nothing in it.

How can I read $nid of the referenced node?

Errors below:

 Additional uncaught exception thrown while handling exception.

Original

PDOException: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation &quot;node&quot; does not exist LINE 3: node base ^: SELECT revision.vid AS vid, base.uid AS uid, revision.title AS title, revision.log AS log, revision.status AS status, revision.comment AS comment, revision.promote AS promote, revision.sticky AS sticky, base.nid AS nid, base.type AS type, base.language AS language, base.created AS created, base.changed AS changed, base.tnid AS tnid, base.translate AS translate, revision.timestamp AS revision_timestamp, revision.uid AS revision_uid FROM {node} base INNER JOIN {node_revision} revision ON revision.vid = base.vid WHERE (base.nid IN (:db_condition_placeholder_0)) ; Array ( [:db_condition_placeholder_0] =&gt; 1 ) in DrupalDefaultEntityController->load() (line 191 of /var/www/site2/includes/entity.inc).

Additional

PDOException: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation &quot;filter_format&quot; does not exist LINE 3: filter_format ff ^: SELECT ff.* FROM {filter_format} ff WHERE (status = :db_condition_placeholder_0) ORDER BY weight ASC; Array ( [:db_condition_placeholder_0] =&gt; 1 ) in filter_formats() (line 427 of /var/www/site2/modules/filter/filter.module).

Uncaught exception thrown in shutdown function.

PDOException: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation &quot;semaphore&quot; does not exist LINE 1: DELETE FROM semaphore ^: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] =&gt; 18701629495353e89467a483.34692095 ) in lock_release_all() (line 269 of /var/www/site2/includes/lock.inc).

Uncaught exception thrown in session handler.

PDOException: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation &quot;sessions&quot; does not exist LINE 3: sessions sessions ^: SELECT 1 AS expression FROM {sessions} sessions WHERE ( (sid = :db_condition_placeholder_0) AND (ssid = :db_condition_placeholder_1) ); Array ( [:db_condition_placeholder_0] =&gt; sLS3fA1YAd1u1G6_xC1yxg0Ba6Kgrus6oXDBm4Wpuww [:db_condition_placeholder_1] =&gt; ) in _drupal_session_write() (line 209 of /var/www/site2/includes/session.inc).


texts:
I have this code.

     if ($_GET['q'] == 'entity/bundle'){
        unset($css[drupal_get_path('module', 'system') . '/system.base.css']);
 }

Which I use in template.php to unset css on certain pages, but I want to have code (in this case unset css) to run on all entity pages for example entity/bundle/1, entity/bundle/2, entity/bundle/3. How can I get this to apply to all entity pages. I need something like entity/bundle/% or entity/bundle/* or maybe there is another way.


texts: Modifying a module's function from another module

texts:
A particular module has a theme function (theme_nice_menus_build()) that I'd like to give a slightly different output; I'd rather not modify the .module file to be able to continue updating the module when new versions are available.

Is it possible to modify that function from another custom module or from template.php?


texts: D8: Replacing Contact Form Title With Label

texts:
I've searched around for this answer but to no avail.

All I want to do is with any contact form I create I want to replace its default title (usually "contact") with the form's label.

So instead of {{ title }} something like {{page.label}}.

I need more descriptive titles for my forms.


texts: webform submission form altering in drupal 7

texts:
I would like to ask a conceptual/architectural question about drupal 7 webform. I have different webforms and submissions of that, I would like to add a textfield to the submissions, so it will allow admin user to write a comment about the submission form and it will send an email to user who submitted that form when admin user saves that comment. Along with that feature I want submission form to update itself with this new comment.

I know I will have to create a custom module to alter the form and I don't need all the codes that is going to solve the issue. I just need a pathway or an architecture that is going to lead me to the solution.

Thank you for your time and attention.


texts: Ubercart/Securepages site breaks overnight!? Can't POST (login/add to cart)

texts:
This site seemingly broke overnight without any changes being made to the configuration.. this is a production site:

https://www.skinnyboyswagclub.com/cardigan

Add an item to your cart and watch the network activity.. It redirects through a 302. Is this secure pages switching to https? (even though it's submitting from https?)

Nothing gets added, no errors.

Can't login either. Logging in with the correct password (guest/guestpass) doesn't work either.

I did add another dns record the other day to point ".dev." at another server. Could that have broken the production site at www.?

I removed the record just now, in case..

Since this is an issue on a production site and I can't even log in, I'm BEGGING for help! :|


texts: Drupal 7 - Passing Arguments from Page Manager/Panel to embedded view/reference field

texts:
Drupal 7: I try to pass an argument (eg node:title) from panels/page manager to use as filter criteria in an embedded view.In the view I want to fetch this argument as a filter criteria to a reference field.

In Panels I can define pass arguments, but how can I fetch and compare them in the view?


texts:
As a content admin, are there any feasible ways in Drupal 8 to search the source HTML of certain Text fields across multiple content types. For example, I want to find all nodes that contain <div class='special-list'> in one or more Text fields.

For Drupal 7, it seems that Views Bulk Operations would suffice. Has anyone encountered a similar need in D8?


texts: Getting all the nodes NOT tagged with a taxonomy term

texts:
I am a bit stuck with this... I am not a drupal expert (yet :D) so I really don't know if I am using the best approach...

I have few nodes tagged with some terms from a vocabulary. Let's say my node 1 is tagged with term 1 and node 2 is tagged with terms 2 and 3. My vocabulary has, let's say, 5 terms in total.

Is there a way of getting in a view all the nodes NOT tagged with a particular term? This mean if I had a content node in a view tagged with term1 (node 1 in our example) I could get in another display of that view (or even in another different view) a list of the remaining terms not tagged (2, 3, 4 and 5 in my example).

I know I can make it using "static" filters, but I need to extract the information (terms tagged) from the node itself, which is loaded dynamically using contextual filters.

I am using panels as well but I am not sure wether that details are worth explaining for my porpoise.

I hope my question is clear enough as English is not my mother tongue.

Thanks in advance for your help.


texts: CCK migration From Drupal 6 to Drupal 7: Which tables can I delete?

texts: After migrating the CCK fields from Drupal 6 to Drupal 7, which tables can I delete?


texts: How to add multiple terms to a taxonomy reference field via feeds?

texts:
I would like to import a node with multiple taxonomy terms referenced in one of node fields.
How can I do this with Feeds and Drupal 7 ?


texts:
When we implement, for example, theme_preprocess_page(&$vars) function, we can alter variable that are visible as not array items.

What I mean: $vars['somevalue'] from theme_preprocess_page(&$vars) function is further  available in page.tpl.php as $somevalue. How is it possible? Definitely there is some kind of automatic generation of variables but the implementation is unclear.


texts:
I would like to add a global gift wrap option to our checkout pane on Ubercart 3 (running on Drupal 7).

It is an option that can apply to any product and has a fixed price no matter how many products are purchased.

I do not want to add it as an attribute to individual products or product classes, but would like to add a simple yes/no radio button to all checkouts.  If yes is selected, the fixed amount is added to the order.

What is the simplest/best way to implement this?


texts: How can I allow the current user to only see their own page?

texts:
I created a page in a custom module. I want only the current user to access this page on their behalf.
For example, I am using it with ID 51. If I go to :
/user/51/tasks

I can see this page.
If I go on :
/user/78/tasks

I must have an error 403 access denied.
How to do this ?
task_notify.user_page.tasks:
  path: '/user/{user}/tasks'
  defaults:
    _controller: '\Drupal\task_notify\Controller\TaskNotifyUserController::Tasks'
    _title: 'Liste des tâches'
  requirements:
    _permission: 'access content'

UPDATE :
My custom module is here :
https://git.drupalcode.org/sandbox/zenimagine-3076032
I applied kiamlaluno's answer but I have the following error :

/task_notify/src/Controller/TaskNotifyUserController.php
<?php

namespace Drupal\task_notify\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;
use Drupal\user\UserInterface;

class TaskNotifyUserController extends ControllerBase {

  public function Tasks() {
    return [
      '#theme' => 'task_notify_user_template',
    ];
  }

  public function taskAccess(UserInterface $user, AccountInterface $account) {
    return AccessResult::allowedIf($account->isAuthenticated() && $user->id() == $account->id())
      ->orIf(AccessResult::allowedIfHasPermission($account, 'administer users'))
      ->cachePerUser();
  }

}


texts: How to pass variables to a theme template file from EntityAPIController::buildContent()

texts:
I may be going about this incorrectly, if so please point me in the right direction.

I currently have a custom entity type and I'm adding the display fields via a controller class that extends EntityAPIController. I want to attach some content from elsewhere (non-entities) to the display of this custom entity.

I have an implementation of hook_theme:

function module_theme($existing, $type, $theme, $path) {
  return [
    'module_plugin_instance' => [
    'template' => 'module-plugin-instance',
    'path' => $path . '/templates',
      'variables' => [
        'instance_id' => NULL,
      ],
    ],
  ];
}

Then, in EntityTypeController::buildContent() I have:

$buildContent['module_plugin_instance_' . $instance_id] = [
  '#theme' => 'module_plugin_instance'
];

Where I'm failing is I can't figure out how to pass variables to the theme template here.  The dummy html I'm putting in the template renders fine, just no variables.  I've tried several different things, but I can't seem to get $instance_id to my template - what am I doing wrong?


texts: Deployment strategy for servers on internal network

texts:
I am following composer based workflow for Drupal 8, in which I commit only custom code and use composer install to install it on another environment.

However, on new workflow, the dev, test, staging instances are on Internal network, with no access to Internet (due to security reasons).

Can you suggest a deployment strategy to use in this scenario, so that I don't have to commit the whole files in git repository, as is.

PS: I am ok with something like Acquia pipelines, where things are 'compiled' into a branch, which is used for deployment. But using that is ruled out, as the code can't be sent to outside because of security concerns.


texts: Display different fields depending on field value in node template

texts:
I have a field named field_event_type. When creating a node, you can select one of two options for this field from a drop-down list:

birthday party
Wedding

I want to be able to display different fields in my node depending on which type of event is selected. So in node--events.tpl.php, my node template, I wrote the following:

if ($element['#object']->field_event_type['und'][0]['value'] == 'birthday party' )
   {
      print render($content['field_some_field']);
   }

else
   {
      print render($content['field_some_other_field']);
   }

However, this does not seem to be working the way I intended it to, not only is it not displaying the additional field content in either event type, but I'm also getting an error in Drupal about an undefined variable. Is my code incorrect?


texts:
The percent sign is something I once saw in Drupal 6 and Drupal 7, but not  Drupal 8. It has been a few years ago; I don't recall where exactly inside a view, but most probably inside the contextual filter criteria.
What is percent sign in the arguments?


texts: Why does my user signup request have no response back?

texts:
I have a Drupal website hosted on a LAMP server (dev machine on intranet).

When tried to signup using the registration page (signup page for a user), the page keeps loading with message "waiting for server".

When tried to check using firebug add on in Firefox, I saw in the "network" tab that there is no response back for the signup request.

Does it have to do with the SMTP configuration within the server?

But once logging in  with admin and checking the "people" tab shows that the user is created but there was no email sent to verify the email address

So I believe the next step after user creation (according to code) gets failed due to which there is no response and email not sent. Appreciate any help on this.


texts: Show the content of a field only if the user is logged in?

texts:
I want to show a fields content in views not for guests, but only for logged in users.
(Drupal 8.30)


texts: Multiple node access rules for same node?

texts:
I'm using the Domain Access module to restrict content to specific domains. It uses the node_access table to do this.

I also want to make a single node hidden behind a login area. The problem is that when I add my node access rules to do this it overwrites all the Domain Access rules which mean that all the nodes appear on the same domain.

Is there a way to allow more than one module to use node access rules?

My node access code looks like this:

define('MYSITE_REALM', 'press');
define('MYSITE_GRANT_ID_PUBLIC', 0);
define('MYSITE_GRANT_ID_PRESS', 1);
define('MYSITE_PRESS_SECTION_NID', 554);
define('MYSITE_PRESS_USER', 'press');

/**
 * Implements hook_node_grants().
 */
function mysite_node_grants($account, $op) {
  if ($op == 'view') {
    $grants = array();

    if ($account->name == MYSITE_PRESS_USER) {
      $grants[MYSITE_REALM] = array(
        MYSITE_GRANT_ID_PUBLIC,
        MYSITE_GRANT_ID_PRESS,
      );
    }
        else {

      // everyone else
      $grants[MYSITE_REALM] = array(
        MYSITE_GRANT_ID_PUBLIC,
      );
    }

    return $grants;
  }
}

/**
 * Implements hook_access_records().
 */
function mysite_node_access_records($node) {
  $grants[] = array();

  if ($node->nid == MYSITE_PRESS_SECTION_NID) {
    $grants[] = array(
      'realm' => MYSITE_REALM,
      'gid' => MYSITE_GRANT_ID_PRESS,
      'grant_view' => 1,
      'grant_update' => 0,
      'grant_delete' => 0,
      'priority' => 0,
    );
  }
    else {
    // everything else is public
    $grants[] = array(
        'realm' => MYSITE_REALM,
      'gid' => MYSITE_GRANT_ID_PUBLIC,
        'grant_view' => 1,
        'grant_update' => 0,
        'grant_delete' => 0,
        'priority' => 1,
    );
  }

  return $grants;
}

function mysite_user_login(&$edit, $account) {
  if ($account->name == MYSITE_PRESS_USER) {
    drupal_goto('node/' . MYSITE_PRESS_SECTION_NID);
  }
    else {
    drupal_goto('');
  }
}


texts: How to add classes to h2 block title tags in sidebar region

texts: I need to add a class to the h2 block titles in a sidebar.  How can I do this in pre-process?  I haven't been able to find an example that shows how to isolate certain blocks.  I'm using Omega.


texts: Add a new role using the Drupal Services Rest api

texts: I'm trying to create a new role using the drupal services module. I am able to update a user with an already created role but can't find a way to add a new role. I'd rather not build a custom service for this so wondering if anyone knows of a way to do this without resorting to that.


texts: Is there any alternative to devel themer?

texts: I am using Theme developer module for theming. The module is pretty good, but still it is very buggy. Is there a less buggy alternative?


texts:
I will preface my post with saying I'm new to Drupal and feeling the upward learning curve but I am working my way through api.drupal.org and The Definitive Guide to Drupal 7. That being said. Here is what I'm trying to achieve.

1) Have a form collect user input.
2) When that form is submitted pass that data to the PHP passthru command.
3) Return the results preferably real time of that command as it's running. (I will settle for just getting the results right now AJAX can come later)

Where I am at: I have built a custom module to display the form. I believe my submit handler is even working and the script is kicking off. I just can't get the resulted data. Tried using drupal_get_message but nothing seems to happen.

<?php

function my_module_menu() {
$items = array();
$items['ios_upgrade/form'] = array(
'title' => t('IOS Upgrade'),
'page callback' => 'ios_upgrade_form',
'access arguments' => array('access content'),
'description' => t('IOS Upgrade'),
'type' => MENU_CALLBACK,
);
return $items;
}

function ios_upgrade_form() {
return drupal_get_form('my_ios_upgrade_form');
}

function my_ios_upgrade_form($form_state) {
$form['ipaddress'] = array(
'#type' => 'textfield',
'#size' => 30,
'#title' => t('IP Address'),
'#required' => TRUE,
);
$form['username'] = array(
'#type' => 'textfield',
'#size' => 30,
'#title' => t('Username'),
'#required' => TRUE,
);
$form['password'] = array(
'#type' => 'password',
'#size' => 30,
'#title' => t('Password'),
'#required' => TRUE,
);
$form['ios'] = array(
'#type' => 'textfield',
'#size' => 30,
'#title' => t('IOS File'),
'#required' => TRUE,
);
$form['md5'] = array(
'#type' => 'textfield',
'#size' => 30,
'#title' => t('MD5 Hash'),
'#required' => TRUE,
);
$form['ftp'] = array(
'#type' => 'textfield',
'#size' => 30,
'#title' => t('FTP Server'),
'#required' => TRUE,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
'#submit' => array('sample_form_submit'),
);
return $form;
}
function sample_form_submit($form, &$form_state) {
if (isset($form_state['values']['submit'] ) ) {
$int = 0;
$ip = $form_state['values']['ipaddress'];
$usr = $form_state['values']['username'];
$pwd = $form_state['values']['password'];
$ios = $form_state['values']['ios'];
$md5 = $form_state['values']['md5'];
$ftp = $form_state['values']['ftp'];

$message = passthru("expect scripts/ios-upgrade.exp $int $ip $usr '$pwd' $ios $md5 $ftp  2>&1");

drupal_get_message($message);
}
}

Ideally the user would be redirected to a new page to get this output, which sounds like a multi-step form would be in order. I'm trying to build this one small step at a time though before I add more layers of complexity.

Thank you in advance.


texts: How to implement arbitrary editable content areas

texts:
I'm trying to figure out the best way to implement pages with multiple editable content areas, each area on each page having a different set of HTML markup. The only solution I've found so far is to add a content type for each area so that I can create a custom block.

For example, on the homepage I have a mantle with image, title, and content:

Here's some example HTML I'd like to use for the structure of the editable content:

<?= $title ?>

            <?= $content ?>

I'd like for the user to be able to edit the image, the title, and the content, without editing the HTML that makes up the structure of the page. Each page on the site will have a different HTML structure, as well as different content areas that need to be editable.


texts:
How would I go about moving the "Add new comment" link above certain items in my content type display? Here's an example: http://www.jcpenney.com/women/fall-trend-shop/boyfriend/ana-boyfriend-cardigan-/prod.jump?ppId=pp5002961049&catId=cat100300005&subcatId=cat100250027&deptId=dept20000013&dimCombo=null&dimComboVal=null&colorizedImg=DP0705201317172824M.tif

In the link above you'll see the "write a review" link. This is where I want to place the "Add new comment" link.


texts:
I am trying to install some packages using composer manager. My installation failed reflecting the following error:

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.

I have tried to change setting in my composer file 'composer_manager.api.php' but it didnt give any result except the error mentioned above. Is there a different file where i can change the settings?
I can add extra details if needed.

Please help me in sorting this.

Thanks,
Chaithanya.


texts: How can Draggable Views be used in columns?

texts:
I have a content type in which I would like to be able to have a 3 column layout and the user is able to drag different content (nodes/blocks) from one column to another, inline. I have almost achieved this with Panels IPE but there are two main problems:

Users with IPE access have access to the IPE "Add Content" modal, and therefore access to all content on the site, I would need to restrict this somehow
The user experience is not exactly inline/in place, because when clicking customize the page changes quite significantly, I have tried modifying this via CSS but it only gets so far

I experimented with Draggable Views since and it solved both of the issues above, but it created a new problem. I cannot find a way to be able to drag View items from one column to another column, for example dragging a block from the left side bar to the right side bar. I have tried this using Panels and Draggable Views, but it only allows dragging inside one column. The closest module that I have found that has this functionality is JQuery Drag Drop Blocks module but it doesn't have a working D7 version. Is there a way that this can be done?


texts: Give some users (e.g., teachers) access to nodes created by a unique subset of other users (that teacher's students)

texts:
My site has roles for administrators, students, and teachers. Students create nodes, and each student has exactly one teacher. Teachers should be able to view all content created by their students, but no content created by other students. In other words, I'd like to have some kind of per-user setting that allows me to select one specific other user who can access the first user's nodes.

This seems like a pretty common situation, but I can't figure out how to do it. I'm open to any suggestions. Here are some things I've looked at so far:

I started out by using references to link each student to a teacher. However, I couldn't find a way to use that relationship for access control.
The subuser module looks appropriate, but I'm leery since the D7 version is still in alpha. Has anyone used it for this purpose?
Taxonomy access control looks like another possibility. The list of teachers is static, so it could be made into a vocabulary. But if Teacher is a per-student setting, is there a reasonable way to make that propagate down to the nodes created by that student?
Any other suggestions about how to do this?


texts: Get the position of a paragraphs entity in a nested template

texts:
I try to build an accordion or slider element with Paragraphs.

Therefore I create a Slider element which had slides. Unfortunately the first element should always looks different. I can do this with a CSS class, but how to figure out which is the first slide?

Slider:

            {{ content.field_feature_slider_slides }}

Slide (which will loaded through Drupal Magic):

  ...

How can I get/set/access a variable (here pos) with the current position of the loop?

The Slider uses Paragraphs to add several Slides. The is a template for the slider paragraph--slider.html.twig and paragraph--slide.html.twig for the slides. No For-Loops are involved here. Drupal/Paragraphs rendering the slides through the template with content.field_feature_slider_slides from the slider.


texts: Accessing the in-place editor with a keyboard hotkey ? (cross-platrofm Drupal question)

texts:
Quite hardcore, cross-platform programming question:

Can a logged admin user reach a state when clicking some button on the keyboard on a Drupal node opens its quick-edit widget to quickly edit the node?

Something that will work for all common systems (Ubuntu, Windows10, Mac).

Accessing the quick-edit widget in the current way tens if not hundred+ times a day can be a bit annoying in this could make the Drupal edit experience much better.


texts: How to get all filters and functions available in Twig templates?

texts: I have an option to create and edit twig templates via UI but I need to display what filters and functions are available to the user but I don't know how to get them.


texts: Use hook form alter to change input type

texts:
I am trying to change the input type on an ubercart checkout form using hook_form_alter. I added an extra field using the uc cart extra fields pane module but there is no option to add e-mail - only text - and I need the field I added to validate as an e-mail.

The field in question is:

<input type="text" id="edit-panes-billing-address-billing-ucxf-bill-to-email" name="panes[billing][address][billing_ucxf_bill_to_email]" value="" size="32" maxlength="255" class="form-text required">

The code I am using but with no success is:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'uc-cart-checkout-form') {
    form['panes-billing-address-billing-ucxf-bill-to-email'][LANGUAGE_NONE][0]['type'] = 'email';
  }

Thanks for any assistance!


texts: File field breaks AJAX form in Drupal 7 form API

texts:
This is a really strange one, I've created a custom form using the multi step form method. So there are various AJAX calls to handler functions that return certain sections of the form back to containers and replace the HTML.

My form works great has a lot of complexity to it and the speed is fantastic. A recent addition to said form is to be able to upload a PDF, simple I thought! Added my manged_file field and all looked great. However I'd missed that now my page was reloading, AJAX requests were no longer in the Firebug console and instead seemed to be in the POST somehow. I don't fully understand how the AJAX is still working but it is slower that's for sure!

This is a problem I think we could live with a bit of slowness but then I noticed on a full form submission it was breaking a second form outside of this form. Basically it's too big of an issue to live with now.

I've tried a few things, one a standard file field, two a markup field with a raw

<input type="file" />

just to see what happened and I experienced the exact same issue as using the form API. This confirms to me that this is not caused by some added javascript from Drupal but a problem with the input itself.

So my question is why does a file field break the AJAX in my form?

Rather awkwardly I can't just paste all my code here as the data is protected and technically not my property. I'm not sure it's needed but I've thrown together a quick bit of code that should demonstrate my issue.

function vv_test_menu(){
    $items = array();
    $items['vvtest'] = array(
        'page callback' => 'vv_test_page',
        'access arguments' => array('access content'),
        'page arguments' => array(false),
        'description' => t('Test page for code.'),
        'type' => MENU_CALLBACK,
    );
    return $items;
}

function vv_test_page(){
    $content = 'This demonstrates the file field breaking the AJAX.';
    $content .= render(drupal_get_form('vv_test_form'));
    return $content;
}

function vv_test_form($form, &$form_state){
    $form['#tree'] = TRUE;
    $form['#prefix'] = '
';
    $form['#suffix'] = '
';

    $form['job_number'] = array(
        '#type' => 'textfield',
        '#title' => t('Job number'),
        '#required' => TRUE
    );

    if($form_state['triggering_element']['#ajax']['callback'] == t('vv_test_call')){
        $form['result'] = array(
            '#markup' => '
You entered: '.print_r($form_state['values']['job_number'], true).'
'
        );
    }

    // - Comment this field in and out to see the problem
    $form['pdf'] = array(
        '#type' => 'file',
        '#title' => t('A file field')
    );

    $form['sync'] = array(
        '#type' => 'button',
        '#name' => 'sync',
        '#value' => t('Sync'),
        '#ajax' => array(
            'callback' => 'vv_test_call',
            'wrapper' => 'container'
        )
    );

    return $form;
}

function vv_test_call($form, &$form_state){
    $form_state['rebuild'] = FALSE;
    return $form;
}


texts:
What is the best way to connect to a remote database through drupal? Would the correct method be to use the settings.php with the database in there, and use the built in db_select, db_query() etc functions to access the remote database?

I have a system that has a bunch of entities, which are different 'servers'. Each server may or may not have a different database for up to 4 different services. Currently, I am storing the database connection details inside of the entity fields, and calling them using entity_load() as needed. In doing this, I am having to write my own SQL library and queries to retrieve data from the external databases.

I am wondering; if instead of writing the values to the entity fields, if I wrote them to maybe an external .php file (maybe dbconfig.php) or something, if there was a way I could still use the built in database functions and methods to access it, or if Drupal only reads from the settings.php for database connections.

I also question if using it on a table that doesn't use the same structure as drupal would even work. (It's a completely different service with it's own tables and structures).

What's the best way to handle this type of situation? I really would like to get away from writing my own library to use for remote connections, as being able to do pagination and all that using the built in methods is extremely helpful and already been tested and hardened.

Just trying to find the best way to get access to the drupal database methods/functions and still be able to update/edit/add new databases when they are needed without risking security, and without having to manually change permissions on the settings.php before making new changes. (The servers currently are automatically added as new entities by scanning a single remote db for new entries then using entity_create() to add them).

Is it possible for me to put an include('databases.settings.php'); inside of settings.php, and use $databases['database_name']['default'] = $info_array; inside of that file (and keep it writable) to store the new database values?


texts: Featuring content with "Existing Node" Panopoly

texts:
I am running Drupal 7 with Kalatheme and Panopoly and am looking to feature specific nodes in specific panes on the site. Currently, I am using the the "Existing Node" feature to pull the teaser of a specific node.

The problem is that I am not able to edit or change the node in that pane once it is placed. The content managers will not be able to add a pane each time they want to change the feature, because they will not know the classes and settings of each pane.

Is there a better way to go about featuring specific nodes that will allow our content managers to just change the node featured in that pane, without loosing any settings, or is there a quick fix that will allow us to edit the node as we are currently doing it?


texts: CTools modal with webform unable to close

texts:
I'm using the CTools modal with a webform, the form comes in via ajax. When a user is logged in, all works normally. If an anonymous user clicks on the link for the modal, I'm seeing the following behavior:

CTools modal close button does not work. No js errors.
The 2nd time the link to display the modal is clicked, the page links directly to the form page (no ajax, no modal).

For logged in users, the close button works and the button to trigger the overlay behaves properly on repeat clicks.

Any tips greatly appreciated.


texts: Link tags in template file auto closing.

texts:
I’m having an issue wrapping a link around some output in a template file.   I have the right template file; and I can put text like ‘start here’ and ‘end here’  and it prints out where I want the ‘a href’ tag to start and end.

However when I put in the starting ‘a href’ it auto closes.   I can put in a ‘div’ and that doesn’t auto close.   I’ve tried

  and although that html output looks right it doesn’t work either.

I’ve also used at ‘function l’ but can’t pass the $content in.

Any ideas how I can either stop the auto close, get the javascript to work or a function I can use to output the link but will except the content being passed in.

Here's my code

print '';
     print $field->content;
     print '';


texts: Views Dependent Filter showing when no controller value selected

texts:
I'm using Views Dependent Filters to have a filter show based on the value of a filter above it. It is working for the most part but it is showing the field by default (when no controller value is selected.)

When my multiple select filter  being used as the controller, the dependent field shows even when no value is selected. For example:

Vehicle:

Car (Set as controller)
Boat
Plane

Tire Size (Dependent Filter)

Small
Med
Large

Tire size shows when "car" is selected but also shows when no value is selected. I believe this the module is not intended to function this way.

Is there a solution to this or a possible alternative?


texts:
In Drupal 8, I was thinking that's a simple task but it's not :

function hmytheme_preprocess_field(&$variables, $hook) {
    $element = $variables['element'];
    if (isset($element['#field_name'])) {

        if($element['#field_name'] == "bar"){
             element['#items']->value ="foo";
             //or
             element['#items']->set(0,"foo");
        }
    }
}

this is not afecting the render.
How to ?
I don't whant to save the altered value


texts: How to print taxonomy terms field in node templates?

texts:
How can I display node taxonomy terms field in node templates of Drupal 8?

We do this in Drupal 7 by add this code to node.tpl.php file:

print render($content['field_tags']);

I tried adding the below code in Drupal 8:

{{ content.field_tags }}

but with this code have problems:

If I add some styles or make some changes to field--node--field-tags.html.twig file these changes displays in all content types also.
If I don't want to show default taxonomy terms in the bottom of article nodes (I want to move and show taxonomy terms in the top of the article) and I assign "Hidden" value in "Administration>Structure>Content types>Article" in "Format" section, this settings cause to not displays all the taxonomy terms fields in throughout of the article nodes at all.
Taxonomy terms Label always display even if no tags added to the node. How can I show taxonomy terms label and their values only when have been added any tags to it?


texts: How do I get the username from the user ID?

texts: I want to print the username knowing just the user ID. How do I achieve this?


texts: Memcache Admin not showing up in Modules

texts:
I am updating a Drupal 6 installation to support memcached. After installing the memcache plugin, and configuring it with the following in settings.php, I cannot seem to access the Memcache admin page like I can on Drupal 7.

$conf['cache_inc'] ='sites/all/modules/memcache/memcache.inc';
$conf['memcache_servers'] = array(
  'ELASTICCACHE URL (Left out Intentionally)' => 'default'
  );
$conf['memcache_bins'] = array(
  'cache_page' => 'pages'
  );

I checked in modules to see if it was enabled but I do not see it there at all. All I can see is the memcache module without memcache admin.

Any suggestions?


texts:
I'm using a Vagrant environment generated from https://puphpet.com/ for a Drupal project & it is all going well except for Drush which gives me an error any time I try running "drush cc -all", see the error below.

Additional uncaught exception thrown while handling exception.

Original

PDOException: SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected: SELECT 1 FROM {blocked_ips} WHERE ip = :ip; Array
(
[:ip] =&amp;gt; 127.0.0.1
)
in drupal_is_denied() (line 1933 of /var/www/includes/bootstrap.inc).

Additional

PDOException: SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected: SELECT * FROM {system} WHERE type = &amp;#039;theme&amp;#039; OR (type = &amp;#039;module&amp;#039; AND status = 1) ORDER BY weight ASC, name ASC; Array
(
)
in system_list() (line 165 of /var/www/includes/module.inc).

Drush command terminated abnormally due to an unrecoverable error.                                                                                [error]

From what I gather the problem is that it isn't selecting a database. Does anyone know where the details for this would be stored? The Drupal site itself is connecting & using the database fine.

I'm not sure if this would cause and issue but the database details for the Drupal site are stored as an Apache environmental variable.


texts: How can I use LESS in a subtheme in Drupal 6?

texts:
I have a site with the LESS module installed. The main theme CSS, main.css.less uses @import "lib.less" to define a set of variables that I use for different text colours, etc.

Now, I want to create a sub-theme. This subtheme is identical to the main theme except lib.less contains different colour values for some of the variables. I set it up in the normal Drupal 6 manner. Again, I want to keep the styles, just change the colours by getting the main lib.less to be overriden by my subtheme's lib.less.

When the subtheme pulls in main.css.less from the main theme, it also pulls the main theme's lib.less, even though in my subtheme I have a different lib.less. I have also tried adding this to my subtheme info:

stylesheets[all][] = css/lib.less

To try and get it to recognise the subtheme's LESS variables, but it always brings in the main theme lib.less. Any ideas?


texts: Images uploaded with CKeditor disappear after cron run

texts:
When i upload images with CKeditor in a directory inline-images - they disappear after each cron run. Why is that happened? I had a look at db table file_managed it's status set to 0.

What it might be?


texts:
How can I configure Drupal 8 with multi-site under an add-on domain using cPanel?  I'm getting a 404 when I browse to my subdomain after following these steps:

Clean install of Drupal to my add-on domain: /public_html/addondomain.com/drupal.  I can successfully browse to addondomain.com/drupal
In cPanel, create a sub-domain at sub.addondomain.com with a document root at /public_html/sub.addondomain.com
Create the directory /public_html/addondomain.com/drupal/sites/sub.addondomain.com
Create a sites.php within public_html/addondomain.com/drupal/sites that contains the following code:
<?php $sites = array('sub.addondomain.com' => 'sub.addondomain.com',);>.  File permissions are 644.
Copy /public_html/addondomain.com/drupal/sites/default/default.services.yml to /public_html/addondomain.com/drupal/sites/sub.addondomain.com/services.yml
Copy /public_html/addondomain.com/drupal/sites/default/default.settings.php to /public_html/addondomain.com/drupal/sites/sub.addondomain.com/settings.php
Remove the directory /public_html/sub.addondomain.com
Create a symbolic link in /public_html/: ln -s addondomain.com sub.addondomain.com

When I do all of the above, I get a 404 error when I browse to both sub.addondomain.com and sub.addondomain.com/drupal.  Why am I not redirected to the Drupal installation page where I can enter in my database info, etc.?  Is the error with my symlinks?  My server (cPanel) configuration?  My .htaccess under either my /public_html, public_html/addondomain.com, or /public_html/addondomain.com/drupal?


texts: Does this look right for adding a terms of use checkbox to register form?

texts:
And also, how can I get node/terms to open target="_blank"?

<?php

function MYMODULE_form_alter(&$form, $form_state, $form_id) {
    if($form_id == 'user_register') {
  $form['legal'] = array(
      '#type' => 'fieldset',
      '#title' => t('legal'),
    );
  $form['legal']['select'] = array(
      '#type' => 'checkbox',
      '#required' => TRUE,
      '#title' => t('Terms of Use*'),
      '#default_value' => 0,
      '#description' => t('I certify that I am over the age of 18, and I have read and agree to the '.l('Terms of use.','node/terms').''),
    );
  $form['#validate'][] ='customfunctions_form_validate_custom';
  }

}

function MYMODULE_form_validate_custom($form, &$form_state) {
    $legal = $form_state['values']['select'];
    if ($legal == 0) {
        form_set_error('select', 'Please check the agreement.');
    }
}

?>


texts:
I am using hook_mail_alter to modify the email that the user gets when an administrator creates an account. What I am trying to do is create a link in the email body, the link gets created but it adds a [1] to the link text and after the email text is done. There is the [1] again with the actual link. Is there anyway to actually have the link created in the text instead of having it render at the end? Here is my code:

function my_module_mail_alter(&$message) {
if ($message['id'] = 'user_register_admin_created') {

    $url = Url::fromUri('https://www.google.com');
    $external_link = \Drupal::l(t('Google'), $url);
    $message['body'][] = t("Go to: ");
    $message['body'][] = $external_link;
}
}


texts: hook_menu_get_item_alter() needs to give a 404

texts:
How can I throw a 404 error from within hook_menu_get_item_alter()?

If I call drupal_not_found() then it keeps calling itself, and I don't know an other way to do this.


texts: Why is it easily possible to theme node add forms and not node edit forms?

texts:
Why can i override:

page--node--add--mycontenttype.tpl.php

and not:

page--node--edit--mycontenttype.tpl.php

What is actually quite the same form?


texts: Make Foo and foo to be different free tagging tags in Drupal 6

texts: I need a way to make Foo and foo to work as two different freetagging words in a Drupal 6 taxonomy field, any suggestions for this?


texts:
I am working on a site where I changed the "email template" email to be sent on registration request to the user. How can I change the "email template" email sent to the site administrators?

I am using Drupal 7.


texts: How can I implement a custom display widget for an existing field?

texts:
Basically I want to have my own widget as a choice in the widget drop down of an existing field type; and/or I want to be able to call field_view_field on a field and have it display the way I need, using info from the field itself and elsewhere.

I can probabaly do what I need with template_preprocess_field but I would prefer to hook the existing admin interface for selecting the output of the form.

I'm assuming that a solution is available that would allow the output of the field to be the way I configure it any place the field can be displayed, Views, etc.

Thanks in advance.


texts: views pass argument for number of records to display to pager contextual filter?

texts:
Drupal 7.

Is it possible to pass an argument to the contextual filter to limit number of items to display in a View from the UI?

IOW: can you pass an argument that replicates the Number Of Items portion of the Pager?

I have a node form which uses View Fields to display a view of related items. I want to pass an argument via the Field Display which limits the # of records.

If this must be done programmatically, how do I hook into the view 'contextually'... ie. so that the hook overrides the Number Of Items when the visitor is on a particular page (a Node of a certain Content Type.)


texts: Taxonomy terms with associated nodes: display page by page navigation in node page?

texts:
Hi i have a content type called Product and have fields(title,description,code,image) and also have vocabulary categories like below formate

parent term 1
 -child term 1
    --sub child term 1.1
    --sub child term 1.2
    --sub child term 1.3
    --sub child term 1.4
    --sub child term 1.5
parent term 2
  --child term 2
    --sub child term 2.1
    --sub child term 2.2
    --sub child term 2.3
    --sub child term 2.4
    --sub child term 2.5
.
.
parent term 5
  --child term 5
    --sub child term 5.1
    --sub child term 5.2
    --sub child term 5.3
    --sub child term 5.4
    --sub child term 5.5

so i want to display my product node page first parent terms list when i click parent term 1 then it's display all related child terms in next page after that when click child term 1 display all related sub child terms list in another page after that when i click sub child term 1.1 need to display related products list with above fields.Please find below flow of screen shots.

Taxonomy Parent Terms list
Step 1

Step 2 when i clk Parent term 1 need to display all related child terms in another page like below

step 3 when i clk child term 1 need to display all related sub child terms in another page like below

step 4 when i clk sub child term 1.1 need to display all related node i.e product items list with above fields info.

Please advice
Thanks.


texts: Modify parent entity from within custom field formatter

texts: How can I modify parent entity's output from within my custom field. I am writing a custom field that adds css class to blocks. Everything is set, except I don't know how to modify the parent entity.


texts: Duplicated content shown in a view using a relationship

texts:
I am using a view that has a contextual filter ("Content: Has taxonomy term ID") and a relationship ("Content: Taxonomy terms on node"); for some reason, I keep getting duplicated content. In the view settings I have "Distinct" checked.

Are there any other options I can look into?


texts: How to override code of module in custom module?

texts:
I am using Content Taxonomy module and trying to override some code, when I tried to modify in my custom module then the module functions also keeps running. And by modifying module file my purpose get solved but is there any way to do it in my custom module, please suggest:

CODE NEED TO MODIFIED:

/**
 * Form element validate handler for taxonomy term autocomplete element, which denies any new terms.
 */
function content_taxonomy_autocomplete_validate_deny_new_terms($element, &$form_state, $form) {
  $values = $form_state['values'];
  foreach ($element['#array_parents'] as $parent) {
    $values = $values[$parent];
  }
  foreach ($values as $delta => $value) {
    if ($value['tid'] == 'autocreate') {
      form_error($element, t('%name: new terms are not allowed. Please choose from the given list.', array('%name' => $element['#title'])));
    }
  }
}

DOING LIKE BELOW:

function custom_overrides_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
  // Add validation function to taxonomy_autocompletes, if necessary.
  $instances = field_info_instances($form['#entity_type'], $form['#bundle']);
  foreach ($instances as $instance) {
    if (($instance['widget']['type'] == 'taxonomy_autocomplete' || $instance['widget']['type'] == 'autocomplete_deluxe_taxonomy')
      && isset($form[$instance['field_name']])
      && isset($instance['widget']['settings']['content_taxonomy_autocomplete_new_terms'])) {

      // Use the language that is used in this form (which doesn't necessarily
      // be the default language in $langcode).
      $lang_key = $form[$instance['field_name']]['#language'];
      if ($instance['widget']['settings']['content_taxonomy_autocomplete_new_terms'] == 'moderate') {
        $form[$instance['field_name']][$lang_key]['#element_validate'][] = 'content_taxonomy_autocomplete_validate_moderate_new_terms';
      }
      else if ($instance['widget']['settings']['content_taxonomy_autocomplete_new_terms'] == 'deny') {
        $form[$instance['field_name']][$lang_key]['#element_validate'][] = 'custom_content_taxonomy_autocomplete_validate_deny_new_terms';
        var_dump($form[$instance['field_name']]);
      }
    }
  }
}

/**
 * Form element validate handler for taxonomy term autocomplete element, which denies any new terms.
 */
function custom_content_taxonomy_autocomplete_validate_deny_new_terms($element, &$form_state, $form) {
  global $user;
       if($element['#title'] == "Topic"){
          if (!$user->uid) {
                $values = $form_state['values'];
                foreach ($element['#array_parents'] as $parent) {
                  $values = $values[$parent];
                }
                foreach ($values as $delta => $value) {
                  if ($value['tid'] == 'autocreate') {
                     form_error($element, t('%name: new terms are not allowed. Please choose from the given list.', array('%name' => $element['#title'])));
                  }
                }
            }
      }else{
            $values = $form_state['values'];
            foreach ($element['#array_parents'] as $parent) {
              $values = $values[$parent];
            }
            foreach ($values as $delta => $value) {
              if ($value['tid'] == 'autocreate') {
                form_error($element, t('%name: new terms are not allowed. Please choose from the given list.', array('%name' => $element['#title'])));
              }
            }
      }
 }

By Doing this now I have my custom validator running and my custom module weight is 1000 and contrib module weight is 0 but still its not working because I think second validator function as shown below in output of var_dump need to be unset by some way:

'#element_validate' =>
        array (size=3)
          0 => string 'taxonomy_autocomplete_validate' (length=30)
          1 => string 'content_taxonomy_autocomplete_validate_deny_new_terms' (length=53)
          2 => string 'custom_content_taxonomy_autocomplete_validate_deny_new_terms' (length=60)


texts: Is it possible to create a template (tpl) file for comment view mode?

texts:
I created a new view mode for comments called "cool", as shown in the image below (click the image for full size):

I created comment--cool.tpl.php and added it to my theme template folder.

Based on the question about Custom tpl for view mode for all contenty type, I also need to add a pre-process to my theme. I tried:

  function MyThemeName_preprocess_comment(&$vars) {
  $vars['theme_hook_suggestions'][] = 'comment__' . $vars['view_mode'];
  }

But I get an error "Undefined index: view_mode"

Seems like comments preprocess doesn't have view_mode as an argument. So I guess it's not possible to create a tpl for comments? OR is there another way?


texts:
As implied in this question, I'm adding a list of similar child forms to my parent form with the following code:

foreach ($form_state['items'] as $key => $item) {

    $existing = NULL;
    if (isset($form['item_holder'][$key])) {
        $existing = $form['item_holder'][$key];
    }

    $state = NULL;
    if (isset($form_state['item_holder'][$key])) {
        $state = $form_state['item_holder'][$key];
    }

    $el = item_form_edit($existing, $state, $item);

    $form['item_holder'][$key] = $el;
}

I am calling the form function directly because drupal_get_form() was causing errors due to confusion about which form was being submitted.

My child form type has ajax callbacks that return parts of it $form object. But  the child's callback function is receiving the parent form's object and causing an error trying to return parts of the child form.

How do I sort out ajax calls between parent and child $form contexts? Do I need to go back and add the child forms with drupal_get_form()? If so, how do I avoid confusing which form has been submitted?


texts: How to upload images via CKeditor 6.x - 1.3?

texts: is there any way to one click upload images with a CKeditor? Found this https://drupal.org/project/ocupload but sadly - its for 7.x version of Drupal :(


texts: Enabled Panels In-Place Editor module but cant see the edit icon

texts:
I am using Panels and have enabled the Panels In-Place Editor module but cannot see the edit icon on the page, the one that should be in top rhs corner.

What am I doing wrong?


texts:
How to change slider widget price range text and "Go" label in KickStart Commerce?

Want to remove "range from...." and change "Go" on the button to Russian "Найти".

What Drupal display view or template, page or module to change? Thank you (see fig. attached, please).


texts: how to check non existent field added later using entityfieldquery?

texts:
I added a required field in a Job type node later. So existing nodes don't have that particular field value.
I want to include all such field values. But how can I do it?

Here is query sample:

$query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', array('central_government_vacancy','psu_vacancy','state_government_vacancy'))
    ->propertyCondition('status', 1)
    -> fieldCondition('field__expired_processed', 'value', 'NULL', '=')  //I'm looking for this field
    ->fieldCondition('field_last_date_of_application', 'value', $date, '<=');

In the above code I want to find nodes having uninitialized field values : field_expired_processed.

!=, or using NULL to compare does not seem to work.


texts:
I have a view and i use a date field for grouping. The position of the grouping field is at the top of the view row.
Is it possible to position the grouping field at the bottom of the view row?


texts:
Our Drupal system has the Services module enabled and is able to return nodes as json using the following url format

http://www.example.com/my_endpoint_path/node/123.json

But I want to retrieve a node using the URL alias I set in the URL path settings tab. I hoped the following would work

http://www.example.com/my_endpoint_path/my_pages_URL_alias.json

But it does not. Is there a way to configure Drupal/Services to fetch nodes by that URL rather than the node id?


texts:
I am running a 7.41 with views 7.3.1.3 version and editing views causes ajax error?

here is the current error code :

an ajax http error code.
http status :500
[{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"seven","theme_token":"L0_2m6Pw1Y-YlW1YH8Xlfc_C0oFxmC1n0tPxBJZyDLA","jquery_version":"1.10"},
"artPortfolio":{"art_portfolio-block_1":{"columns":"3"}},"better_exposed_filters":{"views":{"art_portfolio":{"displays":{"block_1":{"filters":[]}}}}},
"viewsImplicitFormSubmission":{"views-ui-preview-form":{"defaultButton":"preview-submit"}},
"ajax":{"preview-submit":{"wrapper":"views-preview-wrapper",
"event":"click","progress":{"type":"throbber"},
 "method":"replaceWith","url":"\/admin\/structure\/views\/view\/art_portfolio\/preview\/block_1\/ajax","submit":{"_triggering_element_name":"op","_triggering_element_value":"Update preview"}}},
"urlIsAjaxTrusted":{"\/admin\/structure\/views\/view\/art_portfolio\/preview\/block_1\/ajax":true,"\/admin\/structure\/views\/view\/art_portfolio\/preview\/block_1":true}},
"merge":true},

Why is this happening in this version? Do I need to downgrade, or is it due to the jquery_update module? I tested on the following jquery versions :

1.5
1.7.2
1.8
1.9
1.10
but all are not working.

Any help would be appreciated.


texts: Custom module Pager does not work with Ajax filter

texts:
My custom module uses an Ajax enabled drop down to allow users to filter images. There is also a pager attached to the query. The pager works fine when all the data is displayed i.e. no filter applied but after applying a filter, clicking a pager button just gives a white screen.

Here is my code.

function view_colouring_sheets($form, $form_state){
$query = db_select('field_data_field_image','fi')->extend('PagerDefault');
$query->join('node','n','n.nid = fi.entity_id');
$query->fields('fi');
$query->fields('n',array('title'));
$query->limit(20);
if($form_state['input']['tid']){
    $query->condition('entity_id',  colouring_sheets_filtered_tid($form_state['input']['tid']),'in');
}
$images = $query->execute()->fetchAll();

$output = array(
    '#theme'=>'image_matrix',
    '#type'=>'markup',
    '#images'=>$images,
    '#title'=>'Colouring Sheets',
    '#pager'=>theme('pager'),
    '#filter_form'=>  drupal_render(drupal_get_form('image_filter_form')),
);

return $output;
}

function colouring_sheets_filtered_tid($tid){
    $query = db_select('field_data_field_image_category','ic');
    $query->condition('field_image_category_tid',$tid);
    $query->fields('ic');
    $result = $query->execute()->fetchAll();
    $term_array = array();
    foreach($result as $row){
        $term_array[] = $row->entity_id;
    }
    return $term_array;
}

function image_filter_form($form, $form_state){
    $terms = taxonomy_get_tree(18);
    $terms_array = array();
    foreach($terms as $term){
        $terms_array[$term->tid] = $term->name;
    }
    $form['tid'] = array(
        '#type'=>'select',
        '#options'=>$terms_array,
        '#required'=>TRUE,
        '#title'=>'Fitler Images',
        '#ajax'=>array(
            'method'=>'replace',
            'wrapper'=>'image_matrix',
            'callback'=>'view_colouring_sheets',
            'progress' => array('type' => 'throbber', 'message' => 'Images Loading'),
            'effect'=>'fade',
        ),
    );
    return $form;
}


texts:
I keep getting the following error, although I've turned off SafeMode in my .ini file, and confirmed it's off with a PHP status page.

  The following restricted PHP modes have non-empty values:
      open_basedir. This configuration is incompatible with drush.  Please
      check your configuration settings in
      /usr/local/php-5.2.17/etc/php.ini or in your drush.ini file;

safe_mode            Off        Off
memory_limit        168M       168M
open_basedir    no value   no value

UPDATE:
I think it's worth noting that this is on MediaTemple's Grid Service (gs). It looks like the PHP CLI is actually using a different .ini file with open_basedir set. So I'm still trying to figure that part out.


texts: How to convert multiple node in Json format to use in Apps?

texts:
I have created a custom module which takes post argument and sent the result in json format.

function cfood_api_get_stadium_list($cn, $city){
    $query = new EntityFieldQuery();
    $entities = $query->entityCondition('entity_type', 'node')
            ->entityCondition('bundle', 'stadium')
            ->propertyCondition('status', 1)
            ->fieldCondition('field_address', 'country', $cn, 'LIKE')
            ->fieldCondition('field_address', 'locality', $city, 'LIKE')
            ->execute();
    $results = node_load_multiple(array_keys($entities['node']));
    $r = array();
    $i = 0;
    foreach($results as $result){
        $r[$i]['title'] = $result->title;
        $r[$i]['nid'] = $result->nid;
        $r[$i]['type'] = $result->type;
        $r[$i]['field_image'] = $result->field_image;
        $r[$i]['field_restaurantss'] = $result->field_restaurantss;
        $r[$i]['field_address'] = $result->field_address;
        $r[$i]['field_wing_no'] = $result->field_wing_no;
        $i++;
    }
    if(empty($results)){
       $results['error'] = "No record found";
    }
    return drupal_json_encode($r);
}

In postman the result looks ok but in apps additional "\" comes like

["[{\"vid\":\"74\",\"uid\":\"1\",\"title\":\"Stadium1\",\"log\":\"\",\"status\":\"1\",\"comment\":\"1\",\"promote\":\"0\",\"sticky\":\"0\",\"nid\":\"74\",\"type\":\"stadium\",\"language\":\"und\",\"created\":\"1451888078\",\"changed\":\"1453726703\",\"tnid\":\"0\",\"translate\":\"0\",\"revision_timestamp\":\"1453726703\",\"revision_uid\":\"1\",\"field_image\":{\"und\":[{\"fid\":\"85\",\"uid\":\"1\",\"filename\":\"tennis.jpg\",\"uri\":\"public:\\/\\/tennis.jpg\",\"filemime\":\"image\\/jpeg\",\"filesize\":\"16638\",\"status\":\"1\",\"timestamp\":\"1451888078\",\"rdf_mapping\":[],\"alt\":\"\",\"title\":\"\",\"width\":\"350\",\"height\":\"230\"}]},\"field_restaurantss\":{\"und\":[{\"target_id\":\"6\"},{\"target_id\":\"5\"},{\"target_id\":\"4\"},{\"target_id\":\"77\"},{\"target_id\":\"75\"}]},\"field_address\":{\"und\":[{\"country\":\"IN\",\"administrative_area\":\"DL\",\"sub_administrative_area\":null,\"locality\":\"Delhi\",\"dependent_locality\":\"\",\"postal_code\":\"110014\",\"thoroughfare\":\"Jawaharlal Nehru Stadium\",\"premise\":\"\",\"sub_premise\":null,\"organisation_name\":null,\"name_line\":null,\"first_name\":null,\"last_name\":null,\"data\

How to remove this addition "\" . Am i missing something.


texts: How should I store a simple, time dependent, repetitive data type in drupal

texts: Im interested in collecting simple data series over time with Drupal. for instance, lets say a user wants to input a monetary amount the spend on a given item each day, and then track that over time. It seams like overkill to log the information as a node, or even an entity for that matter. What is a good way to store data of this nature?


texts: Is it possible to call a custom module function in the theme template file?

texts:
I created a custom module and there is a simple hello_world() function. Is it possible to call this function in the page template file?

Module file looks like this.

function choco_custom_newui_total_students(){
return 500;
}

function choco_custom_newui_preprocess_page(&$variables) {
    $variables['total_students'] = total_students();
}

page--front.tpl.php

<? echo $total_students?>


texts:
I've installed the Facebook OAuth module which is an essential part of the website I am building. Unfortunately, the connection fails:

  "The Facebook login could not be completed due to an error. Please create an account or contact us directly. Details about this error have already been recorded to the error log."

The module seems to perform just fine in the beginning. Once I click on the FConnect button, I am redirected to facebook website, asked to login and grant access to precisely that information which I asked for when configuring the module.

(Also, when I misconfigure the facebook app, for instance by entering the wrong site domain, I am blocked much further in the process.)

The problem occurs when I am sent back from facebook to my website. Then instead of being connected, I receive the error message I mentioned.

I have had a valuable exchange with the maintainer of the module that can be found on http://drupal.org/node/1994900#comment-7419898. Unfortunately, he could not figure out the problem.

I have spent two days on it, trying many different things, but I could not find a solution. You can find a complete record of my different attempts on http://drupal.org/node/1994900#comment-7419898, but to summarize I have:

checked solutions proposed in related issues, http://drupal.org/node/1441978, http://drupal.org/node/1466598,
http://drupal.org/node/1974488.
Tried with and without clean url's
Tried to disable absolutely all the modules except for fb oauth to check whether it was a module compatibility issue (also tried a clear install of drupal with only Facebook Oauth module)
Checked that http requests were enables on my server.
Tried the alternative Fbconnect module, but I could not configure it either (I got unsolvable errors message before I could even try a connection).

Now I am short of ideas... Anything to propose?

I must say that I am a beginner, so I do not get most technical details. My sepcs are:

Drupal 7.22
Facebook OAuth 7.x-1.6
Hosted by Host1Free.


texts: Display unique text and button in nodes in a view in drupal 7

texts:
I have created a view listing 'invitation' nodes. When viewing each invitation on a full page, I have created a small block to allow people to RSVP to these invitations, but I would like to give them access to the button to RSVP directly from the view list.

Basically, if the user viewing the node in the list was invited to the event, something like this would show:

'You have been invited. RSVP here [button]'

Or if they have already RSVP'd:
'You are attending. Change your RSVP [button]'.

Any suggestions on how to do that?

A few more details:
- I created a custom module to handle the invitation process and form on a full view of the nodes. Details of invitations (who, where, when) are stored in a database.
- when the user is on the invitation in full view, i have created a block to display the RSVP form, adapting it to the status of the RSVP of the user.


texts: What field is Views using to determine the pager 'offset'?

texts:
When I use Views > pager > 'items to display' and set the offset value ... what field is Views using to determine the pager 'offset'? Is it 'post date'?

How can I change the offset to use a different date field that I've created?


texts: hook_user_insert() doesn't fire a custom rule

texts:
The operation should be as follows: Trigger an event after registering a new user.

test_rules_rules_event_info (example_rule_event) it's my event
test_rules_user_insert when a user is registered
test_rules_customFunction the function that is called by the rule

Therefore, when a user is registered, my event is triggered, and `test_rules_customFunction() is called by running the PHP code set by the Rules interface.
When the user is created from the UI, this is done. When the user is programmatically created, this doesn't happen.
The code I am using is the following.
function test_rules_rules_event_info() {
  return array(
    'example_rule_event' => array(
      'label' => t('Regola test, quando un utente è registrato'),
      'module' => 'test_rules',
      'group' => 'test' ,
      'variables' => array(
        'current_user' => array('type' => 'user', 'label' => t('The current user.')),
      ),
    ),
  );
}

function test_rules_user_insert(&$edit, $account, $category) {
  watchdog("test_rules_user_insert", '
' . print_r( $account, true) . '
');
  rules_invoke_event('example_rule_event', $account);
}

function test_rules_customFunction($current_user){
  watchdog("test_rules_customFunction", '
' . print_r( $current_user, true) . '
');
  var_dump($current_user);
  exit;
}


texts:
We have a Drupal 7 site whose content is split into geographic regions. The concept is that page view blocks and filters will display region specific content based on the users IP address or selection of their country, the page URL is the same throughout.
The issue we now have is that Drupal cache and Varnish cache are not regionally aware in that the cache is built up by the first visit upon start and clearing of cache so the wrong content gets displayed to a user who wishes to view content for his region, because someone before him opened the same page from another region. Any ideas?


texts: Is the tags section valid in the info.yml file?

texts:
I see in the devel.info.yml file a section named tags

tags:
- developer

But I can't find it on the documentation page. Is the tags section valid in the info.yml file or is it just an error?


texts:
I'm using media and domain modules.
Nodes are assigned to multiple domains and there are image fields that link to media images on those nodes.
Some content types also use paragraphs and these paragraphs hold their own image fields, referencing media images.

The media view (/admin/content/media) provides some nice information out of the box and I have added a relationship to the image field used on nodes which allows me to add a field for Affiliate domains for the nodes that hold these images. This adds a list of domains for each media image (used on nodes) to the media View.

I need to display the same information for the image fields used in paragraphs. I can add a relationship to these paragraph image fields but that doesn't add an available field that would allow me to display the domains these paragraphs are assigned to. I guess that has to do with config entities not mixing very well with the domain module and Views.

What would the best way to add this field to the media view? A custom field handler seems to be the best bet but it seems that a query is needed to get the domains to which each node (holding a paragraph that holds an image field) is assigned to.

What's the best strategy to get this custom "computed" field into my view?


texts:
I migrate an old not drupal site to drupal 9.
I have a content type called "Team". This content type has some fields that the client needs a fast access/edit to all of them using a table like the old site:

Is there any module/plugin that let me do this? Or should I have to create a custom one?


texts: Showing fields or content with Views - which is faster?

texts:
Say I'm building a view that lists 30 nodes. My understanding is that using fields in the view is faster than content (teaser), because the latter would need to call node_load 30 times? At least, I think this was the case with D6.

I appreciate the performance of both options depends on number of fields and types of fields used (entity reference, dates etc add query overhead). But does anyone have a general steer on this?

Thanks


texts: Only enable SSL for specific websites (Aegir)

texts:
So Aegir has a manual page on SSL.

I need to enable for one website. I enable SSL for the server and then require the certificate on that website.

But now, if I go to any other website on the same server and try the address with https://, it will present that incorrect certificate and a big error message comes up.

How can I enable SSL only for that one website I need and disable it completely for other sites?


texts:
I am using Drupal version 7.42 and a content type used for information regarding Concert setlists. It includes labels for:

Date.
Venue.
Location.
Setlist.
Description.
Lineup.

I will give you an idea of what I am looking to achieve in the end regarding its display. I also have a content type for the Songs.

Each performance listing will be different. I will have some listings that show Songs known to be performed yet the Setlist isn't complete. I will have some listings that show songs known to be performed in:

Set 1.
Set 2.
Encore.
etc.

Also, some performances may have more than one encore, so I also will have performances noted with Encore 1, Encore 2, etc. if the listing requires it.

How do I manage to get the display of the setlist to show a label above the songs indicating the song placement?

I thought having multiple fields in the content type (Set 1, Encore, Encore 1, Encore 2, etc) does the trick. But with time mulling over this one I am thinking is it possible to be achieved by just having one setlist field (Setlist) instead of multiple setlist fields in the content section?

Below is an example of the display I am describing for site viewers to see when visiting a performance page. Each song listed in a performance page at the moment uses Entity Reference to link to its unique song within the Songs content type.

Set:

Song 1
Song 2
Song 3

Encore 1:

Song 4
Song 5

Encore 2:

Song 6

Any suggestions?


texts:
I have a dev site with many modules.  I have another dev site on a different server that I'd like to populate with the same modules.  I can zip 'em up and move the file, or use rsync, but I wanted to see if drush-make would do it faster.

I can create only modules without core using: "drush make --no-core makefile.make" within the module directory but this creates the sites/all/modules directory hierarchy.

How can you use drush make to just build the modules in the modules directory without that structure?


texts: Does anyone have any solutions for multiple users using one profile? Looking for something like profile2 but with the option open for more than one person to use a single profile. Say for instance a company name or organization.


texts: Which access control module will allow me to use limit visibility of individual nodes?

texts: There are a ton of Access control modules. Choosing one is difficult. The current use case is that I have a single video content type. Some videos are public and some are private that are only accessible by role. I want to be able to set each node (public or private) and then ensure that they do not show in taxonomy term pages and views pages unless they are logged in. Which module is best for this use case? Note that the term and view pages will be the shared but I need private ones to automatically removed if they are not logged in. Which access control module will meet these needs?


texts:
While editing a node I've printed the dsm($form) in hook_form_alter and in the dsm array I see the following values:

....
form_id (Array, 3 elements)

    #type (String, 6 characters ) hidden
    #value (String, 14 characters ) unit_node_form
    #id (String, 19 characters ) edit-unit-node-form

.....

This node's machine name is "unit" I want to know what is the difference between #value and #id values.

I want to catch form alter of only this node while editing it.


texts:
I have just installed search auto complete module,its working fine,but the problem is its showing title before every result like:

title: Drupal 7.9 Release

tile:Understanding Drupal

Here Drupal 7.9 release and Understanding Drupal are my article title may be due to that its showing,but anyhow i want to remove this.

Thanks


texts: views and views data export (a question about drupal scaling)

texts:
our drupal site has ~ 6 million nodes.

I have a view, which i want to add the possibility to also export the total results in csv format.

imagine a vie may return as many as 500 k nodes - results.

My question is if i add this option also, to our drupal site, is there a chance that our site's performance will degrade?

I am using export in batches, and i have set this number to 50, in order to avoid timeouts.

Finally, is there any chance our site someday will stall?

I mean say we have around 500 users online, using views all the time, what are the risks, and the overhead to each new view i add?

I would appreciate a thorough explanation of your experience with the scaling of drupal 7 and mysql which is what we have


texts:
Dear Drupal Enthusiasts,

I was hoping that one of you may be able to solve a problem I'm having with the Feeds module and its unique identifiers.

Basically, I would like to be able to target a field with a unique identifier like you can do with any ordinarily created content-type. However, I want to do this on a custom module (which has its own form of unique identification).

In other words, I have a field in my custom module that is unique, but Drupal does not know that this field is unique. How do I both tell Drupal that this custom module contains a unique field and identify that field as unique so that I can update content rather than delete it and replace it every time I wish to import data?

Any guidance would be most helpful!

Thanks!


texts: How to use pager or term limit for taxonomy_get_tree($vid)?

texts:
How to use pager or how to limit terms, when using taxonomy_get_tree($vid)?

I have this code for terms generation:

<?php
$vid = 2;
$terms = taxonomy_get_tree($vid);
$max_depth = (!isset($max_depth)) ? count($children[$vid]) : $max_depth;

foreach ($terms as $term) {
if ($term->depth == 0)
{
print "" .l("<b>Auto Insurance for &nbsp;</b> " .$term->name,'taxonomy/term/'.$term->tid, array('attributes' => array('title' => $term->name, ), 'html' => TRUE) ). "";

}}

?>

But there are thousands of terms or sub terms. Some pages are then loading more then 20 seconds. I need to improve this situation.

Can you advice me please? Do you know some solution? Pager, Jquery, Ajax?


texts: I want to create a link field to a page on the Apple iStore. I develop iPhone apps and I want an Apple Store icon to display instead of the link text.  Ideally, I would like to have a rollover effect. I was thinking that I could add a class to do this, but it seems like there should be a simpler way or perhaps a module.


texts: How can I get the language name of the current node?

texts: I'm trying to figure out how to get the name of the language of the current node in display suite.  I find a language option under one of the node categories in the dynamic field content selector, but that outputs the language code, not the name.  Do I need to handle this in a preprocess function or is there some way of getting this that I've not managed to find?


texts: views_query_alter change to operator OR for contextual filters and normal filters

texts:
My question is rather simple and I have searched quite a bit for the answer with no result.
My view produces below SQL (simplified):

SELECT stuff
FROM
tableA
LEFT JOIN tableB
LEFT JOIN tableC ON stuff
WHERE (( (MY_CONTEXTUAL_FILTER = '5' ) )AND(( (MY_NORMAL_FILTER IS NULL ) )))

All I want to do is to change that AND between the contextual filter and normal filter. I have tried to change all ANDs (including set_group_operator()) to OR and it does not change my AND.

Also need to mention it is an 'Entity Reference' display which I am trying to achieve the above on. Views version 7.x-3.7.

UPDATE

In order to achieve the above, I also tried hook_views_pre_execute() as below:

 $old_query = (string)$view->query->query();
 $new_query = str_replace('AND', 'OR', $old_query);
 $view->build_info['query']=$new_query;

But that doesn't work and throws and error. I know they are different approaches with different issues but both are trying to solve one problem.


texts: Views: Filtering by latest of end dates in multi-value field collection

texts:
I have a content type that contains a multi-value field-collection field (itineraries).  That field collection has another multi-value field collection field (legs).  The legs field collection contains a date field that collects a start and end date.

Is there anyway in views to filter items to show only nodes for which the latest end date (temporally, the actual latest on the calendar) on the node is later than some specific date?

Ideally I'd like to do it without some php embedded in the view itself, but  a solution with code in a custom module would be ok.

Update I'm still interested in a solution for this, but for now, I've gone back and gotten the ok to simplify the business logic, to allow be to use a much simpler filter, since this particular issue will only be relevant for about a month after the view is released.


texts:
I have downloaded and enabled the contact importer module.
Enabled the settings in "Administration » Configuration » Web services » Contact Importer"
I have create a content type called contacts form "contacts_form" with field "field_email".

I have added this field in " Administration » Configuration » Web services » Contact Importer" ->forms integration as form id as "contacts_form_node_form" and filed as "field_email".

when I add email and save then it save as normal page. It does not import contacts.

AM i missing anything (or) any other modifications are needed.


texts: Need to add filter with more than one word in view filter criteria Drupal7

texts:
I need to add one filter that can take more than one word for searching.
Right now i selected "contains" option in Operator for filter criteria.
ie i need search string like this:
title=word1 or word2…

So in this case what should be my search url:
search-page?title=word1 word2


texts: What is the purpose of the config/install directory?

texts: I was trying to use omega theme and found lot of files under omega/config/install. E.g. block.block.omega_account_menu.yml, block.block.omega_branding.yml, omega.layout.omega_default.yml. I wonder what are the functionalities of these files and how are they being used. Is there any guide to follow? How can I create another one and how can I use it?


texts:
my task is, to create a forum-like behaviour which resembles StackExchange's platform with the only difference that only the question's poster will be able to comment on the replies.

My thought is to create a Content Type that describes the initial post/question, and then add a "Reply to this" button that should somehow create a new node of type "Reply" or something (ideally in the front-end, but that's another story - feel free to comment on it though) that should get automatically referenced to the initial post/question.

The "Reply" Content Type should maybe support Drupal's core comment functionality but restricted somehow to the initial post/question's creator.

The basic question is the automatic referencing. Other than that if you got any idea about the front-end content creation and/or the limitation of comments to the afforementioned role and CT, I'd be glad to get some extra input :)

EDIT: using Entity Reference module, not Node Reference module, fyi.


texts: Add javascript to a content type form in Drupal 7

texts:
I'm trying to add a custom javascript file to my article content type forms (add/edit).

I've tried mythemename_preprocess_page, hook_form_alter and  theme_content_type_node_form to no avail. They both seem to pick up the page i'm on, not the form in Drupal's Overlay with the form in it.

Obviously I want the Javascript to fire only when I'm actually on the form. So just putting the Javascript in a onReady function in a sitewide js file won't suffice.

My current setup in template.php:

function zeilschepen_form_alter(&$form, &$form_state, $form_id){
  switch ($form_id) {
    case 'node-accommodation-form':
      $form['#after_build'][] = 'zeilschepen_after_build';
      break;

    case 'views_exposed_form':
      if (isset($form['field_country_value'])) {
        $form['field_country_value']['#attributes'] = array('placeholder' => array(t('Land...')));
      }
      break;
  }

}

function zeilschepen_after_build($form, &$form_state) {
  $theme_path = drupal_get_path('theme', variable_get('theme_default', NULL));
  drupal_add_js ("$theme_path/js/test.js");
  return $form;
}

And test.js:

(function ($, Drupal, window, document, undefined) {

    Drupal.behaviors.test = {
        alert('test');
    }
})(jQuery, Drupal, this, this.document);


texts: Views: how to make an OR condition between filters and contextual filters

texts:
I have been able to separate Views filters into groups and apply an OR condition, following this article: http://www.webomelette.com/drupal-views-filters-and-or-logic

I also understand how to use the hook_views_query_alter() to make a few contextual filters act with an OR statement between each contextual filter.

What I can't figure out is this: how do I make the conditional between the REGULAR filters and the CONTEXTUAL filters? After altering the query, this is what I've able to create:

WHERE
(
  ( (og_membership_node.gid = '8' )
    AND (node.status = '1')
    AND (node.type IN  ('event'))
    AND (field_data_field_event_type.field_event_type_tid = '12')
  )
  AND(
  ( (node.status = '1')
     AND (node.type IN  ('event'))
     AND (field_data_field_event_type2.field_event_type_tid IN  ('11', '10')) )
  )
)

and I want it to be:

WHERE
(
  ( (og_membership_node.gid = '8' )
    AND (node.status = '1')
    AND (node.type IN  ('event'))
    AND (field_data_field_event_type.field_event_type_tid = '12')
  )
  OR(
  ( (node.status = '1')
     AND (node.type IN  ('event'))
     AND (field_data_field_event_type2.field_event_type_tid IN  ('11', '10')) )
  )
)

To give some background of what I am trying to do: I am using Organic groups, and I want my view to show events, Global, Regional and Chapter events. However, if the event is of type Chapter, I want to only show Chapter events which are in the same group as the page content.

I had manually edited the query to move the regular filters associated with the Chapter filter into the contextual filter group, with this:

foreach($query->where[1]['conditions'] as $condition) {
  $query->where[0]['conditions'][] = $condition;
}
unset($query->where[1]);


texts:
I've been trying to move an existing Drupal 7 site from a MySQL database to an MS SQL database. The tables and their contents has been successfully moved. I've seen some errors in datatypes and default values, but these has been manually altered.

The site is now working, well, almost working as it should. At the bottom of each page, I'm getting an error message stating:

PDOException: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]The data types ntext and nvarchar are incompatible in the not equal to operator. in drupal_write_record()

I've been comparing some core tables from a fresh Drupal installation, and the datatypes ar the same.

Is this a database related error or a Drupal related error? Am I even posting this question at the right place? Any help appreciated.


texts:
Apart from unpublishing a node for example, what are the other archiving options for outdated, no longer used pages in the site?

Is there a way to somehow archive the deleted pages?

I am running drupal 7.


texts: Ensure atomicity of user_save within hook_node_delete

texts:
In my system, a user has a number of bookings (nodes of content type 'booking') associated. Each of these bookings has a 'field_price' field and a 'field_customer_user' field (for which I am using the Entity Reference module) that links the booking to its customer. The user also has a 'field_bill' field containing the sum of all his bookings' prices.
Each time a booking gets deleted, I want to subtract its price from its user's bill. I'm doing it the following way, using hook_node_delete:
function mysite_node_delete($node) {
   if ($node->type == 'booking') {
     if ($account = user_load($node->field_customer_user[LANGUAGE_NONE][0]['target_id'])) {
       $bill = $account->field_bill[LANGUAGE_NONE][0]['value'];
       $bill -= $node->field_price[LANGUAGE_NONE][0]['value'];
       $account->field_bill[LANGUAGE_NONE][0]['value'] = $bill;
       user_save($account);
     }
   }
}

However, sometimes this does not work as expected. Given the following case:

User booking #1: 100$
User booking #2: 200$
User booking #3: 50$
Total bill: 350$

An administrator logs in and deletes all three bookings for this user sequentially, starting from booking #1 and finishing with booking #3. The user's total bill should be 0 now, but it ends up being

Total bill: 300$.

I guess that this means that when user_save($account) was called for booking #3, the user bill had not been properly updated by the first two calls to hook_node_delete. Therefore, the old value (350$) gets fetched and subtracted the price of booking #3, and end ups being 300$, which is not correct.
Is there anyway of making it work?