texts: Creating a block that lists various posts for various categories

texts:
I need to achieve something like this:

This is a block on a page. Stuff like U.S., Politics, World etc. are the categories (created by adding a custom vocabulary) and the sub-links are articles under those categories. I'm using Drupal 7.8 and have the Views module installed.

Maybe I could write some PHP code and save as a block and then add that to a region. If so, which functions would I need?


texts:
I have a search: search terms field setup in a view in drupal 7. It's exposed to users so they can search nodes.

I know my users are using the search but google analytics isn't capturing that information.

I also looked at reports > top search phrases and it shows nothing...even though I believe views uses the basic search module.

My question is: is there a way to see statistics on what terms users are using to search with this view?


texts: What does rebuilding content access permissions do?

texts:
Since installing the node access module I see the following message randomly.

  Content access permissions need to be rebuilt.

Will rebuilding them remove all the node access permissions already set? What does "rebuilding" do? Why do I get this message?


texts: content_extra_field_weight() function in Drupal 7

texts: I am porting a module to Drupal 6. I came across this function content_extra_field_weight(), what is the similar function in Drupal 7 for content_extra_field_weight()?


texts: Remove Configuration Management Destination

texts:
I'm using drush cex or drush cim to export and import configuration on D8 site.

Every time I run those commands, I get asked a question to select option for cancel, sync or staging, which is quiet annoying.

Is there a way to remove staging destination and only use sync so that I can use drush cex -y or drush cim -y without errors?


texts: WSOD with error when login as administration

texts:
I was working on website and suddenly noticed that a particular page had a error message and lost a lot of css styles.

When I went back to the back-end I saw a white page with following message and nothing else (no administration menu, no content overview, ...

Error message

Additional uncaught exception thrown while handling exception.

Original

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE s.sid &lt;&gt; :session_id AND c.obj = :obj AND c.name = :name ORDER BY c.updated ASC; Array ( [:session_id] =&gt; HWv-9jPhNMHqjMdxRprJh-YmmBQc2y0jWXrbR_68TeA [:obj] =&gt; view [:name] =&gt; article_4pc ) in ctools_object_cache_test() (line 145 of /home/admin/domains/peace-in-the-city.be/public_html/sites/all/modules/ctools/includes/object-cache.inc).

Additional

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] =&gt; 1 [:db_insert_placeholder_1] =&gt; php [:db_insert_placeholder_2] =&gt; %type: !message in %function (line %line of %file). [:db_insert_placeholder_3] =&gt; a:6:{s:5:&quot;%type&quot;;s:12:&quot;PDOException&quot;;s:8:&quot;!message&quot;;s:382:&quot;SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE s.sid &amp;lt;&amp;gt; :session_id AND c.obj = :obj AND c.name = :name ORDER BY c.updated ASC; Array ( [:session_id] =&amp;gt; HWv-9jPhNMHqjMdxRprJh-YmmBQc2y0jWXrbR_68TeA [:obj] =&amp;gt; view [:name] =&amp;gt; article_4pc ) &quot;;s:9:&quot;%function&quot;;s:26:&quot;ctools_object_cache_test()&quot;;s:5:&quot;%file&quot;;s:103:&quot;/home/admin/domains/peace-in-the-city.be/public_html/sites/all/modules/ctools/includes/object-cache.inc&quot;;s:5:&quot;%line&quot;;i:145;s:14:&quot;severity_level&quot;;i:3;} [:db_insert_placeholder_4] =&gt; 3 [:db_insert_placeholder_5] =&gt; [:db_insert_placeholder_6] =&gt; http://peace-in-the-city.be/admin [:db_insert_placeholder_7] =&gt; [:db_insert_placeholder_8] =&gt; 178.118.99.54 [:db_insert_placeholder_9] =&gt; 1426611072 ) in dblog_watchdog() (line 160 of /home/admin/domains/peace-in-the-city.be/public_html/modules/dblog/dblog.module).

Uncaught exception thrown in session handler.

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT 1 AS expression FROM {sessions} sessions WHERE ( (sid = :db_condition_placeholder_0) AND (ssid = :db_condition_placeholder_1) ); Array ( [:db_condition_placeholder_0] =&gt; HWv-9jPhNMHqjMdxRprJh-YmmBQc2y0jWXrbR_68TeA [:db_condition_placeholder_1] =&gt; ) in _drupal_session_write() (line 209 of /home/admin/domains/peace-in-the-city.be/public_html/includes/session.inc).

I was able to login as another users without any problems. I flush caches and run cron and this have not solve my issue.

How can I troubleshoot this problem ?

You can find the website here.


texts: Showing a message for specific content type

texts:
I'm trying to show a message for specific content type through a new module, on Drupal 8.3.0. (I'm a beginner.)

This is part of the code I am using.

File test_module.module (updated code, still not working)

/**
 * @file
 * Implementation of hook_node_view();
 */

function test_module_node_view($node, $view_mode) {
  if ($view_mode == 'full' && $node->type == 'test_content') {
      /*Message with current date and time*/
      $current_time = time();
      drupal_set_message(t('Hello! Today is '.format_date($current_time,'medium')));
    }
  }

As far as I know, this should work, but it doesn't and I don't know why. The message is not showing for a node of content type "test_content". How can I fix this? Is there another way to alter nodes of custom content types?

