texts: How to set one region over the other (and not beside it) in Omega theme?

texts:
I´m using Omega theme in a Drupal 7 installation, and don´t know how to put the sidebar second right below the sidebar first.

Under Zone and region configuration I have the content section, with the content zone inside it.
Content zone has 12 columns.
Inside it I have 2 regions:
content (6 cols).
sidebar second (3 cols).

If I add there another region, (sidebar first in my case) Omega puts it along the other two, and I can only set the weight of each one to determine wich one will appear first.
But what if I want one region under the other?

I´m using delta module to create different layouts according to some variables, but every time I try to set one region over the other it fails. Is there any way to do that?

Thanks!

UPDATE: How may I use context to do that in case it is possible?


texts: How can I check a Rules condition to see if the Statuses sender and recipient are the same?

texts:
I am using "Execute custom PHP" as a condition in a Rule which is being triggered when a new Status is saved. Here is the PHP I am using, it keeps causing "Trying to get property of non-object" errors whenever I create a new status:

if($sender->uid == $recipient-id){
return TRUE;
} else {
return FALSE;
}

Basically what I am trying to do is detect cases when the sender is sending a status message to himself so I can use an appropriate Rules action, and also the opposite:

if($sender->uid != $recipient-id){
return TRUE;
} else {
return FALSE;
}

I have tried a number of different variable combinations but I can't work out what I am doing wrong. Any suggestions?


texts:
At present stage Drupal 7 looks very mature, BUT is see some modules are not yet moved to Drupal 7 or not production Ready. For now I had troubles finding UC_Product_Import and UC_AJAX_CART.
I was pretty confident that 7 was the right choice, but I am getting afraid I will need more modules that yet did not do the move to Drupal 7.
What do you think?


texts:
Rules (not) triggered with Bulk Media Upload

I have a node type called 'uploads' that includes a user reference field to make each upload particular/available to a certain user.

I have added a rule so when a new upload is added, they are e-mailed to let them know there's something new for them to see once they're logged in.

This works fine when adding uploads (nodes) one at a time, but I'm also using "Bulk Media Upload" (https://www.drupal.org/project/bulk_media_upload) to allow for multiple uploads/node creation, at which point the rules fail with the following error:

"Unable to get the data value for the variable or parameter id. Error: Unable to get the data property uid as the parent data structure is not set."

I realize that Bulk Media Upload is on/past the outs; but I do need the functionality it provides and am unsure as to why the data isn't available doing things this way when they are doing things one at a time.  The references are made the same way in either case since Bulk Media Upload uses/requires the same values.

Edit - Ok, here's the rule being used:

            { "rules_results_uploaded" : {
                "LABEL" : "Results Uploaded",
                "PLUGIN" : "reaction rule",
                "OWNER" : "rules",
                "REQUIRES" : [ "rules", "php" ],
                "ON" : { "node_insert--uploads" : { "bundle" : "uploads" } },
                "DO" : [
                  { "entity_fetch" : {
                      "USING" : { "type" : "user", "id" : [ "node:field-for-user:uid" ] },
                      "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
                    }
                  },
                  { "drupal_message" : { "message" : "Receipt of the sample on \u003C?php echo $data[\u0027components\u0027][\u0027sample_received\u0027][\u0027value\u0027][0]; ?\u003E has been acknowledged.  \r\n\r\nAn e-mail will be sent to [entity-fetched:field-practitioner-name] at [entity-fetched:mail]" } },
                  { "mail" : {
                      "to" : "[entity-fetched:mail]",
                      "subject" : "Your Sample Results Have Been Uploaded",
                      "message" : "Dear [entity-fetched:field-practitioner-name],\r\n\r\nNew sample results are now available on your account.",
                      "from" : "results@afakewebsite.com",
                      "language" : [ "" ]
                    }
                  }
                ]
              }
            }

Again, the rule works fine when fine when adding a new node of the type 'uploads' one at a time, it just doesn't work using bulk media upload (though triggering multiple times.)  Perhaps I'm misunderstanding how BMU works.

Any thoughts or alternatives still much appreciated.


texts: How to allow user to manually change language when using "Browser" Detection as a detection option?

texts:
We have a site with multiple languages and have been using the Language Switch Dropdown menu to allow users to change languages on the site. But when we add "Browser | Language from the browser's language settings." as an additional detection option along with "Selected Language" then the selected language no longer works as it is always overridden by the browser's language, even if "Selected Language" is placed before it.
The ideal workflow would be:

Language is detected from the browser and translated
The Language Dropdown shows the current language (currently it always displays the default language, even if the browser detects and switches to a different language)
The user can then override the browser language by selecting a different language from the drop-down switcher. (Currently the dropdown has no effect if a language is detected via the browser)

SOLUTION EDIT:
The proposed solution did not work for us so we ended up writing a custom form alter function and using a one-time cookie to achieve the functionality we were looking for.
In the language detection, we have "selected language" enable as the first item then "URL" and the second item and no other detections are used.
Then we used the below hook to the detect and set the language from the browser one-time using a cookie. The hook also sets the default value of the language dropdown so it shows what the language is, even if set from the browser.
<?php

function MY_MODULE_form_lang_dropdown_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){

    // Only run if our custom language cookie is not set yet
    if (!isset($_COOKIE['Drupal_visitor_user_lang'])){

      // Get language set in browser
      $language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
      user_cookie_save(['user_lang' => $language]);

      // Set the language dropdown's default value
      $form['lang_dropdown_select']['#default_value'] = $language;

      $current_path = \Drupal::service('path.current')->getPath();
      $path = \Drupal::service('path.alias_manager')->getAliasByPath($current_path);
      $config = \Drupal::config('system.site');
      $front_uri = $config->get('page.front');
      $front_alias = \Drupal::service('path.alias_manager')->getAliasByPath($front_uri);

      if ($path == $front_alias){
        $path = '';
      }
      $default_language = \Drupal::languageManager()->getDefaultLanguage()->getId();
      if ($language == $default_language){
        $language = '';
      }
      $response = new RedirectResponse('/' . $language . $path);
      $response->send();

    }
    $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
    $form['lang_dropdown_select']['#default_value'] = $language;
}


texts: How to load sliders on subsequent pages in GD Infinite Scroll?

texts:
Here is my Testcase.
If you scroll down, the feed will automatically extend: It is an infinite scroll-feed.
However, the slider images of subsequent pages are not being loaded.
As soon as the page is being refreshed, all visible sliders are loaded.

In the scenario I use the following two Drupal modules:

GD Infinite Scroll
Zurb Orbit

How can I get sliders of subsequent pages to work properly?
(Additionally: If the last page is being scrolled down, the infinite scroll would literally keep scrolling this very page infinitely. Is there a way to prevent it and just stop upon hitting the last post of the last page?)


texts: Is there an AJAX command I can use to debug PHP variables without breaking AJAX call?

texts:
I know the list of Ajax framework commands. Every one of them is doing something useful. But sometimes I want, for debug, include a piece of debug data in my AJAX response. I want it to be unobtrusive, so var_dump is out. I need to wrap my debug data in some kind of command. On the other hand, I will view it using JS console, so I don't want it to actually change anything on my page. And changing something hidden with CSS is not feasible - I'm not in charge of CSS here. So it leaves me with commands approach.

Which command could I use for this purpose?

I was thinking about ajax_command_append with selector that will never be found, but I don't want to introduce any additional errors in my JavaScript Console.

Debugging it with xdebug is not, currently, possible, and I would rather avoid spending time and resources on creating VM, when what I need is something I can do with simple var_dump on non-AJAX pages.


texts: How to prevent node creation using hook_node_submit?

texts:
Could you clarify me, how can I prevent node creation if I use hook_node_submit ?

What should I do in code of the hook for it ?
Do returning false ? Or throw an exception ?

That is, if some condition is true then the node simply does not create, without output of any error message.


texts: How to login-redirect users to their profile page on specific days only?

texts:
By using Rules Once per Day module, logged in user would be redirected to profile page on specific day. My issue is, every time when user logged in to the site, the user is redirected to profile page.

But I want this rule to work on specific days, like Monday and Thursday. How I can handle this without Rules Once per Day module?

I want to this functionality works at only once. How can I do this?
Any suggestions?


texts: Prepopulate node-add form with search terms?

texts:
I would like users to be able to create band profiles (which will be a content type), and then those profiles will be associated with their user accounts via Entity Reference. However, I only want one profile per band, so I don't want each member of the band to be able to create a page for the band (but I'd like to have all members of the band be able to be related to the band page via Entity Reference).

So, before a user is able to create a band profile, I want them to search current bands on the site (either via Views or Search API, not sure which yet...probably whichever method allows me to solve the issue below). If the band does exist, then the user will select it and a reference will be created. However, if a profile for the band does not yet exist, I want the user to be presented with a link to the node add page to create a band.

This is where my question comes in. When a user creates a new band, how can I populate the node-add form with the terms that they searched for to begin with? So if a user searches for a band from "San Diego, CA" called "The Band", how can I populate the creation form with "San Diego, CA" and "The Band" without him having to enter the information again on his own?


texts: How can I use Drush in a project installed with Composer?

texts:
I have installed Drupal 8.5 using composer create-project drupal-composer/drupal-project:8.x-dev my_site_name_dir --stability dev --no-interaction.
This command installs many files. I found drush-files in the root and the file vendor/drush.
It looks like Drush is available, but I have no idea how I can run drush. Trying command like "drush cr" was not successful. I get the following error.

-bash: drush: command not found.

I don't want to be able to use Drush from everywhere.
How can I use Drush only from my_site_name_dir?


texts: Unknown map column when migrating users from CSV file

texts:
I'm trying to import the users from CSV file, but the import fails with the following error:

  Migration failed with source plugin exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'map.sourceid4' in 'where clause', in includes/database/database.inc:2171

Migrate class is:

<?php

/**
 * @file
 * Class for migrating users from a CSV file.
 */

/**
 * Class FooMigrateUsers.
 */
class FooMigrateUsers extends Migration {

