texts: How do I handle exceptions in a service class?

texts:
I have implemented a Service which does stuff with a RESTful API:
services:
  api.clientname:
    class: Drupal\my_custom_module\Api\Clientname
    arguments: ['@http_client', '@messenger', '@logger.factory', '@uuid']

I'm injecting dependencies for ['@http_client', '@messenger', '@logger.factory', '@uuid']:

Guzzle HTTP Client
messenger service to call $this->messenger->addMessage(),
logger factory to call $this->loggerFactory->get('my_custom_module')->debug($message, $variables),
UUID service to generate UUID v4, per API specification.

I'm also using the StringTranslationTrait to get $this->t() working in my class.
All this is great so far. When it works, it works, and it logs success to the dblog. But it also needs to log failures. I'm having a problem with exception handling.
I'm trying to do something like this:
    while ($apiCallAttempts < API_CALL_LIMIT && $apiSuccess === FALSE) {
      $apiCallAttempts++;
      try {
        $accessToken = $this->obtainAccessToken($url, $postFields);
        $message = "Step 1: Access Token obtained from API endpoint";
        $this->loggerFactory->get('my_custom_module')->debug($message, []);
        $apiSuccess = TRUE;
      }
      catch (Exception $e) {
        // TODO: "watchdog_exception('my_custom_module', $e);".
        $variables = Error::decodeException($e);
        $this->loggerFactory->get('my_custom_module')->error('%type: @message in %function (line %line of %file).', $variables);
        if ($apiCallAttempts === API_CALL_LIMIT && $apiSuccess === FALSE) {
          // Set errorMessage for messenger service.
          $errorMessage = 'Error CLIENTNAME-01: Authentication API call failed';
          $message = 'Failed to sync %label with API. <br> @error after @limit attempts.';
          $variables = [
            '%label' => $form_id,
            '@error' => $errorMessage,
            '@limit' => strval($apiCallAttempts),
          ];
          $this->messenger->addMessage($errorMessage, 'error');
          $this->loggerFactory->get('dex_provider_hcp_forms')->error($message, $variables);
          return $accessToken;
        }
      }

but it doesn't work because:

Fatal error: Trait 'Drupal\my_custom_module\Api\Exception' not found in /app/docroot/modules/custom/my_custom_module/src/Api/Clientname.php on line 66

After some Googling, I am very confused about how to add the global PHP Exception to my Service class namespace.
Removing a use declaration inside the class removed the "Trait not found" error.
The new error message was:

Error: Class 'Drupal\my_custom_module\Api\Error' not found

EDIT:
Both of these things were happening for the same reason. I was using Exception and Error inside my class without prepending them with a backward slash, causing PHP to assume that Exception was in the same namespace as the one I declared for the file. Using \Exception and \Error instead resolved the issue.
The new error message is:

Error: Call to undefined method Error::decodeException()


texts: Is there any difference or advantages between use of libraries in theme or module level with using of "Libraries API" module instead?

texts:
Is there any difference between times that I define libraries in theme or module level with times that I use Libraries API module instead? Is it necessary to use library module and I add/attach my libraries to it?
What's real purpose and usage of the Libraries API module?


texts: How to change the existing images embedded in Views Twig template to S3 bucket URL

texts:
I have embedded the images using views twig template,

file_url(row['content']['#row']._entity.field_future_program_image.entity.fileuri) %}

The output is public://2018-07/10a_0_0.JPG

Instead, I need the image URL from the s3 bucket: https://s3.bucketname/2018-07/10a_0_0.JPG

Note: I have configured amazon s3 and moved the local files to s3


texts: How to add a permission : reorder Taxonomy terms

texts:
I need some roles to be able to edit and add terms of specific vocabularies, but not to reorder them. How can I add the permission reorder foo vocabulary terms, reorder bar vocabulary terms... with a module or programmatically ?
AFAIK edit terms permissions immediately give you the permissions to reorder terms also.
I already tried these modules below but none implements such permission.
Vocabulary Permissions Per Role

Allows adding to/editing terms of/removing terms from vocabularies per
role... adding terms to a vocabulary but not to another, reordering/editing terms of a vocabulary but not another's, etc.

Says so, but reordering /editing come together.
Taxonomy access fix

adds 1 permission per vocabulary: "add terms in X"
changes the way vocabulary specific permissions are handled
changes the Taxonomy admin pages' access checks
alters the vocabularies overview table to show only what you have access to edit or delete

The module does what native Taxonomy lacks: more specific Taxonomy
permissions (and checking them correctly).

Thank you.


texts:
Drupal 7

I have a vocabulary with hierarchical terms countries and cities.

I have a view with context filter=cityA ( parent country A)

How I can display into a block all cities from country A  ( siblings of cityA from vocabulary)?

Thanks


texts: Alter an image field using an image style rule

texts:
I have a Template file for a specific content type with several images, and to prevent the user from uploading more image sizes, I have an image style rule to crop out the image to 140x140 pixels.

My question is, what would the image style method call look like, to return the altered image back to the template, if provided the field reference from the node in either a $node->field_image or a $content[field_image] call in the template?


texts:
I created a module that displays a very simple form: name of organization, address and contact info. I've been able to add all components to the form with the exception of the address. I installed the latest addressfield module, which supposedly adds the ability to use a form item of type addressfield but it doesn't show up. I'm sure I am missing something. All I did was add the following code to my form:

$form['application']['address'] = array(
    '#type' => 'addressfield',
    '#title' => t('Address'),
    '#required' => TRUE,
    '#default_value' => array('country' => 'US'),
    '#description' => "Please enter your address.",
  );

What am I missing?


texts: Do contrib modules have to be set to expose settings variables to Strongarm?

texts:
I'd like to push everything into Features for the sake of versioning and migration of my site configuration.

Does a contrib module have to be purposefully set up to expose its configuration variables to Strongarm?


texts: The requested page could not be found error appear in page but page is render correctly-drupal 7

texts:
i had create one block in my custom module, which display in "CONTENT" region, only on "currant-trustees" page.

when i access url "localhost/drupal/currant-trustees" page is render correctly, but with error "The requested page "/drupal/currant-trustees" could not be found." and also page title is page not found.


texts: How to display multiple PDF files in a node

texts:
I want to display multiple pdf files in a single node. I am using PDF module to display pdf files with File Resumable Upload. But I need to display many files in a single node. I wasnt able to find any solution to this.
When I select multiple files to upload, all get uploaded successfully in the uploads directory, but only one gets displayed. When I go to 'Edit' tab on the same newly created node, all the pdf files are present in the designated section
, but only one is displayed on the node (even after saving again).


texts:
I was caching some goodies related to the menu, and putting it in the 'cache_menu' bin, assuming they would get cleared whenever someones edits the menu.

cache_set($cachekey, $mymenu, 'cache_menu', CACHE_TEMPORARY);

When I edit the menu, it isn't cleared. When is it cleared, then?

In what sense is it different from the cache bin?


texts: Moving field content to new field collection fields automatically

texts:
I'm working on existing site which has small boxes with an image, title & text in them multiple times on a page. Currently it uses fields for each one so there'll be six image fields, six title fields, etc but I'd like to making them all one field in a field collection which can be added multiple times.

Creating the new field collection an appropriate fields is fine but what is the best way of moving the existing multiple field images, titles, etc to the field collection?


texts: Programatically adding Taxonomy text field

texts:
This code is throwing a FieldException: Attempt to create a field of unknown type text. in field_create_field() (line 111 of C:\wamp\www\local.test\modules\field\field.crud.inc).

field_cache_clear();

//Create the appropriate field type
$field = array(
    'field_name' => 'stock_exchange',
    'type' => 'text',
    'module' => 'text',
    'active' => '1',
    'cardinality' => '1',
    'settings' => array(
        'max_length' => 64
    )
);
field_create_field($field);

$instance = array(
    'field_name' => 'stock_exchange',
    'entity_type' => __DEFAULT_VOCAB_MACHINE_NAME,
    'bundle' => __DEFAULT_VOCAB_MACHINE_NAME,
    'label' => 'stock_exchange',
    'description' => 'stock_exchange',
    'required' => false,
    'widget' => array(
        'type' => 'text_textfield'
    ),
);

At my wits end here trying to figure out why this won't work. Have tried clearing cache and it's not that.

For some reason it's not accepting a basic text field.

Any ideas?


texts:
I have installed the ocupload module and works very well at my localhost enviroment.

But the problem appears to me when i deployed to the testing enviroment  the upload failed ant the alert message says error 200 - 401.

I walked throw the installation steps well and give the permissions for files .

I know it isn't a module bug but i need help to fix it or catch where the error comes from (running nginx with authentication required by the web server).

thanks in advance


texts: How to display language switcher block as buttons, instead of simple links?

texts:
the language switch block looks like this:

I would like to display it as bootstrap buttons or whatever else is possible. At least not in plain links.

<button type="button" class="btn btn-primary">Primary</button>

Now in my D8 core, I found the PHP file for the language switcher, but I don't see where i can put my HTML code.

/**
 * Provides a 'Language switcher' block.
 *
 * @Block(
 *   id = "language_block",
 *   admin_label = @Translation("Language switcher"),
 *   category = @Translation("System"),
 *   deriver = "Drupal\language\Plugin\Derivative\LanguageBlock"
 * )
 */
class LanguageBlock extends BlockBase implements ContainerFactoryPluginInterface {

  /**
   * The language manager.
   *
   * @var \Drupal\Core\Language\LanguageManagerInterface
   */
  protected $languageManager;

  /**
   * The path matcher.
   *
   * @var \Drupal\Core\Path\PathMatcherInterface
   */
  protected $pathMatcher;

  /**
   * Constructs an LanguageBlock object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
   *   The language manager.
   * @param \Drupal\Core\Path\PathMatcherInterface $path_matcher
   *   The path matcher.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, LanguageManagerInterface $language_manager, PathMatcherInterface $path_matcher) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->languageManager = $language_manager;
    $this->pathMatcher = $path_matcher;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->get('language_manager'),
      $container->get('path.matcher')
    );
  }

  /**
   * {@inheritdoc}
   */
  protected function blockAccess(AccountInterface $account) {
    $access = $this->languageManager->isMultilingual() ? AccessResult::allowed() : AccessResult::forbidden();
    return $access->addCacheTags(['config:configurable_language_list']);
  }

