texts: How to make a case sensitive entity query?

texts:
My custom entity type comes with a string field for which I would prefer case sensitive queries. When I use
$query = \Drupal::entityQuery('my_entity_type')
 ->condition('my_token_field', 'SomeSortofTokenString')
 ->execute();

the result will include all entities no matter if the string in my_token_field is written the same way or for example with lowercases only. my_token_field is set a base field of type string - maybe this is the problem?


texts: JS error when using AddThis field displayed in a view

texts:
I keep getting this error:

ReferenceError: jQuery is not defined }(jQuery));

when using an addthis field displayed in a view.

Anyone has a clue what could be going on here?


texts: Test if Anonymous users can sign up for a new account

texts:
In a Drupal theme, how can you test if Anonymous users are able to sign up for a new account?

Background:

I am theming my user login form according to this tutorial.

On my themed user loser login form, there is an option for users to sign up if they do not have account.

On my site, I periodically disable anonymous sign ups, so when this happens, I want the sign up link in my theme to be not printed out.


texts: Install module from URL to site directory instead of /all

texts:
At http://drupal.local/admin/modules/install, when I install modules by entering a URL, they get saved to sites/all/modules.  I have a multisite setup, and I need them to go to sites/SITE/modules.

Any way to control that?


texts: How to utilise RequireJS and still access Drupal(7) JS API?

texts:
I have a project set up with Drupal loading in RequireJS which has a jQuery dependency defined.

All is well and good until I try something like this in a RequireJS managed module:

    (function($, Drupal) {
        Drupal.behaviors.someModuleName = {

            attach: function(context, settings) {
               // Some functional stuff here
            }
       };
    }(jQuery, Drupal));

The problem is that the attach function does not get called which leads me to think that Drupal is firing off its behaviours loader before Require has loaded up its modules.


texts: Display a field of one content type in another content type

texts:
I am using drupal 7.I have created two custom content types Bank details and Loan offers.
Now in loan offers i want the logo of the bank to be displayed.The logo image is part of bank details content type.can it be done using node reference?I need help to resolve this issue.Thanks.


texts: How to show conditional regions in Omega subtheme

texts:
I have created omega sub theme and in that sub theme i have region called postscript where there are four blocks are rendering.
 If there are only two blocks then the other two should take 50%-50% width.
what is the best way to do this?

Now i tried print render ($page['postscript_first']); for printing only postscript_first but it does not show anything(i have attached block to it in my block settings page).

Also i tried region.tpl.php for modification in my sub theme template folder.
I did't get how to print a single region as there is only print $content statement in my region.tpl.php file.


texts: Theme call for block returning as an empty string

texts:
I have a call for a block generating that is returning an empty string when it should be returning with generated content. I have cleared out the theme cache and the results remain the same. I've gone through most of the documented steps on the official docs and am pretty baffled as to why it isn't working as intended.

Here is the code from generic.module

/**
 * Implements hook_block_info()
 */
function generic_block_info() {
  $blocks['gen_1'] = array(
    'info' => t('Project Information'),
  );
  return $blocks;
}

/**
 * Implements hook_theme()
 */
function generic_theme() {
  return array(
    'block_projectinfo' => array(
        'variables' => array(
            'completionPct' => NULL,
        ),
        'file' => 'theme/block-projectinfo'
    )
  );
}

/**
 * Implements hook_block_view()
 */
function generic_block_view($delta = '') {
    global $conf;

    switch ($delta) {
        case 'gen_1':
            $block['subject'] = t('Project Status');

                 $variables = array(
                  'completionPercentage' => 45
                     );

            $block['content'] = theme('block_projectinfo',$variables);
            break;
    }
    return $block;
}

Theme

<?php

/**
 * @file
 * Provides rendered output of the Project
 */

?>

            Percent Complete
            <?php print $completionPct; ?>%


texts: Organize node file attachments into groups

texts:
I have a content type with multiple file attachments to download. Is there a module to give authors the ability to divide all the attachments into groups, writing a title for every group, just like they can reorder and name them in edit mode?
The final node display should be something like this:

Group Title 1
. File n.1
Group Title 2
. File n.2
. File n.3

I've been searching for a while and found FileTree, but it's too complicated. Files shouldn't be managed physically, just displayed in groups.

Thanx in advance.


texts: How to connect to MySQL with SSL connection

texts:
I have Drupal 7.24 / PHP 5.3.27 and am using the PHP native MySQL drivers.  PHPinfo shows that SSL is supported.

I can't seem to get Drupal to connect to MySQL with SSL.  Works fine without it.
I did find a patch 726192-arbitrary-pdo-options-attributes.patch  that looked like it was committed back about 7.17.  However I did not see the patch in my 7.24 that I downloaded.  So I applied the patch.  Still doesn't work.   There are a lot of bad examples of configurations in others questioning how to connect.   My best guess is this configuration.  But again it does not work.  I have test these SSL certs and connection Navicat and it does connect fine

Any suggestions on what to try or where to look??

$databases = array (
  'default' =>
   array (
    'default' =>
     array (
       'database' => 'drupaldb',
       'username' => 'drupaluser',
       'password' => 'password',
       'host' => '192.168.10.100',
       'port' => '3306',
       'driver' => 'mysql',
       'prefix' => '',
       'pdo attributes' => array(
           PDO::MYSQL_ATTR_SSL_KEY => '/path/client-key.pem',
           PDO::MYSQL_ATTR_SSL_CERT => '/path/client-cert.pem',
           PDO::MYSQL_ATTR_SSL_CA => '/path/ca-cert.pem',
        ),
     ),
   ),
);


texts: Allow to filter (in a view) on a datetime field of a custom entity

