texts: Importing products into Drupal Commerce and handling Tax

texts:
Im working on an integration module where I'm trying to import products externally and into Drupal Commerce. I revceive the product object externally like this:
    2692604 (Object) stdClass
      id (Integer) 2692604
      revision (Integer) 2
      currencyCode (String, 3 characters ) NOK
      vatType (Integer) 3
      name (String, 14 characters ) Produktkatalog
      priceCurrency (Integer) 235
      priceIncVatCurrency (Integer) 294
      number (String, 4 characters ) 1003
      cost (Integer) 230

I've found a code snippet from the commerce_example module where you can create a product programmatically like this:

//commerce_price[und][0][amount]
$price = array(LANGUAGE_NONE => array(0 => array(
  'amount' => $price * 100,
  'currency_code' => commerce_default_currency(),
)));
$form_state['values']['commerce_price'] = $price;

// Notify field widgets to save their field data
field_attach_submit('commerce_product', $new_product, $form, $form_state);

commerce_product_save($new_product);
return $new_product->product_id;

I have defined a tax type and a set of tax rates - including a mapping from the code found in the importing object.

I'm thinking the correct way of adding the tax part should be by modifying the code to something like this:

//commerce_price[und][0][amount]
$price = array(LANGUAGE_NONE => array(0 => array(
  'amount' => $price * 100,
  'currency_code' => $product_obj->vatType,
  'data' => array('include_tax' => 'MVA_hoy'),
)));
$form_state['values']['commerce_price'] = $price;

// Notify field widgets to save their field data
field_attach_submit('commerce_product', $new_product, $form, $form_state);

commerce_product_save($new_product);

Problem is that when I import the products, the tax rate is not set as I would expect it to.
Investigating the newly created product (or an old loaded product) does not give me much clue either...


texts: prevent user from putting 0000 in date field

texts: How can I force date validation upon input of a content type so that a user cannot type in 0000 as the year which causes an error in  Drupal 7.


texts: Display and Modify CSS variable ? (Module)

texts:
I'm developing a basic module that allows site admin to have the NavBar for mobile and Administration menu for the desktop view.

This can easily be done by adding this CSS.

#navbar-administration {
    display: none;
}

@media only screen and (min-width: 0px) and (max-width: 959px) {

    #navbar-administration {
        display: block;
    }  /* show it on small screens */;
}

#admin-menu {
    display: block;
}

@media (max-width: 960px) {

    #admin-menu {
        display: none;
    }
}

I'm using hook_page_build() to display it on every page. Now I want user to be able to change on an administration page the 960 width which is the default line break to changes menu to their desired value.

My question  how can I display  the default variable value (960) on a text field and it can be modify the css once the number on the text field is been change.


texts: user_access( ) - Printing list 'variables' you can plug into?

texts:
Something I have seen many times, but never fully understood is what exactly to plug into user_access() (Want to get the correct terminology here too, do you just call them variables?). I have seen some basic ones like user_access('manager access'), manager being a made user? Another using user_access('access nodes links'), which I assume is just seeing if they can see/access the tab links on a node.

If there an easy way to get a common list of what you can plug into user_access()?

Thanks in advance


texts: How would you import settings from an exported drupal 7 omega 3.x?

texts:
I'm able to export settings in omega via the export button: http://prntscr.com/29yr0r

I know I can download the theme, but I do not want that. I want to be able to copy and paste the code into my target omega sub theme. How would i import this to another sub theme for omega?


texts: How do I point to a particular installation of simplesamlphp with the simplesamlphp_auth module?

texts:
I am trying to integrate our company's SSO into our Drupal installation. As a POC to see if it even works, I have a copy of the SimpleSAMLPhp Library located at /foo/bar/simplesamlphp. I configured my apache vhost and the SAML configs and that's all fine for now.

Per the instructions from Acquia on this page, I tried installing the drupal/simplesamlphp_auth module.

composer require drupal/simplesamlphp_auth

This installed the module and as a dependency, installed a second copy of the simplesamlphp library in vendor/simplesamlphp. Now it looks like the module simplesamlphp_auth is using the installation in vendor.

How do I configure this module to use the one I already placed in /foo/bar/simplesamlphp? There doesn't seem to be any options on the page /admin/config/people/simplesamlphp_auth.

I have configuration files that I would like to avoid copying over to the vendor directory after each deployment if possible, since that's not as secure as keeping the configs outside of the project altogether.

EDIT 1

Clarification on the configuration files: I need to define configuration files in /foo/bar/simplesamlphp/config in order for it to work. These configuration files are missing from vendor/simplesamlphp/config and without them the application encounters a fatal error. As stated in the Acquia document above, the library lives outside of vendor/ or docroot/ in their setup.


texts: Pass parameters to external JS file with drupal_add_js()

texts:
My organization is using Eloqua, and to this point have been using the Eloqua module. The main point of this module is just to determine where the external tracking script should be loaded on the site, and then load the external script while passing it a couple of parameters. This call is creating a huge performance hit, and so after talking to Eloqua support, I copied the external file to the site so it could be cached. Since we need the file to be loaded for every page, we really don't need the module, and so all we really need to do is load the file and pass it the required parameters

The problem is determining how to pass the required parameters to the script. Here is the current eloqua.js:

var _elqQ = _elqQ || [];

(function ($) {

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

      _elqQ.push(['elqSetSiteId', Drupal.settings.eloqua.siteId]);
      _elqQ.push(['elqTrackPageView']);

      function async_load() {
        var s = document.createElement('script');
        s.type = 'text/javascript';
        s.async = true;
        s.src = '//img.en25.com/i/elqCfg.min.js';
        var x = document.getElementsByTagName('script')[0];
        x.parentNode.insertBefore(s, x);
      }
      if (window.addEventListener) {
        window.addEventListener('DOMContentLoaded', async_load, false);
      } else if (window.attachEvent) {
        window.attachEvent('onload', async_load);
      }
    }
  };
})(jQuery);

The _elqQ array is accessed by elqCfg.min.js, so I need to make it accessible to the script with the elqSetSiteId and elqTrackPageView parameters. Is there a way to do that while adding elqCfg.min.js via drupal_add_js() in template.php or somewhere else?

CLARIFICATION: What I'm looking for here is a way to include this file and pass the parameters to it without having to create a whole module. That seems like a lot of unnecessary overhead for this one file.


texts: How to programmatically add custom markup to every displayed user name

texts:
Drupal 8.x

I am currently using hook_preprocess_user().

I would like to alter the username to add some custom markup to every username.

MYMODULE.module:

function MYMODULE_preprocess_user(&$variables) {
  $variables['elements']['#user']->name->value = t('Name @newMarkup', ['@newMarkup' => ' Hello']);
}

This returns Name Hello Hello. Concatenation adds 'Hello' twice so this approach is not working.

I've also worked with user_format_name_alter(&$name, $account), however, this does not seem to fit my use case.

How can I alter the username text? Not looking for a "currentUser" solution, but every user so names are changed everywhere. Reference, Views, etc.


texts: Is it possible to run Drush without root?

texts:
I run a Linux server that is administered by a friend of mine, and at the moment I work with Filezilla.

I've heard that Drush is a trivial installation: it seems to require no configuration and work out of the box.

However, it looks for configuration in several places:

  Drush installation directory,  the home directory (as .drushrc.php),
  root directory of a Drupal installation, and  site directory of a
  Drupal installation.  Since the configuration files are just PHP
  scripts, they can  contain any PHP code that you would like to have
  executed on startup of Drush.  one could for instance call ini_set()
  to set the value of a PHP configuration option.

and the configuration file /opt/drush/drushrc.php with following content:

# Allow Drush to use 128 MB of memory. Use -1 for no limit. ini_set('memory_limit', '128M');

I see this is necessary because PHP's default is too low, but I'm not sure if I need higher-level privileges because of it.

Do I have to have root-level permissions on the server, or am I able to work with Drush without them?

Update:  As far as i understand this, i only have to ask my admin to get some more privileges (permissions)Note according to BetaRides answer i need to have more than only the access-data that the FileZilla needs - that are provided for the filezilla! Guess so - but i don not need root-permissions.

btw - i have secure-shell-access (ssh2 access) guess that this is enough -With that i can setup a sftp-connection to the server with filezilla just lemme know - if i can use the exactly same data for the shell access (with the command line tool=?!=


texts: dynamic block title for block-view of referencing nodes

texts:
I have a block listing nodes that all reference the same 'parent node' (etity reference). I would love to see the title of the referenced node as a title of that block.

Example: on a record label website there could be nodes for albums. Every album node references one artist. On an album page there would be a block listing "Other Albums of Artist XY".

I know my question is quite similar to this question
"Dynamic block titles" but the solution on that question suggests using Tokens in the block's body, along with some h2-tags, so that it would look like the block's title.

Sounds like a swell workaround – however – since the block I use comes from a view, there is no body I could place tokens in.

Another workaround that almost did the trick was to add the referenced content type to the fields of the view, hide the output, then use tokens in the header of the view (again with h2 tags). But I only could get the referenced node fully rendered, making it impossible to use as a fake block title.

How can this be done? I would gladly welcome any hints and/or pointers…

Thanks! t.


texts: How to fix Fatal error: Call to undefined function, after updating Drupal core?

texts:
I was updating my site to the new 7.41 release. I did the following as usual:

Made a backup of files & database
Put site in maintenance mode
Deleted all files except the Sites folder
Uploaded all new folders (excluding Sites)
Attempted to update database

Once I did this I got the following error:

  Fatal error: Call to undefined function ctools_include() in /home/cprids/public_html/sites/all/modules/geofield/geofield.install on line 14

This error is on every page, including the backend, so I'm completely locked out!

So I tried uploading my backup but still have the same error! I've emptied all the cache tables in my database as suggested in another similar discussion but have had zero luck. Any ideas on how to fix this would be really appreciated.


texts: How to get session user id in custome php file

texts:
I want user session id in my custom ajax file named "ajax_page.php" below is code that i have placed in that file but i am not able to get object array of $user that i'hv defined as Global $user.

          <?php

               define('DRUPAL_ROOT', 'C:/xampp/htdocs/taconsultant/');
                require_once(DRUPAL_ROOT.'includes/bootstrap.inc');
                require_once (DRUPAL_ROOT . 'includes/common.inc');
                require_once (DRUPAL_ROOT . 'includes/module.inc');
                require_once (DRUPAL_ROOT . 'includes/unicode.inc');
                require_once (DRUPAL_ROOT . 'includes/file.inc');
                drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
                drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);

                global $user;

                $uid = $user->uid;

 if($_REQUEST['type'] && $_REQUEST['type'] == 'buy_course'){

         $cid = $_REQUEST['cid'];
         $course = taxonomy_term_load($cid);
          echo "<pre>";
          print_r($user);
          exit;
         $log = db_insert('tbl_user_log')
                ->fields(array(
                        'uid' => $uid,
                        'title'=>$course->name,
                        'points'=>$course->field_payment_amount['und'][0]['value'],
                        'type'=>'-',
                        'date' => date('Y-m-d'),
                        ))->execute();

    }

        ?>

