texts: How can you pass the value of a variable from drupalSettings to an iframe in the same page?

texts:
I have a variable in Drupal settings which gets its value from php.

 (function ($, Drupal, drupalSettings) {
 /**
  * @namespace
  */
 Drupal.behaviors.pdf_appAccessData = {

attach: function (context) {
  var value = drupalSettings.value_set;
 }
 };
})(jQuery, Drupal, drupalSettings);

How can I set this value to be available in the iframe of the page? I tried in the iframe:

 <script>
xx = parent.value;
alert (xx);
</script>

but it is not working.

Note: the value is supposed to be secret...I managed to do it in Drupal 7 by adding in the js file above (function ($, Drupal, drupalSettings) { var value; to make the variable global and accessible in the page.


texts: The page request for /admin/structure/block only returns part of the html and doesn't render it

texts:
I'm logged in to Drupal and am requesting the blocks page at /admin/structure/block.  However, the page request doesn't render properly in my browser.  (I tried two different browsers with similar results).

The page I get begins with this:

d90
>configure
        delete

        Set Free - FAQ 1

   Region for Set Free - FAQ 1 block
  <select class="block-region-select block-region-user_first
form-select" id="edit-blocks-block-333-region"
name="blocks[block_333][region]"><option value="-1">- None
-</option><option value="help">He

Or this:

10000 ion><option value="map">Map</option><option
value="preface">Preface</option><option
value="breadcrumb">Breadcrumb</option></select>
 <input
type="hidden" name="blocks[block_110][theme]" value="omnia" />

   Weight for 30 DIGITAL TALENTS -
Home Corprate block   <input class="block

or this:

a46c t form-select" id="edit-blocks-block-366-region"
name="blocks[block_366][region]"><option value="-1">- None
-</option><option value="help">Help</option><option value="content">Content</option><option value="top_first">Top
First</option><option value="top_second">Top Second</option><option
value="top_third">Top Third</option><option value="top_fourth">Top
Fourth</option><option value="social_top">Social Top</option><option
value="search_form">Search Form</option><option
value="logo">Logo</option><option value="menu">Menu</option><option
value="strapline_first">Strapline</option><option
value="latest_first">Latest Work</option><option
value="sidebar_first">Sidebar First</option><option
value="sidebar_second">Sidebar Second</option><option
value="postcontent_first">Post Content First</option><option
value="team_first">Team First</option><option
value="logoslider_first">Logo Slider First</option><option
value="bottom_first">Bottom First</option><option

Every page refresh is different.

Anyone have any ideas?

I have a custom module or two, but I don't think they are doing anything bad.  We haven't touched the theme. I've cleared Drupal's cache.  I can't see anything relevant in Drupal's log or the PHP error log.  Every other admin page works fine.  Any ideas?


texts: Problem with field storage for custom content type modules

texts:
I have multiple modules for custom content types (like "node_type_food" and "node_type_wine"), based on "node_type_example" in the drupal examples module.

I can install a content type like "node_type_food" without any problems but  installing a second content type like "node_type_wine" with a common field (food & wine both have a field "field_text") results in this error:

  Unable to install Content type wine, field.storage.node.field_text
  already exists in active configuration.

Without the field.storage.node.field_text.yml in config/install I can't install a content type when no other content type provides the field storage..

  Unable to install Node type wine, field.field.node.wine.field_text has
  unmet dependencies.

Edit: Problem also descibed in comment on Install a module that creates a content type with fileds via YAML


texts: How do I calculate the total of a shopping cart?

texts:
I have the following cart implemented by a custom module I wrote.

The columns are stored in 2 associative arrays.

$jcartItemQty = $_POST['jcartItemQty'];
$jcartItemPrice = $_POST['jcartItemPrice'];

This is what those array could contain:

     [jcartItemQty] => Array
            (
                [0] => 3
                [1] => 1
            )

        [jcartItemName] => Array
            (
                [0] => Armas Jarnefelt - LAULAJAN KOTI
                [1] => Jean Sibelius - Kullervo
            )

        [jcartItemPrice] => Array
            (
                [0] => 110
                [1] => 120
            )

I need to combine somehow the arrays into one that looks like $combined = (3 => 110, 1 => 120) in order to be able to calculate the total.
array_merge() is not working because will only concatenate those 2 arrays.

foreach ($combined as $key => $item) {
  $total += $key * $item;
}

I need to display the total in a form item like this:

foreach ($jcartItemPrice as $key => $value) {
  $form['jcartItemPrice'][$key] = array(
    '#type' => 'textfield',
    '#value' => isset($value) ? $value : '',
  );
}

$form['total'][$key] = array(
  '#type' => 'textfield',
  '#value' => isset($value) ? $value : '',
);

Is there a way to do this?


texts: theme profile2 fields on registration form

texts:
I have two profile types
teacher and student

so far I have used profile2 module and the profile 2 registration path module.
I have the core fields added

I am trying to add profile2 fields to my user-registration template

So far my template looks like this

<?php
print drupal_render($form['form_build_id']);
print drupal_render($form['form_id']);
?>

<?php print drupal_render($form['account']['name']); // prints the username field ?>
<?php print drupal_render($form['account']['mail']); // prints the mail field ?>
<?php print drupal_render($form['account']['pass']); // prints the password fields ?>

<?php print drupal_render($form['actions']['submit']); // print the submit button ?>
password is not being displayed

I am not sure how i can add profile2 fields to my registration form.


texts: How to debug a Commerce value in Rules if field is not exposed?

texts:
I use Drupal Commerce with Commerce Credits module to let users buy credits which later can be used to submit content.

The module has support for Rules but I can't get a very simple condition to work. The problem is that 'Entity has credits' rule always returns 0 even if my users have credits:

I tried to debug the amount of user credits but without any results:

Rules evaluation log shows me that comparison to 0 always returns true but to different values always false, independently if user has credits or no. Before that I check if entity is of type node.

Checking if entity is of type commerce_credits and using 'Entity has credits' doesn't give me any result.

Devel debug using action "Debug value" to show credits for user fails for node:author and site:current-user as no reference to credits is shown.
I tried also to get access to commerce_credits by "Fetch entity by id/property", but couldn't figure out what id/property to define.

Looking at the code of Commerce Credits module it looks like credits get saved to an entity called commerce_credits. But I can't figure out how to use this token.

Any other way to debug Rules and find the credits value related to a user?


texts: Custom submit button callback overrides default callback?

texts:
I am trying to accomplish the following functionality:

I have a profile2 registration form to which I have added a custom form element (just a submit button) using hook_form_alter().

The submit button has a #submit property set to a custom_callback function.

For debugging purposes, the callback function just displays a

drupal_set_message('hello world');

The general idea is that the button is used to gather information from a webservice (in the callback function) and then fill the form with the returned values.

The user can then check the values and submit the user registration form.

When I click the custom submit button, it fires the custom callback. But when I click the user register form submit button, it also fires the custom callback?

I have checked the dpm of $form and the #submit properties are as follows:

$form['#submit'][0] == de default (correct) user registration callback
$form['custom']['#submit'][0] == de custom submit handler

So, any clues on why the default submit handler no longer works?

EDIT:

My form alter implementation looks like this (just add an image button)

   $form['custom'] = array(
    '#name' => 'custom',
    '#type' => 'image_button',
    '#src' => drupal_get_path('module', 'custom') . '/logo.png',
    '#value' => t('get data'),
    '#prefix' => '
',
    '#attributes' => array('alt' => t('get data')),
    '#suffix' => '
',
    //'#weight' => -99,
    '#submit' => array('custom_callback'),
  );

Thanks in advance!


texts: How do I save and retrieve CKEDITOR media (images and video) on a CDN?

texts:
I am using CKeditor, and I need to add media in content. I have enabled the media in the CKeditor configuration.

Then I upload an image:

The image is being added:

Checking the path for the image :

It gets saved in the local server, while I want it to be saved in a CDN.

I am also using the Media module and CDN old S3 module. which saves all the media in the CDN, but the images for CKeditor are saved on the local server.

Currently, it is saved in the base path (eg. https://drupal.stackexchange.com/). I want it to be saved and retrieved from my CDN.

I did find the  Uploadcare : Add media from anywhere plugin, but I don't understand how to use it; I  think it has its own CDN, but I want it to use my own CDN.

Modifying the core is not recommended and it is not the best practice, how do I achieve it in efficient way.
How do I save images added from CKeditor on a CDN instead of the local server?


texts: How can I check for a duplicate node when rendering a view?

texts:
This question is closely related to my other question posed a few hours ago:
How to make a node appear across *all* Taxonomy terms?

As a solution, I plan to create a functionality, where my new nodes are added to every country in my 'countries' vocabulary, when a 'check all' button is clicked (this is in addition to a single term in the 'main' classification taxonomy they are assigned to).

But I have a view for the display of these nodes. It accepts a term ID from the main taxonomy via URL, and provides a Hierarchical Select "exposed filter" for further filtering by geography within the displayed nodes.

I will now have the same node teaser multiplied by the number of countries in my vocabulary, when the user first enters this view (because that many nodes were created).

Is there a way I can tell my view to just notice such nodes only once, in the unfiltered state?


texts: How to hook drupal commerce line item create

texts:
I want to process something when a new commerce line item create, is there any hook can do this?

Or is there another methods can do this?

Thanks at first!


texts: How do I use a submit callback on a Drupal admin settings form?

texts:
I'm using this code to make my admin form:

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

  $form['custom_ignore_terms']['ignore_terms'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Don\'t display these'),
    '#default_value' => variable_get('custom_ignore_terms', array()),
    '#options' => drupal_map_assoc($termTypes),
    '#description' => t("Choose the terms you do not want displayed."),
    '#required' => FALSE,
  );

  return system_settings_form($form);
}

But I notice that if I do this:

function custom_orders_admin_submit($form, &$form_state) {
  exit(var_dump($form_state));
}

I can't exit. I'm guessing this is because system_settings_form() takes care of submitting. How do I get my control back? I need to do some custom processing in that _submit handler...


texts: How to save a vote of an anonymous user only after registering using modal window?

texts:
Here is my usecase:

Only authenticated user can vote.
If an anonymous user tries voting, after the voting is done, the user is represented a modal window for login/register.
If the user registers or loges in, the vote is saved.

The vote calculation is done using cron or other module. I do not have tie up with any particular module (and fine with writing a basic one). I am currently trying my luck with Rules, Voting Rules, Fivestar and obviously, Voting API. For login/registration persona and fbauth is used, so no email verification is requierd.

A similar problem is discussed in A module that allows user to create content anonymously, then if they register, assigns the content to them, however my use case involved voting and email-free registration. Voting makes it more complicated while email-free registration (hopefully) makes it easier.

PS: I want to follow the same work flow for different nodes with plus1 (or similar) module, so a generic approach is requested.


texts: Why is my Rules Component not being scheduled accurately?

texts:
My aim is to send an email to new students at certain weeks after admission. E.g week 28, week 32, week 45.

I set up components with action to send email.

I configured a rule with event: after saving new content type(student).

The content type has a field - date of admission.

I scheduled component evaluation based on the offset of 'date of admission'.

So for example:

Date of admission: 02/03/13 (March 2nd 2013)

Offset: 224 days

However when the rule is triggered and I go to admin/config/workflow/rules/schedule, I noticed that the scheduled date is 16/10/13 rather than 12/10/13.

Please how can I resolve this?


texts: Get node internal path from path alias in Twig template

texts:
I want to get the internal path of a node from its path alias. In Drupal 7 we could use drupal_get_normal_path() directly in the PHP template.

With Drupal 8, Is there a function to get the internal path from an alias inside a Twig template?

In my Twig template I have tried to use the url() function without success...

e.g. {% set path = url('myalias') %} ...


texts: Adding custom functions PHP to use in a views template

texts: I want to use a custom function in views-view-fields--field-name.tpl.php template file. Where do I have to put it? Is it possible to use it in template.php in some preprocess functions?


texts: How to set a field's 'translatable' property

texts:
When I create a new field type in Drupal it seems to be automatically assigned a 'translatable' property and it's not always right. For example, I would expect a Long Text field type to be marked as translatable = TRUE, but for some reason it's coming in as FALSE sometimes. However, body is TRUE.

Is there a place where this property is exposed in the UI and changeable?

I have the i18n module installed and enabled.


texts: Views exposed filter using Solr only returning results for exact phrase

texts:
We're using a Views exposed filter (using the Search API Solr) that searches a Solr index to search for node titles, but only seeing exact phrases matched.

For example, if we have a node titled 'Trees of the Eastern Seaboard,' and do a search for 'Trees,' the node is returned. If we search for 'Trees of' the node is also returned. However if we search for 'Trees Seaboard,' no results are returned.

The Solr search index is using the 'Fulltext' setting. I've tried switching it to 'String' but that setting returns no results at all for the view.

The default search is also configured to use Solr, and returns results correctly for 'Trees Seaboard.'

Is there a way to allow the Views exposed filter to return the correct results for not exact phrases? (keywords?)

Is there a way to allow the filter to accept a 'contains any' setting for the search?


texts: Export Apache Solr enabled facet settings

texts:
On the Apache Solr settings page admin/config/search/apachesolr/enabled-filters you can control which filters are enabled on your site's search interface.

These settings are not stored in regular Drupal variables, hence, you cannot export these settings in a Feature like you would do with another variables. I am interested in making these settings persistent by storing them in Features.

This would allow to effortlessly switch from a produduction Solr instance to a local instance without having to manually re-apply all these settings by reverting the relevant Feature.

What would be best way to store these settings in Features?


texts: Separate and display only particular parent term from a taxonomy vocabulary

texts:
Is there a module or a way to separate and display only a particular parent term from a taxonomy name in Drupal 7 for the admin, while adding the content.

Consider the home page main menu with vocabulary Name.

The home page main menu has the following taxonomy terms.

Hello
----Red
----Green
----Blue
Test
----Orange
----Black
----Violet

Here in my case I have a content type called Article(for example);

While admin is creating an article, I need to display only the taxonomy term related to Hello. Right now it is displaying all the taxonomy terms related to Hello and Test. Is there a way to separate the parent terms from the same Vocabulary Name.


texts:
Im trying to create a view that should have a field which links to a pre-existing view (And Permissioned appropriately). Ive looked into various modules and field options but cannot find it (Newbie to Drupal!).

Basically, I have a view(called, Recipe_Filter) where I have some filters for selecting recipes based on various conditions. I have another view where I show recipes for a particular user and also want to create an "Edit" link that points to Recipe_filter. The problem is that I dont want normal users to see the "Edit" link and only certain roles to be able to view this.

I tried suggestions like the one in this but if I do as in that link, I see a "Edit" link and clicking on it shows a "You are not authorized  to access this page" text. I would like to disable the Edit Link if the user doesnt have access.

Are there modules that will allow a link to an existing view and permission it (like how the standard "Edit to content" or "View to content" works). Any help or pointers would help a lot.


texts: How to get Google Analytics to track progress through a multi-page Drupal Webform?

texts:
I've got a couple of complex multipage webforms, and want to track progress through these forms so that I can how much time users are spending on each page, and whether there are particular pages that cause users to drop out altogether. I thought Google Analytics could do the trick, but it seems to require a unique URL for each page, and that's something that the Webform module doesn't provide.

Has anyone got this to work, and if so how?


texts: How do I resolve missing content type references from uninstalled modules?

texts: In my previous setup of my site, I installed a bunch of modules and had them uninstalled. But now I have many orphaned or missing content types that still resides in the database somewhere. Below is what is displayed on the Field list page where its trying to reference these non-existent content types. Is there a place where I can go to clean this up? Which tables would I be looking into? And if I were to delete these entries where else would I have to delete it?


texts: How to select a particular node reference in a view programmatically

texts:
I have two custom node types : catalog_item and category.

The catalog_item node has a cck node reference field that allow a user to select multiple category nodes. I want to be able to select a particular category from the node reference based on some php code. Is this possible with views?


texts: Making entities under another entitytype

texts:
Suppose, I've created    -name
    -machine_name an entity_type myentity with its schema as:

-name
-machine_name

Next, I want to create another entity subentity that will be grouped under myentity.

I've create both the entities, but somehow during the form making, I'm clueless how to retrieve the myentity data under which I'm creating the subentity and save it.

subentiy schema:

-name
-parent (parent == myentity->machine_name)


texts: theme content type with image from within paragraph

texts:
I'm trying to create a twig layout for a Person content type that is be used within Paragraphs.
My twig file is paragraph--person-profile--default.html.twig.

I can get the Person name with {{ content.field_person[0]['#node'].title.0.value }}

I cannot get the image. I've tried the following:

{{ content.field_person[0]['#node'].field_image.0.value }}

and {{ content.field_person[0]['#node'].field_image.0 }}

The following error is reported.

  Exception: Object of type Drupal\image\Plugin\Field\FieldType\ImageItem cannot be printed. in Drupal\Core\Template\TwigExtension->escapeFilter()

The end game is to have a taxonomy term and a person content type within a paragraph type. The taxonomy term will be used to to style the person.
The same person may be styled differently on different pages.


texts: Custom page with panels in two languages

texts: I created two pages with panels in Drupal 7; they have different names and different languages, but only one can be active as home page.


texts: Is there a way to pass selected date from date_popup to another view in URL?

texts:
I'm using date module in Drupal 7. There are two views that I created; a link inside of one leads to another view. In the first view, I used exposed popup date filter to get the result. What I'm trying to achieve here is how to pass the selected date from the date popup, put it in the URL to use as contextual filter in the another view.

Thanks,
Jake


texts:
I want to use token to show user name in block title. But it is not working.
I tried like [user:name]

Thanks in advacne


texts: How do I print a value from a custom user field on page.tpl?

texts: I have a integer field connected to my users that I would like to print out in the header of my site. I would like to display the value of the field for the user that is currently logged in. When I do print dpm($user) it shows me information about the currently logged in user, but not any of the custom profile fields associated with them.


texts: Can't seem to make use of new user account field in display suite

texts:
I need to be able to display a particular user field in my node display.

The user field is a new, custom field I created, here: /admin/config/people/accounts and it's called 'organization role'. I was able to successfully add values for this field to my users. So the field itself works just fine in the user account settings. When you look at a user it shows their organization role. All that is fine.

However, in my node display I show the photo and name of the author of the node. These fields were made available to me when I installed display suite module and made a custom layout using that module, for my node page(s). However, no matter how many times I flush the cache my new user field 'organization role' is not available to me in my node's 'manage display' tab.

So my question is: how can I make that field available to my node display so I can display it with the rest of the node fields? (and once I make it available how do I actually display it?)


texts: How to display content for specific user

texts:
I created a content type Report. One of the fields name is MyUser and field type is EntityReference. For this field, widget type is SelectList and Target type is User.

I added two contents: Content1 and Content2. I selected UserA for the MyUser field in Content1 and I selected UserB for the MyUser field in content 2.

Now, I created a page view to select the content for the logged in user. If userA logged in, he should see only content1 and if userB logged in, he should see only content2. I thought I needed to add a filter criteria/relationship in view.

How to add the filter criteria/relationship to meet the above requirements?


texts:
I'm a first-time stackexchange user, long time Drupal 6 developer.

I'm just starting playing with Drupal 8 and I know I'm going to love it when I get used to working in it but right now I'm in that frustration phase where it's unfamiliar again and I can't do even the simple things! I wonder if you can help.

I would like to add dynamic content (probably just #markup) to the user's main tab. At the moment, the user tab only contains the familiar text 'Member for xxx'.

Under Drupal 6 I just handled hook_user, something like:

function mymodule_user($type, &$edit, &$user, $category = NULL) {
  switch ($type) {
    case 'view':
      $user->content['the_time'] = array(
        '#type' => 'markup',
        '#value' => 'Epoch = ' . time() . '',
        '#weight' => 100,
      );
      break;
  }
}

(I've not checked the above actually runs, but it's a modified version of something I'm using on a live site).

What's the equivalent under Drupal 8? I'm looking at the following:

function mymodule_user_view(array &$build, UserInterface $account, EntityViewDisplayInterface $display) {
  $build['the_time'] = array(
    '#type' => 'item',
    '#markup' => 'Epoch = ' . time() . '',
  );
}

Although this works (after clearing the caches) I don't think this is the recommended way to do it, as I'm not seeing dynamic content, the hook is only called once and the text is cached.

I really hope someone can point me in the right direction!


texts: How to remove a menu path defined in hook_menu from naviagtion

texts:
I've added two paths for use my my module (for OAuth authentication), but I don't want them to appear as links in menus. I tried defining their 'type' as MENU_CALLBACK but they still appear.

Is there a better way to define paths which aren't necessarily pages.


texts: Storing objects of custom type in $_SESSION - legal way?

texts:
I'm trying to figure out: can I load custom class (defined in module) to be loaded before session starts and its contents processed by PHP (unserialized) - is where any legal way to do this? (without hacking Drupal core)

without it I get _PHP_Incomplete_Class if I store something of a custom type to $_SESSION variable.

I did a research:

hook_boot is not called unless page is cached in NO DB mode otherwise it's called after session is loaded
hook_init is called too late (always after session load)

Any thoughts?


texts: How can I shorten Facet API urls programatically?

texts:
My site uses Search API and Facet API for search.

My user search has several entity references that are also indexed.  So, when just two facets are activated, this gives me a URL like this:

http://www.example.com/search&f1=field_acc_gen%253Afield_location_taxonomize_terms%3A885&f2=field_acc_gen%253Afield_languages%3A50

This is way too long.  What I'd like to do is collapse the field_acc_gen%253Afield_location_taxonomize_terms to co (country) and field_acc_gen%253Afield_languages%3A50 to la (language).

I know that Facet API Pretty Paths can be used to shorten the URLs but because I have about 20 facets, the regex that it uses seems to really kill performance.  I am also thinking about using Search API Page, which does not work with FacetAPI Pretty Paths.  So, I was hoping to find a way to rename the facets themselves in code.

I have my facets exported using the Features module.  I tried changing $facet->name, but this had no affect on the results:

  $facet->name = 'search_api@om_user_search::field_acc_gen:field_language';
  $facet->searcher = 'search_api@om_user_search';
  $facet->realm = '';
  $facet->facet = 'field_acc_gen:field_language';

to:

  $facet->name = 'search_api@om_user_search::la';

How can I programmatically rename a facet?


texts: Using multiple AND/OR operators in contextual filters

texts:
I'm trying to query my nodes by using a contextual filter in views, however, I am unable to use multiple AND (+) operators and OR (-) operators at the same time. For example:

This works:

mysite.com/json/20
mysite.com/json/19+20

This does NOT work:

mysite.com/json/21,19+20
mysite.com/json/21+27,19+20
mysite.com/json/21+27/19+20

Using the "/" causes the additional arguments to be ignored.
What I'm trying to tell the view is to return nodes that have a Term ID equal to either 21 or 27 AND also either have a Term ID equal to 19 or 20.

Here's my view:

Here's the contextual filter:

I have tried checking the "Allow multiple values" box, but it does not affect the filter at all. Does anyone have any suggestions?


texts: Is it possible to redirect anonymous users from /admin to /user?

texts:
Say I have a site called drupal.local, the user login page would be drupal.local/user. And the admin 'homepage' would be drupal.local/admin.

The problem is that lots of people seem to expect drupal.local/admin to lead them to the login page if they are not already logged in. Unfortunately instead of doing that, they just get:

  You are not authorized to access this page.

I guess (thinking about it) a decent solution would be to put a link to the login page in the 403 error template text - but it would be more elegant to redirect the user to /user if they weren't already logged in.

Is it possible to do such a thing?


texts: External javascript that contains jQuery

texts:
I have been asked to include an external js file into a site where I don't have direct access to modify it and the generated script has jQuery it that references $.

Is it possible to include this without modifying the source js file?

I've added it as below

drupal_add_js("www.domain.com/my.js", array(
      'type' => 'external',
      'scope' => 'header',
      'group' => JS_LIBRARY,
      'every_page' => TRUE,
      'weight' => -1,
    ));

But I get undefined errors due to the use of $

Cheers


texts: ajax get to refresh a view with contextual filters

texts:
A view (path example : foo/201507/video) has two contextual filters, the first for the month (YYYYMM) and the second for a taxonomy term (with depth).

The interface provides next and previous buttons for the month and an accordion to select a taxonomy term in the hierarchy.

After each click on a month button or on an accordion entry, the filter criteria have changed and the view's results need to be updated : the associated JavaScript builds the new URL in the path variable, then

var ajax_get = $.get( path)
          .done(function() { alert( "Ok" ); })
          .fail(function() { alert( "Error" ); });

The path is correctly built. I get the "Ok" alert, but nothing else happens. Moreover, if I enter the path manually in the URL bar of the browser, the view displays the expected results.

Has is to do with the fact that I bypassed primary and secondary navigation to directly add Bootstrap buttons and collapse into the page.tpl.php template file ?


texts: Getting fatal error in drupal when open the site

texts:
I am working on a site in which it was perfectly, but now its given this error

  Fatal error: require_once(): Failed opening required
  '/var/www/.../includes/sites/all/modules/context/plugins/context_condition_sitewide.inc'
  (include_path='.:') in /var/www/.../includes/bootstrap.inc on line
  3139.

Here we can see the path is changed .../includes/sites/..... where as the "include" and "sites" are on root folder.

So please guide me that how to solve this issue.


texts: How to make links to private directory always use ssl?

texts:
I am trying to connect all links to files in a private directory to use SSL.

This is what I have done so far;

if (preg_match('!^system/files/webform/([^/]+)(/.*)?!', $path, $matches)) {

    if($_SERVER['SERVER_PORT'] != '443') {
       header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
       exit();
    }

}

This forces private directory file links to use https but it has some issues for users who are not logged into the site.


texts:
On a new drupal 7 installation, I'm trying to get line breaks to show up correctly when saved. I have wysiwyg and tinymce installed through using the panopoly distribution. When I try to do more space after a paragraph (by hitting enter twice), it will generate two empty paragraph tags, such as

. This however won't provide the needed space as they are empty. In an earlier (drupal 6) project, when I tested this behavior it would insert paragraphs with &nbsp; in them which correctly displayed the line breaks. For example:
&nbsp;

&nbsp;

Is there any way to get this behavior back in Drupal 7?

I've played around with the wysiwyg settings, and text formats, but I can't find a combination of settings that will work.


texts: What is the warning I get after moving to a new server?

texts:
This is the warning that I've received:

Warning: file_put_contents(temporary://devel_themer/cs6782ec6bb66b8a6ebfd11530a1ce0d9d1ce55eba): failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in devel_themer_store_krumo() (line 348 of /home/u894021300/public_html/sites/all/modules/devel_themer/devel_themer.module).

What is it?


texts:
Where is the default commerce order_id set and how can i change it to my custom order number?

I am using the Commerce Order Counter module to set a custom order number.
drupal.org/project/commerce_order_counter

The problem i have is the order_id that is passed to paypal is the default commerce order_id and not my custom order number.


texts: Views one to many relationship, display many records in columns

texts:
I have a View with a one to many relationship. ID and Session are in my main table, and "mark"'s are rows in a custom table. When I look up a single ID, I get this result because of the 'many' results in the custom table.

ID | Session     | mark

15 | Spring 2013 | 16

15 | Spring 2013 | 3

15 | Spring 2013 | 5.5

My desired result is:

ID | Session     | mark 1 | mark 2 | mark 3

15 | Spring 2013 | 16 | 3 | 5.5


texts:
I have two hook menu items:

function myid_print_menu()
{
    $items = array();
    $items['user/%user/myid_print_settings'] = array(
        'title' => 'ID Print Settings',
        'description' => 'Configuration options for the myid_print module',
        'page callback' => 'myid_print_admin_settings',
        'page arguments' => array(1),
        'access callback ' => 'myid_print_user_access',
        'type' => MENU_LOCAL_TASK,
        'weight' => -9,
    );

    $items['user/%user/myid_print'] = array(
        'title' => 'Print an ID',
        'page callback' => 'myid_print_user_page',
        'page arguments' => array(1),
        'access callback' => 'myid_print_user_access',
        'file' => 'myid_print.pages.inc',
        'type' => MENU_LOCAL_TASK,
        'weight' => -10,
    );
    return $items;
}

function myid_print_admin_settings()
{
     return drupal_get_form('myid_print_settings_form');
}

function myid_print_settings_form()
{
     $form = array();
     $form['summary'] = array(
         '#type' => 'fieldset',
         '#title' => t('ID Summary'),
         '#description' => t('Summary of ID printed, submitted and reset on a specific range of time')
     );
     return $form;
}

The 'ID Print Settings' was not showing, but Print an ID was showing. I tried clearing my cache, it was still not visible. Why?


texts: How renderable array for an image with style should look like?

texts:
I have a custom module that outputs some images. Now, I would like to render them properly.

Currently, I use theme() function, kinda similarly to the way shown here1 and here1:

echo theme('image_style', array(
  'path' => $image['uri'],
  'style_name' => 'product_page_thumbnail',
  'attributes' => array(
    'alt' => $image['ImageAlt'],
    'title' => $image['ImageTitle'],
  )
));

Now, the theme() docs says:

  Avoid calling this function directly. It is preferable to replace direct calls to the theme() function with calls to drupal_render() by passing a render array with a #theme key to drupal_render(), which in turn calls theme().

So how would I do that?

I know renderable array for links, it's as simple as:

$link = array(
  '#type'    => 'link',
  '#title'   => $title,
  '#href'    => 'http://example.com',
  '#options' => array('html' => TRUE, 'title' => 'link'),
);

So I want the same, but for images. Somehow I can't find any documented example of it.

1Internal Stack Exchange links, just for reference.


texts: Use a custom JS modal to confirm changes made on node add/edit form before submit

texts:
I basically want to do what confirm_form does, but in a custom modal (I am gonna use a JS plugin to generate the confirm modal).

So what I have is a large hook_form_alter, and I am using the following code for the submit button. I am using workflow, so only certain submit buttons will have this behavior attached.

I have succeeded in attaching the behavior, and the popup shows every time you click the button. Unfortunately the node edit form still submits. Where I return the value in openDialog(), it should not save if value if false (if the user clicks NO). If the user clicks YES, save the node.

// Here I am adding the wrapper and adding the ajax attributes. Part of the `hook_form_alter`

$form['actions']['submit']['#prefix'] = '';
$form['actions']['submit']['#suffix'] = '';
$form['actions']['submit']['#attributes']['class'] = array('workflow-submit', 'use-ajax-submit');

$form['actions']['submit']['#ajax'] = array(
    'event' => 'mousedown',
    'callback' => 'confirm_save',
    'wrapper' => 'wf-wrapper',
    'prevent' => 'click',
    'method' => 'after'
);

// Here is the JS that doesn't work right now. The popup displays as it should but the form still submits.

$form['workflow_button_js'] = array(
    '#markup' => '

',
);

// This is just a callback because I have to have one, don't really know what or if I should return anything
function confirm_save(&$form, &$form_state) {
    return 'submit';
}

EDIT I took your suggestions and updated the JS to what is below. The return value is now what I expected, but the form still submits on clicking NO (returning false). I looked at jQuery Form and was under the impression that returning false would stop a submit...

(function ($) {
    function openDialog() {
        vex.dialog.buttons.YES.text = "YES";
        vex.dialog.buttons.NO.text = "NO";
        return vex.dialog.confirm({
            message: "Have you verified that the information you are about to submit is accurate to the best of your knowledge?",
            callback: function(value) {
                return console.log(value);
            }
        });                     }
        // override the default confirmation dialog behavior
        Drupal.behaviors.myModule = {
            attach: function(context, settings) {
                Drupal.ajax["edit-actions-workflow-5"].options.beforeSerialize = function(element, options) {
                    openDialog();
                }
            }
        }
})(jQuery);


texts: How can I create a view that displays the most popular nodes based on an outgoing link?

texts:
The link is a text field that's value is pulled directly in node.tpl:

<a class="list-parent-link" href="<?php echo $node->field_download_link['und'][0]['value']; ?>">

I'd like to be able to track how popular each node's link is, and display the 5 most popular nodes in a views block. Is that possible?


texts: Is there any way to cancel Panels' overlay edit windows?

texts:
I don't want to edit Panel panes via overlay edit-windows and therefore I tried to disable the core "Overlay" module at admin/modules but it seems to effect everything except the overlay of the Panels module.

Note: The reason I want to disable Panels' overlay is because it's slow to me (especially in Dev periods when I disable cache, and that it sometimes stuck and loads "Forever")... Besides, it cannot be open in a new tab, as I would prefer.

Do you know how to disable it?


texts:
On drupal 6 I use page caching and I would like to setup cron to browse all my pages on my website (30pages) before they get expired. What are best options to do that?
I know about boost module but I think it is too robust for my needs. Thank you


texts: Problems importing Conditions of a rule component

texts:
I have generated a feature which exports my tax rate rule component for Drupal Commerce.  However, it is not importing the Conditions of the rule for the component of the tax rate.  It creates the tax rate rule component, and it also creates the action to  be taken,  but just not the conditions.  I have cleared the cache.

Could the problem be that it is trying to import a component configuration?

Field taxable if a field that I have created whose data I am checking to determine taxability.

function bh_taxable_tax_rate_default_rules_configuration() {
  $items = array();
  $items['commerce_tax_rate_taxrate_taxable'] = entity_import('rules_config', '{ "commerce_tax_rate_taxrate_taxable" : {
  "LABEL" : "Calculate Taxable",
  "PLUGIN" : "rule",
  "OWNER" : "rules",
  "TAGS" : [ "Commerce Tax", "sales_tax" ],
  "REQUIRES" : [ "rules", "commerce_tax" ],
  "USES VARIABLES" : { "commerce_line_item" : { "label" : "Line item", "type" : "commerce_line_item" } },
  "IF" : [
    { "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } },
    { "entity_has_field" : {
        "entity" : [ "commerce-line-item:commerce-product" ],
        "field" : "field_taxable"
      }
    },
    { "data_is" : {
        "data" : [ "commerce-line-item:commerce-product:field-taxable" ],
        "value" : "1"
      }
    }
  ],
  "DO" : [
    { "commerce_tax_rate_apply" : {
        "USING" : {
          "commerce_line_item" : [ "commerce-line-item" ],
          "tax_rate_name" : "taxrate_taxable"
        },
        "PROVIDE" : { "applied_tax" : { "applied_tax" : "Applied tax" } }
      }
    }
  ]
}
  }');
  return $items;
 }


texts: single view for multiple term Image slideshow

texts:
I have created a taxonomy vocabulary as a product and created a taxonomy term as a collection, collection1 and so on. In collection i have an option to add multiple images once if i add, it will display in their respective collection term page and same process has been followed for Remaining taxonomy terms.

While click on the collection term page it will need to show particular images as a slideshow and same as it is for other collections taxonomy terms also.

Now I need single view to display the images as a slideshow. I can able to bring out the particular images of the taxonomy terms using contextual filter(using TermID) option in view, whereas i would like to show those images as slideshow. Is it possible to do.


texts: I need to insert hreflang tags in the head tags, but I only need these on the homepage. At the moment I'm inserting the hreflang tags into the head via the html.tpl.php template, but this puts the code on all pages in the site. How can I edit the head for just one page? I'm using Drupal 7.


texts: Do I need to sanitize a user input textfield used in a mail body?

texts:
I have a feature on my site where a user is allowed to edit a textfield is a Drupal form (built using the D7 Form API) and then send the contents of that textfield as (part of) the body of an email to another user.  I use drupal_mail to send the mail.

The textfield is saved in the database, and I rely on the Form API to protect against SQL injection.  The textfield is never rendered on the screen outside the textfield widget, so "dangerous" HTML tags and PHP/JavaScript injection is not a concern (I hope).

I use DefaultMailSystem as mail backend.

Given that the user can type anything in this textfield, is there any need to sanitize this user input before it is included in the email body and sent?


texts: Import or Programmatically create nodes with Videos

texts:
I'm working on a new drupal site which I need to migrate from an existing non-drupal site. I need to be able to import the old blog posts as Article nodes (either through some standard import mechanism or I can write some php to programmatically create the nodes).

However, I'm not sure how to handle creating Image and Video data in a node, especially with the need for transcoding video after creation of the node. So, two questions:

1) How can I programmatically create nodes with binary Image and Video data?

2) When I do create a node with Video data, will the post-create transcoding job be started? I'm using Zencoder to do my transcoding.

I am not using the local filesystem for drupal, I'm storing all of my files in Rackspace Cloud Files, however, I can handle it if I need to use the local filesystem temporarily during import and then manually move things over to Cloud Files. This is only a one-time event.


texts: Import a big website using Feeds XPath Parser

texts:
I'm trying to import the content of a website with thousands of posts using Feeds and its related tools.
I will import the content by accessing a page that contains all the links.

I've tried importing the content using
http://premiumtemplate.org/kaboodle-premium-business-wordpress-theme.html
 as URL.

Below is the function I use:

Context: /
URL: //h:h2
title: //h:title
body: //*[@class="entry"]

I don't know what happens. It doesn't import anything, and I get the message "There is no new content."


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

texts:
I want to use the function form_set_value to replace a taxonomy vocabulary by an other in my form. What's happend if the value is not a string, but an object. In this case I have an error.

The form element looks like this $form['field_arborescence']['und'][0]['tid']['shs_vocabulary']->vid (=2, ->name= 'vocabulary 1', ->machine_name = 'vocabulary_2' ...)
and $form['#parents'] = array('field_arborescence','und',0,'tid','shs_vocabulary')

The new value if form_set_value is an object : ->vid = 3, ->name = 'vocabulary 2, ->machine_name ='vocabulary 2' (from taxonomy_vocabulary_load)

I got the error 'Fatal error: Cannot use object of type stdClass as array in ...form.inc'


texts: Mainteance Mode Causes CSS to be removed

texts:
I am getting my site ready for an update, but whenever I put my site in maintenance mode, all it does is remove all the CSS and images from the site and just shows the content.

Does anybody know what is happening?


texts:
I had a site and it was running fine on the live server but when I moved it to my local server it gave me this error.

Fatal error: Cannot redeclare drupal_get_hash_salt() (previously declared in
D:\wamp\www\htdocs\projects\mysite\includes\bootstrap.inc:2248) in
D:\wamp\www\htdocs\projects\mysite\includes\common.inc on line 5045

I guess the problem occurred because of editing the variable

$drupal_hash_salt = 'zU4q79TqFe0thQO-xGQbfbrFfKloUk9OYXfQ70J1nw0';

manually in setting.php file.

Does anybody have any idea how can I solve this problem?


texts: Subdomain drupal sites cannot read domain cookies

texts:
I have set a cookie from domain (.example.co) and its .NET platform & reading those cookie from drupal site(test.example.co).

While retrieving it shows empty, I have used $_COOKIE.

This link suggests it is possible, also we are setting domain name while creating cookies? Is it possible to use while retrieving cookies?

Also i have found this link, is that interrelated?


texts:
Some modules insert JavaScript at top of list. I put my $sctipts variable at the bottom of html.tpl.php file just before the closing of body tag.
Due to this, some scripts do not work as they get called before jquery or drupal.js .
Please provide steps to reorder list of js.
I tried this code in my template.php but with no effect:

function MYTHEME_js_alter(&$javascript) {
  $javascript['sites/all/modules/syntaxhighlighter/syntaxhighlighter.min.js']['group'] = 500;
  $javascript['sites/all/modules/syntaxhighlighter/syntaxhighlighter.min.js']['weight'] = 500;
}

Solved. I did this: enabled AdvAgg Modifier, Advanced CSS/JS Aggregation. Then I visited settings page /admin/config/development/performance/advagg/mod where I checked options: Enable preprocess on all JS,  Move all inline scripts to the bottom of the execution order, Move all browser conditional JavaScript to the bottom of the group, Move JS to the footer - All.
And now i have all JS in the bottom (as google recommends), without need to chane html.tpl.php


texts: Temporary add role by token for a particular page to anonymous user

texts:
I have a specific task: I need to give a temporary access to particular unpublished nodes for anonymous users using access token. Anonymous is a key feature, so I can't create a limited user account by some reasons.

I found a rough temporary solution by adding a field "access token" to my node type, creating a role with access to unpublished nodes (using view unpublished module) and by changing user_access function. I added the following strings:

 if ($_GET['access_token'] && arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) {

        $node = node_load(arg(1));

        if (isset($node->field_access_token['und'][0]['value']) && $node->field_access_token['und'][0]['value'] == $_GET['access_token']) {

            $account->roles[6] = 'unpublishedaccess';
        }
    }

How can I do similar but without changing Drupal core files?


texts: Hiding the previous instance in a Multi value field collection embedded widget

texts:
I have a multi valued nested field collection with many field in it like checkboxes ,image etc.

Now when adding/editing a node looks clumsy when multiple values added for that field collection.

So I decided to hide the previous instance when add another is clicked , which i achieved by hacking and preprocessing the theme_field_multiple_value_form in the core field.form.inc by not passing the item to drupal_render(), but now what I get is empty draggable row that is not good.

So i managed that by just render a markup there which is not an issue now.

now the values entered to the field collection is not saved if it is hidden.

so what I'm technically asking is how to hide a field but still process it on saving the node.

OR may be is there any alternate ui for multi value nested field collection?

Note : I have tried hide(), #access & skipping from drupal_render.


texts: Add aditional field with title to every node

texts:
I am trying to add additional field to nodes. I could add the field but I can't find a way to add its title. I have implemented the hook_node_view .
My code is

function cso_node_view($node, $view_mode, $langcode) {

  $node->content['my_additional_field'] = array(
      '#markup' => "additional field",
      '#title' => "additional title",
      '#weight' => 1000
    );
}

The title is not appearing where the node is being printed. How can I add the title for this additional field?


texts: Is there a way to delete/purge all generated image style images without re-generating them?

texts:
I'd like to delete all generated image style images without re-generating them immediately.  I want to do this in order to remove them from my backups, because as the number of files on the site increases, it's taking up an exceedingly large amount of space.

I also have the option of making the backup script more complicated and not backing up those directories, but I was wondering if there is a quick way just to remove the generated files only.


texts: How to notify a subscriber before a subscription expires (using Commerce License)?

texts:
I'm using the commerce license module to sell subscriptions (a license in my case). I want to send an email to the subscriber before the license of a subscriber expires.

I found a code snippet in the module's issue queue, which I'm trying to test. So I granted a license to a user for 23 hours, and I want to get a notification message after running cron.

I'm new to Drupal coding, so I want to know what is wrong in my code (why it doesn't seem to work as I want to).

Here is the code:

 <?php
/**
 * Implements hook_cron().
 */
function license_notif_cron() {
  $expires = strtotime('-1 day');
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'commerce_license')
    ->propertyCondition('status', COMMERCE_LICENSE_ACTIVE)
    ->propertyCondition('expires', 0, '<>')
    ->propertyCondition('expires', $expires, '>');
  $results = $query->execute();
  if (!empty($results['commerce_license'])) {
    $license_ids = array_keys($results['commerce_license']);
    drupal_set_message('licensce expires soon');
  }
}
?>