texts:
I have created a custom entity as follow:
Here is an extract of my entity definition in  modules/custom/bank_operation/src/Entity/BankOperation.php
Notes:
1- As you can see, I have changed the value of the views_data key
2- The operation_date base field have the datetime type
 * @ContentEntityType(
 *   id = "bank_operation",

 ...

 *     "views_data" = "Drupal\bank_operation\BankOperationViewsData",

 ...

class BankOperation extends ContentEntityBase implements BankOperationInterface {

  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {

    ...

    $fields['operation_date'] = BaseFieldDefinition::create('datetime')
      ->setLabel(t("Operation date"))
      ->setRequired(TRUE)
      ->setSettings([
        'datetime_type' => DateTimeItem::DATETIME_TYPE_DATE,
      ])

    ...
}

Here is an extract of my overrode EntityViewsData in  modules/custom/bank_operation/src/BankOperationViewsData.php
This class is used according to the value of the views_data key. This is my attempt to allow a view to filter on the operation_date field
class BankOperationViewsData extends EntityViewsData {

  public function getViewsData() {
    $data = parent::getViewsData();
    $data['bank_operation']['operation_date']['filter'] = [
      'id' => 'datetime',
      'field' => 'operation_date',
      'table' => 'bank_operation',
      'field_name' => 'operation_date',
      'entity_type' => 'bank_operation',
    ];
    return $data;
  }

}

After that, I have created a view to display my BankOperation entities with an exposed filter on the operation_date field.
Here is the error produced when using this filter (I don't understand why ViewsYearFilterDatetime is called)
Exception: DateTime object not set. in Drupal\Component\Datetime\DateTimePlus->__call() (line 360 of core/lib/Drupal/Component/Datetime/DateTimePlus.php).

Drupal\datetime\Plugin\views\filter\Date->opSimple() (Line: 63)
Drupal\views_year_filter\Plugin\views\filter\ViewsYearFilterDatetime->opSimple() (Line: 330)
Drupal\views\Plugin\views\filter\NumericFilter->query() (Line: 1373)
Drupal\views\ViewExecutable->_build() (Line: 1262)
Drupal\views\ViewExecutable->build() (Line: 390)
Drupal\views\Plugin\views\display\PathPluginBase->execute() (Line: 180)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1630)
Drupal\views\ViewExecutable->executeDisplay() (Line: 77)

I know that there are other questions like this one, but none of them are providing a detailed answer (only links).
I have setup my question to allow people who are facing the same issue to quickly find a path to solve it.


texts: How to create a View that shows a node from the URL inside the admin area?

texts:
I have a certain node type that I want users to be able to view using the admin theme.

I have a view that provides a list of this content at admin/foo/list. I'd like to create a view with a contextual filter such that admin/foo/list/123 would show node 123.

I can create that view, and it uses the admin theme, but what I'd expect/want is that the breadcrumbs should show admin/foo/list. Instead it shows just "home".

The View won't let me create a menu entry for it because of the contextual filter.


texts: How to programmatically set the color scheme for a theme?

texts:
Is there a way to programmatically change the color scheme, set by the color module, for a certain theme in Drupal 6 (in PHP or using drush)? For example, I can change Garland's color scheme from the UI:

but I want to do it programatically.


texts:
I have created a custom form in a custom page in the admin of my Drupal 7 site. On this form I have two sets of radio buttons (cities and sectors). I want it so that when I change the cities radio selection, the sector radio values swap to my new set values.

I have the following code in the main form declaration which initially sets up the form.

$form['module']['cities'] = array(
    '#type' => 'radios',
    '#title' => t('City'),
    '#ajax' => array(
        'event' => 'change',
        'wrapper' => 'sector-wrapper',
        'callback' => 'module_field_city_change_ajax_callback',
        'method' => 'replace',
    ),
    '#options' => array("1" => "New York", "2" => "Moscow"),
    '#required' => TRUE,
);

$form['module']['sectors'] = array(
    '#type' => 'radios',
    '#title' => t('Sectors'),
    '#prefix' => '
',
    '#suffix' => '
',
    '#options' => array("Sport"=>"Sport", "Media"=>"Media"),
    '#required' => TRUE,
);

This creates forms. You can see I've added a callback 'module_field_city_change_ajax_callback'. The code for the callback is as follows:

function module_field_city_change_ajax_callback($form, $form_state){
    $form['module']['sectors'] = array(
        '#type' => 'radios',
        '#title' => t('Sectors'),
        '#prefix' => '
',
        '#suffix' => '
',
        '#options' => array ('Aerospace' => 'Aerospace', 'Art' => 'Art' ),
        '#description' => t('Some text to show the div was updated?'),
        '#required' => TRUE,
    );
    return $form['module']['sectors'];
)

It almost works. The old sectors are updated with the new form element apart from one major part - the actual radio buttons (#options). I know the div has updated and the form rendered because it has the text 'Some text to show the div was updated?' injected. However there are just no values to click.

Any ideas?


texts: Not able to make simple node path show up in "crumbs module"

texts:
I have read all the documentation, and I have been clicking about wildly for hours, and I have used the "debug" tab for the Crumbs module, and I still cannot get the simplest path to show up:

Home > Content type > Node title

It always gives me: Home > Node title

This seems a simple task. Someone please give me the steps...

Many thanks.


texts: Using Feeds Tamper to convert one list to another?

texts:
I am using a feeds importer to import a number of FIPS county codes for given locations and I was hoping to use the Feeds Tamper module to convert those county codes to county names, but have thus far been unsuccessful. Any ideas? I realize that there is a "Find replace" plugin for the Feeds Tamper, but seeing as this seems only to convert a single word or phrase at a time, I'd have to do this too many times for it to be worthwhile, though it does seem to reveal that the module is capable of doing the task I desire.

Thanks in advance,

David


texts:
When I am logged-in as administrator, I click on content, then add content, and I get a message saying I have no content types created, and I must create new ones. In fact, though, I have several content types, and I have been using them for days to build my site.

Do you have any idea on where the glitch is?


texts: Global site variables to be used in node fields and menu item

texts:
I'm looking for some way of having variable defined by admin which can be displayed in some fields or nodes.

Real use case:
I have that specific date that changes periodically. And I want it to appear in some places, ie. within text of some node body (with possibility of fixing the variable ie. putting some text instead of date, but it's not a matter of my question).

My guess: create some hook to preg_replace all occurences of some string, ie. ##VAR_VARNAME1## with certain fields of nodes or within field texts. But actually I know that it will occur mainly in 2 or 3 places within my website (which is for sure body of one specific node and text of 1 menu item).

Any ideas to make this efficient and quick?

edit: I believe it's easy to do with defining new block.. but how about way I mentioned above..


texts:
Possible Duplicate:
  Listing entity fields

I want list fields of my content type(example: blog), so as described at Drupal API reference, I should pass $entity_type and $entities to this function.

I know $entity_type is 'node', but how can I fill $entities?
I should fill $entities with bundle of "blog" so I should know the bundle ID.
How can I know bundle ID for blog?


texts: Views Filter Criteria "Now" not working on webform submitted data field:event date

texts:
The closest I have found to this is This Question which sounded perfect but didnt work for me.

I need to show a list of results in my view equal to or greater than todays date. In the past, on a value formatted as a date, I use "now" and it works a treat.

I have built a view using webform submission data from the latest webform release, which enters a date field as plain text into the database rather than timestamp. So i have the raw value 2014-05-08 from the database.

I can test it by entering the date into the filter value as "2014-05-08" and it works perfectly, but of course I need todays date to update automatically.

I have tried using token filter to use a current date token, for a custom date type I created ('Y-m-d'), but nothing happens.

I have also installed views-php module, which hides a row if value returns true, but the following test didn't work

$date = date('Y-m-d');
if ($row>value_1 == $date) {
return TRUE;
}

Is there any way to use tokens in the Configure filter criterion: value field?

EDIT:

There was a bug in the views-php module that this patch fixes.

I used a Global:php field to convert my text to date, but my next hurdle is that you cant use an exposed filter to filter results from a global:php field.

$eventdate = strtotime($row->value_1);
echo date('Y-m-d', $eventdate);


texts:
I have two content types: "banner wallpaper" and "banner1".

I'm using two views blocks. The view "banner wallpaper" displays the content from content type "banner wallpaper" and "banner1" the content from "banner1".

I have two wallpaper banners and two banners1 content.

With format views slideshow, timer delay set to 0 and marked random option in view I successfully managed to display the two banner wallpapers by refreshing the page. That goes same for Banner1.

My goal is: when the first wallpaper banner is displayed, the first banner from banner1 to be displayed too. When I refresh the page the second wallpaper banner and the second banner from Banner1 will be displayed, so they will be synchronized.

For an example we have two brands that will wants to advertise in the website.

Green and Orange.

These two brands wants to have wallpaper banner and flash banner.
So, when Green wallpaper banner is displayed, the flash banner from Green has to be displayed too, not to be mixed with Orange. After refresh the wallpaper from Orange will be displayed and the flash banner from Orange too... I think I'm clear.

Is there any filter or sorting available to achieve this with views?


texts: Theming book navigation block to generate drop-down menus

texts:
I have a 3 level deep book navigation block. I'd like to change the menu tree HTML output in the following way: For each level of the tree, create a li and inside it put an anchor tag with the active-trail link for that level, and afterwards a ul with the rest of the siblings for that level.

    Level[x] active trail link

Level[x] sibling1

Level[x] sibling2

Level[x] sibling3

Level[x] sibling4

The order of sibling links appearance should be according to their corresponding node weight.

I thought this could be done via the theme_menu_link() function but I can't seem to find a way to pass the current item's depth to the function.

What function do I have to work with in order to achieve what I'm after? Can someone offer some guidance?

Thanks,
Avner


texts: full html and ckeditor strip some meta tags

texts:
I have this code in the field_data_body table in Drupal 7 in the database:

 <meta itemprop="url" content="http://sitename.com/images/picture01/art-cinema1.jpg" />
 <meta itemprop="width" content="252" />
 <meta itemprop="height" content="190" />

But when I edit the content I have just this code in the body field:

When I copy the code from database and paste it again into the editor, it shows the correct form of code but when I click the source key in CKEditor the code will change to the short form again.

In addition, when I save the content and use inspect element of Chrome browser it shows me the complete form of the code!!

So the problem is just the edit node page which just shows me a short form of code and removes all the meta tags!! How can I fix this problem?


texts: How to get workflow state transition history for a node?

texts:
In the admin section, for any given node, I need to add a dropdown field that lets QA assign that node to a developer who had previously made changes to the node's workflow state. I am currently using the workflow module (https://www.drupal.org/project/workflow). This field needs to be populated with users who have changed the node's workflow state before. So, I'm working on a module that can do this. My question is, how do you programmatically get the workflow state transition history for a given element?

For every revision of a given node that has involved a workflow change, I would need the following information:

The state or state id (sid) that it was changed to.
The uid of the user that made the change.
The order in which the workflow state transitions were made.

I tried node_revision_list, but it does not include revisions that only change the workflow state. (Because it's not looking at the workflow_node_history table).

I can get the information I need directly from the database by running the following query, but I don't want to do any database-hacking if this functionality is already in Drupal somewhere.

SELECT sid, uid  FROM `workflow_node_history` WHERE `nid` = ? ORDER BY stamp asc

Is there a Drupal function that already does this?


texts: I'm working on a feature that will allow me to create series of nodes.  Each node will have a number of associated files.  I'd like to be able to upload the files to a directory that uses some fields from the parent node.  In other words, when the file is uploaded, a directory is used (or created if it doesn't exist yet) that uses the date the node was created and the title of the node.  I know I can specify a static directory to use when creating a file field, but I need create a subdirectory inside the parent directory. Is this possible?


texts: How to pre-populate a field with the current users name?

texts: I want to pre-populate a form field with the value from another cck field from a different content type. I have been looking into using the prepopulate module and pathauto to get the correct url, but I am not sure that these will work. I am new to drupal and kinda lost in the storm with this problem.


texts: How can I force Drupal to load all taxonomy terms?

texts:
On a site that heavily uses Drupal core's taxonomy, we are encountering serious problems when editing content: Already entered taxonomy terms are not properly loaded into the node editing form; fields that should contain values are rendered empty; when the nodes are saved, the terms are lost. So this is not a display issue.

Please note: Some terms are not loaded into the node editing form. We know exactly which terms should be there because a View displays the terms in a structured fashion.

I am aware that Drupal inherits multiple issues with large forms from PHP; for example, large user permission screens are not being saved in Drupal, because PHP has a default value for 'max_input_vars' of '1000'; by increasing this value, e.g. to '1500', Drupal becomes able to save user permissions again. We'Re supecting something similar with the node editing screens. However, in our case, values are not even inserted from the database into the node editing form, so it's totally unclear where to even start looking for a solution.

The environment:

Drupal 6 (Pressflow)
Around 110,000 nodes
24 vocabularies with >  100,000 terms

Also noteworthy: The problem with incomplete node editing forms is not limited to taxonomy terms; it sporadically also applies to other form elements like attach images.

Are there any PHP configuration values that could cause this misbehaviour or does Form API have any hard limits in redard not the size of node editing forms (e.g. number of form elements per form, memory limits per node editing form)?


texts:
I will build a form for register new team on drupal 7 website.

In my custom module i use this code :

tournament.module :

function tournament_menu() {
    $items['tournament/newteam'] = array(
        'title' => 'Créer une nouvelle équipe',
        'page callback' => 'form_newteam',
        'access callback' => TRUE,
        'file' => 'form_tournament.inc',
    );
}

form_tournament.inc :

function form_newteam ($form, &$form_state) {
    $form['description'] = array(
        '#type' => 'item',
        '#title' => 'Créer une nouvelle équipe'
    );

    $form['name'] = array(
        '#type' => 'fieldset',
        '#title' => t('Name'),
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
    );
    $form['name']['name_team'] = array(
        '#type' => 'textfield',
        '#title' => 'Nom de l\'équipe',
        '#required' => TRUE,
        '#description' => "Entrez le nom de votre équipe.",
        '#size' => 20,
        '#maxlength' => 25,
    );
    $form['name']['tag_team'] = array(
        '#type' => 'textfield',
        '#title' => 'Tag de l\'équipe',
        '#required' => TRUE,
        '#description' => "Entrez le tag de votre équipe (version courte du nom de votre     équipe ex : 'FrR').",
        '#size' => 4,
        '#maxlength' => 4,
    );

    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => 'Créer',
    );

    $form['contact'] = array(
        '#type' => 'fieldset',
        '#title' => t('Contact'),
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
    );
    $form['contact']['contact_email_team'] = array(
        '#type' => 'textfield',
        '#title' => 'Email de contact de l\'équipe',
        '#required' => TRUE,
        '#description' => "Entrez l'email de contact de la team.",
        '#size' => 20,
    );
    $form['contact']['contact_name_team'] = array(
        '#type' => 'textfield',
        '#title' => 'Nom du contact',
        '#required' => TRUE,
        '#description' => "Entrez le nom du contact de l'équipe.",
        '#size' => 20,
        '#maxlength' => 64,
   );

    [...]

    return $form;
}

function form_newteam_validate($form, &$form_state) {
    $syntaxe_email = '#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#';

    if (!preg_match($syntaxe_email, $email)) {
        form_set_error('contact_email_team', "Entrez une adresse email valide !");
    }
}

function form_newteam_submit($form, &$form_state) {

    drupal_set_message('OK : team : @team, tag : @tag, email : @email, contact : @contact, site_web : @site, logo : @filename. ',
        array(
            '@team' => $form_state['name']['name_team'],
            '@tag' => $form_state['name']['tag_team'],
            '@email' => $form_state['contact']['contact_email_team'],
        )
    );
}

This form appears correctly, but when i submit it, nothing is happening...

Any idea ?

Thank !


texts: Add content are not correctly re-parented

texts:
I decided to change Add content node/add/% from Navigation menu to Management menu.

My prob is :

Add a Content type
Go to Add content

and my new Add content's child link doesn't appear. It appears without parent in Navigation menu which is use in my case as a Top menu.

I found some answers about this bug but nothing permit me to clear my question.

Thanks in advance for helps.

PS: when I edit a content type, regardless about Menu settings I put, my Add content child back to Navigation menu.


texts:
I am having trouble installing drupal on my localhost, using PHP Version 5.6.0-1, system Linux notosh 3.16-2-amd64 #1 SMP Debian 3.16.3-2 (2014-09-20) x86_64
Installing standard 7.31, no distro.
Upon completion cannot login as user1 with password to access admin interface.


texts: Using hook_node_presave to auto-select a reference field from a field list selection

texts:
I'm trying to use hook_node_presave to select a value in a term reference field based on a selection a user makes in a field list field. The term reference field is hidden from the user. The code I'm working with is problemmatic in at least two ways:

1) I'm not sure I'm referencing the correct theme in my function header because the dpm() is not outputting anything. But it's in the administrative theme 'seven' that this form is running so I assume that's right.

2) I'm getting errors when I run this code saying 'syntax error, unexpected ||' wherever I have those. Am I not using the correct syntax for OR operators? It seems fine to me. I tried OR in place of || and got the same errors.

Here's the code I'm working with:

function seven_node_presave($node) {
    $field_type = $form['field_type']['und']['#options'];
    dpm($field_type);
    if (($field_type == 4) || ($field_type == 5)) || ($field_type == 7) ||
($field_type == 6)) {
        $form['field_icon']['und']['#options'][]= '2';
    }
    elseif (($field_type == '9') || ($field_type == '98')) || ($field_type == '8')) {
        $form['field_icon']['und']['#options'][]= '6';
    }
    elseif (($field_type == '3') || ($field_type == '1')) || ($field_type == '2')) {
        $form['field_icon']['und']['#options'][]= '1';
    }
}