The output i got in console after print_r($user) is
  <?php
    <pre>stdClass Object

        (
            [uid] => 0
            [hostname] => ::1
            [roles] => Array
                (
                    [1] => anonymous user
                )

            [cache] => 0
        )
?>


texts: After upgrade from Drupal 6 to Drupal 7 search does not work

texts:
Same server, upgrade went well and site is stable however it won't index content even after clicking on re-index. Crons are running just fine on server, checked on the MySQL database and all the tables related to search (search_dataset, search_index, search_total etc) are all empty. I have tried turning all modules off, emptying cache, turning search on off, nothing works.

I would really appreciate if anyone knew a way around this.

Kind Regards

Javier


texts: Custom content entity template preprocess doesn't contain any variables

texts:
I've created a custom entity and a template for it.

path to template /modules/custom/my_module/templates.

My theme_hook()

/**
 * Implements hook_theme().
 */
function my_module_theme($existing, $type, $theme, $path) {
  return [
    'my_module' => [
      'path' => $path . '/templates',
      'template' => 'my-module',
      'variables' => [
        '#my_entity' => '',
      ],
    ],
  ];
}

My preprocess

/**
 * Prepares variables for My Module templates.
 *
 * Default template: my-module.html.twig.
 *
 * @param array $variables
 *   An associative array containing:
 *   - elements: An associative array containing the user information and any
 *   - attributes: HTML attributes for the containing element.
 */
function template_preprocess_my_template(array &$variables) {
  // Fetch my_entity Entity Object.
  $my_entity = $variables['elements']['#my_entity'];

  // Helpful $content variable for templates.
  foreach (Element::children($variables['elements']) as $key) {
    $variables['content'][$key] = $variables['elements'][$key];
  }
}

But all I get is the user object nothing else.

Did I miss something?


texts:
I need to ensure that the user is the one who is acting on the website by sending hash code generated to his emial or sms message before complete an operation.

we have implemented account balance so we need to prevent others use his balance by verify the account owner.

Scenario wanted to achieve:

User add items to his cart
Send hash code to his email
verify the code
Complete to checkout

What is the best practice to achieve?

using commerce framework -- commerce account balance


texts:
we have a problem that we get a internal server error on about every ajax call. The example below happens when editing a view clicking "add filter" and directly click on abort. It also happens when making changes to a view. At first glance the change seemed to be ignored but after refreshing the pages the changes will be visible.

When accessing the URL which throws the error we get a valid json string (checked with jsonlint.com).

Our server logs sadly show nothing interesting. I would appreciate any kind of hint where to look for a solution.

Edit:
The nojs version seems to work fine but that's no solution in the long term :/


texts: How to add a view dependency to a Drupal 8 functional test

texts:
I'm working on a contrib module port to Drupal 8 and am currently adding additional test coverage (#2586125). The module provides both a field formatter and a views style plugin. I have good working test coverage for the field formatter and am now focusing on several views test cases (simpletest based on Drupal\simpletest\WebTestBase).

I have built a simple view, that uses my module's views style plugin along with a few other simple dependencies (some field storage conf, etc.), and exported this as a couple yml conf files. What's not clear to me however is the best practice way to load this bundled view during each functional test case.

A couple ideas come to mind:

Method 1: Bundle View as Config in Test Module Dependency

I Drupal 7 the standard method appeared to be to export a view and then bundle it inside a test-only module (with hook_views_default_views()) which is installed as part of the test case setup. In D8 the exported view yml can just be placed inside a test module's config/install directory and then the module made a dependency inside the $modules property of the test class.

Method 2: Add View Explicitly during Setup with ViewTestData::createTestViews()

Some of the D8 views module's own tests use Drupal\views\Tests\ViewTestData::createTestViews(), along with a $testViews property array to directly enable a specific view inside the test setup. Something like:

  public static $modules = array('node', 'field', 'image', 'my_module', 'views');

  // Views used by this test.
  public static $testViews = array('my_test_view'); // Exported yml inside config/test_views of my_test_views_module

  /**
   * Define setup tasks.
   */
  public function setUp() {
    parent::setUp();
    ViewTestData::createTestViews(get_class($this), array('my_test_views_module'));
    // Additional setup...
  }

Other Factors

The way configuration is loaded and cached, and related dependencies are resolved during tests is slightly mysterious. I've noticed that test cases which also programmatically add configuration that a view depends on (using something like $this->drupalCreateContentType() for a content type config or entity_create() for field storage config) can be tricky. In these cases Method 1 could be problematic as the view may get loaded from conf before it's dependencies are programmatically prepared. This is leading me to think that Method 2 is potentially preferred, but all the factors are not yet clear.


texts: Controlling the display format of a rss feed

texts:
I am using drupal 6. I have created an RSS feed to display the nodes of a certain type (set in the filter). This type of content has many different fields, but I only want to display some of them. Is this possible? At the moment I am very new to Drupal, and I am only working in the front end view.

To fix this issue, do I need to go deeper and mess with the PHP code somewhere?


texts: Views Contextual Filters - User Name in URL

texts:
I have a view set up to function as a blog, and a contextual filter set up to filter by author of the blog post.

The point is to be able to click on the blog post author link and go to a page that lists all the blog posts by that person. This is facing anyone who visits the site, and any visitor (non-logged in) can view the blog listing of any of the authors.

The current set up is to have a Relationship to the author table, and filter by User: name. Then when visiting a url /blog/author/John Smith, you see all posts by John Smith. (I realise that's an invalid URL.)

The filter itself is working and the blog posts are being pulled through for all the authors, however, I'm having issues to transform spaces to dashes and to lowercase the URL.

When you visit /blog/author/John Smith, you are redirected to /blog/author/John%20Smith, and then the blog posts by John Smith are visible, but this isn't good enough for us in terms of URLs.

So instead of /blog/author/John%20Smith, I need the URL to be /blog/author/john-smith.

The problem is that the default checkboxes and options which work for taxonomy terms do not seem to work with Author names. Ticking transform spaces to dashes in URL and using case in path: lower does not affect the filter the way I want it to - it has no effect at all.

  I'm considering creating a new field in the user entity and then using that to filter instead. Like john-smith for the John Smith user. I'm not sure if that'll work, but I'll try it out right now.

The above has worked, and I do have the URL's I want and they query for the right items. I'm not sure if it's the cleanest solution though.


texts:
I am using a fresh D8 install. I have created a custom block with a token which I have added to a header. The block is themes from somewhere to float left. If I, through "inspect" in the browser, add an element to float right. All my spacing works out great. I dont want to change other site feilds. Just this block and/or content to float right

How do I add CSS to get this block content to float right? Specific files would be handy or ? Your advise?

The html I have copied from the inspect looks like this

Pro Safety

Thanks for Im sure a simple fix


texts: I have a note type 'team' with a body field and a checkbox field (checked by default). I want to automatically check the box on save IF there is content in the body field. Is there a way to do that programmatically?


texts: How to remove 'None' from forum options?

texts:
In D7 advance forum, when users want to create a forum thread at node/add/forum, they are presented with a dorp-down menu fo froum whose default is set to .

So when users do not choose an existing forum from the menu, their thread is just added to 'None' forum, which is so bad. I need frequenty to remove these 'none' forum threads.

So I'm wondering how remove this  option or otherwise solve this problem?


texts:
Is it possible to split the Drupal database into multiple databases. For example I have one database having the watchdog table and another database having all the other tables?

I know if I created my own tables I could store them in a separate database and use the following:

How to connect to multiple Databases in Drupal 7?

db_set_active('your_second_db_alias');
$query = db_query("SELECT * FROM your_table");
db_set_active();


texts: Get data from remote REST API (read only)

texts:
We use a remote service (not Drupal) to publish press releases and to show those releases in a remote newsroom.

This remote service offers an API so we should be able to fetch and show the newsroom on our Drupal site. To use the API a custom token must be present in the request header and the method used must be GET:

Notified-Custom-Token: [TOKEN]

This is what I have done so far in a custom module named notified_api. [custom token] is replaced by a unique token genererated for our newsroom and [id] is replaced by our newsroom ID:

function notified_api_preprocess_page(&$variables) {
  // Fetch newsroom from Notified API with custom token
  $headers =  array('Authorization'=>'Notified-Custom-Token [token]', 'Content-Type'=>'application/json' );
  $url = "https://api.newsroom.notified.com/api/newsrooms/[id]";

  $options=array('headers'=>$headers, 'method'=>'GET');

  $result=drupal_http_request($url, $options);

  dpm($result);
}

Partial result from the dpm:

... (Object) stdClass
url (String, 53 characters ) https://api.newsroom.notified.com/api/newsrooms...
status (String, 5 characters ) Done.
code (Integer) 401
chunk_size (Integer) 32768
data (String, 0 characters )
request (String, 438 characters ) GET /api/newsrooms/345345 HTTP/1.0 Authorizatio...
GET /api/newsrooms/345345 HTTP/1.0
Authorization: Notified-Custom-Token 9832502938403876504329820348ewieitrje...
Content-Type: application/json
User-Agent: Drupal (+http://drupal.org/)
Connection: close
Host: api.newsroom.notified.com

options (Array, 20 elements)
headers (Array, 5 elements)
Authorization (String, 258 characters ) Notified-Custom-Token 9832502938403876504329820348ewieitrje...
Content-Type (String, 16 characters ) application/json
User-Agent (String, 28 characters ) Drupal (+http://drupal.org/)
Connection (String, 5 characters ) close
Host (String, 25 characters ) api.newsroom.notified.com
method (String, 3 characters ) GET

What I get is a 401 message: unauthorized. Can anyone see what I am doing wrong?


texts: D8 - Cannot make Custom EntityType translatable

texts:
When I am trying to make a custom entity translatable I get the following error message:

The Redirect entity entity type cannot be translatable as it does not define a translatable "langcode" field. in <em class="placeholder">Drupal\Core\Entity\EntityFieldManager->buildBaseFieldDefinitions

After checking other modules and the drupal docs I have to define 2 things:

1.) I need to create a translatable "langcode" field
2.) I need to set the entityType annotation to translatable

Still I receive this error.

My annotation of the entityType:

@ContentEntityType(
 *   id = "email_confirm_redirect",
 *   label = @Translation("Redirect entity"),
 *   admin_permission = "administer email confirm redirect entity",
 *   base_table = "email_confirm_redirect",
 *   revision_table = "email_confirm_redirect_revision",
 *   data_table = "email_confirm_redirect_field_data",
 *   translatable = TRUE,
 *   handlers = {
 *     "list_builder" = "Drupal\email_confirm_redirect\Entity\Controller\RedirectListBuilder",
 *     "form" = {
 *       "add" = "Drupal\email_confirm_redirect\Form\RedirectForm",
 *       "edit" = "Drupal\email_confirm_redirect\Form\RedirectForm",
 *       "delete" = "Drupal\email_confirm_redirect\Form\RedirectDeleteForm",
 *     },
 *     "access" = "Drupal\email_confirm_redirect\RedirectAccessControlHandler",
 *   },
 *   list_cache_contexts = { "user" },
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "title",
 *     "uuid" = "uuid"
 *   },
 *   links = {
 *     "edit-form" = "/admin/email_confirm_redirect/{email_confirm_redirect_entity}/edit",
 *     "delete-form" = "/admin/email_confirm_redirect/{email_confirm_redirect_entity}/delete",
 *     "collection" = "/admin/structure/email_confirm_redirect/list"
 *   },
 * )