  /**
   * Constructor.
   *
   * @inheritdoc
   */
  public function __construct($arguments) {
    parent::__construct($arguments);
    $this->description = t('Foo users from CSV file');

    // Create the migrate source.
    $import_path = drupal_get_path('module', 'foo_migrate') . '/import/users.csv';
    $options = array(
      'header_rows' => 1,
    );

    $this->source = new MigrateSourceCSV($import_path, array(), $options);
    $this->destination = new MigrateDestinationUser();

    $this->map = new MigrateSQLMap($this->machineName,
        array(
          'Title' => array(
            'type' => 'varchar',
            'length' => 15,
            'not null' => TRUE,
            'description' => 'Title',
          ),
          'Firstname' => array(
            'type' => 'varchar',
            'length' => 35,
            'not null' => TRUE,
            'description' => 'First name',
          ),
          'Lastname' => array(
            'type' => 'varchar',
            'length' => 35,
            'not null' => TRUE,
            'description' => 'Last name',
          ),
          'Primary email address' => array(
            'type' => 'varchar',
            'length' => 80,
            'not null' => TRUE,
            'description' => 'Primary email address',
          ),
        ),
        MigrateDestinationUser::getKeySchema()
        );

    // Mapped fields

    // We must have a unique username in the Drupal 'users' table.
    // dedupe() takes the Drupal table and column for determining uniqueness.
    $this->addFieldMapping('name', 'Primary email address')
         ->dedupe('users', 'name');
    $this->addFieldMapping('mail', 'Primary email address')
         ->dedupe('users', 'mail');

    //$this->addFieldMapping('pass', 'password');

    // Apply default role.
    $this->addFieldMapping('roles')
         ->defaultValue(DRUPAL_AUTHENTICATED_RID);

    $this->addFieldMapping('field_user_first_name',      'Firstname');
    $this->addFieldMapping('field_user_last_name',       'Lastname');

    $this->addUnmigratedSources(array('Title'));

    $this->addUnmigratedDestinations(array(
      'access',
      'created',
      'data',
      'is_new',
      'language',
      'login',
      'pass',
      'picture',
      'role_names',
      'signature',
      'signature_format',
      'theme',
      'timezone',
    ));

  }

  /**
   * Modifies the row to be imported.
   *
   * @inheritdoc
   */
  public function prepareRow($row) {
    return parent::prepareRow($row);
  }

}

The CSV data is like:

"Title","Firstname","Lastname","Primary email address"
"Mr","Foo","Bar","foo@example.com"
"Mrs","Bar","Foo","bar@example.com"


texts: I've previously used Drush to update my Drupal-installations. They are installed without using Composer, and currently on version 8.7.3. However, when I try to use Drush (drush v8.1.15, using drush up) to install the currently newest version the update fails when untarring the new core. When googling I see conflicting answers about what to do - among suggestions are Drush9, updating using composer (which I tested - does not work since the page is not installed using Composer) and others. What would be the simplest, least likely way to destroy the page while being able to update (with regards to security updates)?


texts: How to track Drupal user login-logout session length and registration activities?

texts:
Is there any hook_function/code in Drupal where I can track user activity, like:

User core logged in time / or third party login
User log out time
Login-Logout session length (active time)
registration submit core or / third party submit.

Please share event for these activity.


texts: Why do I get "Page not found" with my code?

texts:
I just created a new module but I can't manage to access it.

Here is the home.info.yml

name: Home
description: Ownzones Homepage
type: module
core: 8.x

Here is home.routing.yml

home.oztest:
  path: '/oztest'
  defaults:
    _content: '\Drupal\home\Controller\HomeController::oztest'
    _title: 'Ownzones'
  requirements:
    _permission: 'access content'

And here is the HomeController:

namespace Drupal\home\Controller;

use Drupal\Core\Controller\ControllerBase;

class HomeController extends ControllerBase {
  public function oztest() {
    $element = array(
      '#markup' => 'Hello, world',
    );

    return $element;
  }
}

I don't see what I'm doing wrong, and when I try to access /oztest I get a message saying The requested page could not be found.


texts:
I have a node type called 'basic' with 10 nodes and a bunch of fields. However, I want to add a field that is specific to only one node. What is the best way to do that?

At the moment I've got a custom field and I'm hiding it using hook_form_alter() ['#access'] = FALSE (and hiding visibility via the UI), so it's not editable or visible for the other 9 nodes, which works but I'm worried this isn't the best way performance wise. Aren't those field tables then being joined for every node call?

Using the Form API isn't an option because I want to take advantage of the field widgets (using unlimited values etc).

Any ideas?


texts: How to clear ALL cache, including field and filter caching of nodes and fields?

texts:
I'm working on a text format filter module. Now, somehow Drupal keeps the node content in some cache that is not refreshed with drush cc all, which I would have hoped to "clear all cache". This is with Cache pages for anonymous users and Cache blocks disabled.

I wrote a little script that adds " " at the end of the node body, but even running that between two drush cc alls doesn't cut it, still with cache disabled.
It's really strange. If I go to a page I haven't accessed yet, it will show me an old version what was filtered.  So I'm tempted to now also let the script access the specific node over HTTP...

Is there an easy way to really clear all cache? I guess dropping and recreating all cache_* tables could cut it but that seems a bit convoluted.


texts: Any way to get localized term names in node paths

texts:
I have a node type "news" with an included term reference field named "newscategory". i18n-module incl. taxonomy-i18n is also installed, vocabulary is translatable and all terms are translated. But for pathauto patterns there is only the token "[node:field_newscategory]" available, which will not be localized depending on the node language.

Is there any trick on achieving this?


texts: Programmatically add a taxonomy term to an existing content type

texts:
How would you programmatically add a taxonomy term to an already created content type? Presupposing that I already have the taxonomy field available on all the selected content-types beforehand.

I wish to bulk add a taxonomy term to several nodes. I noticed in the content display list there is a way to filter down to a term when it already exists on nodes, but is there a way to possibly add it to a content-type that doesn't have it yet?

I read the question and comments for Programmatically create taxonomy term, and this is partially there, but I don't know how to get it further.


texts: How to alter default ajax_view default ScrollTop?

texts:
In ajax_view.js, the code responsible of smooth Ajax View ScrollTop when changing the exposed filters is the following :

Drupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response, status) {
  // Scroll to the top of the view. This will allow users
  // to browse newly loaded content after e.g. clicking a pager
  // link.
  var offset = $(response.selector).offset();
  // We can't guarantee that the scrollable object should be
  // the body, as the view could be embedded in something
  // more complex such as a modal popup. Recurse up the DOM
  // and scroll the first element that has a non-zero top.
  var scrollTarget = response.selector;
  while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) {
    scrollTarget = $(scrollTarget).parent();
  }
  // Only scroll upward
  if (offset.top - 100 < $(scrollTarget).scrollTop()) {
    $(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500);
  }
};

})(jQuery);

I tried to alter this behaviour from a custom module, but no way to get it working. How can I proper change the values of offset.top - 10 to offset.top - 100 ? Here's one of my several tries...