Note 1: the numbers being compared to (ex: $field_type == 4) are the 'keys' for those fields, not the actual text the user would select.

Note 2: I'm running this from a module called grouphideandselect, not from template.php...maybe that's my problem?


texts: How do I pass a value from the url to a custom field in the registration form?

texts:
I know variations of this question have been asked but I haven't found any with this specific set of characteristics. Also, the only programming language I know is python. I don't know PHP at all.

I want to be able to pass the value from a url parameter into a custom hidden field in the registration form.

I've tried using theme functions, template files, and hook_form_alter() but I haven't been able to get any of these to work.

So far, I've been able to add the custom field but I can't seem to hide it, let alone be able to pass the value to it. I am able to add html to the form via the template file but that's about it.

I based my attempts on this site: themery

This is the code I tried to see if I could alter the label for email.

function acq_dmc1_form_user_register_form_alter(&$form, &$form_state) {

$form['mail']['#title'] = t('E-mailzzzzzz');
$form['field_recipientid']['#title'] = t('QualID'); //this is the custom field

}

...but it didn't work.

this is the form id:

<input type="hidden" name="form_id" value="user_register_form" />

this is the HTML that's rendered for the custom field:

<input class="text-full ckeditor-mod form-text" type="text" id="edit-field-recipientid-und-0-value"
name="field_recipientid[und][0][value]" value="[url:path]" size="90" maxlength="25">

EDIT: June 17, 2013
Someone gave me this code as a solution but I don't understand if it will work or how it will work:

function passval_user_presave(&$edit, $account, $category) {
    $fields = array(
    'RecipientID' => array('fieldname'=>'field_recipientid', "type"=>'complex'),
        'mail' => array('fieldname'=>'mail', "type"=>'simple'),
    );
    $urlargs = drupal_get_query_parameters();
    foreach($fields as $key=>$field) {
        if(isset($urlargs[$key])) {
            $value = ($urlargs[$key]);
            $value = intval($value);
            if($field['type'] == 'complex') {
            $edit[$field['fieldname']] = array('und'=>array(0=>array('value'=>$value, 'format'=>'', 'safe_value'=>$value)));
        }
        else {
            $edit[$field['fieldname']] = $value;
            }
        }
    }
}


texts: Javascript loaded via DrupalSettings variable not executing?

texts:
I have added a js library and associated code to get all Location nodes onto a Map page

This code works fine if I paste it into the map.js file but if I use the drupalSettings variable, the code is appearing in the map.js file but doesn't appear to be executing

The map.js file

(function ($, Drupal, drupalSettings) {

    'use strict';

    Drupal.behaviors.mybehavior = {
        attach: function (context, settings) {

            var map = L.map('mapid').setView([-38.037511118801255, 176.41345152203002], 13);

            var googleSat = L.tileLayer('http://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}',{
                maxZoom: 20,
                subdomains:['mt0','mt1','mt2','mt3']
            }).addTo(map);

            // the data from basic.theme file, basic_page_attachments_alter function
            // console.log(settings.basic.nr_map.foo);
            settings.basic.nr_map.foo;

        }
    };

})(jQuery, Drupal, drupalSettings);

And the code from the theme function

function basic_page_attachments_alter(&$page) {
  $node = \Drupal::routeMatch()->getParameter('node');
  if (!empty($node)) { // if empty its a view and has no bundle - causing 503
    $bundle = $node->bundle();
    if($bundle == 'map') {
      $mapid = $node->id();
      $nids = \Drupal::entityQuery('node')->condition('type','location')->execute();
      $nodes = \Drupal\node\Entity\Node::loadMultiple($nids);

      $out = '';

      foreach ($nodes as $key => $location) {
        $map_title = $location->getTitle();

        // lat, lon
        $latlong_arr = $location->get('field_mahere_location')->getValue();
        $lat = $latlong_arr[0]['lat'];
        $lon = $latlong_arr[0]['lon'];

        $out .= 'var ' . strtolower($video_title) . ' = L.popup({ closeButton: false, closeOnClick: false, autoClose: false, className: "static" }).setLatLng([' . $lat . ', ' . $lon . ']).setContent("
' . $map_title . '
").openPopup().addTo(map);' . PHP_EOL;
      }

      $page['#attached']['drupalSettings']['basic']['nr_map']['foo'] = $out;
      $page['#attached']['library'][] = 'basic/nr_map';
    }
  }
}

If I copy the code from the console i.e. console.log(settings.basic.nr_map.foo) and paste it into the map.js file it runs perfectly and creates all of the map markers I'm after, but if it comes from the variable i.e. settings.basic.nr_map.foo it doesn't execute, and doesn't create any map markers

Any ideas? It seems like it should be simple!

Apologies for the duplicate post but I haven't had any joy on drupal forum.

Thanks

EDIT:
And the libraries yml file

nr_map:
  js:
    js/map.js: {}
  dependencies:
    - core/drupal
    - core/jquery
    - core/drupalSettings


texts: How to change a custom field on form save

texts:
In the node type page I've added one Integer field "field_article_rejected".
When in rejected stated it contains 1.

But when a registered user changes and "Saves" it I want to set the value of it to 0.

Also the registered user does not have read/write permission on this field. But if needed I can give the user permission for this field but I'll hide it in "Display fields"

How to do it?

I'm working on Drupal-6.

To explain what I'm doing: I've created an article directory. So an user will log-in and create an article type of page. So now this page will be shown as "Submitted articles" block using views.

But as an admin when I reject it then I want this article to be shown under "Rejected Articles" block to the user. So I want to use field "field_article_rejected". When 0 it means user has sumbitted and when 1 then it means rejected by admin.


texts:
I'm new to developing in Drupal and am trying to create my first module. I've got it all set up, but I don't know how to add the theme to it. Right now it just shows a blank page with only the text "Hello World".

   <?php
function news_main() {
    require_once('/global_applications/news/home.php');
}

function news_menu() {
    $items = array();

    $items['news'] = array(
        'page callback' => 'news_main',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
     );

    return $items;
}
?>


texts: Remove attribute ID from site-logo (Panels Page Elements)

texts:
I use a module panels everywhere with Omega 4. I try to put a site-logo in header and footer but Logo Page Element from Panels takes site-logo and render it with ID. So I have same ID twice in my page.

Header

Footer

How I can remove ID or render element with my markup?
How I can create own element for panels?

Thank you


texts: Why is Search API only searching node titles?

texts:
I have a Drupal 8 site with a custom content type called "Story". It uses the provided body field with machine name "body". Although I have set up configured Search API, it seems to only search node titles.

Here are the fields I have added under the search index:

How can Search API be configured to search other fields, including the body field? I have tried searching words that are found only in a body field, and no search results are returned.


texts: Not all custom theme styles shown in ckeditor window

texts:
In my theme.info.yml file I set my theme CSS to be also used in the ckeditor window. The problem is that in my CSS I declared some styles to be only applied within #content section, so it doesn't show in ckeditor. I tried these styles to be shown in the editor through classes like

.cke iframe body ul {
  list-style-type: disc;
}

but it doesn't work...


texts:
I have a simple Entity Form and have added a custom submit handler:

$form['actions']['submit']['#submit'] = array('custom_submit','entityform_edit_form_submit');

That works very well. The problem is when I enable form preview before submission. My custom_submit function runs before preview is generated and not after it was confirmed.

How do I get it to run after form has been confirmed in preview?

$form['#submit']  = array(
    'custom_submit',
    'entityform_edit_form_submit'
);

does not work at all.


texts:
I am using Drupal basically to store a ton of info on various topics. The problem is, we add data slowly over time.

I would like to get a report that shows which nodes have the least content. I.e. The most empty fields. This way, I can tackle those with the least amount of data first. Is this possible with Drupal?


texts: Is there a module that would allow me to reorganize the way fields are displayed for a content type form?

texts:
When I create a particular content type, Drupal generates a form for me with all the appropriate data entry fields.

However, the form is not particularly attractive: all the fields are displayed one below the other, but in some cases I would like to be able to display fields side by side, for example.