The field declaration in my baseFieldDefinition() function:

//langcode
        $fields['langcode'] = BaseFieldDefinition::create('language')
            ->setLabel(t('Language'))
            ->setTranslatable(true)
            ->setDescription(t('The redirect language code.'))
            ->setDisplayOptions('form', array(
                'type' => 'language_select',
                'weight' => 2,
            ));


texts: How do I create a conditional form field?

texts:
I have this dropdown menu of options in the user registration page of my site (image shown below), and i want when the user selects the employer, some text fields appear, like name of company, and when they select job seeker, the text field that appears asks for things like uploading CV.

I have conditional fields module installed but it does not cater for user registration form (image shown below) .

Is there a way to add the user registration form to be one of the options that conditional fields module offers? I have followed each of those links and none of them is helpful.:(

Lastly, in the account type drop down image shown above, I want to filter out the administrator, anonymous user and authenticated user options such that the user only creates either an employer account or job seeker account. Any ideas how i can do that?


texts: How to add Organic Groups after Site has been created

texts:
My site allows people from a certain class to upload their pictures on the website. It has various content types and views made but and I would like to install the Organic Groups module to allow multiple classes from my school to upload images.
Can I do that now or do I need to re-create the site from scratch?


texts: Multiple nested forms of same type - submit from first one only posts form_build_id of parent form

texts:
10 forms of the same type, each with one submit button (which have distinct #name attributes), nested within a parent form of a different type. They are nested simply by calling drupal_get_form() from within another form callback (why am I doing it this way? Well, I have some display suite fields that call drupal_get_form(), and I am rendering some entities within the parent form, so rendering those entities calls drupal_get_form() within the parent form function).

All work perfectly, except for the first one of the 10. When its submit button is pressed, the correct _triggering_element_name is posted, but the form_build_id posted is the build id of the parent form, not the child form. For all subsequent 9 forms, the correct _triggering_element_name and form_build_id are posted, and they work perfectly.

The HTML seems to be the same for each of the 10 subforms, i.e. the first one has the hidden form_build_id input, which has its own distinct value from that of the parent form. This value is just not posted.

Any thoughts? I'm a bit stumped! Even just an idea of where to look to see what's wrong...


texts: How to add an icon before (or after) the node title if a field is filled?

texts:
I'm a newbie in Drupal and I want to add an icon before (or after) the node title, if the node have a 'field_fav' filled. I know it can be done using preprocess functions, but I don't know how to append the title's  with the class I desired. Any how to?

Found this : Optionally add image/icon after node title based on boolean content type field? but it only for boolean type value.


texts: How to remain logged in when switching languages via domain?

texts:
I am using Drupal 7 to configure a new single Drupal site that uses two languages (English and French), using Locale with the "Language domain" setting enabled. This site requires both the display and the admin language to be switchable, and almost have it working! I have just one last issue.

When I visit "en.dev.example.com" I can log in everything seems to be working great; when I switch to "fr.dev.example.com" while logged in, I am no longer logged in. I can actually have two different users logged in at once, using the same browser, on each domain.

This is not desired! This Drupal site is not a multi-site, and I don't want it to behave like that. When someone logs in, I need them to stay logged in also when they switch languages. This is because many users will be totally bilingual and need to see the site content in both the languages. This is important, since the content is membership based.

I started out setting the "Path prefix language code" in my language settings which was working well; you could switch languages without problems and stay logged in while doing so. Perfect! Except…

I had to change the method of handling languages to "Language domain" because the URLs created by some modules (namely the Advanced Forum module, but I am sure it will come up in other places) were not respecting the path language prefixes, and giving many 404s. I really need to use the subdomain method!

I created two subdomains via my hosting account, one is "en.dev.example.com" and the other is "fr.dev.example.com" (both using subdomains to give each language equal significance). I changed the "Language domain" for each language, and am now able to see both language versions by using the subdomains I created, as expected.

What can I do to make sure users stay logged in when they switch language after starting their session, while using the "Language domain" option?

I cannot locate any info or forum posts for Drupal 7 on this particular issue... Do I need to make some changes to my settings.php file? I also couldn't find D7 documentation on setting this up (only for path prefixes), so it's possible that I have missed a step.

I have been at the languages settings for a few days now, and I have made real progress, but I feel totally stuck at this point, the last problem! I would absolutely love some advice at this point.


texts: How to merge two different vocabulary in one auto-complete text-field?

texts:
I have two taxonomies like below:

Content--- editor pick
       --- recommended
       --- today high
Sources--- sky
       --- earth
       --- water

to attach these with blog-post i need to make 2 different auto-complete text-box.
I want to make a single text box and both the taxonomy should be suggested in that.


texts:
Hoping for some guidance here. Sometime in the past few weeks, my inline modal popups stopped working in Chrome. I had Colorbox set up at the time, both hand coded inline links and views colorbox triggers. With views, the links now force a page refresh to the home page with the colorbox query appended:

i.e. ?width=500&height=500&inline=true#content

With hard links, the page refreshed on the existing page, with the same query string added.
After some investigation, I discovered that ONE page on the site still works, but it's part of a series of panel variants on a page. I've been through the variants with a fine toothed comb, but they're configured identically, so there's no clear reason why this one page should work when the others don't. I've also tested Chrome on two other (both older) laptops, with the same results.
I installed the Popup module to see if I could by-pass the issue, but the results are exactly the same. The popups work on the one rogue page but not on any of the others. So the problem isn't colorbox, but something else. Again, this is ONLY in Chrome. Firefox and IE both work fine.
I've tried creating solo links on basic pages, I've systematically turned off all the other components on all of the test pages ... nothing. I tried removing all of my custom jquery and disabled my custom modules. No dice.
Can anyone suggest another approach, or other possible conflict areas I can test?
Edit to add:
Looks like the working page is processing the link class as "colorbox-inline init-colorbox-inline-processed cboxElement", while the non-functioning pages are only rendering "colorbox-inline". It's the same block on all pages, so I'm not sure why it wouldn't be processed evenly.
The base colorbox inline code I'm using is adapted from the following:

Link to click

What ever content you want to display in a Colorbox.


texts: Can't access admin after moving localhost to live server

texts:
Almost finished my site and thought I have completed the puzzle but there is one last frontier in my way and a rather annoying ankle-biter...

I moved my site off my localhost onto my live server everything was successful until I tried to login the first time and was denied access.. I requested a new password through the email I provided when i created the site on my localhost but the emails do not come to my inbox but when i try to recreate the process on my localhost I get the email and can change it etc. I have tried going into my DB>users>browse> and change my password and put MD5 so it becomes encrypted but still no success on the live site.

I have tried to search online for the answer but have been going in circles and would like to see if anyone can offer some advice I am novice level and eager to learn so if responding kindly use terms a novice would be familiar with, thank you.


texts: How can I add JavaScript and CSS to my site?


texts: How to expose to users filter for changing views items limit for pagination?

texts: As in question, is this possible via UI or only custom form must be created?


texts: I am using Share this module in Drupal . In that when we click on Facebook, Linkedin the image is also inserted and linked to that social site but when we click on twitter,no image is pulled in.Kindly help me with this


texts: Edit custom field using user_presave hook during account creation

texts:
I have made a custom field for user field_custom_xyz from the admin GUI.
Now after i saved it i got two tables into the database : one for data and one for revisions.
I already have a huge database into which a lot of users are already there.

I have two questions :

How can i make sure that i can assign default value to each user at the time of creation of this field?
Let's say if i have to assign a default value of 0 (or null in case i don't follow step 1).
how can i change that value at the time of new registration using  hook_user_presave ?

I want to override the default value of this field using user_presave hook in some custom module lets say 'abc' module

so far i have tried :

$account->field_custom_abc['und'][0]['value'] = 0;

but that doesn't work, any suggestions.
thanks in advance.


texts: How can I display the last modified date on my site?

texts:
I am using Drupal 7, and I would like to include a PHP snippet on my home page that displays the date the site was last updated (i.e., had content added or modified).

How can I go about doing this?


texts: How to partial search in taxonomy terms and entity references with Views Exposed Filter?

texts:
I have a content type and the content type has a taxonomy term field (tags) and a entity reference field (author as another content type).
I'm trying to create an "advanced search" with views exposed filter.

What I want to do is to allow users to search in node titles and inside these fields without an autocomplete function. I don't want to force the users to write and select an author, but I want to let them to write a word and then search.
For example:
If a user enter John in the author field then search; all the nodes should be listed with the authors name that include "John": John A., Michael John, Another John etc.
How can I do this?


texts:
The following code is adding
's and link to the form action. How can I add them before the form?

function ajax_register_form_user_login_alter(&$form, &$form_state, $form_id) {
  $form['bigletters'] = array(
    '#type' => 'item',
    '#markup' => 'Big letters',
  );

  $form['smallletters'] = array(
    '#type' => 'item',
    '#markup' => 'Small letters',
  );

  $form['links'] = array(
    '#type' => 'item',
    '#markup' => '',
  );
}


texts: Modify the error message about the maximum upload file size

texts:
I would like to modify the default error message for the maximum upload file size, but I can't find the configuration.
I looked at webform general settings, individual settings, and media file settings, but I found nothing about it. Forum issues only talk about configuration of the maximum file size, not about customization of the error message.

Can anyone help me?


texts: REST API POST returning 400 Syntax error

texts:
I wrote a REST plugin for posting data to my Drupal site, When I send JSON data from browser it is returning the error {readyState: 4, responseText: "{"error":"Syntax error"}", responseJSON: Object, status: 400, statusText: "Bad Request"} but it is working fine in Postman. What might be the issue?

The data I am send is  {"name" : "user", "pass" : "userpass"}

I am also adding the following headers in request.

"Content-Type", 'application/json'
"Accept", 'application/json'


texts: Product migration with group and execute-dependencies options

texts:
I'm migrating from an SQL source in a D8 commerce site. Presently, I'm working on product and inventory data. I have one migration for product variations, one for products, and then 6 additional migrations for inventory tables all in a single migration group. (Inventory data migrations are dependent on the product/variation migrations.) Everything works properly when I run the migrations individually. However, I have a strange problem if I use this command:

drush migrate-import --group=my_inventory_group --execute-dependencies

The migration runs fully and reports that everything is ok--no error messages. I get all the inventory data, products, and variations, but the table commerce_product__variations (relationship data from products to their relations) gets only a single record added (instead of the 1510 records it should have.) That record references the first product item in my source data and one of its variations.

I've found that what does work for me is to execute the product and variation migrations individually and then the rest of the group, like this:

drush migrate-import my_variation_migration
drush migrate-import my_product_migration
drush migrate-import --group=my_inventory_group --execute-dependencies

Since I have this workaround, it's not a huge issue. But I'm curious as to why I can't execute the migration for the entire migration group with the single command. I'm wondering whether I'm missing something related to the structure of the product/variation entities -- the rest of the migration is all for custom entities.


texts:
Some images fails to load on IE.

DOM7009: Unable to decode image at URL: '[some unique url]'.

The URL are set to sites/default/files/styles/image/image_name.jpg?itok=RANDTOKEN

I can fix the error by removing the header in .htaccess

Header always set X-Content-Type-Options nosniff

But that does not seem to be a right solution. Any ideas why it behaves like this?


texts: Change node title and node field content

texts:
I try to change the values of the title and a field of a node.

function module_node_view($node, $view_mode, $langcode) {
  $node->title = 'TEST';
  $node->field_description[$node->language][0]['value'] = 'CONTENT';
}

When I try this, nothing is changed...


texts:
How can I encrypt my entire site?

I also need to require password and username to access site. When visitors are accessing site, they will be redirected to a login page where they can also request membership. How to implement that?


texts: Integration of Microsoft Exchange server with Drupal

texts:
I am using Drupal 7.

I would like to integrate Microsoft Exchange server with my Drupal site, so that I can login with the credentials of Exchange server and can also integrate with other features of Exchange server like Events, Calenders etc.

I checked one module called LDAP(Light Weight Directory Access Protocol), and it is working with other servers, But i don't know whether I can use this integration with Microsoft Exchange server.


texts:
How set min/maxScale (or Resolution) at Openlayers map

I tried:

  a. In my module :

function myoladd_openlayers_map_alter(&$map = array()) {
    $map['maxScale'] => 14000000;   }

  b. In openlayers.module

set $map['maxScale']=14000000; in openlayers_build_map

  c. In js\openlayers.js

set options.maxScale

also, I have tried different values of Scale, Resolution.


texts: How do I dynamically include ouput from an external file?

texts:
How do I dynamically include output from another web page?

This is the result of a CGI link along the lines of: http://www.example.com/name.cgi?Arg=argument  I would like to include everything within the html tags that it generates as HTML on my page.

(I own both web pages!)


texts: Center the open layer map when in edit mode

texts:
i setup a map with openlayers, geofield, addressfield and geocoder.

I added a geofield to a node, with openlayers as the widget type, and use geocoder to get the geocode from addressfield.

when editing, user press the Find using Address field button and the map display with the marker if found.

the question: how to center the marker? If i set the zoom level higher (in Center and Bounds setting of open layer), the marker will not be shown (out of the visible map area).


texts: When a user enters a search query into an Apache Solr Search box, is it possible to pass that query onto a view - specifically to a Apache Solr Views view?


texts: How to generate a list of field items using the field item name programmatically in Drupal 7?

texts:
I need a way to generate a simple list of all the items in a particular field. The field name is field_portfolio_description, and I'm looking to simply loop through the results and output each item into an unordered list. For example:

Item 1

Item 2

Item 3

Is there a way to do this programmatically without using a module like Views? I would also like to display the data in page.tpl.php not node.tpl.php. I tried checking out some Drupal functions like field_info_field but they weren't much help.

Update:

I've been working with the following function in my template.php file:

function blocks_preprocess_node(&$vars) {
  $node = $vars['node'];
  if ($node->type == 'portfolio') {
    $vars['description'] = $node->field_portfolio_description[LANGUAGE_NONE][0]['value'];
  }
}

However a quick var_dump($description) where I'm trying to access the data brings up null. Am I on the right track?

edit: fixed typo


texts: Load JS only on specific content_type node creation

texts:
Drupal 6. What is the proper way to execute drupal_add_js only when specific content_type is being created?

I have some jQuery code that needs to execute only to control some form elements in a specific content_type creation.


texts: Render commerce item page with views - how to get proper add to cart form?

texts:
I use Drupal Commerce module to build my store. There are items in this store with sets of attributes such a color, size etc. I've created a content type to render a product. When I use a built in way to render this content type I have an interactive add to cart form with select lists or radio buttons for all attributes which loads values such a photo etc depend on it's values. Please suggest an approach how can I get this form using views?

I guess it should be quite a common task.


texts: Facet API : How to change some behaviors like having input radio instead of checkbox

texts:
I need to change some default behavior from the facet API.

I am searching for documentation about the hook from the Facet API module, but I have not found anything for now, except a very good tutorial about Apache Solr and Facet API.

I downloaded the Facet API bonus module because I thought it would help me.

There are some very good features like Rewrite facet items via callback function, but it seems it only works for the markup; I can't change the input.

function custom_facet_facet_items_alter(&$build, &$settings) {
  dsm($build);
  dsm($settings);
  if ($settings->facet == "field_produit_dev_durable") {
    foreach($build as $key => $item) {
      $build[$key]["#markup"] = drupal_strtoupper($item["#markup"]);
    }
  }
}

I tried to use the Devel modutle o see the content of the variables build, and setting, but there is nothing interesting for me.

So I need two things

Understand how to change the checkbox input
Understand how to remove the count number aside the Yes or No

I made my module and use this, but weirdly it doesn't remove the number.

$build[$key]["#markup"] = drupal_strtoupper($item["#markup"]);

I used the fist tutorial I linked at the beginning of my post, but I found a problem I don't understand.

When I used my code on two different facets I got an error:

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

My code is the same code shown in this article, but I replace the select field with a radio field. I think there is a conflict between the two form, when I validate.


texts: How do I render contextual links for blocks I render in my code?

texts:
I loaded a block subject and content with module_invoke() and used render() for rendering them. I want to use contextual links for this block. How can I render them too?

This is the code I am using insde the page--front.tpl.php template.

$block = module_invoke('block', 'block_view', '4);
print render($block);

What code should I instead use?


texts: Render view array programatically within template

texts:
I would like to print the array of a specific View within a template, so I can then access each specific field and theme as I wish. The view I am using will only be outputting one row. All my attempts seem to be returning 'previously declared' errors.

Your help is appreciated.
Thanks


texts: Drupal Search Result Sorting in Desc order

texts:
I am trying to change my Drupal site's search results. Currently it's showing the default search results by node "Updated or Changed" but i want to change it to node "Created or Published" into Descending ORDER. So all the search results will be  ORDER BY CREATED or PUBLISHED. I have looked at many files but couldn't have any success.

Which files do i have to modify and what code?

Any help will be really appreciated.

Thanks!


texts: TF-IDF ranking for nodes with taxonomy term keywords

texts:
I would need to implement a ranking system that uses the TD-IDF http://en.wikipedia.org/wiki/Tf%E2%80%93idf

Maybe it looks complicated but isn't

Example: "Consider a document containing 100 words wherein the word cow appears 3 times. Following the previously defined formulas, the term frequency (TF) for cow is then (3 / 100) = 0.03. Now, assume we have 10 million documents and cow appears in one thousand of these. Then, the inverse document frequency is calculated as log(10 000 000 / 1 000) = 4. The TF-IDF score is the product of these quantities: 0.03 × 4 = 0.12."

My situation is similar. I have a bunch of documents tagged with keywords, and I have to determine how relevant one term is pro node author.

I found a MYSQL query for this, here: http://snipplr.com/view/51513/

This is the MYSQL Query

SELECT id,
       keyword,
       item_id,
       item_type,
       created_by,
       EXTRACT,
       extract_start,
       extract_end,
       SUM(occurrences / (SELECT keyword_count
                          FROM   keyword_counts
                          WHERE  item_id = t.item_id
                                 AND created_by = [creator user id goes here]
                                 AND item_type = t.item_type) * Log(
               (SELECT COUNT(1)
                FROM   search_results) / ( 1 +
               (SELECT COUNT(1)
                FROM   search_results
                WHERE  '.[keyword '
                        OR ' statements go here].') )))
       AS keyword_density_product
FROM   (SELECT *
        FROM   search_results
        WHERE  ( '.[keyword '
                  OR ' statements go here].' )
               AND created_by = [creator user id goes here]
               AND item_type = [item type, e.g. 'document', goes here]) t
GROUP  BY item_id
ORDER  BY keyword_density_product DESC
LIMIT  [pagination limit goes here] OFFSET [pagination offset goes here];

I would like to translate this to Drupal, it would be a great if somebody could help me.
Thenks


texts: Getting a node-uniqe identifier such as node id or path as replacement pattern at node creation

texts:
I have a content type which consists of a large text field and a number of file fields. Users are allowed to /node/add instances of this content type and are then expected to upload all relevant files to their separate fields.

On disk I want to organize this so that all files end up inside one subdirectory unique for the node, so that I have a file structure:

.../sites/default/files/mycontenttype/
  node1/
    file1
    file2
    file3
  node2/
    file1
    file2
    file3

However, so far I haven't been able to find a value which is a) unique for a node and b) available at the point of adding the node.

I have tried:

[current-page:url:unaliased:path] (ends up as "/node/add/mycontenttype", ie the path for adding the node, not the path the node is about to get)
[random:number] (each field get a different random number)
[nid] (doesn't seem to be available, ends up as "%5bnid%5d")
[current-date:raw] (each field get a different time stamp unless they get uploaded exactly at the same time, ie files can't bee too large)

So question: How can I find a value which is guarranteed to be unique for a node at the point of running /node/add?


texts:
I would like to build a table with Views like this:

          | Header A| Header B | Header C

  Header 1 | Value A1 | Value B1 | Value C1

  Header 2 | Value A2 | Value B2 | Value C2

Header A, B, & C comes from 1st content type and number of columns is variable.

Header 1, 2 comes from 2nd content type and number of rows is variable.

Value A1, B1, C1, A2, B2, C2 comes from 3rd content type and content types are linked to each other with Node Reference fields.

How can I make this table with Views?

Thanks


texts: Where can I download the Windows installer for Drush?

texts:
I cannot find the link where to download Drush windows installer.
Can anyone tell me if there is or how to do?

I am using Drupal 8.1 and Windows 7.


texts:
using Drupal 7, I'd like to add some help text underneath each field for the user who is filling out the comment for a node.

For example, under 'your name' I'd like it to say, possibly in smaller font, "only give your name if you want it published with your comment".

Anyone know how to do this (maybe with hook_form_alter)?


texts: Is there a way to make node titles longer?

texts: I am importing data which has some very long title fields in academic journals. Is there a way to lengthen the title property? Perhaps to 1000 characters?


texts:
Basically, there is a module I'm using and there is a submit button on the page.

When the user clicks submit, it validates and processes the user input before going to the next page.

What I want to happen is that when a user clicks submit, the form does the default behavior of validating and processing the user input. But then I want to add a popup depending on if the previous input is valid. There will also be a button on the popup to take you to the next page.

How can I do this, if at all?


texts: Unable to fetch paragraph's multi field values inside node twig

texts:
I have a content type as "worker". I have a Paragraph "test" and I am referencing "test" paragraph inside my content type "worker". This allows multiple values to be saved.

How can I get the multiple "test" paragraph's field_name inside my node--worker.html.twig file directly?

I am able to get the single value of that field like below:

{{ node.field_test.entity.field_cdsfasdf.value }}

But, unable to fetch the multiple values for this field inside my node--worker.html.twig. I tried using for loop to fetch the multiple values like the code below:

{% for key, item in node.field_para %}
    {{ key }}
    <div class="item"> {{ item.entity.field_cdsfasdf.value }} </div>
{% endfor %}

But, I am facing the following error:

Exception: Object of type Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem cannot be printed. in Drupal\Core\Template\TwigExtension->escapeFilter() (line 465 of DRUPAL_ROOT\exp\core\lib\Drupal\Core\Template\TwigExtension.php).

Exception: Object of type Drupal\node\Entity\Node cannot be printed. in Drupal\Core\Template\TwigExtension->escapeFilter() (line 465 of DRUPAL_ROOT\exp\core\lib\Drupal\Core\Template\TwigExtension.php).


texts:
we are implementing a custom login (based on an auth cookie given by a third party authentication service). When the cookie arrives, we trigger the drupal user_login.
When the user logs out (via a custom box, NOT drupal logout link), we trigger the user_logout.

The problem is: if you clear the cookie auth, you remain logged on drupal.
What hook can we implement to trigger the logout anytime the cookie auth disappear?


texts: How to use term edit page instead of view page?

texts: On the terms list page,  each term is linked to the view page (i.e. term/[tid]). As I don't have any details in the view page, I would like to link it to edit page. (.i.e term/[tid]/edit). How to alter this behavior?


texts: How to limit number of displayed images within one field under views?

texts:
I've created a content type News with different fields, one of the fields is field collection that allows administrator to upload unlimited images with a detailed description text.

I used Views module to display a list of news on the homepage, now I want to limit the number of displayed images within field collection to max 2 per news and when users clicks on the news to see full detail page they will be able to see all images that have been added by administrator.

Is there a way to limit number of items in the frontend but keep unlimited in the backend (admin)?


texts: What is wrong in my code for replacing the text of 'add to cart' button?

texts:
Can somebody tell me what is wrong in my code, please? I'm trying to replace the regular text for 'add to cart' button for two types of product. I'm using Drupal Commerce module. But something is wrong in my code. Works just first part of code.

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

  $product_types = commerce_product_types();

  if (isset($product_types['product']))  {
    $product = $form_state['default_product'];
    $price = commerce_product_calculate_sell_price($product);
    $price_display = commerce_currency_format($price['amount'], $price['currency_code'], $product);
    $form['submit']['#value'] = 'Buy this product ' . $price_display;
  }

  if (isset($product_types['product_2']))  {
    $product = $form_state['default_product'];
    $price = commerce_product_calculate_sell_price($product);
    $price_display = commerce_currency_format($price['amount'], $price['currency_code'], $product);
    $form['submit']['#value'] = 'Buy these products just for ' . $price_display;
  }

}


texts:
So I recently migrated my site between servers. I think this is causing some issue with the base path of Drupal, which in turn affects the image upload path when a user tries to upload an image to his/her profile.

So, before migrating, some data was already uploaded to some of the users and their images and paths work just fine. The path is as follows for example:

www.example.com/sites/default/files/styles/thumbnail/public/pictures/picture-125-1377507580.jpg

But now, when I'm trying to add new users and when I upload new pictures, the image doesn't get uploaded and the path to the image is as follows:

www.example.com/new/?q=sites/default/files/styles/thumbnail/public/pictures/picture-125-1377507580.jpg

Why is this happening? How do I change the Drupal base path? Thanks


texts: How to add css class to a table created using views

texts: I want to add a css class to a table which is created using views. I tried to override "views-view-table.php" in my custom theme but that doesn't seems to work. In "views-view-table.php" I replaced the line "<table <?php if ($classes) { print 'class="'. $classes . '" '; } ?><?php print $attributes; ?>>" with "<table class="responsive">" and then cleared the cache, yet it didn't work. Can any one help. Thanks in advance.


texts: Conditional field on checkbox is not woking

texts:
If the checkbox is checked then it will show the textbox else not, for this purpose i've written this code. But it is not working, even the textfield is not showing.what do i need to change in this code ?

      $form['details'] = array(
       '#type' => 'fieldset',
       '#title' => $this->t('Details'),
      );

      $form['details']['field_type'] = array(
       '#type'    => 'checkbox',
       '#default_value' => 0,
       '#title'   => t('Choose entry type.')
      );

     $form['details']['text'] = array(
      '#type'          => 'textfield',
      '#title'         => t('Enter the text'),
      '#states'        => array(
         'visible'      => array(
           ':input[name="field_type"]' => array('checked' => TRUE),
         ),
       ),
    );


texts: How to modify the Drupal Solr Search fields / apply custom fields / modify results

texts:
Am attempting to understand the report in admin/reports/apachesolr (Drupal 6). There are a large number of fields, and I am trying to understand

1) Are these the fields within the Solr index that are being populated, or are these within Drupal?

2) Assuming they are the Solr index fields, how can I make reference to them? For example, I have added a custom module that hooks into hook_apachesolr_modify_query

$query->add_filter("type", 'job'); // Works fine

$query->add_filter("sis_cck_field_job_approved", 1); // Unsure

Will this filter on those custom CCK fields?

In addition, I am attempting to customise the way that the search captures search terms, applies those additional terms to specific fields and potentially saves them for emailing at a later date. With a little research I have come across Panels + Apache Solr Panels as one approach, and Views 3 and Apache Solr Views as an alternative approach. Is either preferred for a production site? I am specifically looking to

1) Add extra field filters to the search form

