texts:
Have searched a lot for this issue. I am not sure if it is a php issue or Drupal issue but the error message is pointing towards Drupal. Whenever i go to the user edit form in Drupal 7 i get the following error:

Notice: Undefined index: #title in user_account_form() (line 1070 of /opt/lampp/htdocs/modules/user/user.module)

I have searched a lot. This seemed relevant http://drupal.org/node/1088964 but it did not work out for me. Any suggestions would be appreciated.

Thanks

Edit 1: I am using 7.18 and yes i have done some changes in user registration form...i have commented the lines in bold and added a placeholder. Now when i uncomment them then no error occurs but then in my user registration form those fields show up...let me clear this through 2 images...1st image shows the case when i commented the lines(in bold) and added a placeholder (this is what i want it to look like):

However this gives me the error in user edit form. Now when i uncomment, it looks like

I do not want the labels Username and password to show up there. How can i achieve this without that error bugging me. The line number 1070 is inside user_account_form as well. I have realized the error is because i have commented out and it is looking for a title field or password field but then my registration form looses its appearance as i want. Is there a way round to do this.

function user_account_form(&$form, &$form_state) {
      global $user;

      $account = $form['#user'];
      $register = ($form['#user']->uid > 0 ? FALSE : TRUE);

      $admin = user_access('administer users');

      $form['#validate'][] = 'user_account_form_validate';

      // Account information.
      $form['account'] = array(
        '#type'   => 'container',
        '#weight' => -10,
      );
      // Only show name field on registration form or user can change own username.
      $form['account']['name'] = array(
        '#type' => 'textfield',
        **//'#title' => t('Username'),**
        '#maxlength' => USERNAME_MAX_LENGTH,
        //'#description' => t('Spaces are allowed; punctuation is not allowed except for periods, hyphens, apostrophes, and underscores.'),
        '#required' => TRUE,
        **'#attributes' => array('class' => array('username'), 'placeholder'=>t('Username')),**
        '#default_value' => (!$register ? $account->name : ''),
        '#access' => ($register || ($user->uid == $account->uid && user_access('change own username')) || $admin),
        '#weight' => -10,
      );

      $form['account']['mail'] = array(
        '#type' => 'textfield',
       **'#title' => t(' Email Id'),**
        '#maxlength' => EMAIL_MAX_LENGTH,
       // '#description' => t('A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'),
        '#required' => TRUE,
        '#default_value' => (!$register ? $account->mail : ''),
        **'#attributes' => array('placeholder' => t ('E-mail')),**
      );

The lines where the error points to :

if (!$pass_reset) {
      $protected_values['mail'] = $form['account']['mail']['#title'];
      $protected_values['pass'] = t('Password');


texts: Most performant way to check if a user is referenced in any node of a specified type?

texts:
I need to get a list of all users that have a specific role. Those users can be referenced in a multivalue field of a specific content type; some users are referenced in multiple nodes of that content type, some in none. I want to filter out all users that are not referenced in any node of that content type. Here's my current (functional) code:

 $ids = \Drupal::entityQuery('user')
 ->condition('status', 1)
 ->condition('roles', 'dozent')
 ->sort('field_name', 'ASC')
 ->execute();

 foreach($ids as $k => $id){
   $references = \Drupal::entityQuery('node')
   ->condition('type', 'angebot')
   ->condition('field_dozenten', $id)
   ->count()
   ->execute();
   if(intval($references) === 0) unset($ids[$id]);
 }

This works as intended as far as I can tell, but performant-wise it seems quite inelegant due to the large amount of database queries. Is there a better way? Can I somehow include the condition that a user must be referenced in at least one node in the first entityQuery? If not, is there a more performant way to perform the second query (e.g. a way to only search for the first reference from a node to the user, since I don't need the exact count anyway)? I'm open to other suggestions as well.


texts: How do i use pathauto to create a url alias for nodes' menu local tasks?

texts:
The nodes are aliased automatically using the Pathauto module.  E.g., node/448 is displayed as aliased/path.

Is it possible to alias node/448/edit to aliased/path/edit?


texts: Backup and Migrate writing empty files locally

texts:
When I do either a scheduled or a manual backup, that's all I get. When I also write to NodeSquirrel, the NodeSquirrel backups are fine.

The problem started when I moved the private file folder to a level below the Drupal user "home" directory (it's a CentOS/cPanel server), to avoid these backups getting added to the overall server backup files - or so I originally thought (see below).

I've since figured out that I can exclude the files from the backup via a script. I pointed the private files directory back the original directory (one level below the web root), but I'm still getting empty files, even though Backup and Migrate sends me messages that the backup completed successfully.

I've checked permissions; I can manually write to that directory as the Drupal user (via nano). Anyone else experienced this?

Update:

Now when I back up the database ONLY, it works as expected. I actually get a compressed .sql file that looks like what I'd expect. But when I try to back up the public files directory, it reports "Public Files Directory backed up successfully to XYZ-2016-12-20T22-20-22 (444.61 MB) in destination Manual Backups Directory in 7 min 42 sec." However, this is what's in the directory:

-rw-r--r-- 1 dUser dUser      0 Dec 20 22:28 XYZ-2016-12-20T22-20-22.tar.gz
-rw-rw-r-- 1 dUser dUser      0 Dec 20 22:28 XYZ-2016-12-20T22-20-22.tar.gz.info

Have altered max_execution time in php.ini, and tried changing dir permissions to 775 and ownership to dUser:webserverUser to no avail.

Next tried drush bam-backup files. First time I got "Unable to create or write to the save directory 'private://backup_migrate/manual'." (!!!)
And drush was operating under root! So I changed permissions to 777 on the whole directory structure and the drush back up was successful, but why? It did kick out an error, though: "Error while sending QUERY packet. PID=7537 database.inc:2227".

So now I'm quite confused. Was it one of the updates I did to Drupal core? I don't believe the backup_migrate module had an update in that time frame.

TIA for any insights or advice!


texts: How to load a file during the load of drupal 8 bootstrap (hook_init)

texts:
I want to make something that in Drupal 7 can easily be done with hook_init, but this hook doesn't exists in Drupal 8.

I want to load an .env file and at the same time load the dotenv file from vendor.

I'm trying with EventSubscriber as it's plain here: https://www.drupal.org/node/2013014, but I'm not sure if this the good way.


texts: How to theme regions in non-standard themes like Consilium?

texts:
So I'm stuck with a theme that is very difficult to work with because it is nonstandard. It seems like it would like to be Omega and put lots of functionality into the admin UI and out of template files but it seems they forgot to actually add that functionality in there.

So the goal is to add regions and edit existing ones. Normally I would do this in page.tpl.php but this theme does not define region order and html inside a template like this. They've provided a Layout section in their appearance settings but there's no way to actually do anything in this section. No drag, no select, nothing.

So my question is that somewhere in some file, these regions have to be defined in a specific order so where? It's not in page.tpl but it has to be somewhere or else drupal wouldn't know what to do with these regions or how to structure their html.

I know a few suggestions would be to contact the theme maintainer but they are horrible on support. Another suggestion might be to choose another theme but my company picked this one and so I have no choice. I also have a Friday deadline and just got to start this week so figuring out this silly theme has been taking up all my time.


texts: Is possible to redirect all 404's to the front page?

texts:
I use Drupal 8.2.3. Is it possible to redirect all the pages returning a 404 error to the front page?
I am not sure the new Drupal 8 Redirect module (that combines the Drupal 7 Global redirect module with the Drupal 7 Redirect module) would help me to achieve this exact task.


texts: Setting up remote drush aliases for aegir

texts:
I have an aegir platform and I need to set up a drush alias file for all of the sites for our developers. I can't seem to figure out the best practice to do this. Normally we would set our 'remote-user' and that user would have access to drush but on aegir, drush is limited to the aegir user. I've follow these instructions http://community.aegirproject.org/node/427 to make is so certain users can also use aegir but I keep getting 'drush needs a higher bootstrap' error.

I have considered just setting the 'remote-user' user to aegir and then useing passwd to set a password for the aegir user but I'm not sure what secondary effects that could have. Presently we just su as the aegir user when we need drush.

Am I approaching this the correct way or is there a better way to approach this problem?


texts: Separate permissions for administering user configuration and administering users

texts:
In Drupal 7 there is one permission for administering users, "Administer users".

This covers both the main user management page at 'admin/people/permissions', and the configuration of settings/fields for the user entity at 'admin/config/people/accounts' and 'admin/config/people/accounts/fields'.

A very common requirement for a site that's being released to a client is that they can administer the users (fair enough right?), so they need the "Administer users" permissions.

However, granting that permission also gives them access to edit the user entity settings/fields, which is very undesirable (no client should be able to change the underlying structure of the user once it's been set up, for obvious reasons).

This must be something a lot of people have to deal with...what methods/modules/custom code do people use to get around this limitation in the user module?


texts: What is the advantage of the APC module?

texts:
I had the APC PHP extension enabled it it seems to work well. I had 0.0% misses and not much fragmentation.
Then I installed the APC module with:

$conf['cache_backends'][] = 'sites/all/modules/apc/drupal_apc_cache.inc';
$conf['cache_class_cache'] = 'DrupalAPCCache';
$conf['cache_class_cache_bootstrap'] = 'DrupalAPCCache';

in settings.php. After that the fragmentation becomes enormous and I can't see any performance loss when I disable the module again, but with it is actually enabled I get annoying messages when I use drush. So what exactly is the advantage of using that module?


texts: Fetching client time using JavaScript and comparing them with values stored in the database

texts:
I am developing a module, where:

The administrator enters time in (0-23) format.These values gets saved in database.
In the front end (for the website users) I need to fetch the current client time (not the server time), maybe using JavaScript, and then comparing it with the stored time (in PHP variables with current time fetched using JavaScript).

I want to do something like the following.

// $time_one: from the database.
// $time_two: from the database.
// $currentTime:  client current time.

if (currentTime > $time_one && currentTime < $time_two) {
  // Display some message.
}

How can this be done? Can PHP and JavaScript be mixed in the module file?


texts: validate #ajax generated textfield value

texts:
I was trying to modify the ajax_example.module, so I can validate value entered in the textfields. Below you'll find the code. But it seems that I can't access the field first name for example in order to validate it's value. I am still pretty new in Drupal 7 module development so I am not quite sure that the approach I used below is the appropriate one. Thanks in advance for your help.

  $form['ask_first_name'] = array(
    '#type' => 'checkbox',
    '#title' => t('Ask me my first name'),
    '#ajax' => array(
      'callback' => 'ajax_example_autotextfields_callback',
      'wrapper' => 'textfields',
      'effect' => 'fade',
    )
  );
  $form['ask_last_name'] = array(
    '#type' => 'checkbox',
    '#title' => t('Ask me my last name'),
    '#ajax' => array(
      'callback' => 'ajax_example_autotextfields_callback',
      'wrapper' => 'textfields',
      'effect' => 'fade',
    ),
  );

  $form['textfields'] = array(
    '#title' => t("Generated text fields for first and last name"),
    '#prefix' => '
',
    '#suffix' => '
',
    '#type' => 'fieldset',
    '#description' => t('This is where we put automatically generated textfields'),
  );

  // Since checkboxes return TRUE or FALSE, we have to check that
  // $form_state has been filled as well as what it contains.
  if (!empty($form_state['values']['ask_first_name']) && $form_state['values']    ['ask_first_name']) {
    $form['textfields']['first_name'] = array(
      '#type' => 'textfield',
      '#title' => t('First Name'),
    );
  }
  if (!empty($form_state['values']['ask_last_name']) && $form_state['values']['ask_last_name']) {
    $form['textfields']['last_name'] = array(
      '#type' => 'textfield',
      '#title' => t('Last Name'),
    );
  }

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

  return $form;
}

/**
 * Selects the piece of the form we want to use as replacement text and returns
 * it as a form (renderable array).
 *
 * @return renderable array (the textfields element)
 */
function ajax_example_autotextfields_callback($form, $form_state) {
  return $form['textfields'];
}

/**
 * implementing hoo_validate for the form
 */
function ajax_example_autotextfields_validate($form, &$form_state) {
  //$name = $form_state['values']['textfields']['first_name'];
  if ($form_state['values']['textfields']['first_name'] == 'King Kong') {
    form_set_error('first_name', t('Your own first name not allowed'));
  }
}

/**
 * hook_submit
 */
function ajax_example_autotextfields_submit($form, &$form_state) {
  $name = $form_state['values']['textfields']['first_name'];
  drupal_set_message(t('Good Job, %name', array('%name' => $name)));
}
?>


texts: Setting up a staging server workflow (for a relative beginner)

texts:
I'm working on a Drupal 6 project and would like to set up a simple staging/live server workflow.

I know Drupal pretty well, including the Features module, and am relatively familiar with Git; as for the server itself, I've only got FTP access. I'd be interested in hearing possible ssh-based solutions too, though.

Can anyone recommend a suitable workflow, or suggest what I should consider if I have to develop my own workflow?


texts: How to preprocess group title render in views?

texts:
I tried to preprocess a title of the group in the result of the rendering of the view.

Example:

Actual:

Group 1 title
Item 1
Item 2
Item 3
Group 2 title
Item 4
Item 5
Item 6

Expected:

Group 1 title
Item 1
Item 2
Item 3
Group 2 title
Item 4
Item 5
Item 6

Here the similar question on the drupal.org https://www.drupal.org/project/drupal/issues/2950737.


texts: Outputting the sum of multiple fields into a new view that then gives a grand total

texts:
I have a view right now that takes data such as # of properties owned and Square footage total by region. So for example if someone clicks the northeast region of a map they'll get the number of buildings and square ft of properties in that specific region, displays them, then at the bottom totals them.

I'm trying to come up with a way to take the totals of those regions, display them in another view and then add THEM up for a grand total.

Is this something that can be done with views? If not, is there another solution that can work with the view already implemented?


texts: Different fields of same content type to different roles

texts:
I have a content type 'new resource'.

I have the form displayed as a page. I would like to make it so that form contains an image field for the admin role, but have this field hidden for any anonymous user filling out the form.

I have been trying to use 'Rules':

EVENTS content is viewed

CONDITION content is of type... Parameter: Content: [node], Content types: new resource AND... NOT User has role(s)... Parameter: User: [node:author], Roles: administrator

ACTIONS Remove an item from a list
Parameter: List: [node:field-web-resource..., Item to remove: [node:field-web-resource..

This might be completely the wrong way to do it, and there is a simpler way, or the Rules approach might work.

When I try to add the ACTIONS the dropdown box keeps showing me things like this:
node:field-web-resource-image-main:0 (Image)
node:field-web-resource-image-main:1 (Image)
node:field-web-resource-image-main:2 (Image)
node:field-web-resource-image-main:3 (Image)

I'm guessing that this is because I have an unlimited amount of images available for upload in this field.

Any help would be most welcome.


texts:
I am using drupal 6 as i am trying to save file that comes from another server through Json format

I am using

file_move('path of image','sites/default/files');

I also tried this  one Still having same error

file_move('path of image','sites/default/files', $replace = FILE_EXISTS_RENAME));

But it gives this error

  Fatal error: Only variables can be passed by reference in

How to solve this? Anybody have idea ?

Thanks


texts: How can I pass $title a node variable to html.tpl.php?

texts:
I'm looking to use the variable $title in my html.tpl.php file. How can I do this?

I would like to just write a bit of php like so:

<?php print $title ?>

So is a preprocess function needed? TPLNAME_preprocess_html() { ??? something like that?

I would like to reference this question here which got me thinking, what is the proper way?

Helpful Question That I Saw


texts: How can I highlight the code section and reserved words for common languages like c/c++/Php etc ? I have tried the GeSHi Filter, but it does not work with the CKEditor. Am I doing something wrong ? Can anyone suggest some workable solution for the CKEditor?


texts: #ajax-processed not added on a form inside a custom callback (MY_MODULE_deliver_html_page)

texts:
Ok, a lot of things on the title so I'll try to explain everything on the question.

I'm trying to create a logic inside Drupal 7 to enable modal forms with AJAX.

This is the pipeline:

Render a form with an #ajax callback in a modal (foundation reveal)
Send a form via AJAX and receive Drupal ajax commands.

In order to print the form without the whole themed template I used a custom callback to render plain html.

$items['statusupdate/%statusupdate/delete'] = array(
        'title' => 'Delete',
        'page callback' => 'statusupdate_delete_confirm',
        'page arguments' => array(1),
        'access arguments' => array('delete statusupdates'),
        'weight' => 1,
        'type' => MENU_LOCAL_TASK,
        'context' => MENU_CONTEXT_INLINE,
        'delivery callback' => 'MY_MODULE_deliver_ajax_html_page',
    );

Attempt 1 - not working

function MY_MODULE_deliver_ajax_html_page($page_callback_result) {
    print $page_callback_result;
    return null;
}

Attempt 2 - Create a custom template to load javascript, not working (the logic is on the php side)

function MY_MODULE_deliver_ajax_html_page($page_callback_result) {
    print theme('page-ajax-html', array('page' => $page_callback_result, 'styles' =>'', 'scripts' =>drupal_get_js()));
    return null;
}

This works fine to render only the form in plain HTML but by doing so no ajax logic is applied to the form.

Drupal_render($form) renders the form, but is not adding #ajax-processed.

I tried to render the $form inside the page.tpl.php and AJAX works, so my guess is that rendering the $form in plain HTML some ajax preprocess logic.

Form:

function statusupdate_confirm_form($form, &$form_state, $data)
{
    $form['#id'] = 'statusupdate-confirm-form';

    $form['submit'] = array(
        '#type' => 'submit',

        '#value' => t('Delete'),
        "#ajax" => array(
            "callback" => "delete_statusupdate_callback",
            "effect" => "fade",
        ),
    );
    return $form;
}

Form rendering:

function statusupdate_delete_confirm($statusupdate) {
    $form = drupal_get_form('statusupdate_confirm_form', array());
    $form['submit'] = ajax_pre_render_element($form['submit']);
    $html = '
'.t('Careful').'!
';
    $html .= '
'.t('Are you sure you want to delete %status_id?', array('%status_id' => $statusupdate->status_id)).'
';
    $html .= '&#215;';
    $html .= drupal_render($form, '');
    return $html;
}

HTML Result

<form action="/statusupdate/12/delete" method="post" id="statusupdate-confirm-form" accept-charset="UTF-8">
<input type="submit" id="edit-submit" name="op" value="Delete" class="form-submit"><input type="hidden" name="form_build_id" value="form-muOSqaoWicTDGYZ-IAp149QAmMpsOPKNsq8WXH2XSLI">
<input type="hidden" name="form_token" value="ckXsiTcF2_sINFfKdNj3uK6L9FiJv3krg1jnhKh0Vsk">
<input type="hidden" name="form_id" value="statusupdate_confirm_form">

Any idea?


texts: Render custom twig in a specific language

texts:
I need to specify the language,
which the drupal renderer uses,
when generating a custom render array.

$renderArray = [
    "#theme" => "DNMBE_email",
    "#body" => [
        "#theme" => "DNMBE_emailBody_groupMessage",
        "#author" => $groupMessage->author,
        "#group" => $groupMessage->group,
        "#message" => $groupMessage->message,
    ],
    "#leadin" => $partials->leadin,
    "#leadout" => $partials->leadout,
];

$render = \Drupal
    ::service('renderer')
    ->renderRoot($renderArray);
$html = (string)$render;

#theme parameters resolve to twigs, which, among other things, contain {{ "From"|t }} markup which is incorrectly rendered as From.

I already posted a similar question, which was marked as duplicate, with the answer suggesting using \Drupal::languageManager()->setConfigOverrideLanguage($language). I do not get the expected result.

When using the t() function, you can supply as third parameter an array, which can be used to specify the language. The renderer however does not take extra parameters, thus also not passing it to twig.

I verified that /admin/config/regional/translate has got the translated string, case-sensitive. I also use ['#cache']['max-age'] = 0 and I don't "precalc"-store any Drupal objects.


texts: Migrating a Content Types and its Nodes into another site

texts:
I have 2 Drupal 7 sites and I want to migrate data from one into the other. One of the D7 sites has a bunch of content types that the other doesn't have, along with a bunch of nodes associated with it (about 1000+ nodes). It's something I can't migrate manually or else it would take forever.

I know everyone points to the Migrate module to do something like this, but are there other similar methods that are just a streamlined. FYI, I never used the migrate module, as it seems like its more for migrating foreign data from other DB sources into drupal.

I remember there was another module that lets you copy data from another Drupal site, but it has to be the same version. Which one was this called?

Now the question is, what is the fastest approach in migrating data + content types between same version Drupal 7 sites? And what are some other caveats I might need to know?


texts: Should I use the Activity or Message module?

texts:
I want to create a view of user activity on my social site as shown below:

User A is now following User B
User C just joined "My_Site_Name"
User D just gained 30 points for posting "User D_Blog"

I have the user points modules installed for assigning points and other modules such as entity and tokens are also in place, along with rules. What i am not sure is which module should i use: the Activity module or the Message module. I first thought of using the Heartbeat module but its functionalities are all in the Message module as well.


texts: How to customize the email subject for a webform?

texts:
I am using Webform 7.x-4.0 on Drupal 7.24 and I am trying to customise the email subject for my webform.
I have followed the instructions as per the instructions in this post How to use [submission:values] in Email template in Webforms but when I save the settings, the email subject is blank.

I entered [submission:values:event_type] for the custom field and my field key is as follows:

After saving the configuration, the field turns up blank.

The email sent out just shows -no subject given as the subject of the email.


texts: How to disable webform Results tab in webform without uncheked Access all webform results?

texts: I'm using D7, i like to hide web form result tab, i try with tab tamer module,but it doesn't work i still got access to submission results,when i unchecked Bypass views access control and Access all webform results permissions, results tab become disable but in this case i couldn't change my webform workflow submissions anymore. Could any one suggest me an idea how to disable result tab without disabling the possibility to change my webform worflow state


texts: Node Permission base on per Taxonomy Term

texts: Is it possible to give view page(or article) permission per Taxonomy term? I know there is a "Taxonomy Access Control" module but this module does not really give the permission, beside hiding the node url. Meaning I still able to see the page if I know the original url. For example, "www.mysite.com/node/100".


texts: Display a field from a content type which is not displayed in the current node

texts:
I can add new variables to the node (like day, month, year) based on current node->created. The problem is I need to display the date field from another content type which is not displayed on the page. How do I fetch it from there?

Here is my code so far:

  function mytheme_preprocess_node(&$vars) {
        $node = $vars['node'];
        $vars['year'] = format_date($node->created, 'custom', 'Y' );
        $vars['month'] = format_date($node->created, 'custom', 'm' );
        $vars['day'] = format_date($node->created, 'custom', 'd' );
      }

and I display them in node.tpl.php simply printing them as $day, $month, $year. I am interested in finding an answer. Thanks.


texts: Drupal site returning 404 error for all pages besides the main page

texts:
I have two completely independent Drupal installations on the same server. Both have https enabled in the settings file, and the Apache configuration was literally copied from one file to the other. However, one of them works under HTTPS and the other does not. The broken site will open the front page successfully, but, for example, https://www.example.com/user will return a 404. https://www.example.com/index.php?q=user works fine.

I opened the apache config of the WORKING site, and changed the DocumentRoot to the directory of the BROKEN site, and tried the site using the working URL, and I see the broken site...and it IS STILL broken.  This leads me to believe that it is not Apache, but something in the Drupal installation or configuration which is misbehaving.

Both installations have an .htaccess file in the base directory, and in sites/default/files, and the files are identical.

The apache error logs for both sites have the same errors:

server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)

and

server certificate does NOT include an ID which matches the server name

Any advice on where to look next?


texts:
I have just set up a site working with Organic Groups. I am now adding users and user permissions.

I create a type called group which serves as the group node and page that serves as the group node content.

The issue is I want my authenticated users to add new page content but only within groups I have assigned them to.

Can anyone advice how I can do this?


texts:
I am trying to setup a Google Analytics property. I have done this before and have had no problems. However this time I am setting it up though the drupal module rather than manually inserting the code.
I have my tracking ID and everything filled out, and I inspect the page and I can see the tracking code is installed.
However my tracking code isnt being picked up by Google Analytics. This is what it says:

Status: Tracking Not Installed

I have enabled debugging for the module, and all seems to be sending correctly. Here is the log:

Initializing Google Analytics. analytics_debug.js:10
Running command: ga("create", "UA-49353541-2", "auto") analytics_debug.js:10
Creating new tracker: t0 analytics_debug.js:10
Auto cookieDomain found: "carbonfunding.co.uk" analytics_debug.js:10
Running command: ga("send", "pageview") analytics_debug.js:10

Sent beacon:
v=1&_v=j30d&a=1343148915&t=pageview&_s=1&dl=http%3A%2F%2Fwww.carbonfunding.co.uk%2F&ul=en-us&de=UTF-8&dt=Carbon%20Funding%20%7C%20Th…_u=MCCAAEQAI~&jid=&cid=2073925826.1413195127&tid=UA-49353541-2&z=327379316

 analytics_debug.js:10
_j1              (&jid)  analytics_debug.js:10
adSenseId        (&a)   1343148915 analytics_debug.js:10
apiVersion       (&v)   1 analytics_debug.js:10
clientId         (&cid) 2073925826.1413195127 analytics_debug.js:10
encoding         (&de)  UTF-8 analytics_debug.js:10
flashVersion     (&fl)  15.0 r0 analytics_debug.js:10
hitType          (&t)   pageview analytics_debug.js:10
javaEnabled      (&je)  1 analytics_debug.js:10
language         (&ul)  en-us analytics_debug.js:10
location         (&dl)  http://www.carbonfunding.co.uk/ analytics_debug.js:10
screenColors     (&sd)  24-bit analytics_debug.js:10
screenResolution (&sr)  1920x1080 analytics_debug.js:10
title            (&dt)  Carbon Funding | The ECO people analytics_debug.js:10
trackingId       (&tid) UA-49353541-2 analytics_debug.js:10
viewportSize     (&vp)  1903x955

I read that it can take up to 72 hours before Google will pick up the tracking code, but I also read that at least the real-time view should be picking myself up on the site. I have also disabled do-not-tack everywhere and no prevail.

Why is this the case?

Thanks,
Darryl


texts: Conditional display of views based on comparing node taxonomy and user taxonomy

texts:
I'm using drupal 7 and working on a site that displays nodes based on a user's taxonomy option. A quick example, i want users to make a blog entry and select a taxonomy option "Target audience". The target audience contains selected "Interests" of logged in users. Both "target audience" attached to node and "Interest" attached to user profile are from the same taxonomy vocabulary, so that when a user selects a target audience, he matches a user interest.

Is it possible to build a single view of all blog enteries and then display parts of the view based on certain conditions like "if blog entry is tagged with taxonomy value which is equal to the interest of logged in user,  then display blog enteries which match the logged in user's interest.

Another use case is this: taxonomy value location = New York. Blogger makes a post and selects target audience = New York. User logs in with selected location = New York (mandatory during registration), view checks if target audience = user location, then displays only posts tagged with "New York". Another user logs in with location = Washington, but there are no posts with tag = Washington, views empty field is then displayed or default display is used (when all conditions fail).

I'm also using panels. currently with panels, to achieve this, i have to build a separate view for each user with selected taxonomy option. This makes it cumbersome because, for instance, to display for all users logged in from 52 cities, you have to create 52 views. My intention is to build a single view that decides what to display based on the checked conditions.

Help is greatly appreciated. Thanks


texts: How to prevent Drush pm-update from backing up symbolic links?

texts:
In my Drupal installation folder, I have symlinks to external folders with 80+ GB of data.  When I backup/update Drupal using Drush, Drush also archives the 80+ GB of data. How do I prevent Drush from backing up the contents of symlinks?

Also, when Drush restores the backup, the symlinks are not preserved as well. Drush replaces symlinks with the actual content.  So after the backup/update of Drupal core is done, my Drupal installation folder ends up being too huge.

Can you please suggestion solution to both of the above problems?  I am okay even if I have to write code to patch Drush or anything else. Just need help pointers in correct directions.


texts:
I have a page that contains lots of products (node with commerce form) that is formed in custom theme function (template).
I update them by ajax, but forms of updated products do not work. I googled, that it is because Drupal.settings javascript form needs to be updated. I tried to do this in such way on my ajax callback function.

  $javascript = drupal_add_js(NULL, NULL);
  $commands[] = ajax_command_settings(array($javascript['settings']['data'][0]), $merge=TRUE);
  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );

It does not work. Nothing changed really.

My full ajax callback:

function products_ajax_callback() {
  $commands = array();
  $commands[] = ajax_command_html('#block-system-main', _all_my_products());

  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}

function _all_my_products(){
      // loading nodes
      $nodes = node_load_multiple(array_keys($result['node']));
      return theme('products_list_in_shop', array('nodes' => $nodes));
}

And my theme function of all products:

function theme_products_list_in_shop($variables) {
  $output = '
';
      foreach ($variables['nodes'] as $node) {
        $output .= theme('product_in_shop', array('node' => $node));
      }
  $output .= '
';
  return $output;
}

And theme product_in_shop - template, where I render form in such way:

  <?php
    $order_id = 0;
    $line_item = commerce_line_item_new($product->type, $order_id);
    $line_item->data['context']['product_ids'] = array($product->product_id);
    $line_item->quantity = 1;
    // need to create config for quantity
    $qty = 1;
    $form_id = commerce_cart_add_to_cart_form_id(array($product->product_id), $qty);
    $addtocart_form = drupal_get_form($form_id, $line_item);
    $addtocart_form['submit']['#theme'][] = 'vtcommerce_button_small';
    $addtocart_form['#action'] = '/shop';
    print render($addtocart_form);
  ?>


texts: Submit of custom node with imagefield ends without warning after imagefield save

texts:
I have a custom Drupal node type with a bunch of text fields, a taxonomy-dropdown and an imagefield. Only the title is mandatory, all other fields are optional. I have added no custom code that should interfere with the form being processed.

When I submit the filled-out form to add a node of this type, the form reloads without adding the node and without displaying any kind of error message. When I leave the title blank, the expected error is displayed.

EDIT/UPDATE

I have started reconstructing the content type and found out that the imagefield seems to be the culprit. The node will save flawlessly if the the type does not have an imagefield.

The minute I add the imagefield, saving fails. The image will even be uploaded, thumbnails will be displayed, but then the form will reappear with no further message.


texts:
I have a field so-called "Status" in my custome contact type. It is a List (integer) and widget type is "Radio buttons". I added two values for allowed values list:

 0|Sold
 1|Available

Default value is "Available". But Drupal lists this as below:

 () N/A
 () Sold
 () Available

Why does Drupal add this unnecessary "N/A" to the radio buttons? I encountered this problem since D6. Now, I'm using the latest version 7.14. I'm still seeing this.

I know I can remove the "N/A" by writing a hook from a custom module.
Nonetheless, I don't want to write additional codes for this kind of small thing. When I use "Select list", it is ok with an option "-None-", but the radio button is ideally suited for the two options.

How can I remove it without installing additional module? Am I missing some functionalities from Drupal core interface?


texts: Custom node template based on field condition

texts:
Is it possible at all to create a node template file based on a specific field value?

For example I already have a node template file called "node--video.tpl.php" for nodes of content type video. I would now like to add a checkbox field in that content type.

If the box is unchecked then it will use the above template.

If the box is checked then it will use a different template.

UPDATE: I added the following to my template file as Mohammed suggested, but I am not getting the changes.

function motg_preprocess_node(&$vars) {

$node = $vars['node'];
  if($node->field_solo[0]['value'] == 1)
  {
       $vars['theme_hook_suggestion'] = 'node__solo';
  } else
  {
       $vars['theme_hook_suggestion'] = 'node__video';
  }
}

My field "field_solo" is correctly outputting a value of 0 or 1 also.


texts: How to use CURDATE() and INTERVAL in Drupal Database object syntax

texts:
How to convert SQL query to Drupal Database object query. I have already tried many ways but I didn't get success.

# Get the records which are published in week
SELECT node.nid as nid
FROM node node
INNER JOIN field_date field_date ON node.nid = field_date.entity_id
WHERE from_unixtime(field_date.field_date_value) BETWEEN CURDATE() - INTERVAL 7 DAY AND CURDATE();

The above query is working fine in mysql.


texts:
I have downloaded and installed Drupal 8. The first thing I need to ensure when I create articles URL is automatically generated. In Wordpress this comes by default. But it appears not the case for Drupal.

I searched and found Pathauto (https://www.drupal.org/project/pathauto) will do what I want but facing difficult installing it. The page https://www.fastcomet.com/tutorials/drupal8/module-installation shows a tab List with button +Install New Module but on my system when I visit http://localhost/admin/modules I don't see the tab List or +Install New Module.

What could I be missing?


texts: How do I display a list of nodes that reference a given node on the node content page?

texts:
I have a central content type that is being referenced by many child content types.  The child content types all have an entity reference field pointing to the central content type.

Now, on the node page, I want to display a list of all the nodes that are referencing this particular piece of content.

It seems I can use Field View to set up a view showing the desired content, and then embed it as a field, but I'm not sure how to pass the value of the currently-being-viewed content to the view in order to make it limit the results properly.

Any advice or other ways to approach this problem?


texts:
I've been trying to update my drupal installation with the security patch from 7.20 to 7.26
using a patch file. Problem is I cannot get out of maintenance mode. I've tried everything indicated in other posts: http://example.com/index.php?q=user, http://example.com/user/login. Also tried to go the DB route, but that does not work either since the variable do not seem to contain anything with the "site_offline" name.
This is very frustrating. I've also backtracked on the changes by reinstalling the DB and site from backup, but unfortunately I had already put the site in maintenance mode when I took the backups. Grrr.
Any help greately appreciated.


texts: using hook_query_alter with fieldcondition()

texts:
I want to use hook_query_alter to alter a query constructed by a module. This is the code I use:

function MYMODULE_query_alter($query) {
  if ($query->hasTag('agent')) {
    $query->fieldCondition('field_area', 'tid', 10, '=');
  }
}

The code above gives a 500 error: Call to undefined method SelectQuery::fieldCondition()

What is the proper way to add a field condition to the query?


texts: How do I make a $node object properties available in my views--template?

texts:
I have a node--type and view--type templates. In view--type I cannot access $node, for example with $node->nid.

How can I inject $node inside view type templates?

I have a views-view-field--mypage--page--body.tpl.php file; this is a field template of the body of teasers where I inserted a Read more link. I need the URL for that link.


texts: how to duplicate a form action programatically

texts: when a form action takes place, it posts the fields and also redirects to that page, right?  I need to make a custom form do the same, I have successfully made it post the fields in my drupal 8 custom module , using an http request with guzzle, but how do i make it redirect simultaneously as well?


texts: Does  Drupal have an AJAX solution for search results, preferably with Apachesolr integration?

texts: Specifically, I'm referring to being able to have the top 5 search results display as options in a drop down menu while the user types in a search query, somewhat similar to how node reference autocomplete works. It would be great to have such functionality work with Apachesolr.


texts: Taxonomy Filter with parents and child of select parent dropdown`s

texts:
On my website i have pet type (dog, cat, rabbit...) those are taxonomies, and every pet type has its own child taxonomies called pet breed. So lets say we selected in first dropdown dog, in second dropdown i want to list dog breeds.

I have tried with http://drupal.org/project/hierarchical_select but i cant make it work.

I tried with Views but still my exposed filters doesnt show at all on Preview or in Block...

Any help would be nice. I tried searching but no luck...

http://www.pets4homes.co.uk/ this is what i want to acomplish same thing as that filter they have but just without taht location field.


texts: Will Drupal 6 be left in a secure state after it becomes unsupported?

texts:
I created a custom database interface using Drupal 6 + Views + CCK that works really well for my company and recently I had to migrate it to another server.

I thought "Hey, why not install Drupal 7 and then dump the database in it: then I can upgrade Drupal to the latest version while we migrate!?"

That turned out to be a bad idea. Drupal 7 doesn't seem to have the slightest clue what to do with the DB info I gave it. And the upgrade guide looks very time consuming to me, right now.

So my question is: will Drupal 6 be left in a secure state after it becomes unsupported? Or will the platform become deprecated and vulnerable forcing an even more massive upgrade on me?


texts: Best way to inform users after file upload

texts:
I'm searching for a good solution to inform users after a file was uploaded (with standard upload URL: ...file/add).

I would solve this with rules, but I can't find the right events for this.
Has anybody a good idea.


texts: Rules react on event for file_managed table?

texts: Im looking for a solution to be able to create a "react on event" in rules for when a file is added to the file_managed table. Is it possible and if so, how?


texts: How to add View Translated Version button in Views?

texts:
My site is multilingual and I have a view page of content type. If node has translation then I want to add a button/link for viewing the translation.

Example

View Row 1
Title 1
Body 1
View in English | View in Arabic

View Row 2
Title 2
Body 2
View Full Content

View Row 3
Title 3
Body 3
View in English | View in Arabic


texts:
I'm currently working a styling of a drupal 8 website. And I'm trying two things.

In HOOK_preprocess_container I want to output a block, I got the block script figured out but I want to filter and output only when the Container ID matches a certain ID. Can someone help me out with this?

Thanks in advance.

My current HOOK:

function HOOK_preprocess_container(&$variables) {
  //something like this
  $containerID = //get container ID;

  $block = \Drupal\block\Entity\Block::load('block_id');
  $block_content = \Drupal::entityTypeManager()
    ->getViewBuilder('block')
    ->view($block);

  if($containerID == "containerID"){
    $variables['containerblock'] = $block_content;
  }
}


texts:
I have a view where I am listing all the nodes. user can select the ones he wants to print in bulk.
I am able to show the print option in VBO but I am stuck with next step as how to send all the selected nodes to print.

Can anyone help me to get this done.

Thank you


texts:
can anyone tell me if there is a way to set the terms under a taxonomy to have only one node?

I am building a system which is based on taxonomies but each term should contain only one one. If any user tries to save a node under an occupied term, I need it to be disallowed.

Can anyone help with some insight?


texts:
I was looking at my drupal site log messages and I´ve been having very weird ones as the ones attached.

I was wondering if someone is trying to hack my site, if so, how can I prevent that? I have all my site up to date. But it seems I need to take more measures.

thanks in advance


texts: How to make a Data Selector a negative value in a rule action?

texts:
I create a rule and inside it I added a action, this action involves a data selector: node:field-labpoints. I need to make this data selector a negative value.

I tried with -node:field-labpoints and -[node:field-labpoints] but it is not accepted.

look my capture:


texts: Alter Views query limit using views_query_alter

texts:
I want to alter the limit of view using views_query_alter hook.

My code is :

function track_click_views_query_alter(&$view, &$query) {
  if($view->name == "click_list_days"){
  $w_count = count($query->where[0]['clauses']) - 1;
  $w_clause = array();
  for($i=0; $i <= $w_count; $i++) {
      $w_clause[] = "(".$query->where[0]['clauses'][$i].")";
      if($i > 0)
          unset ($query->where[0]['clauses'][$i]);
  }
  $w_clause = implode(" AND ", $w_clause)." Group By track_click.article_title ";
  $query->where[0]['clauses'][0] = $w_clause;
  }
}

How can I alter the limit of this views query? I didn't understand which query object i have to alter.


texts: How to push form values to database in Drupal

texts:
I am building a drupal site in which I would like the admin to have the ability to input goals into a table on the drupal database that can then be output to other users to be completed.

The form for the input and the table get created, however the values are not added into the table when submit is pressed and I'm not sure why.

I have the following code from the module that I am hooking into my site. I think the problem occurs at the top where I am creating the fields, or at the bottom when I submit the values. I'm really not sure.

Can anyone tell me where I went wrong and how to fix it?

function achievementList_init() {
if(!(db_table_exists('achievements'))) {
    $achvmnt_list_schema = array(
        'description' => 'Achievement Fields',
        'fields' => array (
            'achvmntID' => array('type' => 'int', 'unsigned' => TRUE, 'AUTO_INCREMENT' => TRUE, 'not null' => TRUE),

            'achvmntName' => array('type' => 'varchar', 'length' => 256, 'not null' => TRUE, 'default' => ''),

            'achvmntDesc' => array('type' => 'varchar', 'length' => 256, 'not null' => TRUE, 'default' => ''),

            'achvmntPts' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),

    ));
    db_create_table('achievements', $achvmnt_list_schema);
}
}

function achievementList_menu($form, &$form_state) {
$items = array();
$items['achievementList/addAchievement'] = array(
    'title' => 'Achievement Input',
    'description' => 'Input Achievement info to add achievement to database',
    'page callback' =>'drupal_get_form',
    'page arguments' => array('achievementList_form'),
    'access callback' => TRUE
);
return $items;
}

function achievementList_form($form, &$form_state) {
$form['name'] = array (
    '#type' => 'textfield',
    '#title' => 'Achievement Name',
    '#size' => '20',
    '#maxlength' => '20',
    '#required' => TRUE
);
$form['description'] = array(
    '#type' => 'textfield',
    '#title' => 'Achievement Description',
    '#size' => 50,
    '#maxLength' => 400,
    '#required' => TRUE

);
$form['points'] = array(
    '#type' => 'textfield',
    '#title' => 'Point Award',
    '#size' => '20',
    '#maxlength' => '20',
    '#required' => TRUE
);
$form['add_button'] = array(
    '#type' => 'submit',
    '#value' => t('Add Achievement')
);
return $form;
    }

function achievementList_validate($form, &$form_state) {
$name = $form_state['values']['name'];

if($form_state['values']['name'] = '') {
    form_set_error('name', t('Achievement must have a name!'));
}
if($form_state['values']['description'] = '') {
    form_set_error('name', t('Please describe the achievement!'));
}
if(!($form_state['values']['points'] > 0)) {
    form_set_error('name', t('Achievement must be worth points!'));
}
}

function achievementList_submit($form, &$form_state) {
db_insert('achievements')
->fields(array(
'achvmntName' => $form_state['values']['name'],
'achvmntDesc' => $form_state['values']['description'],
'achvmntPts' => $form_state['values']['points'],
))
->execute();
}


texts: I'm working on a real estate site. We are importing the listings from a csv. In the file, one column is the url for the image and another column is the number of images for that listing. For example Column A would have http://www.realestate.com/image1.jpg and then column B would have 4. The way to view the other images is append the value in column B to column a, so it would be http://www.realestate.com/image1_2.jpg, /image1_3.jpg, etc. Does anyone know if a way to do this automatically when drupal imports the csv? Thanks!


texts: Slideshow Question - Slider for images uploaded to a node

texts:
I am building a review web page. I want to be able to upload 3-5 pictures for the product to be reviewed and have those images displayed as a slideshow within the product node. Pictures are uploaded and stored as a CCK field.

I have been able to get the Views Nivo Slider to get to work for my homepage slider, but I'm not sure it if is possible to use it to build a slideshow for fields within the same node.

Is there a way to use Views Nivo Slider to showcase the uploaded images for the product node? If not, can you recommend another slideshow module?


texts: Combining fields and avoiding duplicate display

texts:
I use below code for printing out images in search results. I get double print outs on the ALT tags. If I disable ALT tags all displays just fine.

<a href="<?php print $url; ?>" class="search-result-img-wrapper">
    <?php
      print theme_image_style(array(
        'style_name' => 'thumbnail',
        'path' => $result['node']->field_image['und'][0]['uri'],
        'alt' => $title,
        'attributes' => array('class' => 'search-result-img'),
      ));
    ?>

  <a href="<?php print $url; ?>" class="search-result-img-wrapper">
    <?php
      print theme_image_style(array(
        'style_name' => 'thumbnail',
        'path' => $result['node']->field_product_image['und'][0]['uri'],
        'alt' => $title,
        'attributes' => array('class' => 'search-result-img'),
      ));
    ?>

If I add fields like below, I get only the print out of one of the fields and not both.

<a href="<?php print $url; ?>" class="search-result-img-wrapper">
    <?php
      print theme_image_style(array(
        'style_name' => 'thumbnail',
        'path' => $result['node']->field_product_image['und'][0]['uri'],
        'path' => $result['node']->field_image['und'][0]['uri'],
        'alt' => $title,
        'attributes' => array('class' => 'search-result-img'),
      ));
    ?>

What am I missing? Thanks much for your input.


texts:
I am using Drupal 6.  and using services and view_service module .

I have created a exposed filter view.
here is screenshot for that view

now i am using service module

here is screen shot

now i want to  pass filter result to get name . does anybody tell me how to pass exposed filter arguments in web services.
Thanks


texts: Adding Fivestar rating each item in a view containing most recent stories?

texts: I'm using the Fivestar module (drupal.org/project/fivestar) and was just wondering if it is possible to add it to a view of my most recent stories. Basically, I want it to appear below each item in the view so users can both view it and use it.


texts:
I've got a Drupal 7 site with a default theme (Nuboot_Radix). How do I find out which template files (.tpl.php) are being used on each page. For example, I have the following page:

How do I find out which file to change in order to change how the datasets are displayed here (in this case Age by Economic activity 2011, 2011 UK Borders, Ethnic group 2011).

I understand that I need to make these changes in a subtheme, which I have already created. But I don't know what to call the tpl.php files, what the put in them, what variables I can use, etc. If I could find out where the html was being created for that section then I can figure out the rest myself.

I have been advised in another drupal post to not use Theme Developer since it is no longer supported.


texts: Function to check for value prior to using getValue?

texts:
I'm trying to write a function that takes into account both regular text fields and entity references and checks for a value prior to using getValue() to assign it to a variable.

   function checkUserFieldAvailability($fieldName, $assignedName){
      if (!$user->get($fieldName)->isEmpty()) {
        ${$assignedName} = $user->get($fieldName)->first()->getValue()['target_id'];
      }
      else {
        ${$assignedName} = "";
      }
    }

Something like this... Is there an easy way to make it account for both entity references that are assigned like this...

$name = $user->get('field_firstname')->first()->getValue()['target_id'];

and regular text fields which are assigned like this.

$email = $user->get('mail')->getValue();

Basically i'm trying to confirm all the fields I'm making assignments too in fact first have a value (to avoid errors) and if not assing  an empty string.


texts:
I create a  website  on Linux/Apache and I want move it to Windows/IIS 6  here , my panel is Plesk.
I can't upload files and images and my Images that customize with Imagechach module not shown!
I guess folder permission not trust.
where I can find a list of Drupal folder permission?I don't know how to set permission in Plesk,Please help me ..!? :(


texts: LoginToboggan redirect to the same page on Drupal-7

texts:
I have a Drupal-7 website and I use LoginToboggan module for login.
Is there a way to override this module or change the settings, in order to redirect users to the same page after successful login, and not on the user's profile page?


texts:
I want to inject Font Awesome icons to user menu based on the route/link of each item.

But it looks like there is no way to get the path grom the url object. I tried everything I could think of but nothing worked. It's like the url object won't give any data in Twig.

This is what I am trying to do in menu template for user acocunt:

                    {% set uri = path(item.url.routeName) %}

{{ dump(item) }}

{{ dump(uri) }}

                    {% if uri == 'user' %}

                    {% elseif uri == 'user/logout' %}

                    {% elseif uri == 'user/register' %}

                    {% elseif uri == 'user/login' %}

                    {% endif %}
                    {{ link(item.title, item.url) }}
                    {% if item.below %}
                        {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
                    {% endif %}


texts: How do I make computed fields visible when other fields are presented?

texts: I have been spinning my wheels for hours.  I added a computed field to a content type and it simply wouldn't show up in the result.  I made an all new content type with nothing in it and the computed field showed up fine.  Once I added an additional field, the computed field vanished.  Is this a bug or a feature?


texts:
I'm having trouble understanding how to attach a library to views.  I want my assets to be included in /foo but not in /bar.  I've read through the documentation on this more than once and from my understanding this is achieved by using preprocess, such as:

function my_theme_preprocess_page(&$variables) {
  if($variables['is_front']){
    $variables['#attached']['library'][] = 'my_theme/my_library';
  }
}

I'm new to Drupal so forgive my inherit ignorance, but what does $variables contain?  'is_front' is easy enough, but how do I apply this to views or content types?

Thank you all in advance.


texts: Determine main menu item on front page updating menu--main.html.twig

texts:
I am trying to write a custom twig for menu--main.html.twig under Drupal 8.3.  When in the menu_links macro while on the home page, the item.in_active_trail is not TRUE.  I tried to compare the path('') to item.url but it never returns true.  I can print out both path('') and item.url and see that they output the same exact text (character for character).  Is there a special way to determine if the item.url is the front page or to string compare URL strings?

{{ path('<front>') == item.url ? 'true' : 'false' }} ==> 'false'
{{ path('<front>') }} ==> '/drupal8_test/'
{{ item.url }} ==> '/drupal8_test/'


texts: Is there anything other than taxonomy and flagging out there for organising/describing/promoting content for better search and refinement?

texts:
I'm trying to make and get more out of the content on a site. So when someone adds a description, the topic/main points (which isn't the title of the node) are prioritised/promoted automatically somehow, or added in a sub-field. So that when people are searching the site, they can search the title ofcourse but main points of the nodes as well.

Instead of flagging content for keywords, definitions of what the content is about, or using taxonomy. Is there something else out there? The problem i'm having with flagging is I can't put them in to one view that people can filter (when exposed). I would have to create multiple flagging views covering every possible definition (I have over 20 flags and it just won't work like this).

On top of that, i'm interested in any other cool modules out there that may work with, or advance taxonomy or flagging or are their own thing I may not have heard of?

I also wanted users who sign up to the site to do most of the categorisation and defining of content.


texts: How do I search all contents including code from admin?

texts:
I am a Drupal newbie and I am frustrated in my search for methods that allow admin searches of code in node content fields ie CSS classes.  I'm baffled that there is not a built-in default way to help admins search content like this.

I have looked at many projects for Drupal 7 and Drupal 8 and only a few Drupal 7 modules looked like they could have helped. None of what I have read for Drupal 8 appears to offer code search.

The documentation I have read, and the module I found are the following.

https://www.drupal.org/project/admin_views (D7)
http://drupal.org/project/scanner (D7)
https://www.drupal.org/docs/8/core/modules/search/overview
https://www.drupal.org/resource-guides/content-administration
https://www.drupal.org/project/search_api
https://www.drupal.org/docs/8/modules/search-api/getting-started/common-pitfalls
https://www.drupal.org/project/find_content (D7)
https://www.drupal.org/node/384486


texts: How to synchronize my Drupal site with content pulled from a Wordpress site?

texts:
I need a solution which asks to another site (running WordPress) for updates (i.e., I want to pull new content posted on a WordPress site into Drupal.

Please note that I need a regular (daily) sync of the contents, not a single import.

How can I implement this?
Can I read the site RSS? Or can I ask in some other way this data?
And how?


texts: Display message or block when View Page is null or empty

texts:
I have a Content Type : Events and i have created 3 events they are currently published and displayed in Page ie Display as View.
If there are no published Events then it should display a custom message as "No Events" or a "block".

I am trying to work on views with null values but i could not get it. Is there any thing like this.


texts: Post method not working on non-CRUD methods

texts:
I'm just trying to create custom rest service action but I can't get it. I have created end_point called "testing". Whenever I try to post the data it shows access denied for authenticated user. Where I'm going wrong?

The steps I followed:

used advanced rest client chrome extension
http://localhost/testing/test/username
In dataform I added data "username" = "abc";

I can't get the name. What I expecting is the post call must return the username "abc" according to my below function.

function my_module_service_services_resources() {
    return array(
      'test' => array(
         'actions' => array(
            'username' => array(
              'check' => array(
                'help' => 'Checks username for uniqueness',
               'callback' => 'test_module_username_check',
               'access callback' => 'my_module_service_access',
                'access arguments' => array('view'),
                'access arguments append' => TRUE,
                'args' => array(
                  array(
                    'name' => 'username',
                    'type' => 'string',
                    'description' => 'The username to check',
                    'source' => 'data',
                    'optional' => FALSE,
                  ),
                ),
              ),
            ),
          ),
       ),
    );
  }

  function test_module_username_check($username) {
    return $username;
  }

  function my_module_service_access() {
    return true;
  }


texts:
Is there a module that can create a Taxonomy out of the installed modules?

I want to create simple configuration tracking system and need to make my modules one of the taxonomies.

In relation to existing configuration management systems I got a suggestion here Is there a module for tracking changes to a Drupal site's configuration? so any other existing options for configuraton management should be answered there.


texts: Activate bootstrap theme in BrowserTestBase phpunit test

texts:
In a Drupal 8 testclass I am trying to install the bootstrap theme (v 8.x-3.1). It is saved in the /theme directory. No problem when using the UI. Unfortunately I get an error in the test when I try to install it with this code:

/*
 * Anytest
 * @group proreos
 * @runTestsInSeparateProcesses
 * @preserveGlobalState disabled
 *
 */
class CalculatorControllerTest extends BrowserTestBase {

  public function setUp() {
    parent::setUp();
    \Drupal::service('theme_handler')->install(array('bootstrap'));
  }

The test exits with the following error:

PHPunit Test failed to complete; Error: PHPUnit 4.8.27 by Sebastian
Bergmann and contributors.
There was 1 error:

1)
Drupal\Tests\preosasde\Functional\CalculatorControllerTest::testCalculatorController
Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for
bootstrap.settings with the following errors: bootstrap.settings:schemas
missing schema

/var/www/vhosts/proreos/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php:93

Any advice on this? Anyone tried to install bootstrap in an PHPUnit test sucessfully?

Thanks!


texts: Why doesn't the pager appear in page--taxonomy.tpl.php?

texts:
$query = db_select('node', 'n');
$query = $query->condition('n.type', 'article', '=')
  ->fields('n', array('nid', 'title', 'uid'))
  ->extend('PagerDefault')
  ->limit(1);

$result = $query->execute();
while ($record = $result->fetchObject()) {
  echo $record ->title."<br/>";
}

echo theme('pager');

If I put the code in page--node--3.tpl.php  there is a pager under the title. When I put the same code in page--taxonomy.tpl.php the title is output, but there is no pager. Why?

If there is a term ID, the pager will disappear.

template.php

function mythemename_preprocess_page(&$vars)  {
 if (isset($vars['node']->type)) {
$nodetype = $vars['node']->type;
$vars['theme_hook_suggestions'][] ='page__' . $nodetype;
}

}


texts: How to get field collection values from user object?

texts:
I added a field collection to the user 'manage field' page, the field machine name is 'houses'. The user may add as many home he want.

This field collection regroup :

a sample text plain field (the name of the house), the machine name
"house_name"
a sample integer field (the size of the house), the
machine name "house_size"

In a custom module, I want load the current user and get values of all values of all his houses (in an array ?), how can I do that ?

I tried this :

$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
$user_houses = $user->get('field_houses')->getValue();
ksm($user_houses);

But I get :

It's ok, I set 8 houses in "user edit" page, so I get an array of 8 entries. But, I would like get all data in an array like this :

house 1 : name1 : size1
house 2 : name2 : size2
...
house 8 : name8 : size8

Thank you :)


texts: Get error after update modules to view Map

texts:
After I updated modules, I get the below error, but everything seems to be working fine:

  Out of a total of 40 result rows in view Map List Business (Block Maps
  ), 1 rows did not have their field_coordinates set and therefore could
  not be shown on the map. The first row that could not be located was
  row #1. You can improve execution efficiency by using the Views UI to
  add an "is not empty" filter for field_coordinates.

What should I do about it?


texts: How can I download specific dev version of Drupal module?

texts:
What to do when I want specific dev version of Drupal module.

For example:

Geocoder dev version from Jan 07 2016 is broken. Latest working dev version was from Sept 01 2015.

How can I download previous dev version of Drupal module (Geocoder in my case)? Any method is welcome.


texts:
I have a view listing news items.
Is is possible to lazy-load them, so when I scroll to the bottom of the screen, it will load more news items?


texts: Add Meta tags and Title on hook_menu "page callback"

texts:
How to add Meta and Title tags to the document head on hook_menu "page callback"?
Drupal 7


texts: Form api custom validation function doesn't work

texts:
I'm trying to reuse the login form in my own form. So far so good, everything is populated and shown properly. Now I want to use my validation functions to validate some data, so I tried to add them:

$userLogin = drupal_get_form('user_login');
array_unshift($userLogin['#validate'], 'MY_UBERLEAD_FUNC_validate');
$form['selfservice_ad_tabs']['tab_3']['login'] = $userLogin;

Printing the form shows that the function is in the proper place, but it was not invoked when expected.

I tried several other methods:

$userLogin['actions']['submit']['#validate'][] = 'MY_UBERLEAD_FUNC_validate';

also removing all validation handlers and leaving just mine, but those didn't work either.

Can somebody point what i am doing wrong or explain how i can reuse existing form into my custom form using my validation functions.

Thanks in advance!


texts: How I can use grid system of bootstrap in views-exposed-form.tpl.php?

texts: I have a form with filters exposed and I want to apply the bootstrap grid system for each input to adapt to different devices, but in the views-exposed-form.tpl.php I don't know how to access each generated input.


texts: Create shipping charge based in produc weight' with Drupal commerce module?

texts:
I just followed this Randy Fay video which shows how to generate a charge based in the products weight. I works fine. It multiplies the weight of products by a Cost Per Pound (CPP)

I need this CPP to be different based in the total weight of ALL products in the order.

Example:

Order up to 1 pound ........  CPP = 0,006

Order with weight higher than 1 pounds ........ CPP = 0,004


texts: change RegEx in filter_url for text field

texts:
I have nodes with text field containing URLs. The content is imported from XML file. The URLs are converted to links with drupals filter system, which works fine for most of the links but not all. I guess its the regex in filter_url function, but I can't figure it out.

Example URL:

http://example.net/2027/uc1.$b81009?urlappend=%3Bseq=7

is converted to

http://example.net/2027/uc1.$b81009?urlappend=%3Bseq=7

I'm not a php expert but I'm trying to fix this issue with a custom module. I copied the function _filter_url to mymodule.module, renamed it to mymodule_filter_url. Invoking hook_filter_info_alter(&$info) I change the process callback:

$info['filter_url']['process callback'] = 'mymodule_filter_url';

Now I have to find the regex expression, which stops the URL encoding right before the '.$'. I guess it's in one of these lines:

$trail = '[a-zA-Z0-9:%_+*~#&\[\]=/;?!\.,-]*[a-zA-Z0-9:%_+*~#&\[\]=/;-]';
$punctuation = '[\.,?!]*?';

But here I'm stuck. Can someone help me?


texts: Filter the nodes by language output by the view

texts:
Before I have i18n module and some modules that does the translations but we decided to stop doing translation but still preserve the translated nodes.

After disabling translation modules my views which are using content negotiation says "Broken/Invalid handler" so I removed this filter.

Now all the views are using nodequeue which has a bunch of multilingual nodes.

My question is, how can I filter views to display nodes based on page language. I mean I want to display english articles only when I'm in English pages, korean articles when viewing Korean pages, japanese articles when viewing Japanese pages, etc.

Ex. nodes(eng) for English pages, nodes(korean) for Korean pages, nodes(japanese) for Japanese pages, and nodes(chinese) when in Chinese pages


texts: how to be the last hook_page_alter called?

texts:
If you implement hook_page_alter in your own module, your hook will be called somewhere between all the other modules.

I am trying to undo something another module is doing in hook_page_alter. Somehow my hook is called before the other one.

How can I become the last hook to get called ? Or, what is the first hook after hook_page_alter that still uses $page ?


texts:
I would like to update the title of a order item before it's put in the cart to add some extra dynamic info for the user. I tried this but nothing changes.

In the onCartEntityAdd function:

$item = $event->getOrderItem();

// Some code to check that its the item I wanted then:

$newTitle = $item->getTitle() . ' - some extra info';
$item->setTitle($newTitle);

setTitle call does not seem to do anything, the title in the cart is still just the product name.
The getTitle() call works though.

Thanks for any info.


texts: Create views have field image with multil image style?

texts:
I want create view like this

You can see this view have two image style (name are 700x700 and 263x132). I want use two image style because it's faster when the page loading.

So how can do that with views?


texts: How do I have points and polygons in the same Leaflet map?

texts:
I have two content types

Location that geocodes an addressfield to place markers on the map
Boundary that uses a geojson field to create complex shapes on the map

I need to use views to show both content types on the same map. It appears that I can only do one or the other.

For an example, think about a map that shows constituency boundaries and voting stations.


texts: Permissions to Upload images in text field

texts:
The Administrator role has no problem with this, but a lesser role (Editor) that I created cannot upload an image in the basic html text box.  They ARE ABLE to upload images as files and images, however.  What is the permission setting that I am overlooking here?
I should mention, this is Drupal 8.

The basic html option does work for uploading in-line images - for the Administrator.  Permissions on the in-line folder are correct.  Allowing my Editor role to use full html and even restricted HTML does not answer.

Just a further note, Editor can insert an in-line image in source code mode.


texts: How to create a node in Drupal 7 with a custom nid

texts:
I have to create a node in drupal 7 with a custom nid but the solution I've tried doesn't works (The created node not appears in the backend).
If I create the same node without the custom nid, it works.

Code:

$node = new stdClass();

$node->nid = intval($insert['id']);
$node->vid = intval($insert['id']);
$node->uid = 1;
$node->type = 'nodetype';

$node->title = $insert['name'];
$node->created = time();
$node->changed = $node->created;
$node->promote = 0;
$node->sticky = 0;
$node->format = 2;
$node->status = 1;
$node->language = 'en';

$node->field_custom_1 = array('und' => array(array( 'value' => $insert['foo'] )));
$node->field_custom_2 = array('und' => array(array('value' => $insert['hello'])));
$node->field_custom_3 = array('und' => array(array('value' => $insert['world'])));

if ($node = node_submit($node)) {
    node_save($node);
    drupal_set_message(t("Node ".$node->title." : ".$node->nid." added correctly"));
}
else {
    drupal_set_message(t("Node ".$node->title." added incorrectly"), "error");
}

What's wrong? Thanks


texts: Is there an easy way to move non-English selected nodes into a language section?

texts:
I have a site in English but it also has a few nodes in Arabic, a few in Aramaic, a few in Hebrew, etc.

Is there an easy comfortable UI way to move each group of nodes for a language section? To better explain, here is how the URL should look in relation to each section:

  www.example.com/ar0/This-is-a-node-in-arabic0

  www.example.com/ar1/This-is-a-node-in-aramaic0

  www.example.com/he/This-is-a-node-in-hebrew0

Let me just clarify, I am not talking about a sub-site, All nodes are exactly on the same English-native site.

it is important for me for any case to have a solution that doesn't include Views at all since these are simple nodes.


texts: Allow subusers to access parent's content

texts:
I have 2 drupal roles. Let's say a teacher and student.

A teacher should be able to:

Create student account.
Create new nodes.

Student should be able to:

Edit and view ALL nodes created by the teacher who has created his
account.

Since it involves mapping of users, I've used the subuser module

I have checked the content access and node access modules as well but they doesn't let me map teacher's content to his student (sub-user).
These modules require me to grant permission for individual nodes created by teacher and does not apply permissions automatically to all content created by the teacher.

How do I make all sub-users automatically get edit permission to all content created by parent user?

PS: My actual problem is much more complicated with multiple seller roles and integrating with payment methods. However a solution to this simple case will guide me to go about the problem.


texts:
I have a new multisite instance with the Backup & Migrate module installed in /sites/all/modules/

When I run drush the bam-* commands don't show as available commands.

I have site aliases set up and if I run drush @site-alias bam-destinations as a test it does show the available backup destinations.

Is there a more correct way to show the list of available commands for all sites as well as site-specific commands?


texts:
I have implemented hook_file_download function in my module. When I call function current_path in the body of this hook, it returns path of the file, not path of current URL in browser. The similar result I got when I try method request_path or variable $_SERVER['REQUEST_URI'].

My hook_file_download is called after I am programatically displaying image with function

<?php
function some_page_callback() {
// $args = ...some args
$output = theme('image_style', $args);
return $output;
}
?>

How to get  path registered in hook_menu for "some_page_callback" in hook_file_download method?


texts: why are Twig template variables with markup not being rendered?

texts:
In my template preprocess function I have a variable:

$test = "
this is a paragraph
";

and I pass it to my template:

$variables['test'] = $test;

and output it in twig:

{{test}}

but instead of getting a formatted paragraph, I'm getting the original output in plain text:

this is a paragraph

How do I get Drupal to render this as normal HTML?


texts: How to expire views cache in code or with rule?

texts:
I have a view with block display that shows a user's picture and profile info. The view is cached for 1 hour.

How can I expire that cache when the user updates the profile?


texts: For content, what are the differences between nodes and terms

texts:
I am debating whether to use nodes or terms to store a large amount of content in Drupal.

There are a lot of similarities between nodes and terms in Drupal 8/9:

Both can add any type of field.
Both can have URL aliases set automatically via Pathauto.
Both can have customized metatags via Metatag.
Both can have comments.
Both can have the displayed customized with Layout Builder, and both can be themed in the same way with Twig templates.
Both have content types (nodes have "content types", terms have "vocabularies").

They seem very much alike.  So what are the differences between terms and nodes?


texts: How to edit Views results using postExecute in a field handler?

texts:
I have a custom field handler which returns JSON data, and I would like to alter the output prior to the render() function in the handler. This is mainly for the purpose of compatibility with another module, which is using the handler's query results directly. After looking through the Views source code, I see that I need to call postExecute for the handler, as we are trying to set the appropriate data before it is used to create $this->view->result.

Currently, I have the following, but it does not seem to set the data as expected (trying to get the field to output 'hi' as a test)

/**
 * {@inheritdoc}
 */
public function postExecute(&$values) {
  foreach ($values as $value) {
    $ent = $this->relationship ? $value->_relationship_entities['entity_type'] : $value->_entity;
    $ent->set('field_name', array('value' => 'hi'));

    if ($this->relationship) {
      $values[$value->index]->_relationship_entities['entity_type'] = $ent;
    }
    else {
      $values[$value->index]->_entity = $ent;
    }
  }
}

How could I modify the returned query values in this step?


texts:
I am having issues with a template - in the template.php there is code causing a warning:

Warning: Creating default object from empty value in theme545_preprocess_html() (line 31 of /home/noramtow/public_html/sites/all/themes/theme545/template.php).

The line in questions is this:

$vars['rdf']->version = 'version="HTML+RDFa 1.1"';

The whole section of code looks like this:

function theme545_preprocess_html(&$vars) {
if (module_exists('rdf')) {
$vars['doctype'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML+RDFa 1.1//EN">' . "\n";
$vars['rdf']->version = 'version="HTML+RDFa 1.1"';
$vars['rdf']->namespaces = $vars['rdf_namespaces'];
$vars['rdf']->profile = ' profile="' . $vars['grddl_profile'] . '"';
} else {
$vars['doctype'] = '<!DOCTYPE html>' . "\n";
$vars['rdf']->version = '';
$vars['rdf']->namespaces = '';
$vars['rdf']->profile = '';
}
$vars['classes_array'][] = 'body';

I'm not great with PHP - anyone have any idea how to fix this or what's causing it??
Thanks for any help you can give!!
Candace


texts: db_query unknown column on where clause?

texts:
I am getting this error:

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Weddings' in 'where clause': SELECT id from galleries_types WHERE name="Weddings"; Array ( ) in catering_gallery_add_image_submit() (line 195

Why does it think 'weddings' is a column? It clearly is where name='Weddings'. What's up with the blank array on the end?

This is the code I am using.

$a = db_query('SELECT id from galleries_types WHERE name="'.$form_state['values']['id'].'"');


texts: Sync local dev site to live best practice

texts:
What is best practice for syncing a local dev site with a live production site when your live database is  constantly changing?

From what I have read there are two possibilities:

Replicate changes made in dev manually on your production site. This seems like something you would only want to do with fairly limited changes that I can make while the site is down for maintenance and users are unable to make any changes to the production database. I can imagine that it can make it tough to make more complex updates/changes. I have done this in the past with simple changes/updates to modules and so on.
Migrate the test site into production, with the site in maintenance, and synchronize the databases. This option seems more like the way to go for bigger jobs, as long as I can synchronize the databases somehow.

That seems to assume that your production site is basically static and the database will not change much at all when you are making changes on your test site.

However, I am working on a batch of improvements for site that has daily activity (new content, users, transactions, comments etc.). These changes are taking time to set up and test.

I found this comment on Drupal.org https://drupal.org/comment/4511654#comment-4511654

It addresses my situation, but is there any better way to go about this or a more detailed guide/how-to? Or should I be breaking things up into smaller and more manageable chunks -- that way seems time consuming.


texts: Using drupal_add_feed() in template.php gives warning errors

texts:
As soon as I add a call to drupal_add_feed in my theme template.php file I get this warning:

  Warning: call_user_func_array() expects parameter 1 to be a valid
  callback,   no array or string given in theme_get_registry() (line 277
  of  /var/www/example.com/includes/theme.inc).

The feed (created by Views) is valid, and the code works, i.e. it does add the meta tag. But the warning is unacceptable, obviously.

Fix? Something I'm doing wrong?


texts: Trigger a Drupal behavior from another module in Javascript?

texts:
The block_ajax module defines a behavior in its module:

https://git.drupalcode.org/project/block_ajax/-/blob/8.x-1.x/js/refresh_ajax_block_command.js

I want to initiate this call every 60 seconds so the contents of the block can refresh if there is new data from my own script file.

I tried two ways.

The first way I tried was setting up a route for a simple controller that returned an AjaxResponse:

  public function execute() {
    $response = new AjaxResponse();
    $response->addCommand(new RefreshBlockAjaxCommand('.my_block'));
    return $response;
  }

Hitting the route with Drupal.ajax results in 'context.querySelectorAll is not a function', but it appears that the block is replaced (but missing the block wrapper around it, oddly enough, which probably won't work calling it over and over).

The second way is I tried to call it from the browser console with Javascript, but I can't figure out between this answer and the linked Javascript file at the top of the question what to call.

Trying to loop the element and attachBehaviors results in this:


texts: Ability to 'mark' nodes and build a book functionality

texts:
I am looking for ways to do the following:

users (both anonymous and authenticated) 'mark' nodes in some fashion to say that they want paper copies sent to them
users can set quantity of the paper versions they require
users get review their 'marked' nodes and potentially add/remove items from it
users enter in address to postal system

This problem could probably be solved in several ways, what is the cleanest?


texts:
Is there a difference in Drupal 7 to add a file-upload field on a "normal" form (i.e. a separate page for a modules' configuration) as opposed to the small settings area for a CCK field (the one that appears after clicking on the cog for the field you'd like to modify under the "Manage Display" tab)?

I have a bunch of configuration options for a custom field using hook_field_formatter_settings_form, but am stuck at trying to figure out how to create a file upload field. I'd ideally like to have the user able to browse for an image and upload it without having the page reload. This is all I currently have:

$element['custom_field_name']['image'] = array(
    '#type' => 'file',
    '#size' => 48,
    '#title' => t('Image upload'),
    '#description' => t("Upload an image."),
);

If it is possible to have a file upload field (that uses ajax) in this area, what else must I do?

Edit:

My file field now looks like this:

$element['custom_field_name']['image'] = array(
    '#type' => 'managed_file',
    '#title' => t('Image upload'),
    '#upload_validators' => array(
      'file_validate_extensions' => array(0 => 'png jpg jpeg gif'),
      'file_validate_image_resolution' => array('64x64', '10x10')
    ),
    '#upload_location' => 'public://default_images/',
    '#description' => t("Upload an image."),
);

This is sort of working: it allows me to upload a file and it goes to sites/default/files/default_images, but its only temporary. I've been going through the form api reference and it says I need to permanently save it. I am just unsure how where to put this logic. Do I add a #process key to my file field and call some private function? Or do I create a submit handler? The API reference doesn't go into as much detail as I'd like.


texts: How can I remove nodes using Drupal Console?


texts: #autocomplete_path doesn't present a "spinny thing"

texts:
I'm working on adding an autocomplete field to a node edit form using hook_form. The field should not be stored in the database; hence the reason I am not adding a field to the node itself.

I seem to have the required components for autocomplete to work, and I've double checked spelling errors, but I can't get a "spinny thing" (aka "throbber") to appear, and there are no attempts by the browser to retrieve data from the autocomplete path when entering data into the autocomplete field.

Javascript is working in the browser, as evidenced by a working entity reference autocomplete field.

Some code:

/**
 * Implements hook_menu()
 */
function cao_contenttypes_menu() {
    $items = array();

    // autocomplete
    $items['cao_contenttypes/user/autocomplete/%'] = array(
        'title'            => 'Autocomplete C&O users',
        'page callback'    => 'cao_contenttypes_cao_handler_users_autocomplete',
        'page arguments'   => array(3),
        'access arguments' => array('C&O Administrator'),
        'type'             => MENU_CALLBACK,
    );

    return $items;
}

/**
 * Implements hook_form()
 */
function cao_handler_form($node, $form_state) {
    // Fields in the node add form are merged into the array we create
    // here.
    global $user;

    // Fetch the title field.
    $form = node_content_form($node, $form_state);

    // get a list of users that are allowed to have cao
    $users = _cao_contenttypes_cao_handler_users();
    $form['c__o_user'] = array(
        '#type' => 'select',
        '#title' => 'CaO User',
        '#weight' => -20,
        '#description' => 'Choose a user.',
    );

    if (0 < count($users)) {
        dpm($users, 'users');
        $form['c__o_user']['#type'] = 'textfield';
        $form['c__o_user']['#autocomplete_path'] = 'cao_contenttypes/user/autocomplete';
    } else {
        $form['c__o_user']['#options'] = array();
    }

    return $form;
}

function cao_contenttypes_cao_handler_users_autocomplete($str) {
    if (!$str) {
        return;
    }

    // choose users from among a limited subset
    $users = _cao_contenttypes_cao_handler_users();
    $list = array();
    array_walk($users, function ($item) use ($str, &$list) {
        $comp = substr($item->name, 0, strlen($str));
        if ($comp == $str) {
            $list[] = $item->name;
        }
    });
    drupal_json_output($list);
}


texts: How to reference external JS callback in custom module

texts:
So I apologize if I mess the terms here up, I'm relatively new to using jQuery in Drupal. I'm trying to implement a custom Google Map application with the V3 API. When I started mocking the module up I had no problem invoking the google maps function callback without my JS being wrapped in a closure. However, needing to use jQuery functions pointed me to wrapping my JS in a closure and referencing jquery, as well as attaching my js to the Drupal.behaviors object. The problem that I have is that now it seems that the callback on my Google Maps script tag is out of scope. I'm not sure if this is due to the closure, due to how I'm loading the script, or something else that I haven't come across yet. The specific JS error I get is

Uncaught (in promise) message: "initMap is not a function"

My module JS is

(function ($) {
Drupal.behaviors.gmap_json = {
attach : function (context, settings){
var map, alumLayer, chapterLayer, assocLayer, userLayer;
  function initMap() {
    map = new google.maps.Map(document.getElementById('json-map'), {
      zoom: 4,
      center: {lat: 38.43, lng: -90}
    });
  alumLayer.setStyle({
    icon: 'purple.png',

  });
}
}
};
      alert('it works');
}(jQuery));

And my module php is

function gmap_json_block_info() {
    $blocks = array();

    $blocks['gmap_json'] = array(
      'info' => t('Google Maps with GeoJSON'),
    );

    return $blocks;
  }

  function gmap_json_block_view($delta = '') {
    $block = array();
    if ($delta == 'gmap_json') {
      $block['subject'] = '';
      $block['content'] = '

';
    }
    $path = drupal_get_path('module', 'gmap_json');
    drupal_add_js('https://maps.googleapis.com/maps/api/js?key=mykey&callback=initMap', 'external');
    drupal_add_js($path. '/gmap_json.js', 'file');

    return $block;
  }

So, what am I doing wrong and how can I either bring my callback into scope? Or what's the right way to set this up.

EDIT:
I have attempted to implement both the answer as well as one of the comments.

drupal_add_js('https://maps.googleapis.com/maps/api/js?key=mykey&callback=initMap', array('type' => 'external', 'defer' => 'defer'));

Adding a "defer" via array doesn't produce any changes, and changing the order of my calls to the js only changes where the error gets called.


texts: How can i implement a hook in my theme template that will display a placeholder in my comment box? I am using drupal 7 and zen sub theme. Thank you, in advance.


texts:
I wants to manage content type by admin menu tab, suppose I am having a "news" content type and if I would go to put some news, then I have to go first "content" tab then "Add content option" would appear and after navigate it, it shows all content types where I would select news this is default Drupal functionality but I wants that there should be link in admin menu like news, so when I click on news it directly navigate to news content type page and there should be only news contents not all. So how to do that? Actually I am having a lot of content types that I wants to show, each content type by each admin menu tab and also shows the data particular for its.

Please tell every thing step by step.


texts: Is there a way to add bulk operation options to the admin/content list's 'Update Options'?

texts:
I have downloaded the views bulk operations module and activated it.  I offers me many new options for changing the settings on my nodes/entities.  I would like to know if there is a way to add these options to the "update options" which is available on the content page of Drupal admin (location: admin/content.)

This menu already lets you do things such as publish, unpublish and delete.  It also picks up options from add-on modules.  It seems that views bulk operations should appear in this menu too.


texts: I'm on rackspace's cloud sites service, so I can't modify my server environment. I'm also running Drupal 7. I've spent the last couple days looking for a way to minify JS in Drupal 7 and it is my conclusion that one does not exist yet. Am I wrong? Or do I need to wait for a D7 release of http://drupal.org/project/advagg?


texts: How to create a custom field programmatically on content type creation?

texts:
I have a module which creates custom fields to the selected content type. This works fine when the content type already exists.

With hook_form_node_type_form_alter I create a extra tab on the edit page of the content type. In this tab is a simple checkbox.

function hook_seo_form_node_type_form_alter(&$form)
{
    /* @ CREATE VERTICAL TAB ON CONTENT TYPE TO ADD OR REMOVE SEO  */
    //get node type
    $bundle = $form['type']['#default_value'];
    if ($bundle != null) {
        $node_type = NodeType::load($bundle);
        $default_value = $node_type->getThirdPartySetting('seo', 'seo_options');
    } else {
        $default_value = 0;
    }

    //create vertical tab
    $form['seo'] = array(
        '#type' => 'details',
        '#title' => t('SEO'),
        '#group' => 'additional_settings',
    );

    //add checkbox to vertical tab
    $form['seo']['seo_options'] = array(
        '#type' => 'checkbox',
        '#title' => t('Use custom SEO fields'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#weight' => 10,
        '#default_value' => $default_value,
    );

    //create submit handler
    $form['actions']['submit']['#submit'][] = 'seo_form_submit';
}

I use  the following function to see if the form of the content type is submitted and run my script to add fields.

function seo_form_submit(&$form, \Drupal\Core\Form\FormStateInterface $form_state)
{
    /* @ ON SUBMIT SAVE CONFIG & ADD/REMOVE FIELDS  */
    //get node type
    $bundle = $form['type']['#default_value'];
    $node_type = NodeType::load($bundle);
    $checkbox = $form['seo']['seo_options']['#value'];

    //set checkbox value to config and save
    $node_type->setThirdPartySetting('seo', 'seo_options', $checkbox);
    $node_type->save();

    if ($checkbox == 1) {
        //Add fields
        seo_enable_field(
            'add',
            'node',
            $bundle,
            'page_title',
            'string_textfield',
            'basic_string',
            'Page title',
            'Description'
        );
    }

But for some reason this only works when the content type already exist and I edit it. When I create a new content type it doesn't work and my fields are not created.

How can I solve this?


texts: relative path in blocks - multilingual - does not work

texts:
I'm using Drupal 7 with i18n modules. I have 6 languages on my site.
The relative paths are working fine except for:
the relative paths in blocks for the languages other than the default language.

On my front page I have several blocks.
If I add the relative path in a block on my English (default language) front page (www.example.com) it works.
If I add a relative path in a block to my French front page (www.example.com/fr)

Link in block on the French page

Then my expectation was to get to this page

www.example.com/fr/page-in-french

but instead I get to the page:

www.example.com/page-in-french

which obviously does not exist.

I know that I can manually add in the relative path the language code

  Link in block on the French page

but since the URL that I'm accessing is www.example.com/fr , then a relative path should not contain the "fr/" since it is already in the URL.

How can I set the relative path to just "page-in-french"?

Thank you


texts: How can I return actual JSON using Drupal?

texts:
I'd like to implement a simple AJAX function locally that allows me to autocomplete node titles of already existing nodes as the user types. To that end, I need the ability to have an API that I can search on node titles. The problem is that when I output raw JSON, it comes surrounded by tags. So, no matter what I do, I keep getting...

 {json here}

I've tried implementing a custom page template that only outputs content already, that produced the same results. Here is how I am currently doing this, in my module file...

<?php

/**
 * Implementation of hook_menu()
 */
function content_relation_menu() {
    $items = array();
    $items['api'] = array(
        'title' => 'Search',
        'page callback' => 'content_relation_get',
        'access callback' => TRUE,
        'type' => MENU_CALLBACK,
    );

    return $items;
}

function content_relation_get($term = '') {
    drupal_add_http_header('Content-Type', 'application/javascript; utf-8');
    $var = json_encode(
        db_query("SELECT nid,title FROM {node} WHERE title LIKE :title LIMIT 5", array(":title" => $term.'%'))->fetchAll()
    );
    echo $var;
    exit(0);
}

How can I return JUST raw JSON?


texts:
We have a Drupal 7.12 Setup in production.

Recently we upgraded PHP to 5.4.10 and we are getting the following error,

  PHP Fatal error: Cannot call overloaded function for non-object in /var/www/html/includes/database/query.inc on line 331

What can be the possible reason for it and how do can we solve it?

If the above information is not good enough to know about the root cause,
how can some more data be logged about the error?


texts: Add a 'Buy-it-Now' button to an ApacheSolr View

texts:
So I have built a View that uses Apache Solr to display products on my Ubercart site from the Solr index.  Swell.  Now Ubercart typically lets me add a 'Buy-it-Now'/ Add to Cart button as a field in most views but for some reason in this view that is not possible.

How do I add a 'Buy-it-Now'/ Add to Cart field to this view?


texts:
I want to add additional vertical tabs (marked with red) in screenshot, but have had no luck with google or documentation.

How does one add tabs here?


texts: Before saving a node how to get the file path

texts:
For a content type "TEST" which has a field "upload file", I want the file path before saving the node.
hook_node_presave can be used to do anything before saving the node.
I want to rename the file before it get saved into database.

but my file is getting saved first into the database.

How to do rename a file before it gets saved into database in a custom module.