Does anyone know of a module which would allow me to take control of the way fields for data entry are displayed? I am thinking of something like Display Suite, but for forms.


texts:
I recently noticed a 5 second delay on my Drupal 7.34 website which I think is being caused by itok (a new security token used for files, like images, that are modified by Drupal).  How do I remove this delay?  Do I have to disable itok?

For instance this image takes 5 seconds to load.


texts:
Ok I have been working with the batch API and I have one working successfully now I would like to run another batch after the first one.

batch_set says I can do this:

array(
  array('my_function_1', array($arg1)),
  array('my_function_2', array($arg2_1, $arg2_2)),
)

I am trying this, but it isn't running the second function:

$batch['operations'][] = array('test_function1', array($new_node), array('test_function2'), array($new_node));
batch_set($batch);

Any ideas on how to run the second function?


texts: Add custom files/file-fields to panels pages

texts:
I would like to add content from a set of file fields to particular pages (via panels/panels everywhere/panelizer) with the ability to change the files by panels IPE editor or backend form.

Ideally, I would like to just add a custom content pane, or minipanel (or whatever it needs to be) to specific panels pages, and have that widget be able to upload files that print to the page, and that page only. It would also be nice to reuse the widget for other panels pages for different sets of files. I'm trying not to involve a whole other set of node/content types just to do this.

Could anyone point me in the right direction? Thanks.

Detail: The purpose is to upload files and add file paths to an element on some pages which is the image/video source for a fullscreen image/video background script.


texts:
I'm trying to run a migration D7 to D8 which I've coded. This is the command:

drush migrate-manifest manifest.yml --legacy-db-url=mysql://User:PASSW@localhost/drupal7ddbb --verbose

but basically no response, just something like done... but there is no nodes in the list of content.

Anyone knows how to make a deeper debug in Drupal8 migrations?

Thanks in advance.


texts:
I have a search page with a faceted filter on 'Content Type' field.

I basically need to merge some of the content types into one single facet.

Example:

Content Type A
Content Type B
Content Type C

Should be turned into:

Content Type AB
Content Type C

How can I achieve this?

My Drupal setup for this scenario is the following:

Search API + Search API Solr + Facetapi + Views


texts:
I have defined a custom action for a VBO.

function expense_action_info() {
  return [
    'expense_finalize_action' => [
      'type' => 'node',
      'label' => t('Approve and finalize expense'),
      'behavior' => ['changes_property'],
      'configurable' => TRUE,
      'vbo_configurable' => FALSE,
      'aggregate' => FALSE,
    ],
  ];
}

I've also created a configuration form for this action and rendered it along with the view.

function expense_finalize_action_form($settings, &$form_state) {
  $form['kickback_note'] = [
    '#type' => 'textfield',
    '#default_value' => 'new'
  ];
  return $form;
}

function expense_finalize_action_submit($form, $form_state) {
  return ['kickback_note' => $form_state['values']['kickback_note']];
}

When I submit the VBO I've redirected to page of this custom form and I need to click on the Next button to proceed the action.
As I have provided required values in the form I need to skip this step. Is it possible?


texts: Can't access template page--node--1.tpl.php by its path

texts:
I'm trying to access template page--node--1.tpl.php through /node/1 but seeing 'The requested page "/node/1" could not be found.'

What can I do with this to access this template?

I'm using Drupal 7 and the template is in theme/templates folder.


texts: How do I use non-admin theme for page containing node form?

texts:
I've created a custom route where I return node add form with a controller. It works fine, but for the administrator user it is using the administrator theme.
I tried using the following, but it doesn't help.

  options:
    _admin_route: FALSE

Is there a good approach to achieve this? As I remember, in Drupal 7, it worked fine with hook_admin_paths().


texts: View that displays map with clustered points and Streetview option

texts:
I need to construct a map block that displays multiple location markers with the following characteristics:

Markers are linked to other content on the page.
Markers are clustered until you zoom in far enough, when they gradually resolve into separate markers.
Individual locations may have multiple markers leading to different content on the page.
It's possible to open the map in a full-screen view.
It's possible to display the map in satellite view.
It's possible to switch to Google StreetView by dropping the orange pegman onto the map. I do not need to display a panorama of the locations, just have the orange pegman available.

I have the following relevant modules installed:

Geofield
IP Geolocation Views & Maps
Leaflet
Leaflet Markercluster
Leaflet More Maps
Leaflet Views

but I'm willing to supplement these or switch them to get the right functionality.

At present I can either:

construct a map that handles the markers as I wish on a Google hi res map (using a Map view generated using Leaflet API via IPGV&M). I believe I will be able to add full screen capability to this as well, but haven't tested it yet. Satellite view works. I have not found a way to provide Google Streetview in this set up.

or

construct a map that has full-screen capability and Streetview and satellite view on a Google his res map (view generated using Google API via IPGV&M). However, markers aren't clustered and only a single marker is associated with each location which means I can't link to all the appropriate content on the page.

What can I do to meet the full set of requirements? Is it possible to add Streetview capability to the Leaflet API solution? Or Marker clustering to the Google API solution?

I've reviewed https://gis.stackexchange.com/questions/70636/incorporate-google-streetview-into-a-leaflet-map and the linked questions there, but haven't found a solution; not have I found a solution in the [location] tag here.


texts: User login not linking to translated front page

texts:
On my front page I have a language selector (English / Spanish). The default language is English. If a user chooses Spanish and logs in he is redirected to the English version of the front page. How do I redirect them to the Spanish version of the front page?

I tried Rules but that did not work.


texts: How to have a field with a select list widget and custom list entries?

texts:
In my content type there is a text field that is set using a list (combobox).

When adding new content, the list is displayed with static elements.

I would like to query an external site when the user adds content (or edits the page) and then build the list from the query result. The user can then select from these elements.

Is that possible?


texts:
I am a single developer making a good few sites in drupal.  At the moment I have one site working, I will be using the same modules for the next few but different theming.  Is multisite a good option even though wont be sharing any content?  I just want to be able to manage the sites on the one laptop, the one installation if possible & save time downloading modules again and again.  All of the sites will have different domains, none of them subsites.  I have been trying to get this working for weeks but am in an awful fuzzle now.  Any thoughts?  I tried to post on drupal.org forums but couldnt even get that working.  Any help welcome..

Regards
Naoimi


texts: Is it possible to provide logins based on purchases?

texts:
There shall be an online shop with drupal commerce. It is required that a visitor can buy a digital product, i.e. a ticket with a barcode that he can print out. The visitor shall not be able to create an account.

The visitor must provide his email when buying a ticket. When the visitor finishes the payment process a pdf (a ticket with a barcode) and a unique id are generated (an id for that purchase if you will). A visitor can buy multiple tickets, but everything that is bought in one process has the same purchase id.

Is it possible to let that user "login" with his email and the generated id, given an overview of all the tickets the user bought related to that purchase id?

Background of this is: a user shall be able to see the bought tickets to be able to print them again. But one email address can be used several times, not meaning its everytime the same user.

Example:

Visitor foo@bar.com makes a purchase with 2 tickets, t1 and t2, id abc is generated.

The visitor can then "login" using the credentials foo@bar.com and abc "as password", seeing tickets t1 and t2.

Two days later, another visitor with the same email address makes another purchase, buying a ticket t3 and generating the id def. Hours later, he wants to print the ticket again, he can login using the mail foo@bar.com and the "password" def, showing ticket t3.

If he used password abc instead, he would be shown tickets t1 and t2.


texts: How to get location (longitude and latitude) from json data show on map?

texts:
I am using Openlayers module to have a map. In my json, it has longitude and latitude field. I want to get them to show on map so that user can see the location with the marker.

Is there any way to help me solve this problem?
Any help would be appreciated.


texts: Owl Carousel 2 switches to default position after Ajax call

texts:
I'm a real noob at js so I hope I'll find working solution to solve my problem. I'm working on Drupal 7 project based on Porto template v.2.1 using Dupal Commerce module. I've implemented Owl Carousel 2 v. 2.1.0 with jQuery 1.12.3.
At the product display page I have few attribute widgets which are carousels. All my carousels items are clickable (product attributes which loads big picture of a model with related attributes by Ajax calls). One widget has more than 30 items (models which are taxonomy terms), now it has just 14 items. So I call for that widget (div) carousel plugin with following code:

(function($) {
    Drupal.behaviors.myBehavior = {
      attach: function (context) {
        $('.attribute-widgets > div > div ').addClass("owl-carousel");
        $('.attribute-widgets > div > div ').addClass("owl-theme");
        var owl = $('.owl-carousel');
            owl.owlCarousel({
                dots: false,
                margin: 10,
                autoWidth: false,
                responsive:{
                    640:{
                        items:3,
                        nav: true,
                        navText: "",
                    },
                    768:{
                        items:4,
                        nav: true,
                        navText: "",
                    },
                    1024:{
                        items:7,
                        nav: true,
                        navText: "",
                    },
                    1280:{
                        items:9,
                        nav: true,
                        navText: "",
                    },
                    1366:{
                        items:10,
                        nav: true,
                        navText: "",
                    },
                    1600:{
                        items:13,
                        nav: true,
                        navText: "",
                    },
                }
            });
        }
    };
})(jQuery);

Here is the current version of that website I have done by this moment: Dev site

So the problem is when you move to the last item for example which is not visible when page loads first time and click on that item, carousel switches to it default position and clicked item become not visible, but I want carousel to stay after click in the same position before clicking.

All those color squares below are carousels too which are respresents product attributes such as door color, glass color etc, so those carousels should keep their current positions after their items being clicked.

Is there a possibility to do that by modificating my js code? All matching examples are really appreciated!

Also what I want to make work is when you click on middle+1 item carousel should moves forward for one item, when you click on middle+2 item carousel should moves forward for two items, the same for +3 and +4. And carousel should have possibility to move backwards after clicking middle-1 items, middle-2 item and etc.

Really hope to get real examples of how can I make all this work, cause my knowledge don't allow me to make is by myself.

Thanks in advance,
Ilya


texts: d7, large Taxonomy, entity reference, php error

texts:
when I like to add a content type "add/CCC" I get an PHP Error "Fatal error: Allowed memory size of 125MB". CCC includes an Entity Reference to Content Type AAA. AAA is large (10.000 Elements, including about 10 different taxonomies one of them with 2500 entries). When I change the reference in CCC to a test Contenttype BBB there is no error. Sometimes even to edit the structure of the content types of the entity reference leads to the PHP error.