(Test_content_example is a node of type 'test_content', so there should be a system message displayed, but there's none.)


texts: make sure hook cron is only run once a day setting

texts:
I'm building a hook_cron in my module but I actually don't want it to run at a maximum of once a day.
Is there a Drupal setting for this or do I need to check when the last cron was run and see if that was at least 24 hours ago? How do I do this?

I'm using drupal 7


texts: "The directory sites/default/files is not writable" error

texts:
I am trying to install drupal 8.1 on a CentOS linux machine as root user.
I am getting "The directory sites/default/files is not writable." error. Before that, I had to manually create the sites/default/files folder. I have even changed the permission to 777 for all files and folder in "sites" and its sub folders and 'root' is owner of all files and folders/subfolders.

  -rwxrwxrwx. 1 root root  5997 Apr 27 05:28 default.services.yml
  -rwxrwxrwx. 1 root root 29105 Apr 27 05:28 default.settings.php
  drwxrwxrwx. 2 root root     6 Apr 27 05:45 files
  -rwxrwxrwx. 1 root root 29105 Apr 27 05:40 settings.php

How can I fix this issue?


texts: How to retroactively apply Mollom spam filtering?

texts:
I've been asked to clean up a site that's been running for a few years, and has accumulated some spam in addition to a lot of valid content.

I've just installed Mollom on the site to help reduce future spam postings; but is there some way I can have Mollom process what's already been posted to the site, and flag potentially-spammy content for my review (rather than having to review all of the mostly-valid content individually)?


texts:
I'm using the default register form on a custom page, which I want to use to set a specific role for the user who registers using that custom page.

Now I need to know how I add this specific role when the user registers.

Can I use like, the submit funcion for the custom form function, and then use user_multiple_role_edit()?

But how di I get the $uid?

What's best?


texts:
I have a problem in a custom module I can not figure out, I have an update hook like this one:

function article_update_7003() {
  features_revert(array('article' => array('field_base')));
}

But it does not revert the feature. But if I run that update, and manually change it to:

function article_update_7004() {
  features_revert(array('article' => array('field_base')));
}

And run it, the feature is reverted. Anyone that knows what is going on? I tried to duplicate it the first time, but that does not help...

function article_update_7003() {
  features_revert(array('article' => array('field_base')));
  features_revert(array('article' => array('field_base')));
}


texts: How to enable revisioning for user photo (user/profile field)?

texts:
I want to moderate pictures, uploaded as user avatars. So, I need:

History for user field “Photo” to see all previous photoes.
UI for accepting or declining new photo.

How can I implement it?


texts: User registration with content profile + data manipulation on submit

texts:
I'm actually using a type with content profile in my user register form, and I'm trying to manipulate both the user and node data after submitted and inserted in database. I'm supposed to use hook_user with $op insert/after_update/update, but I dont get any data from my content profile node, just the user data, and I also tried hook_nodeapi also with $op insert/update, but got no success too.

I have a custom module, and also tried to change the weight in system, to be executed before the content-profile module.
This is driving me nuts!

Do you have any idea on how I can manipulate that in the user register submit?


texts: Drupal 8 create a template override for a view block within a custom module

texts:
The Question:

In Drupal 8: How do I add a template override for a view block and have that twig file reside in a custom module - not my theme?

Further Information:

I have already created a custom module that creates a content type, imports data from an RSS feed and generates nodes into the content type it created.  The module also contains a view YML file so that the view for my content type is created when the module is installed.  The view only has one display which is a block.

I would like to create a template override for the block and house the template override within the module (rather than within my theme).  The template override does the following:

Adds the appropriate classes to the block
Adds an image beside the block title when the title is displayed
Wraps the {{ content }} in a div with an appropriate class
Loads the custom module's library to apply CSS

The goal is to have a module that a non-technical person can install, assign a block to the desired region and have all the templates, CSS, JS, etc pull from the module.  I don't want them to have to copy a template into their theme, etc.  I want the block to be a view so that the user can use the Views UI to make any desired updates to the view block's fields, number of returns, etc.

I was able to get Drupal to recognize the template by using hook_theme_registry_alter() but the variables from the block are null.  Both the {{ label }} and {{ content }} are null when I kint them in the template override.

Here is the hook_theme_registry_alter() code:

/**
 * Implements hook theme_registry_alter
 **/
function MYMODULE_theme_registry_alter(&$theme_registry){
  $theme_registry['block__views_block__MYVIEW_block_1']['path'] = drupal_get_path('module','MYMODULE') . '/templates/';
  $theme_registry['block__views_block__MYVIEW_block_1']['template'] = 'block--views-block--MYVIEW-block-1';
}

It should be noted that when I used hook_theme_registry_alter() for a view page template override in my module it worked.  My guess is that the variables were pulled from the page alias.

Please include detailed information because I am still learning about the various hooks and how variables are passed.  Thanks in advance!


texts:
How to remove unclosed tags(e.g. ) in ckeditor?
When I put any unclosed tag within a tag, its closed automatically before closing parent tag. e.g. below my code before render

  Test unclosed tag

    Hey this is test content to check unclosed tag
      Google

Processing...

But after saving content, render content looks like below code

 Test unclosed tag

Hey this is test content to check unclosed tag
     Google

  Processing...

So what I want, if any unclosed tag are there, they should be stripped and remain the content of the tag as plain like below code

  Test unclosed tag

    Hey this is test content to check unclosed tag
      Google

Processing...

Note: I am using Drupal 7 with full html and filter html format in CK Editor.

Any help or suggestion is much appreciated.

Thanks


texts: Access Denied on private image styles but not on public

texts:
I am allowing a user to upload images via FTP into my private:// location as configured under File system. This location is owned by ftpuser:apache and has write permissions for both user and group.

Then my Content Type has a field called "picture file" which is the base filename of the image, e.g. IMG_9001.jpg

Note: I am using FTP instead of an Image/Media upload because the user will be uploading hundreds of images.

In my template, I do this:

$picture_file = $node->field_picture_file['und'][0]['value'];
$picture_file = 'private://' . $picture_file;
$picture_url = image_style_url('large', $picture_file);

This returns a correct URL with the itok parameter appended:

http://example.com/system/files/styles/large/private/IMG_9001.jpg?itok=xxxxxxxx

However, the image does not display. Going to the URL in another window gives an Access denied error. Even with

$conf['image_allow_insecure_derivatives'] = TRUE;

in my settings file, it still gives Access denied!

If I copy the file to the public:// location and changing the path it works. It's only the private:// location that doesn't work. Why wouldn't it work even chmodded to 777?


texts:
I installed drupal 7, and ABT module.

Created taxonomy vocabulary 'Proj' with terms 'proj1' 'proj2'
added term ref 'Proj' field under Article cck
added term ref 'Proj' field under Users (Account settings->manage fields)

Enabled abt's Control "view" access with this field. => Yes, but allow...  on both the term ref fields (Account, article)

Created User1 (proj1 term ref)
Created User2 (proj2 term ref)

Created article PROJ1 article (proj1 term ref)
Created article PROJ1 article (proj2 term ref)

I can see both the articles as admin, but have no access to any of the articles when logged in as User1 or User2

Am I missing any step? please help
Thanks in advance.


texts: Can't enable drupal 7 membership suite module

texts:
Just installed MS core, Membership suite on drupal 7. installation is ok, I can see the new module on the admin page, but can not click on the enable box to activate/enable the new module. it says "Entity is missing" in red.
any input would be appericiated.

thanks


texts:
How do you create a webform on a node insert?

I create an event content type and want to automatically add a webform with 3 fields (lastname, firstname, e-mail) on node insert of the event. I do not want the client to add the webform each time he creates an event node. I want a webform per node.


texts: How to update 8.0.x to 8.1.x with composer?

texts:
This is excerpt from my composer.json file (trimmed for readability). It was created by running composer create-project drupal/drupal my_site_name 8.0.* as described on drupal.org:

{
  "name": "drupal/drupal",
  "type": "project",
  "require": {
    "composer/installers": "^1.0.21",
    "wikimedia/composer-merge-plugin": "^1.3.0"
  },
  "replace": {
    "drupal/core": "~8.0"
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "extra": {
    "merge-plugin": {
      "include": [
        "core/composer.json"
      ],
      "recurse": false,
      "replace": false,
      "merge-extra": false
    }
  }
}

If I just do composer update - core is not updated, only packages inside vendor dir.
If in addition to the above, I update my composer.json file and replace core version with ~8.1 - still core not affected.

The only thing that worked for me was to:

Remove core dir, vendor and composer.lock.
Edit composer.json and:

Remove replace section.
Add "drupal/core": "~8.1" to require section.

Run composer install.

That worked however every installed package complained that:

  Class Drupal\Core\Composer\Composer is not autoloadable, can not call post-package-install script

So I'm not sure if the whole process completed flawlessly. Also removing core directory seems like a desperate move.

What is the recommended procedure of updating core to the next minor version with composer (for example 8.0 => 8.1)?
Note that I am not using drupal-composer as suggested in this answer.

Update 1

After trying to use composer require --update-with-dependencies "drupal/core:8.1.*" I got no results:

$ composer create-project drupal/drupal my_site_name 8.0.*
Installing drupal/drupal (8.0.6)
  - Installing drupal/drupal (8.0.6)
    Cloning c5afca05cde0c94ef4d7aff5b078be27024670d2

Created project in my_site_name
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess
Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]? Y
$ cd my_site_name/
$ composer require --update-with-dependencies "drupal/core:8.1.*"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess

I'm using composer version 1.1-dev.


texts: Drush on windows 10 gives an error - Command pm-update needs a higher bootstrap level to run

texts:
When I try to use drush to work on my local site I get this error:

Command pm-update needs a higher bootstrap level to run - you will need to invoke drush[error]
from a more functional Drupal environment to run this command.
The drush command 'up' could not be executed.                                          [error]
Drush was not able to start (bootstrap) the Drupal database.

I have wamp server installed on windows 10. I also have composer and drush installed on windows 10. I have the user environment path set up correctly. I am in the drupal directory.  I have my local drupal site set up but I cannot get drush to work. I have been crawling the internet and can only find older solutions.

My user environment path for drush is C:\Users\Name\AppData\Roaming\Composer\vendor\drush\drush

My user environment path for composer is
C:\Users\Name\AppData\Roaming\Composer\vendor\bin

When I type drush status I get

$ drush status
 Drupal version         :  8.1.8
 Site URI               :  http://default
 Database driver        :  mysql
 Database hostname      :  localhost
 Database port          :  3306
 Database username      :  root
 Database name          :  tekopolis
 PHP configuration      :  C:\wamp64\bin\php\php7.0.4\php.ini
 PHP OS                 :  WINNT
 Drush script           :  C:\Users\Anthony\AppData\Roaming\Composer\vendor\drush\drush\drush
 Drush version          :  8.1.3
 Drush temp directory   :  C:\Users\Anthony\AppData\Local\Temp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  C:\wamp64\www\tekopolis
 Drupal Settings File   :  sites/default/settings.php
 Site path              :  sites/default
 Sync config path       :  sites/default/file/config[...]/sync

Does anyone know how to get drush working on windows 10 without acquia dev?


texts:
I'm trying to work with some information out of our enterprise system to create an employee directory, and I have a question regarding how I can relate nodes together.

I have a content type called Employees, and it has a number of fields, including Employee ID, First Name, Last Name, etc.

I then have a content type called Positions, and it has a number of fields, including Employee ID, Title, etc.

I'm trying to figure out how I can link the Positions and Employee nodes together on the Employee ID field rather than the nid.

Any help would be appreciated. Thanks!


texts: How to return boolean with math expression comparison in Views

texts:
I want to output a boolean value like this:

if some field value (e.g. [comment_count]) > x (my constant, e.g. 5) = 1, else 0

without installing Views PHP (or other modules) or having to create a field.

I tried with the Views field "Global: math expression" but that won't support comparisons.

Is there a math expression or another simple way to do this within my view?

PS: I thought I could use floor(logX([comment_count]) but logX() seems not supported: it always returns 0. Custom base logarithm is among PHP math functions but not present in Views? :(


texts: Add class to views row if image fields has content

texts:
I have views which has multiple image fields. In some cases all those image fields are empty, but some cases one of them has content.

When image field has content I want to have extra class .has-image for views row.

There is image fields: image_field_1, image_field_2 and image_field_3

It can be done programmatically, but I'm lost how to check those fields.
I know this much:

function YOURTHEME_preprocess_views_view_unformatted(&$vars){

SOLUTION

There can not be used $vars['classes_array'][$id][] because $classes_array[$id] is not an array.

Here is code for working solution.

function theme_preprocess_views_view_unformatted(&$vars) {
  $view = $vars['view'];
  $rows = $vars['rows'];

foreach ($vars['view']->result as $id => $row) {

    if (!empty($row->field_field_image) || !empty($row->field_field_image_2) || !empty($row->field_field_image_3)) {
      $vars['classes_array'][$id] .= ' has_field';
    }
    else {
      $vars['classes_array'][$id] .= ' has_no_field';
    }
  }
}


texts: Ajax form works on page but not on block

texts:
I've created an ajax form with drupal API. The ajax functionality works if I render the form on a page with hook_menu, but it doesn't when I render it in a block. This is how I create my block:

function hook_block_info() {
    $blocks['my_block'] = array(
      'info' => t('Title'),
      'cache' => DRUPAL_NO_CACHE,
    );

    return $blocks;
}

function hook_block_view($delta = '') {
    $block = array();

    switch ($delta) {
        case 'my_block':
            $block['subject'] = t('Title');
            $block['content'] = drupal_get_form('my_form');
            break;
    }
    return $block;
}

Any idea how I can fix this?


texts: Add styles to a custom sidebar region in Zen

texts:
I am using Zen as a theme.

I want to know how I can create a third sidebar and apply the styles in responsive.css to it.

I already know how to create a custom region and render it.


texts: Multi-site installation with shared database but different user table

texts:
I need to install drupal multi-site with shared database but just need to create some tables specific to that site like, users table should be different for sub-sites.

I know about full sharing or full different database for different sites, but I need partial different database. I searched for it on google but didn't get exact solution so posting it here if anybody has clue about?


texts: How to act based on a styled image is generated?

texts:
three image styles defined: thumb, medium and large.
By uploading an image, its thumb/medium/large copies are not generated. .    each styled copy of image is generated only when specific style is asked to be viewed.

I want to do something after styled copy is generated. For example, I want to upload medium size of image to my other server with my API copyToMyServer().

How may I do so? Couldn't find hook for this case.


texts: Capturing return value from remote post hander

texts:
I have a number of forms set up using Webforms (the module formerly known as yamlforms) in Drupal 8.

This data is stored in Drupal, but is also sent to a remote CRM using a Remote post handler added to the form. The CRM handler generates a key for the newly added lead that I would like to use in my success message. There's no option for capturing data from a remote post though.

Does a solution already exist for this, or am I doomed to writing my own module?


texts: Are there any embedded video/media field modules which integrate with Rules?

texts:
I'm trying to set up some Rules conditions which deal with whether or not a user has added a YouTube URL into a media field for a node. The idea is to use a Media type module to embed the YouTube video into the forum post. But I want a specific Rule to fire if the user saves their forum post without adding a YouTube video URL to that custom field.

However, I can't seem to find a module like Media or Video Embed Field, or Embedded Media field which expose that field entity to Rules.


texts: How to show only top level menu name in Superfish

texts:
As seen "Departmental Information" is first level sub menu under top level "Staff Menu". But I want only to display "Staff Menu" and it should expand only on hover. How to do it?
I've tried all the options in Superfish block settings.
I've added this code to generate the html:
$block = block_load('superfish', '1');
$menus = render(_block_get_renderable_array(_block_render_blocks(array($block))));

Otherwise it's working fine and when I hover over "Departmental Information" it does expand as in this picture:


texts: Cron function set to run once per month not completing

texts:
I have a cron function that is being triggered but not completing. The function is supposed to run only once on the first of every month. The function runs but, I think, gets as far as comparing the $summary_sent variable and then stops. Cron is running once every 3 hours.

By changing the $day_of_month_to_run to the current day and resetting the $summary_sent variable I can successfully run the full function using cron but, when left to run automatically on the first of the month it fails.

variable_set('summary_email_recipients', 'me@example.com');

function appointments_cron() {
    send_monthly_summary();
}

function send_monthly_summary() {
    $recipients = variable_get(summary_email_recipients);
    // run on first of the month
    $day_of_month_to_run = 01;
    $date_string = date('Y-m-'.$day_of_month_to_run);
    // only run on the correct day of the month
    if ( date('Y-m-d') == $date_string ) {
        // check if the process was last run today
        // prevents process being run multiple times on the same day
        $summary_sent = variable_get( 'appointment_summary_sent' );
        if ($summary_sent != $date_string) {
            // do stuff
            // set a record of this process
            variable_set( 'appointment_summary_sent', $date_string );
        }
    }
}

Why isn't this running once on the 1st of every month as expected?


texts: How to include data-url-encode data using drupal_http_request()?

texts:
I am attempting to make a GET request using drupal_http_request(). A basic request works as expected but I need to include extra data. The example provided to me uses curl and the -G --data-urlencode option as shown below. What is the correct way to implement this type of request using drupal_http_request()?

curl -X GET \
  -H "Header-Example: Header Data" \
  -G \
  --data-urlencode 'include=gator' \
  https://example.com/1/endpoint


texts: Add a class to a div depending on which term was clicked

texts:
Since clicking on a taxonomy term opens a page showing all pages using that term, how do I identify which term was clicked so I can add a unique icon to each one? What do I type in template.php so I can add it to my page.tpl.php like so: class="<?php if(this-term-was-clicked) : ?> add-this-class <?php endif; ?>"

I have 3 terms right now and would like to customize the display of each one by adding a unique icon before the title.


texts:
I have a content type called event_page. In event, I have a drop down for selecting templates.

In the templates folder of my active theme, I have included my custom tpl.php files, such as node--event-page--default.tpl.php and node--event-page--blank.tpl.php.

I have used strreplace to remove 'node--event-page--' and '.tpl.php' to populate the types like bank and default from the files in the templates drop down.

Now I am using hook suggestions to take these theme on form submit, but it seems to not working

if (isset($variables['node'])) {
  $node = $variables['node'];
  $field_template_list = $node->field_template_list->und[0]['value'];
  if ($node->type == 'event_page') {
    $variables['theme_hook_suggestions'][] = 'node__event_page__' . $field_template_list;
  }
}


texts: How Drupal differentiates from url_alias and url path with argument

texts:
I am trying to understand how Drupal recognizes that the following two different paths set in database table url_alias are different and don't success to understand it:

products --> node/8

products/bikes --> node/9

so products/dummy is found to match node/8.

Trying to locate the PHP-Drupal code that checks the table, I have found, at "includes/path.inc"

 $result = db_query("SELECT source FROM {url_alias}
   WHERE alias = :alias AND language IN (:language, :language_none)
   ORDER BY language DESC, pid DESC", $args);

but the variable $args["path"] apparently is set by drupal_get_path_alias, which gets the result from the node->id. However, I was expecting to see something of the sort $alias = arg(0) . "/" . arg(1)..., etc.

What am I missing?


texts: I need to run some code after the config for my module is imported(it will create/update a css file that depends on configuration). So what is the correct hook to use? The module install will run only on first time when the module is instaled.


texts:
What are entity URIs? What are they used for?

Every answer I see is like Just define in your hook_entity_info() a URI callback. Why, if we are able to define entities and make them work without a custom URI? What is the benefit of the custom URI? Does it bring additional custom, cool functionality to our table that we can exploit?

Some examples of things out there on the web that mention Entity URIs, but don't leave me the wiser: Do entities need to have URIs?, Developing a custom Drupal entity, path(), uri(), defaultUri(), entity_class_uri, what to use?

In a nutshell: Why go through the hassle of defining an entity URI callback in your hook_entity_info(), if you can live without it?


texts: Any way to use the Scheduler module with the Bean module?

texts:
I use the https://drupal.org/project/scheduler module with standar content types.

But I see no integration with the Bean module

Is there any way to use the Scheduler module with the Bean module?

If not, are there any other module for this. I need to set both publishing and unpublishing dates for bean nodes.


texts: making correct return array of ControllerBase

texts:
I am new to Drupal 8 and it is hard to comprehend the documentation. I am required to make a custom module. I came across examples in creating custom modules, but I am having difficulty in making the correct return type. For example, consider the code snippet take from doc:

<?php
/**
 * @file
 * Contains \Drupal\hello_world\Controller\HelloController.
 */

namespace Drupal\hello_world\Controller;

use Drupal\Core\Controller\ControllerBase;

class HelloController extends ControllerBase {
  public function content() {
    return array(
        '#type' => 'markup',
        '#markup' => $this->t('Hello, World!'),
    );
  }
}

In this example, the controller is called when some page (defined in route) is visited. In this case an array is returned with #type and #markup, whose definition I cannot find anywhere. Similary consider another example:

<?php
namespace Drupal\acme\Controller;
use Drupal\Core\Controller\ControllerBase;
class DefaultController extends ControllerBase {
  public function hello($name) {
    // the {name} in the route gets captured as $name variable
    // in the function called
    return [
      '#theme' => 'hello_page',
      '#name' => $name,
      '#attached' => [
        'library' => [
          'acme/acme-styles', //include our custom library for this response
        ]
      ]
    ];
  }
}

In this case, the return type is #theme, #name and #attached. These two code clearly shows different return type. As a beginner, I am having difficulty in understanding what to return from function as I cannot see those definitions in the documentation of ControllerBase class.

Where in the documentation are these tags defined and how do I use them in different scenarios? Thanks.


texts: How to display, search, and edit form submissions from a table with WebForm?

texts:
I am very new to Drupal and I've been recently assigned a task to make a form for a single admin to register people and their info. It's basically a registration/contact form, except these people aren't users; the admin is just recording their info in a database.  The admin needs to be able to search for a person's name through a table for a previous person's registration, and be able to click an edit link for that person as well.

I have been messing around with the WebForm module, and it is great for making the form itself, not to mention it already has a 'Results page' with a table of past submissions. However I do not know of a way to add a search functionality to the 'Results page'.

I also heard that you can put a search bar in Views module, so I messed around with getting the WebForm submission data into a table in Views, thanks to the Data and WebForm SQL Views modules. However I do not know how to put the corresponding edit link next to each of the rows in the table.

Is there a better approach to solving this problem? It seems I have to either handle adding searching functionality for a field, or making it possible to point to the WebForm edit functionality from each row of the Views table.

At this point, I am also wondering if its better to just hand code everything in php.


texts: The requested page could not be found on user settings

texts:
I am trying to change the following user settings:

However upon clicking Save configuration I get an error saying The requested page could not be found. Any ideas how to fix this?

Note: I already tried running update.php and flushing all cache.


texts: How to get field data for Panels style plugin? (ctools context?)

texts:
I think this is a Ctools context question. I'm writing my first Panels style plugin and am having trouble getting field values from nodes inside the pane. I'm basically trying to recreate the plugin from this tutorial, http://precessionmedia.com/blog/creating-custom-panels-style-plugin-background-image-support, but I have changed it from a region plugin to pane plugin. The pane contains a list of node fields generated by Views, and I need to get the info from an image field but I'm not sure how to proceed.

In the link above, the render region callback uses this function: ctools_context_keyword_substitute($string, $keywords, $contexts, $converter_options = array()), where $contexts is $vars['display']->context, but this array is empty for me. I'm also not sure what values to use for $string. In the example link above, $string is replaced by the value entered into the style plugin settings form and the example given in the tutorial plugin is %node:field_image, isn't this just a token? I'm not sure if this is the right token to use, but I believe the missing context array is what is breaking this function for me.

Thanks, any help is greatly appreciated.


texts: How do you handle maintaining core updates with clients?

texts: When you develop a site using Drupal, do you include as part of it updates to core as they come out, or do you offer maintenance charges to keep it updated?


texts: Unresolved dependency error when updating

texts:
I Tried updating 2 different sites and both gave error messages saying "Unresolved dependency" missing from different modules.

The pages no longer load on the site saying

  Fatal error: Call to undefined function libraries_load()

Why am I getting these messages?


texts:
I would like to know if there is any option for db_merge function to do UPSERT (update or insert) operation in table if key is "id" column of serial type (autoincrementing).

I need to insert new row if "id" is not defined, or update if "id" is specified. For now I have:

db_merge('t_project_proposal_writer')
   ->key(array('id' => $state['storage']['project']['proposal_id']))
   ->fields(array( .... ))->execute();

where $state['storage']['project']['proposal_id'] is null, because is not specified and it should create row with next id value. It is not working, returning:

  Numeric value out of range: 7 ERROR: setval: value 0 is out of bounds for sequence "t_project_proposal_writer_id_seq"

It is working, when new id is manually specified, but then, how to get last inserted id of table? db_last_insert_id is not working in D7, only in D6.


texts: Creating content regarding to node address arguments

texts:
Say it I have such node alias:
example.com/content/my-fancy-page/

If user enters to node above, he will see default page content of my fancy page.
After some process I will redirect him to this:
example.com/content/my-fancy-page/tt3741/
or this
example.com/content/my-fancy-page/tt3802/

Regarding to user's selection he will see the "tt3741" or "tt3802" content that resides inside database. Is it possible to do this with hooking etc. When I try "example.com/content/some-old-page/foobar" in my old website I get 404 error. So is it nt possible?
Is it possible to cache these three addresses seperately with Boost module? Or Boost only caches "/my-fancy-page/"


texts: Field Collection RESTful API rendered in HTML

texts:
I'm not sure this is a bug or what. But when I create API view page and add field (which is field collection), it rendered HTML instead of 'neat' JSON.

For example it should be look like :

field_collection_name: [
   {
     "title": "Big Title"
     "field_a": "content"
   },
   {
     "title": "Big Title 2"
     "field_a": "content 2"
   },
   {
     "title": "Big Title 3"
     "field_a": "content 3"
   }
]

Instead, the JSON in api view render like this:

field_collection_name:
Big Title

content

Big Title2

content 2

Big Title 3

content 3

Anyone experience same problem like this before? Any settings need to set for field collection?


texts: Total number of likes on views images and social networking?

texts:
I have a view that displays 8 images (which links to their particular node) uploaded by the all users. Now I want to display a counter which counts total number of likes on that post either by facebook or on the site.

Can I link the image like with the facebook likes of that particular image post?


texts: How do I override a fields output in a Views template?

texts:
I have a field, foo, set to "Exclude from display", and output later in a "Global: Custom text".

I need to control the rendering of this field based on a different value on the same node.
I thought I could just implement a template file like:

function THEME_views_view_field__VIEWNAME__DISPLAYNAME__FIELDNAME($view, $field, $row) {
  $output = isset($bar) ? $foo : $baz;
  return $output;
}

But as soon as I add this function to my template.php file, I loose all output instead. No matter what I return, I get nothing. I tried trivial things like

return 'AAAAA';

to no avail. I'm probably doing something very simple wrong, but looking at my own previous attempts to do similar things in the same template file, I can't see what's wrong. Yes, I've cleared the cache numerous times.


texts: How can I add two 'add to cart' ubercart buttons in a product page

texts:
I would like to have two 'add to cart' buttons on my ubercart drupal site.
I've set up two views, but only one button will show at a time.
Why is this?
You can see it on https://www.thepetwiki.com/mg-testsite.com/ubercart/painting/please
There should be an 'add to cart' button next to both 'BUY: $2,400'


texts: How can I implement a required disclaimer page?

texts:
Whenever a user enters the site I would like a page with a disclaimer to appear, and only when you agree to the conditions can you enter the site.

What can I use to do this?


texts:
What is the proper way to expand feeds to import the entities themselves instead of the values for already existing entities (like a node type).  For example let's say we have various forms collected in a store that need to be synced with on outside database.  It is simple to use a custom processor to do this manually, but what is the proper way to pull the information from the feed programmatically.

We obviously have to declare what the variables being mapped by the parser (which we are going to use) will be.

// Mapping Variables
public function getMappingTargets() {

    $targets = parent::getMappingTargets();
    $targets += array(
      'test_machine_name' => array(
        'name' => t('Machine Name'),
        'description' => t('machine name.'),
        'callback' => 'mymodule_set_target',
        'optional_unique' => TRUE,
      ),
      'test_label' => array(
        'name' => t('Label'),
        'description' => t('This will be the label.'),
        'callback' => 'mymodule_set_target',
      ),
    );
    return $targets;
  }

The problem comes in when trying to use those mapped values from the parser when saving the entity.

// Create a new Entity
    public function newEntity(FeedsSource $source) {
          $feeder = $this->getMappingTargets();

      $field_collection = new stdClass();
      $field_collection->id = $feeder['test_machine_name'];
      $field_collection->title = $feeder['test_label'];
      $field_collection->description = '';
          $field_collection->machine_name = $feeder['test_machine_name'];
          $field_collection->log = 'Created by Importer';
      return $field_collection;
    }

    // Load an existing Entity
    public function entityLoad(FeedsSource $source, $entity_id) {
          if ($this->config['update_existing'] == FEEDS_UPDATE_EXISTING) {
                $field_collection = field_collection_load($entity_id);
                $field_collection->log = 'Updated by Importer';
              }
              else {
                $field_collection->log = 'Replaced by Importer';
              }
              return $field_collection;
    }

// Save Entity
public function entitySave($entity) {
  $t = get_t();

  $fields_array = array(
    array(
      'field' => array(
        'field_name' => $entity->machine_name,
        'label' => $t($entity->title),
        'cardinality' => -1,
        'type' => 'field_collection',
      ),
      'instance' => array(
        'field_name' => $entity->machine_name,
        'entity_type' => '$type',
        'bundle' => '$bundle',
        'label' => $t($entity->title),
        'description' => '',
        'widget' => array('type' => 'field_collection_embed'),
        'required' => 1,
      ),
    ),
  );

  // Loop through fields array and create field and instance
  foreach ($fields_array as $field) {
    // Check if field already exists
    if (!field_info_field($field['field']['field_name'])) {
      field_create_field($field['field']);
    }

    // Check if instance exists
    if (!field_info_instance($field['instance']['entity_type'], $field['instance']['field_name'], $field['instance']['bundle'])) {
      field_create_instance($field['instance']);
    }
  }
}

Everything saves properly and is imported into the correct places, but the values from the mapped fields are never pulled.  Any ideas?


texts: Create taxonomy reference field programatically in Drupal 8

texts:
How to create taxonomy reference field programatically in a custom form?

$tags = array();// get taxonomy terms from a vocabulary.

$form['custom_tags'] = array(
  '#type' => 'select',
  '#options' => $tags,
  '#title' => $this->t('Preffered Tags'),
  '#default_value' => $this->store->get('custom_tags') ? $this->store->get('custom_tags') : '',
);

How can I get taxonomy terms from a vocabulary? Or how to create a term reference field in custom form?


texts:
Is there a way to disable the render cache, which caches all the nodes by default, for a particular content type X.

I know we can disable the render cache site wide by commenting out

$settings['cache']['bins']['render'] = ‘cache.backend.null’;

in settings.local.php. But this is not a ideal approach for me as I need to disable the render cache only for a particular node type.

Also, I need to disable the cache for both Authenticated and Anonymous users for the content type X.

Any pointers on the same would be very much appreciated.


texts: Exposed grouped filter triggers 'illegal choice' on page load

texts:
For Drupal 8.8.2, I've got an exposed filter of grouped items. Ever since the last update to 8.8.2, I've been getting an "illegal choice" error when a user navigates to the page with this filter. Once the filter is used, the error goes away. But it's back every time they reload.

It happens regardless of whether 'remember choice' is on or off.

Looking at the logs, I don't get enough information. it will just say:

Illegal choice  in Type element.

or

Illegal choice 10,11,12,13,14 in Type element.

Even if I completely remove the choices, I get an error when nothing but -any- is an option. So it's not the specific choices that are the issue.

I turned on Devel, with kint, in hopes of finding more info and it doesn't give me any more detail.

I also tried adding the settings.local.php for verbose errors. It gave me a 502 error, so I dropped this into the settings.php, and got just the basic error.

$config['system.logging']['error_level'] = 'verbose';

Here are a couple screen shots of the filter's settings:

for reference, the actual page result, when first visited:


texts:
My Drush commands doesn't work because my Drupal files are in another directory than the one set in Drush. Everything is set up to this path so I can't just change the folder name.

Drush status
  [..]
  Drupal root   : /Users/nicklas/Documents/SourceTree/Drupal/web

How can I change the path to /docroot instead of /web?

  /Users/nicklas/Documents/SourceTree/Drupal/docroot


texts: Setting up drush ini path in my site alias

texts:
Unfortunately, i use shared hosting for my dev site to show to clients.

I'd like to specify an ini path in my example.aliases.drush.php file.

I couldn't find that particular custom variable in the example file.

Is it possible to set the drush.ini path so i don't get these nagging open basedir errors?

<?php
        $aliases['dev'] = array(
        'remote-host' => 'foohost',
        'root' => '/home/xxxxxx/users/.home/domains/xxxxxx/html',
        'php' => '/usr/bin/php',
        'path-aliases' => array(
         '%drush' => '$HOME/bin/drush/',
         '%drush-ini'=>'/home/xxxxxx/etc/drush.ini',
         '%drush-script' => '$HOME/bin/drush/drush/drush.php',
         '%dump' => ' ../db/dev.xxx.sql',
        '%files' => 'sites/all/files',
        ),
    );


texts: One-to-many and many-to-many relation between nodes of different content types

texts:
I am using Relation module for creating relationship. But i didn't find the option how to create one to many, many to many relation.
Can anybody tell me regarding that
Thanks


texts:
Right now, I am touching the database for drupal 7. I searched about the difference between "commerce_line_item" table and "field_data_commerce_line_items" table. But no luck.

Does anyone know the difference between them? Also, is there any reference that I can follow to check the table explanation?

I really appreciate anyone's help.

UPDATE

Based on everyone's help and my own opinion, I drew a simple diagram for these two tables:


texts: Does drush stop events from firing and/or bypass event subscribers?

texts:
I'm running some migrations and have logic dependent on their Events

  public static function getSubscribedEvents() {
    $events[MigrateEvents::POST_IMPORT][] = ['onMigratePostImport'];
    return $events;
  }

When I run a migration from the UI my onMigratePostImport() runs as expected. However, I just tried running the same migrations via drush and that logic appears not to have run. Would using drush cause these events to be bypassed/not fired?


texts:
I have a site that get statistics on products. I get data from an external source to update the Drupal DB to register a buy on a product and the date of that buy to be able to show a flowchart over that product.

I need this statistics for showing the development of the products selling rate. So if one customer buys a product that information will be sent to my Drupal DB, and that's where I wonder how I should construct my DB so it is optimal in speed and storage. Is it a good idea to create a content type that has a product entity reference and a date? So when a product is bought a new node is created that holds the date and product as information.


texts: How to move the user account/Profile 2 information from the content region to a sidebar region

texts:
On the "My Account" page i.e. /user, the account and Profile 2 information is by default residing in the content region. I would like to move everything to the right sidebar region. Any suggestions on how I can achieve this ?

I am using Bartik

Thanks in advance.


texts: Problem with dependency injection (File::load and \Drupal::service)

texts:
In order to make a managed_file field permanent I did this in my module configuration form:

<?php

namespace Drupal\my_module\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Class MymoduleSettings.
 */
class MymoduleSettings extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'my_module_settings';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config                    = $this->config('my_module.settings');
    $form['my_module_title'] = [
      '#type'          => 'textfield',
      '#title'         => $this->t('Title'),
      '#description'   => $this->t("Enter the title"),
      '#maxlength'     => 64,
      '#size'          => 64,
      '#required'      => TRUE,
      '#default_value' => $config->get('my_module_title'),
    ];
    $form['mymodule_icon']   = [
      '#type'              => 'managed_file',
      '#title'             => $this->t('Icon'),
      '#description'       => $this->t("Upload the image file for the icon"),
      '#upload_location'   => 'public://',
      '#upload_validators' => [
        'file_validate_extensions' => ['gif png jpg jpeg'],
      ],
      '#default_value'     => $config->get('my_module_icon'),
    ];
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);

    $this->config('my_module.settings')
      ->set('my_module_title', $form_state->getValue('my_module_title'))
      ->set('my_module_icon', $form_state->getValue('my_module_icon'))
      ->save();

    // First we just grab the file ID for the icon we uploaded, if any.
    $icon_field = $form_state->getValue('my_module_icon');
    $file_id    = empty($icon_field) ? FALSE : reset($icon_field);

    if (!empty($file_id)) {
      // Make this a permanent file so that cron doesn't delete it later.
      $file         = File::load($file_id);
      $file->status = FILE_STATUS_PERMANENT;
      $file->save();
      $file_usage = \Drupal::service('file.usage');
      $file_usage->add($file, 'my_module', 'file', $file_id);
    }
  }

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'my_module.settings',
    ];
  }

}

