texts: Hierarchical select as radio buttons and checkboxes

texts:
I have a need to display a hierarchical select of a vocabulary as a series of radio buttons representing the top-level terms.  When the user selects one of the radio buttons, the child taxonomy terms should be displayed below as checkboxes.

Do I need to build a custom AHAH form, or can I look at form altering the default hierarchical select widget?


texts: Order of facets block change after the research

texts:
I'm new in Drupal and I have a problem when I use search ajaxified with search api and facet block.

My research works fine: When I click on the facet block that contains tags for example, my results are fine. After, my block are not anymore in the same order than before.

For instance, before I click on one tag, the order are like this (all my blocks are in the left sidebar and so in the same region):

navigation
Facet API: content type
Facet API: Tags
Saved search

After the reseach in Ajax:

navigation
Saved search
Facet API: content type
Facet API: Tags

All my Facets blocks are now at the bottom.

I followed all the instructions on Drupal.org given by the author of the module, and they worked fine, I just don't understand why my facet block are not in the same order after the ajax search. I've been trying for a couple days and cannot figure out a cause for this. Has anybody encountered this before?

Maybe I need to create another region to put only my facet block in, but I think there must be a better solution than that.


texts: Export an entity with the Migrate module

texts:
in my Drupal 8 site, I want to export certain nodes and taxonomy terms into files (JSON or XML) using the Migrate module. (The goal is to have this data in Version control, and to be able to import/update it later.)

However, I have trouble in finding any examples for exporting from Drupal to files (there are many for the other direction).

Can one of suggest me which (preferably core) plugins from Migrate I can use as source (something that reads entities, with being able to define the IDs to be exported) and also as destination (something that writes into JSON/XML or even YAML).


texts: Drush on windows xp not working, stuck with no output at all

texts:
I'm having serious trouble running drush from the command line in windows xp.

Php is working fine, and execution of some test scripts work just fine.
When i try to execute drush, both from the folder where the .bat and .php are in, and from any other folder, it seems stuck and show no output or error at all.
I tried changing the batch file to use a specific php.exe instead of relying on PATH variable but nothing changes.

How can i make it work, or at least get some error messages?

Thanks in advance for any kind of help.


texts: Adding multiple checkbox in drupal using cck

texts:
I am trying to add multiple checkbox. My requirement is how can you travel the place with

Plane
Train
Bus
Ship

One can select all the four above options. For that I added a new field Travel Details , field type Boolean , Widget Check boxes/radio buttons . From Drupal CCK

I made Number of values equal to 4 . But I am getting only two fields, also without their names ! How can I able to make this content type to behave like normal HTML checkboxes with their names ?


texts: Remove datatype attribute from meta about tag

texts:
I'm trying to validate my Drupal 7 website on http://validator.w3.org but I can't keep getting the following error:

  Attribute datatype not allowed on element meta at this point.

This is because <meta about="/frontpage" property="sioc:num_replies" content="0" datatype="xsd:integer" /> automatically gets the 'datatype=xsd:integer' attribute. I want to remove the datatype attribute altogether.


texts:
I have a custom table clinic_consultation and using the field doctor_id which is the uid from the Users table, I couldn't join the tables together to come with a name field of the Users table in the same view

here is what I did, but I can not find any solution for joining both tables to display the name field from the users table

 $data['clinic_consultations']['table']['group'] = t('clinic_consultations table');

  $data['clinic_consultations']['table']['base'] = array(
    'field' => 'consultation_id',
    'title' => t('Consultation table'),
    'help' => t('Consultation table contains all listed Consultations'),
    'weight' => -10,
  );

  $data['clinic_consultations']['consultation_id'] = array(
   'title' => t('Cons ID'),
    'help' => t('Cons ID'),
   'relationship' => array(
      'base' => 'node',
      'field' => 'consultation_id',
     'handler' => 'views_handler_relationship',
     'label' => t('Cons ID'),
   ),
);

$data['clinic_consultations']['consultation_id'] = array(
    'title' => t('Cons ID'),
    'help' => t('Cons ID.'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_numeric',
    ),
  );

  $data['clinic_consultations']['consultation_date'] = array(
    'title' => t('Cons Date'),
    'help' => t('Cons Date'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_date',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_date',
    ),
  );

   $data['clinic_consultations']['patient_id'] = array(
    'title' => t('PTN ID'),
    'help' => t('PTN ID'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );

    $data['clinic_consultations']['doctor_id'] = array(
    'title' => t('Doctor ID'),
    'help' => t('Doctor ID'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );

     $data['clinic_consultations']['consultation_type'] = array(
    'title' => t('Consultation Type'),
    'help' => t('Consultation Type'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );

    $data['clinic_consultations']['table']['join'] = array(
          'avatar' => array(
            'left_table' => 'users',
            'left_field' => 'uid',
            'field' => 'name',
            'table' => 'clinic_consultations',

        ),
      );


texts:
I'm using Services with Drupal 7 and I built a rest service with it, I also included the Privatemsg module and the Entity API module.

I can see under the my service a resource called entity_privatemsg_message it has only retrieve and index as operations.

I also found a pm_service supported in drupal threads by someusers here :
 Add Service methods .

Now I can see also the privatemsg resource in my service. but I'm missing the documentation on how to send and receive pm message over the rest service. what kind of arguments should be sent with the request.  I'm working with js/jquery to make request calls  ($.ajax).

Thanks for any help  about the private message services.


texts: When 'cron_safe_threshold' is set to 0 in settings.php, should the dropdown value on admin/config/system/cron be "Never"? or is it irrelevant?

texts:
I've installed Drupal 8.1.6. As Ultimate_Cron won't work on this site consistently or reliably, I've decided to just use Drupal's core cron, triggered externally (via /etc/crontab) rather than using Poormanscron.

The documentation on https://www.drupal.org/cron says:

  Disabling "automated cron"

  Another way to disable cron is to add the following line to your
  settings.php: $conf['cron_safe_threshold'] = 0; Note that this fixes
  the setting at admin/config/system/cron to "Never", and administrative
  users cannot override it.

I set $conf['cron_safe_threshold'] = 0; in the settings.php file, but when I go to admin/config/system/cron, I still see the following:

  Cron settings
    Run cron every 3 Hours

What does fixes the setting at admin/config/system/cron to "Never"  actually mean?

The value I see is set to "Never", and can't be changed
The value is overwritten in the {variables} table to a fixed value equal to 0, and that the displayed drop-down value on admin/config/system/cron is irrelevant

p.s.

There's gotta be an easier way to find out available $conf settings than this

1) realize that cron in Drupal8 is actually controlled by a core module

cd web/core/modules/automated_cron

2) look for any drupal::config() assignments

grep -i "drupal::config(" *.module
    $automated_cron_settings = \Drupal::config('automated_cron.settings');

3) for each one found, get set-able vars

grep -i "automated_cron_settings" *.module | grep "=>"
    '#default_value' => $automated_cron_settings->get('interval'),

NOTE: in default.settings.php

 * Example:
 * @code
 *   $conf1) realize that cron in Drupal8 is actually controlled by a core module

     cd web/core/modules/automated_cron

     2) look for any drupal::config() assignments

         grep -i "drupal::config(" *.module
                 $automated_cron_settings = \Drupal::config('automated_cron.settings');

                 3) for each one found, get set-able vars
                     grep -i "automated_cron_settings" *.module | grep "=>"
                             '#default_value' => $automated_cron_settings->get('interval'),
                             ig_directories = array(
 *     CONFIG_SYNC_DIRECTORY => '/directory/outside/webroot',
 *   );
 * @endcode
 */

Re: automated cron, no less

and, a 'simpler' method:

drush cli | grep -i cron
    automated_cron.settings
    system.cron

drush cget automated_cron.settings
    interval: 10800
    ...

drush cget system.cron
    threshold:
      requirements_warning: 172800
      requirements_error: 1209600
    ...


texts: overriding core asset ckeditor js to remove ckeditor media edit button

texts:
When embeding a media in ckeditor, using the media libray, an edit button is added.
Since the editing does not allow to modify custom fields , i would like to remove or hide that edit button.
https://www.drupal.org/project/drupal/issues/3132324

I have been trying in my admin theme to hide it using css or js , with no effect.
How could i do it ?


texts: Got error message from Deleting Vocabulary

texts:
I'm trying to delete one of the Taxonomy's Vocabulary on Drupal 7.26. It would not allow me to delete and turn out an error message. How can I fix this and be able to delete Vocabulary?

  Fatal error: Call to undefined function drpual_static_reset() in
  /sites/all/modules/metatag/metatag.module on line 271


texts: Views: Display filters as a HTML UL list of links with clean mark up

texts:
I have a View that has a filter which allows users to select nodes that contain specific taxonomy terms.

I would like to display this as a HTML list of links (<ul>). How can I do this?

Steps I have tried

1. Using Better Exposed filters

This displays a filter as links. But the links are displayed wrapped in <Div> tags instead  of a UL tag.

2. Using Views template

Using views-exposed-form.tpl.php lets you access the exposed form, but it doesn't let you access the actual widget the makes up the filter.

3. Using Custom Code

This page says you can turn a select list into links via a custom module. But it requires Javascript to make the links work, which seems bad practise to me


texts:
In Drupal 7 it is possible to use:

$field_name = 'field_name';
$field = field_read_field($field_name);
$field['locked'] = 0; // 0: unlock; 1: lock.
field_update_field($field);

How to do this in Drupal 8?


texts:
I've created a PHP program outside Drupal that inserts Terms into my Drupal installation.

define('DRUPAL_DIR', __DIR__);

use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

$autoloader = require_once DRUPAL_DIR . '/autoload.php';
$request = Request::createFromGlobals();
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$kernel->boot();

require_once DRUPAL_DIR . '/core/includes/database.inc';
require_once DRUPAL_DIR . '/core/includes/schema.inc';

$term = \Drupal\taxonomy\Entity\Term::create([
      'vid' => 'subject',
      'langcode' => 'en',
      'name' => 'Test af Tag',
      'description' => [
        'value' => '
My description.
',
        'format' => 'full_html',
      ],
      'weight' => -1,
      'parent' => array(0),
])->save();

var_dump($term);

My question is - how do I retrieve the newly created Term tid?
The var_dump only gives a

  string(9) "SAVED_NEW"