Any ideas ?
Michael


texts:
i need to override a form.html.twig in my custom module.

i used hook_theme_suggestions_alter in my .theme file to add new suggestions.

function MY_THEME_theme_suggestions_alter(array &$suggestions, array $variables){

if (isset($variables['element']) && isset($variables['element']['#type']) && $variables['element']['#type'] == 'form') {
    $original_theme_hook = $variables['theme_hook_original'];
    $suggestions[] = $original_theme_hook . '__' . str_replace('-', '_', $variables['element']['#id']);
}

return $suggestions;
}

the debug show me this suggestions

THEME HOOK: 'form' -->
<!-- FILE NAME SUGGESTIONS: * form--pom-mapping-setting-form.html.twig x form.html.twig -->
<!-- BEGIN OUTPUT from 'core/modules/system/templates/form.html.twig' -->

if i put form--pom-mapping-setting-form.html.twig in my_theme/templates/ folder works.

if i put form--pom-mapping-setting-form.html.twig in my_module/templates folder doesn't works

I don't understand why :/

why drupal doesn't read templates in module folder?

thanks


texts: Drupal Commons: Active sub theme of Commons Origins is intermittently not working (base theme is showing)

texts:
I have a staging site and a production site.  The production site does not currently have a DNS record and I currently have a hosts entry for it  (134.x.x.x subdomain.example.com).

I have a subtheme of Commons Origins theme called exampletheme.   Exampletheme works fine on the staging server (which has a DNS record and no hosts file entry); but, when I migrated it over to the production server, I can only sporadically get the subtheme to show.  Sometimes it reappears if I activate random themes (including commons origins), when I re-activate exampletheme, it will show for a while.   But, eventually it goes away and I am back to looking at Commons Origins theme.

Two other factors, while the problem is existing, a drush status shows that the current theme is exampletheme.  Also I have an error_log in commons_origins_preprocess_html and exampletheme_preprocess_html.  It shows that commons_origins_preprocess_html does fire , while exampletheme_preprocess_html does not.

In addition, I have made a copy of exampletheme with a different name, activated it and it has the same problems.

I have checked the permissions on the theme files and they are the same as the commons_origins theme.

Any insight into this issue would be appreciated.


texts:
I'm a beginner with configuring varnish, so my apologies if this is a stupid question. I am trying to make things work on my ubuntu VM (12.04) with Varnish 3.

I am facing a problem, where after I log in, the admin menu (created by admin_menu) just disappears. Looking at the ajax request, it seems that varnish sends the request to drupal, receives a valid answer and then just refuses to serve it. It just outputs a 503 error instead.

I have captured the varnish logs, but I'm not sure what to make of them. Anyone has any ideas?

    11 ReqStart     c 192.168.1.20 50807 2144510792
   11 RxRequest    c GET
   11 RxURL        c /js/admin_menu/cache/a4270b058219f623d092552467a5cde0
   11 RxProtocol   c HTTP/1.1
   11 RxHeader     c Host: www.giftmonkey.ubuntu
   11 RxHeader     c User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Firefox/24.0
   11 RxHeader     c Accept: text/plain, */*; q=0.01
   11 RxHeader     c Accept-Language: en-US,en;q=0.5
   11 RxHeader     c Accept-Encoding: gzip, deflate
   11 RxHeader     c X-Requested-With: XMLHttpRequest
   11 RxHeader     c Referer: http://www.giftmonkey.ubuntu/
   11 RxHeader     c Cookie: __utma=94903434.1646672653.1383344251.1383344251.1383390432.2; __utmz=94903434.1383344251.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); has_js=1; pmcwidth=1920; __utmc=94903434; SESS9433506a0f068ea0ad220f58b963eef8=6FfRyBpNYYBlufL7y6AoBa5eqBP
   11 RxHeader     c Connection: keep-alive
   11 VCL_call     c recv pass
   11 VCL_call     c hash
   11 Hash         c /js/admin_menu/cache/a4270b058219f623d092552467a5cde0
   11 Hash         c www.giftmonkey.ubuntu
   11 VCL_return   c hash
   11 VCL_call     c pass pass
   11 Backend      c 17 default default
   11 TTL          c 2144510792 RFC 31536000 -1 -1 1383409657 0 1383409657 0 31536000
   11 VCL_call     c fetch
   11 TTL          c 2144510792 VCL 120 -1 -1 1383409657 -0
   11 VCL_return   c hit_for_pass
   11 ObjProtocol  c HTTP/1.1
   11 ObjResponse  c OK
   11 ObjHeader    c Date: Sat, 02 Nov 2013 16:27:37 GMT
   11 ObjHeader    c Server: Apache/2.2.22 (Ubuntu)
   11 ObjHeader    c X-Powered-By: PHP/5.3.10-1ubuntu3.8
   11 ObjHeader    c Expires: Sun, 02 Nov 2014 11:17:03 +0000
   11 ObjHeader    c Last-Modified: Sat, 02 Nov 2013 11:17:04 +0000
   11 ObjHeader    c Cache-Control: private, max-age=31536000
   11 ObjHeader    c ETag: "1383391024-1"
   11 ObjHeader    c X-Drupal-Cache: HIT
   11 ObjHeader    c Content-Language: ro
   11 ObjHeader    c Vary: Cookie,Accept-Encoding
   11 ObjHeader    c Content-Encoding: gzip
   11 ObjHeader    c Content-Length: 6705
   11 ObjHeader    c Content-Type: text/html; charset=utf-8
   11 FetchError   c Junk after gzip data
   11 Gzip         c u F - 6611 59085 80 80 52818
   11 VCL_call     c error deliver
   11 VCL_call     c deliver deliver
   11 TxProtocol   c HTTP/1.1
   11 TxStatus     c 503
   11 TxResponse   c Service Unavailable
   11 TxHeader     c Server: Varnish
   11 TxHeader     c Content-Type: text/html; charset=utf-8
   11 TxHeader     c Retry-After: 5
   11 TxHeader     c Content-Length: 436
   11 TxHeader     c Accept-Ranges: bytes
   11 TxHeader     c Date: Sat, 02 Nov 2013 16:27:37 GMT
   11 TxHeader     c X-Varnish: 2144510792
   11 TxHeader     c Age: 0
   11 TxHeader     c Via: 1.1 varnish
   11 TxHeader     c Connection: close
   11 TxHeader     c X-Cache: MISS
   11 Length       c 436
   11 ReqEnd       c 2144510792 1383409657.339800358 1383409657.400331020 0.511597395 0.060457230 0.000073433
   11 SessionClose c error
   11 StatSess     c 192.168.1.20 50807 2 1 5 0 5 4 1760 6926


texts: Make content type available for anonymous to edit and use front end theme

texts:
I have a content type that I have made available for anonymous users to edit. I want that content type when it is in edit mode to use the front end theme. How would I achieve this?
Thanks


texts: Split the node edit form into multiple pages (preferably using panels variants)

texts:
The task

My goal is to split the node edit page with the main field forms staying on the default one (the add page itself or mynodeurl/edit), and some additional field forms on the other pages (e.g. mynodeurl/option & mynodeurl/otheroption).

I think the best way to do this (and the way I want it to work) would be using a couple of variants for the node add/edit page (Panels Module), with the url path's being filtered through the string: url path selection rules.

The problem

I have no idea how to make the string url path selection rule work like that (I practically dont know anything how the string url path's selection rules work for the node (or node add\edit pages) at all, since I've only seen people implementing the url path based selection rules on custom pages and never on nodes).

How I've tried to solve it

I've done some playing around setting url path's like: /option option /option nodetype//option etc. to the node template and the node add\edit form variants, the only thing that worked is when i set my main node view variant to trigger when: Current path is not "/option" , and set the additional variant to trigger when Current path is "/option", the exactly same thing didnt work for the node add\edit page. (see http://shot.faintrush.me/xfvu1c0aic.png <- this screenshot).

The only working variant is using the Node template page, and adding forms there doesn't work which makes it useless for me. (If you know how to make forms work on the Node template page you'r also very welcome to answer here).

Of course the */option is probably not the best thing to put there, it's just the only one I found that's at least a bit alive.

Additional info