but I'm getting warning to use dependency injection principle in this case:

File::load calls should be avoided in classes, use dependency injection instead

and

\Drupal calls should be avoided in classes, use dependency injection instead

I looked through Dependency Injection for a Form but still not sure that I really get it.

Can someone explain me what I need to do in this particular case so I can get a better view on this issue and figure it out?


texts: How can I create a View utilizing the Access Log hits (Hits in last 4 weeks)

texts:
When creating a View, the only statistics available are total, today, and most recent. Is there a way to utilize the Access Log statistics (Number of views in last 4 weeks by example) instead?

See here for example of how to set up the typical Statisics Hits View: https://www.ostraining.com/blog/drupal/track-hits/

But instead I want only the hit count from the Access Log (Set for 3 days in the above example, mine is set for 4 weeks) so I can restrict the counter to a larger time period than "today", but shorter than "total".


texts:
I am not able to get form element qty twice. I have 2 line item IDs, but I am getting 1 instead of printing qty twice. Please help me out this. This is my code.

function mol_split_delivery_form($form, &$form_state, $order_id) {

$order = arg(1);
$line_item_idds = get_total_line_item_ids($order);

if (!empty($line_item_idds)) {
  $line_items = commerce_line_item_load_multiple($line_item_idds);

}
else {
  $line_items = array();
}

foreach ($line_items as $line_item_id => $line_item) {

$form = array();
$option_first = array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9');
$form['line_items'][$line_item_id]['quantity'] = array(
    '#title' => 'Qty',
    '#type' => 'select',
    '#options' => $option_first,
    '#default_value' =>  $line_item->quantity,
 );

 }
return $form;
}