Why on earth doesn't it return the newly created Entity/Term?!?

I need it in case there will be a child Term later.
I've looked at www.drupal.org/documentation and api.drupal.org. But those pages just confuses me more :-(

Thank you very much


texts: How do I add a menu router that works even in the maintenance mode?

texts:
when a Drupal site is in maintenance mode (not due to a technical fault), users without permission cannot access any page other than /user.

Is there any special hook to define a specific menu router should be allowed in maintenance mode ?

I checked user_menu but there does not seem to be any clue about this.


texts: Taxonomy terms not mapping in D6>D7 migrate_d2d node migration

texts:
I'm using migrate_d2d to migrate content from Drupal 6 to 7. I have a taxonomy term migration and a node migration. The taxonomy term migration runs correctly and creates 11 taxonomy terms, but when the node migration runs, the terms are not being mapped.

My migration code can be reviewed here: https://gist.github.com/vinmassaro/a7bce8175aa3cafffc2035092b0fe7be

It doesn't seem to be finding anything, because when I examine the output of of $row from prepareRow, there is no [1] element in the object coming from the source. What am I missing here?

Migrate documentation says say the taxonomy terms are mapped this way, which is the format I have it in:

$this->addFieldMapping('field_taxonomy_reference', 'legacytermid')
     ->sourceMigration('LegacyTermMigration');
$this->addFieldMapping('field_taxonomy_reference:source_type')
     ->defaultValue('tid');

Thanks in advance!


texts: How to show terms in a Views in its hierarchical structure?

texts:
I have create a view to show the terms of the Products vocabulary.

I the view I set:

Format: Html list

Show: field

Fields: Taxonomy term: Name

It works fine but it the hierarchical structure is lost.

The Products vocabulary has this structure:

-Cars

--Ford

--Volvo

-Computers

--Desktop

--Laptop

But in the Views the terms lost the hierarchical structure and are listed like:

-Cars

-Ford

-Volvo

-Computers

-Desktop

-Laptop

What am I missing here??


texts: Drupal 7, Omega subtheme where to put template_feed_icons function?

texts:
I would like to alter the feed icon that appears in the built-in syndicate block. Following the basic Drupal instructions, you are supposed to copy the theme_feed_icons function to template.php and rename "theme" to whatever your theme's name is.

If I do that, I get a white screen if I use the format of "my_theme_name_alpha_feed_icons" for the function name. Any other name format doesn't have any effect. It does not matter whether I put this function in preprocess/preprocess-page.inc or in template.php.

Can someone explain how I can alter the theme_feed_icons function using Drupal 7 and an omega subtheme?


texts: download a file from a link using DrupalWebTestCase?

texts:
I'm building a module that has a file download as part of its functionality. The data in it is dynamically populated from the use of forms.

Is there a method in DrupalWebTestCase that will allow me to download it? Or do I resort to wget?


texts:
I'm working on my first module, in this module I want to show a pager to two similar nodes. (Yes I know there are modules for this but it's more complex then the above but I kept it simple to make my question more clear). I'm completely new to making modules and the way de db_select works so I need some help with keeping my code clean and simple.

I have three tables I need information from.

Table 1: node
Table 2: field_data_field_issue (referenced node)
Table 3: field_data_field_order (order of nodes field)

First I need to get the current node id. For this I use the following code:

if (arg(0) == 'node' && is_numeric(arg(1))) {
  // Get the nid
  $nid = arg(1);
}

Now I need to find the nid of the node the current node refers to. I have to do this in Table 2. So I use this query:

$subquery = db_select('field_data_field_issue', 'i');
 ->fields('i', array('field_ref_nid'))
 ->condition('entity_id', $nid)
 ->execute();
 return $subquery;

Third I need to find all nodes that have the same referenced node and order them by nid and order. So I'm going for a query with join:

$query = db_select('node', 'n');
$query->join("field_data_field_issue", "i", "n.nid = i.entity_id");
$query->join("field_data_field_order", "o", "n.nid = o.entity_id");
->fields('n', array('nid', 'title'))
->fields('o', array('field_order_value'))
->fields('i', array('field_issue_value'))
->condition('field_issue_value', $resultsubquery) //I don't know how to get the result in here?
->orderBy('nid') //First order by nid
->orderBy('field_order_value') //Then order by order
->execute();
return $query;

This is what I have till now. Things I didn't figure out yet and where I could use some help with are.

How to get the result of $subquery in $query.
Is this the way to do it? Is this clean enough and am I missing out
on something?
I need the two nodes next to the current node. So if the ordering is
(nid): 3,2,4,5,1,6,8,9 and I'm currently at node 1 I want to output
node 5 and 6.

Thanks in advance!


texts: How can I render a specific node as the content for the maintenance page?

texts: Given a nid X, how do I have Drupal render it as the content for the maintenance page?


texts: Adding a custom data-attribute to a field in Views

texts:
In a view I need to add a custom data-attribute to the row output (just like classes are added). Simply rewriting the output doesn't work because XSS attribute filtering strips the attribute.
How can I accomplish this in a reasonable way?
These answers are for D7 and do not quite cover dynamic output:

Custom attribute in views fields

How to add data attributes to view list <li> tags?


texts: Is it possible to set the sitemap option programmatically using the module Simple XML Sitemap?

texts: On my drupal instance I have enabled the module called Simple XML Sitemap. The problem now is I want to toggle the option to index certain pages programmatically. I can't find out how. Can this be done?


texts: Display views block only on user profiles

texts:
I created a views block that lists all the content a user has created. I just want this block to appear on the user's profile page, not anywhere else.

User profiles can NOT be found under www.mydomain.com/users/username but under www.mydomain.com/username, so there is not really a way to just display the block on any arg(0)-predefined path.

If I were using Profile2 (which I am NOT, as I haven't figured out a big advantage of Profile2 over the core profile module in combination with the field permissions module yet) I could simply add the contextual filter "Content: NID" and validate with content type "profile". However, my user profiles aren't nodes and so this can't be done.

Is there any way to resolve this issue without using Profile2? All my users will have one profile only and this is really the first time where I would need user profiles to be nodes.


texts: Build out a complete main nav menu for a module - not just adding one menu link

texts:
I've been finding a lot of info about how to add a menu link as part of a module.  That works fine using the route/controller & links.menu.yml file.
But I am now trying to figure out how to add a complete main menu for my module (my module is a default data & structure module).
My goal is to have x level-1 menu items and each one of those will have varying numbers of sub-menus.
Any hints or references to guides/tutorials?


texts: How can I programmatically create an user account and trigger an activation email?

texts:
I developed custom module to create users.
And I setup config account setting "Require email verification" to "Require a verification email, but let users set their password directly on the registration form" using the User registration password module.
When registering via default forms it is works fine (email verification sent to user). But when I created user via custom module API the email verification doesn't send to user.
This is my code:
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$user = User::create();
$user->setPassword($data->password);
$user->enforceIsNew();
$user->setEmail($data->email);
$user->setUsername($data->nama_ibu);
$user->set('init', $data->email);
$user->set('status', 0);
$user->set('langcode', $language);
$user->set('preferred_langcode', $language);
$user->set('preferred_admin_langcode', $language);
$user->set('langcode', $language);
$user->set("field_name", $data->nama_ibu);
$user->set("field_dob", $data->dob_year . '-' . $data->dob_month . '-' . $data->dob_date);
$user->set("field_phone", $data->phone);
// $user->activate();
$result = $user->save();

_user_mail_notify('register_no_approval_required', $user);


texts:
I am using AddtoAny buttons to share in my project, but I am using colorbox node to show the webpage I want to share, like a modal windows.

Here is the issue, when I open  the page without the colorbox node module, the addtoany buttons work smoothly, but when I use the colorbox node module, the buttons are not initialized, it looks like is missing something, or some script.

Did anyone have same behavior and how could be fixed?


texts: I display some blocks using context module and others using template. Is it possible to set block weight inside template?


texts: Drupal Commerce: this hook_form_alter snippet won´t work to hide the postal code of the addressfield. Why?

texts:
I want to programatically hide the postal code field, of the address module.

I´ve unsuccessfully tried this:

function mymodulename_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'commerce_checkout_form_checkout') {
hide($form['commerce_customer_address']['und'][0]['locality_block']['postal_code']);
}

It is not working, what´s wrong with that code? Thanks for your help!
Rosamunda


texts: URL alias with taxonomy term (multiple vocabularies). How do I choose one?

texts:
I'm trying to setup a content type that has a multiple level taxonomy vocabulary assigned. The same content has a CCK taxonomy field for other use, but I don't want to use it on the URL.

The problem is that when I put in the URL alias "[term]/[title-raw]," it selects the CCK field, not the vocabulary assigned through the Taxonomy module. I tried to change the order  of the fields, but nothing changes.

What can I do, apart from putting the other vocabulary through CCK as well?


texts: How do I prevent an entity to be saved on update depending on conditions?

texts:
I use content moderation, recently present in drupal 8 core, for editorial workflow.

I'd like to prevent the entity from being saved in an update if the current user is the author of the document.

how could I achieve that ?