By default my url's work as I have explained here -> https://drupal.org/node/1993068 (i made those url aliases being created automatically but in a different way from using a pathauto + a custom token)
To make the links like siteurl.com/nodetype/25/edit work i use the sub-pathauto module (i have tried setting the sub-pathauto url depth to 2 and accessing siteurl.com/nodetype/25/edit/option with the settings on the screenshot above - didn't work).

More additional info

I also tried to make this work by creating a custom Page with the /node/%node/option path and assigning %node the Node edit form: node ID context, but then I'm running into another problem because the Node id doesn't actually match the url path and there's no way for me to assign the right context to the node edit form - the unique content type node id that i'm using in urls (again, read the issue from the link a bit higher) is not to get by any token or variable, the url alias is just being generated once by the rules module.

I posted the same issue (written in a little bit different words) to the drupal official  website issue queue to the panels module but there seems to be no activity there for a couple of days so I'll give it a try here.

Any help would be appreciated!


texts: How can I render an URL path from a custom route?

texts:
In my module.routing.yml (and using D8), I have a module_new route associated with the /module/name path.

I want to render this path in my module. How can I show http://example.org/module/name on a page?


texts: How to access a table I inserted manually into Drupal 7 db

texts:
I just inserted a new table into the Drupal db called mini_table with my own custom data using only phpmysql. How do I access this table's data for use in my *.tpl.php files?

EDIT: No cause for alarm. All my code is in template.php and not in any *.tpl.php file. Just wanted to clarify that.


texts: Why getMimeType() is returning wrong value for xlsx file

texts:
Below is my 2 line code to get the Mime Type of an attachment in a preprocess function

$file = $node->get('field_attachment_file')->entity;
$variables['attach_type'] = $file->getMimeType();

The $variables['attach_type'] is always getting the value of 'application/pdf' despite the attachment being an Microsoft Excel spreadsheet


texts: exporting/importing nodes without losing disqus comments / social media stats

texts:
I've been working on a website and the live version there is still content being created while i develop the local site.

Whats the best way for me to import the new nodes that have been created on the live site into the local site without losing the disqus comments or social media stats (fb likes etc.) it has?


texts: Commerce 2 - display price summary on product pages

texts: the price is broken down in cart and checkout pages, but there is no formatter to display it this way anywhere else ... most specifically it is needed for the product detail page so customer can see product and taxes itemized (and i suppose any discounts). this seems really basic so not sure why i am not finding this answer for myself but no luck yet so asking here. thanks all


texts: All the sudden my site show rare characters and links doesn't work.Help

texts:
All the sudden my site (drupal 7) shows rare characters like �0�1�0�

Also, the links doesn't work. All links in the site reload the home page.
I can't access example.com/user neither.

Please help. The site was working fine yesterday and did not make any change.

The encoding of the page is: UTF-8

Meta Content-Type is text/html; charset=utf-8

I can use Drush in the site. I already run drush cc all and drush cron and drush updatedb. But problem is not fixed.

Please help.


texts: Using db_query() or db_select() to connect to multiple databases

texts:
How can I execute a query that connects to different databases?

I have the following query, and I need to rewrite it for Drupal.

SELECT a.empid, b.empname FROM db1..empidmaster a, db2..emplist b
WHERE a.empid = b.empid

How can I rewrite the query using db_query(), or db_select()?


texts:
I have form with an alt attribute like the following.

<input type="text" alt="abc">

I want to replace that attribute with data-alt.

I tried the following code, but it doesn't seem to work.

function theme_form_alter(&$form, &$form_state, $form_id) {
    foreach($form["submitted"] as $newForm)
    {
        foreach($newForm as $keyid=>$frmArr)
        {
            if(isset($frmArr[]["#attributes"]["alt"]))
            {
                    $alt = $frmArr["#attributes"]["alt"];
                    unset($newForm[$keyid]["#attributes"]["alt"]);
                    $newForm[$keyid]["#attributes"]["data-alt"] = $alt;
            }
        }
    }
}

The following code is not working either.

foreach($form["submitted"] as $newForm)
    {

        foreach($newForm as $keyid=>$frmArr)
        {
            if($keyid=='#attributes'){
                $newForm[$keyid]['data-alt']=$newForm[$keyid]['alt'] ;
                 unset($newForm[$keyid]['alt'] );
                $form["submitted"]['#attributes']['alt'] = array("sss");
                form_set_value($form["submitted"]['#attributes']['alt'], array("aaa"), $form_state);
            }
        }

    }

What code should I use to achieve what I want?


texts: Tokens in blocks configuration for List only pages

texts:
I want to set a block to visible only for a certain path, with the logged in user id, like my-path/[user:uid].  I feel like I should be able to just do that.

How can I do this?


texts: Term lineage in simple Hierarchical select module

texts:
I'm working on a project using Drupal 7. I'm using simple Hierarchical select module.

How its possible to attach the parent lineage to the node? Is there any way to do so using simple Hierarchical select? because the SHS only attach the child term to the node
I tried to google it million times but couldn't find an answer

I tried the Hierarchical select module but its doesn't help because I'm using this field as exposed filter in a view and there are only two 'selection type' choices:

Autocomplete : Which is not what am not looking for
Drop down : Which combines the parent terms and children terms in one list and that is not what I want , I want the selection type to be Hierarchical select which is not provided

please help
thank you in advance


texts: How can I update the values of an exposed view filter when another filter changes value?

texts:
I know there are several examples of this around, on a view with two exposed select list filters, I need to update the value of the second based on the value selected on the first. I can't even seem to get any debugging info on my callback, but the request is throwing a Drupal\Core\Form\Exception\BrokenPostRequestException. Here's the simple form alter I'm trying.

use Drupal\Core\Form\FormStateInterface;

function MODULENAME_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if($form_id == "views_exposed_form"){
    $form['field_article_value1_value']['#options']  = _MODULENAME_get_update_value1_values();
    $form['field_article_value2_value']['#options']  = _MODULENAME_get_value2_values();

    $form['field_article_value1_value']['#ajax'] = [
     'callback' => ['_MODULENAME_get_value2_values_ajax_callback'],
     'event' => 'change',
     'wrapper' => 'edit-field-article-value-wrapper',
     'progress' => [
     'type' => 'throbber',
     'message' => NULL,
     ],
  ];
}

function _MODULENAME_get_value2_values_ajax_callback(array &$form, FormStateInterface $form_state) : array {
  $markup = '
Testing!
';
  return ['#markup' => $markup];
}


texts: Get field from another content type in Views

texts:
I have two content types, 'user' content type where I have some info about user and then 'post' content type.

Now I have a view that gets all 'posts' and shows them correctly but I would need to get image (field_user_image) from 'user' content type. How can I get in views from this another content type this image field?

EDIT: Can I do this somehow on code level in template.php?


texts: How do I set the HTML element of a text field?

texts:
My request couldn't be simpler - I have a custom text field on a node (field type text), and I want this field to be placed in a Panels layout in a <h3> element.

For Node title, I can choose the HTML element. For text fields, there seems to be no such option. The available formatters are Default, Trimmed and Plain text, none of which have any settings. Views fields have all sorts of easy field rewriting features, but I can't find anything equivalent in Panels.

How can I get the drop down of HTML elements like you get for Node Title for a custom field? Or change the output another way?

I'd prefer not to have to rewrite my entire Panels layout and create a whole new region for this one field in its .tpl file simply to put some text in a <h3>.


texts: Is there a way to pass additional variables into a twig field template, from another twig template?

texts:
I appreciate that this requirement might be fairly uncommon, and perhaps against the pure Drupal approach, but I'd like to pass additional variables to my field template, from another twig template.

In order to fulfil this requirement, I created a twig function to add additional properties to my field array (I didn't use the default twig merge() function as it destroys the objects in the field array). So, in my template is something like this:

{{ safe_merge(content.body, {'#my_property': 'my_value'}) }}

I then tried to use the template_preprocess_field() function, to check for and set these additional properties as a variable in the twig template - but I believe this hook runs prior to template being built, not as it is built, which is what I had assumed. So my custom properties are not present.

Is there any way to achieve what I'm looking to do?

Update: it seems I was wrong, the added properties are there, under $variables['element'] in my hook. Unfortunately, I need to pass variables to the title field template too - but label at least does appear to be processed prior to being displayed in the template.


texts: Views: Suggest nodes based on user behaviour and history

texts:
I tried to search here and there to see if there's an easy solution for what I'm trying to do but to no avail!

I want to show a list of nodes using views based on user's behavior specifically based on previously viewed nodes and Likes on Rate module, so it will be something like "suggestions based on user".


texts: When I add the shipping line item that was selected to the orders view in commerce it duplicates orders

texts:
This seems to be related to how many products were in the order, as adding this shipping line item from the order to the view it shows every product that that applies to.

Is there a way to change the settings in views to only show the one listing that shows the shipping option and hide all the duplicates?


texts: Redirect after submitting custom entity form

texts:
I'm working with a custom entity and would like to programmatically set the redirect based on submitted values.

When I set the redirect path however, the user is redirected to the canonical path instead of the path I'm setting in the redirect.

In the file mymodule/src/Form/MyEntityForm.php, I'm doing something like this:

  public function submitForm(array &$form, FormStateInterface $form_state)
  {
    // Note: Same results with the order of the next 2 lines reversed.
    parent::submitForm($form, $form_state);
    $form_state->setRedirect('mymodule.overview', ['state' => 'CA']);
  }

So how would I set the destination of an entity form submission dynamically?


texts: Don't keep original mp4 file after transcoding

texts:
I am on Drupal 6 using video module and ffmpeg to transcode videos. My source videos are in mp4. So I do not convert to mp4 but just copy the original file to the converted folder.

To save hdd space I want to remove the original file after transcoding. Is this possible? Any other suggestions?


texts: I am trying to create a node using the rest service. I am hitting /myendpoint/node using a post. My header is application/json. I am not sure what I need to post as the data.


texts: Form Builder module not working in Drupal 7

texts: Can someone confirm if Form Builder module is working on your end. I review the .module and seems like the paths are still using Drupal 6 format.


texts: How get a programmatically menu fields into template?

texts:
i add to my main menu an image field programmatically for build a megaMenu :

/**
 * Implements hook_entity_base_field_info().
 */
function hook_entity_base_field_info(EntityTypeInterface $entity_type) {

    $fields = [];

    if ($entity_type->id() == 'menu_link_content') {

        $year = date('Y');
        $month = date('m');

        $fields['image'] = BaseFieldDefinition::create('image')
            ->setLabel(t('Image'))
            ->setDescription(t('Image field'))
            ->setSettings([
                'file_directory' => 'imagesMenu'. '/' . $year . '/' . $month,
                'alt_field_required' => FALSE,
                'file_extensions' => 'png jpg jpeg',
            ])
            ->setDisplayOptions('view', array(
                'label' => 'hidden',
                'type' => 'default',
                'weight' => 0,
            ))
            ->setDisplayOptions('form', array(
                'label' => 'hidden',
                'type' => 'image_image',
                'weight' => 0,
            ))
            ->setDisplayConfigurable('form', TRUE)
            ->setDisplayConfigurable('view', TRUE);
    }

    return $fields;
}

After a drush update-entity, i can see the field on my form and i can add the image.

Now i try to get this field into twig.

When i use kint with keys this is the result :

  menu--main.html.twig

I cannot see my field image.

Any idea how can i get my field in tempalte ? hook_preprocess for the menu ?


texts: How to implement a mysql date or datetime field correctly in hook_schema()?

texts:
I have written a mymodule.install file which contains a schema definition to create a table in my database. This table contains two data fields. Theese fields will be populated by the users when they will fill in the specific content (example: to specific a publish date for a news). Now i didn't used the Date contributed module on purpose, cause i needed that theese two fields were on the same row in the database table for other reasons.

The hook_schema defines the two fields this way:

'pubblish_date' => array(
    'description' => t('The pubblish date for the single news'),
    'mysql_type' => 'datetime',
    'not null' => FALSE,
  ),
  'unpublish_date' => array(
    'description' => t('The unpublish date for the single news'),
    'mysql_type' => 'datetime',
    'not null' => FALSE,
  ),

The table is created correctly in the database, but i always get theese advice messages:

Field news_board.pubblish_date: no Schema type for mysql type datetime.
Field news_board.unpublish_date: no Schema type for mysql type datetime.
news_board.pubblish_date: no  type for Schema type :normal.
Field news_board.pubblish_date: no Schema type for type .
news_board.unpublish_date: no  type for Schema type :normal.
Field news_board.unpublish_date: no Schema type for type .

Seems strange to me cause I red on the documentation to use the mysql_type specification in order to store the datetime format in mysql database.

I know that Drupal supports natively timestamps and if you want to store a different date format you have to use specific definitions like mysql_type or pgsql_type according on the database yuo are using.

In discussions I found online lot of people used mysql_type definition and from what I seen they solved the problem, so why it doesn't work for me?

Thanks a lot.


texts: Why Can't Panels Select My Organic Groups?

texts:
I'm trying to create panels that are visible or show up on pages specific to certain groups. I'm using Organic Groups 7.x-2.7 on Drupal 7.34. So, our company's technicians would only see panels specific to them and the same for office staff. I'm having an issue integrating Panels with Organic Groups. When setting the "Selection Rules", "Visibility" or any other value for a panel to the group of the User who is viewing, the option to select the group is there and selectable BUT it only shows up as an empty string and the panel doesn't abide by this rule. I'm pulling my hair out and eating it in a mad attempt at proving to the gods of drupal code that I am worthy of a solution.

Update (3/20/15)

I changed my Organic Groups installation to version 1.5. This seems to work. I'll try each version incrementally until I reach the first one that breaks and just place it here. I still have no idea why this is occurring, though.


texts: Can I still start a "stable" D8 project now that D9 is stable?

texts:
Trying to start a new Drupal 8 project today:

$ composer create-project --no-install drupal/recommended-project my-recommended-project

But this now installs Drupal 9.0.0 instead! :mindblown:

So I tried to manually require 8.9:

$ composer create-project --no-install drupal/recommended-project^8.9 my-recommended-project

But:

Could not find package drupal/recommended-project^8.9 with stability stable.

So it seems like I will need to install ^8.9@dev

But then the whole project will be ... unstable?

What do you recommend?


texts: Drupal 7 - Make a CCK Date field a required field

texts:
How do I make a CCK Date field a required field in hook_form_alter?

I have tried doing

function mycustommodule_form_user_register_form_alter(&$form, &$form_state, $form_id){
    $form['field_birth_date']['und']['#required'] = TRUE;
    $form['field_birth_date']['und'][0]['#required'] = TRUE;
}

but it doesn't work.

I was able to make it work on a CCK Text field:

$form['field_nickname']['und'][0]['value']['#required'] = TRUE;


texts:
I am trying to render some fields of a view...

this code works nearly perfect:

$view = views_get_view('<name>');
$view->execute('<name 2>');
$view->render_field('title', 0); //works!
$view->render_field('view_node', 0); //does not work, should be a link

"view_node" should be handled by "views_handler_field_node_link" but does not output anything...

Can anybody help??

Thanks in Ahead!


texts: How can I get a custom module's file path in a preprocess function?

texts:
I've got default images located in a custom module directory and I'd like to load them using hook_preprocess_node(). I then will pass the images to the template file.
In the screenshot, I'm loading an image into $default_image, which renders correctly when passed to the template file.
Instead of loading the image from an entity field, I want to read the image directly from the directory in the custom module. Clearly, the path I manually built into $premier_tech_image is incorrect.

The problem is NOT how to access the file. For example, we use code like this for JSON feeds.
$module_handler = $this->moduleHandler;
$module_path = $module_handler->getModule('my_custom_module')->getPath();
$resource = $module_path . '/resources/countries.json';

How do I correctly pass the reference to an image located in the directory of a custom module to the template file?


texts: Knocked out my own admin recongizion on my own site

texts: I have Drupal 6  site. In deleting spammers I accidently knocked myself out. Can I reclaim admin on my own site? Help.


texts: AddThis Icons Being Blocked on SSL/HTTPS Site

texts:
I've installed and configured the AddThis module to show sharing buttons to my users. It works great on my local machine. When I put the site on my SSL/HTTPS enabled site however the buttons do not show up (although I see the  they are in in the page inspector) and Chrome gives me JavaScript errors that the script being used to get those icons is calling from http://s7.addthis.com/js/300/addthis_widget.js...a not-secure link and is being blocked).

Does anyone know how to change the link the addthis module is calling to make it SSL/HTTPS compatible?


texts: Render with custom style all contents of a content-type from custom module

texts:
I am trying to create a custom module to manage a slider.

After install my current-development module, I have:

a slider content-type
a slider view defined to show Content (Full Content) of the content-type slider with Unformatted list format
a node--slider template that renders the slider node as a li element

EDIT: Code updated
You can check the module code here: https://github.com/jmvelasco/drupal

I wonder how could I add a wrapper that contains all nodes of this content-type and call to render each node using the template defined.

The idea I have in mind is define a block like:

        render_node_slider($slider_content)

So the end rendering will be somethink like:

 slider content 1

 slider content 2

         ...

 slider content N

But I don't know how to manage this even if I am pretty sure this is completely possible to achieve.

The accepted answer points to the right direction, from the current state of development, now I'd like to know if I can improve the slider_block_view

https://github.com/jmvelasco/drupal/blob/master/slider.module (line 101-124)

using a templete file defined in the module instead code the html inside a function module. I want also to attach a css and js files when rendering this view.

I'll appreciate any kind of help here.

Thanks for the reading.


texts: Facets and Apache Solr in Drupal 7 - Clicking Facets results in no results being show

texts:
I'm having a bit of an issue with Facets and Apache Solr, I'm not sure whether the fault lies with Solr or the Facets API.

I am using Solr as my search engine and I get results being shown when searches are performed, also shown are the amount of matches in specified fields/facets.

E.g. I search for 'content' - there are numerous values for 'content' within different categories such as 'category1', 'category2'

The search result shows as:

category1(5)
category2(7)

Implying there are 5 results in the facet category1, and 7 results in the facet category2, these are also links, however upon clicking these links the search shows as "no results found". Odd behaviour, has anyone experienced anything like this before? if so any pointers on where to look in order to resolve the issue?

I'm hoping this question is quite clear, if not just ask and I'll try provide some more details.

Thanks, Dan.


texts: How to Create twig template files in drupal 8 for customizing user login,profile edit and forget password forms?

texts:
Earlier we use the below code for creating custom template of user login ,user profile edit and forget password forms:

 function Yourtheme_theme($existing, $type, $theme, $path){
 return array(
 'user_register' => array(
 'render element' => 'form',
 'template' => 'templates/user-register',
),

'user_pass' => array(
  'render element' => 'form',
  'template' => 'templates/user-pass',
),

'user_profile_form' => array(
  // Forms always take the form argument.
  'arguments' => array('form' => NULL),
  'render element' => 'form',
  'template' => 'templates/user-profile-edit',
),
);
}

function Yourtheme_preprocess_user_register(&$variables) {

$variables['rendered'] = drupal_render_children($variables['form']);
}

function Yourtheme_preprocess_user_login(&$variables) {

$variables['rendered'] = drupal_render_children($variables['form']);
}

How to Create same twig template files in drupal 8 for customizing user login,user profile edit and forget password forms?


texts: How do you wrap a link around the block header text with Drupal?

texts:
(sorry if i'm redundant) What's the easiest way to wrap a link to the header of any block title text?

I know a workaround would be to just not include a title and add it in the content; but that's not the most convenient at times.


texts:
All the other form elements render properly. Radios and Checkboxes do not. The title and descriptions show up, but not the boxes or radios.

$options7 = array();
foreach ($resqry1 as $option)
{
  $options7[$option->id] = $option->id;
}

$form = array();
$form['lis'] = array(
  '#type' => 'checkboxes',
  '#options' => $options7,
);

return $form;

Please help me out. Thanks


texts: How do I display a link icon in custom modules?

texts:
I would like to display an icon of correct answer but in my condition full URL is displaying (it's not displaying icon ) how I'll manage.
This icon will be on a table so the user can click that icon and check the answer. please guide me where I'm doing wrong. here I have put some linking portion of my code. I'm writing custom modules in drupal 8.
Thanks

$imgsrc = $base_url.'/scp/sites/default/files/images/corr_icon.gif';
$correct_link = Url::fromUserInput('/answer/'.base64_encode($data->ans_refno).'by'.base64_encode($data->q_id));
'isanswer' => \Drupal::l($imgsrc, $correct_link),


texts: Pass parameter from a custom php function to hook_block

texts:
I have a hook_menu page callback. I want to use the argument which it receives in hook_block.

For example

function myCustomFunction($args) {

}

modulename_block() {
  // Use $args here
}

How can this be done. Is there a way I can pass this as a parameter.


texts: Can I use ajax to target multiple form elements from one input?

texts:
I'm trying to use ajax to update two different parts of a drupal form from just one form input blur.

I have the standard ajax stuff on my input:

$my_form['my_input']['#ajax'] = array(
  'callback' => 'my_callback',
  'wrapper' => 'my_target_div',
  'event' => 'blur',
);

This is working well, swapping out my div when the input is updated ... however I also want to update another form input elsewhere in the form with different code as a result of the blur on my original input.

Is this possible, any ideas?

Edit: For clarity, here's my real world example:

Content type 'movie'
Added field 'primary_title'
When 'primary_title' is updated my ajax callback checks for similar strings and returns html.
The html from the callback is inserted into an empty div.

That part is working great!

I'm trying to also modify the standard node 'title' input, giving it the value of 'primary_title' after I have done some regex to tidy up the string (removing "The" or "A" from the start etc) The result will be two title fields, one with the complete title 'primary_title' and one trimmed 'title' that will be useful for sorting and displaying records.


texts: how do I control order of promoted pages?

texts: I have a bunch of pages I have promoted to the front page and I'm wondering how I can control the order the items appear in? This is in Drupal 7.


texts:
I have a file field called "contracts" between my user fields.
What I want is that in the user-profile form this field would come up as a file-download widget.

Does anyone have an idea how to show a file-download widget (even a link to a file would work) in the user-profile form?


texts: check mark disappear after moving to new ip address

texts:
I moved my web server to another ip address. But "Advanced CSS/JS Aggregation" still refer the images from the old ip address. All the checkmark in my dashboard are disappeared, no matter for radio or checkbox.

Here is an example:

Update:
I checked the console and found an error message: "Failed to load resource: net::ERR_CONNECTION_TIMED_OUT".
Here is a screenshot for error from console:

What do I need to do??? How can I update the css and js file? Does anyone have any idea?Thank you for all helping.


texts: Class not found error on creating a custom service inside a module

texts:
I want to create a class with list of helper functions, so I created a module and placed the helper functions inside it. I created a service.yml inside that module folder.

services:
  helpers.helpers:
    class: Helpers

Helper class file:

class Helpers {
   public function buildPage($page_template, $template_variables) {
      echo "Dheivamey oru vazhiya"
   }
}

I make it as a dependency inside another module.

dependencies:
  - helpers:helpers

I tried using it inside a controller file like this

public function buildSomePage(Request $request) {
  $helper = \Drupal::service('helpers.helpers');
}

But I am getting a Helpers class not found error. Someone help me before my head explode.


texts:
i want to create a drupal 7 site that invoke an APi asp.net , when user login by email or user name if he already exist and password ('module login tobaggon') it invoke the  api asp.net to check if that user exist on the database sql server and return result to the drupal site if the user is already exist in sql server drupal show the offers of the site or if the user does't exit we invite him to sing in with his email
how to create an client php that invoke and consume this api asp.net ('module')?
how to create that api asp.net ?
thank u


texts: How to make loadByProperties or entityQuery case sensitive for field value

texts:
Neither loadByProperties or entityQuery are case sensitive. How to make it case sensitive? I'm using MySQL as a database but would rather have a portable solution if possible.
With LoadByProperty
$nodes = $this->entityTypeManager()
              ->getStorage('node')
              ->loadByProperties(['field_myfield' => $value]);

With entityQuery
    $entity_ids = \Drupal::entityQuery('node')
        ->condition('field_myfield',$value)
        ->execute();

You can, of course, build your own query as explained in this answer. But my question is specifically about using loadByProperties or entityQuery API.


texts:
In Drupal 6 there is a parameter $destination for the function 'image_scale_and_crop()' . The parameter is not available in D7. I have the following code block.

image_scale_and_crop($image, 100, 70);

This code is executed an the thumbnail is created in a path if I examine the file directory.

My question is, how I can determine the path where the cropped file is created in order to save it to db.


texts: Asserting a failed login attempt on Simpletest

texts:
I want to test a module that adds an additional login validation clause. Only users whitelisted somewhere else are allowed to log in to the system.

In order to test this behaviour with Simpletest, I would like to assert that a random user has no access to the system.

I have tried to create this random user and then to call drupalLogin(). Unfortunately, my test fails because drupalLogin() is checking whether the log in succeeded, by calling assertLink() internally.

This is what I have tried:

    $user = $this->drupalCreateUser(array());
    $user->roles[] = 'authenticated user';
    user_save($user);

    // Try to login with it
    // It fails, because of the additional validation performed by my custom module
    $this->drupalLogin($user);

    // I would like to assert it here instead:
    $this->assertFalse(isset($this->loggedInUser->uid));

What should I do in order to avoid the assertion to fail at drupalLogin(), so that I can assert it myself?

Any help will be appreciated.


texts: Using hook_form_alter to change from text filter to checkboxes

texts:
I'm using a custom module and hook_form_alter to change a Views Exposed Filter from a text field to checkboxes. When altering to a select list, the module works fine. However, when I change the form type to "checkbox", the filter renders as a single checked checkbox without a label. I thought I had solved it earlier by simply removing the #size line, but after reverting the code and trying to fix it that way again, it's no longer fixing it. Any idea what I need to change?

Working select list code:

function dropdown_bartab_form_views_exposed_form_alter(&$form, &$form_state) {
  $field_id = 'field_venue_bar_tab';

  // Only alter forms with the necessary field
  if (isset($form[$field_id .'_value'])) {

// Build a query to get all node ids having the specified field
$query = new EntityFieldQuery();
$results = $query->entityCondition('entity_type', 'node')
                  ->fieldCondition($field_id, 'value', 'NULL', '!=')
                  ->fieldOrderBy($field_id, 'value', 'ASC')
                  ->execute();

// Attach the field values to the nodes
$nodes = $results['node'];
field_attach_load('node', $nodes, FIELD_LOAD_CURRENT, array('field_id' => $field_id));

// Add a default so the filter is optional
$options = array(
    '' => 'Any',
    '0' => 'Drinks',
    '1' => 'Food',
    );

// Alter the field
$form[$field_id .'_value']['#type'] = 'select';
$form[$field_id .'_value']['#options'] = $options;
$form[$field_id .'_value']['#size'] = 1;
  }
}


texts: How to determine the source (views/modules/blocks, etc) of content in different URLs?

texts:
I am working on re-designing an existing site for which I need to edit the output of each page (i.e. each URL). Is there a good way to determine where the data is coming from? By "where" I mean, is it a 'View'? or from a module? or combination of blocks?

I have tried devel & theme developer but that only tells me which tpl.php file but not the actual source.


texts:
I know that similar questions have been asked before but none of the suggestions there have helped me at all.  I've been trying all day to get this node to save file data and nothing has worked.  I'm not sure whether I am missing something, but if anyone could help I appreciate it a whole lot.

This is the code, which seems accurate but when the node save happens the file field is emptied.  So I don't understand what is happening.  I have tried different approaches to this and haven't figured it out yet.

$file_object = file_save_upload('node_file', NULL, $dest, FILE_EXISTS_RENAME);
    if ($file_object !== 0) {
     $node->field_file_upload[$node->language][0]['value']=(array)$file_object;

        node_save($node);
    }


texts: Move menu code to the template.php with the associate hook

texts:
I have created a region (called menuCustom) .info file in my template, I created a custom menu and I'm showing in the previously created region.

I created a file called block--menuCustom.tpl.php to show it as a block.

My question:
How I can move code from the .tpl file to the file template.php?

I have managed to show the links with the structure needed with the following code:

<?php
    $contenidoDesple = $elements['#content'];

    $templateMenu = '
';

    foreach ($contenidoDesple as $key => $item) {

        if ($key != '#sorted' && $key != '#theme_wrappers') {

            $enlace = $contenidoDesple[$key]['#href'];
            $nombreEnlace = $contenidoDesple[$key]['#title'];

            $templateMenu .= '
';
            $templateMenu .= '' . $nombreEnlace . '';

            if (count($contenidoDesple[$key]['#below']) != 0) {

                $templateMenu .= '
';

                foreach ($contenidoDesple[$key]['#below'] as $newKey => $newItem) {

                    if ($newKey != '#sorted' && $newKey != '#theme_wrappers') {
                        $enlace2 = $contenidoDesple[$key]['#below'][$newKey]['#href'];
                        $nombreEnlace2 = $contenidoDesple[$key]['#below'][$newKey]['#title'];

                        $templateMenu .= '
';
                        $templateMenu .= '' . $nombreEnlace2 . '
';
                }
            }

            $templateMenu .= "
";

        }

        $templateMenu .= "
";

    }

}
$templateMenu .= "
";

print $templateMenu;

?>


texts: How to organize better the taxonomy-selection drop-down box in Views?

texts:
I made a View to list a series of items. Each item has been assigned a Taxonomy term.

My taxonomy terms go like this:

--- Main1
----- Sub1
----- Sub2
--- Main2
----- Sub3
----- Sub4
----- Sub5

So there's a main category and inside other terms.

In my view, you can filter the entries to only display items for a certain category. But the dropdown menu is a mess. It goes like Sub3, Main2, Sub1, Sub5...

So, is there a way to organize it in a way it appears as I listed it above? And also, is it possible to give some kind of indentation for the  subterms in the dropdown? (So people can easily tell what is a main term and what's a sub-term).


texts: Translate Node Metatags using modules: il8n + metatags

texts:
How does one configure translation of Node metatags (Title, Description) which allows the content author to translate metatags from the node edit page?  Similar to how they translate individual fields from node edit page.

Using the il8n module, and URL method of translation:

  -Base Language: root/webpage
  -Spanish: root/es/webpage

Thank You!


texts: How to show status messages in modal window?

texts:
Here, I tried many different ways to show status messages in pop window but was not able to get success in any way. So, basically i want to  show all the status message of site in modal box whether it is configuration message or submit on site of form. Please give suggestion for this if any.
Thank you


texts: Views keeps crashing when I change setting

texts: I have created a Latest News view which I'm displaying in my sidebar as a block. When I then go back to change anything such as the Title of the View or the number of items that can be displayed, it crashes. can anyone help? I have attached a screen print which shows the error.


texts: In Drupal 7, how do I create a custom rules event for any and all file entities?

texts:
I'm having trouble creating a small module to add an Event scenario to Rules using the Rules API.  Basically, I'm creating a rule that should detect to see if certain fields of a file entity have certain values upon saving that file.  Then, if the conditions are met, the action is to change the URL path alias of /video/ to point to the newest video file in my system (file/[fid])

But I'm getting stuck even creating the new Event to even work.  My code below does succeed in making it appear in the Rules event list, and then when setting conditions, the Data Selector exposes the correct file fields.  But, when I set a very simple condition or even no condition, my action does not fire.

(A bigger aside: shouldn't the Rules module come pre-packaged with functionality for dealing with file entities?  There are plenty of events for nodes, users, and comments, but nothing for files.)

So, what is wrong with my code below?

/**
 * Implementation of hook_rules_event_info().
 */
function rules_extended_rules_event_info() {
  return array(
    'rules_extended_rules_event_file_insert' => array(
      'group' => t('Entity'),
      'label' => t('After saving a new entity'),
      'module' => 'rules_extended',
      'variables' => array (
        'file' => array ('type' => 'entity', 'label' => t('created entity')),
      ),
    ),
    'rules_extended_rules_event_file_update' => array(
      'group' => t('Entity'),
      'label' => t('After updating an existing entity'),
      'module' => 'rules_extended',
      'variables' => array (
        'file' => array ('type' => 'entity', 'label' => t('updated entity')),
      ),
    ),
  );
}


texts: An illegal choice has been detected. Please contact the site administrator is given on ajax form after programmaticly adding an item to a select list

texts:
I have a form in Drupal. On a select list I am using the ajax built into the form api to trigger a callback on change.

I need to be able to add an option to the select list via javascript. Set the value on the select list to be that new value and then trigger the ajax call.

I have something like:

var select_list = $('#edit-example');

select_list.append($("<option></option>")
  .attr("value", data.ObjectID)
  .text(data.Name));
select_list.val(data.ObjectID);
select_list.change();

Where data is a JSON object.

So the option is being added to the select list. The value has changed to my new option. I trigger the ajax event. However I am getting the error message:

  An illegal choice has been detected. Please contact the site administrator.

The callback is working fine except the error is displayed. What can I do to stop this message appearing?


texts: Multiple database group users for one database

texts:
For a blog post, I have db design of 1 database in D7, the database contains multiple database users:

Anonymous - Only Read privilege on Database
Writer - CRUD privilege on Database
Admin - Has all privilege to Database

How do I achieve this in Drupal 7 ? The settings.php in Drupal has only one database connection section, as I'd need to connect the database from all 3 database users, and change the database user when they log in, like when Admin logs in, he'll also be admin database user, and so on...