texts: file_scan_directory() takes about 10 seconds to execute

texts:
Using xhprof I noticed that file_scan_directory() takes more than 10 seconds to execute when front page loads. Why should it take such a long time?

This is the output of xhprofile:


texts:
I am trying to build a list of node ids that have view access for a specific role. Is this at all possible? I currently have an array of all 'page' content type nodes "pages".

I now need to loop through these and see if they have a specific role enabled, if so get the id and display the link on a page if the user has access to that page.

I know I can do that using the following example. But this just checks if the user has view access, and the user could have access from another role they have which my list would not be accurate for what I am trying to achieve.

if(node_access('view', $nodeid, $user)){
    // do something
}

Or is there a way to check if a specific users role has view access rather than just access in general.

The reason I am trying to do this, is I am trying to get the list of specific pages dynamically if a role is given to that node "page".

Sorry if my terminology is off I am not super familiar with drupal.


texts: How to convert bold to strong, italic to emphasis on pasted text?

texts:
I'm using Paste Format to clean up all text pasted into CKEditor (setup with WYSIWYG API), and it does a great job at this. Both the text format for users, and the text format that pasteformat uses for cleanup are setup with WYSIWYG Filter.

Content pasted from Word or OpenOffice usually contains b and i tags rather than <strong> and <em>. Is there a way to convert <b> to <strong> and <i> to <em>? Ideally this would happen during the paste action (e.g. with the pasteformat text filter?) so the correct tags will be saved to the database, but converting the tags upon display would also be acceptable.