2) Build custom field filters (e.g. between Date X and Y)

3) Format the returning results, to show / hide specific node data, and censor particular fields based on a role.

Greatly appreciate all and any response!

Craig Moore


texts: Add additional information to a field of a content type

texts:
Let's say I have a content type Order. It has two fields:

Product1 with values 1-10 and Product2 with values 1-10. I am looking for a way to assign prices to the fields.

For example:

Product1*1 = 10

Product1*2 = 20

...

Product2*1 = 20

Product2*2 = 40

So if someone chooses value 2 of Product1 and value 2 of Product2 the system should calculate 40. I will do the calculation with a custom module, I am just looking for a easy way to define these prices.


texts: ubercart zip/postal code reformatting in views using php

texts:
Is it possible to rewrite in views (possibly with php field) ubercart's customers zip numnber? The original format is "12345". I need to put a empty space after 3rd digit like "123 45". Can anybody help me with php code?
I put

  chunk_split($data->delivery_postal_code, 3, ' ');

inside custom php field inside value field but views output empty field.
Thank you very much


texts: Commerce Order email with an "Unknown" payment method (Drupal 7)

texts:
I placed the order programatically.  Everything seems to work fine, even the "payment method" on the order page is show up correctly.  However the order email I received, the payment method is unknown.  It suppose to show "Add to account"