texts:
I am trying to set up a Rule to check if a user has added one of several states to an address field in a Profile2 profile. So I thought I'd do a Data Comparison.

I created a new rule called "Profile Save"
Added an Event from the drop down menu: "After saving a new profile"
Added "Entity has field"

Parameter: Entity:[profile2], Field:field_address
Added AND and Add Condition,
chose "Data comparison"

But the Data Comparison form is all wonky. The drop down has div tags in it. The "Data Selectors" isn't active.

Do I have to already know what the Data selector should be? Or should it be available in the drop down?

(See images)

Any idea what I'm doing wrong? Is this a known issue with Data Comparison.


texts:
I am getting this error on a Drupal 7 site on Ubuntu 12.10.  I downgraded PHP from 5.4 to 5.3, but am still getting it.

Does anyone recognize this error?

  Fatal error: Call to undefined function lock_initialize() in /home/buck/drupal/cms/includes/bootstrap.inc on line 2366


texts: Pressflow + CDN, node access counter not updating

texts:
I am using Pressflow (Boost+Varnish) with "boost ajax stat block" enabled for stats, things were working ok and node counter was getting updated. Few days ago I started using full-site acceleration via CDN and the node access counter (page reads) is no longer updating ?

In theory boost ajax stat should work with caching, why is it not in this case ?