Any clean way to accomplish this?


texts: Is it safe and fine to block external access to sites/all/modules folder and all its subfolders and files?

texts: That's to say block all except 127.0.0.1?


texts: Config for using PUT with Services Module

texts:
I'm integrating DrupalGap with Drupal 7 and Services module. Issue I'm running into is that all PUT requests are returned as 405 Method Not Allowed.

For example: GET http://example.com/?q=drupalgap/user/1.json works just fine.
After I update the json and try PUT http://example.com/?q=drupalgap/user/1.json gives me the 405.

This is happening locally and on the hosted server, hosting is with Pantheon, they use nginx if that's relevant.

I also tried doing the PUT using the Poster browser extension, same result, which makes me think it's a config setting that's incorrect.


texts: need to replace default drupal user picture with an image field from user profile

texts:
Need to replace the user_picture with my own field_profile_picture(since i've provided a nice crop with imagefield crop).

I've succeeded in getting the file path using template_preprocess_user_picture and the code

 function theme_preprocess_user_picture(&$variables) {
    $account = user_load($variables['account']->uid);
    if(isset($account->field_profile_picture['und'][0]['uri'])) {
        $variables['user_picture'] = $account->field_profile_picture['und'][0]['uri'];

the user_picture is getting replaced by the file path.... how to render the image???

Anyone Please....


texts: how to display/hide block on homepage depending the value in user profile field?

texts:
I'm currently displaying a block on my D7 site' homepage.

Now I've a requirement to display that block only if the logged in user has a specific value in their profile.

I know it can be done using php evaluation by navigating to the bottom of the block and then click (Pages > Pages on which this PHP code returns TRUE ) but have no experience in writing php scripts.

global $user;

If($user->your_profile_field_value == 'requiredvalue')
{
// display the block
// display the block only on 'homepage' }
Else { // don't display the block }

I'm new to php can someone please help me fill in the blanks in above code snippet.

thanks


texts:
I have a file field in a content type. I have enabled the description field for this field. How can I print this description field in twig???

I have a situation here I need to print description field only for one content in views page instead of all the contents on the same page.

For example:
First content has Download
Second content has Download
Third content has field description

Can I put some condition in twig or views field?


texts: How to change a file field value with entity_metadata_wrapper

texts:
I need to remove a file field value, and instead, assign a new value to it. The file field contains video and the new video is in the videos directory.
This is my code to delete a file field value (which works well)

    $node = node_load(37);
    // Get the language for the file field.
    $lang = field_language('node', $node, 'field_video');
    // load the file
    $file = file_load($node->field_video[$lang][0]['fid']);
    // unset the field for the node
    unset($node->field_video[$lang][0]);
    // delete file from disk and from database
    file_delete($file);
    // Save the node.
    node_save($node);

But this code which assigns a new value, reports an error. I get this code from How to set value of file field with entity_metadata_wrapper

    $node = node_load(37);
    $realpath="";
    if ($wrapper = file_stream_wrapper_get_instance_by_uri('public://')) {
      $realpath = $wrapper->realpath();
    }
    $file_path = $realpath."\\video_file\\sarmaye.mp4";
    $file = new stdClass;
    $file->uid = $node->uid;
    $file->filename = pathinfo($file_path, PATHINFO_BASENAME);
    $file->uri = $file_path;
    $file->filemime = file_get_mimetype($file_path);
    $file->display = '1';
    // Make it permanent, otherwise it will get deleted later.
    $file->status = FILE_STATUS_PERMANENT;

    file_save($file);
    $file = (array) $file;
    $items = array($file);
    $ewrapper = entity_metadata_wrapper('node', $node);
    $ewrapper->field_video->set($items);
    $ewrapper->save(true);

But it reports this error

  PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'D:\xampp\htdocs\MySiteName\sites\default\files\video_file\sarmaye' for key 'uri': INSERT INTO {file_managed} (uid, filename, uri, filemime, filesize, status, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => sarmaye.mp4 [:db_insert_placeholder_2] => D:\xampp\htdocs\MySiteName\sites\default\files\video_file\sarmaye.mp4 [:db_insert_placeholder_3] => video/mp4 [:db_insert_placeholder_4] => 4877369 [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => 1468934410 ) in drupal_write_record() (line 7361 of D:\xampp\htdocs\MySiteName\includes\common.inc).


texts: Some Drush master-branch commands report DB problem in Drupal 8

texts:
I use Drupal 8.0.0 in a Windows 10 home, WAMP environment.

When I run for example drush up, I get:

  The drush command 'up' could not be executed. Drush was not able to
  start (bootstrap) the Drupal database

Every action is done when I am in the sites folder (C:\wamp\www\sname>).
This is a brand new environment - I've only one DB named equally as it's user.

Update:

After I tried to follow this similar (but surly not identical!) thread, I added a fifth value to the Path Environment variable, restarted the Win CLI, and than when I ran drush up at the sites' folder, I got another, brand new error:

  wget nor curl executables found.

I need to further explore this but if you have an idea, please shoot...

Drush status

 C:\wamp\www\sname>drush status
 Drupal version         :  8.0.0
 Site URI               :  http://default
 Database driver        :  mysql
 Database hostname      :  localhost
 Database port          :  3306
 Database username      :  sname
 Database name          :  sname
 PHP executable         :  php.exe
 PHP configuration      :  C:\wamp\bin\php\php5.5.12\php.ini
 PHP OS                 :  WINNT
 Drush script           :  C:\drush-master\drush.php
 Drush version          :  8.1-dev
 Drush temp directory   :  C:\Users\Beni\AppData\Local\Temp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  C:\wamp\www\sname
 Site path              :  sites/default
 Sync config path       :  sites/default/files/config_mkuaR5uFQ7VCjh1_FFBuZzWXkUsz-sA7Klv4HO_2yLJG33wfJJabdavO7QKzyIRWiQoWA3IJbg/sync

Drush sql-conf

C:\wamp\www\sname>drush sql-conf
Array
(
    [database] => sname
    [username] => sname
    [prefix] => Array
        (
            [default] =>
        )

    [host] => localhost
    [port] => 3306
    [namespace] => Drupal\Core\Database\Driver\mysql
    [driver] => mysql
)


texts: Drupal node "ranking" based on views sorting

texts:
I am creating a site where there are nodes (which are "causes") that users can donate to (i.e. buying a donation product using Drupal Commerce, which is sort of irrelevant, but just for the record).

I would like to display a "ranking" on each node based on how much money has been donated to that cause. It will be output something like "Rank: 50 out of 210".

My question is: What is the best way to do this?

I know how I could create a view and sort it by the criteria that I'm wanting, but then how to display on a node the index from the view... ? I don't know how to do that.

I've thought about figuring out a way to use Rules to assign a value to a field in the node whenever a donation is made... ? That might be a decent bet.

If anyone has any direction for me on this, I'd really appreciate it.


texts: Why can't I add another allowed file extension to a Drupal 7 image field?

texts:
I've added the SVG file extension for image uploads via admin/structure/types/manage/image/fields/gallery_image, as you see below:

But when I go to upload an image, I'm still not allowed to upload SVG.

I definitely pressed "Save" in the admin page, and I cleared the cache, and I even see the settings as I wanted them in the database, when I inspect the field_config_instance table.  There must be some other table or cache that's not updating.  Any idea?


texts:
was tying to create a <input type="button" /> in drupal 8, below code snippet

$button['button'] = array(
    '#type' => 'button',
    '#value' => $this->t('#Clear'),
);

followed by

render($button)

It's not working as expected. An input type submit is being created instead.

I have also check the example module for D8 here, same thing occurs here.

How do I create an input type=button, any help ? , or am I doing some thing wrong ?


texts: Simplenews newsletter producing undecoded base64 email

texts:
I have a client site that's running Simplenews with Mime Mail and SMTP Authentication Support. Everything works fine except when my client wants to include a link to a YouTube video (and just to be clear, this just a link to the video, not an attempt to embed a video in the newsletter). Here is an excerpt of the resulting newsletter email:

  PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvVFIvUkVDLWh0bWw0MC9sb29zZS5kdGQiPgo8aHRtbD4KPGhlYWQ+PG1ldGEgaHR0cC1lcXVpdj0iQ29udGVudC1UeXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7nIGNoYXJzZXQ9dXRmLTgiPjwvaGVhZD4KPGJvZHkgaWQ9Im1pbWVtYWlsLWJvZHkiIHN0eWxlPSJi

. . . and so on. No other links cause this to occur. When I look at the email source, the plain text version is fine. This only happens to the HTML version. I am thoroughly stumped. Has anyone seen anything like this?


texts: Entity creation-form: Prepopulate all existing entity-references of a field collection

texts:
I have a content-type seasonal_prices with field-collection containing an entity reference field (referencing content-type room) and a number field; the field-collection is multi-value with unlimited cardinality.

When adding new content of type seasonal_prices, I want the form to be pre-populated with an instance of the field-collection for every existing content of type room.

An example: If there are 5 nodes of type room, the create-form of seasonal_prices should show me 5 instances of the field-collection, where each reference-field is pre-populated with its reference to room, so all I have to do is fill out the number-field.

UPDATE:
Here is the code i finally used in a custom module, hope this is helpful:

<?php

function seasonal_prices_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
  // Increase the max cardinality to 20
  $range = drupal_map_assoc(range(1, count(get_roomtype_ids())));
  $new_options =  array(FIELD_CARDINALITY_UNLIMITED => t('Unlimited')) + $range;
  $form['field']['cardinality']['#options'] = $new_options;
}

function seasonal_prices_form_alter(&$form, $form_state, $form_id) {
  // update cardinality in field settings
  $field_name = 'field_prices_and_roomtype';
  $field = field_info_field($field_name);
  $field['cardinality'] = count(get_roomtype_ids());
  // field_update_field() throws an exception on failure
  try {
    field_update_field($field);
  }
  catch (Exception $e) {
    drupal_set_message(t('Could not update cardinality of field.'), 'error');
  }
  // generate fieldcollection instances
  if($form_id == 'seasonal_prices_node_form') {
    $items_count = count(get_roomtype_ids());
    $form_theme = $form[$field_name][LANGUAGE_NONE]['#theme'];
    // remove delete and add more buttons
    $form[$field_name][LANGUAGE_NONE][0]['remove_button']['#access'] = FALSE;
    $form[$field_name][LANGUAGE_NONE]['add_more']['#access'] = FALSE;
    $items = &$form_state['field'][$field_name][LANGUAGE_NONE];
    // generate required number of fields collection
    if ($items_count > 1 and $items['items_count'] != $items_count) {
      $items['items_count'] = $items_count;
      $items['field']['cardinality'] = $items_count;
      $form[$field_name][LANGUAGE_NONE] = field_multiple_value_form($items['field'], $items['instance'], LANGUAGE_NONE, array(), $form, $form_state);
      // reset theme function, as field_multiple_value_form hijacks it
      $form[$field_name][LANGUAGE_NONE]['#theme'] = $form_theme;
    }
    // fill generated instances with default values and disable access
    for ($delta = 0; $delta < ($items_count); $delta++) {
      $form['field_prices_and_roomtype'][LANGUAGE_NONE][$delta]['field_ref_roomtype'][LANGUAGE_NONE]['#default_value'] = get_roomtype_ids()[$delta];
      $form['field_prices_and_roomtype'][LANGUAGE_NONE][$delta]['field_ref_roomtype']['#access'] = FALSE;
      // designate Fieldcollection Items correctly
      $form['field_prices_and_roomtype'][LANGUAGE_NONE][$delta]['#prefix'] = '
' . get_node_title(get_roomtype_ids()[$delta]) . '';
      $form['field_prices_and_roomtype'][LANGUAGE_NONE][$delta]['#suffix'] = '
';
    }

  }
}

// Helper function to get the node title without loading the whole node object.
function get_node_title($nid) {
return db_query('SELECT title FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchField();
}

// Helper function
function get_roomtype_ids() {
    $query = new EntityFieldQuery();
    $query
    ->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'roomtype')
    ->propertyCondition('status', 1)
    ->propertyOrderBy('created', 'ASC');
    $result = $query->execute();
    return array_keys($result['node']);
}


texts:
I would like to do a few things:

Limit the profile type a user has based on their role. When/if they change roles, their profile type would change and any fields that were the same are brought forward.
When accessing a user's profile page, the relevant profile type displays (one URL).
Allow users to display some of the fields in their core profile in the profile2 page that people see. (eg. birthday in core displayed as age in profile2 page).

Or am I thinking about this all wrong? Should I just think of profile types as different pages of the same profile that happen to have different fields?


texts: ajax button doesnt fire callback function

texts:
I need to put some ajax buttons on each row of table.

My theme looks like this:

/**
 * Implements hook_theme().
 */
function application_wizard_theme($existing, $type, $theme, $path) {
  return array(
    'application_wizard_table' => array(
      'render element' => 'element'
    ),
  );
}

function theme_application_wizard_table($vars) {
  extract($vars);
  $header = $element['#header'];
  $header['operations'] = array('data' => t('Operations'));

  $rows = $element['#rows'];

  foreach ($rows as $key => $row) {
    foreach ($row as $fieldKey => $field) {
      $fieldValue = $field[$fieldKey][LANGUAGE_NONE]['0']['value'];
      $rows[$key][$fieldKey] = $fieldValue;
    }

    $operations = array();
    $operations['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
      '#ajax' => array(
        'wrapper' => 'wizard-form-wrapper',
        'callback' => 'application_wizard_callback'
      ),
    );

    $rows[$key]['operations'] = drupal_render($operations);
  }

  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
    )
  );
}

function application_wizard_callback($form, $form_state) {
  return $form;
}

function application_wizard_submit($form, &$form_state) {
  if ($form_state['triggering_element']['#value'] == t('Delete')) {
    dpm($form_state['triggering_element']);
  }
}

There is no action when I click on generated Delete buttons. In other words, buttons doesn't work.

I have no clue what I am doing wrong so I was hoping someone could tell me thank you in advance.


texts: Form Submission values in Hook Form Alter method

texts:
I wrote a custom method to do some set of operations when a webform is submitted and that is working fine. However I need to access some fields values that has been submitted in the Webform.

The fields in the Webform are: 'phone' , 'emailid'. I need to access these variables in the method custom_example_some_function. I tried playing around with some arrays, but that didn't worked out.

function custom_example_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'webform_client_form_22') {
       $form['#submit'][] = 'custom_example_some_function';
  }
}

function custom_example_some_function($form, &$form_state) {
// Do something
// echo $phoneNumberFromForm;
// echo $emailidFromForm;
}


texts: How do I retrieve an entity from an entity reference

texts:
I have a custom module with three entities. The first represents a chemical compound. The second is a list of the periodic table of elements. The third is a many-to-many binding between these two, and also contains a "quantity" field. This last entity is to be able to create each chemical's chemical formula.

Example-combining the quantities and element symbols to produce CH4O

Entity:chemicals
id   name
1    Methanol

Entity:elements
id    symbol   name
1      H       Hydrogen
2      C       Carbon
3      O       Oxygen

Entity:chemical_formulas
id     element    chemical   quantity
1        2          1           1
2        1          1           4
3        3          1           1

I have the three entities working to the point that I can get all the correct data in the database. However, retrieving has proven a challenge.

My ChemicalFormulas class contains this function, and this seems to be where the problem is because it always returns 'null'. The ChemicalFormulas->getQuantity() function is basically the same, and it works fine.

//in the ChemicalFormulas class
public function getElement() {
   return $this->get('element')->value;
}

The field is defined as

$fields['element'] = BaseFieldDefinition::create('entity_reference')
  ->setLabel(t('Element'))
  ->setDescription(t('The Element.'))
  ->setRevisionable(TRUE)
  ->setSetting('target_type', 'elements')
  ->setSetting('handler', 'default')
  ->setDisplayOptions('view', array(
    'label' => 'above',
    'type' => 'string',
    'weight' => 0,
  ))
  ->setDisplayOptions('form', array(
    'type' => 'entity_reference_autocomplete',
    'weight' => 5,
    'settings' => array(
      'match_operator' => 'CONTAINS',
      'size' => '60',
      'autocomplete_type' => 'tags',
      'placeholder' => '',
    ),
  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

I am trying to produce the formula with this function

public function getFormula(){
  $query = \Drupal::entityQuery('chemical_formulas')
    ->condition('chemical', $this->id());

  $ids = $query->execute();
  $entries = entity_load_multiple('chemical_formulas', $ids);
  $formula = "";
  foreach ($entries as $entry){
    //Is element supposed to be an entity or the id of an entity?
    //$element = $entry->getElement(); //If it's an entity
    $element = entity_load('elements', $entry->getElement()); //If it's an integer.
    $symbol = $element->getSymbol();
    $quantity = $entry->getQuantity();
    if ($quantity == 1) {
      $quantity = "";
    }
    $formula .= $symbol . $quantity;
  }
  return $formula;
}


texts: How can I add an additional, custom profile to the checkout flow?

texts:
In Commerce 2 I have a custom Profile to collect additional contact information that may differ from the billing/payment profile information.

I've created the new profile but cannot figure out how to add it to the checkout flow. Any ideas?


texts: How to include CSS for a custom admin theme?

texts:
I want to include my custom style.css in admin pages in Custom Admin theme I have been create.
I am including CSS in .info file as follows

name = Example Module
description = Custom Example Module
core = 7.x
configure = admin/config/example-module/settings
permissions = admin/people/permissions#module-example-module
stylesheets[all][] = css/style.css

and I used mymodule_preprocess_page(&vars) , but I didn't see any result.


texts: How to display custom data array via Twig

texts:
I've created service which gets the raw data from custom content type. It looks like this :

  Array
(
    [front_page_slider] => Array
        (
            [1] => Array
                (
                    [title] => Lorem ipsum dolor sit amet
                    [body] =>Some example slider text up here
                    [field_image] => http://localhost/drupal8/sites/default/files/2016-05/slider1.png
                    [field_link_uri] => http://example.com
                    [field_link_title] => see more
                )

        )

)

After that i use array_push function to add this array $variables global variable.

I've tried to display any of this fields like this:

{{ dump(front_page_slider[1].title) }}

or this:
  {{ dump(front_page_slider) }}

But both return NULL. What I do wrong ?


texts: How to prevent access to Views-only content?

texts:
When I'm developing sites in Drupal, I create various content types and taxonomy vocabularies that I use with Views to build displays. I might not ever want the nodes to be viewable in their own right or listed by taxonomy. Visitors may never figure out the URLs to do this, but I'd still like to lock this down.

I'm aware of various content access modules, and have considered theming taxonomy displays to simply say 'page not found'. But I've yet to find a simple solution, so wondered what other people use to prevent content from being viewed outside of a View?


texts:
When I first developed this module internally (not on Druple.com) the module_schema function created a table with the same name of the module (it was the only table, so it made sense. Short sighted.).

But I now need a 2nd table, so the first table should have a more sensible name. There is also a requirement for an additional field in the original table.

 function afd_pce_update_dependencies(){
   // update_7201 needs to run after update_7200.
   $dependencies['mymodule_field_mappings'][7201] = array(
     'mymodule_field_mappings' => 7200,
   );

   return $dependencies;
 }

 function mymodule_update_7200(){
      db_rename_table('mymodule', 'mymodule_field_mappings');
    }

 function mymodule_update_7201(){
   $spec = array(
     'type' => 'varchar',
     'description' => "The fieldset that this mapping belongs to",
     'length' => 15,
     'not null' => FALSE,
   );
   db_add_field('fieldset_type','mymodule_field_mappings',$spec);
 }

When I run update.php I get the error

Update #7201
Failed: DatabaseSchemaObjectDoesNotExistException:
Cannot add field fieldset_type.
mymodule_field_mappings: table doesn't exist.
in DatabaseSchema_mysql->addField() (line 325 of
{filepath}\includes\database\mysql\schema.inc).


texts: Removing username from personal contact form

texts: On the personal contact form, when someone cc themselves, the username of the user they are emailing is exposed. Many users actually type their full name as username, so for them to remain anonymous, I don't want username to be exposed to others.


texts: text formats - not allowed tags are saved anyway

texts:
I have filtered html text format set to limit allowed html tags (<a> <em> <strong> <ul> <ol> <li><p>), I use also CKeditor with this format. I expected that Drupal would clean any other tags. This is happening after I save a node with text with some not-allowed tags and look at yet unpublished node's html - everything is stripped the way it should be.
However, if I open the node again and look on the code using ckeditors source button - the tags are there.
Were not the tags supposed to be deleted by Drupal? If not, what module can provide such functionality? Thank you.


texts:
After creating a new content type in DEV and then in STAGE importing the exported DEV; After successful import I find below file in in CHANGED stage(1 Changed).

core.entity_view_display.node.my_node_type.teaser

Is anyone having any idea why it is happening?

.


texts: Parse error on JSON response containing URL value

texts:
In my code it is making Ajax request for json data. For JSON output I am using drupal_json() function.

But on browser side it is invoking error handler instead of success handler and getting 'parsererror'.

The JSON data is like this:

{
    "affiliate_urls": {
        "4131": {
            "nid": "4131",
            "title": "play.com - Books",
            "file_path": "sites/default/files/playlogo.gif",
            "url_value": "http://www.play.com/Search.html?searchstring=asd+asdasd\x26searchsource=0\x26searchtype=allproducts"
        }
    }
}

When put on http://jsonlint.com/  I am getting this error:

Parse error on line 7:
...       "url_value": "http://www.play.com
-----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

What is wrong with passing URL value over JSON? and still using drupal_json().

Please help on it.

Thanks


texts: How to call function from PHP file (or another module) in JS file from my custom module?

texts:
After this question, I try to write custom module to add support Views Infinite Scroll to Background Images module. Here is my code:

my_module.module

/**
 * @file
 * Module file for Background Image for Views Infinite Scroll.
 */

/**
 * Implements hook_page_build().
 */

function my_module_page_build() {
  // Settings.
  drupal_add_js(array(
    'viewClass' => '.view-content',
    'nodeClass' => '.node-content',
  ), 'setting');
  // Add JS to page.
  drupal_add_js(drupal_get_path('module', 'my_module') . '/js/my_module.js');
}

/**
 * My function.
 */

function my_module_function() {
   // Code here
}

And ./js/my_module.js

/**
 * @file
 * This is main script of Background Image for Views Infinite Scroll.
 */

(function($, Drupal) {

  Drupal.behaviors.my_module = {
    attach: function (context, settings) {
      $(Drupal.settings.viewClass).on('DOMNodeInserted', function() {
        // Code here
      });
    }
  }

})(jQuery, Drupal);

How call function my_module_function() in my JS file?


texts: Fetching specific node fields instead of whole nodes using EntityFieldQuery

texts:
The standard for fetching specific nodes from the database in Drupal 7 goes something like this:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node');
$query->entityCondition('bundle', 'page');
$query->fieldCondition('field_category', 'value', $category_id);

$result = $query->execute();
$nids = array_keys($result['node']);
$nodes = node_load_multiple($nids);

For better performance, is there any way to specify that I want to load only certain fields (the title for example) of the nodes instead of loading all their their fields?

I prefer a solution that doesn't use SQL to benefit from all the goodies Drupal functions offer (reliability, caching results, future proofed, ...).

Thank you.


texts: Connecting Commerce module with registered users

texts:
I have a site that forces users to register before they can make any purchase, But I can't figure out a way to get the information from the registered users on my site and use it in my commerce module customer profile, so people don't have to enter their information again while making a purchase.

Using:
Drupal 7 Commerce Module


texts: Adding blocks or content panes to a Views page in Drupal 7

texts:
I am using Drupal 7.34 and a bootstrap theme to develop a website for an organization. I have a custom content type which displays people's profiles, and a view page which currently displays all the profiles created from this custom content type. The link to this page is on the main menu. I have created a taxonomy which categorizes people into current and alumni (for example).

I want to organize this as follows:

When users navigate to the People page, they are shown the profiles of all current people first. I am using bootstrap grid for this.
After this, I want to display as a seperate group all alumni, with the title Alumni.

Like this:

I have been able to create the view page with all profiles, but am unable to create the Alumni section.

Could you give me some pointers?


texts: Inserting jQuery corresponding to a certain element ID

texts:
I have a website in which I want to apply a custom drop down menu to a block. However, I have no idea how to go about doing this.

I posted this yesterday and came to the agreement that the jquery was to be added from a separate location, but I do not know where to implement it! I was wondering if perhaps this should be added to the /modules/block/ location or if it should be called elsewhere.

The content that I want to edit may be seen at mag-ds.com in the lower portion (the entries with #id=T_roll.

Help?


texts: How do I access/style the field content in a block?

texts:
So I created a block view showing a Unformatted list of text and image fields.
Now I would like to style the output.

I can create a twig file for that block. But how can I iterate through the content? What I would like to have is basically the text and the image link for each row.

Edit: So one solution is to add to the theme.theme file

/**
* Implements hook_theme_suggestions_HOOK_alter().
* Add a suggestion given by the url of the node.
*/
function mytheme_theme_suggestions_views_view_unformatted_alter(array &$suggestions) {
  $url_fragments = explode('/', \Drupal::request()->getRequestUri());
  if (count($url_fragments) > 1) {
    $suggestions[] = 'views_view_unformatted__' . $url_fragments[1];
  }
}

and then create a views-view-unformatted--.html.twig which will then only act on http://example.loc/<the_node>.
But I am still looking for a solution to iterate through the rows. Also this won't work if we change the path of a node.


texts:
I try to import a 1.2 GB CSV tab delimited without Headers file as nodes with Drupal Feeds, Feeds Tamper, Feeds Entity Translation.

But it imports only on all my servers 1.799 items (without Erros in Feeds and Drupal logs) and a lot of items are missed. I tried following solutions with Feeds:

Set the max_execution_time to value 3000 in php.ini
Set the php_limit to 256M in php.ini
Set the Feeds process limit from value 50 to 2000 in the settings.php

$conf['feeds_process_limit'] = 2000;

The Server has 16 GB RAM, SSD etc. - strong Managed Server.

The Import file is saved in the Drupal private Directory on the Server. From this directory i parsing with Feeds.

With small CSV files it works.

Have anyone a better solution or a solution with Feeds?


texts: Facebook Comments Widget disappears for logged in users

texts:
EDIT: I would clarify that this only affects Chrome, works in IE\Firefox\Opera.

I am using the following code after the opening  tag

Then in my module I've created a block for the FB Comments, so that I can add it via Panels to the pages I'd like commenting to be enabled in like this (omitting the typical block code required):

function _fb_comment() {
  $url = "http://" . $_SERVER['HTTP_HOST'] . request_uri();
  $comment = '

';
  return $comment;
}

Visitors on my site are able to see the Comment widget, but for logged in users it's not visible and I just can't determine why. It feels like FB is hiding the widget due some problem, but there are no errors in the Console to help debug the issue. Inspecting the actual dom shows us that when it works, the markup is following (visitor):

  …

And for logged in users it shows up like this:

  …

As we can see, FB for a reason or another decides to hide the widget -- what causes this I have no idea, I have tested disabling contextual filters so as not to fiddle with the markup of the block in any way and not aggregating JS, not caching blocks and  just about everything.

As we traverse further down to INSIDE the Facebook iframe, the logged in users one has

..

This might be key, but I've not the slightest clue what may cause it. Was hesitating over asking this in StackOverflow instead of Drupal, but since it's a problem with being logged into Drupal, I might not be the first one to tackle the issue.


texts:
Trying to theme image for the first time. Both file and image_style '200x200' exist. In page source code I see this url: http://sitename.com/sites/default/files/styles/220x220/public/guides_images/CBrQ9m1WAAA1EQf.jpg?itok=lGfz-IbP

But second image doesn't exist same as "220x220" folder. What did I miss and how to make image appear(be created by drupal in this folder)?
"The requested page "/sites/default/files/styles/220x220/public/guides_images/CBrQ9m1WAAA1EQf.jpg?itok=lGfz-IbP" could not be found. "

//$g is file number
$f = file_load($g);

$img = theme(
   'image_style',
      array(
        'path' => $f->uri,
        'style_name' => '220x220',
        'alt' => 'Alternate Text',
        'title' => 'Title Text',
      )
);

$form['top'] = array(
  '#type' => 'markup',
  '#markup' => $img,
);


texts: Dynamic menu breadcrumb for custom Drupal form

texts:
We have a form developed using form API in Drupal 7. Based on taxonomyID & nodeID in URL, the form fields will be pre-filled. I want to display the taxonomy term & node title in menu breadcrumb. The taxonomyID & nodeID will be dynamic.

For example:
URL = /tweaks/tryityourself/{taxonomyID}/{nodeID}

Expected menu breadcrumb:
Home >> Contact Us >> Add new Contact us >> Try it Yourself

In above example,
Contact Us = Taxonomy term
Add new Contact us = Node title

Can you please give your suggestion?


texts:
I want to place a PHP variable in SQL LIKE, I tried many ways but no change.

e.g. today $adate is 2012-08-12%

$adate =  date("Y-m-d") . '%';
$tvisit = db_result(db_query("SELECT `counter_id` FROM counter_today WHERE `counter_date` LIKE '{$adate}' ORDER BY `counter_id` DESC LIMIT 1"));

How can I do that ?


texts:
I want to alter the entity.node.canonical route so that when it is accessed using ?_format=json it will return the rendered node in JSON.

So far I have created a RouteSubscriber that alters the route like this:

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('entity.node.canonical')) {
      $route->setRequirement('_format', 'json|html');
    }
  }

}

Ideally I want to have a seperate controller that is called when the format is JSON and otherwise use the default controller from core.

Is this possible, and how would I have to code it?

If that's not possible how can I override the default controller then?


texts: How to embed images in MIME mail system?

texts:
How to progamatically embed images in mail?
I am using mime and mail system module

Here is my code:

function send_rush_me_mail($node){
  $dataArr = array();
  $dataArr['field_name'] = $node->field_name['und'][0]['value'];
  $dataArr['field_email'] = $node->field_email['und'][0]['value'];
  $body = location_beacon_email_body_string('rush_me', $dataArr);
  $params = array(
    'body' => $body,
    'subject' => 'Auto Response for Ask Me',
  );

  drupal_mail('register', 'register', $dataArr['field_email'], language_default(), $params, 'example@domain.com', TRUE);
  watchdog('Ask me mail', print_r($params,1));
}


texts: Does 'managed file' type form api support the properties #prefix and #sufix?

texts:
Does managed file type in drupal 7 form api work with #prefix and *#sufix * properties?

$form['myfilefield'] = array(
            '#title' => t('Image'),
            '#type' => 'managed_file',
            '#title_display' => 'invisible',
            '#id'=>'edit-image-example-image-fid',
            '#prefix' => '
',
            '#sufix' => '
',
            '#default_value' => variable_get('myfilefield', ''),
            '#upload_location' => 'public://myimages/',
);


texts: Jquery version issues: Flexslider doesn't works only with 1.5 and bootstrap needs 1.8+

texts:
This is my site: investassure and I tried incorporating the code for 'button dropdown' from bootstrap. This works only with jquery-1.8+ but the flexslider I used works ONLY with 1.5. As a result, I'm getting this error:

 Uncaught TypeError: Object [object Object] has no method 'on'

I tried using jquery_update, didn't work. There is only one version added on the page right now, which is 1.5. I didn't find a version of flexslider which works with version 1.7+. What else can I do?


texts: Horizontal scrolling in Safari on one content type only when logged out?

texts:
So I have spent numerous hours trying to solve the following issue and without success I bring it to Drupal Answers. For some reason, on my site for content type 'level_1' when browsing in Safari it creates long horizontal scrolling. The strange thing is that when you are logged in, the issue is not there. Furthermore the issue doesn't exist when I coded the HTML/CSS pre-Drupal installation.

It's not an issue of caching as I've made changes and checked they followed through when not logged in.

Anyone have any ideas?

If someone has the opportunity to try and debug this issue it would be greatly appreciated.

The error occurs here in the Safari browser:
http://beta.innovista.org/about-us

Thanks for your time.


texts: Replace a content type name with a different string, in a view

texts:
I have a view that appears as the following table:

Title            Content type          Published
------------------------------------------------
title1           content type 1          yes
title2           content type 2          no
title3           content type 3          yes

I want to be able to use a custom string instead of the content type name. My view should be like the following:

Title            Content type          Published
------------------------------------------------
title1           my content1             yes
title2           contents for all        no
title3           other content           yes

I don't know is it's possible to do this with Views. I don't want to change the name of content types, I only want change them in the view.

Is it possible?


texts: Does a new site installation run through hook_updates of every module?

texts:
I have an existing D7 website for which i write hook_updates whenever i have to make any changes to the schema. Now, i have altered the taxonomy_term_data table using one such update. My question is if I install this website in another Schema(Database) will it automatically make those changes to taxonomy_term_data?
Or, do i need to make those changes again explicitly?


texts:
I have blocks for several profile types that links to users photos videos etc. (think myspace)

With arguments it works nice, block is visible only on page created by userXY and leads to other content made by userXY.

But, when userXY logs into his account and goes to "My account" it leads to www.example.com/user

Now blocks from all profile types are visible and they lead to false urls. The correct block is also there and works well but i can't find a way to limit other blocks not to be shown here.

I am using profile2, tokens and real name module.

Other problem which was thinking of to solve the issue was to change pattern for /user into /role/realname or anything that will change from default /user but nothing seems to work (pattern is ignored).


texts: When two rules attempt a page redirect, which will actually happen?

texts:
I have a rule set up that redirects the user to a specific page after they edit a node.  I  have another rule that changes the value in a node, then redirects to a different page.  My problem: because the second rule makes a change to a node, the first rule is triggered and the user is sent to the first rule's URL (instead of the second rule's URL.)