I don't know why, I thought that could be the email rules is executed before the token is available with the payment method name to use. On Drupal commerce email configuration, it's set to use the token [commerce-order:payment-method-short-title]

$payment_method = commerce_payment_method_instance_load('bank_transfer|commerce_payment_bank_transfer');

 $charge = $order->commerce_order_total['und'][0];

$transaction = commerce_payment_transaction_new('bank_transfer', $order->order_id);
$transaction->instance_id = $payment_method['instance_id'];
$transaction->amount = $charge['amount'];
$transaction->currency_code = $charge['currency_code'];
$transaction->status = COMMERCE_PAYMENT_STATUS_SUCCESS;
$transaction->message = 'Name: @name';
$transaction->message_variables = array('@name' => 'Add to Account');

commerce_payment_transaction_save($transaction);
commerce_payment_commerce_payment_transaction_insert($transaction);
commerce_checkout_complete($order);
commerce_order_save($order);


texts:
I have a Drupal View that was created to show users which are members of the site, this works fine but now the client wants to see not only users on the same view, but also content of type "X", but when I try to add the Filter Criteria for Content type = X , that Filter is not available (don't know why I can't see it), I don't know if this is related to the fact that this was a view created to show Users and not Content from the very beginning.

My question is, what would be the way (hopefully the easiest) to show not only users but also content of Type "X" on my view ? I don't need any logic between the user and the content, is just show on the view results Users and Content of type "X".