Website : http://www.megaleecher.net/


texts:
I am trying to install the most uptodate version of Drush as I begin working on Drupal 8.

Apt-get only installs Drush version 5.10.0. So, I'm attempting to install Drush via composer with the following effect:

sisko@li184-76:~$ composer global require drush/drush:dev-master
Changed current directory to /home/sisko/.composer
The "fxp/composer-asset-plugin" plugin was skipped because it requires a Plugin API version ("1.0.0") that does not match your Composer installation ("1.1.0"). You may need to run composer update with the "--no-plugins" option.
./composer.json has been updated
The "fxp/composer-asset-plugin" plugin was skipped because it requires a Plugin API version ("1.0.0") that does not match your Composer installation ("1.1.0"). You may need to run composer update with the "--no-plugins" option.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for drush/drush dev-master -> satisfiable by drush/drush[dev-master].
    - drush/drush dev-master requires consolidation/robo dev-master -> satisfiable by consolidation/robo[dev-master] but these conflict with your requirements or minimum-stability.
  Problem 2
    - fxp/composer-asset-plugin v1.0.0 requires composer-plugin-api 1.0.0 -> no matching package found.
    - fxp/composer-asset-plugin v1.0.0 requires composer-plugin-api 1.0.0 -> no matching package found.
    - fxp/composer-asset-plugin v1.0.0 requires composer-plugin-api 1.0.0 -> no matching package found.
    - Installation request for fxp/composer-asset-plugin 1.0.0 -> satisfiable by fxp/composer-asset-plugin[v1.0.0].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.
sisko@li184-76:~$ drush status
The program 'drush' is currently not installed. You can install it by typing:
sudo apt-get install drush
sisko@li184-76:~$

Can anyone please help me out?


texts:
I am developing an e-commerce site for one of our customers for the first time with drupal. It is going pretty good so far but there is a weird misbehavior where I have no idea on how to handle it in a drupal context.

What I am using:

"require": {
    "php": ">=7.3",
    "behat/mink-selenium2-driver": "dev-master as 1.3.x-dev",
    "composer/installers": "^1.2",
    "cweagans/composer-patches": "^1.6.5",
    "drupal-composer/drupal-scaffold": "^2.5",
    "drupal/better_exposed_filters": "^3.0",
    "drupal/bootstrap_barrio": "^4.22",
    "drupal/commerce": "^2.14",
    "drupal/commerce_shipping": "^2.0",
    "drupal/console": "^1.0.2",
    "drupal/core": "^8.7.0",
    "drupal/field_group": "^1.0",
    "drush/drush": "^9.0.0",
    "vlucas/phpdotenv": "^2.4",
    "webflo/drupal-finder": "^1.0.0",
    "webmozart/path-util": "^2.3",
    "zaporylie/composer-drupal-optimizations": "^1.0"
},

That is the require block with the selenium2-driver fix. (just FYI, not relevant for that question)

So I have a /shop page as view were I am using better exposed filters for the sidebar, ajax/autosubmit is enabled in the view/exposed-form.

When I have, for example, chrome in incognito mode and I am not logged in as user the AJAX functionality works 100% perfect. But when I log in as admin OR as any other user, the AJAX is broken in the shop page.

Do I miss an issue here? I am really stuck, any help is much appreciated.


texts: Create a wrapper around specified number of fields in views

texts:
I like to wrap 3 elements of a view in a div.
I got this code, but it doesn't seem to work. It keeps printing the div but never the /div which makes everything nested in the previous row.