When two or more URL redirects are triggered by rules, which one is performed?
Does this change if a rule is triggered within another rule?
How can I fix my problem?


texts: rest POST via Postman always ends in 403 access denied

texts:
I try to create a node via a rest POST over Chrome's Postman using Drupal 8.2.3., but i always get a 403 access denied.

Can anyone point out a step-by-step how-to on the settings? Mainly regarding the permissions that need to be set accordingly.

I did obtains the token at /rest/session/token and added into the request header.

The Request was: MYURL.de/rest/node?_format=json. For your information: I created the service-endpoint /rest, and I also tried with: MYURL.de/node?_format=json, but the same result.

Can anyone drop me a hint?


texts: Views: output item fields grouped by field instead of item?

texts:
So currently if I make up a view that outputs three articles with their title and body fields a cleaned up version of the html structure would be:

Item One Title

Blah Blah Blah......

Item Two Title

Blah Blah Blah......

Item Three Title

Blah Blah Blah......

Anyone know how I can, through Views or the best alternative, make the structure like this instead:

Item One Title

Item Two Title

Item Three Title

Blah Blah Blah......

Blah Blah Blah......

Blah Blah Blah......


texts: How to pass additional arguments in $form['#after_build']

texts:
function custom_third_level_auto_suggest_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$form['#after_build'] = 'custom_third_level_auto_suggest_widget_selection_afterbuild';

}