  /**
   * {@inheritdoc}
   */
  public function build() {
    $build = array();
    $route_name = $this->pathMatcher->isFrontPage() ? '<front>' : '<current>';
    $type = $this->getDerivativeId();
    $links = $this->languageManager->getLanguageSwitchLinks($type, Url::fromRoute($route_name));

    if (isset($links->links)) {
      $build = array(
        '#theme' => 'links__language_block',
        '#links' => $links->links,
        '#attributes' => array(
          'class' => array(
            "language-switcher-{$links->method_id}",
          ),
        ),
        '#set_active_class' => TRUE,
      );
    }
    return $build;
  }

  /**
   * {@inheritdoc}
   *
   * @todo Make cacheable in https://www.drupal.org/node/2232375.
   */
  public function getCacheMaxAge() {
    return 0;
  }

}


texts:
How can I add current_timestamp or now for date feild in drupal database schema.

        'created' => array(
            'description' => t('Timestamp when the fee schedule was added.'),
            'type' => 'int',
            'not null' => TRUE,
            'unsigned' => TRUE,
        ),


texts: How to handle error at update.php "The "views_bulk_edit:node" plugin does not exist"?

texts:
I'm updating drupal but cannot install the following update:

These updates are mentioned...

system module
Change plugin IDs of actions.
Clear caches due to schema changes in core.entity.schema.yml.
views module
Update dependencies for moved bulk field plugin.
Add additional settings to the entity link field and convert node_path usage to entity_link.
Add placeholder settings to string or numeric filters.
Fix cache max age for table displays.
Include views data table provider in views dependencies.

And then the error at running updata.php is:

system-module
change_action_plugins bijwerken
Mislukt: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "views_bulk_edit:node" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (regel 52 van C:\www\inzicht5\core\lib\Drupal\Component\Plugin\Discovery\DiscoveryTrait.php).

Any idea how to proceed with this?


texts:
I get following two warnings:

  Due to the settings for ServerTokens in httpd.conf, it is impossible to accurately determine the version of Apache running on this server. The reported value is Apache, to run Drupal without mod_rewrite, a minimum version of 2.2.16 is needed.

  PHP OPcode caching can improve your site's performance considerably. It is highly recommended to have OPcache installed on your server.

It would be nice if someone could help me with some pointers about how to solve this problem.


texts: Why does the "drush status" command result in "Permission denied"?

texts:
I installed Drush via global Composer, and it seems that it should have installed correctly. However, when I executed drush status in terminal, it resulted in Permission denied. Why is this happening and how can I fix it?

More information:

which drush command outputted /Users/marcello/.composer/vendor/bin/drush.

Using echo $PATH on Drush outputted /Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/marcello/anaconda/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/marcello/.composer/vendor/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin

I can run Drush in vendor/drush/drush, but not globally.


texts: Saving a particular field of a related entities with Entity Reference

texts:
Using Drupal 7, using entity and entity reference i have created 2 entities: --*Aircraft reservation (date, user, aircraft categorie)
*Aircraft categories (name)

I have created a view (entity reference view) to list all aircraft categories.

Aircraft reservation reference aircraft categories.
In the form subbmission of Aircraft reservation i can see the list of the categories. The reference link with the view work great.

But when i submit the form, instead of having the categorie of the aircraft which i has selected saved, i have the details of the entity that present the categorie which i had selected.

With other words, Instead of saving the value of the field name of the categorie, drupal save the details of the entity.

How can i fix that ? Thanks for all !


texts: Multiple separate forms for searching up different apache solr indexes

texts: Mac_Weber in IRC gave me some great info in relation to this earlier, but I have a more indepth question: is it possible to have multiple separate forms for searching up different apache solr indexes? Say for example I had a separate indexes on rock stars, countries, and organic food suppliers. I want a drupal website that has literaly separate pages with a search box to search upon these indexes.


texts:
On my page http://www.athleticedgefitness.com/, I added a drop down menu under Contact. The hover color is yellow but for some reason, I cannot find that color style in my colors.css. What I found is that the devtools show that the background color change is caused
by a rule starting at line 44 in
http://www.athleticedgefitness.com/sites/default/files/color/corporateclean-659c1a2d/colors.css?mp37st
The rule is:

#header-menu ul.menu li ul.menu li a:hover,
#header-menu ul.menu li.expanded ul.menu li.expanded a:hover,
#header-menu ul.menu li.expanded ul.menu li.leaf a:hover,
#navigation .block-superfish ul.sf-menu li li:hover,
#navigation .block-superfish ul.sf-menu li li a:focus, #navigation
.block-superfish ul.sf-menu li li a:hover, #navigation .block-superfish
ul.sf-menu li li a:active  { background-color:#fbff24; }

But If I check in my colors.css, my rule actually looks like this:

#header-menu ul.menu li ul.menu li a:hover,
#header-menu ul.menu li.expanded ul.menu li.expanded a:hover,
#header-menu ul.menu li.expanded ul.menu li.leaf a:hover,
#navigation .block-superfish ul.sf-menu li li:hover,
#navigation .block-superfish ul.sf-menu li li a:focus, #navigation .block-superfish ul.sf-menu li li a:hover, #navigation .block-superfish ul.sf-menu li li a:active  { background-color:#1b1b1b; }

I have tried to clear the caches and everything but that didn't help either, any recommendations? This is in Drupal 7.x with the Corporateclean theme.

Thank you!


texts: How to solve AJAX problems with reverse proxy?

texts:
We have a server running AEGIR to manage our sites. The back-end server is setup to serve pages in HTTP. Our sites are published through a reverse proxy (Forefront) serving pages in HTTPS to the clients.

If a request is sent in HTTP, Forefront sends a 304 answer, with the correct location (i.e. in HTTPS). Forefront handles the rewriting of http URIs within HTML pages he delivers, so the clients only see HTTPS URIs.

Our problem arises with AJAX, namely the Taxonomy manager module. An AJAX request is sent to the server, and the response is provided in JSON. When looking at the JSON, there are references to the site's URL but with HTTP instead of HTTPS. So the browser sends a request to the server with HTTP instead of HTTPS, and is therefore redirected, but this redirection is rejected by the browser, and the call fails.

Does anybody know how to tell Drupal to always generate references to the site with HTTPS instead of HTTP?

Strangely, the problem is not exactly the same on different sites. In Aegir, I have two sites in the same platform: sites A and B.

For site A, when I look at the JSON answer for an AJAX call I see references http://siteA

For site B, I see in JSON answer references http://siteB:443, so for site B the right port (https) is used, but protocol is wrong

I suppose there is somewhere a place where I can tell the site how to make references to itself. Does anybody know where it is?

I looked in the settings.php of the sites, the global config, ... but didn't find anything relevant.

Any help would be appreciated.


texts: A General Strategy for Images with Captions in Content

texts:
This is a 'general direction' topic. I'm looking for some strategy and philosophical guidance, before marching over to the module development forum at Drupal.org.

I'm new to Drupal, and am very impressed by the architecture - the flexibility and power of the framework as a whole.

However, like many 'newcomers', I've quickly discovered that there's some planning and investment required in creating a new Drupal site (which is apparently the subject of many debates that are shaping the future of Drupal itself - http://www.lullabot.com/articles/understanding-8-where-drupal-and-where-...).

At the moment, for me at least, there's only one piece missing, and that's a non-Javascript method for allowing content creators (site owners) to insert one or more images with captions into the content of a node (like a news article, or blog post).

I also understand that in terms of semantic purity, it would be nice if the content of a node was clean and tidy, without a lot of additional markup - and so I'm looking for an eloquent way to solve the image/caption problem.

I poured over several other solutions - although as a new poster here I can only share two links in this post :(

and...

http://purewebmedia.biz/articles/2013-01-10/how-insert-and-float-inline-... - which is a great write-up describing the difference between using an Image field (with custom locations/folders for image stores), vs. Media Manager - although it doesn't address the caption problem.

I've also read a little about the new Entity model in DR7 - and I'm beginning to wonder of File Entities, with some kind of token replacement might be the right approach? (although I confess I don't entirely understand yet if a token can be placed into the free text/content field of a node - like the main text of an article or news story).

What I'm looking for is a method that will allow a user to insert one or more images into the content area of any content type (article, basic page, whatever - assuming the field/function has been defined for the content type), and that when they upload and insert that image, they are allowed to enter additional information like a title, copyright, caption, date etc.

They should be able to 'see' the image in their WYSIWYG editor (although maybe not the metadata), and then when the node is published, the required metadata is retrieved and inserted via a hook, pre-processor - for example, by surrounding the image in a div, and placing the required metadata above or below the image (perhaps in additional divs or elements) - requiring only CSS to style the title, caption, etc. as required.

I also really like Image Styles feature of Drupal and so I'm wondering how this could all be brought together.

To be clear, this is not a gallery module. The requirement here is to be able to insert one or more images with captions (and possibly other metadata fields) into a the content/body or a story, news article, blog post etc.; needing only CSS to style the result (format caption, float left or right etc.)

Thoughts?

Any pointers on how to start with this?


texts: I created a new content type with several fields in it. How would I print out those fields anywhere on the page that I need them like in the sidebar and other areas? What is the syntax for printing out a field? Also, I think I have to name a PHP file after the content type. What do I name it in Drupal 7?


texts: How can I pull the latest published revision for a referenced node using the CCK node reference field?

texts:
Right now if I reference a node in another node via a CCK node reference field, if I change the referenced node, which creates a new revision of that node, it shows the edits on the page that's referencing that node even though I haven't published the latest revision.

I'm looking for a way to patch the node reference field or CCK to join on the node_revision table so it will pull only the latest PUBLISHED version instead of the latest edit.

I have looked through both nodereference.module and content.module under CCK to try to find where the body is pulled in so I can edit the query.  I can't find that query.

Any help is GREATLY appreciated.


texts: How to print all Webform messages outside the form?

texts:
Does anybody knows how to print all messages (confirmations or error messages) outside the form (created using the Webform module, for example right after the body tag?

I've changed the markup of my alerts. I want them to be full screen, but I can't achieve this, when they're inside the form.


texts: Trying to use Panelizer for a node content type with a panels layout

texts:
I've got a zen theme, with a sub theme, with a plugins folder enabled in which I have a custom layout.
I've got panelizer enabled on a content type and I am trying to make that content type use my custom layout, however, when I select the layout for that content type it doesn't seem to use it. Usually devel_themer it looks like the page is still using node.tpl.php, I want to override the whole page with my custom layout.
Are their any things I should bear in mind using panelizer - stuff I need to disable  /enable.


texts:
when login and go to mysite.com/user, it have some custom block in sidebar first region, but I cant remove them in this region, why?
bookcome.module implement hook_block_view code:

    function bookcome_block_view($delta = '') {
    global $user;
    if ($delta === 'user-menu') {
    return array(
    'content' => _bookcome_user_menu()
    );
    } else if ($delta === 'user-menu-left') {
    return array(
    'content' => _bookcome_user_menu_left()
    );

and at mysite.com/admin/structure/block, the user-menu-left block status is disable, and I  am sure the current theme is using defualt theme, but the user-menu-left block alway in the sidebar first region of mysite.com/user page, would you tell me why?? how to remove them? thanks very much.


texts: How to add selective js on the page load?

texts: I have initialized four js files in .info file.Now on a single page if i want to load only two of .js files not all ,how can i do this?


texts:
I have the ajax property set on a form element.  Its like an autocomplete except it displays the results in a div.  It works great except the textfield gets greyed out by drupal during the ajax call.  I end up having to type one character at a time between ajax calls.  Is there a way to fix this?

Here's the code for my element:

$form['auto_complete'] = array(
  '#title' => 'Auto Complete',
  '#type' => 'textfield',
    '#ajax' => array(
      'callback' => 'k_test_ajax',
      'wrapper' => 'searchresults',
      'method' => 'html',
      'event' => 'keyup',
    ),
 );


texts: How can I give the permission to edit, update, or delete a comment or a user profile to specific roles?

texts:
I am using the ACL module for Drupal 7 to give the permission to edit, update, and delete nodes to specific users. It works perfectly.
I want the same feature for comments and user profiles.
Is there any specific module or API for the same?


texts: How do you retrieve the node IDs of the nodes using a a taxonomy term?

texts:
When you tag a content type with a taxonomy term, if you click on the term itself, Drupal will display a list of content tagged with that term. I have reviewed taxonomy_select_nodes(), but I wasn't able to get a working piece of code. I'm not sure this is the correct function to use when looking for the node IDs of the nodes tagged with a taxonomy term.

How do you retrieve the IDs of the nodes using a specific taxonomy term?


texts: How to override the system timezone in settings.php?

texts:
I'm trying to override the site's timezone in settings.local.php.
Looking at the config file, this should be simple:
$ more system.date.yml
country:
  default: ''
first_day: 0
timezone:
  default: UTC
  user:
    configurable: true
    warn: false
    default: 0

but I've trying various combinations of this and none of them work:
$config['system.date']['timezone']['default'] = 'Europe/London';
$config['system.date.timezone.default'] = 'Europe/London';


texts: When I use user_roles() when there are roles added by features, the feature roles are not returned. How can I get a list of all roles on my site included those defined in features?


texts: How to get addressfield geocoded on import with Feeds?

texts:
I am using Drupal 7.10 with the Feeds module 7.x-2.0-alpha4. The data I'm importing has address data that will be imported into my content type's address field, and the content type is also using the field implemented in the Geofield module, which holds coordinates and it is set to be populated from the address field when a node is saved.

However, when I import the data into nodes, the nodes are not geocoded; if I then edit the node, and save it, the node will be geocoded, and my map will display.

How can I get the Feeds module to trigger geocoding upon data import?

I just found an issue about this: Feeds + Addressfield Integration.

UPDATE

Found the issue about "Creating Your First Map Using OpenLayers, Geocoder, and Feeds" which references a patch. I tried this patch and re-imported my nodes. However they still were not geocoded.


texts: How do I use the Password Policy module?

texts:
I just installed and configured the Password Policy module, but the constraints like password length should be minimum 8 characters is not reflecting when an administrator user adds a new user and creates an one time login password.
The constraints/plugins provided in Drupal 8 by the Password Policy module aren't working in any scenario. Can anyone suggest the possible cause or the right way of using this module?
This module also doesn't modify the default recommendations on /admin/people/create.
Recommendations to make your password stronger:

Make it at least 12 characters
Add lowercase letters
Add uppercase letters
Add punctuation


texts: How to get the field template for view modes to work

texts:
Content type - article , view modes - teaser, vma, vmb. There are 3 views , 2 on the left sidebar called vma view mode and vmb view mode, the one on the right is called teaser view mode. All the views show unformatted list of content using view modes vma, vmb and teaser respectively.
How to check for view mode in twig template?


texts:
One of my sites has started to have a redirect loop that just happens on the homepage. Not the secondary pages though. (Drupal 7 - Commerce Kickstart)

Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.

Some days it does this, some days it doesn't. I feel like it magically fixes itself during the week and on the weekend it breaks. Is there any way to can find out where it is trying to redirect itself to and remedy it? Would the redirect location/error be logged somewhere I could check?


texts:
I have a content type consist a taxonomy field Market and many other fields used to show information about each market. I created a view to shows the data of each market in tabs on the front page of my site. There are many modules available for drupal 7 like quicktab etc. But I didn't find anything like that for Drupal 8.
I tried it using my code in views-view-fields--market.html.twig but it prints the market again and again with each result. And I want to show the market as a group filed for indexes of the Tab. And in the content of each index, I want to show all the information about the market.
Here is the code I have used for the template of Market Tabs.

        Gold

        Silver

        Ore

 Data of Gold Market

 Data of Silver Market

 Data of Ore Market

I am just looking to avail the tabs functionality Wheter views UI or Twig template.
You can see the example of my require solution here. in JavaScript behavior Tabs at the end of this page.
https://getbootstrap.com/docs/4.0/components/navs/


texts: How to get Tb Mega Menu working in Chrome?

texts:
I have a website and integrated Tb Mega Menu for the navigation. But the problem is my dropdown is not working in Google Chrome, though it is perfectly working in Internet Explore, Mozilla. My version of Google Chrome is 45.0.2454.85 m.
How to solve this issue? I did search for this, but found nothing suitable.


texts: How to get the url where an entity is flagged

texts:
How is it possible to get the URL of the content where the user was when s/he flagged an entity? I have content in a view in which I have the links to flag the entities so the URL where the entity is flagged is not the one of the entity itself as available in $account

I've tried this snippet to get the arg() of the page but as I thought, the arg() is related to the flagged entity.

function MYMODULE_flag($flag, $entity_id, $account, $flagging) {
  if ($entity_id->fid == FID && $flag == "flag"){
    dpm(arg());
    }
}


texts:
When doing SEO tests, we consistently seeing a message for cache headers on images. We were thinking of implementing but cannot find the appropriate way to test this as the x-cache still gives a MISS.

Below is the htaccess file we have to accommodate for adding cache header for images.

How can I test to see the performance gain if I did this?

# One month
<filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$">
  Header set Cache-Control "max-age=2628000, public"
</filesMatch>


texts:
Possible Duplicate:
  Drag & drop files into drupal site?

I need to implement drag and drop file upload functionality.  Does Drupal make this easy somehow?  Should I use a JS toolkit, like Dojo or Mootools?


texts: Conditionally aggregate (count) views field

texts:
I have a very simple view of content filtered by content type. Multiple content types are selected. For example, I am listing the latest contents of type Event, Forum topic, and Article. I am using Views Ticker display for this view.
Now I got a new request. Since there are so many articles being published (they are synced from an external publishers), the view should only show the amount of the articles, but it should still list other content types individually. An example output should look somewhat like that:

Forum topic: Lorem ipsum
Forum topic: Dolor amet
New 26 articles
Event: Meeting
Forum topic: XYZ

How can I aggregate only for one content type in views? Can I use some view hooks to achieve that? Like hook_views_pre_render(), etc?
Since I am using Views Ticker as display plugin, I cannot simply add them to footer or header.


texts:
I Integrated a Book reader tool Monoscle written in javascript to get the node.tpl content in the book reader format. I tested it on my php document and it was working great, i am able to get the content from the database in the monoscle tool.

However, im unable to do the same in Drupal i.e.,  i want the content of node.tpl in the TOOL!

I followed these steps to itegrate the tool.

I added JavaScripts and css in Bartic.info file under themes
Initiated some JavaScript in node.tpl [Because its not initiating/working when placed in Bartic.info]
Placed the rendered content inside the div in node.tpl, which is initiated by JavaScript

<?php print render($content); ?>

Now the thing is am getting the Monoscle framework but not the content - neither from $content nor any paragraph.


texts: How to use custom modal with ctools and triggered by a button form

texts:
I'm using ctools to render my node form.
And my quesiton is how to insert the custom style for the popup window.
I know how to use the custom style in the text button. but I don't know how to use it in the button form

the code for my button form

function hs_ajax_button_form($cmp_id=NULL)
{
    $form = array();
    $slogan_url='hs_ajax/nojs/slogan/'.$cmp_id;
    $form['url'] = array(
    '#type' => 'hidden',
    // The name of the class is the #id of $form['ajax_button'] with "-url"
    // suffix.
    '#attributes' => array('class' => array('hs-ajax-button-url')),
    '#value' => url($slogan_url),
    );

    $form['ajax_button'] = array(
    '#type' => 'button',
    '#value' => t('New Post'),
    '#attributes' => array('class' => array('ctools-use-modal')),
    '#id' => 'hs-ajax-button',
    );

  return $form;
}

and my trigger code is below

 $button_form=hs_ajax_button_form($campaign_id);

                    $form['PlayerAttendInformation'][$key]['ctools']=array(
                    '#type'=>'markup',
                    '#markup'=>drupal_render($button_form),
                    );

my style is as below

    $sample_style = array(
        'slogan-style' => array(
          'modalSize' => array(
            'type' => 'fixed',
            'width' => 800,
            'height' =>700,
            'addWidth' => 20,
            'addHeight' => 15,
          ),
          'modalOptions' => array(
            'opacity' => .5,
            'background-color' => '#000',
          ),
          'animation' => 'fadeIn',
          'modalTheme' => 'CToolsSampleModal',
          'throbber' => theme('image', array('path' => ctools_image_path('ajax-loader.gif', 'hs_ajax'), 'alt' => t('Loading...'), 'title' => t('Loading'))),
        ),
        );

how can i do that?


texts: Add a div at end of the form so that i can display data over there

texts:
This is my code..

function mymodule_menu()
{
$items = array();

  $items['mymodules/page'] = array(
    'title' => t('my module settings'),
    'description' => t('change values here'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('mymodule_page'),
    'access arguments' => array('access administration pages'),
    'type' => MENU_NORMAL_ITEM,
   );
  return $items;
}

function mymodule_page()
{
$form = array();

$brandarray = array('nokia','siemes');
 $form['mymodule_brand'] = array(
    '#type' => 'select',
    '#title' => t('Brand'),
    '#default_value' => variable_get('mymodule_brand', 'nokia'),
    '#options' => $brandarray,
    '#description' => t('Change this.'),
  );
 $form['div_tag'] = array('#type' => 'markup', '#value' => '
content comes here
');
 return system_settings_form($form);

}

I just want to do like this. After the form is displayed i just want to add a div so that i can use it for my dynamic data which comes after select is changed. How do i do it?


texts:
I have a view that display members for a group. The path for this view is set as node/%/members. When I go to group page, the menu works fine:

I can't find anyway to change these links.


texts:
In my menu, I want to add some text under the menu item.  For example, I have 'About Us', and right under that, I want some subtext 'About our company'.

Do I add this in region.tpl.php?


texts: The differences between date time zone handling

texts:
There are several options for time zone handling, Site's time zone, Date's time, User's time zone, UTC and no time zone conversion. What are the differences between them?

One case would be a television broadcast where everybody in the world would experience simultaneously. Would User's time zone be correct to use? If the broadcaster put 8:00pm while living in New York someone in California would experience this at 5:00pm.

Or, the case, a poetry slam is happening in New York City and anybody who wants to experience it will have to physically be there at 8:00pm meaning it might be happening at 5:00pm in California but that doesn't matter to the person in California. What matters is that they are at the place at 8:00pm in New York so the time shouldn't change no matter where the user is or what time in their timezone the poetry slam is going on.


texts: Is jQuery .once() needed if we filter by context?

texts:
When implementing a Drupal behavior, a selector can use the 'context' parameter to let the behavior only apply to new elements. On page load the context is the document (I think), on ajax load it is the new ajax content.

Drupal.behaviors.my_behavior = {
  attach: function attach(context, settings) {
    $('.my-selector', context).each(function() {..});

Until now I thought that this alone is sufficient to make sure the behavior runs only once per element.

But in Drupal core and contrib, I see a lot of cases where context is used in combination with .once(), like so:

Drupal.behaviors.my_behavior = {
  attach: function attach(context, settings) {
    $('.my-selector', context).once(function() {..});

Is this ever necessary? Or is 'context' sufficient? And if it is not necessary, why is it used so much in core and contrib?

If it is necessary, does this also apply to click handlers? E.g. would the following cause duplicated click handlers in some cases?

Drupal.behaviors.my_behavior = {
  attach: function attach(context, settings) {
    $('.my-selector', context).click(function() {..});

NOTE: A secondary question would be if 'context' is still necessary if we use 'once()'. My answer to this is: Even if it is not necessary, it is still a good idea because it reduces the search space for jQuery on subsequent calls, thus reducing client-side energy consumption.

NOTE: I encountered this question on D7, but it might equally apply to D8.


texts: When using the Batch API should I create an operation per node?

texts:
I am using the Batch API in Drupal 7 and I just realized that the reason why my count and totals are not showing correctly is because the initial total is based on a count of the operations given to it.

The thing is I set it up so that each operation processes 100 nodes. I have to update information in nodes that meet certain criteria and there are almost 7,000 nodes that have to be updated. So I thought it would be more efficient to fix multiple nodes per operation call.

Instead it seems like I should put in an operation per node or an operation per 100 nodes (even though my current setup seems to keep calling the same operation with no problems). So what should it be? I guess I could use the context variable to force it to count properly, but I don't like hacking around issues if I don't have to.

Below is the code I am using:

/**
 * Load the nodes with the broken language bodies and fix them.
 */
function my_fixes_broken_bodies() {
  $brokenBodyCnt = my_fixes_count_broken_bodies();
  $operations = array();
  $limit = 100;
  $count = ceil($brokenBodyCnt / $limit);

  // Give helpful information about how many nodes are being operated on.
  drupal_set_message(t('There are @brokenBodyCnt nodes to fix. And we are fixing @limit nodes per call. So the operation will require @count HTTP requests.', array('@brokenBodyCnt' => $brokenBodyCnt, '@limit' => $limit, '@count' => $count)));

  //Setup the operations for the fixes
  $operations[] = array('my_fixes_broken_bodies_op', array('broken body fix'));

  $batch = array(
    'operations' => $operations,
    'finished' => 'my_fixes_finished',
    'title' => t('Fixing broken node body language settings.'),
    'init_message' => t('The broken body fix is starting...'),
    'progress_message' => t('Processed @current out of @total.'),
    'error_message' => t('The broken body fix has encountered an error.'),
  );

  return $batch;
}

/**
 * Batch operation for fixing the broken bodies.
 */
function my_fixes_broken_bodies_op($operation_details, &$context) {
  if (empty($context['sandbox'])) {
    $context['sandbox'] = array();
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['current_node'] = 0;

    // Save node count for the termination message.
    $context['sandbox']['max'] = my_fixes_count_broken_bodies();
  }

  // Process nodes by groups of 100
  $limit = 100;

  // Retrieve the next group of nids.
  $result = db_query("SELECT n.nid, FROM_UNIXTIME(n.created) AS created, n.title, n.type, n.language AS 'Node Language', b.language AS 'Body Language'
  FROM node n INNER JOIN field_data_body b ON nid = entity_id
  WHERE n.language != b.language AND status = 1
  ORDER BY nid ASC LIMIT $limit");
  $results = $result->fetchAll();

  foreach ($results as $row) {
    $node = node_load($row->nid);

    if (isset($node->body['en']) && !isset($node->body[$node->language])) {
      $node->body[$node->language] = $node->body['en'];
      $node->body['en'] = NULL;
      node_save($node);
    }

    $context['results'][] = $node->nid . ' : ' . check_plain($node->title) . ' ' . $operation_details;

    // Update our progress information.
    $context['sandbox']['progress']++;
    $context['sandbox']['current_node'] = $node->nid;
    $context['message'] = check_plain($node->title);
  }

  // Inform the batch engine that we are not finished,
  // and provide an estimation of the completion level we reached.
  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
    $context['finished'] = ($context['sandbox']['progress'] >= $context['sandbox']['max']);
  }

  _my_fixes_update_http_requests();
}


texts: Select content based on logged-in user ID and drop-down selected users

texts:
I try to make a relation between two reference fields inside one node. For example, this node (type: groups) I've created:
Example (node) 1:

Group 1 has two users and one course
-- Reference field: Users
--- User 1
--- User 2
-- Reference field: Courses
--- Information technology

Example (node) 2:

Group 2 has one user and one course
-- Reference field: Users
--- User 2
-- Reference field: Courses
--- Psychology

Currently I'm using views for it. My goal is, if a user is logged in, all courses are showing up which is associated with his group.
Group 1: User 1 and User 2 should both see the course: Information Technology.
Group 2: User 2 should also see: Psychology.
I'm not sure if this is possible with views and if my current structure is right?


texts:
I'm embarrassed but I can't find the gmap macro builder anymore. I looked under

config->content-authoring->location and all its tabs
as well as configuration->web services-> GMap and all its tabs
and configuration->web services->GMap location and everything under that.

I also made sure that GMAp macro builder module is enabled

The following modules are also enabled:

Gmap 7.x-1.x dev
Gmap location 7.x-1.x dev
Gmap macro builder 7.x-1.x dev
Gmap taxonomy markers 7.x-1.x dev
Location 7.x - 4x dev
Location add another  7.x - 4x dev
Location Search 7.x -4.x ev
Node locations


texts:
I've one date field which is dependent on another field if it is checked then only date field will display and will be compulsory. Issue is that if I give value once on date field and saved that page, then I'll edit again same node and uncheck that dependent field value then it will be hide from page but the previous value of that date field is not removed from database. If anyone have an solution to remove this value on remove dependency then let me know.

Thanks in advance.


texts: How to permit users to add more items to a multivalue field conditionally?

texts: I'm working on a publication management site and need a multivalue field collection (which contains several file upload fields). Our authors can upload multiple versions of their publication but only after reviewers (or managers) allow it. Basically I would like to hide the "add another item" button and show if certain conditions are met.


texts: Drupal module development - How to build admin items list?

texts:
I'm creating a Drupal module and I would like to know how to build the admin panel table with the list of each items that I've been created with the module.

What is the hook to use ? and/or the API function... ? I did not found it.

All the tutorials that I read on the web explain how to create a form for submitting content but no one explain how to create the list of the content that have been submitted with the form.

You can see in the joined picture two examples of that I want to do.


texts: Writing Drupal 7 queries using drupals DB abstract. (Similar to an entity wrapper)

texts:
Drupal (7) uses an abstact for handling DB-s.

I'd like to write dynamic queries where i can use drupals abstract.

There's entity wrapper for entities and I'm
Looking for something similar to DB-s.

Is there anything like that?


texts: Programmatically rearrange blocks in region and save in database?

texts:
Need to react on site events and regroup blocks in front.

I have my region 'Top' in front, configuration is like this:

Block2: India News

Block1: World News

Block3: Frontpage content

When new nodes added my code must place block2 higher then block1. But I need to save new configuration in database, so hook_block_info_alter() does not help.

Please, which hook allows to save in db new blocks configuration in my region using cron?


texts: Change Dynamic Entity Reference field widget

texts: I am using Drupal 8. I have used the Dynamic entity reference module. Added DER field. I need to change this field widget from autocomplete to a select list. For this, I have used hook__field_widget_form_alter(). But have not succeeded. Is there any way to solve this problem? Thanks.


texts:
I need to restrict a View-generated page to authorized users only. (D7.9, Views 3)

I generally want to hide the Drupal's built-in user login block, but have the login form appear when a guest tries to access that page. I have been messing around with Fancy Login (which is supposed to appear whenever there is a need to authenticate), and also with roles and permissions, esp. with "Views: Bypass views access control". Somehow I cannot get the desired result - the page is either fully accessible, or an Access denied page comes up.

Anyone been through a similar challenge?

Artur


texts: How to programmatically create a add to cart form with quantity input?

texts:
I want to programmatically create an add to cart form with quantity input and default as 1. I tried to use the code:

$form_id= commerce_cart_add_to_cart_form_id(array($product_id));
$product = commerce_product_load($product_id);
$line_item = commerce_product_line_item_new($product, 1);
$line_item->data['context']['product_ids'] = array($product_id);
$form = drupal_get_form($form_id, $line_item);

But it just get a hidden field quantity with value 1 and I cannot change the quantity value. How can I get a quantity input instead of the static value?


texts: How to refresh all views in Panels with a time interval without page refresh?

texts:
I have some views that I want to refresh in a time interval (15sec) OR if there is changes in the content. For that I tried to use module "Views Auto Refresh". It works fine for a time interval but only if I have one view in a page.

If I have multiple views inside a panel (using Panels module), only one of the views is refreshed.

Is there any other way (module or custom code) to achieve this behaviour?

Thanks!

EDIT: As suggested, I tracked the ajax requests. In my case I'm refreshing every 15seconds. In a panel with 2 views I notice that I have only one request every 15sec, should I have two?!?!? Anyway, below is the piece of code I get when clicking in the function in red in the picture (I think is this one). The debug highlights the following line:

$(anchor).trigger('click');

Drupal.views_autorefresh.timer = function(view_name, anchor, target) {
  Drupal.settings.views_autorefresh[view_name].timer = setTimeout(function() {
    clearTimeout(Drupal.settings.views_autorefresh[view_name].timer);

    // Turn off "new" items class.
    $('.views-autorefresh-new', target).removeClass('views-autorefresh-new');

    // Handle ping path.
    var ping_base_path;
    if (Drupal.settings.views_autorefresh[view_name].ping) {
      ping_base_path = Drupal.settings.views_autorefresh[view_name].ping.ping_base_path;
    }

    // Handle secondary view for incremental refresh.
    // http://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-clone-a-javascript-object
    var viewData = Drupal.settings.views_autorefresh[view_name].ajax.submit;
    var viewArgs = Drupal.settings.views_autorefresh[view_name].view_args;
    if (Drupal.settings.views_autorefresh[view_name].incremental) {
      if (!viewData.original_view_data) viewData.original_view_data = $.extend(true, {}, viewData);
      viewData.view_args = viewArgs + (viewArgs.length ? '/' : '') + Drupal.settings.views_autorefresh[view_name].timestamp;
      viewData.view_base_path = Drupal.settings.views_autorefresh[view_name].incremental.view_base_path;
      viewData.view_display_id = Drupal.settings.views_autorefresh[view_name].incremental.view_display_id;
      viewData.view_name = Drupal.settings.views_autorefresh[view_name].incremental.view_name;
    }
    viewData.autorefreshRequest = 'autorefreshRequest';
    Drupal.settings.views_autorefresh[view_name].ajax.submit = viewData;

    // If there's a ping URL, hit it first.
    if (ping_base_path) {
      var pingData = { 'timestamp': Drupal.settings.views_autorefresh[view_name].timestamp };
      $.extend(pingData, Drupal.settings.views_autorefresh[view_name].ping.ping_args);
      $.ajax({
        url: Drupal.settings.basePath + ping_base_path,
        data: pingData,
        success: function(response) {
          if (response.pong && parseInt(response.pong) > 0) {
            $(target).trigger('autorefresh_ping', parseInt(response.pong));
            $(anchor).trigger('click');
          }
          else {
            Drupal.views_autorefresh.timer(view_name, anchor, target);
          }
        },
        error: function(xhr) {},
        dataType: 'json',
      });
    }
    else {
      $(anchor).trigger('click');
    }
  }, Drupal.settings.views_autorefresh[view_name].interval);
}


texts: How to COMPLETELY limit access to Views pages?

texts:
I've got a content type that has attached to each of its nodes a calendar (e.g., node/123/calendar); this is generated by fullcalendar via Views.  I'm setting up node access rules on that page so that some users can see the calendar and some can't.  The node access is handled through the "Access:" field in Page Settings for the view, in what I think is the usual way (I'll admit to being something of a Views newbie).

This works, but (to my eyes) only sort of.  If a restricted user tries to get to the page, they get the same page structure, generated by a page--node--calendar.tpl file, that they'd get if they were allowed to see the page, except that the content is the "You are not authorized to access this page" message.  Thus the user is able to get some information about this restricted item, like the fact that there is a node that has a calendar attached to it.  I'd prefer to have a more empty 403 or 404 error page come back, without the node-related wrappings.

Is there any way to do this?  I suppose my page template could check the content it's about to display and see if it matches the access denied message, but that's a little more hackish than I'd like to get...


texts:
I am trying to create a new node with POST through REST in D8. I have enabled the relevant modules (hal, serialization, http basic authentication, Rest web services, rest ui) and added the required permissions to users (create content). I configured the services with restui and added basic_auth for authentication and allowed post on my endpoints. I send X-CSRF-Token together with Content-Type json (or jal+json as configured) and I get either a login popup (basic auth style with user/pass) in restlet client and a 401 Unauthorized with this response.

  { "message": "No authentication credentials provided." }

I even tried using cURL from command line to create my node, with the same result and a GuzzleHttp Exception.

  PHP Fatal error:  Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: POST http://www.xxxxxx.com/loyalty/node/?_format=json resulted in a 401 Unauthorized response:
  {"message":"No authentication credentials provided."}
  ' in /home/xxxxx/public_html/loyalty/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113

If I allow anonymous to create articles and disable basic_auth everything works fine.

Any clues?


texts: Drupal commerce get All product variation for list of product

texts:
I have a color variation for my products...
Not every product does have multiple colors.

I would like to let the user know that one item comes in multiple color (or even show every color available), in the product-category view...

If I add the color field in the "node: product list" in the manage display of the product, it only gives me the color of the first added color variation.

How can it be done ?


texts: Show terms in view filtered from another view

texts:
I have two views, first one is block, second one is page. I have vocabulary, let's call it "food".
In the food vocabulary we have that hierarchy:

Fruit

Apple
Banana

Meat

Chicken
Pork

Both views goal is to show taxonomy terms, but first one shows ONLY parent terms, then we click on parent Fruit, we get second view, which shows ONLY terms from Fruit, so Apple and Banana. If we clicked on Meat term, we get terms Chicken and Pork. My question is how to do it?


texts: Display a Commerce Option Set select list in views?

texts:
I have a Commerce product type that references an option set which I would like to display in views using referenced product... I have no problem displaying any other field data from the node, but the select list is simply elusive. Is it just not possible to render a select list in views?

I've googled around for like for hours... Sorry if this an obvious answer for everyone, I'm just stumped to the max!!


texts: Override html.tpl.php by content/node type

texts:
I'm trying to build a new template for PPC landing pages. The template design is very different than the main template, therefore I'm trying to override html.tlp.php for a specific content type.

The content type machine name is "landing_page".

I've created the following:

html--landing_page.tpl.php (everything in the header and footer)
page--landing_page.tpl.php (everything in the content area)

I got Drupal to read page--landing_page.tpl.php, but can't get it to read html--landing_page.tpl.php instead of the default html.tpl.php.

I've already tried the code at Override html.tpl.php per node type, but it doesn't work even after clearing the cache multiple times.

Here's what my preprocess_html function in template.php looks like:

  function bartik_preprocess_html(&$variables) {

  $node = menu_get_object();

  if ($node && $node->nid) {
    $vars['theme_hook_suggestions'][] = 'html__' . $node->type;
  }

 /* if ($vars['node']->type == 'landing_page'){
     $vars['theme_hook_suggestions'][] = 'html__landing_page';
  }
*/

  if (!empty($variables['page']['promo'])) {
    $variables['classes_array'][] = 'promo';
  }

  if (!empty($variables['page']['triptych_first'])
    || !empty($variables['page']['triptych_middle'])
    || !empty($variables['page']['triptych_last'])) {
    $variables['classes_array'][] = 'triptych';
  }

  if (!empty($variables['page']['footer_firstcolumn'])
    || !empty($variables['page']['footer_secondcolumn'])
    || !empty($variables['page']['footer_thirdcolumn'])
    || !empty($variables['page']['footer_fourthcolumn'])
    || !empty($variables['page']['footer_fivecolumn'])
    ) {
    $variables['classes_array'][] = 'footer-columns';
  }

  drupal_add_js(path_to_theme().'/js/jquery.actual.js');
  drupal_add_js(path_to_theme().'/js/custom.js');

  // Add conditional stylesheets for IE
  drupal_add_css(path_to_theme() . '/css/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
  drupal_add_css(path_to_theme() . '/css/ie6.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 6', '!IE' => FALSE), 'preprocess' => FALSE));
}


texts: Menu Block disappear when changed the access control permission

texts:
I have "Menu Block" and "Content Access" modules installed. The menu button of that page disappear when I set that page not to view by "anonymous user". How can I show the Menu Block to everyone but not the page content?

PS: I don't wanna create another menu block

Thanks!


texts: How to insert a image gallery into node body?

texts:
I created a gallery using fields (gallery formatter and lightbox) but i can only add the gallery before or after the field body.

I tried the insert module but it can only add one picture and not the whole gallery.

Is there a way to insert the gallery into the field body at a specific location?


texts: Is the Workflow module a Symfony component?

texts:
In Drupal 8.5, is the Workflow module a component from Symfony?

I ask because I thought it might help me to learn the basics from the Symfony Workflow component, but looking at the core directory and the composer.json file I saw this.

"symfony/class-loader": "~3.4.0",
"symfony/console": "~3.4.0",
"symfony/dependency-injection": "~3.4.0",
"symfony/event-dispatcher": "~3.4.0",
"symfony/http-foundation": "~3.4.14",
"symfony/http-kernel": "~3.4.14",
"symfony/routing": "~3.4.0",
"symfony/serializer": "~3.4.0",
"symfony/translation": "~3.4.0",
"symfony/validator": "~3.4.0",
"symfony/process": "~3.4.0",
"symfony/polyfill-iconv": "^1.0",
"symfony/yaml": "~3.4.5",

In the replace section, I noticed the following line.

"drupal/workflows": "self.version",


texts: How to add delete link to recent comments block?

texts: I'd like to add a delete link to the 'recent comments' block on my dashboard. How can I do that? Is it possible to edit the view aswell?


texts: How to assign permissions based on user points?

texts:
I am building a site where users are given permissions similar to SO. I am working with two models.

The first model assigns roles to users based on points. I can probably use Rules or a build a module for that. The nice things with this is that I get to use Drupal's build permission system. The downside is that I probably have to setup +10 roles and add even more if I want to give new permissions.

The second model is based on a custom build module (not build) that checks if a user is permitted to do whatever he/she intends to do. In this way all the roles can be avoided, but it doesn't use Drupal's permission system, which makes me a bit uncomfortable. On the other hand, there is no need for many roles.

So, is there a performance hit on having many roles? Other problems?

Any thought on this? Other approaches to give users permissions based on user points?


texts:
I have scoured the internet trying to find information on how to achieve this functionality to no avail. I am hoping I can get an answer here.

I have a content type called 'Server' on my website. One of the fields on 'Server' is an 'Access Role' field, which is an entity reference of user roles.

When a new piece of content is made, the author selects one (or multiple roles) that have access to this piece of content (The author can't be granted the 'manage roles' permission, so they can't use the standard 'permissions' options available when creating content).

I have a view setup (that is a REST EXPORT of type key_auth. When a user accesses the endpoint using their auth key, the view should return a list of server content that matches ONLY if one of the users roles is in the access roles field for the piece of content. I can't seem to find out how to achieve this using views and filters.

As an example;

Server 1
Access Roles: Developer, Testing

Server 2
Access Roles: Administrator

The user accessing the endpoint does not have the administrator role, but does have the Testing role. When the user accesses the endpoint, only 'Server 1' should return for them, since that's the only server that matches one of their roles. If more servers matched, those servers would be displayed, too.

I have the access roles setup, and the view setup to connect the api key to the correct user, but can't figure out how to set the filter up to match user roles to one of the possible access roles on the server content.

Is there somebody that could offer me some assistance?


texts: Safely change module without losing change at module update

texts:
I'm using the Image_Widget_Crop module for a Drupal 8 website. In this module there is a .js file setting the default values for Cropper.

Drupal.ImageWidgetCropType.prototype.defaultOptions = {
    autoCropArea: 1,
    background: false,
    responsive: false,
    viewMode: 1,
    zoomable: false
  };

I want to add a setting without putting it in the module so when updating my change doesn't get lost, how can I do this?

I want it to look like this.

Drupal.ImageWidgetCropType.prototype.defaultOptions = {
    autoCropArea: 1,
    background: false,
    responsive: false,
    viewMode: 1,
    zoomable: false,
    toggleDragModeOnDblclick: false
  };


texts: How to cache a custom rest resource when using Url::fromUri

texts:
I have a custom rest resource that is returning data using new ResourceResponse():
$node = Node::load($nid);
$data = load_data('node', $node);
$response = new ResourceResponse($data);
$response->addCacheableDependency($node);
return $response;

This works fine, but if I use the function Url::fromUri into the load_data function I get the error:
LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early.

I can get it to work if I use ModifiedResourceResponse instead of ResourceResponse, but as far as I understand this will disable all caching. As this resource might end up getting intensive I want to make sure it is cached - how can I do this?
Many thanks in advance!


texts: Action links available options / caching

texts:
I have some action links defined in module.links.actions.yml which uses a custom "create entity" route. For entity creation I set up some restrictions and at some point the access is denied. The problem is that whilst the access to the page is denied, the action link is still visible until I clear all caches.

Is there a way to tell Drupal not to cache the links or to programmatically clear the links cache? Or some options I can add in the yml file to prevent caching?

Thanks.


texts: Reverse proxy causes issue with CSS links and HTTPS

texts: I have multiple Drupal instances behind a F5 load balancer. If I use it as http, that is OK. If I want to use http and https and ofload https on the LB, all CSS and JavaScript links in the https site comes as http and cannot be loaded because of the https security.


texts:
How to change the ajax throbber location and make it appear in one place in the site whenever any ajax action is running.

For example I have

I want the ajax image to stop appearing in its normal location beside the ajax link or button to appear in the ajaxThrobber div mentioned above. Like Twitter new Ajax Throbber. Always appear instead of the bird logo.

Any possible answers including jQuery is welcomed.


texts:
I am NOT a developer or DB guy but a webmaster who has manipulated mysql successfully for several wordpress sites. I know how to use the command line tool and also to run things via phpmyadmin. I know how to perform basic administrative mysql functions and occasionally to make a custom query.

I am setting up a  drupal7  site on a VPS where I will already have a wordpress-mysql instance. But it occurred to me that there's nothing really stopping me from installing another db -- postgresql, SQLite, MariaDB. I am less interested in power than ease of use -- but obviously better performance would be welcome. I would probably need some management tool with a web interface. As I said, I wouldn't expect to be doing a lot of DB work; just the routine maintenance and rescue operations that occasionally are necessary.

The site should be a low or medium traffic site with not a lot of writes, but probably a lot of reads. There would probably not be enough traffic to do load balancing or clustering. (It's for a magazine site).

Is there any rule of thumb for which db to choose? Sticking with mysql seems to the obvious and easy solution; I'm just wondering if there's any reason to think differently in 2013.


texts:
I have a simple module that is extracting names from database table. I can display that names in hook_block_view like this:

function example_block_view($delta = '') {

  // $result - an array containing names
  // $names - a string containing names from $result array

  $block = array();

  switch ($delta) {
    case 'xxxxxx':

      $block['title']   = t('Example header');
      $block['content'] = $names;
      break;

  }

  return $block;
}

This will output string with names. But I want to use theme() function for outputting names. So I am continuing by this documentation page: https://www.drupal.org/node/722174

Therefore I edited my code to:

  $block['content'] = array(
    '#theme' => 'example',
    '#header' => 'Example header',
    '#rows' => $result,
  );

But I can't manage out by documentation what should I do next. What is the simplest example of displaying names by custom theme function in my case? Should I do something in template.php of my theme folder, or should I make an hook_theme() in my module? How could I theme the list of names stored in $result array?


texts:
in a custom module, I created a custom form. On this form, I have an ajax button to open a specific file (.pdf).

Here is my code in a custom submit function :

  $url = 'myfileUrl';
  $response = new AjaxResponse();
  $command = new RedirectCommand($url);
  $response->addCommand($command);

It's ok and the file is opened when I click on the button. But, the page is closed to open the file. How can I specify an attribute "target" to open the file in a new window? If not possible, is there another ajax command to open an external URL?

Thanks.


texts:
How do I use #states to show an field if the value of another field is greater than one of my variables?

The code below is for =$chkval

$chkval = 4;
// This would be set by a database query

'#states' => array(
    'visible'=> array(
        ':input[name = 'actual_reps'] => array('value' => $chkval)
    )
)


texts: how to render a field group already setup?

texts:
Seems like I didn't find any complete resource for doing this anywhere.

I already have an accordion group set up http://screencast.com/t/Bpubn8GvvI in a Profile type "account profile" (Profile2 module). I intend this profile type to be displayed at registration page. The thing is I need to code my user registration page using a TPL because the client want to rearrange the fields like it's a "fill-in-the-blanks" questionnaire.

I looked at the $form using dsm() and find it hard to print render() the group. All I see is a #fieldgroups, #groups and #group_children object which cannot be rendered.


texts: Runing PHP Code inside region.tpl.php file

texts:
I'm trying to create a dynamic site based on a static theme. I wonder to know why when I want to put my main menu in the region--page-top.tpl.php it does't work. this code

<?php print theme('links__system_main_menu',
                   array('links' => $main_menu,
                            'attributes' => array( 'class' => array('links','inline'))));?>

works correctly inside the page.tpl.php but it seems that php code doesn't recognize in the region section. The HTML codes work fine, though.


texts: Can't see User fields as options for a context filter

texts:
I was following this video to add a contextual filter so the page I'm creating would display content created by the logged-in user only.

However, when I scroll down the list of contextual filters, I don't see the User: options. How can I see them? Am I missing some module or option? My Drupal 7 setup is almost all by default.


texts: drupal 7 - drupal_add_js - inline doesn't execute

texts:
I made a custom module and I added the following code inside the php tag and also in my hook_menu function

drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');

I can't figure out why it's not firing.

When I look at the 'view source' of the page
I do see this:

<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery(document).ready(function () { alert("Hello!"); });
//--><!]]>
</script>


texts:
All the examples for creating custom block online return #markup from build(), but I'd like to return a render array and have it use a template that's part of the module.

Would love an example of how to do this.


texts: Drush is always scanning the whole drupal directory?

texts:
Every time i run a drush command the command returns after 40s. (or more if time consuming operation like cache clean or so)

After strace the command i realized that drush is scanning my whole drupal directory. I have mounted via nfs an storage with thousands of Files which are accessed by an own module and i think there is no need for drush to scan these files on every run.
Is there an option to exclude a path ?

my files are in drupal_root/sites/default/files/my_module/nodes/nid/

Greetings Robert


texts: How to send email to multiple recipients using drupal_mail?

texts:
I am using drupal_mail to send email,

$to = 'email@email.com';
drupal_mail('$module_name', $key, $to, language_default(), $params = array('username' => 'Tanvir'), $from = NULL, $send = TRUE);

I want to send email to multiple email addresses at once. Should I be doing this?

$to  = array('one@email.com', 'two@email.com', 'three@email.com',);
drupal_mail('$module_name', $key, $to, language_default(), $params = array('username' => 'Tanvir'), $from = NULL, $send = TRUE);


texts: How to make all menu links without www? (shortened menu links)

texts:
I've seen a few sites, not necissarily Drupal sites, in which the menu links, are without www. (that is the Cname DNS record).

Drupal 7 shortens links from http://www.barackobama.com to be www.barackobama.com

I am asking if it is possible to create links without the Cname even, I.E that the final result would be:

barackobama.com

Can be done from inside the Drupal GUI? If not, please at least example how will you do so from the .htaccess file?


texts: Why are English translations of Field Labels shown on site's default language?

texts:
I have 5 languages and all my fields are translated into them. My default language is ancient Aryan.

When I clear cache English translations of Fields Labels are displaying in default language. Other languages rest ok.

When I change English translations of fields labels nothing changes.

Only when I rename one of field labels on default language all English translations of field labels become ok.

What to do if i like to clear cache?

I described bug here: https://www.drupal.org/node/2790131#comment-11574329


texts: How to create a link, which will open user login in lightbox, I have installed lightbox2 module in Drupal 7.


texts: How to call a specific library file inside the div

texts:
I have declared the external library and calling this library for a particular page using preprocess html.

The Library file has been called for the particular page and showing the script content at the bottom of the page.

Now I want to wrap the script content between the div

How do I wrap the script content between the Div using preprocess html or Any Other ways to wrap the script ?


texts: My form does not show any action on clicking the submit button

texts:
I have create custom module with hook_block , inside the block i want form but the problem (
my from does not take any action of submit ). This is my code

function loan_calculator_block_info() {
  // This example comes from node.module.
  $blocks['loan_calculator'] = array(
    'info' => t('Loan Calculator'),
    'cache' => DRUPAL_NO_CACHE
  );
  return $blocks;
}
function loan_calculator_block_view($delta = '') {
    switch ($delta) {
        case 'loan_calculator':
        $block['subject'] = t('Loan Calculator');
        $block['content'] = drupal_get_form('loanCalculator_form');
    return $block;
    break;
  }
}

function loanCalculator_form(){
  $month = range(1 , 12);
  $form['amount'] = array(
    '#title' => t('Amount'),
    '#required' => TRUE,
    '#type' => 'textfield'
  );
  $form['duration'] = array(
    '#title' => t('Duration (Months)'),
    '#required' => TRUE,
    '#type' => 'select',
    '#options' => $month
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
    '#submit' => array('calculator_loan_form_submit')
  );
  return $form;
}

function loanCalculator_form_validate($form, &$form_state) {
  $amount = $form_state['values']['amount'];
  if ($amount == '') {
    form_set_error('amount', t('You must select Amount.'));
  }
  elseif (!is_numeric($amount)) {
    form_set_error('name', t('The Amount must be numeric.'));
  }
}
function calculator_loan_form_submit($form, &$form_state) {
  var_dump($form_state['values']);
  $mount = $form_state['values']['amount'];
  if(!is_numeric($form_state['values']['amount'])) {
    return '
'.t('Please Enter numaric value').'
';
  }
  return $mount;
}

How I can fix this problem?


texts: How to embed webform to update existing submission

texts:
I'm trying to display a webform through a module controller. The webform display works as it should but I need to update existing submission data and instead of updating the existing submission a new one gets created.

The code I use looks like this:

public function edit()
{
  $submissionId = \Drupal::request()->get('sid');
  $webform = Webform::load('eventsignup');
  $webformSubmission = WebformSubmission::load($submissionId);
  $webform = $webform->getSubmissionForm([
    'data' => $webformSubmission->getData()
  ]);

  $build['submissionForm'] = $webform;

  return $build;
}

I tried to alter it by giving the operation "edit" and setting the "sid" but that leads to a duplicate key error:

public function edit()
{
  $submissionId = \Drupal::request()->get('sid');

  $webform = Webform::load('eventsignup');
  $webformSubmission = WebformSubmission::load($submissionId);
  $webform = $webform->getSubmissionForm([
    'sid' => $submissionId,
    'data' => $webformSubmission->getData()
  ], 'edit');

  $build['submissionForm'] = $webform;

  return $build;
}

What am I doing wrong?

Thanks for your help!


texts: Create Content with entities to link to another content's sub entities

texts:
It's kind of difficult for me to phrase the question, but I'll still try:
My goal is to create several pieces of content that are referencing each other. But one content type has number of entities that can be referenced in 1 to many way. To be more specific it's an asset tracking which assigns asset to the spot within another piece of content.

Example:

Content type: Asset

Title: Text
Type: Taxonomy (Server, Router, etc.)
Size: Integer (number of U this server occupies)
Rack: Entity reference

Content type: Rack

Size: Integer (number of u this rack can fit)

Details:
Asset has relationship to the rack, and based on the size of it, it'll occupy that specific amount of Us within the rack. When assigned to particular U, asset will occupy additional U's below it if it's greater than 1U in size. Those Us should disappear from selection list when creating another asset and trying to fit it into that rack.
Error must display if the size of the asset is larger than available adjacent U's in the rack.

Questions:
- What would be my best approach to achieve that in D7 and/or D8?
- Are there any modules available (paid/free) that already have this functionality?


texts: How do I add custom pages or view pages to search index?

texts:
Suppose I have a custom page built in a custom controller. Or similarly, a view page the displays the list of nodes, such as the classic "admin/content" page.

I want certain user roles to be able to find this page when they search the site. The search does not have to index the entire view/page content, but rather a select parts of the content.

Is this possible to do using core hooks? If not, then perhaps using search api hooks?
I am thinking of hooking into the indexing process, and then, retrieve the pages I want to index and send them along. But I am not sure how to do this in a abstract manner where the implementation would work using core database search or search api with solr.

Note Drupal 7 or 8 ideas would be much appreciated.


texts: Ajax error when trying to add another paragraph

texts:
Drupal 8.9 and paragraph 8.x-1.11
My issue is that Ajax breaks when altering the #validate form. This is an issue for any form! It may have to do with my ajax, but here is my setup.
I have a paragraph type:
contact_information

field_phone_number (telephone from core)
field_type_of_phone (text_plain)

I have a custom module. In this custom module I am creating a form_alter on /user/register
I have:
function telephone_alter_form_user_register_form_alter(&$form, $form_state, $form_id ){
  //$form['#validate'] = array();  //commenting this in or out doesn't help
  $form['#validate'][] = 'telephone_alter_test_validate';
  //$form['field_phone']['widget']['#element_validate'][] = 'telephone_alter_test_validate';
}

function telephone_alter_test_validate($form, &$form_state) {
   echo "hi"; //prints hi, but ajax breaks
}

The validation works, prints out debugging. However, when I try to add another paragraph element, it does nothing. This is for any form. I have tried this on other forms like adding a basic page and trying to call an alter function!
the Ajax error displayed is:
[{"command":"insert","method":"prepend","selector":null,"data":"\u003Cdiv data-drupal-messages\u003E\n  \u003Cdiv class=\u0022messages__wrapper\u0022\u003E\n \u003Cdiv class=\u0022alert alert-danger alert-dismissible\u0022 role=\u0022alert\u0022 aria-label=\u0022Error message\u0022\u003E\n \u003Cbutton type=\u0022button\u0022 role=\u0022button\u0022 class=\u0022close\u0022 data-dismiss=\u0022alert\u0022 aria-label=\u0022Close\u0022\u003E\u003Cspan aria-hidden=\u0022true\u0022\u003E\u0026times;\u003C\/span\u003E\u003C\/button\u003E\n \u003Ch2 class=\u0022sr-only\u0022\u003EError message\u003C\/h2\u003E\n \u003Cp\u003EAn unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (40 MB) that this server supports.\u003C\/p\u003E\n \u003C\/div\u003E\n    \u003C\/div\u003E\n\u003C\/div\u003E\n","settings":null}]

The Ajax error is key, because if I create an alter form for any other page, I still get the error.
Any help is great! Thank you! I can provide more info if needed


texts:
We have a view with a page attached to it. By default the settings screen pictured below lets you add only a single menu entry for the view.

Is it possible to have this featured in two or more menus as menu links?


texts: How to modify a field value at theme/Views level?

texts:
My content type has a Link field which stores a website URL (e.g. 'site.com'). I use this field in various views and node templates.

My site is multi-language, and I know how to check the current language using the global $language.

Now I need to modify the link field value depending on the selected language. So output 'site-en.com' if visitor is viewing the site in English, 'site-de.com' if viewing in German etc.

I can't use manual field translation (Entity Translation) because the field values are imported from XML using Feeds, and there are hundreds of values.

So I wonder if there is a hook to programatically modify a field value before it is used by templates and Views module?

Or maybe there is a better way..?


texts:
Instead of putting my site in "maintenance mode" I would like to put it in a complete "readonly mode". There is a module for that, however, it only prevents "node add and edit".
I would like to prevent all user activity including login and registration to basically have the site get served from the (varnish) cache. As as side benefit I would use this type of "read only mode" if the site gets flooded with requests.

My question: how can I logout all active users? The login and registrations I can then redirect with a hook.


texts: Is it possible to give inactive accounts a custom error message upon login?

texts:
I have a site where, when a user is flagged as spam, that user account is blocked.

This is fine, but sometimes a user is blocked by mistake.  When the user tries to log in, since the account is blocked, they just get the default Drupal "wrong username/password" message.

However, I would like to give a custom message ("Sorry, it looks like someone thought your account was spam.  If this is a mistake, please contact us.") when the user account is inactive and attempts to log in.  I'm using the latest version of Drupal 7 and I tried to find a way to do this in Rules but I couldn't come up with anything.


texts:
I'm using drupal 6 with the webform module installed.

I need to be able to remotely POST, from PHP results to a webform. Pseudocode:

<?php
//File: remote_script_not_hosted_on_the_same_server_as_drupal.php

$results = array(
'name' => 'testname',
'age' => '6',
);

$node = 5;

$url_to_drupal = 'http://remote_server.com/drupal-6.2';

insert_into_webform($results, $node, $url_to_drupal);

Of course, this example isn't perfect, but you (hopefully) get the idea.

How would you go about doing this?

I've opened an issue on the drupal queue: http://drupal.org/node/1082016

I'm concerned about these two fields invalidating my remote submission:

------WebKitFormBoundaryKIiNRZCPZIFlYWKc
Content-Disposition: form-data; name="form_build_id"

form-58f36748bfffd6752f204eadf1ba87c9
------WebKitFormBoundaryKIiNRZCPZIFlYWKc
Content-Disposition: form-data; name="form_token"

e4becb726ea858b6914980b9142b7f30


texts: Is there a module for adding field types for latitude, longitude, compas coordinates, etc?

texts: Either my google searching skills are low, or there is no such module for D7. I want to create a content type where a user can add his position on the sea: latitude, longitude, knots, heading (000°) and other coordinates. Do you know any module that does this?


texts: Occasional Drupal Error in bootstrap.inc

texts:
Every now and then our site gives out this error:

  Notice: Constant CACHE_PERMANENT already defined in
  C:\Inetpub\wwwroot\includes\bootstrap.inc on line 13

  Notice: Constant CACHE_TEMPORARY already defined in
  C:\Inetpub\wwwroot\includes\bootstrap.inc on line 18

  Notice: Constant WATCHDOG_ALERT already defined in
  C:\Inetpub\wwwroot\includes\bootstrap.inc on line 57

  Notice: Constant WATCHDOG_CRITICAL already defined in
  C:\Inetpub\wwwroot\includes\bootstrap.inc on line 68

  Notice: Constant WATCHDOG_ERROR already defined in
  C:\Inetpub\wwwroot\includes\bootstrap.inc on line 79

  Notice: Constant WATCHDOG_WARNING already defined in
  C:\Inetpub\wwwroot\includes\bootstrap.inc on line 90

  Notice: Constant WATCHDOG_NOTICE already defined in
  C:\Inetpub\wwwroot\includes\bootst... as of 10:40:01 on 2011-07-14.

Don't know what happens that bootstap.inc get run twice? Why else would it complain about constants already being defined. Thanks for any insight.


texts:
I am listing all the comments in a page.

For example, suppose the comments are listed using a design similar to the following one:

  Comment Title 1

  Comment Description 1

  Comment Title 2

  Comment Description 2

  Comment Title 3

  Comment Description 3

If the third comment is the last comment, I should not print the line for that comment.

How can this be done?


texts:
I have varnish configured and "working" on port 80.  I have apache running a few instances of Drupal 6 on port 8080.  One for dev, review and one for production.  I used the four kitchens vcl file as a guide in setting things up.  But I'm wondering if I need to do more configuration in the VCL to separate these environments?  Perhaps separate backends?  I'm not sure when this is necessary.

In addition to this, I am not getting any (or very few) hits, mostly misses which indicates something isn't working correctly.

For reference, my vhosts looks like this...

NameVirtualHost *:8080
<VirtualHost *:8080>
        ServerAdmin info@mysite.com
        ServerName www.mysite.com
        ServerAlias mysite.com
        DocumentRoot /var/www/prod/httpdocs
        ErrorLog /var/www/logs/prod_error.log
        CustomLog /var/www/logs/prod_access.log combined

        <directory "/var/www/prod/httpdocs/">
                Options Indexes MultiViews FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
        </directory>

</VirtualHost>

<VirtualHost *:8080>
        ServerAdmin info@mysite.com
        ServerName test.mysite.com
        DocumentRoot /var/www/test/httpdocs
        ErrorLog /var/www/logs/test_error.log
        CustomLog /var/www/logs/test_access.log combined

        <directory "/var/www/test/httpdocs/">
                Options Indexes MultiViews FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
        </directory>

</VirtualHost>

Feel free to call out anything else you see wrong with how I have configured things in apache.

Additionally, what can I do if I want my dev environment to skip caching all together?

Thanks


texts: Where is the password stored? How do I obtain a new one?

texts:
I have installed  Drupal Commons 6.x 23, but I forgot the username/password I used for the account I created.

Where is the information stored? How can I get a new password?


texts:
I'm trying to create a ECK Entity Content programmatically. I know, because I've used it elsewhere, I have the right code for creating the Entity Content but in my current setup it is not working anymore.
What I have is the following:
.routing.yml
timetracking.ajax_check:
path: '/js/timetracking/ajax/{nid}'
defaults:
    _controller: '\Drupal\timetracking\Controller\TimeTrackingController::timetrackingAjaxCheck'
requirements:
    _csrf_token: 'TRUE'

TimeTrackingControlle.php
<?php

namespace Drupal\timetracking\Controller;

use Drupal\Core\Controller\ControllerBase;

/**
 * Controller routines for user routes.
 */
class TimeTrackingController extends ControllerBase {

  public function timetrackingAjaxCheck($nid) {
    $user = $this->currentUser();
    $timer = (int) $this->timeSpentConfig->get('time_spent_timer');
    /* @    -- Save One Test Entity */
    $test_entity = \Drupal::entityTypeManager()->getStorage('time_tracking')->create([
      'type' => 'time',
      'title' => 'test-2',
      'field_id' => 1,
    ]);
    $test_entity->save();
  }
}

.js
(function ($, Drupal) {
  Drupal.behaviors.timetracking = {
    attach: function(context, settings) {
      // Fetch ajax callback url
      var callbackUrl = '/js/timetracking/ajax/10';

      function timetrackingSendTimer() {
        $.ajax({
          type: 'get',
          url: callbackUrl,
          dataType: 'json',
          data: 'js=1&timer=10'
        });
      }
      timetrackingSendTimer();
    }
  }
})(jQuery, Drupal);

When I put the Save One Test Entity in a .module file it creates an Enitity but when I put it inside the controller it is not. The controller is running as expected when I am debugging it using DPM I get a nice output.
I'm wondering if it is possible to do this inside the Controller? And if not how can I use Ajax to create an ECK Entity?


texts: How can I change the path of calendar views?

texts:
I use the calendar module and the views come with it.

What I want is: When my url is http:mysite/2015 display the year view and when my url is http:mysite/2015/03 display the month view (March of 2015). Of course the day same as well http:mysite/2015/03/16.

I try to change the path and contextual filters setting but I can't do that.
I'm sure it is a simple thing but I can't find the answer yet.


texts: How to Render a field collection item in a Twig template in tabular view

texts:
I have a field collection field having four fields.
I want to display the record in tabular format.
What I have done.
Created a field twig template file.
Added the code like
{% for item in items %}
    <div{{ item.attributes }}>{{ item.content }}</div>
{% endfor %}

Twig file is working properly. But i need to display the content in tabular form.
Coming like

Required

Available Variables


texts: How to specify which form mode to use for a content type

texts: I created a new_form_mode for a content type in D8 and removed some fields in that form mode from Manage form display tab of the content type by selecting that new_form_mode . But how can i select that form should be displayed for that content type instead of default form mode?


texts: On production node_load_multiple doesn't load fields

texts:
I have some code that at localhost runs perfectly but moved to production doesn't load additional fields to nodes.

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'answer')
  ->propertyCondition('uid', $uid);
if (! $owner) $query->propertyCondition('status', 1);
$entities = $query->execute();

// if user has some answers
if (isset($entities['node']))
{
  $nodes = node_load_multiple(array_keys($entities['node']));
  $views = node_view_multiple($nodes, 'teaser');
  $build['#nodes'] = $views['nodes'];
  return $build;
}
return array();

What may be wrong in my migration to production? Or is there any possible aliment with using Feature module to export content types and field associated with it?

To make clear: I've created this content type and fields in CCK and used Feature module to move to production.


texts: How can I view & access all available variables for a Drupal Commerce cart?

texts:
For theming purposes I'm trying to access any and all available Drupal commerce cart variables. For starters, I want to give the user feedback regarding the cart in the global nav.

I thought these vars would be available within the $_SESSION var but not so(?).

an example of what i’m trying to do is as follows, via some pseudo code to be put into the global nav…

<!—- Global nav—->

Cart
    <?php  if($items_in_cart == true) {
        echo ‘*’;
     } ?>

or,....

<?php
if($items_in_cart) {
print $total_items_in_cart;
}?>


texts: commerce drupal 7 cache module suggestion

texts: Any experiences of suggestion about what cache module to use in with a commerce store? I have been researching about it and I cannot find any suggestions or problems that you can face when using Drupal commerce with caching.


texts: location module have problem with field collection it's not appearing in view

texts:
I have used location module inside field collection.
If we use location as a normal field (Outside the field collection) then it will appear in both view and node details but if we use inside the field collection it will not show country or city in view please see the below screen shorts.

Details field is location module which is used in field collection module.

Country and all necessary information is appearing in node details as you can see the above screen short which is highlighted on red color.

But while using in view it will not show the country I have tried both field which is appearing in above screen short

Country= Field collection item: country
Countrylocationonly= location: coutry


texts: Editing the template for Comments editing page

texts:
I've got my comments for my nodes looking good ON the node. However, as an admin, or using the permalink, if you go to the actual comment page (/comment/comment#) it looks funky. I'd like to format it so the sharebar doesn't appear, the whole node doesn't appear, all the rest of the comments don't appear, and the ability to add yet another comment doesn't appear. I JUST want the comment to appear on that page. Sort of like when you go to comments > edit (as an admin).

Does anyone know how to edit this page or what the template file is at least so I can edit that?

Thanks!


texts: looking for equivalent webform select view module on Drupal 8

texts:
I am a new to Drupal 8

I am trying to make select options with webform submission.

What module do I need?
and
How can I make this select options with that module?

Thank you very much!

implement


texts: How to run code after hook_node_delete has completely run?

texts:
I have a node to which I have a number of images attached through the usual content type image field mechanism.  The attachment is done correctly, such that when I delete the node, the images are also deleted.

My problem is that these images are held in a subdirectory, which is not deleted by the file deletion process, and I end up with a bunch of empty and useless directories littering my file system.  I tried deleting the directory with hook_node_delete(), but this fails because Drupal hasn't yet gotten around to deleting the images when that hook gets called, and the rmdir() function I was using to delete the directory fails because the directory isn't empty.

So: Is there a hook I can call that will run after the files have been deleted?  I suppose I could write my own code in hook_node_delete() to delete the files and then the directory, but I'd rather not hack around the architecture like that, if possible.


texts: How do I do per-item shipping based on the number of products?

texts:
I'm doing a favor for a family member by helping set up their store. I've never worked with Drupal before.

They are selling one item, but they want the shipping cost per item to change based on the number of items purchased.

1 item - $3.50 shipping
2 to 9 items - $2.75 shipping PER ITEM
more than 10 items - $2.00 shipping PER ITEM

After a few hours of research I half-understand the rules system, but I can't figure out how to combine rules like this. Can anyone point me in the right direction?


texts:
I followed steps given in this link to create a custom Page.

Page is created and 'Hello world' is printing in the page, now i want to render some blocks in that page. How can I achieve this task?


texts: Can I use same (machine) name for taxonomy and content type?

texts:
My question: Can I (or rather, should I) create a taxonomy and a custom content type that have the same machine name?  I plan to 'link' those two together.

I tried to search around and could not find an answer, I found out that two custom fields cannot have the same name, even if they belong to two different content types for example.  So that would lead me to suggest that the answer to my question is probably not (i.e. they would try to use the same table name). But I don't know if that's correct.

Say I create a site for a school, and want to have a custom content type 'staff' that will hold teachers, administrative staff, etc.  I will also have a vocabulary that has these different staff categories (teachers, administrative staff etc), which I also thought of giving it the name 'staff'.  Is this a bad idea?

PS: I'm using Drupal 8


texts: The tick box is greyed out. What is the "Contribute" module and where can I find it?