<?php if($i % 3 == 0){ print '
'; } ?>
<?php print $row; ?>
<?php if($i % 3 == 2){ print '
'; } ?>

Any suggestions?


texts: User to add/remove products to product bundle

texts:
I want to create a product bundle of say 10 products, but with the ability for the user to add or remove further items to the bundle.
Essentially I have a bundle of products I offer at a discount, and I want the user to retain the discount if they remove an item or add another (or both).
Hope that makes sense.
If anyone has any idea of a way to achieve this, or a way to potentially achieve it, i'd appreciate the tips.
Thanks


texts: Logging into Drupal from an external application

texts: I am currently using the services module and some custom code to delete, login and edit drupal users from an external application. I can currently login as a user on the external application but I am only logged on in the code and not the actual browser. Meaning that I can perform actions with the authenticated account in the code but when I visit my drupal website through the browser, I am not logged in. I want my users to be logged into drupal when they log into my external application. How can I do this?


texts: Work around to getting Backup and Migrate to work with Acquia Dev Cloud?

texts:
Currently, when you host a site onto Acquia Dev Cloud, they disable the ability to install backup and migrate module due to it affecting their "server" setup. This proves to be a big nuisance when trying to create a quick backup of a site and to even make scheduled hourly backups. The suggest us to use the Acquia platform to do backups, but it's totally inefficient since it cannot schedule your own backup times. And doing this via drush is troublesome if you just want to do a quick backup because you wanted to make a change on a site just in case it breaks it.

How would one go around this problem of backing up a site with Acquia dev cloud?


texts: Can I filter the list of candidates used by the menu system to determine the menu trail?

texts:
I have a site with a menu structure like so:

- a
- b
  - 1
  - 2
- c
  - 1
  - 2

Now lets say that I have a node that both b2 and c2 point to (I'll call it node/4). When the user clicks either link, I want the site to display as a click on c2. That is to say that the main menu item for c should be highlighted, and the secondary menu for c should be displayed. And of course, the content of node/4 should be visible.

What actually happens is that the node/4 content is displayed, but both b & c main menu items are highlighted and the secondary menu for b is displayed.

I've investigated, and found the menu_link_get_preferred function in core/includes/menu.inc. This function builds a list of candidates that can match the current path, and places them into an array keyed like this:

$candidates[MENU_ITEM_LINK_PATH][MENU_NAME]

My problem is that I have two link candidates that match the same exact criteria:

$candidates['node/4']['main']

and so I cannot control which one ends up in the candidates array. Ideally I would like to have a way of flagging the c2 link so that it was not treated as a candidate. I had thought that this would make a good module, but I cannot see a way of interrupting the execution of the function.

The bit of code I would like to alter is (D7 version, D8 is very similar):

// Sort candidates by link path and menu name.
$candidates = array();
foreach ($query->execute() as $candidate) {
  $candidate['weight'] = $candidate['link_weight'];
  $candidates[$candidate['link_path']][$candidate['menu_name']] = $candidate;
  // Add any menus not already in the menu name search list.
  if (!in_array($candidate['menu_name'], $menu_names)) {
    $menu_names[] = $candidate['menu_name'];
  }
}

In an ideal world I would have added an extra field to the database, so that a $candidate would be discarded on a certain flag. Any ideas how I could achieve this?


texts:
Got Drush 8 installed alright, but when I try to drush up my Drupal 8.0.0 site I get a Parse error: syntax error, unexpected '[' in /is/htdocs/.../.composer/vendor/drush/drush/includes/output.inc on line 188

Line 188 looks alright to me. What may be wrong?


texts: Render image field from node in page.html.twig

texts:
I make my first steps with Drupal 8. I have a site with a header image. On a specific content type "Blog" I want to replace the standard header image with a node specific header image. So in the content type "Blog" i made a image field "field_headerimage".
I also made it possible to make a content type specific page.html.twig, see https://drupal.stackexchange.com/a/141397/31981. This works.

Problem:
I want to render field_headerimage in page.html.twig. There is a "node" variable, but it seems like this values aren't able to render.


texts:
I'm using a Zen sub theme, and I've placed the main menu block into the header.

I would like to place the links to the right of the site name, but they only sit underneath. I've tried playing with the CSS styles that control the menu block, without success.

Is there a special trick of Zen's quirk I'm missing?


texts: How to sort a view so that, say, all the nodes with stock=0 come last, and not sort by stock?

texts:
I want to sort an output of a view so that the elements with a filed value of "0" be at the end of the list, but all the others are to be treated equally. In fact, it's an Drupal Commerce site, and I want all products with stock >0 to appear first in the lists, regardless of the stock quantity, so that the unavailable stuff get at the end, but still be in the view (after that, I sort alphabeitcally).
Any ideas how to do that?
That means making the output of a boolean forumla stock=0 the sorting criterion


texts:
I have a table with 4 columns that I need to be populated with ~200 rows of data in hook_install() via db_insert().

The problem is that if I mass-insert them, the install fails with PDOException and no other details about the error.

If I insert 10-15 rows at once, the module installs successfully and also the data is in the database. It seems that the installer cannot handle that much inserts at once, or am I wrong?

The code looks like this:

foreach ($values as $record) {
        $query->values($record);
        db_insert('courses_modules')->fields($record)->execute();
}
$query->execute();

Where $values is an array of rows like:

array('mid' => 1, 'cid' => 1, 'code' => 'XX', 'name' => 'Module name'),
array('mid' => 2, 'cid' => 1, 'code' => 'XY', 'name' => 'Module name'),
...

Yes, the schema is created corectly at the time of the insert (because as I said, a few rows can be inserted, but not all).

I also tried db_insert()->fields()->execute() for each row.

Thank you!


texts: How do you define an arbitrary sort sequence for views?

texts:
Take a look at the Drupal issues queue and the Priority column.  If sorted in descending order you get critical, major, normal, and minor issues, in that order.  Since "normal" would not go between "major" and "minor" in alphabetical order, they've obviously defined a custom sequence to use for sorting.  How is this done in Drupal?

Is it merely sorting based on a numeric value that is not displayed?  Or is it more clever than that?


texts: How can I hide the shortcut toolbar in Drupal 8.6? I need the very top menu gone (the green part highlighted in screenshot).


texts:
I'm using the module "metatag" to make my website SEO friendly. This works very well for all pages except the front page.

I go to modules -> Meta tags -> Settings -> Global: Front page

There I set a description. But this description isn't shown if you search the site directly in google. All other pages are working great, with the correct description.

When I look at the source, I see no meta data included at the front page.


texts: How i can add folder in filedepot using a custom module (without rules)

texts:
I want to create a module that adds a FileDepot folder, in this module I want the user chooses a name for the folder and I want the Parent Folder will by default "Top Level Root", I began to create this module but I'm stuck, here is my code :

function custombutton_menu() {
$items = array();
$items['custombutton/form'] = array(
    'title' => t('My form'),
    'page callback' => 'custombutton_form',
    'access arguments' => array('access content'),
    'description' => t('My form'),
    'type' => MENU_CALLBACK,
);
return $items;}

function custombutton_form() {
return drupal_get_form('custombutton_my_form');}
function custombutton_my_form($form_state) {
$form['name'] = array(
    '#type' => 'fieldset',
    '#title' => t('Name'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
);
$form['name']['first'] = array(
    '#type' => 'textfield',
    '#title' => t('First name'),
    '#required' => TRUE,
    '#description' => "Please enter your first name.",
    '#size' => 20,
    '#maxlength' => 20,
);
$form['name']['last'] = array(
    '#type' => 'textfield',
    '#title' => t('Last name'),
    '#required' => TRUE,
);
$form['year_of_birth'] = array(
    '#type' => 'textfield',
    '#title' => "Year of birth",
    '#description' => 'Format is "YYYY"',
);
$form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
);
return $form;}
function custombutton_my_form_validate($form, &$form_state) {
$year_of_birth = $form_state['values']['year_of_birth'];
if ($year_of_birth && ($year_of_birth < 1900 || $year_of_birth > 2000)) {
    form_set_error('year_of_birth', 'Enter a year between 1900 and 2000.');}}

function custombutton_my_form_insert($node){
$node = new stdClass();
$node->type = 'filedepot_folder';
node_object_prepare($node);
$node->language = LANGUAGE_NONE;
$node->name = first;
$node->title = last;
$node->filedepot_folder_desc[LANGUAGE_NONE][0]['value'] = 'This is private folder of author user.';
$node->parentfolder = TopLevelRoot;
$node->inherit = 0;
node_save($node);}
function custombutton_my_form_submit($form, &$form_state) {
drupal_set_message(t('The form has been submitted.'));}

thank you in advance


texts:
Imagine this simple

 $items = array(
   'string',
   'string2',
   $extra_items,
 );

And theme a block content like

 $content = array(
   'subject'   => t('Block title'),
   'content'   => array(
     '#theme'  => 'item_list',
     '#items'  => $items,
     '#attributes' => array('class' => 'my-UL'),
   ),
 );

$extra_items is getting values from a custom hook that may be empty!In that case
theme_item_list() brings an empty

 for that item that is NULL

How can i ensure that this

 is displayed only when this item has a value?


texts: I'm making a CMS for my job on Drupal 7. when i go onto the login page I'm able to access the content on the site without having to enter the password. how do i change this?


texts: How to wrap field out put in custom markup?

texts:
Situation
I have a custom module that is using hook_field_formatter_info() to add an "fancy" option to the image field in the manage display of a content type. When this option is chosen I want to be able to surround the ENTIRE field in custom divs and markup. I want the solution to be a hook in my custom module and not a template override.

Process
A user wants the display of an image field to be the "fancy" option. They check it in the drop down and click save from the content types Manage Display admin page. Now on that content type node there should be custom markup surrounding the entire field even if there are multiple images, the new markup should surround ALL the images and not each individual image.

hook_field_formatter_view
hook_field_formatter_view seems to demand it's output be an array and I can't seem to be able to wrap the output in a div.

Template overrides
I can't just make a field.tpl.php for the specific field because like I initially mentioned I need to be able to switch themes and the module still work like normal. Unless there is a way to get my module to override any field where said field has hook_field_formatter_info() set specifically.

/**
 * Implements hook_field_formatter_view().
 */
function bootstrap_modal_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();

  foreach ($items as $delta => $item) {
    if ($index === NULL || $index === $delta) {
      $element[$delta] = array(
        '#theme' => 'bootstrap_modal_image_formatter',
        '#item' => $item,
        '#entity_type' => $entity_type,
        '#entity' => $entity,
        '#node' => $entity, // Left for legacy support.
        '#field' => $field,
        '#display_settings' => $display['settings'],
        '#delta' => $delta,
      );
    }
  }

  // $element = '
' . $element . '
';

  return $element;
}

And here is the #theme function:

function theme_bootstrap_modal_image_formatter($variables) {

  $item = $variables['item'];
  $entity_type = $variables['entity_type'];
  $entity = $variables['entity'];
  $field = $variables['field'];
  $settings = $variables['display_settings'];

  $image = array(
    'path' => $item['uri'],
    'alt' => isset($item['alt']) ? $item['alt'] : '',
    'title' => isset($item['title']) ? $item['title'] : '',
    'style_name' => $settings['bootstrap_modal_node_style'],
  );

  if (isset($item['width']) && isset($item['height'])) {
    $image['width'] = $item['width'];
    $image['height'] = $item['height'];
  }

  if (isset($item['attributes'])) {
    $image['attributes'] = $item['attributes'];
  }

  // Allow image attributes to be overridden.
  if (isset($variables['item']['override']['attributes'])) {
    foreach (array('width', 'height', 'alt', 'title') as $key) {
      if (isset($variables['item']['override']['attributes'][$key])) {
        $image[$key] = $variables['item']['override']['attributes'][$key];
        unset($variables['item']['override']['attributes'][$key]);
      }
    }
    if (isset($image['attributes'])) {
      $image['attributes'] = $variables['item']['override']['attributes'] + $image['attributes'];
    }
    else {
      $image['attributes'] = $variables['item']['override']['attributes'];
    }
  }

  $entity_title = entity_label($entity_type, $entity);

  if ($style_name = $settings['bootstrap_modal_image_style']) {
    $path = image_style_url($style_name, $image['path']);
  }
  else {
    $path = file_create_url($image['path']);
  }

  $caption = 'some value';
  $gallery_id = 'some value';

  return theme('bootstrap_modal_imagefield', array('image' => $image, 'path' => $path, 'title' => $caption, 'gid' => $gallery_id));
}

Been working on this for days, I'm drowning here.


texts: Display images instead of nodes titles in Drupal 7

texts:
Normaly in Drupal 7 we have (node.tpl.php):

  <?php print render($title_prefix); ?>
  <?php if (!$page): ?>
  <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?>

  <?php endif; ?>
  <?php print render($title_suffix); ?>

It is taking node_url and putting it on a Title in every Node.

I do have 5 nodes (pages) displayed:

First
Second
Third
etc

I have created images First.gif, Second.gif and I want to load that images instead of Title.

I did check various implementation, but didn't find any resolution for me.

[Update] I did try to edit template.php file and to add functions for replacing title with image-if images exists.
I need this in Drupal 7 - please see here - http://drupal.org/node/221854

Is there any help? Thanks


texts: Relation adding not working in Drupal 7.9

texts:
I am a adding a new relationaship type, when i add up its not adding up, it gives one more time asking for details for input of relationship type and when i give the details and add it an fatal error displays..

I am using Drupal 7.9 and latest versions of modules on Drupal.org
below is the error message

Fatal error: Call to undefined function ctools_export_crud_load_multiple() in R:\xampp\htdocs\sitename\sites\all\modules\relation\relation.module on line 397


texts:
I want to have a custom 404 page that displays some additional information. I need to display the requested path that was not found and some pages suggestions based on that path (this is based on some internal logic that I don't think is relevant to my question).

Here is what I did:

I defined the default 404 page to be page-not-found in admin/config/system/site-information

Then in my module I used hook_page_alter() to define my pages suggestions (if drupal_get_http_headers("status") is 404 Not Found), and the request_uri() to be shown on the 404 template page I created.

I have tried to save these values in different ways (session variable, ctools cache, everything I have tried leads to the same issue — see below).

In mymodule.module:

/**
 * Implement hook_menu
 * @return mixed
 */
function mymodule_menu() {
  $items['page-not-found'] = array(
    'title' => '',
    'page callback' => 'mymodule_page_not_found',
    'file' => 'inc/functions.inc',
    'access callback' => TRUE,
  );
  return $items;
}

/**
 * Implement hook_theme
 */
function mymodule_theme() {
  return array(
    'mymodule_page_not_found' => array(
      'template' => 'templates/404',
    ),
  );
}

In inc/functions.inc:

function mymodule_page_not_found() {

  return theme('mymodule_page_not_found');
}

Problem is, if I request a non existing URL for example mysite.com/not-found-page-1 then request mysite.com/not-found-page-2 the information displayed on the 404 page template when I query the not-found-page-2 corresponds to the values I saved when requesting not-found-page-1.

Any idea why I always get the data of the previous query?


texts: trigger attribute AJAX using custom select element

texts:
I'm currently theming the product page for a Drupal Commerce site. Our frontend developer has insisted we use his custom "fancy" select dropdown for the attributes, which is causing a bit of a theming headache!

I have implemented his jQuery successfully, and when a user changes the fancy select option, it changes the "selected" option of the hidden select element too.

The problem is that none of the Drupal AJAX calls to update the price  are fired when we change the selected attribute option via jQuery.

Does anyone know how I can force the onChange AJAX call for attribute options via jQuery?

Thanks in advance!


texts: How to Remove read more link from front page

texts:
Possible Duplicate:
  Remove links 'read more' and 'Add new comment ' on the home

I user zen theme and i tried this question answer Remove the 'read more' and 'Add new comment' links on the home page but when i apply it i face server error message. also i study that drupal core doesn't have a setting to disable read more link.

So, How can i remove read more link from front page on zen them?


texts:
I would like to protect private files with password in a content. For example, I created a content with some files, this field "Protected files" uses private filesystem.

I would like to protect these files in order to anonymous users can download these ones with a correct password.

How can I achieve this in Drupal 8?


texts:
I'm building a module with a basic form. This form has some js attached to it that I want to keep in the module, so that it's not cluttering my regular scripts file. How do I add it to my module?

I tried to add this is in my .module file but no luck.

function mymodule_init() {
drupal_add_js(drupal_get_path('module', 'mymodule') .'/myscriptfile.js');
}

What should I do?


texts: A page that list all the nodes by views but to have a one CMS controlled banner image on that page

texts:
I have created a views page which list maximum of 50 nodes of type 'event'. It works fine but I want have a single image banner on the top that can be uploaded by the logged in user from the admin area for that page. I can't add a banner field on the event content type as it will get pulled 50 times.

The other solution I managed was to create another content type called 'Banner image' and create another view which lists 1 node of event type 'Banner image' and add it to the initial page view but that seems like a really dirty solution. Is there a simpler solution to this problem?


texts:
I am using media module and using it in WYSIWYG.
Is it possible to customize the display of media image? Is there any template file I can rewrite or any hook to call? I found file_entity.tpl.php. but it doesn't seem the correct one.
Please suggest.

Thanks


texts: What "Replacement Pattern" should I choose for Content Type / Node Type in Colorbox popup?

texts:
I am using the Colorbox module and I need the type of the content to be displayed in the popup.
These are the default Replacement Pattern,

[title] == Content: Title
[field_event_date] == Content: Date
[body] == Content: Body

Can anyone tell me what should I choose for Content Type Name?

I have tried [type], [content-type], [node-type], [node:type]. But nothing worked.

Thanks


texts: How might I find a render array of a parent OG group?

texts:
If given the node id, how may I get that node's menu's render array?

I'm almost looking for an API function such as

function get_menu_for_node($nid) {}

Where this would return the render array to which node/$nid belongs.


texts:
I'm planning to build a website with Drupal (having very little experience in building sites and none with Drupal). Through my webhost I managed to install Drupal on my site and I tried to create a drupal account immediately. I got an email "Account details....(Pending Admin Approval)", but then nothing. Maybe I'm just too eager and should just wait longer :-), but it could also be that I did something wrong.
So my question: is it normal for an account to take more than 3 days getting My New Site admin approval? And can I do something to speed up the process?

I'm following some tutorials and wish I could play around a little while learning.
THanks for the info!
Hetty


texts: Minimizing the time taken for entity_load while using for apachesolr indexing

texts:
I am working on a site with a specific node type that has close to 50 fields, most of which are taxonomy term references, a couple of node references and a few conventional text and integer values. Almost all of them accept multiple values.
While indexing the nodes with apachesolr I observe that most of the time in the indexing process is consumed by calls made to entity_load function, almost 3.5 - 4 minutes for loading 200 nodes when checked with timer based logging while the total indexing takes about 50 seconds more (4.5 minutes overall).

Adding a custom 'status back' with hook_apachesolr_entity_info_alter to query and return the node status directly instead of loading it, I was able to negate the entity_load in one instance, however another function apachesolr_index_entity_to_documents() where the drupal node to solr document conversion takes place had entity_load calls consumed more time since they could no longer use the cached result of the status callback.

My aim is to reduce the time taken for indexing to at least half of what it currently which now is completely dependant on the time taken by entity_load. Since entity_load is one of the critical aspects of Drupal 7 around which functions like node_load/node_load_multiple are derived from I'm unable to find a different option to proceed or determine ways to improvise entity_load usage.

Note: The site functions such that these nodes get created almost all the time and none of the fields can be pruned out, negating the option of pre-loading the entities. Also the site uses entity cache module with memcache

I'm hoping to get suggestions on improving the node load time programatically with entity_load or using alternative approach to load the respective entities to bring down my indexing time.


texts: How do I find all objects under an object?

texts:
When I try to print out the possible options of Node::load(10)

I just get null. But I know that there are options as Node::load(10)->field_name->value gives the value of the field.

I have tried using dpm as well as json_encode.

examples:

dpm(Node::load(10)->getFieldDefinitions());
dpm(Node::load(10)->toArray());
json_encode(Node::load(10))


texts:
How to add strip tag in field template i am using ckeditor in my content type because of using it its automatically inserting p tags in Text.

Here is mine field template code

         {% for item in items %}

{{ item.content }}

{% endfor %}

I was trying something like this for adding strip tags

{% for item in items %}
{% set conBody %}
 {{ item.content }}
 {% endset %}

{{ conBody|striptags }}

{{ conBody  }}

{% endfor %}

Only indexed value(conBody[0]) field tags are stripped(p tags removed) but remaining indexed value fields are remaining same not affected.

How could i use above code in loop.


texts:
I have one content type 'object' that references one or more nodes of content type 'image'.
I'm granting access to nodes with TAC Lite: a user can view only content with a particular term.
Since the term is present only in the 'object' content type, the images referenced are not displayed in the node page.
How can I grant view access to all referenced nodes?

I've tried with Node access node reference, but it grant access to the parent node if the user has access to referenced nodes.


texts: Drush Error: no database record could be found after failed attempt of sql-sync

texts:
I was pushing our latest version of the site from our development environment to our live site (located on the same server). But unfortunately our web server ran into memory issues which prevented the move. We opened up access to more space but now SQL-sync refuse to function.

I assumed that we had issues with the database being corrupt so I replaced the database with our backup. But this did not help.

The development environment seem to work really well but I am very poor with Drush/SQL so I got a hard time understanding the error messages I get when testing the alias and site config. The Dev site work well while the live site is down and I would appreciate any advice on likely sources of the error.

The Dev alias that work well

sigvard@server1:~$ drush @mysite.dev status
 Drupal version                :  7.26
 Site URI                      :  dev.mysite.org
 Database driver               :  mysql
 Database hostname             :  localhost
 Database username             :  mysite_dev
 Database name                 :  website_mysite_dev
 Database                      :  Connected
 Drupal bootstrap              :  Successful
 Drupal user                   :  Anonymous
 Default theme                 :  mysite
 Administration theme          :  seven
 PHP configuration             :  /etc/php5/cli/php.ini
 Drush version                 :  4.5
 Drush configuration           :
 Drush alias files             :  /usr/share/drush/includes/../aliases/mysite.
                                  aliases.drushrc.php
                                  /home/sigvard/.drush/aliases.drushrc.php
 Drupal root                   :  /var/www/mysite_dev
 Site path                     :  sites/default
 File directory path           :  sites/default/files
 Private file directory path   :

Alias of the live site

sigvard@server1:~$ drush @mysite.live status
include_once(/var/www/mysite/sites/default/settings.php): failed to [warning]
open stream: Permission denied in drupal_settings_initialize() (line
717 of /var/www/mysite/includes/bootstrap.inc).
include_once(): Failed opening                                       [warning]
'/var/www/mysite/sites/default/settings.php' for inclusion
(include_path='.:/usr/share/php:/usr/share/pear') in
drupal_settings_initialize() (line 717 of
/var/www/mysite/includes/bootstrap.inc).
 Drupal version         :  7.26
 Site URI               :  mysite.org
 Default theme          :  garland
 Administration theme   :  garland
 PHP configuration      :  /etc/php5/cli/php.ini
 Drush version          :  4.5
 Drush configuration    :
 Drush alias files      :  /usr/share/drush/includes/../aliases/mysite.aliases
                           .drushrc.php /home/sigvard/.drush/aliases.drushrc.php
 Drupal root            :  /var/www/mysite
 Site path              :  sites/default
 File directory path    :  sites/default/files

sql-conf of the dev site

sigvard@server1:~$ drush @mysite.dev sql-conf
Array
(
    [database] => website_mysite_dev
    [username] => mysite_dev
    [host] => localhost
    [port] =>
    [driver] => mysql
    [prefix] =>
)

sql-conf attempt on the live site

sigvard@server1:~$ drush @mysite.live sql-conf
include_once(/var/www/mysite/sites/default/settings.php): failed to [warning]
open stream: Permission denied in drupal_settings_initialize() (line
717 of /var/www/mysite/includes/bootstrap.inc).
include_once(): Failed opening                                       [warning]
'/var/www/mysite/sites/default/settings.php' for inclusion
(include_path='.:/usr/share/php:/usr/share/pear') in
drupal_settings_initialize() (line 717 of
/var/www/mysite/includes/bootstrap.inc).


texts: Use of hyphen instead of slash in hook_menu

texts:
For SEO purpose, I need to use hyphens instead of slashes in a URL defined in hook_menu, here's an example :

$items['mypath-%'] = array(
  'page callback' => 'mypath_render',
  'page arguments' => array(1),
  'access callback' => TRUE,
  'access arguments' => array('access_content'),
);

Apparently Drupal doesn't support it natively. Is there a way to make it work ?

Cheers


texts: Responsive image style with srcset and without sizes

texts:
Using this tutorial for example I found out how to use responsive image styles in Drupal 8 without <picture> (which is pretty straight forward anyway).

However this approach forces you to use sizes. The article says

  The default here 100vw is hard-coded for a good reason, it's a pretty sane default and works well in most situations.

which I completely disagree with. I find that in most cases you simply want to provide higher resolution images of simple s for devices with a dppx that is greater than 1.

So how do I achieve something as simple like

with responsive image styles in Drupal?


texts:
I need to define a global variable. Where should I define it?

I will not use the global variable in template files
I should not use settings.php
I will only use the global variable in all the custom module files


texts: How to charge a user to post a job listing in D7?

texts: I have a job board and want to charge recruiters for each time they post a job listing. I will be using paypal and would not mind using the Commerce module in Drupal 7. I'm comfortable building Rules, even very complex ones. What is the best way to let job recruiters and businesses manage purchasing credits to be granted permission to create a job posting content type?


texts: Organic group module- teacher student layout dashbord

texts: drupal7- Organic group. Each teacher manages a class composed of several groups. Teachers only have access to their own groups. By connecting each teacher is directed to a page (or dashboard homebox) containing: its student groups with each group their latest posts, a link to their blogs , a place to send (create) a post to all groups or a specific group. Each group of students connect with the user name and password of the administrator of the group (one group member has the right to connect) and are directed to a page that contains: All posts sent by the group, members of the group, a place to send (create) a post (blog entry) only to the teacher, and a page explaining the course. How much do I create roles (teachers and students only?) which modules should I use? og, og_menu, og-audience ...


texts:
I have a custom entity with an icon_fid property. This property is used to store images.

When displaying this field in views, it just shows up as a number (the file id)

I would like to display the standard image formatter for this.

There seems to be a handler for user picture, but no generic handler for images. I have tried the file_filemime handler, but this is different.

Setting the property type to image using hook_entity_property_info_alter does not seem to work at all (broken/missing handler)

I am hoping there is some magic property somewhere that'll work. I want views to display the standard image field options (image style and all of that)

Thanks for your help


texts: usage of theme_more_link in zen template.php

texts:
I have tried to change the text in the 'Read more' link by putting:

function myzen_more_link($url, $title) {
  watchdog("template.php","myzen_more_link");
  return '
' .
    t('( more ... )',
    array('@link' => check_url($url),
    '@title' => $title)) . '
';
}

In the template.php in my zen subtheme folder but it does not appear to work.

Almost all of the discussions I have seen about formatting the "more_link" concentrate on its placement.  Can anyone tell me why this theme override does not take effect?


texts: How to add a flag link to a view that contains only fields with relationships

texts:
Normally one would add a flag link as field in a view, in order to be able to flag an entity of a views row.

However, I cannot add a flag link to a view that only shows entities using a relationship, since the flag link already uses its own relationship and apparently cannot have another relationship on top of that.

So the question is, how can I add a flag link so that it will flag entities in views rows that use a relationship?

My case:
I have a view based on entities of bundle 'project'. I have added a contextual filter that selects only the currently viewed project entity.
I have added fields of project content that reference the current project, using the entity reference field 'field_project'.
The view shows all content referencing the currently viewed project.
However, the flag that I add to the view does not flag the project content, but the viewed project. Result is that if I press one flag link, all flags appear as flagged in the view.


texts: Hide an entity with hook_entity_view_alter()

texts:
I need to remove an entity from the display.

With hook_entity_view_alter(), I am trying to change the $build array.

$build['disable'] = true;
$build['#entity']['disable'] = true;
$build['#entity'] = "";
$build['#entity']['#access'] = FALSE;

This is all wrong.

$build['entity'] is of type Drupal\eck\Entity\EckEntity and not a renderarray.

What is the correct way to hide an entity from the display?


texts:
I've been looking for a way to show all taxonomy terms that are not searched for in a view.

What I mean is: I want a search to sort out safe food for customers that are allergic to some food. If a customer is allergic to nuts the customer type nuts in the form and the customer gets a list of all dishes that DON'T contain nuts. Anyone know a module that will help me do this?


texts:
I would like to create an alternate node/add page, which can be accessed by a url path, so that I can have an alternate add node page for users while admins can see a different add node page.

This are my current selection rules:

This panel will be selected if Current path is "test", and NOT (Logged in user has role "anonymous user").

I get a 404 error when I access "test". I've tried adding the Node being edited is type "Test". selection rule but it doesn't work either.


texts: Why is the block template for User Login not used on user/login page?

texts:
If I dpm() the theme_hook_suggestions in template_preprocess_block on a standard page with the user login block on it, I get block_user_login as a suggestion.

If I go to user/login (while logged out), I don't get any pertinent suggestions. It doesn't even seem to use block.tpl.php when renderedon user/login. I know it's actually rendering that block because it prints out the description I gave it.


texts: Autocompleting line-item fields in Drupal commerce

texts:
First off all I'm rather new with Drupal & Drupal Commerce. I'm going to do my best to describe what I have done and tried.

I'm developing a website where people can register (buy) a place in event. One of the things is that on the "add to cart" page they should be able to give some information like name, club, etc.

I added some fields to the line item "Product" like for example a textfield name Club and where I selected the option "Include this field on Add to Cart forms for line items of this type" so that it is shows in my add to cart form.

The problem I now have, is that I want (for a start) autocomplete that line-item field Club using #ajax and a ajax callback.

I started off with a hook_form_alter. I dumped (after checking the form id) the $form variable (with dpm()) to look for the Club #textfield so that I can modify it to include #ajax or #autcomplete_path, but I can't find that element.

The only thing I see is an array line_item_fields containing field_club, field_name (my fields that I attached to the line item) of the type #container (and I looked for a #texfield node within it, but didn't find it). I tried adding #ajax to it but that didn't work.

To be honest I'm totally stuck now as I don't know how to proceed further with this. Is it even possible to attach #ajax or any other attributes to a line-item field visible in the add to cart form ?


texts: How to change error-message displayed @ failed form-element validation to be different than the element's '#title" text?

texts:
I'm writing a custom form module.

Using Drupal7's FormAPI, I create a checkbox, the label/text diplayed next to it is set as described here

http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#checkbox

with the #title property,

    $form['test'] = array(
    '#type'     => 'checkbox',
    '#title'    => t('This is the text that gets displayed next to the checkbox'),
    '#required' => TRUE,
    );

which then displays in the browser,

[ ] This is the text that gets displayed next to the checkbox

Ih there's an error in submission that involves that checkbox, e.g. in the example above being required but not being checked, an error box is shown across the top content-area that says

"X  The This is the text that gets displayed next to the checkbox field is required"

I want to change that displayed error message to something other than the label/text.  For example, on error,

"X  Selecting the displayed checkbox is required."

or

"X  You forgot to check the required checkbox.  Please try again."

How do I set the error-message text to be different that the assigned label/text?


texts:
I am making a return request page for my website the user will enter in his/her information about their order and it will pull up a list of their order. The information is pulled from the views then submitted to the confirmation page.

I already have the form validation working but I need the validation code written in the page--node--nodeid.tpl.php to send an email to 2 people, the customer and me, using the information from the form.

I've seen drupal_mail(), but this seems like it needs to be used in a module.

Is this even possible?

On a side note it would be helpful to be able to use a template later.


texts: User picture not removed when deleting user in Drupal 7

texts:
After creating users with a picture programmatically, and deleting them afterwards, I found out that the pictures (files) were not removed.

I started digging into this problem and found out that this problem also occurs when just adding a user by the UI, uploading a picture and deleting the user.

The picture is not being removed. Also the file remains in the file_usage and in the file_managed tables. They're not marked for deletion, so I guess they will stay there forever. Is this a bug? Or am I missing something?