function MYMODULE_init() {
  drupal_add_js( drupal_get_path('theme', 'MYTHEME').'/assets/js/MYSCRIPT.js');
  //...

//IN MYSCRIPT.js
Drupal.behaviors.events = {
  attach: function(context, settings) {
    $('.my_view', context).ajaxStart(function(){
      $('.my_view', context).fadeTo(500, 0.7);//this works
    });
    $('.my_view', context).ajaxSuccess(function(){
      $('.my_view', context).fadeTo(300, 1)//this works
          .animate({scrollTop: (offset.top - 100)}, 500);//this doesn't
  //...


texts: Memory efficient way to load large entity set for data export

texts:
I'm working on an Excel exporting feature in a Drupal 8 site.

Obviously, I can load all entites of certain type like this:

$user = \Drupal::currentUser();

$entity_query = \Drupal::service('entity.query')->get('some_type');
$entity_query->sort('created', 'DESC');

$ids = $entity_query->execute();
$entites = $this->storage->loadMultiple($ids);

foreach ($entities as $entity) {
    // build some Excel row with the entity information
    // ...
}

But if you're doing this on a large entity set, you'll be running out of memory very soon. I think the reason why Drupal would run out of memory is the extensive caching involves in the entity query and loading process.

Is there a more memory-efficient way to load an indefinite size of entity set without running out of memory?

(Note: Let's pretend the Excel library is very clever and do not take up memory. That's another issue for another day.)


texts: How to load block on link click with AJAX framework?

texts:
I have tried in my custom module:

Declaring a path for Ajax callback

function custom_menu() {

  $items['ajax-block/%'] = array(
    'title' => 'Ajax test callback',
    'type' => MENU_CALLBACK,
    'page callback' => 'ajax_link_callback',
    'page arguments' => array(1),
    'delivery callback' => 'ajax_deliver',
    'access arguments' => array('access content'),
  );

  return $items;
}

now the callback itself

/**
 * Callback ajax
 */
function ajax_link_callback($from_cid, $mode = NULL) {

  if ($mode != 'ajax') {
    drupal_set_message('Turn Javascript');
    drupal_goto(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '<front>');
  }

  $commands[] = ajax_command_html('.region-content', some_func());

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

I have a few manually created links:

link1
link2
link3

Now I need such functionality - when I press link1 - block1 loads content in to .region-content, when I click link2 - block2 and etc.

How can I do this?


texts: How to delete content entity type programmatically on uninstall?

texts:
I am trying to delete a configuration from a module in hook_uninstall.
My module creates a content type bundle which has to be deleted.
I tried to use an approach described here: How to delete a content type, programmatically?
but without luck, the content type still exists.

dependencies:
  enforced:
    module:
      - modulename

Of course, I delete entities of the given type before uninstall. Is there any way to do it programmatically: delete a content type with fields?


texts: What are the array keys of $content that can be hidden?

texts:
I see that with drupal 7 theming, we can mark elements of the $content array as hidden.

From http://drupal.org/update/themes/6/7 :

  <?php
    // We hide the comments and links now so that we can render them later.
    hide($content['comments']);
    hide($content['links']);
    print render($content);
  ?>

What other keys always exist? Or if they are dynamically generated, what is the best way to check the hideable content elements?

Thanks

Edit
With the devel module enabled, I found that the information I was looking for roughly corresponds to the information found at the location /node/your_nid/devel/render.
Or using PHP directly, dprint_r(array_keys($content));


texts: Profile field create and set default value programmatically

texts:
I need the checkbox to be checked by default.  Below is my code, notice the 'default_value' under the settings array.

$field_instance = array(
    'field_name'    => $fielddef['field_name'],
    'type'          => 'list_boolean',
    'entity_type'   => 'user',
    'bundle'        => 'user',
    'label'         => t($opts['label']),
    'description'   => t($opts['description']),
    'required'      => FALSE,
    'widget'        => array(
        'type'      => 'options_onoff',
        'weight'    => 10,
    ),
    'settings'      => array(
        'allowed_values' => drupal_map_assoc(range(0,1)),
        'default_value' => array(array('value' => 1))
    )
);
field_create_instance($field_instance);

I have tried using 'default_value' in the $field_instance array, I've also tried 'default_value_function' without success.  I feel like I'm close on this, what am I missing? Thanks!

Also, I am running Drupal 7.23 as shown on my Status Report.
I asked this question earlier on SO, but no reply so I moved it here: https://stackoverflow.com/q/19772646/988355


texts: How do I get all the users in an organic group with specific role programatically?

texts:
I'm trying to use rules to send an email to all users with a specific role in an organic group when someone requests to join the group.

This code almost works. It returns all users from a specific group ($GID) with the specified role ($RID), but it doesn't restrict the role to that group. In other words, if they have the appropriate role in another group, they're included in the results.

$current_members = db_select('og_membership', 'om');
$current_members->join('og_users_roles', 'ogur', 'om.etid = ogur.uid');
$current_members->condition('om.gid', $GID);
$current_members->condition('om.entity_type', 'user');
$current_members->condition('ogur.rid', $RID);

$result = $current_members->execute();
while ($res = $result->fetchAssoc()) { $members[] = $res['etid']; }

// Remove duplicate items.
$members = array_keys(array_flip($members));

What do I need to change to restrict the results so that it only returns users with the specified role ID within the specified group?


texts: How do I create a taxonomy lineage browser?

texts:
Edit:

I want to sort nodes by taxonomy hierarchy and want to show the list of associated nodes when I get to the last "child/level". I have so far followed the suggestions listed at (Clean way of building simple taxonomy browser of arbitrary depth). It is definitely a "hacky" way and it did not work for D8.

Parent 1
    ‑‑Child 1
           ‑‑Sub-child 1
     ‑‑Child 2
           ‑‑Sub-child 2
           ‑‑Sub-child 3
Parent 2

How do I build it this functionality in D8 using views?


texts: View showing ONLY taxonomy children terms and NO parents

texts:
I've managed to got my view working but my worry is that this method is not dynamic.

What I want to achieve?
To have a list of articles tagged with terms that are one level deep (children) but not their parent terms.

E.g.: assuming a taxonomy looks like this:

A
  A1
  A2
B
  B1
  B2

I want to be able to go to the URL mysite.com/A/A1 or mysite.com/B/B2 and retrieve a list of articles with ONLY content tagged with A1 or B2 (in this example)

For that I added a filter and manually selected the parent terms I don't want to list:

Is there a better solution to achieve this?

Thanks!


texts: Automate the creation of settings.php and files directory

texts:
I am using Drush make files and Drupal Installation profiles to streamline the creation of new Drupal websites (which are created in the sites directory of my Mac).

Everything is working fine. The Drush make file automatically downloads Drupal and all the modules I normally use on each site.

However, for each new Drupal website, I have to create a files directory and a settings.php file and then set them to writeable.

Is there any way I can automate this process, so these files are created when Drush downloads the files for the Drupal website?


texts: How to display body content in custom text?

texts:
How to display body content in this line?

I had tried "content_body" and "field_body" but doesn't work.

The script below is inserted in "Configure field: Global: Custom text"

            [field_image]

[title]

[field_categories]

[content_body]


texts: How to show time in node.tpl.php that takes the configured timezone settings into account?

texts:
I have a custom content type and it has a date-time field. I have also a custom node.tpl.php to display this content type.

The timezone settings is done (at admin/config/regional/settings, Europe/Istanbul, +0300).

This is the code I print the date-time field.

<?php print format_date(strtotime($node->field_event_datetime[LANGUAGE_NONE][0]['value']), $type = 'custom_event', $format = '', $timezone = 'Europe/Istanbul', $langcode = 'tr')?>

Although I set everything, it still shows the wrong time. For example it should be 10.00 but it shows 07.00. I also tried to set the timezone NULL but nothing changed.

How to solve this problem?


texts: ImageCache throwing 500 internal server error

texts:
I'm trying to use imagecache for the first time. (already installed by someone else. currently not serving any images)

So whenever I try to see an image modified by imagecache I have a 500 internal error. In the drupal's watchdog report log there is just an error without much description:

Failed generating an image from imagecache_sample.png using imagecache preset small_analysis.

I have no idea why, but in the apache error logs, I can't find anything...

This happens even when I try to display the imagecache sample:

http://www.radicalislam.org/sites/default/files/imagecache/small_analysis/imagecache_sample.png?1344778168=


texts: Taxonomy - populate child dropdown based on parent dropdown?

texts: I am wondering if there is a way to populate a taxonomy dropdown menu with the child terms of a selection made in another taxonomy dropdown menu. I would like to have two taxonomy dropdown menus, one for genre (parent) and one for sub-genre (child). When the a selection is made in the genre menu, I'd like the child sub-genre terms for that genre appear in the menu. Is there a way to implement this?


texts:
I'm looking for a way to add the ability for users to toggle one of two view modes. Essentially, looking for a 'list/grid' switch. I've tried using https://www.drupal.org/project/views_modes but it's failing to switch the URL at all.

If anyone has knowledge of a patch/fork of this project, or a way to achieve this, I'd be grateful!


texts:
I need to set up a weekly email digest of all content from a few particular content types (latest news, latest tech articles etc.) for all users in a particular group.

I have Simplenews installed and it looks like the Simplenews Digest module is not updated. Is there anything else that offers the feature I am looking for?


texts: Why is my Drupal ajax form not populating the radio buttons

texts:
I have a form which send an ajax request to my server. The form is:

function dokimi_add_to_list_form($form, $form_state) {

  $form = array();

  $options=array(
      'option1'=>'option1',
      'option2'=>'option2'

  );

  $form['private_list'] = array(
    '#type' => 'radios',
    '#title' => 'Private lists',
    '#options' => $options,
    '#prefix'=>'
',
    '#suffix'=>'
'
  );

  $form['add_new']= array(
    '#type' => 'fieldset',
    '#markup' => 'Add a list'
  );

  $form['add_new']['new_list']= array(
    '#type' => 'textfield',
    '#title'=> 'New list',
    '#default_value' => '',
  );

  $form['add_new']['add']= array(
    '#type' => 'button',
    '#value' => t('Add'),
            '#ajax'=>array(
              'callback' => 'add_to_list_callback',
              'wrapper'=>'list_list'
                  // 'wrapper' is the HTML id of the page element that will be replaced.
        )
      );

 return $form;
}

And the callback function is:

function add_to_list_callback($form, $form_state){

    $options=array(
      'newoption1'=>'newoption1',
      'newoption2'=>'newoption2',
      'newoption3'=>'newoption3'
  );
    $form['private_list'] = array(
        '#type' => 'radios',
        '#title' => 'Private list',
        '#options' => $options,
        '#prefix'=>'
',
        '#suffix'=>'
'
  );

    $commands = array();
    $commands[]=ajax_command_replace('#list_list', render($form['private_list']));
    return array(
        '#type'=>'ajax',
        '#commands'=>$commands
    );

}

When the 'Add' button is clicked, a new array of options should be returned, but I get an empty list instead.

The form is rendered in a ctools modal if that is of importance.

Thanks for any help with this - it's driving me barmy.


texts:
I am using fivestar module to rate the content. I have added it to my view and full node view. I have configured it only to display number user voted the content. By default it is displaying as No votes or (10 Votes) and so on. I want to alter the text as (0) or (10) and so on. How can I alter the text.
 In contrib it  is written in http://www.drupalcontrib.org/api/drupal/contributions!fivestar!includes!fivestar.theme.inc/function/theme_fivestar_static/7


texts: PDOException: SQLSTATE[42S02] on cache_block after module install

texts:
I am getting the following error on my (localhost) test system after installing some modules:

  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146
  Table 'bitnami_drupal7.cache_block' doesn't exist

After receiving the error, I uninstalled and removed the modules I was attempting to install thinking that a fresh module install might fix the problem.  However, it's apparent to me that the install corrupted the database.  Before I even attempted a new install of those modules, I get the above error while performing some other work.  So, I used PHPMyAdmin to peek into the database.  When I try to access cache_block, I get an error stating that it does not exist.  Unfortunately, I do not have a recent back up since this is a test system.  However, I do have a live production system.

Question: can I use the live production system to export the cache_block table structure and then import it into my localhost?  If not, is there an alternative solution to resolve this error?  I'd like to avoid having to reinstall Drupal.


texts: Exporting Custom Display Suite View Modes With Configuration

texts:
I'm using display suite with custom display settings for several view modes.  I am also using the configuration management module for D7.

When I go to import my config on the staging server, the content types and settings and even the 'ds' field format settings come through, but it does not remember what view modes I've checked to have custom display settings.  If I manually go back in and recheck the view modes, everything displays fine again.

Any idea where to track those changes?


texts: Filling an Entity Reference programatically

texts:
I am creating a node programatically and one of the fields in the node is an entity reference field referencing a user.

I am using the guide from https://www.drupal.org/node/1388922 and the general consensus i gather is that I need to do something like;

$node->field_customer_nid[$node->language][] = array(
'target_id' => $form_state['values']['entity id'],
'target_type' => 'node',

);

My question is where do i pass the values for the target entity(basically the uid)in that array. Is it the target_id or the entity_id because my attempts with either of those is not working.


texts: Node display based on conditional view [NULL] field entry or a Rules expression

texts:
I am trying to find a solution to empty user Content Listings shown on a User dashboard (landing page). Ideally I want to show a Mini-panel pane or Custom Content Pane instead of a users listing View which would other wise show an empty table and hence blank space on (in this case a Desktop browser, alternatives to be incorporated via CSS Bootstrap etc).

Should the user not have posted any content then a pane with a (vector.svg) graphic will show in place of the empty view blockspace based on the View being NULL or empty asking them to 'add some content' or maybe a vector graphic to instruct. I have looked at the Conditional View module and Rules, but nothing seems to show such options so I'm not quite sure is this my right approach.

Where and what should be my correct approach?


texts: how to update price from front end in ubercart product in drupal 7?

texts:
I have a site in drupal 7, and I am the admin of site. I am using ubercart in my site for products. I have lot of products in my site with attributes and options. My products options are price based..

For example: I have one jewellery $100 with siver $23 and gold $43. Silver and gold are comming from option.

I want to update  options price from front end where product are displaying without going from edit product from backend.


texts: Multiple language node import with Feeds

texts: I am using Feeds to import a very huge CSV file with products to my Drupal Commerce site. My site must be in two languages and it appears that Feeds hasn't support for this. How can I import nodes in multiple languages with Feeds?


texts: How can I disable the link on authenticated an authenticated user's name in the comment submission form in Drupal 6?


texts: Why am I seeing "Undefined index: und" when I'm using LANGUAGE_NONE?

texts:
I've never seen this before, I'm getting an

  Undefined index: und in mymodule_page_alter...

on a line where I'm checking this

$node->field_override_ads[LANGUAGE_NONE][0]['value'] == 0

Is this a bug, or am I missing something?


texts:
I'm using a "managed file" to upload an image, which works fine, but if you want to remove the image by clicking on the "Remove" button, nothing happens.

 $form['logo'] = array(
    '#type' => 'managed_file',
    '#title' => 'Logo',
    '#default_value' => variable_get('logo', ''),
    '#theme' => 'mymodule_thumb_upload',
    '#upload_location' => 'public://my-files/',
    '#upload_validators' => array(
      'file_validate_extensions' => array('gif png jpg jpeg'),
      'file_validate_size' => array(0.3*1024*1024),
      'file_validate_image_resolution'=>array('100x100'),
    ),
);

I'm using a custom theme, and I just realized when I switch back to 'Seven' the button works. But what could be the problem?


texts: Creating media_bundle entities programatically

texts:
I am still trying to wrap my head around some of the D8 things.  Working with some media bundles like media_audio_bundle and need to write some migration scripts. I have spent couple of days now researching and trying everything but nothing seems to work.

Its like Drupal wall all over again.

This is the closest I came:

$audio = \Drupal::entityTypeManager()
          ->getStorage('media_bundle')
          ->create(array(
            'type' => 'media',
            'bundle' => 'audio',
            'title' => 'Another Audio',
            'field_audio_file' => 11
          ));

It seems to create some sort of media object but does not save it.

If somebody can help, would be much appreciated.


texts: Define entity in module and edit existing items

texts:
I am trying to create a module which defines an entity (called "didyouknow") with two fields: ID and content.

I have set it up to create new items of this custom entity, but I can't get it to work for editing existing items.

I'm trying to reuse the same form (didyouknow_item_form()) for creating and editing, which works fine for creating, but for editing. The "%didyouknow" part in the URL is supposed to mean that the argument of didyouknow_item_edit() is a loaded entity object, but it isn't; if I output it within that function using print_r(), it outputs as "structure." This results in PHP outputting:

  Notice: Trying to get property of non-object in didyouknow_item_form()

The code for the functions is below:

function didyouknow_menu() {
    $items['admin/structure/didyouknow/manage/add'] = array(
    'title' => 'Add Did You Know item',
    'page callback' => 'didyouknow_add',
    'access arguments' => array('create didyouknow'),
  );
  $items['admin/structure/didyouknow/manage/%didyouknow/edit'] = array(
    'page callback' => 'didyouknow_item_edit',
    'access arguments' => array('create didyouknow'),
    'page arguments' => array(1),
  );
  return $items;
}

function didyouknow_item_edit($didyouknow){
  return drupal_get_form('didyouknow_item_form', $didyouknow);
}

function didyouknow_add() {
    $didyouknow = (object) array (
    'pid' => '',
    'type' => 'didyouknow',
    'content' => '',
  );

  return drupal_get_form('didyouknow_item_form', $didyouknow);
}

function didyouknow_item_form($form, &$form_state, $didyouknow) {
  $form['content'] = array(
    '#type' => 'textarea',
    '#title' => t('Content'),
    '#default_value' => $didyouknow->content,
    '#required' => TRUE,
  );

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

  field_attach_form('didyouknow', $didyouknow, $form, $form_state);

  return $form;
}

function didyouknow_item_form_validate($form, &$form_state) {
  $didyouknow_submission = (object) $form_state['values'];
  field_attach_form_validate('diyouknow', $didyouknow_submission, $form, $form_state);
}

function didyouknow_item_form_submit($form, &$form_state) {
  $didyouknow_submission = (object) $form_state['values'];
  field_attach_submit('didyouknow', $didyouknow_submission, $form, $form_state);
  $didyouknow = didyouknow_item_save($didyouknow_submission);
  $form_state['redirect'] = "admin/structure/didyouknow/manage/$didyouknow->pid/edit";
}

function didyouknow_item_save(&$didyouknow) {
  return entity_get_controller('didyouknow')->save($didyouknow);
}


texts: How can I display the block title when rendering a block using Twig Tweak?

texts:
Block title when using twig-tweak plugin, not showing. I created a block-type view. And using the module's cheat sheets, I called:

{{ drupal_view('views_name', 'block_1') }}


texts: How to have an environment specific drush.yml?

texts:
I'm using Drush 9. With the old drushrc.php I could easily include a local.drushrc.php that dynamically set the site url. How can I do it now?

This is similar to How can i set site url dynamically in Drush-9?. However I don't want to pass the url in every Drush command. I think of something like below in ../drush/drush.yml:

drush:
  paths:
    config:
      - ${env.home}/local.drush.yml

But I'd need another variable that point to the Drupal site directory (sites/default in a monosite, sites/CURRENT-SITE in a multisite). Does such a variable exist?


texts: How do I show product attribute fields in a view?

texts:
I'm having difficulty with what seems straight forward and have tried many Drupal Commerce extra modules. Can anyone advise on showing product attributes in a add-to-cart form?

I have product types:
- "product" and
- "boat checkout"

And "boat checkout" products:
- 1/2 day
- full day

And node types:
- basic page
- boat
- boat reservation

I'm not able to get boat product attributes showing in the add form nor in the checkout view, despite attribute settings on Despite visibility on /admin/commerce/products/types/boat-checkout/fields.  I'd prefer using a view to keep the site simple (and not creating 2 nodes to display 2 products).

Separately, can product attributes be saved/ shown on orders??  Very hard letting users change or view attributes.


texts:
I'm trying to customize login, logout functionality in my drupal site. My custom login function works fine by using the below code:

function my_module_custom_login() {
  $username = $_POST['username'];
  $pass = $_POST['password'];
  $uid = user_authenticate($username, $pass);
  $form_states = array('uid' => $uid);
  if(!empty($uid)) {
    $user_login = user_login_submit(array(), $form_states);
    return 'user is logged in';
  }
  else {
    return 'user is not logged in';
  }
}

After calling this function I checked the "Recent Log message" in my drupal reports it tells "Session open for user abc".

Here is my logout code:

function my_module_custom_logout() {
  module_load_include('inc', 'user', 'user.pages');
  user_logout();
}

Whenever I called this function the recent log message shows "Warning: session_destroy(): Trying to destroy uninitialized session in user_logout()" That call went as an anonymous call. So the current user can't be able to logout from the site. How can I overcome from this.


texts: How to display the average rating of a node as stars in a view?

texts:
The users on my website can rate an article with the Fivestar module while they comment. I'd like to create a view with the 5 articles that have the highest average score.

I've nearly been able to achieve what I want with a 'Vote results' relationship and a 'Vote results: Value' field. The problem is that the average score is displayed as a number, but I'd rather like it to be shown as stars. I achieved this in the past without custom coding (thanks to a deleted video that was situated here), but I forgot how to do it.

Can you help?


texts: Allow users to add own taxonomy terms to uploaded images

texts:
I am using imagepicker moudule to allow users to add images to the website.

I want them to have a 'tags' bar where they can add words that describe the image they have uploaded (so that other users can also search by those tags)
One like the one on this site when you upload a question!


texts: Searching for nodes from another site in a multisite installation

texts:
I am trying to have the search function of a www.site.com return also nodes from site.com/somethingelse. Is there any way I can achieve this?

I prefer not to use Solr.


texts: How to make the search engine use search api db?

texts:
I have installed search_api, with search_api_db, create 2 indexes, one for node, one for users.
The conf:

server: search_db server,
2 indexes: default_node_index and user_index
service class: database service

The one for users has parameters:

field: email (fulltext)
filter:role (limit to one only).

The index seems working good, it indexes the right number of users, I checked the uids in the db and it is corresponding to the good users.
But still when I use the search (search/user/something), the search is on the names instead of emails, and the role filter is not applied. So in short, it is not using the search_api_db. It looks like the whole system is overriden by some other fulltext on everything search. I'm stuck here


texts: In D7 how can I append an element to the DOM via ajax on an arbitrary event (not forms and not links)?

texts:
There are many Form and Link related examples for D7's new Ajax features.  I'm looking for something a little less involved but haven't got it working yet.

Using ajax-reload-of-block-on-an-event

I've modeled the following contrived example:

I'm tring to request and receive a tag and then nest it within an existing one:

function MY_MOD_menu(){
    $items['ajax/insert'] = array(
            'page callback' => 'ajax_return_tag',
            'type' => MENU_CALLBACK,
            'access callback' => TRUE,
    );
    return $items;
}

function ajax_return_tag(){
    $tag = "<h1>";
    $tag .= "HERE";
    $tag .= "</h1>\n";
    return $tag;
}

Here is the js:

(attach:function ($) {Drupal.behaviors.MY_MOD = {function (context){
    var insert = function(response){
            $('.field-name-field-').html(response);
    };
    $.post('/q=ajax/insert',
            {},
            insert,
            'html',
    );

}};})(jQuery);

It does not appear that my event is firing. Do I need to do something in addition to get the js to load on document ready?  Have I made a mistake with the way I've attached the behavior?

Thanks in advance.

EDIT:  Thank's for the responses.  The typos are a result of me creating this example on the spot.  I'm not so interested in getting this specific example to run but I am interested in a example that will update/Insert a DOM element that is not a Form or Link.

FYI I don't believe the event is firing. I assume that means that it is not registered with D7's included jQuery?


texts:
I'm using Drupal 7 for my website.
I created custom settings page with custom form in it, but the problem is I don't know proper way to load inserted value from database to my form after saving it, and every time I write something in it, information is written to database, but form is empty.
My code looks like this for this:

function registration_pdf_form($form, $form_state) {
    $form['registration_body_twoside'] = array(
        '#type' => 'text_format',
        '#title' => t('Two-sided PDF'),
    );
    $form['registration_body_threeside'] = array(
        '#type' => 'text_format',
        '#title' => t('Three-sided PDF'),
    );
    $form['actions'] = array(
        '#type' => 'actions'
    );
    $form['actions']['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Save settings')
    );
    return $form;
}
function registration_pdf_form_submit($form, $form_state){
    $values = array(
        'reg_twoside' => $form_state['values']['registration_body_twoside']['value'],
        'reg_threeside' => $form_state['values']['registration_body_threeside']['value'],
    );
    $insert = db_update('pdf_settings')
        -> fields(array(
            'reg_twoside' => $form_state['values']['registration_body_twoside']['value'],
            'reg_threeside' => $form_state['values']['registration_body_threeside']['value'],
        ))
        ->execute();
    drupal_set_message(t('Settings have been saved'));
}

How do I get values to my fields from database?


texts: Calling function from other module does not work with module_load_include

texts:
I'm building a custom module that uses functions from other modules. Specifically the node_clone module. I'm building a custom module to clone a certain content type from a selected user to another selected user.

In my custom module I'm adding those lines:

module_load_include('inc', 'node_clone', 'clone.pages');
clone_node_save($nid);

The function clone_node_save is defined in the module "node_clone", in the root folder of that module,

function clone_node_save($nid, $account = NULL) {
//Function Content
}

inside a file called clone.pages.inc

yet those 2 lines of code give me the error Fatal error: Call to undefined function clone_node_save()

I also tried making a function inside node_clone.module that calls clone_node_save but that gets the same error.

This is drupal 7


texts: Joining Taxonomies in an Ubercart Views into a single Field Group (D6)

texts:
I have a view for a taxonomy term filtered by the argument.

A particular product has more than one taxonomy term related to the individual node.

This works for only all nodes that have just one taxonomy term. Unfortunately i have a product that has more than one taxonomy term.

Thus on the page with that particular product I have them grouped by fields. When i do this they're displayed as two different fields. All the products with a singular term and another taxonomy term with two terms.

Is there a way for me to group the node into one field ?


texts: How to use DataDefinition::create('list')?

texts:
This answer links to a list of all possible types that can be used with DataDefinition::create().

One plugin that can be used is ItemList.

But I can't find any documentation on how to define what items are on the list.

I would have expected something like this:

$status_definition = DataDefinition::create('list')
  ->setLabel(new TranslatableMarkup('Status'))
  ->setRequired(TRUE)
  ->setListItems([
    1 => 'One',
    2 => 'Two',
    3 => 'Three',
  ]);

But the method setListItems (or anything similar) does not exist.

For some more context I'm following this article on how to extend the entity reference field type but instead of adding an integer field I want to add a list field.


texts:
I have a block with a select box and submit button. The main purpose of the select box is to store a variable in the session. I used template_preprocess_node to filter contents based on user selection.

function blackout_preprocess_node(&$vars) {
  $node = $vars['node'];

  // define a variable to hold your rendered content
  $newContent = "";

  if($_SESSION['myid'] == '1' && $node->field_field1[0]['value'] != '') {
    $newContent = $node->field_field1[0]['view'];
  } else if($_SESSION['myid'] == '2' && $node->field_field2[0]['value'] != '') {
    $newContent = $node->field_field2[0]['view'];
  } else {
    $newContent = $node->body;
  }
  if (strlen($newContent)) $vars['content'] = $newContent;
}

Everything is working fine except I have to click submit twice to reload the page contents or I have to move to another page to see re-loaded content. How can I reload content with just one click?


texts: How to skip specific tables with drush sql-dump?

texts:
I have a drush config file ~/.drush/drushrc.php:

if (!isset($options['structure-tables']['common'])) {
  $options['structure-tables']['common'] = array(
    'cache', 'cache_*', 'history', 'search_*', 'sessions', 'watchdog'
  );
}

$options['structure-tables']['common'] = array_merge($options['structure-tables']['common'],
  array('ctools_css_cache', 'ctools_object_cache', 'logz', 'views_object_cache')
);

And I have a bash script file:

/usr/bin/drush sql-dump --root="/home/username/domains/sitename/www" --skip-tables-key="common" --gzip --result-file=/home/username/backup/$year/$month/dbname_$date_now_time.sql

But when I execute it the backup file still have data in cache tables.
What am I doing wrong?

And second question is - If I put this into crontab do I need to put configuration file somewhere else?

I use Drush version 8.


texts: Need advice on how to setup a Drupal site on a given scenario

texts:
I need ideas/help on how to setup a drupal website with following given scenario. I just come up with the scenario this is not real but if I get the answers then I think I can apply on real poject.

I have two content-type Movies & Celebrities.

Movies content type will list all the movies information like...
"Movie story overview", "movie review" and "movie cast"

Similarly I have Celebrities content type which will Celeb information like
Movies acted, Bio, awards etc.

Now what I want...

First Objective:

When I add a new celebrities node to site, how can I create/add multiple pages automatically
Example: I added a new celebrity named “kate winslet” by using “Add Content”->Celebrities content type. Now when I save it there should be 4 urls created in one go.

a.   Domain.com/celebrity/kate-winslet
   b.   Domain.com/celebrity/kate-winslet /movies-acted
   c.   Domain.com/celebrity/kate-winslet /bio
   d.   Domain.com/celebrity/kate-winslet /awards

Similarly while adding a Movies content type it should generate multiple pages like

a.   Domain.com/movies/titanic/overview
b.  Domain.com/movies/titanic/cast
c. And more like this.

Note: I don’t want to create pages manually. Only one main landing page for each type should be created manually and rest of the pages should be added itself.

Now...

Second Objective:

On the “domain.com/movies/titanic/cast” page, how can I have functionality to look-up all the celebrities page titles & url and link both, a movie with its casts or an actor/actress with movies.

Example: I added a new movie “titanic”, now the movies content type may have a custom filed (CCK) named as “movie cast” where I will be adding actor/actress full name like “kate winslet”, “leonardo dicaprio” etc.

Now what I want is these names should be link to their corresponding celebrity pages like

a.  “kate winslet” shoule be linked to Domain.com/celebrity/kate-winslet

b.  And “leonardo dicaprio” should be linked to Domain.com/celebrity/ Leonardo-dicaprio

Any idea or help is highly appreciated.


texts: How to use Rules to auto populate field B with the value of field A after saving a new node or updating an existing one?

texts:
This must be easy, but I just can't figure it out ...

My scenario is like so:

I have a content type with field A (title_field - text field) (that contains the title) and field B (field_tagged_as taxonomy reference).
I need to auto populate field B with the value from field A, after saving a new node or updating an existing node.

Is there a way to do this using the Rules module?


texts: How to customize a field price in Drupal Commerce?

texts:
I have a field price in my grid and want to customize it.

Below are 2 pictures that will explain the situation:

My question: How can I customize that field to looks like this:

Any suggestions?


texts:
is there anyway to run drupal 8 with guzzle to access remote server rest server without turning off selinux.

for example in httpd, i can do:

  setsebool -P httpd_can_sendmail on

to be able to make apache send email without turning off selinux.

Thank you,


texts:
I'm building a site which has several "guide" sections, each with their own menu. Think "London guide", "Paris guide", "Berlin guide" etc.

All of these guides will share the same forum - call it "European city forum". (I don't anticipate there'll be enough postings to merit one forum per guide, at least not at first.)

I'd like this forum to be accessible within each guide section, while retaining the guide menu. So you could click on "forum" from the London menu, or from the Paris menu, and it'd give you the European city forum... but still within the London or Paris menu.

In theory I can do this by setting up different URL aliases for the forum (say, /paris/forum and /london/forum, both leading to /forum/8); adding these to each menu; and then checking request_uri in my template code, and calling menu_tree_set_path accordingly.

However, that only sorts out the menu path and URL for the forum index. Any action that the user takes within that forum, such as viewing a thread or starting a new topic, will go to the standard URL - such as /node/add/forum/8 - and (therefore) the first matching menu path.

I'd like the user's interactions to continue "within" the city guide that they're browsing. Right now I'm completely stumped as to how to do this.

Any wisdom?


texts:
I'm on an Amazon Linux machine.

I ran:

$ composer global require drush/drush
Changed current directory to /home/ec2-user/.composer
Using version ^8.1 for drush/drush
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files

Then I added composer into the PATH so it reads like this:

$ echo $PATH
/home/ec2-user/.composer/vendor/bin:/home/ec2-user/.composer/vendor/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin

Then if I try this I get an error:

$ composer show drush/drush

  [InvalidArgumentException]
  Package drush/drush not found

show [--all] [-i|--installed] [-p|--platform] [-a|--available] [-s|--self] [-N|--name-only] [-P|--path] [-t|--tree] [-l|--latest] [-o|--outdated] [-D|--direct] [--] [<package>] [<version>]

And if I run the drush command the cursor stays there waiting:

$ drush

What did I miss?


texts:
I am unable to display the value returned from my JOIN query, the error i get is:

Notice: Undefined property: stdClass::$field_brand_value

Here is my code:

$sql = "SELECT nid, title FROM {node} AS n JOIN {field_data_field_brand} AS brand ON brand.entity_id = n.nid WHERE created > :created";

$args = array(':created' => REQUEST_TIME - 3600);

$result = db_query($sql, $args);

foreach ($result as $obj) {
  drupal_set_message("title: {$obj->title} brand: {$obj->field_brand_value}", "warning");
}


texts: I want to modify the drop down menus for Marinelli (a Drupal theme)

texts:
I have the Marinelli menu setup in a website I am internal testing.
I want to modify the drop down menu (I know it uses jQuery), but I have no idea what to do to show the drop down all nested.

In other words, instead of having this in the Marinelli theme

MENU1
submenu
underMenu
undermenu
submenu
undermenu

I want to have the menu like the corolla theme

MENU1
submenu
submenu

and when I hover a submenu:

SUBMENU
undermenu
undermenu

Any help is welcome.


texts:
How can I remove the Page SUM row in my Views Calc?

I have upgraded Views Calc module to its latest version.


texts: How to reset 'new' and 'updated' flags without visiting a node page?

texts:
In my drupal site I have a content type that has its nodes visible only in a view and they have always the 'new' (or 'updated') flag up for all users.

How can I reset the flags without visiting the node page?
Is there a function to tell drupal "this user has seen this node"?


texts:
I have created a content type Agenda - the body is paragraphs - there are two types: (1) Text and public files and (2) Private Files.  The fields work properly - Anonymous cannot see Private Files.  Authenticated Users can see Private files.

My issue occurs when I create group content for Agenda.  Non-members can see Private Files.  I cannot figure out where to go to turn this off.  The paragraph Private Files is set for view for authenticated user.  I cannot find in group how to change paragraph.

Any help is appreciated.


texts:
I would like to import some nodes from csv file using feed_import module in Drupal 7.
The original CSV file has around 500k entries and I have to do some filtering before importing. (the result will be under 40k).

Now, I have seen on drupal.org that feed_import has the possibility of adding some filters, but I cannot find the way to apply them.

Anyways I haven't seen nothing about the lenght of the field or about the type of content (numeric, alphanumeric, letters only), and I have to filter on these criteria.

Can that be made? Or should I try to do the filtering in PHP before using feed_importer?


texts:
I am using the Video module with FFmpeg.
How do I show the video preset options when uploading video files in the node edit form? Is this possible?


texts: How to add an editable text box to a page

texts:
So i have created a page which uses an XML feed to generate some output. I want to be able to add a textarea from the FORM API so that i can allow user of my site to enter some details on to the form itself.

Similar functionality to how entityform works, seemed like a simple task, but not sure how to do it.


texts:
How to display a block inside lightbox 2 in d7.

i have views exposed filters as a block and i am trying to display it inside lightbox2 ... any help will be appreciated


texts: Drupal do not publish more current notes to other browsers than admin logs in

texts:
On my site eso-meetu.de Is a node created on  13 Juli, 2014  Drupal does not publish more current nodes to other browsers than the one i uuse to admister my site.

has someone any idea how to fix this or get closer to the error that populates this issue?

There are no errors in watchdog related to this also the server logs look fine

Even if I turn off memcache ore flush all caches the resul is the same.


texts:
I'm using the flag module with Views.  I need to display all the nodes a user has flagged. This is quite similar (point.3) View of users flagged by a user, users flagging a user, and nodes from users flagged by a user - But there doesn't appear to be an answer. Any idea how to achieve this?

The view will take in the uid as a contextual filter from the URL.  But I'm not sure how to print out the related flagged content, as the view has only user information available..

Edit> There will be multiple users in which anyone can view the profiles of. On a users profile there is a tab called 'Following'.  This needs to show the nodes that the user (being viewed) has flagged 'follow'.  So I've created a page in a view 'user/%/following' for example.. I've included the flag relationship, I just need to print out the node teasers.. This option doesn't appear to be available..

Any ideas? Cheers!


texts:
I'm currently migrating a website from Drupal 5 to Drupal 6. I've migrated most of the modules but something keeps nagging me: on Drupal 5 I had a block that displayed a snippet of text with a "More" link in a separate line. This snippet of text sent the user to a page with the full text.

After the Drupal 6 migration that snippet of text no longer links to anything. How can I make it lu


texts: Organic Groups new group error on group creation

texts:
I am getting the following error when a user tries to create a new group

Can't save entity as group, because user  can't be subscribed to group and become a manager.

The user is subscribed to one group and should be able to create a new one. If they are unsubscribed then this works, even if they are later subscribed.

I would like to look at this page as it may have some useful information but it has a gateway timeout

https://www.drupal.org/node/1538658

Does anyone know of a solution to this?


texts: Adding attributes to a link to an uploaded file

texts:
I have been asked to add target="_blank" to the links that are produced when a user uploads a file on a Drupal 8 site.
The field type is "File". Multiple uploads are allowed.
Twig debug shows me that the field is being produced by the core template "file-link.html.twig". The entire uncommented contents of that template are:
{{ link }}
{% if file_size %}
  {# @todo remove class before Drupal 9.0.0 #}
  ({{ file_size }})
{% endif %}

I brought that template into my custom theme and tried to add the attribute to the link. I thought I'd be editing the {{ link }} part of the template, changing it to attach attributes. I did variations of this:
{{ link(item.title, item.url, attributes.setAttribute('target','_blank')) }}
Every syntax I tried produced a fatal PHP error. Thinking I was doing the attribute syntax wrong, I tested  by simply trying to add a single class.
{{ link(item.title, item.url, { 'class': ['bananas'] }) }}

That was still a white screen of death, so I guess I can't use that syntax on the {{ link }} field in my file-link template.
I've been googling my eyeballs out of my head. I found this cool idea:
{% for item in items %}
  {{ item.content|merge({'#attributes': {'class': ['button', 'button--arrow', 'button--centered']}}) }}
{% endfor %}

so I adapted it for my field.html.twig template like so, changing this part:
{% for item in items %}

{{ item.content }}

{% endfor %}

to this:
{% for item in items %}

{{ item.content|merge({'#attributes': {'target': ['_blank']}}) }}

{% endfor %}

And while at least the page loaded and didn't have a fatal error, the target attribute did not appear on the link.
Does anyone have any advice for me getting an attribute onto a file upload link? Almost everything I've found has to do with the link field, not the file upload field. Thanks for your time.


texts:
I'm working on a site's structure and I'm not sure where to start. I could use some general advice.

My Goals:

Personal and professional groups (organic groups)
Two types of user accounts - personal/professional (profile2)
Account may contain sub-users i.e. mom dad brother sister (subuser)
Users can belong to both personal and professional groups
Users can create both personal and professional groups
Professional groups and personal groups require different fields

User X belongs to two or three groups using a personal profile but manages a professional group with a professional profile. Or vice versa.

I could put the fields I want in either the group or the profile but I'm not sure which is the better practice. A friend suggested to make a content type for the user profiles to prevent clutter with the user entity. Hell - I may be going about this all wrong.

I'm not looking for step-by-step instructions - just a push in the right direction.

Thanks


texts: Cannot get currentUser after custom Drupal boot

texts:
I have a /foo.php on the Drupal 8 root which programmatically boots Drupal:
chdir('web');
$autoloader = require_once 'autoload.php';
$request = Request::createFromGlobals();
print_r($request->cookies);             // ... ( ... ( [SSESSabfa7...] => _Eu_28jS3Vr8Y... ))
$this->kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$this->kernel->boot();
var_dump(\Drupal::currentUser()->id()); // int(0)

$this->kernel->preHandle($request);
var_dump(\Drupal::currentUser()->id()); // int(0)

The problem is that it doesn't seem to be able to access the current user (see the var_dumps). By visiting a regular Drupal URL though (e.g at / or /about) I confirm that the session cookie is correct with a logged in user.
What do I need to do so my custom PHP script boots Drupal in a way that it can return the currently logged in user?


texts: Access Value of variable content in twig template

texts:
I'm new in a Drupal 8 and using Devel kint() function for debugging. In my twig template menu--main.html.twig, I have looped for the menu items like this:-

{% for item in items %}
   {{kint(item.url)}}

The output like this:-

What I should write to print the URI, I've tried {{item.url.uri}} but not working


texts:
I'm new to Drupal 8, and was curious why some modules have a *-routing.yml file, while others don't.

Why is this the case? Does this mean that modules lacking in a *-routing.yml file don't have any routing URLs?


texts:
My question: Is it possible to reference a field to a node, and also to a user?

I want to keep track of scores scored by users while playing a boardgame. So, I'll need a reference between nodes (boardgame) and users. I'm using the "entity reference" for this.

With the module field_group and field_group_multiple, I can make rows with user field, score field, etc... But the problem here is: the score field is linked to the node, not to the user. (So if I want to make a view and get all scores scored by a player, this will be not possible.)


texts: Add extra node from nodequeue in views before rendering views content

texts:
My need is that i made a block form views which show the content from content type blog, now i want to some extra node from nodequeue to that views block on given condition.

I am tried with hook_views_pre_render, but didn't get anythings.

Thanks in advance


texts: Extract data from Field Collection using db_select()

texts:
I'd like to use db_select() to extract values from a field collection attached to the user profile, to help speed up some complex Ajax forms (rather than loading the entire field collection, using standard entity queries, etc, etc).

Assuming I have the following:

Field Collection: field_my_address
Field 1: field_street_number (integer field)
Field 2: field_street_name (text field)
Field 3: field_city (taxonomy term reference field)

How would I go about doing this?


texts: Tag Users and Taxonomy terms in body field of a post

texts:
I am building a Social Networking site in drupal. My client requirement is to tag users and taxonomies using a '$'. For example "$john" will tag a user john with that post. and "$Arts and Entertainment" should tag the Taxonomy term to the post.

I tried hashtags module. But it is for tagging the words in body with a "#". The words are tagged under a separate vocabulary called "Hashtags".

My functionality needs twitter OR facebook like tagging of both users and Taxonomies(with a autocomplete Dropdown).

For tagging the taxonomies, I have created a separate field called Industry Tags of type Term Reference in that content type. This field will store the mapping of that particular node to the Industry Terms(Taxonomy Terms). Iam not going to display this Industry Tags field in the frontend. Instead of that i have to save the terms that user enters in the Body field prefixed with "$" to in this field. Example: "$Education".

Also for tagging users i can use "User Reference" in the same manner i mentioned above for industry tags. But i need the functionality to be something similar to twitter / facebook.

Please suggest me some ideas for implementing this.


texts: Autocomplete results showing behind the form

texts:
How can I make the autocomplete search results appear above all elements on the page?

I have 2 forms on one page, the top form has the autocomplete text field. Immediately below that is another form. When the autocomplete results show, they are behind the second form.


texts: Hook to compare the already saved value of moderation state of node and updated value

texts:
I'm using Workflow state on a content type.
What is the correct HOOK should I use in my custom module to check if the workflow state of the node changed from value to another value to add some actions.


texts: Run a Drupal website offline (±without server)? --- E.g. hand it over on a usb-stick / by mail? --- Run it from the HD, while retaining functionality?

texts:
Why run Drupal offline?

Since I use free webhosting, I don't have 100% up-time, so I started wondering whether I could maintain such Drupal functionality, while at the same time working offline.

An example of an application

In general, I am talking about a more or less operational website here.

E.g., my own quest at the moment: I want to let people fill in a couple of words/lines on a Drupal website by clicking on hyperlinks at specific points in a HTML article which is created on a Drupal website - and have the input of the people saved somewhere. (I still have to find the right module / way of achieving this by the way)

1 small step to think, 1 giant leap in technology?

Any thoughts on how to go about this? Perhaps letting people "run" / temporarily host the website from their own computers? (P.S.: I would rather like to keep things as WYSIWYG as possible.)

I am not experienced in this matter, but what do you think would be perhaps missing to pull this off: the handling or online hosting of a MySQL-database; something that has to do with PHP;...?

Perhpas, cf. the following question about offline MySQL.


texts:
I have looked through multiple tutorials and I don't know what I'm missing.

I have created a new field type using the Field API and it's displaying everything perfectly, but when I try to put information in the textfield and hit save, nothing shows up on the form after the submit and nothing gets put in the database.

Can anyone tell me what I'm missing?  Here is an example of the code I've written:

in the module.install file i have:

function cptc_test_field_schema($field) {
 $columns = array(
 'field_test' => array(
   'type' => 'int',
   'unsigned' => TRUE,
   'not null' => FALSE,
 ),
);
return array('columns' => $columns);
}

and in the module.module file i put

function cptc_test_field_info(){
return array(
'field_test'=> array(
  'label' => 'test',
  'description' => 'test crap',
  'default_widget' => 'widget_test',
  'default_formatter' => 'formatter_test',
 ),
);
}

function cptc_test_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$value = isset($items[$delta]['value']) ? $items[$delta]['value'] : '';
switch($instance['widget']['type']){
case 'widget_test':
  $element['widget_test'] = $element + array(
    '#title' => 'Additional Email Addresses',
    '#type' => 'textfield',
    '#default_value' => '',
    '#size' => 60,
  );
  break;
default:
break;
}
$element['#element_validate'][] = 'cptc_test_field_widget_validate';
return $element;
}

There's a lot more to it (obviously), but figured that I shouldn't post everything - for expediency's sake. The other hooks I have implemented are:

hook_field_is_empty
hook_field_validate
hook_field_widget_error
hook_test_field_widget_info
hook_test_field_widget_validate
hook_test_field_formatter_info
hook_test_field_formatter_view

Thanks in advance!


texts:
I have created a module with its routing.yml file.

mymodule.dossier:
  path: '/dossiers/{node}/dossier'
  defaults:
    _entity_view: 'node.dossier_dossier'
  requirements:
    _permission: 'access content'

I have created a custom view mode (node.dossier_dossier) and the corresponding Twig template. If I go to dossiers/1/dossier, it works, and it displays the node with the dossier_dossier view mode and appropriate template.

node/1 has /dossiers/my-custom-path as its path alias, which is automatically set from the Pathauto module. If I try to access /dossiers/my-custom-path/dossier, it returns a Page not found error.

How can I make this route work for my nodes for both (default and path aliases) URLs?

Edit: I should maybe mention why I need that:

/dossiers/my-custom-path should display the node using the default view mode
/dossiers/my-custom-path/dossier should display the node using the dossier_dossier view mode
/dossiers/my-custom-path/abstract should display the node using yet another view mode (I'd create another route for that one presumably)


texts:
I use hook_node_access() to redirect users, if they don't have the right attributes to see a specific node.

While programming I used dpm() to check some variables and was wondering, that dpm() is called 9 times although I just opened a single node.

Well, my question is:
Is it normal, that hook_node_access is called several times for one node, so I should use drupal_static() to avoid duplicate calculations or do I have some disadvantageous loops in my code that I should detect and remove (in hook_node_access are no loops, I mean somewhere else)?

I would welcome every advise!

Thanks, Daniel


texts:
I'm searching for a hook in Drupal 8 API for adding values to a add content form.
What hook can I use to alter values from /node/add/movies_movie page?


texts:
I have a custom form, on submission of which I am calling ctools modal with a node form(content type: turn).

Code for Custom Form.

function _my_module_name_files_listing_form($form, &$form_state) {
  $form = array();
  $form_state['storage']['values'] = $files;
  $form['download_submit'] = array(
    '#type' => 'submit',
    '#value' => t('Download'),
    '#submit' => array('_my_module_name_files_download_submit'),
  );
  $form['create_segment'] = array(
    '#type' => 'submit',
    '#value' => t('Create Segment'),
    '#attributes' => array('class' => array('ctools-use-modal')),
    '#ajax' => array(
      'callback' => '_my_module_name_files_create_segment',
    ),
  );
  $form['upload_content'] = array(
    '#type' => 'submit',
    '#value' => t('Upload Content'),
    '#submit' => array('_my_module_name_files_upload_content'),
  );
  $form['delete_submit'] = array(
    '#type' => 'submit',
    '#value' => t('Delete'),
    '#submit' => array('_my_module_name_files_delete_submit'),
  );
  return $form;
}

Callback code for ajax submission rendering node form.

function _my_module_name_files_create_segment($form, &$form_state) {
  global $user;
  $form_id = 'turn_node_form';
  ctools_include('node.pages', 'node', '');
  ctools_include('ajax');
  ctools_include('modal');
  ctools_modal_add_js();
  ctools_add_js('ajax-responder');
  $destination = 'node/1';
  $form_state = array(
    'ajax' => TRUE,
    'title' => t('Form Title'),
  );
  $node = (object) array(
        'uid' => $user->uid,
        'name' => (isset($user->name) ? $user->name : ''),
        'type' => 'turn',
        'language' => LANGUAGE_NONE,
        'status' => TRUE,
  );

  $form_state['build_info']['args'] = array($node);
  $output = ctools_modal_form_wrapper($form_id, $form_state);
  if (!empty($form_state['ajax_commands'])) {
    $output = $form_state['ajax_commands'];
  }
  if (!empty($form_state['executed'])) {
    $output = array();
    // Redirect to destination.
    $output[] = ctools_ajax_command_redirect('node/8', 0);
  }
  print ajax_render($output);
  drupal_exit();
}

Problem:
Node Form is coming fine on modal and hitting save button triggers ajax call but node form does not submit. Am I missing something here?


texts: how to provide a content type variable to region--header.tpl.php

texts: I want to hide some inline html from header for specific content type. How cud I provide a content type variable to region--header.tpl.php to put a php condition to hide the html?


texts: EntityMalformedException in custom module. Can anyone see what I did wrong?

texts:
I'm trying to create a custom module and found out that it's causing the following error message to appear:

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7721 of ~/includes/common.inc).

if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
  throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
}

I'm using xdebug setup with netbeans to debug the error and found out what is causing the culprit.

I found out it was a specific field I added in my module that looks like this:

$form['base']['st-volume-pricing']['add'] = array(
'#type' => 'button',
'#value' => t('Add'),
'#name' => 'add_row',
'#limit_validation_errors' => array(
  array('price'),
  array('till-amount'),
),
'#ajax' => array(
  'callback' => 'bulk_and_user_pricing_add_volume_standard_ajax_callback',
  'wrapper' => 'error-placeholder',
  'method' => 'append',
  'effect' => 'fade',
),
'#prefix' => '<td>',
'#title' => t('Click this button to add a standard volume price'),
);

My debugger basically showed the following data:

$info['entity keys']['bundle'] = "type"
$entity_type = "node"

$entity stdClass
add string  "Add"
add_row string  "Add"
price   string  "123"
till-amount string  "123"

I checked my database and couldn't find any nodes without type so that shouldn't cause any problems.

I suppose I have to define the bundle in my code somewhere but I'm not that famillair with bundles yet.

The field is added to the node edit page of a product created by the ubercart module using hook_form_FORM_ID_alter() -> hook_form_product_node_form_alter().

Does anyone have a clue as to what I should do to define the bundle?

Or in OOP terms, how can I make my field a class member of the ubercart product bundle (which is an extended class of the entity type base class)?


texts: Which module supports select or other option for Term reference type?

texts:
Is there any module to support select or other option for Term reference type?

I tried with the Select (or other) module but its not working in Term reference type


texts:
I have the feeling that I'm doing something stupid or missing something obvious...
I want to create a block in template.php in my custom template but it is not showing in admin/structure/block
The code i use is simple:

/**
 * Implements hook_block_info().
 */
function MYTHEMENAME_block_info() {
  $blocks = array();
  $blocks['eeeeeeee'] = array(
    // The name that will appear in the block list.
    'info' => t('eeeeeeeeeee'),
  );
  return $blocks;
}

Then i created a custom module, to see if a have a typo,  with the same code. Just changed MYTHEMENAME with MYMODULENAME and I can see it in admin/structure/block

I tried changing MYTHEMENAME to phptemplate
Cleared the cache many times

Is it even possible to create a block in template.php?


texts:
I have the module.routing.yml as

entity.node.ssl_check:
  path: '/node/{node}/check-ssl'
  defaults:
  _form: '\Drupal\ssl_check\Form\SslCheck'
  _title: 'Check SSL Cert'
  requirements:
  _permission: 'access check ssl tab'

and module.links.task.yml as

 entity.node.ssl_check:
  route_name: entity.node.ssl_check
  title: 'Ssl check'
  base_route: entity.node.canonical
  weight: 15

Here when I access node/1104/check-ssl/ the form defined in the form controller is loading. But my other need that is to show a 'Ssl check' tab when I visit path /node/1104/ is not there. I have done the tab thing while dealing with Controller but not working with form controller. Please help. I have checked 'Add tab / local task to a node' this but there was nothing dealing with form controller.


texts: Update existing data in a content type from JSON file in Drupal

texts:
I have to import Latitude and Longitude data in to a Geofield that was added to an existing Content type.
Source Info
The json feed contains a lot of data fields including the Longitude, Latitude info, Title and a unique ID
I tried the following:
Feeds module
It requires an existing guid to match which I found no way to work around with existing nodes. The need here is to update. In this case the nodes already exist so I am unsure how to map them to GUID which is available only for Feeds imported nodes.
Migrate module
I am planning to explore Migrate module. What I looked at seems like this may be a complex solution and better suited when source and destination are different databases rather than the same.
Thus let me know if there is a straightforward way to import data to a new field on an existing content type. If it can support geodata, that would be a bonus.


texts: The view is not filtering the duplicate nodes

texts:
i have a view which is not filtering the duplicated nodes and i tried couple of solutions but it looks like they are not working.

The code I am using is the following.

function mymodule_views_pre_render(ViewExecutable $view) {
  if ($view->id() == 'basicnews') {
    $unique_nids = $new_results = array();

    // Loop through results and filter out duplicate results.
    foreach ($view->result as $index => $result) {
      if (!in_array($result->nid, $unique_nids)) {
        $unique_nids[] = $result->nid;
        $new_results[] = $result;
      }

      // Replace $view->result with new array. Apparently views requires sequentially keyed
      // array of results instead of skipping keys (e.g. 0, 2, 4, etc), so we can't just
      // unset the duplicates.
      $view->result = $new_results;
    }
  }
}

Is there any patch or work-around for this issue?


texts: How to create a views contextual filter of the current domain

texts:
I'm using the domain module, but have not enabled the submodule 'domain access' because I'm already using open social group access, and want to prevent performance issues. I only need to filter views
The domain, domain configuration and domain site settings are enabled.

i added an entityreference field to the 'group' entity type, which allows to choose the domain record.

Now I simply want to have a view that shows groups filtered by domain record, of which the domain is the same as the domain in the current context (as seen in url)

Views contextual filters does not give an option to choose the domain context as default filter.

Not sure if I explained it clearly enough..but how can this be accomplished?

Summarizing:
Domain module installed without domain access submodule
Only have entity reference field in group entities
Want to filter a view of groups by current domain, using contextual filter of the reference field.


texts: How do I build a relation of users having a specific role, automatically?

texts:
I have installed the Relation module. I need that users with the "test" role are related with all users having the "student" role, automatically.

How can I build this relation?


texts: How do I add two Flags counts to a a single view?

texts: I'm looking for a method where I can have two flag counts in the same view. For example: I would like to list Authors, with a count of how many other people 'follow' them, and at the same time I would like to display the number of nodes that the author has 'bookmarked'. I'm struggling to find away to do this. Any ideas would be greatly appreciated!


texts: Managed File Field and file_usage_add() - what should I attach the file to?

texts:
I'm creating a module which uses the Form API and integrates with the Mantis bugtracker system.  I have included a managed file field on the form and am at the stage of handling the form submission.  The Form API documentation mentions that you must make a call to file_usage_add:

Without the call to file_usage_add, file_managed_file_validate produces an error upon saving the form, saying that the uploaded file may not be referenced.

Here is the signature for file_usage_add():

file_usage_add(stdClass $file, $module, $type, $id, $count = 1)

And the explanation of the parameters:

$file: A file object.

$module: The name of the module using the file.

$type: The type of the object that contains the referenced file.

$id: The unique, numeric ID of the object containing the referenced file.

$count: (optional) The number of references to add to the object. Defaults to 1.

The problem I have is that my module doesn't create any nodes to attach the file to.  I just want to store the file in the filesystem and then send it off to Mantis.

Any suggestions on what I can enter for the $type and $id parameters?


texts: Webform confirmation message alternate source

texts: How can I override the default webform source for the form submission confirmation message and fetch it from a 'CCK' (I still can't remember what they are now called in D7) element instead?


texts:
I have the following form:
Displayed at Page load

$form['platform'] = array(
  '#type' => 'select',
  '#title' => t('Select a Platform'),
  '#options' => array(
    0 => t('- Select -')) + $options,
  '#default_value' =>  0,
  '#required' => TRUE,
  '#ajax' => array(
    'callback' => 'ajax_select_callback',
    'wrapper' => 'replace_model_div',
    'effect' => 'slide',
   ),
);

I'm trying to pull out the $form_state['values'] to determine if another select field should be shown. However I'm not sure how this will ever get called without a submit function.

To be Displayed after option is selected

 if (isset($form_state['values']['platform'])) {
 $platform_value = $form_state['values']['platform'];
 $sqlmodel = "SELECT tid, name FROM {taxonomy_term_data} WHERE vid = $platform_value";
 $result = db_query($sqlmodel);
 $options = array();
   foreach ($result as $row) {
     $model_options[$row->vid] = t($row->name);
    }

$form['model_wrapper'] = array(
  '#type' => 'select',
  '#title' => t('Select a Model'),
  '#options' => $model_options,
  '#options' => t('$platform_value'),
  '#prefix' => '
',
  '#suffix' => '
',
);
}
return $form;
}
function ajax_select_callback($form, $form_state) {
  return $form['model_wrapper'];
}

If I am understanding AJAX properly even though on a select change my AJAX call will happen to render the model_wrapper. There is nothing in the AJAX call that will re-evaluate the if (isset function, and as such the model_wrapper section will never display.

Full story and objective: AJAX dependent select


texts: Is there a way to tell if the current page is a node?

texts:
Without checking the URL I would like to know if the current page is a node page.  We plan on using URL aliases so we would like to not rely on the '/node/*' structure.

Is there some page variable or something that will indicate a node page?


texts: How to Create and Retrive a product programmatically in Drupal commerce 2.x

texts: I have created the store in Drupal commerce 2.x. I have added a product for the product type from the dashboard. Now i want to create Product grammatically  in  my custom module. how  this can be done Drupal 8 for Drupal commerce 2.x


texts: StringOverrides doesn't change the text in DCommerce "Add to Cart" Button

texts:
Seen a lot of references to the hook_form_alter function on how to apply this, but many of the posts are aimed at more seasoned developers. I know enough to know that I need either a custom module to change these, but I don't know where to find the form id's on the buttons to change.

I was also pointed in the direction of the StringOverrides module, but this doesn't effect the changes I want on the buttons, only where the terms I want appear in plain text, as opposed to what I'm learning is hard-coded into the Commerce Modules.

So...a) how do I find the form ids to make a module to change these buttons? and b) how to get String Overrides to actually change the text on the buttons?


texts: (search) form without redirect or submit handler

texts:
Use case:
Search field e.g. in the header, that leads to a url with GET query string.

The usual flow of forms built with Drupal 7 form API is like this:

User visits a page with the form.
User submits, $_POST or $_GET
Validate + submit handlers are called
Redirect to a new page.

What i would like instead:

User visits page with the form, that was built with form API.
User submits, resulting in a $_GET request, e.g. example.com/search?query=foo+bar.
The page example.com/search?query=foo+bar is served, without thinking about form API.

So, I want to use form API to build the form HTML (cause it's convenient), but not any submit magic.

Ideas?
Maybe I could find an example in existing modules, but I am looking for a "big picture" or documentation.


texts: EntityFieldQuery return nodes with all terms

texts:
I have form that allows a user to filter a list of results.  The filter is set using checkboxes.  EntityFieldQuery is used to retrieve the results based on taxonomy ids.  The problem is that if multiple checkboxes are selected, it returns all nodes tagged with any of the taxonomy ids, while I want only the nodes that are tagged with ALL of the taxonomy ids.  This includes terms that are from multiple taxonomies.

These are the definition of the field conditions in my EntityFieldQuery:

$query->fieldCondition('field_section', 'value', $sections, 'IN');

$query->fieldCondition('field_features', 'tid', $params['features'], 'IN');

$query->fieldCondition('field_region', 'tid', $params['regions'], 'IN');

Basically, when checking on items in the filter it returns MORE items, when it should go the other way.

Does anyone know how to adjust the EntityFieldQuery so it does what I'd like?

Thanks in advance


texts: How do I overwrite the variables in my theme?

texts:
function rate_preprocess_test(&$variables) {
  extract($variables);
  $buttons = array();
  foreach ($links as $link) {
    $button = theme('rate', $link['text'], $link['href']);
    $button .= $link['votes'];
    $buttons[] = $button;
  }
  $variables['buttons'] = $buttons;
}

I want to overwrite the $link['votes'] variable to add a <span> tag around $link['votes'].

This is the code I added to template.php, but it doesn't contain the <span> tags that I  added.

function mytheme_preprocess_test(&$variables){
    $link['votes']='<span>'.$link['votes'].'</span>';
}

I want to add the span tags around $link['votes'].


texts: When using a grouping field in an HTML list, is there a way to determine the group/loop number of the current content being rendered?

texts:
I want to be able to determine what group number is currently being processed to that I can treat the output of the first group differently than subsequent groups.
Unlike rows, I do not see a way to find the current count of groups or loops through the view such that I could, for instance, do something like the following (i.e., classing group content by group iteration) -

{{ title }}

    {% for row in rows %}

        {{- row.content -}}

    {% endfor %}

{{ title }}

    {% for row in rows %}

        {{- row.content -}}

    {% endfor %}

...

{{ title }}

    {% for row in rows %}

        {{- row.content -}}

    {% endfor %}


texts: Moving SQLite-D7 Installation to other Server throws Uncaught exception in shutdown function

texts:
When I move my Drupal7-Website (with SQLite Database) from my XAMP to another Computer also running XAMP I got the following error message.

  Uncaught exception thrown in shutdown function.

  PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a
  readonly database: DELETE FROM {semaphore} WHERE (value =
  :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0]
  => 192200923514edf6a15a484.46864520 ) in lock_release_all() (line 269 of
  /Applications/XAMPP/xamppfiles/htdocs/myd7site/includes/lock.inc).

How comes? And how to fix?
Thnx!


texts: How to pre-populate fields on a node creation form based on fields from Profile2 module?

texts:
There is a content type ("Job Listing") that a business account can use to list job openings, and a Profile2 profile for each business that contains the business's address, organization name and taxonomy terms such as industry type.

95% of the businesses that will list a job posting will use the same information; I could just use the profile information, but I need to account for the 5% that might want to change the job listing form. For example, the job might be in another state or country and that needs to be accounted for. I think the the best way to handle this situation is to have the same fields in both the profile and job listing form but allow the business change the information in the job listing form.

It would make sense to pre-populate the job listing form with business profile information as the default. How do I best do this? I was going to use Rules but I can't find a single option for a Rule before the original node creation form is created.

Should I just use hook_form_alter() to access the profile information on orginal node creation and use that information to set the default values?


texts: drush_get_commands() does not return Feature Drush commands

texts: I am expecting that drush_get_commands() will return all drush commands including from modules such as 'feature', but it is not when called within my Drush custom command. How to retrieve all drush commands available for the current drupal instance including ones provided from custom modules? Thank You


texts: "Your command line PHP installation is too old"

texts:
When trying to run Drush on my shared hosting account I get this error:

  Your command line PHP installation is too old. Drush requires at least PHP 5.3.0.
  To suppress this check, set the environment variable DRUSH_NO_MIN_PHP=1

When I type php --version, it tells me that I am running PHP 5.2.6.

The .bashrc file has the following lines

export COLUMNS
alias drush='/usr/bin/php ~/public_html/drush/drush.php'
alias php='/usr/bin/php'

How I can fix this?


texts: Get an error message "invalid file extension"

texts: I always get the error message: "Invalid file extension" when I'm trying to upload a PDF file? Does anyone know how to solve that problem?


texts: How to use Vertical Tabs on ConfigEntity Form

texts:
how are you?
I've created a ConfigEntity and there a Configuration Form with Fieldsets and Fields.
Example:

But now I want to change this form to Vertical Tabs, like that:

Do you know how can I do this?
P.s. It is for the Contrib project if you want to test it is:
https://www.drupal.org/project/modal_page