I need to pass $element across #after_build function, how I can implement it?


texts: Problem with views exposed filters and cyrillic й symbol

texts:
I use views exposed filter as search string with "contain" operator.
The filter works normally, but somewhy does not work with cyrillic symbol 'й' if it is placed at end of a word (so it have space after й).

So for example I have words красный, бархатный, койот, йодоформ, ковбойская

The first two words cannot be found and the view shows no result. But other words can be found.
The position of й in search string does not matter. For example I can find ковбойская when I enter ковбой in search field. But if I enter красный I can't find this word, but красны shows me красный word.

Here is the SQL request formed by views

SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created, 'node' AS field_data_body_node_entity_type
FROM
{node} node
WHERE (( (node.status = '1') AND (node.type IN  ('product')) AND (node.title LIKE '%красный%' ESCAPE '\\') ))
ORDER BY node_created DESC

So why it happens and how to avoid this bug?


texts: How to override views-view-field.tpl.php in custom module?

texts:
I am trying to override views-view-field.tpl.php in my custom module as suggested in override views-view-fields.tpl.php in custom module but looks like it's syntaxes are old.

My codes are like:

In mymodule.info

 ; $Id$

  name = My Module
  description = Create custom views template.
  package = Views
  dependencies[] = views
  core = 7.x

  files[] = mymodule.module
  files[] = includes/mymodule.views.inc

 ; Information added by drupal.org packaging script on 2011-07-21
  version = "7.x-4.1"
  core = "7.x"
  project = "mymodule"
  datestamp = "1311290520"

In mymodule.module

function mymodule_views_api() {
  return array(
   'api' => 3.0,
   'path' => drupal_get_path('module', 'mymodule') . '/includes',

   );
 }

function mymodule_theme($existing, $type, $theme, $path)
  {

   return array(
    'views_view_field__views__ticker' => array(
    'variables' => array('view' => NULL, 'options' => NULL,'row' =>NULL),
    'template' => 'views-view-field--views--ticker',
    'base hook' => 'views_view_field',
    'path' => drupal_get_path('module', 'mymodule') . '/includes',

         ),
       );
    }

In /mymodule/includes/mymodule.views.inc

  function theme_views_view_field__views__ticker($vars) {

    $view = $vars['view'];
    $field = $vars['field'];
    $row = $vars['row'];

    return $vars['output'];
   }

  function template_preprocess_views_view_field__views__ticker(&$vars)
   {

    $vars['output'] = $vars['field']->advanced_render($vars['row']);
   }

My custom template file views-view-field--views--ticker.tpl.php in /mymodule/includes

 <?php print $output; ?>

Problem: it is not overriding views-view-field.tpl.php

I am using drupal version 7.41