Thanks in advance.


texts:
I have two instances of main_menu on a page. One is in the header, using superfish. The other is in the sidebar, using menu_block.

I want to hide a menu item in the sidebar and show it in the header. Is this possible?

Could you use template.php to target a block/region?

For example:

function my_theme_preprocess_block(&$variables) {
  if ($variables['region'] == 'content' && $variables['block']->module == 'menu_block') {
    // What would go in here?
  }
}

Any help would be greatly appreciated.

Thanks,

Steve


texts: How to implement an option for users to limit access to nodes/comments to users with the same role while posting it?

texts:
How can I offer users an option on all node/comment postings to limit access to their own user role group? Essentially making the conversation accessible only for the members of their own year who they are together with in person.

Each year gets its own user role. There are multiple years of group members using the site, and sometimes members would like to limit sensitive content to themselves, as old members retain access to the site otherwise.

Ideally, it would just be a single checkbox that reads 'make this content private to your peer group' without offering any other options, which should restrict the content to their own peer group and to admins.


texts: At the bottom of each blog post I need to show a teaser for the next blog post. I know there is module to add links to next/prev blog. But I need to show more than a link. I need to show the title and summary. Could someone please suggest a way to achieve this?


texts: Why am I getting the "Argument 2 passed to drupal_array_set_nested_value() must be of the type array, null given" error?

texts:
The Drupal "Search" module is not working when accessed from the /search/node page.

When I use the search functionnality from a Search block, it redirects me to the /search/node/mySearchKey (I entered mySearchKey in the block) and displays the results correctly.

But when I use the search functionnality from the "Search form" it redirect me to /search/node/ and an error appears. "Error : the website encountered an unexpected error. Try again later". The request POST show a HTML 500 response.

The error report shows this:

  Recoverable fatal error : Argument 2 passed to
  drupal_array_set_nested_value() must be of the type array, null given,
  called in \includes\form.inc on line 2657 and defined dans
  drupal_array_set_nested_value() (ligne 6703 dans
  \includes\common.inc).