this does a redirection but the entity saves still does happen

 function hook_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {

 if ($entity->getEntityTypeId() !== 'content_moderation_state' ) {
    return;
}

$article_id=$entity->get('content_entity_id')->getString();
$article = \Drupal\node\Entity\Node::load($article_id);
 if($article->bundle()=='article') {

    $author_name=$article->getOwner()->getAccountName();
    $current_user_name=\Drupal::currentUser()->getAccountName();

    $moderation_state = $entity->get('moderation_state')->getString();

    switch ($moderation_state) {
        case 'peer-reviewing':

           $author=$article->getOwner();
           $current_user=\Drupal::currentUser();

            //$entity= $entity->original;
             //if author same as current user:
            drupal_set_message(t('original author cannot be reviewer.'), 'error');
            $url = $base_url.\Drupal::service('path.current')->getPath();
            $response = new Symfony\Component\HttpFoundation\RedirectResponse($url);
            $response->send();
            return;

 }


texts:
I'd like to disallow all HTML and only allow plain text in comments across the site for all users, authenticated or not, but I still want to use other HTML filters for other content types. How can I achieve that in Drupal 8?

I've created a custom text format called "No HTML" and set it as the default format for comment bodies at admin/structure/comment/manage/comment/fields/comment.comment.comment_body. But instead of disallowing all HTML, it gives the option to change the text format to any other format available to the user.

How can I get comments to only use my "No HTML" text format for all users without disabling the other text formats for other content types?


texts: How to implement bulk pricing/discounts with Drupal Commerce?

texts:
I've been trying to find a way using Drupal Commerce to be able to give discounts on individual item prices based on quantity. For instance:

1-9 units of product A: $1.99 per unit

10-19 units of product A: $1.75 per unit

1-19 units of product B: $2.99 per unit

20-39 units of product B: $2.60 per unit

and so on and so forth. However, I haven't been able to find any documentation or modules to do this. Is there any way to do this with Rules, or any modules?


texts:
Cron seems to complete, but I get a message stating that a file could not be created.

Do you have any idea about what is causing this?


texts: How do I show content based on relationship?

texts:
There are two users A & B. A is in "friends" type relation with B. Basically what i want to achieve with this is that i want to display blog posts made by B (or any friends of A) to A.
Now the content should be displayed inside a block on user A's profile page. (Just like facebook wall where you get latest updates from friends).

I know i can achieve this using Views but can anyone point me in correct direction?

User Relationships module is what i am presently using.


texts: How to setup multisite to multisite rsync with drush?

texts:
I try to rsync between a multisite setup (local) and a multisite setup (stage). If I run a sync it will copy all sites from dev to stage but I just want the current site to be synced.

$drush rsync @dev @stage

My drush alias file is located in ~/.drush/example.aliases.drushrc.php

$aliases['local'] = array(
  'root'           => '/Users/admin/Sites/drupal',
  'uri'            => 'example.local',
  'shell-aliases'  => array(
    'dump' => '!drush sql-dump --gzip --ordered-dump'
  ),
  'path-aliases' => array(
    '%dump'          => '/Users/admin/dev-' . date('Ymdhis') . '.sql',
    '%drush'         => '/Users/admin/drush',
    '%site'          => 'sites/example/',
  ),
);

// REMOTE: STAGING
$aliases['stage']  = array(
  'remote-user'      => 'xyz',
  'remote-host'      => 'stage.example.com',
  'root'             => '/home/xyz/www/stage.example.com',
  'uri'              => 'stage.example.com',
  'path-aliases' => array(
    '%drush'         => '/home/xyz/drush',
    '%drush-script'  => '/home/xyz/drush/drush',
    '%dump-dir'      => '/Users/admin/.drush-backups/example.stage',
    '%site'          => 'sites/example/',
  ),
  'command-specific' => array(
    'sql-sync'       => array(
      'no-cache'     => TRUE,
    )
  ),
  'shell-aliases'    => array(
    'dump' => '!drush sql-dump --gzip --ordered-dump'
  ),

  // DB
  'databases' =>
  array(
    'default' =>
    array(
      'default' =>
      array(
        'database'   => 'xyz',
        'username'   => 'xyz',
        'password'   => 'xyz',
        'host'       => 'xyz',
        'port'       => 'xyz',
        'driver'     => 'mysql',
        'prefix'     => '',
      ),
    ),
  ),
);

Questions:

%site: My project folder in sites/ is called example on the local side and has the same name on the staging side. Do they need to be different?
Do i need to put all domains in site.php on my staging server? At the moment I am using just the actual setup ($sites['stage.example.com'] = 'stage.example.com';) on my staging server.
My local sites.php file:

$sites['example.local'] = 'example.local';
$sites['stage.example.com'] = 'stage.example.com';
$sites['example.com'] = 'live.example.com';

Are the directories all/ and default/ always needed?

My local Setup:

Drush 7.x dev
PHP 5.5.x
MAMP

My Server Setup:

Drush 7.x dev
PHP 5.5.x

Edit: Removed opinion based questions ;)


texts: How do I use services on server that does not support CORS?

texts:
I am using Drupal 6 for my current website. I have confirmed that the server(Pantheon) running my Drupal 6 website on nginx does not support CORS as of now.

I want to interact with this site using services from a Sencha app. If I send a post request to this site from sencha app, the Post method is converted to OPTIONS and is never converted back to Post on the server side. Due to this, no post request is completed. The sam is the case with get request too. However, if I use $.get() method, the get works perfectly. But there is no solution visible to me for post method.

Here is the sencha code making rest call to Drupal 6 site:

For GET

    Ext.Ajax.request({
                        scope:this,
                        url: 'http://test.dabeastv2.gotpantheon.com/disk/node',
                        method: 'GET',
                        //params: param,
                        disableCaching: false,
                        crossDomain:true,
                        headers: {"content-Type":"application/json"},
                        success: function (response) {
                            var responseJson = Ext.decode(response.responseText);
                            console.log(responseJson);
                            Ext.Msg.alert("Question Received", "We shall get back to you soon.");
                        },
                        failure: function (response) {
                            Ext.Msg.alert("Error","Get failed");
                        }
                    });

For POST

   Ext.Ajax.request({
                        //scope:this,
                        url: 'http://test.dabeastv2.gotpantheon.com/disk/node',
                        method: 'POST',
                        headers: {"content-Type":"application/json"},
                        params: param,
                        disableCaching: false,
                        success: function (response) {
                            var responseJson = Ext.decode(response.responseText);
                            console.log(responseJson);
                            Ext.Msg.alert("Question sent", "We shall get back to you soon.");
                        },
                        failure: function (response) {
                            Ext.Msg.alert("Error","Post failed");
                        }
                    });
                    console.log(CONTENT_HOST);

I have following big issues :

As far as I know, if CORS is not enabled, then one can use jsonp for post requests. But I dont know the exact method of using JSONP.
How to keep a check on the method conversion when a get/post call is sent using Ext.js from sencha app. By this, I mean how to keep a check either on the server side or on the client side that the requested method reaches as GET or POST and not as OPTIONS.

To say that this is not by large a server specific issue is that Drupal does the same with secha requests on localhost as well. If on localhost, the requested OPTIONS request is not converted back to POST or GET, then this has something to do with Services and Rest Server on Drupal 6 too.


texts:
I am trying to build a simple website with a blog. The website needs to have, at least, 4 languages and SEO optimization (Title Description Keywords).
Please advise me on which modules to use and if there is any how-to tutorials to do so. Are there any pre-made profiles I can use?
In the end I would like to create a profile which I will replicate for feature projects.


texts: Copy value of field into the value of a different field

texts:
How can I copy the value of one field into another during a node edit?

I'm trying to take the value of a text field and have it populate the title field.  I'm thinking I can use the Ajax framework and $form_state, but I haven't quite got it yet.  Or, is there a way to do this on submission?  The Title field is hidden so Ajax isn't required.

In case this helps, the scenario is this: user edits a node, fills in one text field and that value automatically populates the Title field in addition to the current field.


texts: How to hide "add to card" button after the product has been paid?

texts:
How to hide "add to card" button after the product has been paid for once?

I'm using Drupal Commerce.

Can somebody share the code or link?


texts: How to print entity referenced fields (node) title in node.tpl.php?

texts:
I want to print an entity referenced fields (node) title in node--customtype.tpl.php.
<?php print render($content['field_my_entity_reference']); ?> prints the field with some CSS class as below:

Entity Title

What I want to do is to print this field without any pre-defined CSS classes etc..
[field_my_entity_reference] => Array
        (
            [und] => Array
                (
                    [0] => Array
                        (
                            [target_id] => 11
                            [entity] => stdClass Object
                                (
                                    [vid] => 41
                                    [uid] => 1
                                    [title] => Entity Title
                                    [log] =>
                                    [status] => 1
                                    [comment] => 1
                                    [promote] => 0
                                    [sticky] => 0
                                    [nid] => 11
                                    [type] => project
                                    [language] => es
                                    [created] => 1466009429
                                    [changed] => 1466502663
                                    [tnid] => 0
                                    [translate] => 0
                                    [revision_timestamp] => 1466502663
                                    [revision_uid] => 1
                                    [body] => Array
                                        (
                                            [und] => Array
                                                (
                                                    [0] => Array
                                                        (
                                                            [value] =>

I tried <?php print $node->field_my_entity_reference['und'][0]['entity']['title']; ?> but it gives error:

Fatal error: Cannot use object of type stdClass as array in

How can I print the title value of entity referenced field in node.tpl.php?


texts: How to set the default language in code?

texts:
I want to set the default language during install to something other than English.
How?


texts: How can I stop a specific page in the Omega Responsive theme from being responsive

texts: I need to stop a specific page from resizing and display the styles specified in the normal stylesheet. I have an iframe that is a set width and height and will not display properly when viewed on smaller screen sizes. Is this possible?


texts: Is there a way to allow an authenticated user to add to another users post?

texts: I have a content type that uses a field collection field and I would like for one user to create the initial node, then have other users able to add field collection entries after it has been submitted. Do you have any suggestion?


texts: Are there alternative ways to creating themes in Drupal 7?

texts:
Specifically I'm looking for something as simple as having the HTML/CSS/JS theme ready as static files and then just filling in the dynamic parts using PHP/Drupal. This is more or less how WordPress and other CMSs do it.

Are there any modules or other theming engines that do this?

Thank you.


texts: CCK Select List widget with "Add another item" functionality?

texts:
With certain field types that are set to unlimited you get an "Add another item" button that lets you create as many fields as you need. If you set a field with a Select List widget to unlimited it instead gives you a select list box that has ctrl click functionality for selecting multiple.

I want to know if there's a way to make a Select List widget that is set to unlimited instead show a regular select list, and an "Add another item" button that creates further select lists.


texts:
I want to try doing Mysql Casting in my query by db_select but face to error,

$q=db_select('node','n');
          $q->join('field_data_field_cinema_type', 'fct', 'fct.entity_id = n.nid');
          $q->condition('n.type',array('movie'),'IN');
          $q->condition('fct.field_cinema_type_tid',11095,'=');
          $q->condition('cast(n.nid AS SIGNED )',11517,'>'); // also $q->condition('cast(n.nid AS SIGNED INTEGER )',11517,'>');
          $q->fields('n',array('nid','type'));
          ym((string)$q);
     $res= $q->orderBy('nid')->execute()->rowCount();

and query string

SELECT n.nid AS nid, n.type AS type FROM {node} n INNER JOIN {field_data_field_cinema_type} fct ON fct.entity_id = n.nid WHERE (n.type IN (:db_condition_placeholder_0)) AND (fct.field_cinema_type_tid = :db_condition_placeholder_1) AND (castn.nidASSIGNEDINTEGER > :db_condition_placeholder_2)

My question is how can I use Mysql Casting in db_select?Is that supported in db_select or I should use db_query on EntityQuery ?


texts: Why are my translated Select List values not shown after switching language?

texts:
I have a content type for Job Openings, which has many fields and some of them are drop-downs (select lists).

The issue is that when I switch the language (German) everything switches to the currently selected language but the data coming from select field stays in English.

I have been going over the internet and have not found anything. Any suggestions?

Notes:

All the fields are translated in the backend but they just doesn't show up (in German).
I have simple text_fields too and they are shown translated, but not the select list fields.


texts: Two concatenated links throwing an error upon attempted logout

texts:
I've looked everywhere, and can't seem to find an answer to my problem. I've written some code to toggle between a log in block and, once the user has logged in, a line of text that includes both a link to the logged-in user's profile (I have the Profile 2 module installed) and a log out link.

Both the log in block and the line of text display nicely on my site when users log in and out. The problem comes when I click on the user profile link, which takes me to the user's profile page (which is correct). But then, when I click the "log out" link while on the profile page, it throws an error, rolling the two URLs into one.

Here is the code I included on the page.tpl.php:

  <?php
    global $user;
    $var1 = $user->name;
    $var2 = 'Welcome back' . " " . '' . ucwords($user->name) . '' . " " . '|' . " " . 'Log Out';
    if ($user->uid == false) {
      print render($page['code']);
    }
    else {
  ?>

  <?php print $var2; ?>

(Not that it matters, I'm sure, but a few lines of this code are wrapped in div wrappers that this post wouldn't allow me to include.) When a user logs out from the profile page, this is the URL that results:

www.site.com/users/user/logout

Which obviously doesn't do the job of logging the user out. I want to emphasize that on every other page I've tested, the user can hit the log out link and be logged out with no problem; the issue only exists when trying to log out from the profile page. I suspect that I've coded something wrong with respect to the link HTML, but can't seem to figure out what the issue is. Any help would be much appreciated, thank you.


texts: Views random list with different css for result 1

texts:
I want to create a random list of pictures with views 3 in Drupal 7 where the first picture is larger than the other ones.

So each time I reload I have a random list and the first result is always bigger.

How do I do this?


texts: Modifying destination directory for imagefield file migrating D6->D7

texts:
I'm working on a D6->D7 site migration, and I'm having problems trying to figure out how to do a couple things with the migration of some of the files. An added wrinkle in this migration is that I'm moving the storage of the files from the local server to Amazon S3 using the S3FS module (which is really slick, BTW). The source D6 blog content type has two image fields - field_mainphoto and field_thumbailphoto. I would like to combine these fields into one multi-value image field in the blog content type in the D7 site titled field_images. The file storage locations for the two fields are main_photos/[site-date-yyyy]/[site-date-month] and thumbnail_photos/[site-date-yyyy]/[site-date-month].  The new field_images will have a storage location of images/[site-date-yyyy]/[site-date-month]. Therefore, what I need to do is twofold:

Change the destination directory from main_photos/ and thumbnail_photos/ to images/.
Combine the data from these two image fields into one image field.

In the interest of asking one question per post, this one is limited to the first one. I've been looking through all of the documentation, and the shortest and easiest way would be to implement an override of the prepare() method, and modify $entity->destination_dir.  The only thing I don't like is that it's modifying a string. Do I need to go as far as overriding MigrateDestinationFile or MigrateFileUri, or is there a simpler way to do this?

Thanks.


texts: Uploading images so that they are searchable

texts:
How would I go about uploading images so that they are searchable, and so that the search results are actually displaying the image thumbnails?

How difficult would it be to integrate this search into the site search?


texts: Limit entity reference options base on taxonomy tag

texts: I have three content types. Building, Department and Person. I connect this contents whit entity reference base on Content types. The problem is that I have a lot of persons and a lot of departments and also multiple buildings. How can I limit selection in edit mode, that I can add persons in department only from particular building wher the department is placed? My first try was to add taxonomy term (building A) to person and department placed in building A and then try to filter this in view but without a success because for building B I will need to create new Content type and add different view for same content structure. I could create Content Type "Person building A" and then filter by content type but this does not seems like a good solution.


texts: How to display data from external tables in Drupal without coding?

texts:
I want Drupal users to be able to display data from external databases. There is no processing involved, just listing the results based on filters. What Drupal 7 techniques are capable of accomplishing this?

I am not interested in anything that requires coding, just using the admin modules. A little coding at the start to configure access to the external databases is fine, but the main linking and displaying shouldn't require coding.


texts:
We need to output a list of all products with all options. Example:

5 models of bicycles -- The Product
Each model comes in three different wheel sizes (and wheel size option might vary by model) -- Wheel Size option type with specific options
Each model might also have other options, such as with or without basket

So the list might be:

Model A 26"
Model A 26" with basket
Model A 28"
Model A 28" with basket
Model A 30"
Model A 30" with basket
Model B 24"
Model B 26"

and so forth.

I figured that I could create an Commerce Option view, then add a relationship to the product so that I could add the title/name field from Product to generate the list. But Relationship doesn't have an option to create a relationship to the Commerce Product.

In reality, there are something like 9,000 various options for the entire product line so a method of automating the list is important. After the view is successfully set up, we'll be exporting once and never used again. Any help is appreciated!


texts: Solr ignoring NOT but works with "-" and "!"

texts:
I have a apachesolr module which works well except in one case. I'm not sure what happens when NOT is entered in query, it behaves as OR. It even works for ! and - case.

For eg.

"apple" -"orange" //Results that only has "apple" but not "orange"
"apple" NOT "orange" //Results all the entities that has either "apple" or "oranges"

I have the a very similar installation on another site which seems to work without flaw. Any thoughts on what might be causing this?


texts:
In Drupal 6 I used the following snippet of code in my .htaccess file to extract information from a non-existent URL and pass it to an existing URL in a GET form. However, it isn't rewriting the URL with my Drupal 7 installation and when I visit a URL the should be rewritten, I just get a Page Not Found error! I have cleared all caches and even tried different browsers:

# Custom Rewrite  ScriptOptions +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^home/code/([^/]+) home/software?code=$1 [L,NC,QSA]

I have placed the code just after the default handler is set.

Could anyone tell me why this code isn't working? Should I be doing this a different way in Drupal 7?

UPDATE: Please see the question I asked on Stackoverflow to get this code working with Drupal 6 - https://stackoverflow.com/questions/10765799/rewrite-a-url-to-include-get-data-with-drupal


texts: Displaying user's default image with User Picture Field module

texts:
I am installing the User Picture Field module to take over the Drupal default user picture but it does not display the default user image when empty (D7, Bartik.)

What snippet should I add to the page--user--edit.tpl.php template so that the uploaded user picture is displayed OR the default "nophoto.jpg" file when the user has NOT uploaded a picture.

I can do the first part and display the uploaded picture but I can't get the "nophoto.jpg" to display. The "nophoto.jpg" is located in public://pictures/nophoto.jpg and I do not use image styles.

Any and all help is appreciated.  Thank you :)


texts: How to disallow some emails in Drupal 7?

texts:
Some temporary emails are frequently used by human spammers and I want to disallow them either from registration or posting.

I know that there is a similar question here but that one is for D6 and did not work for me. I'd like to do that in D7. Appreciate your help.


texts: Issue using search_api_ranges with search_api_ajax

texts:
I have set up search_api_solr - integrating search_api_ajax, facetapi and search_api_ranges into the results for a better flow.

I keep hitting an issue with regards to search_api_ranges where initially, for example; when a search runs on a taxonomy view which returns indexed nodes with the tag 'toyota', the link is always originally structured as:

mysite.com/car-tags/toyota/field_car_price/%5B1000%20TO%202000%5D

When clicking this, a 404 page not found is returned.

However! If I run the search again, this time clicking around the other facets - seeing the ajax working nicely, it's as if something triggers the ranges api, and each link is now:

 mysite.com/search_api_ajax/taxonomy/term/2/field_car_price/%5B1000%20TO%202000%5D

When clicking this, the ajax works fine.

Anyone come across this before?


texts:
I have a content type with an entity reference field (I suppose a term reference field would work as well).  The target type is a taxonomy term.  The taxonomy term has a name and ID field (among others).  My feeds source that I would like to import has the taxonomy ids that I can import but I'd like to display the name not the id.  My problem is I can't get the feeds map correctly unless I have a list of names in my feeds source, not ids.

Thanks
Sharon


texts:
Below is the array in my hook_menu

The only issue that I have with it is that the titles are not displaying for tabs pages (the last three array collections).

They are showing the title for the parent: 'Affiliate Hoover Home page'.

I've tried title callback instead but that isn't working

$items['admin/config/affiliate_hoover'] = array(
    'title' => 'Affiliate Hoover Home page',
    'page callback' => 'drupal_get_form',
    'description' => 'This is the affiliate hoover homepage - add shit here',
    'access arguments' => array('access content'),
    'page arguments' => array('affiliate_hoover_first_form'),
    'file' => 'affiliate_hoover.home.inc',
    'menu_name' => 'Affiliate Hoover',
    'type' => MENU_NORMAL_ITEM,
    );

$items['admin/config/affiliate_hoover/uniquename/%'] = array(
    'page callback' => 'affiliate_hoover_unique_name',
    'access arguments' => array('access content'),
    'page arguments' => array(4),
    'file' => 'affiliate_hoover.uniquename.inc',
    'type' => MENU_VISIBLE_IN_BREADCRUMB,
    'title callback' => 'affiliate_hoover_uniquename_title_callback',
    'title arguments' => array(4),
    );

$items['admin/config/affiliate_hoover/uniqueform/%'] = array(
    'page callback' => 'affiliate_hoover_unique_form',
    'access arguments' => array('access content'),
    'page arguments' => array(4),
    'file' => 'affiliate_hoover.uniqueform.inc',
    'type' => MENU_VISIBLE_IN_BREADCRUMB,
    'title callback' => 'affiliate_hoover_unique_form_title_callback',
    'title arguments' => array(4),
    );

$items['admin/config/affiliate_hoover/ajax'] = array(
    'type' => MENU_CALLBACK,
    'file' => 'affiliate_hoover.ajax.inc',
    'page callback' => 'affiliate_hoover_ajax_callback',
    'access arguments' => array('access content'),
    );

$items['admin/config/affiliate_hoover/'] = array(
    'title' => 'Home',
    'type' => MENU_LOCAL_TASK,
    'access callback' => TRUE,
    'weight' => -10);

$items['admin/config/affiliate_hoover/delete'] = array(
    'title' => 'Delete',
    'type' => MENU_LOCAL_TASK,
    'file' => 'affiliate_hoover.delete.inc',
    'page callback' => 'affiliate_hoover_delete_page',
    'access callback' => TRUE,
    );

$items['admin/config/affiliate_hoover/log'] = array(
    'title' => 'Log',
    'type' => MENU_LOCAL_TASK,
    'file' => 'affiliate_hoover.log.inc',
    'page callback' => 'affiliate_hoover_log_page',
    'access callback' => TRUE,
    );

$items['admin/config/affiliate_hoover/tracking'] = array(
    'title' => 'Tracking',
    'type' => MENU_LOCAL_TASK,
    'file' => 'affiliate_hoover.tracking.inc',
    'page callback' => 'affiliate_hoover_tracking_page',
    'access callback' => TRUE,
    );

return $items;


texts: Need clarification on installing site with DRUSH on localhost

texts:
I have read tutorials and drushcommands site, but I'm missing something...

My desired info is as follows:

Database name: scratch
Database username: scratch
Database password: 1
Account name: scratch (admin login?)
Account password: 1  (admin password?)
Site in English

I have the username set up in PHP my admin, desired website URL is localhost/scratch

My Drush command is:

drush dl drupal-7.x
drush site-install --db-su:scratch --db-su-pw:1 --account-name:scratch
--account-pass:1 --account-mail:founder@satearn.com --locale:EN

Am I missing something? I'm getting these errors:

  e:\xampp-portable\htdocs>drush site-install --db-su:scratch
  --db-su-pw:1 --account-name:scratch --account-pass:1 --account-mail:founder@satearn.com --locale:EN

  Command site-install needs a higher bootstrap level to run - you will     need to invoke drush from a more functional Drupal environment to run this command.

  The drush command 'site-install' could not be executed. [error]


texts:
I want to fetch student result from database, by asking user to enter roll number and name. I have created a webform to take inputs but I don't know how to fetch the records from the database and display it in tabular form. Kindly tell how to fetch the record and display it.

One thing I tried is create a form in basic page content type using HTML and do the required using PHP, but I cannot figure out how to do if the form is created using Webforms.


texts: Conditional 404 response based on inclusion of /node/# in URL

texts:
I've been requested by a client to completely block the URLs that contain a /node/## after the hostname to prevent these locations from being indexed by search engines.  My issue is that I've already defined a Page Not Found node that gets shown with error 404s.

I've already implemented a modification in the robots.txt file to include

Disallow: /node/
Disallow: /?q=node/

to prevent the web-crawler bots.  However, the URLs are still directly accessible.  So in this case, the client wants two different 404 actions:

www.clientname.com/testttt -> Drupal renders 404 page
www.clientname.com/node/897 -> blocked completely without returning Drupal's 404 page.

Does any module allow for this kind of functionality?


texts: Drupal Coding - Menus - hook_menu is not generating menus

texts:
While working on the layout of a new custom menu, I discovered that the hook_menu process is not working on my D7.12 local site.  As a test I enabled the Menu_example module and found that it will not generate menu items in the navigation menu, although it did a week or two ago.  So far I have reinstalled all Drupal 7.12 files and confirmed that the module file hook_menus are being read (using dsm).  I am at a loss as to what else can be preventing the menu links from being installed.

Does anyone have any similar experiences or suggestions on how to track this problem down to its source?

EDIT:
This code does not add a menu item in an empty menu called "Stuff":

function material_menu_menu (){
  $items['stuff/existing'] = array(
    'title' => '020000 Existing',
    'page callback' => 'material_view' ,
    'page arguments' => array ('sum' , '020000 '),
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'Stuff',
    'access callback' => TRUE,
    'weight' => '2 ');
  return $items;
}


texts:
I've followed different tutorials but I cannot seem to override a field on my webform via a function in template.php.

  Theme is called: 'myTheme' Id of the form is:
  'webform_client_form_76' Id of the input:
  'edit-submitted-henkilotiedot-etunimi' Name of the input:
  'submitted[henkilotiedot][etunimi]'

The function I think should work:

function myTheme_webform_form_76 (&$vars) {
    $vars['form']['submitted']['edit-submitted-henkilotiedot-etunimi']['#value'] = t('Name');
}

What is the correct format to override webform elements?


texts:
If I add the following:

      function MYTHEME_preprocess_user_picture(&$variables) {
      $variables['user_picture'] = theme('image_style', array('style_name' => 'thumbnail_scale_n_crop_120_x_120', 'path' => $filepath, 'alt' => $alt, 'title' => $alt));
}

to my comment.tpl.php (the purpose of which is to use an image style on the comment author's picture,) I get a WSOD with the following message:

Fatal error: Cannot redeclare MYTHEME_preprocess_user_picture() (previously declared in /home3/zc1/public_html/sites/all/themes/mytheme/comment.tpl.php:8) in /home3/zc1/public_html/sites/all/themes/mytheme/comment.tpl.php on line 12

Now, I know this error normally indicates a duplicate of the function. But in this case it seems to indicate that the duplication is in the same comment.tpl.php file. And I can't see it.

Here is the file, with the added code included:

<?php ?>
<div class="<?php print $classes . ' ' . $zebra; ?>"<?php print $attributes; ?>>

<?php
  function MYTHEME_preprocess_user_picture(&$variables) {
$variables['user_picture'] = theme('image_style', array('style_name' => 'thumbnail_scale_n_crop_120_x_120', 'path' => $filepath, 'alt' => $alt, 'title' => $alt));
} ?>
<?php print $picture ?>
<?php print $submitted ?>

  <?php print $signature ?>

<div class="content"<?php print $content_attributes; ?>>
<?php if ($new): ?>
  <?php print drupal_ucfirst($new) ?>
<?php endif; ?>
    <?php hide($content['links']); print render($content); ?>
<?php if ($signature): ?>
<?php endif; ?>

<?php print render($content['links']) ?>

Any idea what's going on?

This is Drupal 7 and I use Bartik.

Any and all help is greatly appreciated. Thank you. :)


texts: Call apachesolr_mark_entity without node_save

texts:
I need your advise. I have this code:

$nid = 5; //example
$engine = 'mustang';
$node = new stdClass();
$node->nid = $nid;          // node id
$node->type = 'car';  // aka content type
$node->engine[LANGUAGE_NONE][0]['value'] = $engine;
field_attach_update('node', $node);
//send to solr
apachesolr_mark_entity('node', $nid);

The code was used to update a field called engine in content type car without using node_save(). This way is used because more lightweight then calling using node_load() and then node_save().

But unfortunately I can not send the entity to solr using apachesolr_mark_entity(). apachesolr_mark_entity() needs node_save() to work.

How to allow apachesolr_mark_entity() works although I don't use node_save()?


texts:
I have a taxonomy vocabulary with 4 terms. One of the content types has a term reference field to tag a node with a single term from that vocabulary. Now, I want to have Views (3.5) generate a navigation block for me which would list the terms in the following way: skip item 4 and merge item 2 & 3 into a custom item labeled, say "Item 2 & 3", as in:

Item 1
Item 2 & 3  [linked accordingly: taxonomy/term/2+3]

Of course, with eventually 2 items in a block, I could do that statically, I know. However the vocabulary may grow and would like to have a scalable, dynamic solution. Hence my question: is that possible?


texts: Email Notification to Store Owner When Order Complete

texts: During early development I had it working so the store owner would get an email when an order was completed. I just realized this isn't working anymore. Where are the settings related to this? Is it supposed to use the store's email, or something else?


texts: Show newest nodes for each taxonomy term in Views

texts:
A block with taxonomy terms and an overview of the newest nodes for each taxonomy term. Every news sites uses this idea.

Business: Article 1, Article 2
Technology: Article 1, Article 2
Sports: Article 1, Article 2

Only article 1 for every node has a teaser and picture...

Any idea how to do this with just one view? You can make a view for each term, but I don't like that idea...


texts: Limit options when creating content according to selected value

texts:
I have three content types, Events, Disciplines and Championships. An Event has entity references to Disciplines and Championships and Championship has an entity reference to Disciplines.

 ----- 1..n    1..n ------------
|Event|------------|Championship|
 -----              ------------
   |0..n               |0..n
   |                   |
   |                   |
   |1..n               |
 ---------- 1          |
|Discipline|-----------/
 ----------

When users are creating new Event nodes they initially select which Disciplines are involved from a list of checkboxes and then similarly the Championship(s) involved.

At the moment all Championships nodes appear, allowing users to potentially select Championships for Disciplines which are not part of the Event.

Is it possible to use the conditional fields module to create a dependency to display only Championships where the Championship's Discipline field matches the Discipline(s) selected when the dependency is triggered?

How would one fill the 'Set of values' in the conditional fields module?

For example when creating Event1, I select DisciplineA and DisciplineB. The list of Championships should only contain those which have DisciplineA or DisciplineB associations and not contain any Championships that do not have the correct associations

if event.disciplines were a list of selected disciplines I'd like something along these lines (with the dynamic aspects of conditional fields)

SELECT championships c WHERE c.discipline IN (event.disciplines)

edit

Dependent Fields seems to do the sort of thing i'd like but there's no D7 version...

edit 2

Changed the structure a little.

I suppose Discipline didn't need to be an entity in itself and have created a taxonomy vocabulary Discipline instead with terms for each discipline. Event and Championship now have term references to the same field_discipline.

Using the Reference field limit option module the Championship entity reference in Event has the 'Limit this field's options according to the matching field values' option selected and the matching field being discipline (field_discipline).

When creating an Event the list of Championships is empty but when I select the Discipline(s) the expected Championships do not appear.

No options are available for the current form values. Try selecting different values for the following fields: discipline.

edit 3...

Firebug suggested that the ajax wasn't actually firing for checkbox/radio button but was for select menu. Applied this patch and the section is now updating but still not finding any values. There are appropriate Championship nodes to find.

edit 4!

The Championship nodes didn't have the discipline taxonomies selected...


texts: How do i configure admin email on a shared host? where is that email going?

texts:
Can someone explain where the admin emails go once the site is up and running? how does it integrate with email accounts on a shared hosting environment?

to test i sent an email to admin@mynewwebsite.com and it didn't bounce. but also, on the shared hosting account no such email address exists.

not sure really where it's going at this point?

any help or advice would be appreciated.


texts: Problem with trailing slash and global redirect

texts:
I have a site with some languages, with language prefix enabled.
I wanted the homepage url will be with trailing slash (i.e /en/), so i installed the trailing slash module.

I also want that users who entered my site without language prefix will redirect to the url with the prefix (i.e www.mysite.com -> www.mysite.com/en/), so i istalled th global redirect module, which works well without the trailing slash module.

When the two modules enabled, the redirection in the home page not working. Does someone has solution for this?


texts: Display a user's responses to a webform in the webform but uneditable

texts:
Use-case: The user completes the webform but is still able to view it, in the webform structure, but uneditable. They finished it, they can't change it.

I know we can add a "lock" to a completed webform submission using an action handler, but I've played around with various options and I just can't see any  way to do this.

Is it a matter of creating a wrapper theme, maybe, that sets every element to readonly?


texts: Adding extra attributes to webform input element

texts:
I am looking to run javascript for a textbox on a webform. I am looking to add an extra attribute to my webform, but I am not sure how the webform is rendered . I was able to do that for my cck form using hook form alter but unable to do that for a webform.

Simply I have

<input type="text" maxlength="128" name="submitted[school_name_cancer]" id="edit-submitted-school-name-cancer" size="32" value="" class="form-text required" />

But I would like

<input type="text" maxlength="128" name="submitted[school_name_cancer]" id="edit-submitted-school-name-cancer" onkeyup="lookup(this.value);'" size="32" value="" class="form-text required" />

Thanks.


texts: How can I fix a migration input format mess?

texts:
I did a migration from Drupal 6 to Drupal 8 and now I have two Full HTML, two Plain text, and all other individual for both versions of Drupal default text formats. Of course when I try to modify the duplicates I have warning that it is not possible to have the same human readable names so I have Full HTML and Full HTML2 now. I want to get rid the one of them. It looks like that all the migrated by me content is with a text format with a machine name 2 while the other Full HTML text format with no any content in the website is with the machine name full_html. Also the default Plain Text, the one that it is not possible to be removed is with a machine name 3.

As far as understand by the research I did, even if I disable the full_html text format, I cannot use its machine name for the other one. I don't mind what the name is, but can I safely change somehow the text format machine name 2 to something more meaningful?

Is it necessary to do so, or it will be fine if I leave it this way and just remove the full_html one as far as I do not need it?


texts: I just found out that when I try to submit a form with AJAX, in that instance user_login, the redirection doesn't work anymore. Is this normal? How can I make the redirection happen after the AJAX request comes back?


texts: Enable modules across platforms using Features/Drush

texts:
I am wondering, could this be automated.

I download and enable contrib modules on @dev
I push files on @live (including new modules)
via Features/Drush I tell @live to enable new modules, so servers are in sync.

I do some needed disabling/enabling of dev modules when doing sql-sync to @dev, but this is case when I install new modules on @dev and want them on @live automagically when I commit.

I could, of course, do drush @live en [modulename] for each module I installed on dev.


texts: how to give edit permission content to new user in drupal?

texts:
I have a content type called "company." I have uploaded a lot of company details to the site by myself.

Now I want that people employed by these companies create new accounts in my site, and they should be allowed to edit the details for the company where they work.
I need to give the permission for editing the "company" nodes in my site to new users.

Can you tell me how to implement this?


texts:
I created a custom field with the following definition:

  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {

    $value = isset($items[$delta]->value) ? $items[$delta]->value : '';

    $element += [
      '#type' => 'select',
      '#title' => $this->t('Select item'),
      '#options' => [
        'empty' => $this->t('Select an item'),
        'key1' => $this->t('value1'),
        'key2' => $this->t('value2'),
        'key3' => $this->t('value3'),
      ],
      '#suffix' => '

',
      '#attributes' => ['class' => ['edit-custom-field-widget']],
      '#attached' => [
        'library' => [
          'custom_field/my_js_custom_field',
        ],
      ],
    ];

    return ['value' => $element];
  }

In Formatter class I wrote this:

  public function viewElements(FieldItemListInterface $items, $langcode) {
    $elements = [];

    foreach ($items as $delta => $item) {
        $elements[$delta] = [
          '#type' => 'html_tag',
          '#tag' => 'p',
          '#value' => $item->value,
      ];
    }
    return $elements;
  }

When I show content type item with my custom field I see

"key1" but I would like to see: "value1"

Is it possible to show "value1" directly or are other operations necessary?


texts:
I'm having some problems with my forum, I messed up my lay out and can't seem to get it back. Reinstalling the Advanced Forum module doesn't help.

Does anyone know how to get my text to the right, in other words next to the red line I drew? Also it doesn't register my 'enter' clicks, so a reply is just plain text without structure.

Thanks


texts: How to correct my rule to update user info on login using HybridAuth?

texts:
I'm using Drupal 7.5x and the HybridAuth Social Login module.

I am aware a lot of users have done this using Rules and Rules Event HybridAuth login, combined with Set a data value. However no one explains what comes after, it seems the Hybridauth tokens are either not editable or just invalid.

So I am using the the Rules Event User logged in through HybridAuth, and I want to set a data value. Here is an export of the rule I have so far:

{ "rules_updateinfo" : {
    "LABEL" : "updateinfo",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "login" ],
    "REQUIRES" : [ "hybridauth" ],
    "ON" : { "hybridauth_user_login" : [] },
    "DO" : []
  }
}

I want to update the token user:hybridauth:profileURL with the new data provided by the API (= hybridauth:profileURL). However when trying to input any of these tokens into the data selector, either of the following errors show up:

If I use Data selector: hybridauth:profileURL, the error is:

  "The selected data property doesn't support writing."

If I use Data selector: user:hybridauth:profileURL, the error is:

  "Data selector user:hybridauth:profileURL for parameter data is invalid."

I'm sure I'm doing something wrong, can someone help me to get such rule to work? Is it even possible?


texts: https - Works for the homepage but fails for all other pages

texts:
Running D7 7.43 on Debian 8 with Apache 2.4.10. Everything seems to be set up properly to run https. I go to my dev site https://example.com and all is great. But the moment I go anywhere else (e.g. https://example.com/WhatEverpage_I_go_To I get error 404,

The requested URL /WhatEverpage_I_go_To was not found on this server.

I seem so close but yet not there yet. Where do I look to get this thing working for any page on my site, not just the homepage?

Important note, I changed /etc/apache2/site-enabled/default-ssl.conf

From
DocumentRoot /var/www/html

To
DocumentRoot /var/www/drupal

Before doing that not even the homepage would work.

Thanks.


texts: Showing both original base price and calculated price (inc. taxes), when using two price fields and rules

texts:
Building a webshop for customer with Drupal 7 + commerce. I've defined two price fields for commerce product entity:
1) base price (excluding tax) that is wholesale price
2) retailer price (excluding tax)

There is a rule with a condition "current user has role reseller" and action that sets retailer price as base price. This works perfectly, showing different price for logged in resellers. Also, there's a rule for tax calculation.

Now, the problem comes when trying to show both wholesale price and reseller price on the product pages including taxes. Because prices are overwritten by rules, "original" base price is not available anymore. I've tried to figure out how to do this programmatically since "Commerce price savings formatter"-module does not work with this kind of price structure. (tested price savings formatter module with discount rules, we are also using and it works well)

I'm quite lost where this should be done, should I change it in product node template (or template.php with some hook)? I can find the the original price without tax by going really deep in the content array. But I would need the tax too, at least the percent so I can do the calculations.

Any help, even tiny hints are much appreciated!

EDIT:
The working rule that sets the retailer price is defined as follows:

EVENT:
 * Calculating the sell price of a product

CONDITIONS:
 * User has role (=retailer)

ACTIONS:
 * "Product has special price"-component
   * Parameter:[commerce-line-item] (named as "product line item")

Then I have custom component "Product has special price"-component

CONDITIONS:
 * Data comparison: [product-line-item:type] = Product

ACTIONS:
 * Set the unit price to a specific amount
   *  Parameter:  [product-line-item]
   *  Amount: [product-line-item:commerce-product:field-retailer-price:amount]


texts: Drupal 7 - Webform 3 - How do you expose form results to Views Easily?

texts: What is a good module to use to expose Webform 3.x results to views? I want to create a views page with links to each form submission so search engine spiders can crawl and index user submitted questions.


texts: Print module download pdf file name change characters into HTML entities

texts:
I am using print module to generate pdf using dompdf library. I am facing issue with file name which node title have ampersand(&) sign, this character is converting into &amp;.

For example- If file name is hello & drupal then the file name become hello &amp; drupal - 2019-04-23

My filename filename configuration is as attached image.


texts:
I see that triggers page is changed from the version 6, It's pretty wierd..
I can't find When user logs in execute a php code thing...

What I have to do is exactly that..
control some user roles depending on his location (intranet or internet)
I already have the php code developed but...can't find how to put it ....

$usr = user_load($uid);

$array_roles=array();
//supose i'm logging in from internet
    $details = array(
        'uid' => $uid,
        'roles' => array(
            21 => 'Internet'
            )
        );

foreach($usr->roles as $key=>$value)
{

 if ($key!=20 and $key!=21) // exclude internet or intranet roles
 {

  $details['roles'][$key]=$value;
 }
}

user_save($usr, $details);


texts: Administrative page still accessible by anonymous users?

texts:
It's almost 2 years I don't program modules in D7.
I'm creating a module that shows 2 forms.
One is public (and to's working) and one is a setup form under /admin space.
The issue is that the one in the admin still accessible to anonymous, even when I check the checkbox into the "permission" page.
Could you help me please to find out what I miss?

Please here part of the code

function MyModule_permission() {
  return array(
    'administer MyModule' => array(
      'title' => t('Administer MyModulemodule'),
      'description' => t('Perform administration tasks for MyModule module.')
    ),
  );
}

here below the address of the 2 forms

/**
 * Implements hook_menu().
 *
 * Displays module information.
 */
function MyModule_menu() {
  $items = array();

  // It should be accessible by everybody
  $items['fillin'] = array(
    'title' => 'Participation Data',
    'description' => 'Please fill here below the fields in',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('MyModule_form'),
    'access callback' => TRUE
  );

  // it should be accessible only by admin
  $items['admin/config/setup_collection'] = array(
    'title' => 'Participation Text',
    'description' => 'Text for the presentation',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('MyModule_setup_form'),
    'access arguments' => array('administer'),
    'type' => MENU_CALLBACK,
    'access callback' => TRUE
  );

  return $items;
}

Here below the setup form with the default content, that should be accessible only by the administrator

/**
 * Implement hook_form()
 *
 * Creates the form for the setup page
 *
 */
function MyModule_setup_form($form, &$form_state) {
  $form['MyModule_message'] = array(
    '#type' => 'textarea',
    '#title' => t('TEXT '),
    '#wysiwyg' => TRUE,
    '#default_value' => variable_get('MyModule_message', 'Subscribe fill in the form below'),
  );

  $form['submit_button'] = array(
    '#type' => 'submit',
    '#value' => t('SUBMIT'),
  );
  return $form;
}

Here below just a part of the form accessible by the anonymous user

/**
 * Implements hook_form().
 *
 * Creates the form for the user.
 */
function MyModule_form($form, &$form_state) {

  global $conf;

  $form['MyModule_main_message']['hello'] = array(
    '#markup' => variable_get('MyModule_message'),
  );

  $form['first_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Put your first name'),
    '#size' => 50,
    '#maxlength' => 50,
    '#required' => TRUE,
  );

            ...
            ...
            ...


texts: Create imagefield and set min width and height programmatically

texts:
I've created an image field programmatically in Drupal 7. I want to set a minimum width and a minimum height on the image, so it checks whether the image is large enough.

The imagefield I've created:

$form['box_image'] = array(
    '#type' => 'media',
    '#title' => t('Image'),
    '#default_value' => isset($content['settings']['box_image']) ? $content['settings']['box_image'] : '',
    '#theme' => 'media_widget',
    '#media_options' => array(
      'global' => array(
        'types' => array('image'),
        'schemes' => array(
          'public' => 'public',
        ),
        'file_extensions' => 'png gif jpg jpeg',
        'max_filesize' => '500 KB',
        'uri_scheme' => 'public',
        // Can I set the min width and height here?
      ),
    ),
);

Is this possible? Thanks.


texts: Template suggestions for file_entity.tpl.php

texts:
Short version

My aim is to theme a file field in a view of node fields. In the view configuration, the field formatter is set to Rendered file and a view mode is selected. How do I suggest a template file?

Long version

What I see is, theming of a file entity is done through file_entity.tpl.php in file_entity module. I copied this file to my theme folder and tried following names:

file_entity--my-view-mode.tpl.php
file-entity--my-view-mode.tpl.php
file_entity--views--my-view-mode.tpl.php
file-entity--views--my-view-mode.tpl.php

None worked. So I tried to hook in some suggestions like below as view_mode_templates.module also does.

<?php
MYTHEME_preprocess(&$vars){
  $vars['theme_hook_suggestions'][] = 'file_entity__views__my_view_mode';
}
?>

This ends up loading that file-entity--views--my-view-mode.tpl.php but funnily I get an error like this:

  Fatal error: Only variables can be passed by reference in
  blah/blah/file-entity--views--my-view-mode.tpl.php on line 71

Which is actually this line:

hide($content['links']);

Funnier thing is if I comment that line out, I get a fatality masterkill WSOD with no error message.

If I try to do it like below, again as view_mode_templates.module does, it doesn't see the suggestion.

<?php
function MYTHEME_preprocess(&$vars) {
  if (array_key_exists('file_entity', entity_get_info())) {
    $vars['theme_hook_suggestions'][] = 'file_entity__views__my_view_mode';
  }
}
?>

So, does it maybe not suggest the theme suggestion in the correct place? Do I need to suggest this in something like template_preprocess_file_entity(&$variables) or template_preprocess_entity(&$variables)? Which don't have the appropriate $vars['theme_hook_suggestions'] array as far as I couldn't see.

Any comment is hardcore appreciated, thanks.


texts: Programming Layout Changes into Theme Templates & CSS Files

texts:
I've kicked a problem down the road for too long and am now stuck in the fact that I finally need to get it fixed.

I need to program layout changes into the php code so that the right CSS rules can apply to changes based on whether or not the left sidebar and/or the right sidebar is present on the page. In these sidebars are a variety of blocks that I have added to the templates and theme .info file.

So here's an example of my situation. If you need access to my current template files let me know.

So for one page, say I have one side bar the main content area, the css rules would read : Left_Sidebar (width: 33%) and Main_Content (width 66%). But when switching pages, say to one without a sidebar, I want the css rule for Main_Content to be (width: 100%).

I've seen it done on other themes, but this theme is all of my own design. Some examples I've seen are in the "body class" where you see "with-sidebar", "no-sidebar", "two-sidebars" -----

I've tried looking around, but I must be not using the correct terms for what it is I'd like to do. If there is anyone who can help, please let me know! Thank you in advance!


texts:
I want to disable the default front page, that is showing a list of nodes. I use another front page but it is still displayed at the url example.com/node. Either restricting access or redirecting to the front page would be fine.

My homepage is currently set to /home (which gets nicely rewritten to example.com/). Now I have already tried a few different things.

Under /admin/config/search/path, I have set an alias from node to home.
Unfortunately this just resulted in redirecting both example.com and example.com/node to example.com/home, showing the node list - not my front page.
I tried with an alias from node to <front> (I don't know if that is even valid there). This almost worked, /home and /node both redirect to example.com showing the right page. But now the node list is available at /<front> ...
I also tried with panels, creating a variant of node template. Returning a status code when the  path was equals node did not work, I guess because the page is only triggered on /node/, with a slash. It won't let me create a panel just for the node path as the path is already in use of course.
There doesn't seem to be any permission for setting access to this list.

So, how can I disable the page at example.com/node?
I guess my problem is I don't even know what kind of page this node list is. I have the feeling it's some unique page type, buried deep down in the core and can't be easily disabled.


texts: Countdown timer field with a scheduler module

texts:
i am using https://drupal.org/project/field_countdown and https://drupal.org/project/scheduler modules.

I have added field_countdown field to my content type 'items'.
I have enabled scheduler for my content type 'items'.

When i am creating a node, i have to choose a date for field_countdown (it shows jQuery timer countdown until set date), also i have to set Scheduler date after that. So you have to set 2 dates instead of one, because these modules are not working together.

So i want to fill only 1 field instead of 2 of them, in my case its a field_countdown and copy its options to a scheduler input.

I've tried jquery without success:

(function($) {
    // jquery timer
    Drupal.behaviors.MyTimer = {
        attach: function (context, settings) {
            // This code will run, on load, even in overlay!!!!!!
            var timerDate = $('#input-id').val();
            alert(timerDate);
        }
    };
})(jQuery);

But js console says that timerDate is undefined. I am using overlay and bartik theme for administration pages.


texts: Commerce Recurring Framework - Get active subscriptions?

texts:
For the Drupal Commerce Recurring Framework module I have a quesiton

Is there a way to get a user's active subscriptions programatically?

Bonus: Is there a way to delete a user's active subscriptions programmatically?

Thanks if anyone answers!


texts: Drupal 7 multisite password protect single site

texts:
I am running a Drupal 7 multisite platform in which sites will be added at a later date to a live version of the website. During the testing process I need the new sites to be on their final live domain but not be viewable by anyone outside of the company.

With single sites we usually achieve this by using the .htaccess and .htpasswd to password project the entire site.

Is there a way to achieve this for induvidual sites on a multisite platform?


texts: Can region be defined outside of the theme's .info file?

texts:
Basically I'm trying to reverse-engineer a theme that was developed by another guy. The problem is that I'm not yet quite firm on Drupal ground.

So I'm looking onto a management page for blocks and see a specific region, which is not defined in theme's .info file...

Can regions be defined elsewhere? Or inherited from somewhere else (another theme maybe)?

UPDATE:
Since to inherit something this should be a sub-theme, which should be denoted by:

  base theme = themeName

line in themeName.info file. But there is no such line in this theme... :( This undefined region should be coming from somewhere else...


texts: How to add tracking scripts from external sites?

texts:
We want to use several lead tracking snippets of code on various pages.

<script type="text/javascript">llfrmid=123456</script>
<script type="text/javascript" src="https://formalyzer.com/formalyze_init.js"></script>
<script type="text/javascript" src="https://formalyzer.com/formalyze_call_secure.js"></script>

...I can use drupal_add_js() but it seems to want to wrap the first line in --CDATA-- and I'm unclear if that makes a difference.

I came across this post: How to add script to <head>?. Is that accepted answer still recommended for D7? ie. just concatenating text to the header with drupal_get_html_head() Or is there a way to use drupal_add_js so it does not wrap the text in --CDATA--?

TIA


texts:
I have a site theme that needs to use Jquery 2.1.3. The theme uses on() and affects the node/add form. So I also need Drupal's default Jquery 1.4 to be running, otherwise the default Drupal scripts on the node/add form will not work.

The Jquery Multi module is supposed to be the best way of doing this. But how do you use the module? I have installed it and verified that the Jquery 2.1 library is running.

In the Read Me it says:

  For instance, if you're loading jQuery-1.7.1, the alias will be jq171,
  and you can
          use it in your scripts by wrapping your code as follows:

      (function($){
        // your code here, using jQuery 1.7.1
      })(jq171)

  NOTE: All jQuery targeted to use jQuery Multi (using methods A, B,
  or C above) must properly use a
          closure around the jQuery code, as is best practice for all Drupal jQuery code, i.e.:

        (function($){
          // your code here, using jQuery 1.7.1
        })(jQuery)

Do I wrap my code in both jq213 and Jquery for example:

(function($) {
    (function($) {
        "use strict";
        $(document).ready(function() {

            /* *********************** */
            /* Mobile only Hamburger menu       */
            /* *********************** */
            $(".masthead .menu").on("click", function() {
                $(this).toggleClass('menu-close');
                $("body").toggleClass('menu-open');
                $(".masthead ul").toggleClass("animated bounceInDown");
                $(".masthead .tap-back").toggle();
           });
                  });
    })(jq213)
})(jQuery);

I have tried this, but it doesn't work. When I check the HTML source I can see that Jquery 2.1.3 doesn't load, so presumably I am wrapping my scripts wrongly.

In admin/config/system/jqmulti I can see that Jquery 2.1.3 has loaded.


texts: How to limit number of values for field collection returned in a vew

texts:
I have a content type with a field collection item. The field collection includes an image field and a text field. Unlimited items can be added.

I have a view that is using only the image field. I want to show only the first image in the view. However there is no "multiple values"settings available when adding this field.

I have am able to use a conditional to only render the first image, however the view still creates a blank space for each additional image in the node. How can I get the view to only show the first image.

The code I have tried is below:

if ($data->field_data_field_add_images_delta == 0)
 {
 print '<a href="/rooms-houses/' . $row->title . '/' . $row->nid . '/' . $row->uid . '">  ' . render($data->field_field_collection_upload_image) . ' </a>';
  }


texts:
We have a Media type called Documents that has a Link field called field_link. We need to obtain the URL (external or internal) from the field so that we can use to wrap block elements inside of a  tag in our twig templates. All works fine when the link is an external URL, but when linking to an internal page, the following code does not work in our mymodule_preprocess_media hook.

How can I obtain both the internal and external link within the field_link field inside of the mymodule_preprocess_media hook?

This is what we have tried, but only works for external links.

function mymodule_preprocess_media(&$variables) {
  $media_entity = $variables['elements']['#media'];
  $link = $media_entity->get('field_link')->first();

  // This works for external, but not internal
  $link_value = $link->getUrl()->getUri();

  $variables['custom_var'] = [
    'link_value' => $link_value,
  ];
}

media--document.html.twig

{{ name }}

When using ksm($link->getUrl()), we find that the uri value is NULL when the link is internal.

Goals:

Get the internal link (absolute) using hook_preprocess_media
Get the external link using hook_preprocess_media


texts: How to set rel="alternate" hreflang="x"?

texts:
I am trying to set my hreflang links with this code:

$langcode= $GLOBALS['language']-> language;
//Get enabled languages
$langcode= array_pop(language_list('enabled'));
unset ($languages[$langcode->language]);

// Get path
$path1 = drupal_is_front_page() ? '<front>' : $_GET['q'];
//Get Urls
$links = array();
foreach ($languages as $lang) {
  $links[$lang->language] = array(
    'href'=> $path1,
    'language'=>lang,
    'absolute'=> TRUE,
  );
}
drupal_alter('translation_link', $links, $path1);

//Set head tags
foreach($links as $link) {
  drupal_set_html_head('<link rel="alternate" hreflang="'.   $link['language']->language .'" href="'. url($link['href'], $link) .'" />');
}
//Update head
$vars['head'] = drupal_get_html_head();

with no luck.

While researching I have found this module Internationalization contributions
but it doesn't do anything. Or I don't know how to use it.


texts: How to move the Entity Browser "Create Entities" button below the created/selected entities

texts:
Drupal 8 / Entity Browser Module
When leveraging the Entity Browser form field display, the "Button" is always displayed on top of the created/selected entities, like so...

I'd like to move the button so it shows below the entities, like so...

What's the most effective way of accomplishing this? Thanks!


texts: migration process plugin not registering

texts:
My plugin aims to strip out html tags from titles being imported from xml
Here is the error I'm receiving:
FVFXF0ETHV2F:process$ drush mim complinet_xml_to_node
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "stripouthtml" plugin does not exist. in                                          [error]
/Users/Sites/devdesktop/drupal8test/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php:52
Stack trace:

Here is the plugin which lives in custom/complinetmigration/src/Plugin/migrate/process

<?php

/**
 * @file
 * Contains \Drupal\complinetmigration\Plugin\migrate\process\StripOutHTML.
 */

namespace Drupal\complinetmigration\Plugin\migrate\process;

use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;

 /**
 * @MigrateProcessPlugin(
 * id = "stripouthtml"
 * )
 *
 */
class StripOutHTML extends ProcessPluginBase {

  /**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    // $value: cut off .<nnn>Z and replace by Z
    if( is_null($value) )
    {
      return $value;
    }

    // $old = $value;

    $value= strip_tags($value);
    // drush_print_r( $old . ' -> ' . $value );

    return $value;
  }

}

and here is the migration

# This migration demonstrates importing from a monolithic XML file.
dependencies:
    enforced:
      module:
        - complimentmigration
id: compliment_xml_to_node
label: XML feed of nodes from compliment
migration_group: compliment
migration_tags:
  - advanced xml import
source:
  # We use the XML data parser plugin.
  plugin: url
  data_fetcher_plugin: http
  data_parser_plugin: xml
  # Normally, this is one or more fully-qualified URLs or file paths. Because
  # we can't hardcode your local URL, we provide a relative path here which
  # hook_install() will rewrite to a full URL for the current site.
  urls: private://FINRAManual08-08-18.xml
  #  - /migrate_example_advanced_position?_format=xml
  # Visit the URL above (relative to your site root) and look at it. You can see
  # that <response> is the outer element, and each item we want to import is a
  # <position> element. The item_xpath value is the xpath to use to query the
  # desired elements.
  item_selector: '/quickpipe/section/section/section'
  # Under 'fields', we list the data items to be imported. The first level keys
  # are the source field names we want to populate (the names to be used as
  # sources in the process configuration below). For each field we're importing,
  # we provide a label (optional - this is for display in migration tools) and
  # an xpath for retrieving that value. It's important to note that this xpath
  # is relative to the elements retrieved by item_xpath.
  fields:
    -
      name: versionid
      label: 'Version Id'
      selector: 'version[1]/@recordId'
    -
      name: title
      label: 'Title'
      selector: 'version[1]/title'
    -
      name: content
      lable: 'Content'
      selector: 'version[1]/content'

  # Under 'ids', we identify source fields populated above which will uniquely
  # identify each imported item. The 'type' makes sure the migration map table
  # uses the proper schema type for stored the IDs.
  ids:
    versionid:
      type: integer
destination:
  plugin: entity:node
process:
  # Hardcode the destination node type (bundle) as 'migrate_example_beer'.
  type:
    plugin: default_value
    default_value: article
  title:
    plugin: stripouthtml
    source: title
  uid:
    plugin: default_value
    default_value: 1
  sticky:
    plugin: default_value
    default_value: 0
  body: content
migration_dependencies: {}


texts: Can you do branching multistep forms in ctools?

texts: I'm using the ctools multistep form code in a couple of places in a project, and would like to branch the user's path through the form.  That is, in step 1, I get some stuff from the user that allows me to determine that the user should be sent to either steps 2a, 2b, and 2c, or 3a, 3b, and 3c.  I've been looking but haven't yet found anything out there about this; are branching multistep forms in fact possible with ctools?


texts:
I have a modal box for login and registration for my site.

example.com
I want to add the captcha with the registration process.I added the captcha module in my site. But the captcha only work with the drupal's default registration page but not work with the modal box's registration.

How can I add the captcha with the modal box.


texts: How do you create a make file and minify it for pdf.js?

texts:
I want to install the PDF module. In the modules "Getting Started" instructions, I read the following sentence:

  Make pdf.js file in the pdf.js/build directory by following the README.

The README file includes these instructions:

  In order to bundle all src/ files into a final pdf.js, issue:

$ make

  This will generate the file build/pdf.js that can be included in your final project. (WARNING: That's a large file! Consider minifying it).

How do you accomplish this from a Windows machine?
Does it require the web server to be a linux machine?
Does this require SSH'ing into the remote host?


texts:
I am trying to not show a certain view result using hook_views_pre_render but I didn't find the correct way to not display the result.

I did manage to have access to the view and change each result title to a test title, code:

function MODULENAME_views_pre_render(\Drupal\views\ViewExecutable $view) {

  if($view->id() == 'tasks') {
    foreach($view->result as $task) {
      $task->_entity->set('title', 'test - ' . time());
    }
  }
}

I want to use something like $task->show = false;, is there any way?

Thank you!


texts: How do you sql-sync a site with multiple databases?

texts:
I have a site that uses two databases.  I would like to sql-sync both of those databases to the development version of the site. Is this possible?

// Default
drush sql-sync @prod @dev

// Optional?
drush sql-sync @prod @dev --database=my_other_db


texts: Remove the extra headers from the e-mails sent

texts:
My site is made of book(book pages) and any authenticated user is able to send the book page as an e-mail to anybody (other user in the site / external user using e-mail) he wishes. The mail system is working fine but when (lets say) User1(user1@example.com) is sending mail to anyone, the sent mail headers are as follows:

  site_admin@example.com on behalf of user1@example.com

I want that a user should be able to send the email directly by his e-mail id.

I am using Drupal 7, with Print and SMTP configured to send to book pages.


texts: Customize HTML for field in field collection

texts:
My field collection template is ds-1col--field-collection-item-field-video-item.tpl.php. I need to access the Image field so that I can customize the HTML. I've tried the following by neither work:

<?php print $fields['field_video_image'][0]['und']['value']; ?>

and

<?php print $fields['field_video_image']->content; ?>

I also need to wrap each field collection item in its own div. For instance, each image should be wrapped in a videoClip div but right now all field items are rendering inside videoClip. Also I need to get the delta value of each field item to add it to as part of a CSS class. How can I do this?

Current fields wrapped in custom HTML together:


texts: Filter a view with content from two different content types

texts:
I am creating an RSS feed that outputs all posts from two views: one is the men's blog, and the other is the women's. I found out that, when I specify my filters, I need to select both custom content types, leaving me with no results as if one cancels out the other. How do I add these two together, so I get all posts in the feed?

I noticed in contextual filters there is "month + year." I need something like this for two content types.