texts: Generating URLs with fromUri and the language prefix, base vs internal

texts:
What is the recommended way to generate non-route URLs that include the language prefix?

Context: In CiviCRM, an open source third-party project that integrates with Drupal, we have a function that generates internal URLs (a wrapper over the CMS-specific function).

Since not all URLs referenced have a proper route, so far fromUri has given the best results (rather than fromRoute).

However, the URLs generated by fromUri do not seem to include the language prefix for multi-lingual configurations when using base as the prefix. The language prefix is included with internal, but if I understand correctly, internal should only be used for user-specified links, such as a link field.

Example on a site that has English and French, with French being the default language:

print \Drupal\Core\Url::fromUri("base:/admin")->toString() . "\n";
print \Drupal\Core\Url::fromUri("internal:/admin")->toString() . "\n";

$ drush scr test.php
/civicrm/dashboard?reset=1
/fr/civicrm/dashboard?reset=1

I also tried passing in the $language object, but the behaviour is the same:

$language = \Drupal::languageManager()->getCurrentLanguage();

print \Drupal\Core\Url::fromUri("base:/admin", [
  'language' => $language,
])->toString() . "\n";

Related question: Generating arbitrary internal URLs


texts:
I'm trying to port a working FAPI module from  D6 to D7.
I'm passing a POST value to the form and then assigning using :

 $link = check_url(substr($_POST['file_link'], 0, 300));
     $form['anu_download_file_link'] = array(
        '#type' => 'value',
        '#value' => $link,
      );

But when form is submitted the form is built again but this POST data file_link is missing in the submit handler.

In D6 $form['#cache']=true was working fine which avoided recreating of the form but now in D7 it does not seem to work.

How can pass POST values to the submit handler?


texts: If a Views Contextual Filter using PHP code doesn't resolve, can I make Views "Display all results"

texts:
Situation:

Contextual filter "Has taxonomy term by ID"
Filter is set to "Provide default value" > "Type: PHP Code"
The PHP code resolves in most cases, but on some pages it shouldn't.  In those cases I'd like to do what Views does when you choose the "Display all results for the specified field" option.

Is there something my PHP code can pass back to Views that will cause it to display all results?

(Or even 'Display contents of "No results found"' because then I could use a View inside there)

Config: Views 3, D7


texts:
can someone please explain the difference between

hook_user_insert() and

hook_user() with $op='insert'

i mean is hook_user with $op='$edit' is invoked after a user create an account??

cos i am trying to get some custom field values when a user create a new account.
i used this code for testing:

function myModule_user($op, &$edit, &$account, $category = NULL) {
  if ($op == 'insert' ){
    dpm($edit)
  }
}

and it don't return nothing after creating a new user account.


texts:
I am trying to use Unix timestamp for my date field.

According to the php.net/date U is for Unix timestamp, so this is how I set it up:

When I put an Unix timestamp time, such as the current time, 1451362409 and save. It says, "Article X has been updated", but when I go to edit, the field is empty.

For Field Type, I tried using

Date
Date (Unix timestamp)
Date (ISO format)

Hence test 1, test 2, test 3.

As you can see in test 4, when it's non Unix timestamp, it is saving to the DB.

Why is it not saving to the DB? Did I miss a step, or I'm I doing something wrong? Could it be a bug? Is there any other way of doing this?


texts: How do I add classes to form elements in the theme layer?

texts:
I want to do it in template.php. The form ID is page_node_form, and there are six form text fields. The default class is "form-text."

I want to add "text1," "text2," etc after "form-text" to each input text class. How can I do it?

This is the HTML:

<input gtbfieldid="10" id="edit-field-14sq-und-0-value" name="field_14sq[und][0][value]" value="" size="12" maxlength="10" class="form-text" type="text">
<input gtbfieldid="10" id="edit-field-14sq-und-0-value" name="field_15sq[und][0][value]" value="" size="12" maxlength="10" class="form-text" type="text"> ....


texts: how to change the weight of a moderation state transition outside the database

texts: how can I change the weight of a Moderation state transition in code?  is it possible?  This is for Drupal 8


texts: Generate file path for created file so it can be downloaded

texts:
I'm writing a module based on this Jeff Geerling post that will allow the user to use a form to select some data, and then use the Batch API to generate a large .csv file with the desired data and download it from the browser. I have the form and batch processing working fine, but I can't figure out how to determine the path for the created file, as referenced in this code snippet:

/**
 * Interim download step for downloading CSV file.
 */
function MYMODULE_download_csv_file_interim($list_id) {
  global $base_url;

  if (empty($_SESSION['csv_download_filename']) || empty($_SESSION['csv_download_file'])) {
    return t('Please visit your list subscribers page to begin a list download.');
  }

  $list = node_load($list_id);

  // Redirect to the download file.
  $redirect = base_path() . 'path/to/download/csv/' . $list_id;
  drupal_add_js('setTimeout(function() { window.location.href = "' . $redirect . '"; }, 2000);', 'inline');

  $download_link = l(t('click here to download the file'), 'path/to/download/csv/' . $list_id);
  $output = '
' . t('Your subscriber list is now ready for download. The download should begin automatically. If it does not begin downloading within 5 seconds, please !download_link.', array('!download_link' => $download_link)) . '
';
  $output .= '
' . l(t("&#8592; Back to %list subscribers", array('%list' => $list->title)), 'node/' . $list_id . '/subscribers', array('html' => TRUE)) . '
';
  return $output;
}

At this point in the code, $_SESSION['csv_download_file'] is tmp/my_file.csv. I've tried to figure how to make this a valid url for downloading the file, but can't. For instance, I've tried using file_create_url(), but it just returns the same path.

What do I need to use to make this a valid URL to pass to the browser?


texts: How might one get a conditional display of tooltip or popup message from a rewritten view field?

texts:
The issue concerns a View displaying a partial set of fields from a content type "video record," containing a collection of info about videos. One of those items is a Boolean (checked or not checked) indication of whether or not this video is allowed to be added to a user's shareable lists, generated by the module Flag Lists. If it IS shareable (Boolean was checked in full record) then the View displays a checkbox, allowing it to be added to a list. If it's NOT shareable (Boolean was unchecked) then we want to suppress the checkbox and display something else instead; currently that is just an "X" and that is working. Partial display of this here:

The "X" in the View field, a table cell, is the result of a View field rewrite plus display of the text "X" on the condition of "no results."

However we also want to have some form of tooltip/popup message, for hover on the "X," that explains why it's not allowed to be selected. Ideally, if this View field contains "X" then the tooltip would be active; otherwise it wouldn't. Here is a simulation of that:

This is currently working and the tooltip message is generated by the module "Tipsy." However that requires CSS selectors to associate it with the proper item. The only way we can see to use this is to manually add (to Tipsy config) a unique selector for each and every item in the list where this condition applies. Most problematic is that the selectors (as far as I have been able to understand) merely identify a position in the table – so if the table is resorted, they would get out-of-sync.

Can anyone suggest another path for getting to the desired result? That could be either a different way to get the tooltip/popup message that would only be active on the relevant table cell contents, OR maybe backing up farther and presenting the checkbox/no checkbox option a different way, depending on the full content page's condition of shareable/not shareable.


texts: How to programmatically remove a user from an organic group

texts: I have found many examples about how to add a user to an organic group but I can't find any info on how to remove a user from an organic group programmatically. Does anyone have an example of how to do this?


texts: How do I display two different views for a single content?

texts:
I'm quite new to drupal and trying to learn this after working with a very different CMS system the past ten years.  Here is my issue/question:

I have a content type that I'd like to have two distinctly different views. The first view contains a form (that does not use any drupal module).  When a user submits the form, I'd like to show a 'confirmation page' view for that same content type (since it has info that I'd like to show in the confirmation view).  What would be the url to use for the different view?


texts:
I need to make changes to several admin pages, instead of conditionally tests for the page/node (ie: User, Appearance, Views admin pages right now) can I override each using more specific theme functions?

MYTHEME_preprocess_page_admin_user
MYTHEME_preprocess_page_admin_views
MYTHEME_preprocess_page_admin_appearance

Is this possible? It's the themeing function not the template TPL I need to execute as I am re-structuring some list items in each -- not really changing the markup per se.

Alex


texts:
I read on the drupal.org site: "Never put a literal value or variable directly into a query fragment, just as literals and variables should never be placed into a static query directly (they can lead to SQL injection vulnerabilities) http://drupal.org/node/1848348

$query = db_select('node', 'n');
$query -> condition('node', $nid);
$nodes = $query
-> fields('n', array('title'))
-> execute();

Does this also apply to queries written with the query builder, like the one above? If so, how should it be re-written?

Thanks


texts: How to set up a View in Drupal that shows recent posts relative to post date of node it is on?

texts:
I want to set up a View that shows all the nodes that were updated within 7 days of the node that is being viewed

So if the node being viewed has a post date of January 15, 2014, I would see posts that were published between January 8-15, 2014.

I know there is a contextual filter involved, but it eludes me how to do this so the date used is relative to the node it is being viewed on.


texts: Why should the Hacked! module not be used on a production server?

texts:
In the source code of the Hacked! module, it says it should never be used on a production server.

/**
 * @file
 * The Hacked! module, shows which project have been changed since download.
 *
 * We download the original project file, and hash all the files contained
 * within, then we hash our local copies and compare.
 * This module should never be used on a production server.
 */

Why not?  How would it compromise security?


texts: drupal_add_js() won't work with footer scope

texts:
i 'm trying to add a file to end of body via template.php in mytheme_preprocess_page.
this is the line i have:

drupal_add_js(drupal_get_path('theme', 'mytheme') . '/js/file.js',array('type' => 'file','scope' => 'footer'));

why i can't see file.js in view source? -if i change footer scope to header file.js add to head tag -

doc says:

  Possible values are 'header' or 'footer'. If your theme implements
  different regions, you can also use these

i tried to add footer region to page.tpl.php but it doesn't work.

what do means footer scope?


texts: How to get the Collage Formatter module to work?

texts:
I'm using the Collage Formatter module (Drupal 7) to create a gallery.

But I seem to have a problem when I apply the Collage Formatter image style. When the image is smaller the colorbox doesn't resize it and it leaves a white box. So I tried creating a new image style and apply it but it doesn't work either.

Any suggestions?


texts: Module to list menu_router / path debug info?

texts:
Every now and then, mostly when looking at a new site, I find myself wanting to know

What's the source of this particular page?

Usually, I end up starting to dig in the menu_router table, and possibly also alias tables. Is there a module that will be helpful in finding and displaying this, and other relevant, information for me?


texts: Calling a contact form in a certain page

texts:
I want to see my contact form in another page. I have now a link, www.xxx.com/index.php which is the contact form and dose work perfectly. I want to put it in another page let's say www.xxxx.com/YYY.php.

By opening www.xxxx.com/YYY.php, I want to see the contact form, too. Any help? Thanks


texts: How do I display in a view, the opposite of what is checked/true?

texts:
I have a table that displays a list of food items where the columns are the food name, the vitamins, and the minerals the food contains.

My goal is to display the list of vitamins and minerals missing in someone's diet. So as for the example in above, the table is currently showing which minerals and vitamins the food contains. It should instead display the vitamins and the minerals the food items are missing.
The way it would work, as blueberries have vitamins C and K, the table should show vitamins A, B1-12, D, E, etc etc.


texts: Suddenly unable to add a field to a new content type

texts:
When editing a content type I was going to add a simple boolean field to an existing content type. When attempting to add the new field Drupal threw an error. After a few more attempts to add a field to an existing content type I created a new content type to add a field to and was unable to add a field to a new content type.

I get the following error when trying to create a new field on a content type:
There was a problem creating field First Name: Attempt to create a field field_first_name that does not exist on entity type node.

I have the same problem trying to a field to a taxonomy item:
There was a problem creating field IsActive: Attempt to create a field field_isactive that does not exist on entity type taxonomy_term.


texts: multiple Value of group of fields in CCK

texts:
I would like to create a form with CCK.

The user should be able to create unlimited number of "people" :

M    -  Smith   -   John
Mrs  -  Dave    -   Lily
M    -  John    -   Doe
...

So I need a Select (with gender) - textfield (last name) - textfield (first name).

I can not create each field to unlimited it would not be linked.
I have tried field_group, but it does not give me the ability to put multiple value.

What would be the best way to do that ?
I thought about create my own field with those 3 inputs. but it seems way to complicated for the simple thing I need to do. further more I cannot find any good tutorial.

EDIT : I'm using Drupal 7


texts: Is there an option to somehow display all nodes that that doesn't have a menu link?

texts:
As almost all users here know, you can set up a menu link to each node from the "Menu settings" tab in the node's edit form.

Is there an option to show all nodes that don't have a menu link?

I tried to create a view and use the filter criteria to achieve that, but no relevant filtering option appeared for me there.


texts: hook_install() doesn't seem to work, even though I have disabled and uninstalled module

texts:
I'm writing a module that will enable an editor to determine whether a script is available on a specific node, in order to improve page load times.

I need to create a database table to hold an indicator showing, for each node ID, whether the script is available. My code is this.

function script_show_schema() {
    $schema['script_show_enabled'] = array(
        'description' => 'Tracks whether Script Show is enabled for a given node',
        'fields' => array(
            'nid' => array(
                'description' => 'The {node}.nid that has Script Show enabled',
                'type' => 'int',
}               'not null' => TRUE,
                'default' => 0,
            ),
        ),
        'primary key' => array('nid'),
    );
    return $schema;
}

I've disabled, then uninstalled, then re-enabled my module through the admin UI, (as opposed to using Drush), but I still don't seem to be able to see my database tables.

I know this question has been asked a couple of times before, but usually the solution seems to be the uninstall thing.

Does anyone have any idea on what is going wrong? I wonder if it's a DB permissions thing. But then, I guess Drupal has root access to the DB in order to create its tables in the first place.

Updates:

I am using version 7.23 of the core.

Here's my .info file:

; $Id$
name = Script Show
description = "Allows the user to specify that the Maxymiser script will only execute on specific pages"
package = JD Dev Modules
core = 7.x
files[] = script_show.module

flag

My entire module is here: github.com/jamesdesq/script_show.


texts:
I need to be able to change attributes (like class, data-toggle, data-direction) of the label itself, at a PHP level, in a way that will support conditions in form definition function.

The solution given in How can I add a class to a label? doesn't work for my problem, as they are only workarounds that will not work with the theming JavaScript I need to expose my data to. Also, they are pretty much limited to styling, and that's only one of the attributes that may be needed.

I'm OK with only having limited, predefined sets of attributes, as long as I can select one at the time of form building.


texts:
I need 2 context that are identical expect that a single block will not be shown for one. Do I have to create 2 completely separate context (which will be more work to maintain)? Or is there someway to not show a single block within a context based on a new criteria?

For instance my context is page = front page. Im using mobile detect and I need to hide a certain block in this context for mobile devices.


texts:
In the UK our weather office provides a live weather data feed. I would like my Drupal site to retrieve data from this service.

I've read up on the XML-RPC API that is in Drupal 7 core. I've successfully built a Hello World! module that acts as a client, makes a call to a service, and successfully gets a response.

However, Drupal 7 is old and I'm wondering if I should be looking into a more 'modern' approach. I've read up on the Services module.

Can anyone advise me on what are currently the recommended ways to get data from a service into a Drupal 7 site.

I'm not looking for a weather module. This is an API learning exercise.

Thanks.


texts: How to restrict a page to a group of people?

texts:
I am trying to figure out how I can lock down a page (part of my site) to a list of users that I have in another MySQL DB.

Ideally I would like to call the DB and see if the user has access each time they login. Is there any modules that would do this? Or has anyone done anything similar before.