The code causing the error is drupal_array_set_nested_value($form_state['values'], $element['#parents'], $value, TRUE);`.

I checked the values of $value.  I have an array with 17 entries.

string 'node' (length=4)
string 'form-xxxxxxxx' (length=48)
string 'xxxxxx' (length=43)
string 'search_form' (length=11)
string 'mySearchKey ' (length=7)

The last entry of the array is string 'mySearchKey' (length=7)
We can see that mySearchKey appears 2 times in this array.

I have also checked $element['#parents']. I have an array with 17 entries.

string 'module' (length=6)
string 'form_build_id' (length=13)
string 'form_token' (length=10)
string 'form_id' (length=7)
string 'keys' (length=4)

We can see that the values matches the values array, but the last item of $element['#parents'] is null, when it is supposed to match my duplicate mySearchKey entry.

I think the null value from my error comes from here.
I have no idea how it get there.

Someone has an idea of how to fix it ?


texts: Reorder the Basic page list in views .How?

texts: I have created views to display basic pages in blocks.I what to reorder the list according to me .How to do?Plz help......


texts:
I have JSON file with some id and value, and this need to be populated in form as select list:

$form['select_item'] = [
      '#type' => 'select',
      '#options' => $list,
      '#title' => $this->t('Choose'),
      '#required' => TRUE,
    ];

What is the best way to approach this. Can I somehow convert this JSON in array or something and use it in options?

I would like to have this values form JSON in separate file and to use it from there.

Any idea?


texts: How do I alter a boolean value and display a string in views output?

texts:
Whats the best way to override a simple 0/1 boolean field in views output so instead of 0/1 it would output "Hello" or "Goodbye"?

EDIT: To improve on my question:

Whats the best way to add further options to the default view boolean handler? For example ...

$default_formats = array(
  'yes-no' => array(t('Yes'), t('No')),
  'true-false' => array(t('True'), t('False')),
  'on-off' => array(t('On'), t('Off')),
  'enabled-disabled' => array(t('Enabled'), t('Disabled')),
  'boolean' => array(1, 0),
  'unicode-yes-no' => array('✔', '✖'),
  'drunk-sober' => array(t('Drunk'), t('Sober')),
  'hello-goodbye' => array(t('Hello'), t('Goodbye')),
);


texts: How to add link to Comment Author's User Profile page

texts:
The below code is from the comment.tpl.php file:

<?php print $picture ?>

<?php print render($content['submitted_by'] ['#markup']);?>

I want "$content['submitted_by'] ['#markup']" to link to the user profile of the user who posted the comment.

i have tried editing the code to something like this:

<?php $link = drupal_get_path_alias('user/' . $user->uid);?>

<?php print $picture ?>

<a href="<?php $link ;?>"><?php print render($content['submitted_by'] ['#markup']);?>

But it links to the user profile of the currently logged in user.

What I would like is to link it to the profile of the Comment author.

Thank you.


texts: How to implement a custom field available for Views?

texts:
I'm making my first steps authoring simple modules. I would like to make my life easier by implementing a custom field for taxonomy views, a field named: "Taxonomy term: Arbitrary ascendant" so that it gets a term's ascendant at the given hierarchy level, as returned by taxonomy_get_parents_all.

Similarly, for content Views, I would like to provide a field configuration that would allow for ascendant tests for any term on an entity.

Could anyone point me to the Views API functions that must be taken into account to make this module properly authored?


texts: Pass hidden fields using drupalSettings to Twig template

texts:
We have a paragraph field (field_pr_custom) on the Basic page content type that has a custom twig template, pr-custom.html.twig. In the twig template, we need to pass in an array inside of a <script> tag. To accomplish this, we use the mymodule_preprocess_paragraph__pr_custom hook and set the array using the #attached variable. However, when we print the drupalSettings we are not finding the value passed in. There is no Drupal behavior used.

How can we pass the value in an array from the mymodule_preprocess_paragraph__pr_custom into the drupalSettings variable inside the pr-custom.html.twig template?

Here is what we tried:

mymodule.module

function mymodule_preprocess_paragraph__pr_custom(&$variables) {
  // pass node id.
  $node = \Drupal::routeMatch()->getParameter('node');
  if($node instanceof \Drupal\node\NodeInterface) {
    $variables['elements']['#attached']['drupalSettings']['myArray']['myvar'] = $node->id();
  }
}

pr-custom.html.twig

<div>
  {{ content.field_text }}
  <script>
    // this doesn't print myArray and doesn't even have it.
    console.log(drupalSettings);
  </script>
</div>


texts:
In custom module which selects field (collation: utf8_latvian_ci) from database ordered ouput gives wrong alphabetical order:
"Aaaa, Āaaa, Abb, Acc" instead of "Aaaa, Abb, Acc, Āaaa".
This can be corrected by query like this

[..] ORDER BY myfield COLLATE utf8_bin

and then I can get correct order.

Here is my query from custom module:

  $query = db_select($table, 'd');
  $query
    ->fields('d', array('myfield1', 'myfield1'))
    ->condition('d.field1', $field1, '=')
    ->orderBy('field1');
  $return = $query->execute();

Can I specify ORDER collation using Drupal's query structure? Or only workarounds can help?


texts: Why does my Drush post_make hook not run from bash script?

texts:
I have written a drush extension that runs some post_make operations.

It's all good when I run $ drush make normally.

I have also written a bash script, which with some arguments, perfoms also drush site-install and other file structure stuff. The problem is when I execute this script and bash runs my drush make, my extension and post_hook is not running.

I know it's more of a bash permissions/ownership thing or something, than a drush issue, but does anyone have an idea?

My extension lives in ~/.drush/extension.

I'm using drush 5.9 and this is the actual script.


texts: What are the template variables to identify that a page is a term or user?

texts:
I'm trying to modify a theme so that when the term page or user profile page are displayed it doesn't generate the title at the top.  I figured out how to do it on nodes but I just can't figure out what variable is used in the following code to identify a user or term page.  Any thoughts?

Here's the code from my page.tpl.php in a Bootstrap v3 theme:

<?php if (!isset($node)): ?>

<?php print $title; ?>

<?php endif; ?>

The above example suppresses the title when the page being viewed is a node.  I'd like to get this to work for user and term pages as well.


texts: Commerce Node Checkout free option skip cart/checkout/payment

texts:
I am working on a free/paid listing site. I setup Commerce Node Checkout with Node Checkout Expire and have a free version(14 days) and a paid "featured" option (30 days). The paid option should go to cart->checkout->payment while the free option should act and behave as if Drupal Commerce wasn't installed.

I was looking around rules but I can't seem to find the proper events/conditions/actions to basically treat free listings as regular drupal nodes. I don't really want to track orders for free listings, but I also don't want to mess Drupal Commerce's reporting up either.

Can rules do this? And if so, what would be the proper events/conditions/actions to bypass Commerce all together and just publish the node if "free listing" is selected under listing options for Node Checkout.

Thanks


texts: Update cart button removing item from cart

texts:
I am working on an issue presented to me on a Drupal Commerce site. For some reason, when you click on the update cart button on the cart page, without actually making any changes, the top item in the cart is removed.

Any ideas?


texts: Scheduled Update - publish new draft of an existing and published node

texts:
Trying to setup a scheduled update of an existing node (Drupal 8.3).

I make content changes and setup Moderation State to draft - node is still visible to visitors, and new revisions is saved with changes to node content.
I setup scheduled update - Publish single node at certain time, and set Moderation State to Published.
Click Save

Result - When I run Scheduled Updates node moderation state changes to draft and is no longer visible to visitors.

Any idea why it doesn't change node moderation state from draft to publish?


texts: Views not showing date field in proper time zone

texts:
I created a node type with a date field (from the date module).  I list nodes of this type in a view.  The problem I have is that the date values being shown by the view are in UTC (ie as they are stored in the db) not in the user's local timezone.  I have tried the following to no avail:

1)  Unchecked "Administration » Configuration » Regional and language » Users may set their own time zone".  I then logged out and cleared the cache.

2)  Verified that if I view the node outside of the view (ex: going to http://mysite.local/node/123), the time appears in the proper timezone.  The proper dates are also shown when editing the node.

3)  Tried to format the date using this code:

format_date($date, 'custom', 'D d/m/Y - g:ia', date_default_timezone_get())

$date is a timestamp and date_default_timezone_get() returns the proper timezone.

4)  Tried this with the date_views modules enabled and disabled.

For some reason the view pulls the date field value straight from the db without converting it to the proper timezone.  Unfortunately, I don't know how to either 1) tell views how to convert it properly, or 2) convert it manually in a template.

Note: I refuse to hard-code my timezone into my template.  This is a terrible option I've seen when searching for an answer to this.


texts: View outputs Access-Control-Allow-Origin header

texts:
I have created a view (via the views module) which outputs a JSON output (minus the template etc) I have loaded the page and it outputs data as required.
I now need to call this page from another domain (cross domain) - however, when I am calling the page from the other domain (through javascript) I am obtaining the common

  Failed to load https://<>: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

The Query: Where within the views module would I be able to set the 'Access-Control-Allow-Origin' value such that it would either allow all requesting sites to be served the page or only specific domains to be served the page.

Side Note: As things stand I am not able to install other modules on the primary domain where the JSON page resides, as I am restricted to what I can do on that site.

As people of have worked with cross domain access will no doubt have guessed by now I am using the Chrome browser.

Side Note 2: When I use the Chrome extension "Allow-Control-Allow-Origin: *" I am able to load the page as required because the whole access control check is by-passed, but I need the loading functionality to work without the need for such an extension.


texts: Only Show Nodes From Child Terms (-1 excluding parent)

texts:
Hello i have some nodes which i am using as to hold information on a taxonomy term (image, desc etc) and I have created some block views to pull that information to display on my taxonomy/term pages (yes om on D6 due to custom modules and upgrade problems)

Also ive made the term nodes appear on the parents term page in a node view.

Sport
-American Sports
--Baseball
--NFL
-Football
--England
(etc)

This is in a View with tax depth of -1 (just show the immediate children) If i visit 'Sport' I only see my 'Sport' stuff and then below in the child term (node) View i see

American Sports
Football

Well in an ideal world thats all i see but because i am in 'Sport' I also see the node for the 'Sport' term that i am in.

Sport
American Sports
Football

I want the -1 in depth but i dont want the '0' if that makes sense.

I have tried excluding the argument, like you do for for nodes with nid but it doesnt seem to work the same.

Its the same all the way down. If i go into 'American Sports' in my list of nodes that are referance (like that old drupal video from Bob (the christian) 'taxonomy on steroids) shows as-

American Sports
Baseball
NFL

etc.

Aye so in a round about way i was wondering how to exclude...no how to only display, nodes of child terms (-1)

All help appreciated as its been annoying me for a while and ive been trying to sort it for ages.

thanks


texts: Advanced form block - fields not showing in block configuration

texts:
I have installed Advanced Form Block (AFB) in a Drupal 7 site.

At first the AFB settings didn't show. But after applying the patch from issue 1863852 that got resolved. I can now create blocks, but in my block configuration form no fields are showing up. I am not getting options like in this image:

Basically I have a content type add content form that I was hoping to be able to split up into different blocks. I created an add type of block but when I go to that blocks configuration page I don't get any options beyond the normal options (no field selection options are presented to me).

Any idea why?

Infact the block isn't displaying at all, and I tried using different content types. When I go to the block configuration and save it I also get these notices:

I have been and am continuing to use Form Block.

Thinking about it those notices appearing would seem to be part of the problem as they would hint that the fields aren't being found and therefore cannot be displayed.


texts: Email all users when a new content is published in Drupal 7

texts:
I want to send email notifications whenever a new content is published in the site. It would be helpful if I can do it by Actions - using Actions & Triggers I can use token to mail a single user, i.e. author of a node. But how do I send email notification to ALL authenticated users of my site?

P.S. It is necessary that emails appear in bcc field, to avoid Spam. I've searched a lot, but no specific solution was found.


texts: Making a variable in a certain node type and access that variable in another node type

texts:
I'm fairly new to Drupal. But I'm trying to learn.

What I'm try to accomplish is have a variable in a certain node type (artist) and I want to access this variable in another node type (news). Is this possible?

Let's say I have two content types, Artists and News. The artist node will have (at some point) related pictures, songs, and news. But at default it does not have any. So I wanted a variable that acts like a flag that if there are any related pictures the flag is changed. In the news node, I have tags that point to an artist if the news is related to him/her, then I'll show the same related songs, pictures of the same tagged artist. I want the flag variable as a checker if there are truly related songs/pictures. In that way I'll just use the flag and before I query the related pictures/songs


texts: Converting the login / register / password reset tabs into three different pages?

texts:
I want to separate the user account menu tabs structure into an individual page layout.

For short I want to remove the tabs, I know that the pages are different.

Snapshot attached.

What I have done so far is trying to use the theme suggestions but couldn't get any closer.

I get to know that it's being rendered from:

  themes/bootstrap/templates/block/block--local-tasks-block.html.twig


texts:
On a Drupal 8 site, I see an error on a block which says:

  This block is broken or missing. You may be missing content or you might need to enable the original module.

How can I resolve this error?


texts: Drupal 7 "undefined function" fatal error; from FTP error

texts:
One of the guys here deleted a module folder, in error, from drupal 7 site using FTP (I know but it was a mistake).

the Commerce module was deleted. Now can not access the site at all as we are getting a fatal error
Fatal error: Call to undefined function commerce_pricing_attributes_property_info_callback() in /var/www/sites/all/modules/contrib/entity/modules/field.info.inc on line 30

Anyone know how to correct it?
line 30 is
    $callback($info, $entity_type, $field, $instance, $field_type);

The function in question is below

function entity_metadata_field_entity_property_info() {
  $info = array();
  // Loop over all field instances and add them as property.
  foreach (field_info_fields() as $field_name => $field) {
    $field += array('bundles' => array());
    if ($field_type = field_info_field_types($field['type'])) {
      // Add in our default callback as the first one.
      $field_type += array('property_callbacks' => array());
      array_unshift($field_type['property_callbacks'], 'entity_metadata_field_default_property_callback');

      foreach ($field['bundles'] as $entity_type => $bundles) {
        foreach ($bundles as $bundle) {
          $instance = field_info_instance($entity_type, $field_name, $bundle);

          if ($instance && empty($instance['deleted'])) {
            foreach ($field_type['property_callbacks'] as $callback) {
              $callback($info, $entity_type, $field, $instance, $field_type);
            }
          }
        }
      }
    }
  }
  return $info;


texts: Link to the same page but without ?arg=value parameters

texts:
How to create link in Drupal 7 that will redirect me to the same page but with omitting "?arg=value" query fragment?

The following code doesn't work, as it always add ?arg=value.

<?php echo l(t('My Label'), 'views-page-url'); ?>

<a href="<?php echo $_GET['q']; ?>"><?php echo t('My Label'); ?>


texts: WSOD while trying to install Drupal Commerce Kickstarter

texts:
I'm trying to install Drupal Commerce Kickstarter with core, but I cannot go past random WSOD, or hangs, to complete installation. WSOD happens randomly, but mostly after "Configure site" step. Very rarely I can reach "Installing additional functionality", but then it just stops at some point and won't move.

(At this point:  )

I'm trying to install it on local apache2, and have 128M of memory_limit, 1000 of max_input_vars, and 60 of max_input_time. If you need any more information, just ask and I will provide it. What can I do to complete installation?


texts:
I have a form that users can fill out and it creates a node, an event node to be shown in the community calendar of my website. I'm using Rules to create the new node when the "Webform: After a webform has been submitted" event (requires Webform Rules module).

Everything is working well except for the Date field. The event node needs a date and time, that's kinda the point of a calendar!

I can select the webform data with [data:date-value] and [data:time-value] and I know that they output the correct data because if I put them into a regular text field ([entity-created:body:value]) the date and time show up just fine. And I can use PHP if I need to:

<?php
  echo $data['components']['date']['value'][0] ;
?>

I just don't know what Data Selector to choose for the date field. There's several that Rules knows about but so far I have no luck:

entity-created:field-date

if I choose this, in the resulting page to set the new value, there is no PHP Evaluation or Replacement Patterns available to use, only the Data Selector ajax dropdown, which doesn't allow for the [data:date-value].
and it says "Data types: Select data of the type List<struct>."

entity-created:field-date:0 - it goes from 0 to 3 although there's only 1 date field for the event node, and they all the same

if I choose this, in the resulting page to set the new value, there is no PHP Evaluation or Replacement Patterns available to use, only the Data Selector ajax dropdown, which doesn't allow for the [data:date-value].
and it says "Data types: Select data of the type Struct."

entity-created:field-date:0:value (Start Date)

in the resulting page to select the new value, it says: "Data types: Select data of the type Date." so I think it's a step in the right direction...
now there's a plain value field I can use (direct input mode),

instructions say: "The date in GMT. You may enter a fixed time (like 2016-06-04 16:01:07) or any other values in GMT known by the PHP strtotime() (link is external) function (like "+1 day"). Relative dates like "+1 day" or "now" relate to the evaluation time." If I put "+1 day" into the field and test it by submitting the webform, then a node is correctly created with the date field set one day into the future.

I can switch to the Data Selection mode and I have Data Selectors, PHP Evaluation and I can add an offset.

if I set the new value to [data:date-value] or [data:date-value] [data:time-value] then it doesn't say there's any errors, but when I test it but submitting the form and checking the new node that was created, the Date field was not set
if I try to set the value to <?php echo $data['components']['date']; ?> ... still no luck. And no errors are displayed or logged.

it also lists entity-created:field-date:0:value2 (End Date) and entity-created:field-date:0:duration (Duration) as possible "Set a data value" things to select

Anybody have any idea what I'm supposed to do here?? Thank you!


texts: Programmatically update node image field (using URI of the image) and get URL in twig

texts:
I am trying to update a node image field programmatically. I currently loading the node like this:

$node = Node::Load(1);

have the URI if the image that I want to set. I have tried this but no luck:

$node->set('field_image_head', array('#uri' => $imageUri));

How do I now update the node image with an image URI?
The twig will need to get the URL from the image field like so {{ file_url(node.field_image_head.entity.fileuri}}


texts: How to auto resize the height of an iframe with Jquery?

texts:
Any idea on how to automatically resize the height of an iframe based on its content.

The iframe source is coming from different domain.

Any thoughts on how to achieved it via Jquery or native JS?

Thanks

UPDATE:
This script addressed my needs.

Drupal.behaviors.cnngomobile = function (context) {
    $(window).bind('load', function(){
        var adsIframe = document.getElementById("303799");
        if (adsIframe) {
          var style = adsIframe.contentWindow.document.createElement("link");
          // create <link>
          var host = "http://"+location.host+"/sites/all/themes/cnngomobile/css/style-iframe.css";
          style.setAttribute("href", host);
          style.setAttribute("rel", "stylesheet");
          style.setAttribute("type", "text/css");
          // append
          adsIframe.contentWindow.document.head.appendChild(style);
        }
    });
  };


texts:
My users can only become activated in only one group after subscription. I have mentioned them to subscribe without approval. But, when each of them subscribe in one group, can not see the link of subscribing for other groups.

So, I have also activated the:

Organic groups access control
Organic groups field access

And I am using the last version of OG beside drupal 7. And, I have also activated the private/public option for groups.

Please help me.


texts: How to add a layout specific hook_preprocess_page to omega 4 using multiple layouts?

texts:
I'm using omega 4 and I can't seem to be able to add a preprocess function to any of my pages using layouts

This is some tests I've made without any result.

Adding:

web_contacto_rector_preprocess_page(&$variables)
on

[theme_name]/preprocess/page.preprocess.inc
Adding:

web_contacto_rector_preprocess_page(&$variables)
on

[theme_name]/layouts/[layout_name]/[layout_name]-layout.preprocess.inc

Is there something I'm missing?


texts: Some of my Panel content is missing for anonymous users. What went wrong?

texts:
I've set up a landing page panel with two items in it, a content page with a welcome message and a view showing certain content. It works great, but when I look at it as an anonymous user only the view is showing up, not the welcome page message.

I haven't put any special access conditions and my only variant is the landing page and I can see all the content in the preview, so I don't understand why it isn't visible to everyone. The welcome message is on a published page as well, and caching is disabled for that panel for the moment.


texts:
I'm using drush 9 on a remote server and I'm trying to perform a sql:sync.

This is my alias:

live:
  host: www.mysite.com
  paths:
    drush-script: '/home/wodby/drush-wrapper.sh'
    files: files
  root: /var/www/html/web
  ssh:
    options: '-p 9191 -o "AddressFamily inet" -o "StrictHostKeyChecking=no"'
  uri: www.mysite.com
  user: wodby

The "drush-wrapper" is a script (on remote server I've docker, so  I use ssh to connect into the container. The wrapper is this:

export PATH=$PATH:/usr/local/bin
/home/wodby/.composer/vendor/drush/drush/drush.php $@

This alias works (for commands like drush cr or cim) but doesn't work the sql:sync command.

If I try to run drush sql:sync @d8.live @self I obtain:

 Error: no database record could be found for source @d8.live

How should I add this configuration about database?


texts: How to redirect to original page after node create

texts:
I have a link to a create node form from a particular page.  After the user creates the node and saves, I want to redirect the user back to that page (and not to the new node URL).

What is the best way to do that?


texts: Create token with translatable variable in pathauto

texts:
I would like to be able to create my own tokens for pathauto. In D7 I was able to create with the variable module some variables to represent a portion of an url. These variables where available as tokens and I had a different per content types and where translatable.

For example I would like to be able to do that:

[content-type-monthly-theme-base-url]/[node:title]

I can do that:

featured/[node:title] but the word 'featured' is not translatable

Another solution would be able to translate patterns. ATM only the pattern title is translatable! Not usefull...

As a last resort I can add a field base_url in my content type Monthly theme and use it as a token. But this means each time someone would create a node of this content type he or she would have to make sure the base_url field is in the right translation. This should really be configurable else where.


texts: Twig adds an unwanted 'row' class that doesn't appear in class array

texts:
My site theme includes customised templates for 4 regions in the footer, all containing identical code:
  set classes = [
    'region',
    'region-' ~ region|clean_class,
    'col-sm-12',
    'col-md-6',
    'col-lg-3',
  ]
%}
{% if content %}

    {{ content }}

{% endif %}

However, the HTML it produces varies.
In the first two regions, the class row is being inserted - despite it not appearing in the classes array:

In the last 2 regions, the row class is missing - which is the correct code I want:

I can't figure out where it's coming from, so my workaround is to include an additional step that removes the class, in the first two region templates only:

This gives the result I want, but I'm still not sure where the row class comes from and why it was being applied inconsistently??


texts: Undefined variable error in node.tpl.php

texts:
I'm using the Basic theme, and I get the following error when I refresh my site.

  Notice: Undefined variable: unpublished in include() (line 18 of /Users/me/Projects/mysite/httdocs/sites/all/themes/mytheme/templates/node.tpl.php).

The line that is caused the notice is the following one.

    <?php if ($unpublished): ?>

<?php print t('Unpublished'); ?>

    <?php endif; ?>

<?php endif; ?>

I don't understand this error. How can I fix it?


texts: How can I use the Commerce Paypal module module without the Commerce module?

texts:
I have a form, which has an amount and item detail values to pass to PayPal.

I have installed the Commerce Paypal module, but I don't find any clue on how to integrate it so that when the form is submitted, it should go to PayPal for transaction. On success, it should redirect to the success URL; likewise, it should happen on failure, where the users are redirected to  the failure URL. I haven't installed the Drupal Commerce module as there is no use of pages like catalogs and checkout in this system.

How can I use the Commerce Paypal module?


texts: Pods created after the first try to load the private files using the same path as the first one

texts:
I'm currently working on deploying Drupal8 on Openshift to achieve horizontal scaling, but I hit a problem.

On a single pod (ie: "server" running drupal"), everything seems to be ok so far. But when I'm deploying a new pod, it tries to load the private files (/sites/default/files) using the same path as the first pod.

I guess it's because something is cached in the DB since "Clearing all cache" fixes it.

Is there something in the configs I can do to prevent this behaviour ? And do you think of something I should be warned about when trying to achieve horizontal scaling ?


texts: Make blog available to authenticated users only

texts:
I have a site which lists some events in a block using the agenda module.  I have this set to be the main content (eg taking up the center of the page).  This is the only content I would like general visitor to see.

I would like to use the same site to have a private blog which is only available to logged in users.

Is there a  way I can restrict viewing of the blog pages to anyone not logged in?

I have tried simply removing the view content permission but this causes other issues!


texts: How to display event's views block inside another content type's content section with only events related to that content alone?

texts:
I am working on a drupal7 site. The scenario is that, there are 2 content types namely singers and events. When i am adding an event, i need to add an event to a singer, so that when i am viewing a singer's node page, i can see  block containing events related to that singer alone.

I have done the events block inside the singer's content page(Using the views block). But it displays all the events and i want to display the only the events related to that singer alone. I have tried to make it using term reference or some other stuff. But nothing have worked out. Can anyone help me out to get this scenario working. Thanks in advance.


texts: How to do some calculations using fields within a Field Collection field?

texts:
I have a Field Collection field and I'm trying to do the following:

Multiply the value in one field with the value in another field and have the result shown within a third field.

I have tried Mathfield, but it doesn't support Collection Fields.

Is it possible to do this with Computed Field? How? Or would be difficult to write a custom module to do this?


texts:
I'm teaching myself Drupal theming, so naturally, one of the first things to think about with my (Zen) sub-theme are regions. However, the documentation is lacking in its explanation of the meaning of a couple of the defaults.

On the Assigning Content to Regions page, it says:

  Drupal 7 adds Highlighted and Help as default regions. By default, the textual content of the Help region is the same as the $help variable was in page.tpl.php for Drupal 6.

This is very bad copy, because it never actually states what these regions are for. And although the meaning of most of the regions (content, header, footer, the sidebars, etc.) is pretty obvious, I'm a bit fuzzy on the precise meanings of Highlighted and Help. Is Help the place where system messages (like the "theme cache is being rebuilt on every page view" message I get while I develop) are printed... or is that what Highlighted is for?


texts: Fetch fields of a block defined via content type programmatically

texts:
I've created a block type via the UI. This is a translatable block with 3 text-fields.

I am using hook_block_view_alter($build, $block) to massage the data. However, I can not seem to find the fields neither in $build or $block vars.
Any idea on the fetch the field's values programmatically?