texts:
I like the multiple login possibility of Disqus. You can login with facebook or twitter or google etc.
 On the other hand, comments will exist on a 3rd party server and the package that includes the single login feature costs a lot (that mean that drupal site's users can comment without logging again at disqus system or another).

How I can simulate similar system on my site?
How can users sign in with facebook, twitter, google, openid at my site so that they comment?
Is there any other feature of disqus system apart from multiple login that can be accomplished with drupal modules?

[3. Does disqus makes site slower to load?
4. How can I move comments from Drupal to Disqus?
5. How can I move comments from Disqus to Drupal?]

Edit: I would like an answer possibly from someone that has used both systems as advantages and disadvantages appear in the long run, and it is not easy to decide just at a fast research. I have seen sites switching from one commenting system to another because they understood the disadvantages of their choice after some months.


texts: How to add a button in the header of a table form?

texts:
I have this table form:

The corresponding code for the header is
$form['inscriptions'] = [
  '#type'   => 'table',
  '#header' => [
    [
      'data'    => '',
      'colspan' => 2,
    ],
    [
      'data'    => 'Distribution',
      'colspan' => 2,
    ],
    [
      'data'    => 'Réserve',
      'colspan' => 2,
    ],
    [
      'data'    => 'Référent',
      'colspan' => 2,
    ],
  ],
  '#id'     => 'planningofdistributions',
  '#sticky' => TRUE,
];

I would like to replace the (empty) content of the first cell by a submit button.
How can I do that?


texts: Views Slideshow: specified number of images in random order?

texts:
I set up Views Slideshow so that it use the image field from a given content type. Total number of images in database under that field is 15.

What I want is a row of 6 random images on my home page that changes every x seconds. To achieve that I set the Views Slideshow pager option "Items per slide" to 6.

Now, everything works fine for the first and second slide, but the third slide has only 3 pictures (6 + 6 + 3 = 15), while I would like to have a full row of 6 pictures on every slide. If I set the Pager feature of the view itself (as I did before slideshow, using Grid format), the slideshow turns off (it has to be set to "Display all items"), so that's not the way to go about it.

Does anyone have any idea how to get that result?


texts: How do I resolve this conflict between two Feature modules?

texts:
I have two content types with various menus, views, menus, etc. which I have packaged as two Feature custom modules.  The two content types both use a taxonomy and use several of the same fields in the database.  When I load these Feature modules in a new site, they show conflicts with each other over these common fields and vocabulary and I am not certain what would be the best way to resolve the conflict.

Although the Feature modules are intended to work together, they do not need to both be present on the same site. Each may also work with other different features as well.  They both use the taxonomy and fields for views filtering etc so it makes sense that they each include these components in their Feature definition.  Should I:

Remove the fields and taxonomy from one of the modules, and declare a dependency to the other?  This is not desirable since each can work without the other.
Make two versions of the features, one for independent use, and one for collaborating.
Define the fields and taxonomy as a separate feature?
Ignore the conflict and enable the modules?  (If I do, will they both share the field?)
Another solution?

I have not yet tested this, but will disabling or uninstalling one of the two Features modules remove the fields from the database even though the other module requires it?


texts:
I've added the paragraphs field as a relationship and managed to add my fields to the view but I can't seem to group them together. As a result the node entity is being spit out twice. Is it possible to group the nodes together?

Current:

0: {
    nid: '1',
    field_section_title: 'Section 1',
    field_section_reference: '6',
},
1: {
    nid: '1',
    field_section_title: 'Section 2',
    field_section_reference: '7',
}

Desired:

0: {
    nid: 1,
    paragraphs: {
        0: {
            field_section_title: 'Section 1',
            field_section_reference: '6',
        },
        1: {
            field_section_title: 'Section 2',
            field_section_reference: '7',
        }
    }


texts: On entity save, identify the user fields that have been changed

texts:
I have a need to track changes to users in a separate database, apart from Drupal. When a user changes their email address or their password, I need to communicate that change with a shadow table in MSSQL.
I've created an event and listener. The event is triggered by hook_entity_update. That works fine, but I don't know what was changed in that request. Is there a way to pass the value that was changed to that event listener?


texts: Is it fine to use hook_entity_view_mode_alter() to intercept an entity view to change the view mode based on an attached field value?

texts:
Basically I want to let the content creator choose an arbitrary view mode. For example, be able to choose a gallery that is a FlexSlider slideshow, a Masonry jQuery plugin type image gallery, or an image gallery that displays metadata below each image.

On the entity there would be a field called field_view_mode which is an options list. The options are flex slider, masonry, and full images with text. Depending on the option they get the images and other fields formatted differently in different templates.

I'm thinking about defining 5 different arbitrary view modes. One more view mode would be custom_view_mode.

function hook_entity_view_mode_alter(&$view_mode, $context) {
  // For nodes, change the view mode when it is teaser.
  if ($context['entity_type'] == 'node' && $view_mode == 'custom_view_mode') {
    $view_mode = 'use entity metadata wrapper to pull field_view_mode value here';
  }
}

I don't want to use the Template Field module because it seems like overkill. I'm not sure if the Display Suite module does this but that seems like overkill too. I just want different view modes to be available. Has anyone done this before?


texts: Config split settings file generated into split directory

texts:
Drupal 8.7
I have a multisite split. The config_split.config_split.<sitename>.yml files are supposed to go into the config/default directory. For some reason when updating a split on one of my sites, instead of updating the existing file in that location, it creates a new file in the config/sitename directory. It only does it on this one site. When I compare the newly generated file to the one for that site in the default directory, only the new changes are different. The rest is the same.


texts: Repeat the alt text and title text for a series of image field values

texts:
I have created a content type for an image gallery, and added an image field with alt text and title tags and gave unlimited upload feature.

If I upload 10 images I want to give the title and alt tags 10 times. Can I bypass each individual image by giving these details one time and applying for all subsequent images?

Is this possible to do via the Drupal admin UI?


texts: Ubercart : divide the main stock in stocks per type of users

texts:
I have a D6 Ubercart site with the following:

There are different kind of members (Premium Member, Regular Member).
There is an online shop, using Ubercart with the possibility to define a stock that is automatically updated when people book a ticket.

So far, all the users have access to the same stock : if I have 100 tickets, it is sold regardless the type of the users.

What I want to do is sub-divide the stock such that one role (e.g. Premium Member) has 60 tickets, while another, has the remaining 40. Each role should only see the amount in stock that is available to them.

I couldn't find a way to personalize the stock in Ubercart. is it possible to do such a thing without installing any complementary module?


texts:
I am trying to get the user ID associated with a node using this code in Drupal 7, without any luck:

$uid =  $node->uid;
echo "uid: " . $uid;

$uid doesn't have any value in it.

I want to get it so that I can count the number of my members' posts.

$node = node_load('NID');
$uid = $node->uid;
$sql = "SELECT nid FROM {node} WHERE uid = $uid";
$result = db_query($sql);

$number_of_rows = $result->rowCount();
echo "uid: " . $uid;
print "
$node->name has submitted $number_of_rows source code / articles.
";'

I tried putting it in a display suite module under fields. I also tried putting in a page content type.


texts: I'm trying to hide non-admin users to view the email address field in the user section. I have the following hook. Right now, I have the current password hidden, but the email sends back a naughty validation requiring email to be added.


texts: Enable all languages for multilingual site

texts:
I notice I can add languages one by one on this page
mysite.com/admin/config/regional/language/add

Is there an easy way for adding all languages?
Maybe there is a command with drush?


texts: I want to change the title and title head html element. I have tried with drupal_set_title() but Drupal insists on adding the site name to the title output. How can I override it so the title reads exactly as I want?


texts: Where are these modules - "Views Slideshow: SingleFrame" & "Views Slideshow:ThumbnailHover"?

texts:
Were these integrated into some other modules? Cannot find a trace of them anywhere on drupal.org but they are used at many places, like in this tutorial: http://mustardseedmedia.com/podcast/episode42

Screenshot from the tutorial showing the Modules: http://www.tiikoni.com/tis/view/?id=0000d1a


texts: Is it possible to wrap the fields of a view inside a  and ?

texts:
UPDATE: Colin is right but I'd like to go over what I did to accomplish this.
I added a views-view.tpl.php template and where it said

<?php print $rows; ?>

I wrapped it like this

    <?php print $rows; ?>

I also wanted to prevent each row from being wrapped in a view so I also added a views-view-unformatted.tpl.php template and replaced

<div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"';  } ?>>
    <?php print $row; ?>

with just

<?php print $row; ?>

I'm trying to have a view that starts with a

then contains all the content of my view like so

image

image

image

and then ends with

However I'm having a lot of trouble. Header and footer does not work because it starts and closes it in it's own div. I tried hiding all the contents and doing a global text field like so

[image]

However that gives each item it's own nav and closes it right after each one.

Is wrapping the entire comments in the  and  tags possible in drupal?


texts:
I have a module that define a Routing and a controller

my.partner:
  path: '/partner/{alias}'
  defaults:
    _controller: '\Drupal\myname\Controller\PagesController::partner'
    _title: 'Partner'

In controller I define the template to use:

$variables = [
         '#theme' => 'page_partner',
]....

But I need to pass some "variables" from this "controller" to html <head>. How can I do it ?


texts: how to show image style with private file system? 403 access denied error occurs

texts:
I'm working on a webapp and changed my public file system in to a private file system. Everything works fine, except my thumbnails created by image styles throwing a 403 Access denied error.

Does anyone know how to fix this, without removing the private check in image.module in core??

private file system check in image.module

if ($scheme == 'private') {
    if (file_exists($derivative_uri)) {
      file_download($scheme, file_uri_target($derivative_uri));
}

Thanks


texts: Images in sites/default/files are not allowed to be seen anymore

texts: Today I realized, that all images, that are located in sites/default/files/fields may not be accessed anymote, neither are they shown in my articles nor may I see them in the browser (e.g. http://daniel-stein.com/node/210#). All I get is a 403 - no permission - error. The folder and the files within are all set to 744 (and I also tested 777). I have not found any permissions I could adjust and I am not sure when this started or what I changed in that moment. Maybe it was around the time I changed from buedit to ckedit but the switch back was also useless.


texts:
I have a site that has over 18,000 data items in a catalog. I am using Drupal 7 and the latest Views module to display the data. The data items contain an auto make, model, year, cv axle. My search query needs to be able to search this catalog in the following matter: If the EU click in an input box for "make," they can put in the search term (e.g. Ford) and all Ford models pull up. In addition, there is another search field next to the "Make" field for "Model" and another one for "Year." I want Drupal to add all the search terms together to alter the view. Right now, If the user types in one term and searches, it works; however, if the EU types in another term in the "Model" field say, the view that outputs will only include the last term searched.
For example, I type in "Ford," and all Fords come up; if I add a term to the "Year" field (e.g. 1999), all 1999 autos come up, not just the Ford models of that year.

How do I create a search engine that spans terms across multiple fields (Make+Model+Year: OR however many search term the EU wishes to include) to filter what is output through Views?

Any help would be greatly appreciated!!

www.sutrack.biz=> cv axle catalog link


texts: What is the convention for naming routes?

texts:
Lets say I have these paths:

/admin
/admin/settings
/admin/settings/myentities
myentity/id
/admin/settings/myentities/id/edit
/admin/settings/myentities/id/delete

What would be the proper route names for each one of them?

My current usage is this:

admin

/admin

admin.settings

/admin/settings

admin.settings.myentities OR admin.myentities

/admin/settings/myentities

myentit OR myentity.view

/myentity/id

myentity.edit OR admin.myentities.edit OR admin.settings.myentities.edit

/admin/settings/myentities/id/edit

The things I mostly not sure about is whether I should use the path structure for the route name or not(ie. /path/to/some/where => path.somewhere OR path.to.some.where) and when it comes to entities if I should use admin.myentities + admin.myentities.myentity OR admin.myentity.edit) etc..


texts: View with empty filter result visible only to admin user

texts:
So I am new to Drupal 7, just so you know.

Here is my problem:

I created a view displaying all registered users ("members"). Following a tutorial, I managed to display their user pic, name, date joined and amount of posts. The latter was done using aggregation and the relationship filter "User: content authored".

All works great in the preview and real view, but only for the Admin role. When I log out and try it as a fake member I created for testing, the members with 0 posts don't show up.

I have searched for an answer for hours now and have fiddled with filter settings until I am blue, but no luck.

ETA: I have found that some people have had luck using the Views Field View Module. I tried it, setting up a new view for the post counter and then adding it to the parent view, but now I am getting the same post count for all users. Don't know what I am doing wrong...

Please can anyone help?


texts: Check if it's the front page in the template

texts:
Im trying to show content when I'm on the front page of my Drupal 8 test website, but the content shows on every page:

{% if front_page %}

    {% if logo %}

    {% endif %}

TESTTESTTESTESTAET

test</h1

    {{ page.header }}

{% endif %}

Why doesn't this work and how can I make this work?


texts:
I have came across this error for a few times now, and i don't know why it happens.

I have created a view, in which i show node data. Nothing special... Data is obviously loaded from "node" table. But when i run

    node_load()

i get different data!? I checked, and it is from node_revision table.

Why is that? How can i fix this?

thanks


texts: Status report: Twitter module using unautheticated api

texts:
So, I'm getting kind of a strange error in my status report about my twitter module. I get an error that the twitter pull authentication is using an unauthorized api" Below that it says that the Twitter modules doesn't have any authorized accounts, and that I should add an authorized account via the accounts page. The issue is that I have authorized accounts attached.

I'm using twitter module 6.2 and twitter pull version 7-2.0alpha3.

callback url is: twitter/oauth
the host is : twitter.com
and the api is: https://api.twitter.com

Not sure if this an incompatibility between versions, or what the problem is here. How to fix?


texts: How restrict Anonymous users from creating accounts

texts:
I am building my first site in Drupal(7), and I would like to restrict unloged users from creating user accounts, so how can I disable new account creating from {mysiteName}/user?

Thanks a lot


texts: Check if config_translation exists in specified language

texts:
The following code loads all configuration entities of a given type:

$entities = Drupal::service('entity_type.manager')
  ->getStorage('ENTITY_TYPE')
  ->loadMultiple();

However, this will erroneously include entities that are not translated into the active language via config_translation. Worse, regardless of whether a translation has been loaded, $entity->language() still returns the original language of the entity.

Is there any way to determine if a given config entity has been translated into the active language, so the untranslated entities can be filtered out?


texts: db_select pager query orderBy signed int

texts:
I have an INT 'weight' field for some nodes that runs -20 through to +20 and want to order the nodes so that -20 is at the top, but, as far as I can tell I'm getting them in string order.  I've tried

  $query->addField('w', 'field_weight_value', 'weight');

  $result = $query
    ->limit(10)
    ->orderBy('CAST(w.field_weight_value AS SIGNED)', 'ASC')
    ->execute();

But that makes no difference, I still get 0 appearing above -10.  I'm using db_select so that I can use the PagerDefault extension.  I could just change the 'weight' field to be all positive, but that seems like a fail!

I think the problem might be it's always evaluated as a string even though the table column is type INT, if I perform the same query as db_query, e.g.

  $result = db_query('SELECT n.nid, n.title, w.field_weight_value
    FROM {node} n
    ORDER BY w.field_weight_value ASC', array(':nid' => $nid));

I get the results I expect.


texts: Different colors and fonts dependent on roles in views results

texts:
Views listings are made from many users, but some of them have special role that is more important.
Is there an easy way to give that special role different background color or font or font size when viewing views results ?


texts: Is there a function that can output an image?

texts:
[field_img] => Array(
  [0] => Array(
    [fid] => 200
    [list] => 1
    [data] => Array(
      [alt] =>
      [title] =>
    )
    [uid] => 1
    [filename] => cpon.jpg
    [filepath] => sites/default/files/cpon_0.jpg
    [filemime] => image/jpeg
    [filesize] => 4434
  )
)

Is there a function that, using the above information, can output an image?
Is there any other method to output an image using the above information?


texts: Automate creation of taxonomy terms for use with migration module

texts: How do i script the creation of my taxonomy terms - do people normally do this with features?


texts: Drupal Commerce - Update profile on order without cloning?

texts:
I understand the reasoning behind preserving integrity of data for existing orders tied to profiles, however...

I have a page where the user can edit the order contents and change their billing or delivery information. Instead of create a new profile, I would like to save the data directly to the order being viewed. I don't want it to affect new orders created later, either.

How can I do this? It would seem that every time commerce_customer_profile_save is called, a brand new profile is created.

This isn't a standard commerce workflow, but most of the fundamentals are there. A customer can have many open orders at any given time, and I want the flexibility for them to change the delivery address ON a specific order and save it for that order only. Someone out there has to have done this I would believe.


texts: Change URL of link in Main Menu if href=X

texts:
I thought that this would be simple, but I'm finding it difficult.

I would like to change the URL of a link that is set in my main menu if the URL is a certain URL.

I have been looking at theme_menu_link(). I've placed the following in my template.php

function MYTHEME_menu_link(array $variables) {
  $element  = $variables['element'];
  print_r($element);
  print_r($variables);
  dpm('im here');
  return '
test
';
  // $element = $variables['element'];
  // $sub_menu = '';
  //
  // if ($element['#below']) {
  //   $sub_menu = drupal_render($element['#below']);
  // }
  // $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  // return '
' . $output . $sub_menu . "
\n";
}

However, nothing gets returned that I can see. I have replaced 'MYTHEME' with the actual name of my theme and have cleared all caches and checked the output for my dpm()'s and print_r()'s. Once I can target the array/link/href I am assuming I will just check if it isset and overwrite it with a new value.

Thank you in advance for your suggestions!


texts: Flexible addons for Solr to achieve sorting and filtering

texts:
My requirement is to provide end user with an option to sort/filter the search results. This can be achieved different ways but I am unclear to choose one. I found these methods.

Using facetapi - I can filter results, not sure about sorting.
Using apachesolr_sort - I can group/sort results, not sure about filtering.
Using apachesolr_views - I can show my results more flexible this way. But this doesn't seem to support sorting https://www.drupal.org/node/443410.
Using search_api and search_api_solr - This method is more preferred and flexible to group/filter/sort results. But I am worried about heavy size of these modules.

Can someone suggest me to achieve the most flexible (and less resource consuming) method of sorting/filtering results by any combination of the above modules.

Thanks!


texts: Let authenticated users (non-admin) reorder uploaded images using the 4-way arrow

texts:
Currently, the admin is able to reorder uploaded images (field), using the 4-way arrow, like so:

But other authenticated users(not admin) can only reorder images through "Show row weights":

but it gets tedious when there is more images. Is there a way to enable the 4-way arrow for them?


texts: Drupal 7 views exposed filter: Removing -Any- and sorting items

texts:
I am using Drupal 7.21 and views 3.7. I have date module installed. In one of my views, I want to give drop-down year as an exposed filter and it is working fine. I do have choices as
-Any-
2012
2013
But I want to remove -Any- and sort the items, so it will be like
2013
2012
I checked Required in exposed filter option without success and also used BEF module but there is not any option to do so. I also saw some blog and issue suggesting using hook__form_views_exposed_form_alter hook. I used that as http://eureka.ykyuen.info/2012/11/22/drupal-7-customize-the-exposed-filter-selection-list/ this blog suggested but in my form option there isn't even any options listed not as this blog said.

Can anyone help me to get the exposed filter I want to show?
Thank you


texts: How to setup the recipient email in the webform mail template file?

texts:
I have overridden the webform mail(webform-mail-19.tpl.php) template in my theme.
The problem is I want to set the recipient in this template file so I used this code.
$email['email'] = 'example@example.com'
but it did not send email to this address instead it sends email to the email address which i setup in the email settings of the webform.

I print the $email array and I could see "example@example.com" email there but did not know why it sends the email to the default email address which is setup at the email settings of the webform.

Any Idea about this?


texts: How do I append a unique menu ID to the menu?

texts:
I'm using Drupal 7 and I want to append a unique ID to specific menus. My search result gives me the way to change the item of the menu, but I want to change the menu itself.
Is there a way to do that?


texts: Decode an image in base 64 to a file, using feeds, feeds tamper and jsonpath

texts:
I have a problem importing a 64 base image through the feeds module. I am consuming a service through jsonpath.

I am using the tamper feeds module to try to decode the image and then save it as a file but I have not succeeded.

I get the data well in the attribute mapping between the service and the content type, but I can not get the feed tamper to decode it and save it as an image in the content type.

Is this possible to do?


texts:
A call to field_attach_load should be loading node titles, but they are not being loaded.  Perhaps I am missing something simple, since this my first Drupal hook.

This is the code I am using to query all the published Event nodes and their associated fields.

$query = new EntityFieldQuery();
$results = $query->entityCondition('entity_type', 'node')
  ->propertyCondition('type', 'event')
  ->propertyCondition('status', NODE_PUBLISHED)
  ->execute();

  // Attach the field values to the nodes.
  $nodes = $results['node'];

  field_attach_load('node', $nodes, FIELD_LOAD_CURRENT);
  var_dump($nodes);

Unfortunately, this code doesn't work for me.

How do I get the list of nodes of a specific content type and their titles?


texts: How can I cache the operations on the admin content overview per user?

texts:
The admin/content view page gets cached, but the operations column is different for the various users. When a user visits the page after the cache is cleared, their operations are correct. Another user, with the same role, may have different access to other nodes, but the result of the first user is shown => this leads to unwanted, in access denied resulting edit buttons.
I installed Views Custom Cache Tags and set the cache tag to user:[user:id], but it didnt work (looking at the module I'd guess it supports tokens).
How can I set that the output of admin/content is cached per user? I dont want to completely disable the cache for that view.


texts:
I'm trying to use data captured within my drupal database to drive some analytics in another tool.
I am trying to develop a view which gets the field data for a content type i've created.
The db model seems rather complicated, can anyone give me any tips on how to join the tables together to find fields for a given content type.

Cheers
A


texts:
Within hook_menu(), I added multiple (form/page)s.

function mymodule_hook(){
  $form[...]=aray(...);
  // ...
  return $form;
}

function other_hook_form(){
  $form[...] = aray(...);
  // ...
 return $form;
}

function mymodule_menu() {
  $items['section/form1'] = array(
    'title' => 'form1',
    'page callback' => 'mymodule_form',
     'access arguments' => array('arg1 arg2'),
     'type' => MENU_CALLBACK, );

  $items['section/form2'] = array(
    'title' => 'form2',
    'page callback' => 'other_hook_form',
     'access arguments' => array('arg1 arg2'),
     'type' => MENU_CALLBACK, );

  return $items;
}

With the first Item I don't have a problem because it calls mymodule_hook(), but the second one renders the markup without <form> tag. So no submit/validation hooks are fired.


texts:
I am having problems trying to control the layout and fields together in a grid style of a view.
On the internet I saw several tutorials about how to theme views, and they suggest using functions in template.php, or using view template files. I cannot find a tutorial that helps me.

Specifically, when I use a template file, I cannot control the disposition of fields (controlling the disposition of each field; controlling the fields altogether; adding conditionals; adding classes; trying to use "views-view--," "views-view-field--," "views-view-fields--," or "views-view-grid--"), and when I use a function in template.php, I cannot get the variables/values of fields.

I must say that I know how to include a custom design using the Views module interface, to control the design per fields (or controling all fields of each item, if I include the design and fields in the last field). But I want to do this using some external way to custom display in a centralized way (also to not allow to change the design from the web interface, and to have the control in a files, not in the database).

When I say a centralized way, I mean, using a file or files to control the disposition of each field, control fields together, add conditionals, add classes, add functions, (such as a theme in Drupal).

I am using Drupal 6 and Views 2.


texts: Why does all links of homepage redirects me to Xampp homepage ( Took backup from Godaddy )

texts:
I took backup of SQL from Godaddy and copied all the data from my Godaddy hosting account through FTP.
I imported the SQL in my machine's mysql ( no issues ).
I copied the files to my htdocs/subdir1/drupalDIR/ and made changes in settings.php ( updated mysql connection details ).
Homepage is showed in a perfectly fine way but whenever I click on any link, it takes me to Xampp Homepage.

Perhaps it's a htaccess issue.

What should be the Rewrite rule to make it okay ?


texts: How change Drupal Context with a button?

texts:
Context is great for delivering content to the right part of my site in the right circumstances, in the right order and to the right user.

I'd like to be able to add the ability for a user to toggle Context using a link I create - a button - to cause certain blocks to appear, disappear or be be re-arranged - via Context.

I have researched and experimented for hours and can't find a solution.

In what ways I can I change Context with the press of a button?


texts: Views - How to suppress ajax errors without leaving a log entry in browser

texts:
I have a views page that is continually updated using views_autorefresh.  My setup works fine except for the occasional error message:

AJAX Request terminated abnormally

This only happens if the user tries to navigate away from the page during an update.  Is there a way to suppress this message?  Because I know that this message will happen (repeatedly) I do not want for there to be a log entry of it.


texts:
how do i control: validateForm

public function validateForm(array &$form, FormStateInterface $form_state) {
  // form validation here
  // if validation success then proceed to submit
  // else dont submit and send notification to the respective field
}

i have done my fields validation inside that method, however, how do i control from there?

how to stop the submit process if the validation failed?
and
how to send notification/error message to the respective field?

Thank you,


texts: Migrating comments of recipe module from D6 to D7

texts: Hi I have a site which teaches how to cook different types of food and I use recipe module for listing the recipes of different foods. The site was first developed in Drupal6 and recently I have migrated the site to Drupal7. I used the options in recipe module to export all the recipes in my D6 site to import in Drupal7 and was success. Now I need to migrate all the comments made by the users for each recipe to D7. How can I do that?


texts:
I'm looking to display a weekly events calendar. I've set up content type event and added a starting day field. What I'm essentially looking for is this:

So the interface is a tabbed one, so as long as I can get the current week and its events grouped by date I should be fine, but I need to be able to pull future weeks via ajax in a manner the Calendar View does. So the question is this: can this be done with some Calendar View template? How can this be put together with views? I tried to modify the Calendar block provided as Views Template, but all I ended up was a monthly block.

Thank you in advance.


texts: output same form buttone on same page - drupal_render($form

texts:
I try to duplicate form button on the same page. The button is printed like this

drupal_render($form['continue_shopping']);

The problem is that once I render the button, the second one is not rendered again later in DOM. How to overcome this? Thank you


texts: Create a Json view of the user, with the format of the user/login response

texts:
I'm in Drupal 8.
After activating the module rest, and try and receive a response from the route /user/login?_format=json I get this:

{
    "current_user": {
        "uid": "4",
        "name": "cravushedal"
    },
    "csrf_token": "49TlM-VLnQcErR1W5vW7losJPLHXPpqE2UpLh9_bZzg",
    "logout_token": "fkBNWh8iLoTbXPO4Elha86PVe_0I8L1JKIxXQ2KemMo"
}

Now I want to craete a view with all the users, but something like this:

{
    "current_user": {
        "uid": "3",
        "name": "blablabla"
    }
}
{
    "current_user": {
        "uid": "4",
        "name": "cravushedal"
    }
}

In my rest view, I have the name, uid, and a Global custom text. The name and the uid are hidden, and I am calling both fields in the global custom text.
This is my result:

[{"current_user":"1josue"},{"current_user":"2slucuthivili"}]

It doesnt recognize the label, so I had try to include them manually, but the json add \n or \what ever and that destroy my json.

Any idea about how can I achieve this?? thanks!


texts: Organic Groups Vocabulary - Dynamically Load Terms

texts:
I've recently installed OG Vocabulary and have been kicking the tires for the last day or so. It'll do what I need it to do, that is, provide segregated group taxonomies. However, it seems to me that the workflow is less than ideal.

I have a content type named Event. It has 2 OG fields:

og_group_ref - Allows the user to associate content to a group

og_vocabulary - Contains select lists of vocabularies based on which groups the user belongs to, and whether those groups have referenced vocabularies.

When creating a new Event, if a user belongs to multiple groups with taxonomies on that node, the user is shown a og_vocabulary field for every group. This allows a user to associate the Event to "Group A", but select terms from "Group B".

After a new Event is created and associated to a group, if a user goes back to edit that group, only vocabularies related to the group they've associated to the node show up. If the user changes the group to which the content belongs, they must save that content then edit the content again in order for the correct og_vocabulary field to show up. I'd like to be able to skip having to go back in and edit the node after changing the referenced group.

Is it possible to dynamically load the correct og_vocabulary field based on the value of og_group_ref?

I've been mucking around with AJAX to accomplish this, but I'm wondering if there's a better way to accomplish this. It's possible that this functionality is built in and I'm missing something.

I'm using D7, by the way.

Thanks for any help!


texts: How to resolve my database connection error when using the Wordpress Migrate module?

texts:
I have a Drupal8 site and I've installed the Wordpress Migrate module and it's dependencies for migrating a Wordpress site to Drupal8.

When I start to import the exported XML file from Wordpress, I get this error:

The website encountered an unexpected error. Please try again later.

When I checked the error messages pages I found this:

  Drupal\Core\Database\ConnectionNotDefinedException: The specified database connection is not defined: migrate in Drupal\Core\Database\Database::openConnection() (line 361 of /media/mosama/Content/test_poc/drupal8_2/core/lib/Drupal/Core/Database/Database.php).

Any solution for this?


texts: Hide Fields in Edit Page based on Role and Content Type?

texts:
Use Case: Content Editor A (Role of Monday)  when edting a node (of Content Type Alpha) is able to use Field AA and Field BB.

But Content Editor B (Role of Tuesday), when editing the same node, does not see Field AA and Field BB.

I have experimented with many of the modules of this regard (Field Permissions, Conditional Fields, Rules), but nothing that can compute for  all four conditions (role, content type, edit, fields).


texts:
Background information: I'm trying to manipulate the available options of a list type text field, depending on the host bundle:

function wtbase_options_list_alter(array &$options, array $context) {
  $fieldDefinition = $context['fieldDefinition'];
  if ($fieldDefinition->getName() == 'field_aos_cell' && $fieldDefinition->bundle() != 'link') {
    foreach ($options as $key => $value) {
      if ($key == 'link-horizontally-opposing') {
        unset($options[$key]);
      }
    }
  }
}

The $fieldDefinition->bundle part is really confusing. There seems to be a variable  $fieldDefinition->bundle (containing the expected bundle name link) and a function $fieldDefinition->bundle() (containing field_config). But I can't access the variable bundle, because this crashed with Cannot access protected property Drupal\field\Entity\FieldConfig::$bundle.

After some digging I found FieldConfigBase::getTargetBundle(), which did return the expected result and did not crash (yet).

So this leads to two questions:

What is the difference between $bundle, bundle() and getTargetBundle() and which one I'm supposed to use? I'd prefer using variables, because they are visible in Xdebug, while functions are not.

And in a more general point of view, are there some guidelines when to use functions and when to use variables? In the same example as above Xdebug printed the same weird results for e.g. entity_type vs entityTypeId vs getEntityType() vs getEntityTypeId().

--

Update, clarification for question 1:

I know the technical difference between a member property and a member function. But I'm deeply confused that a property $bundle and a function bundle() of the exact same name are returning values from a completely different entities/context. In my example $fieldDefinition->bundle returns a Paragraph bundle name link, while $fieldDefinition->bundle() seems to return the bundle name from FieldConfig. I know this is technically possible... but why would anyone write code like this? I've not yet experienced this behavior anywhere else in Drupal core, usually $entity->bundle and $entity->bundle() return the same result.


texts: Interface translation - Body, Title built-in interface

texts:
I use i18n and I10n_client to translate English to Dutch in my web page, however some interface variables are not changing.

I searched 'Body' and try to replace it with its Dutch word, it doesnt take effect no matter what I do http://imageshack.us/photo/my-images/831/searchbody1.png/

and http://imageshack.us/photo/my-images/576/searchbody2.png

How can I change this type of built in interfaces. I cant change "Title" as well.


texts:
I  want to add news in my website . i want left sidebar and header as in image.

I dont know which module should i use for this.

Months are showing in tabs . I am using Bootstrap3 theme here


texts:
This is all programmatic: in a module.

I have a flag that I can set successfully, but I cannot unset/unflag. I do not know why, as the code seems so similar.

The flag is set in a _submit function of a form:

  // Enable the global user object
  global $user;

  //Flag the user as having MyExample credit
  // Invoke the Flag API to set the flagging. This also saves the flagging entity.
  $flag = flag_get_flag('MyExample_credited');
  $flag->flag('flag', $user->uid);

I can detect this flag successfully in other functions using this code:

if ($flag->is_flagged($user->uid)) {

However, unflagging is not working. Here is the code:

  // Enable the global user object
  global $user;

  $markup .= 'Removing credit...
';
  //Unflag whether the user has MyExample credit
  $flag = flag_get_flag('MyExample_credited');
  $markup .= 'Flag status:' . $flag->is_flagged($user->uid).'
';
  $flag->flag('unflag', $user->uid);
  $markup .= 'Flag status:' . $flag->is_flagged($user->uid).'
';

This produces the following output:

  Removing credit...

  Flag status:1

  Flag status:1

Testing the flag on other pages also confirms that it has not been unflagged.

Why could this be? Nothing in any of the error logs. Is it to do with how I have declared the flag, perhaps?

function MyExample_flag_default_flags() {
  $flags = array();
  $flags['MyExample_credited'] = array (
    'entity_type' => 'user',
    'title' => 'MyExample Credit',
    'global' => 1,
    'types' =>   array (),
    'flag_short' => 'Give credit',
    'flag_long' => 'Give this user a MyExample credit',
    'flag_message' => 'Credit given.',
    'unflag_short' => 'Remove credit',
    'unflag_long' => 'Remove a MyExample credit for this user',
    'unflag_message' => 'Credit removed.',
    'unflag_denied_text' => 'You cannot remove this credit.',
    'link_type' => 'toggle',
    'weight' => 0,
    'show_in_links' => array (
      'full' => 0,
      'heartbeat_user' => 0,
      'token' => 0,
    ),
    'show_as_field' => 0,
    'show_on_form' => 0,
    'access_author' => '',
    'show_contextual_link' => 0,
    'show_on_profile' => 0,
    'access_uid' => '',
    'module' => 'MyExample',
    'locked' => array (
      'global' => 'global',
      'status' => 'status',
    ),
    'status' => true,
    'api_version' => 3,
  );
  return $flags;
}


texts: Limit Taxonomy Term references to special vocabulary

texts:
I have a custom entity type with custom fields, one of them is  an entity_reference type ,
I saw this question How to create entity reference field from custom entity to specific content type , and according to it some references I googled , try the below code but it not works .

 $fields['book_cat'] = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Book Category'))
    ->setDescription(t('Book Category Name'))
    ->setSetting('target_type','taxonomy' )
    ->setSetting('handler','default' )
    ->setTranslatable(TRUE)
    ->setDisplayOptions('form', array(
        'type' => 'options_select',
        'weight' => -1,
        'handler_settings' => array(
            'target_bundles'=>['book_cat_agency'=>'book_cat_agency'],
            'size' => '60',
            'placeholder' => '',
        ),
    ))
    ->setDisplayConfigurable('form', TRUE)
    ->setDisplayConfigurable('view', TRUE);

But not working.

my vocab name is : book_cat_agency


texts: Show / Hide administration menu (module)

texts:
Is it possible to use a javascript function for a link in Drupal?
I would like to make an option to show/hide the administration menu when clicked on the Drupal icon.
Something simple like this:

  $links['icon'] = array(
    '#title' => theme('admin_menu_icon'),
    '#attributes' => array('class' => array('admin-menu-icon')),
    '#href' => 'javascript: alert("ok")',
    '#options' => array(
      'html' => TRUE,
    ),


texts: How to properly add multiple form elements in a loop?

texts:
I have a form where I need to loop through an array and display multiple form elements in a specific area.

Example:

$form_layout = 'Some html';
$form_layout .= '
';

foreach($something as $key => $value) {
    $form_layout .= 'some html';
    $form_layout .= 'some html';

    // I need this to be displayed in between the above and below code
    // in the layout
    $form['awesome_element'] => array(
        '#type' => 'textfield',
        '#size' => 5,
        '#value' => 0
    );

    $form_layout .= 'some html';
    $form_layout .= 'some html';
}

$form_layout .= '
';
$form_layout .= 'Some html';

$form['some-other-awesomeness'] = array(
    // ...
    '#prefix' => $form_layout,
);

Doing it like the example puts the textfields after all the other page elements. I have tried using #prefix and #suffix but that breaks the layout even worse.

Any ideas on what I should do?

Edit: For clarity...

If I had layout elements such as a div tag I need my form elements, such as textfields, to be inserted in between those div tags.

So I need it to output something like this:

FORM ELEMENT
FORM ELEMENT
FORM ELEMENT

Instead it is outputting something like this:

FORM ELEMENT
FORM ELEMENT
FORM ELEMENT

Hopefully that is more clear, sorry if the above is confusing. Looking at code for the last 20 hours.

Edit2: added some visual stuff to make it easier to understand


texts: Custom field: users organized into departments

texts:
I'm building an intranet corporate site, and need to have users linked to departments. The easy way I see this to be done is to create a taxonomy vocabulary with list of departments, and then add custom field to user entity, linking it with corresponding department from departments vocabulary.

Now I want to add a "Person responsible" field to a custom content type (let's name it "Document"), which should be a list of users, organized by departments.

In future a need to use this field to control access to the document may arise.

So, the questions are:

Is my method to link users to departments good enough, or are there better ways? (as this is now in development, I can change everything painlessly).
What is the best way to make "Person responsible" field (a list of users, organized by departments).
Does all this play well with possible future access control needs?


texts: Pre-Built Theme, how to transfer header to blocks

texts:
I am moving at a glacial pace at theming, even following guides, because I think I am having trouble understanding the relationship between all parts of drupal theming. If someone can help me with the following issue, it should make me better understand how I am to configure everything else

Basically, I want to know the ideal way to theme this header which is static html to transfer into a block or a region so that I can theme it. I initially just included it using php include statements, but realize this is not good practice in drupal, and am looking for  the proper way to do it.

             Login

                <form role="form">

Login Form

                            <input type="text" class="form-control" placeholder="Username">

                            <input type="password" class="form-control" placeholder="Password">

                                <input type="checkbox"> Remember me

                        <button type="submit" class="btn btn-ar btn-primary pull-right">Login</button>

                </form>

                <form role="form">

                        <input type="text" class="form-control" placeholder="Search...">

                            <button class="btn btn-ar btn-primary" type="button">Go!</button>

                </form>

Thanks for the help,

Matthew Beal


texts: Numeric value not working with Solr Polish site

texts:
Using the Drupal 7.39 and Solr 3.5(Search Api module) keywords search works fine on Solr with the filter "StempelPolishStemFilterFactory" for the polish language.

But when using a numeric string like "18001g", "18010" the search return multiple records i.e. when searched for "18001" it returns the two record one of "18001" and "18010" ideally it should return one record i.e. "18001".

Using the Solr admin analysis feature, I found that the after the filter "StempelPolishStemFilterFactory" is applied the search value i.e. "18001" or "18010" changes to "180ć".

But in case if the above mentioned stemming filter is removed it effect the polish keywords searched.

Just need to under stand why this value changes and how to avoid this value changed or is there anyorder the filter needs to be placed.  Below is the polish configuration setting.

    enter code here
<fieldType name="text_pl" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt" />
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.StopFilterFactory" words="stopwords_pl.txt" format="snowball" ignoreCase="true" enablePositionIncrements="true" />
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" splitOnCaseChange="1" splitOnNumerics="1"  catenateWords="1" catenateNumbers="1" catenateAll="0" protected="protwords.txt" preserveOriginal="1" />
<filter class="solr.StempelPolishStemFilterFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms_pl.txt" ignoreCase="true" expand="true" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.RemoveDuplicatesTokenFilterFactory" />
</analyzer>
<analyzer type="query">
<charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt" />
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.StopFilterFactory" words="stopwords_pl.txt" format="snowball" ignoreCase="true" enablePositionIncrements="true" />
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" splitOnCaseChange="1" splitOnNumerics="1" catenateWords="0" catenateNumbers="0" catenateAll="0" protected="protwords.txt" preserveOriginal="1" />
<filter class="solr.StempelPolishStemFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.RemoveDuplicatesTokenFilterFactory" />
</analyzer>
</fieldType>


texts:
When creating a new user account, as a visitor or unregistered user, I get the following message:

The website encountered an unexpected error. Please try again later.

and the account is not fully created.

The log (admin/reports/dblog) gives the following description of the error:

  PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'name': INSERT INTO {users} (uid, created,
  data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1,
  :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] =>
  150752 [:db_insert_placeholder_1] => 1422513054
  [:db_insert_placeholder_2] =>
  a:6:{s:7:"contact";i:1;s:20:"l10n_client_disabled";b:0;s:17:"mimemail_textonly";i:0;s:34:"user_relationships_ui_auto_approve";a:0:{}s:34:"user_relationship_mailer_send_mail";b:1;s:40:"user_relationships_allow_private_message";s:12:"on
  all users";} ) in drupal_write_record() (line 7239 of
  /home3/zacteyc1/public_html/includes/common.inc).

The referer is: user/register

However, if I am the super user (user/1) I can create a complete new user account with no error.

I have disabled all the modules I could (including core ones) one by one to find the culprit but even with all modules disabled, the error persists.

I have also uploaded a fresh copy of the core files, but to no avail.

I have then uploaded, one by one, backups of my database going as far back as September 2014. It is with the September 14, 2014 (and prior) that the error disappears.

I need to fix the current database otherwise I will have lots of angry users who will have lost all the pictures they uploaded, all they have written in blogs, messages, etc. since September!

Does anyone know how to do this (like comparing a "good" database with a "bad" one to isolate the error?)

Any and all suggestions to fix the current database is greatly appreciated!

Thanks. :)


texts: Custom entity generate process plugin gives error

texts:
I am creating a custom process plugin. Which is inherited from the EntityGenerate plugin. In my custom plugin I want to call the EntityLookup tranform function. So I tried to inject the entity_lookup plugin into my custom plugin.
    class CustomEntityGenerate extends EntityGenerate {
      /**
       * The database connection.
       *
       * @var \Drupal\Core\Database\Connection
       */
      protected $database;
      /**
       * An instance of the entity_lookup process plugin.
       *
       * @var \Drupal\migrate\Plugin\MigrateProcessInterface
       */
      protected $entityLookupPlugin;
      /**
       * {@inheritdoc}
       */
      public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition, MigrationInterface $migration = NULL) {
        $instance = parent::create($container, $configuration, $pluginId, $pluginDefinition, $migration);
    $instance->entityLookupPlugin = $instance->processPluginManager->createInstance('entity_lookup', $configuration, $migration);
    $instance->database = $container->get('database');
        return $instance;
      }

/**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrateExecutable, Row $row, $destinationProperty) {
    $this->row = $row;
    $this->migrateExecutable = $migrateExecutable;
    // Creates an entity if the lookup determines it doesn't exist.
    if (!($result = $this->entityLookupPlugin->transform($value, $migrateExecutable, $row, $destinationProperty))) {
      $result = $this->generateEntity($value);
    }
    return $result;
  }
}

But when I try to execute the import, I am getting this error.
The "" entity type does not exist.

here is my migration yml code
keywords:
    - plugin: sub_process
      source: keyword
      process:
        value: Name
    - plugin: custom_entity_generate
      value_key: name
      bundle_key: vid
      bundle: keyword
      entity_type: taxonomy_term
      ignore_case: true

when I use the entity_generate instead of custom_entity_generate then it works fine. What I am doing wrong here?
When I print $this->lookupEntityType in the entity_lookup's transform function. It prints the taxonomy_term . But when I print it in the entity_generate's generateEntity method, I am getting an empty string
Note: I am creating a custom process plugin, because I want to insert some data to the database if a terms does not exist and is created through the migration.


texts: how to bulk edit all users (change city field for example)

texts:
I need to run bulk operations on all the users. Like changing the value of a field for all users.

I am using Profile 2 module for extended profile fields.


texts: How to get nodes that do not belong to a particular user role

texts:
I am getting custom entity nodes using entity queries like below:

  $query= $this->entity_query->get('order_entity')
      ->condition('external_id', $data['external_id']);

  $order_nids2 = $query->execute();

I am trying to put a condition where I can get nodes which do not belong to a particular user role. How can achieve this?


texts: Getting Drush to play with MAMP and Acquia

texts:
I have a Mac workstation which is shared between two users, User°1 who first installed the machine, and User°2 who came along after, both administrators. User°2 has installed Drush using brew and Acquia Drupal and all this works very nicely. However, when User°1 tries to start Acquia Drupal he just gets an alert box saying that the Apache server failed to start - nothing shows up in the Apache error logs (the MySQL server starts ok though). I can't help thinking this is something to do with permissions, but no idea where to look.

So user n°2 has installed MAMP and that all works ok except for one thing: running Drush.
Here is an example:

imac:~ martinknapp$ drush @eco pm-info views_bulk_operations
Extension        :  views_bulk_operations
Project          :  views_bulk_operations
Type             :  module
Title            :  Views Bulk Operations
Description      :  Provides a way of selecting multiple rows and applying operations to them.
Version          :  7.x-3.1
Date             :  2012-12-03
Package          :  Views
Core             :  7.x
PHP              :  5.2.4
Status           :  enabled
Path             :  sites/all/modules/views_bulk_operations
Schema version   :  6002
Files            :  plugins/operation_types/base.class.php, views/views_bulk_operations_handler_field_operations.inc
Requires         :  entity, views
Required by      :  admin_views
Permissions      :  none
Configure        :  Aucun(e)

It appears to be running PHP5.2.4 (which I believe is almost certainly the reason I am constantly getting errors on db objects).
I've done everything I can to get this working, in particular by using the alias command like so:
alias drush='/Applications/MAMP/bin/php/php5.3.27/bin/php /usr/local/Cellar/drush/6.2.0/libexec/drush.php'
but all to no avail.

Any ideas?


texts: Passing a node variable into views filtering

texts:
I have content type called "season", which has a custom field. This field can have two options: Helloween and Christmas. Article content type contains the same field.

I want to create a View, which would sort articles by actualy selected field value of single "season" node. Is this possible in Drupal7?


texts: Make a view or panel that displays image *or* video field if present

texts:
My goal is to have a content type that will display an image in a certain panel pane or an embedded video, if the video is present.

I can imagine setting up two fields, one for the image and one for the video embed code. But I'm not sure how to hide the image if the video is present or to make the video field take precedence over the image field in panels.


texts: How to calculate user scores based on 3 variables to assign an appropriate text label?

texts:
I need to calculate a score for users in D7 based on 3 variables and then assign an appropriate text label and a CSS class.

So, using data from Voting API, time ago joined, and number of nodes published, it needs to select and display one of 15 text labels such as "Promising newcomer, reliable veteran, etc".

Given that I am a site builder with limited PHP skills, where should I start? Should I setup 15 different rules to set a value on a list field?

Before investing time in Computed Field, Display Suite Custom Field or Views PHP, I would love advice from the Drupal community.

Looking for something similar to SE badges.


texts: Display constraint error in the ajax modal window

texts:
From within a form, I have added a link which open a modal form in which I can edit a Paragraph.
Here is the code for this link:
$form['my_modal_edit_form'] = [
  'title' => $this->t('Edit'),
  'url' => $this->ensureDestination($url),
  'attributes' => [
    'class' => [
      'use-ajax',
    ],
    'data-dialog-type' => 'modal',
    'data-dialog-options' => Json::encode([
      'height' => '99%',
      'width' => '95%',
    ]),
  ]
];

This is working fine except when I have added a constraint on the Paragraph being edited:
When I wrongly encode this modal form to fire the constraint, the constraint error message will not be displayed in the modal form but in a "new" form which is not modal (I mean the same form but not modal).
This could lead to a data loose in the following scenario:
1-Change a field value of field AAA in the "original" form
2-Open the modal form to edit the paragraph
3-Wrongly encode it to fire the constraint
4-A new Paragraph Edit form is displayed (the modal is removed). This means that the "original" form is "replaced" thus we lost the encoding of the AAA field.
My question is: How can I make sure that the modal is not replaced by the "not modal" same form
when an error is displayed
Note: It looks like some constraints are working fine:
Working fine: A required "text" field will display some kind of popup near the missing value in the modal form
Not working: But a required "file" field will go into the problem. (A file field that you set as required in the Field UI)


texts:
How to fetch manual flate rate token on replacement pattern

I added Flate Rate cost manually on orders, but I don't find this token on REPLACEMENT PATTERNS. How to fetch this token for my invoice?

here screenshot that I did


texts: Creat a test user with no access permisions

texts:
On a site where only authenticated users have the permision to access content, I want to set up one test user that can log in but not access any content.

How would I achieve this?

This user will only be used to test different authentication methods. After logging in the user shoud get a "acces denied" result for all content.


texts: Use Drupal's Default Views Filter Handler on "Pseudo" Views field?

texts:
How do I use Drupal's core Views filter handler plugins on a custom views field?

I have a custom field which has its own FieldPluginBase Class. Does not have a DB query.

MYMODULE.views.inc:

/**
* Implements HOOK_views_data().
*/
$data['table']['date_field'] = [
  'title' => t('Date Field'),
  'field' => [
    'id' => 'date',
  ],
  'filter' => [
    'id' => 'date',
  ],
];
$data['table']['custom_field'] = [
  'title' => t('Custom Field'),
  'field' => [
    'id' => 'custom_field',
  ],
  'filter' => [
    'field' => 'date',
    'id' => 'boolean', // <--
  ],
];

How do I use this core views filter with a "pseudo field"?


texts:
I am trying to automate a notification integration between Drupal8 and Mailchimp.
I currently the Mailchimp module installed and a signup form has been configured so that people can signup for notifications and select which 'Group' they wish to be part off.
However, I am now trying to automate the notification process. So that the process will be like this:

An article created which has the 'Sports' and 'NFL' taxonomy selected,
The article is published,
Send notification to Mailchimp that a 'Sports' and 'NFL' article has been published,
Mailchimp will send a notification email to all users who are part of either the 'Sports' or 'NFL' groups in our mailing list. The notification email will include a link to the relevant article.

I have searched for a module for the above but haven't found anything. Is there an already built solution for the above? Or should I be writing a custom module and/or using the Rules module?


texts: How to create custom preview for content type in Drupal 7?

texts:
I am implementing a content type called "Product" which has some 8 to 10 fields.
While creating new product details under that content type "Product" client wants the custom preview of the content.

The default preview while adding content is really weird and it does not look good.

I have searched a lot on google but there is no any contributed module available for it.

So please tell the way other than custom module to implement it ?


texts: How do I install sandbox module 'Filedepot multiupload'?

texts:
I am new to Drupal and I am unable to install the sandbox module called Multiupload, it is an add-on module for Filedepot but there are no installation instructions that I can see. I am unsure where to put the files.

Steps I have taken so far:

Installed filedepot and it is working.
Installed plupload.
Overwritten filedepot-mainpage.tpl.php with the multiupload version.


texts: Different commerce payment paypal settings on dev and live sites

texts:
The problem is similar like here:
How to force rules configuration to load

I planned to use hook_default_rules_configuration_alter(), but after this:

  if (isset($configs['commerce_payment_paypal_ec'])) {
    foreach ($configs['commerce_payment_paypal_ec']->actions() as $action) {
      dsm($action);
    }
  }

I don't see any $settings['settings'] array:

How can I change the saved commerce_payment_paypal_ec rule's settings by code?


texts: How to customize the node info being shared on Facebook and other sites?

texts:
This article describes how to use hook_process_html() to customize the node info when you embed your page into Facebook or other sites.

Is this still the best way to go or are there other ways?


texts: Why is Pressflow not listed under Drupal.org's List of distributions?

texts: I'm curious why it isn't listed under distributions. Is it because they have made modifications to the drupal core?


texts: How can I override the autocomplete.js file while developing a module?

texts:
I want to override the default tags field wherever it is used. After looking through a few files, I figured that I should override drupal/misc/autocomplete.js and the Drupal.jsAC object.

Is it correct to override this file, since I only want to work with tags field?
How is it possible to create a module which overrides this file?


texts: Set default to empty result with views exposed filters

texts:
I am using Views (7.x-3.0-beta3) and I have created a exposed text filter to a view, which work fine.

The problem is the default result value: when the field is empty, is displaying all possible results. But I want to display the empty result by default. If you have a solution please shear it.


texts: how do i integrate an svg script with iframe on a webpage?

texts:
Bare with me I'm a n00b....

I'm working on a project and the person that has the drupal knowledge has backed out making me responsible for their part.

ISSUE:
I'm in the works of creating an intercative map uoft-medicine.eu.pn using snap svg, now I have to integrate it into their website using iFrame;

1) how do i go about iframing my svg script?

2) how to i implement it into their working prototype site?

the map wont be changing on demand, it will probably stay the same until the new school year.


texts:
Step One

I am wondering the best approach to add custom fields to the profile2 module. I saw how to get data from a custom field How do I reference (what is the syntax I have to use) to get the data of my Profile2 custom fields?. But I am not sure how  to add the fields. What hook do i need to use. I cannot find a particular page for using the profile2 module. Could someone post a code snippet. I have used the form API so I have knowledge of constructing particular entities which I think is what fields are called in Drupal 7.
I just though I could use the text field and integer fields that already exists and then insert these fields into the eCommerce table.

I can retrieve the field for firstname

function test_first_name()
   {

$uid =3;

   // calls the user_load functions
   $account = user_load($uid);
   // now pass the account the variable to the function profile2_load_by_user
   $profile = profile2_load_by_user($account);
   //var_dump( $profile); // drupal_render(field_view_field('profile2',
   $print_first_name =  drupal_render(field_view_field('profile2',
   $profile['main_profile'], 'field_first_name'));
   print $print_first_name;

}

I have just added the product_name into my members profile as well as a product_price .I want to update the ecommerce module with the relevent fields. Does anyone know a way to insert relevent fields into the commerce tables.

I discovered the API for profile2
http://drupalcontrib.org/api/drupal/contributions!profile2!profile2.api.php/7

 function mymodule_form_profile2_form_alter($form)
 {
 }

I am wondering if i can just use the Subscriptions and recurring payments an integrate it into profile2.


texts: In Commerce 2, how can we allow users with a role to bypass payment during checkout (bill me later)

texts:
We have a Commerce 2 site that we need to be able to assign users a role ('Bill Me Later') that will allow the user to select the payment option 'Bill Me Later' during checkout.

I have not found a module that provides this functionality. I started to dive into creating a custom payment processor but I'm not sure if this is the correct route to go. If the user were to select 'Bill Me Later' then no further information would be needed. The order would go through (completed) but now marked paid.

Could someone offer some insight into the best way to achieve this? We're open to building a custom payment gateway module if that is required but could use a little guidance as to get started since this technically is not a payment gateway.


texts: How do I use hook_entity_access() to let anonymous users upload private files?

texts:
I have same issue described in
How to skip the ReferenceAccess constraint on a file upload by an anonymous user?
So I need to use hook_entity_access() or hook_ENTITY_TYPE_access() to solve the issue.

What code should I use inside the hook?


texts:
I have a global module that has several .tpl files.

I would like to alter these files, but only have the alterations appear on one particular page (or Node Template).

I know I can duplicate the existing .tpl files and place them in my theme directory to overwrite the global .tpl files, but how would I go about creating .tpl files that only get picked up when a particular page is viewed?

Eg, something like:

/sites/mysite.com/themes/custom/mytheme/templates/gallery.tpl

and then, for the 'About us' page:

/sites/mysite.com/themes/custom/mytheme/templates/about-us-page-gallery.tpl


texts: How to find number of assigned content to all user

texts:
I have book content type, where i attached user entity reference fied.
In which i can select user to assign the books.

How can i find list of users and its number of assigned books.

Thanks


texts: Users rate and comment each other after an event?

texts:
I'm working on a project where users trade services (like AirBNB or Uber). I'm a bit stuck at the stage when the task is done and the two users have to rate each other. I have ratings sorted using Voting API and Fivestar but don't quite know how to handle Comments. They shouldn't be open all the time.

I've played around with user comments but it doesn't have Views field support. I then created a "Comments" content type and am trying to use that.

Any other ideas?


texts:
Lets say I have a music site that a user can add a youtube URL in a box and then the video will play.
Is it possible to have the background of that page change based on search parameters in the field.
So if a user puts in a Daft Punk video, could I have my site query a website with fan art and load the fan art as the background of that page?

EDIT:
To elaborate more.

Popular media players (PLEX and XBMC) will often "srape" websites for information about tvshows, movies, and artists. They pull the content (biography, rating, fanart, etc.) from the different sites (imdb etc.) and display them in the media player.

I want to extend this functionality to my site.

Now this is where it could get complicated.

My website has an emfield that allows users to paste the URL's of different videos from youtube, vimeo and others that will display one video then create a playlist of the pending videos in the list.

Fortunately the emfield can also pull the artist and song title of the video from youtube.
I want to use this information to then query a search on a website such as fanart.tv and pull an image or even corresponding artist information and display said information on my site as the corresponding song is playing.

In short:
1. URL is entered
2. Emfield displays video, artist, and song title
3. Somehow a search is performed on a website to locate that same artist and display fanart and other artist biography information
4. Listen and learn.


texts: Domain Access and websites for multiple countries

texts:
I currently have this url structure for nodes town.domain I would like to add country into that url to make it domain/country/town/type. My question is how do I achieve this on drupal 7?

practical example ureport.com/ke/mombasa/business


texts: Drupal 7.x Development - Naming conventions

texts:
Because of a recent project I need to dig into this drupal thing and try to fix a bug inside.

I am a drupal CMS beginner,and studying this CMS for several days, also going through the drupal module development website.

But I still have no clue about how to do proper development in Drupal, especially the function naming, database table naming, and relationship between .module, .info and so on.

e.g. hook_revision_publish become revisioning_revision_publish

My question:

How are names mapped and what is the sequence of functions that are called (the workflow?)

Hope that my question is clear and help someone to shorten the learning path of Drupal.

Thank you very much in advance for helping.


texts: How to get the specific field raw data in node.html.twig

texts:
I am using link field in a couple of content types, but when I am trying get url from node.html.twig with content.field_my_link_field and have tried some suggestions like content.field_my_link_field.uri, content.field_my_link_field.content|raw, content.field_my_link_field.content|striptags, content.field_my_link_field.0 but all return null.
Is there any possible solution to getting raw url from link field in (preferably) twig or any other way.

I am using Drupal 8.


texts: Is different checkout-flow per product possible?

texts:
I've tried finding a solution to this myself, but have so far been very unlucky in that regard.
To save you checking the tags, this question is about:

Drupal Commerce 8.x-2.0-beta6
Drupal 8.2.7

Question
I want different checkout flows on different products, and while I can find plenty of documentation on how to create these, I cannot find anywhere, how you tell the product which flow it should use.

I have tried searching, going to every commerce backend page on my install, searching through the questions here, and looked at commit messages in the hope that they would shed light on it.

Can anyone help me with this? I would greatly appreciate it.

Thanks in advance.


texts:
I am upgrading Drupal 6.26 to Drupal 7. I had a small handful of nodes (a dozen or so) that contained PHP code. After the upgrade, I've found that the <?php tags have been replaced with <!--?php.

I searched the Google but all I found was http://drupal.org/node/1403918. I'm not using the WYSIWYG module though. I am using CKeditor so I followed the advice in post 1 but that didn't resolve the problem.

I have the PHP filter module enabled.

When I try to edit the node, the <?php tags are not HTML comments so I can't fix it that way. How can I fix this?

Edit 1: I don't think CKeditor has anything to do with this actually. I've completed disabled the CKeditor module and I'm still getting issues mentioned above.

Edit 2: I have a script that resets it back to 6.26. When I re-upgraded, the PHP scripts execute before I enable any non-Core modules. I then enabled everything but CKeditor and it fails so I don't think its CKeditor but another module. I will attempt to further diagnose.


texts: Programmatically append values to entity reference field of node with a dynamic field name

texts:
I understand that I can append values to an entity reference field to a node normally with this method

$node->field_tags[] = [
    'target_id' => $my_id,
  ];

However I have a function like so

function addTag($node,$field,$id){
$node->set($field,[
    'target_id' => $id,
  ]);
}

In other words I have to anticipate any field the user supplies. Looking at the node class here

https://api.drupal.org/api/drupal/core!modules!node!src!Entity!Node.php/class/Node/8.2.x

I did discover the set function that lets me specify a field and a value but I don't believe that this would append to an array of entities in a field.

How would I append to an entity reference field to a node if the field name is supplied in a variable?


texts:
When I use drush to download modules, I get this weird error:

drush dl registry_rebuild
exec(): Unable to fork [wget --version 2>&1] exec.inc:150 [warning]
exec(): Unable to fork [curl --version 2>&1] exec.inc:150 [warning]
exec(): Unable to fork [which curl 2>&1] exec.inc:150 [warning]
wget nor curl executables found. [error]

which wget gives me /usr/bin/wget and which curl gives me /usr/bin/curl. /usr/bin/ is in my PATH. This seldom works if I do drush cc drush. How do I solve this permanently?


texts: Best approach for a minimal HTML5 theme for Drupal

texts:
Feel like I'm stuck between a rock and a hardplace, I've decide to post.

I'm looking for answers/opinions on getting going on custom Responsive Drupal v7 theme dev using ONLY HTML5/CSS/Less/Responsive with a primary focus on mobile then desktop with a view to it being a MINIMAL design set.
I'm not an IT newbie having been in IT since '86 and then earlydays webdev HTML usage since '97, but due to a health/career change I've recently had to 'upskill' again and hence back in IT and focused now purely on D7 by choice. A lot has changed since '97 and early HTML and now I'm wreaking my brains looking at the best approach to contemporary webdev trends (ie Less/HTML5/CSS/SCSS). I don't really want to use 'off the shelf' free D7 themes as I want to be able to theme myself again using the above. I most definately like the idea of HTML5 Boilerplate/360 and the mobile future.

Numerous hours researching online has left me confused (LOL) with all the available Responsive frameworks (CSS: 360 and up, 1140, inuit/Less etc etc).

So my query here is:

best approach starting grid for webdev on the above technologies at this entry level of learning. (I like building things so I'm keen as an all rounder, as I think I have way long mised the boat on becoming a 'themer' so my interests lay in 'lego' building in Drupal so to speak).
should I skip early CSS theory and go straight into Less/SCSS? (html5 will be easy to pick up on me thinks).
which single Responsive model should I pick to start out with then?

FYI, I'm now on a Linux Ubuntu 11.04 LAMP DEVBOX using a range of tools such as Aptana (and comfortable on a pure text editor) having moved over from M$ but I still have 3 other M$ comps due to other multi-media/pro-music interests.

I've been 'hacking' some D7 themes, but feel I can't see to 'wood for trees' when it comes to hacking to vast amount of data in the css files and feel I'm over whelmed in simply wants to create simple, minimal css so much taht it may be just easier starting from scratch.

Any advice to get me going immediately in the right direction would be most helpful.
Thanks in advance.
Paul, UK


texts: Programmatically add more 'paragraphs' in form alter ajax call

texts:
I have a content type called repair that has a multi paragraph field (field_products) called Products.

In the create new repair form I have an ajax button that fetches N number of products and returns the $form['field_products'] for re-render.

By default the form shows only 1 paragraph subform.

My question is how do I programmatically show N number of paragraph subforms based on the number of products fetched. The behavior I want is the equivalent of clicking the Add Product (add more) button N times.


texts: using sass to generate RTL & LTR css files in Omega 4

texts: is there any convenient way of using Omega 4 to compile rtl and ltr css files automatically. I mean something like this or this, but for drupal.


texts: WSOD "The provided host name is not valid for this server"

texts:
My Drupal 8 site only works with www. but without it I'm getting a WSOD with the "The provided host name is not valid for this server" error.

I've tried to implement the suggestions from this thread:
What does "The provided host name is not valid for this server" mean?

Specifically I tried:

$settings['trusted_host_patterns'] = array(
  '^www\.example\.com$',
  '^example\.com$'
);

$settings['trusted_host_patterns'] = [];

$settings['trusted_host_patterns'] = [ '.*' ];

Still, site will only work with www