texts: Change content location in node template

texts:
My content is normally displayed in a specific region that takes up 75% of the screen width, which is usually desired.
However on 'User Profile' pages (and a few others) I want it to take 100% of the width.

I created a user-profile.tpl.php file, which contains the content wrapped in a div that takes up the full screen width using bootstrap like so:

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

The content is rendered, but it's wrapped in the normal content region that is only 75% of the width.  This is a simplified version of the content that is rendered:

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


texts:
I am migrating a Drupal 7 site to Drupal 8 using the Migrate API. So far, I have been able to do this without writing my own plugins.

How do I migrate additional information in an image field (e.g. the alt and title attributes)?

So far I have been using this, but it does not seem to work.

field_bild:
  plugin: iterator
  source: field_bild
  process:
    target_id:
      plugin: migration
      migration: d7_file
      source: fid
      alt: alt
      title: title


texts: View that only shows content that have a certain date?

texts: I have a view that I am using to list events, specifically "today's events." it was relatively easy to create it, say that I want it to sort by time, but what I am wondering, is how can I  filter it to only show events that are happening on the day that it is displaying. I am using the date module's CCK in order to create the date. I would assume that I would use the date start time, but I can't figure out how to filter that start date.


texts: How to add span tag in to webform element label?

texts:
I am trying to style my webform checkboxes and radio buttons differently. For this reason I want to insert span element in to the label and use it instead of original checkboxes.

Found this module : https://www.drupal.org/project/webform_optionsmarkup , but non of the listed options appear in my webform field settings.

Does any body know good solution to accomplish this ?


texts: Views hook_views_data add multiple joins to custom table based on row condition

texts:
I'm using hook_views_data to add a custom table and its fields to Views. The table relates to nodes, and looks like this:

+ node id   | my_value   | time_period  +
|-----------|------------|--------------|
| 1         | 100        | 1 year       |
| 1         | 200        | 1 month      |
| 2         | 300        | 1 year       |
| 2         | 400        | 1 month      |
+---------------------------------------+

I have defined an implicit relationship to my custom table, so I have a view with nodes as the base table and I can access the my_value field from my custom table.

The time_period column is new, however. Now there are multiple rows per node, with different time_period values, and each of these results in a different output row in my view.

Rather than having a my_value field for each row, I would like to have my_value (1 year) and my_value (1 month) fields, so that each output row represents one node - i.e. rows for the same node are collapsed and their fields are separated.

I've cobbled together the SQL that achieves this, but I can't figure out how to accomplish this with hook_views_data:

SELECT
    node.title AS node_title,
    node.nid AS nid,
    custom_table_1month.my_value AS my_value_1month,
    custom_table_1year.views AS my_value_1year
FROM
    node
LEFT JOIN
    custom_table custom_table_1month ON custom_table_1month.node_id = node.nid AND custom_table_1month.time_period = '1 month'
LEFT JOIN
    custom_table custom_table_1year ON custom_table_1year.node_id = node.nid AND custom_table_1year.time_period = '1 year'

I have tried to add two base tables to views, called custom_table_1month and custom_table_1year, but these value names are used verbatim as the table name whereas I really want them as aliases, so Views complains that these tables don't exist, and I can't seem to specify the correct table name anywhere.

I'm feeling like this has to be possible, because I've got the SQL for it! I just can't for the life of me figure out how to do this with Views.


texts: Add element to the "Add new comment" link

texts:
I'm using a Bootstrap theme and would like to add a glyphicon to the "Add new comment" link so that it comes out something like this:

 Add new comment

I've considered overriding the link's default text, but I'm not sure how to do it for this string of text, and I don't like the idea of adding HTML to a translatable string.

Using THEME_preprocess_links(&$variables), I used Kint to explore $variables['links']['comment-add'], but I couldn't find any public methods that would allow me to edit the link contents.


texts: Deleting migrate module tables post migration

texts:
We did a massive migration a while back, several hundred thousand rows. Needless to say we now have a bunch of migrate tables that we could do without.

I've disabled the migrate modules but before I dropped the tables (or should I truncate?) I wanted to make doubly sure that this will have no affect on anything.

Thanks in advance.


texts:
I am using feeds module. The site structure creates a new feed_item for each item in the parsed rss

I want that upon the arrival of each feed_item, the link be shortened. I read about few related modules, but all require manual intervention.

I am ready to insert some api function into the feeds module, but where to insert it exactly, that is out of my knowledge. Please help.

Currently using Shurly


texts: Custom search_api query for categories block

texts:
A site I am building has products that are indexed with search_api + facetapi + search_api_solr.

One of the indexed fields is a (hierarchical) taxonomy term reference. In case this is relevant, I am indexing the "parents all" version of this field.

On the frontpage I want to show some kind of "doormat navigation" showing the most important categories. Something similar for the footer. And for the sidebar maybe.

What I found so far is this article, Display facets on non-search pages

I am not really happy with the options there, and would much rather do a solution with custom code, where I have full control on everything.

The missing part is how to do the search_api query?
I need a search_api or SOLR query that returns a list of category ids, each with the number of indexed products for this category.

How would I build such a query?


texts: How to make block with list of terms from blog postings

texts:
I would like to display a navigational block in a sidebar on a single-user blog page which will have a listing of all taxonomy terms used in the blog entries.

I am using a custom content type and Views to make the blog. I have set up a vocab for this content type, with multiple terms from this vocab selectable for each posting.

I set up a block display in the view with a field using Taxonomy: All terms. Then a filter limited to my specific vocab. Everything is fine, except that I am getting duplicate terms in the list, as some blog entries have the same terms.

Can anyone please tell me how to remove the duplicate results, or tell me a better way to get what I want?


texts: How to prevent drupal select 10 articles on front page by default?

texts: The thing is I don't know where to disable this action, even after I rebuild my frontpage with other blocks/views/panels instead the default blog list style page, drupal will still do the select from database. At /config/system/site-information can change number of articles drupal select, but cannot really turn it off.


texts:
I had to build a form with a select field populated with all the users registered in database. There are 10 users that I can see in admin>people.

To get all the users, I used entity_load('user').

But in my select, I have one empty option in addition to my 10 users.

I checked in my database, and I found this empty UID=0 record:

I searched the Internet but I didn't find a satisfying answer. I read something about Anonymous user but I didn't get it.

Is this record important?
Does it have to be there?
If yes, I'll do some trick to ignore it in my select.
If not, can I just delete it?

Thank you in advance for this little trivial question.


texts: Retrieve File Url from Upload Form When Form is submitted

texts:
I have the following code in my form.

function video_subtitles_menu() {
    //print "video_subtitles_menu 1";exit;
  $items = array();
  $items['video_subtitles_test/upload'] = array( //this creates a URL that will call this form at "examples/form-example"
    'title' => 'Upload Subtitle', //page title
    'description' => 'Uploading subtitle for videos',
    'page callback' => 'drupal_get_form', //this is the function that will be called when the page is accessed.  for a form, use drupal_get_form
    'page arguments' => array('video_upload_subtitles_form'), //put the name of the form here
    'access callback' => TRUE
  );
      //print "video_subtitles_menu 2";exit;
  return $items;
}

function video_upload_subtitles_form($form, &$form_state) {
 $form = array('#attributes' => array('enctype' => 'multipart/form-data'));
 $form['video_name'] = array(
    '#title' => t('Name Of the video'),
    '#type' => 'textfield',
 );

 $form['sub_file'] = array(
        '#type' => 'file',
        '#title' => t('Upload video'),
        '#size' => 48,
        '#description' => t('Pick a video file to upload.'),
    );
 $form['submit_button'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),

    );
 return $form;

}

function video_upload_subtitles_form_validate() {
  if(!file_check_upload('upload')) {
    // If you want to require it, you'll want to do it here... something like this:
    form_set_error('upload', 'File missing for upload.');
  }
}

function video_upload_subtitles_form_submit($form, &$form_state) {
 $video_name = $form_state['values']['video_name'];//I am able to get this
 $file = file_save_upload('sub_file', array());
print "<pre>";print_r($file);// no response here
drupal_set_message(t('The form has been submitted.'));//this also not printing
}

On the submission handler, it only returns the text field, I don`t get anything from file upload field, when I use file_save_upload.

This is the response which i get in firebug, I have tried uploading text and excel file.

What I am trying to do is create a block where you can upload a file than I need to get the url to upload it to CDN but how to get the link of file at form submission.

I am using Drupal 7 by the way.


texts: Renders my safe_value instead of the value

texts:
When I'm displaying the contentfield of a node, Drupal only shows the safe_value. I want to use the full HTML from my WYSIWYG. I know this because, when I change $items[$id][$delta]['safe_value'] into $items[$id][$delta]['value'] (in modules/field/modules/text/text.module line 159 in the text_field_load hook implementation), it displays the correct HTML from my WYSIWYG.

How can I change this, so that Drupal shows the value with the HTML?


texts: Submit values and redirect user from to external URL

texts:
What is the equivalence of:

   <form action="https://paypaad.bankpasargad.com/PaymentController" method="POST">
            <input type="hidden" name="content" value='<?php echo $xml ?>' />
            <input type="hidden" name="sign" value="<?php echo $sign ?>" />
            <input type="submit" value="send" name="submit" />
   </form>

in Drupal 7 ?

I already use following code in my form submit handler, but it doesn't work:

function Chargingform_nameform_submit($form, &$form_state)
   {
    $options = array();
    $options = array(
        'method' => 'POST',
        'xml' => $form_state['values']['xml'],
        'sign' => $form_state['values']['sign'],
        'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
    );

   $url = 'https://paypaad.bankpasargad.com/PaymentController';
   $response = drupal_http_request($url, $options);
}

How I can submit XML, sign to URL and redirect user to that URL at the same time?

This is my code:

function Chargingform_nameform() {
    $xml = 'PHP Handbook30000130000This is good book.MySQL Handbook25000250000This is a good book too.';
    // Get sing
    $sign ='ewtnXYRWPSalHhna9hgO+Kc0W9Z8JBUeG1FkcKPvZL5w2s588c0/B9r';

    $form['xml'] = array(
       '#title' => t('xml'),
       '#type' =>'hidden',
       '#value'=>$xml,
    );
    $form['sign'] = array(
       '#title' => t('sign'),
       '#type' =>'hidden',
       '#value'=>$sign,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('submit'),
    );
    return $form;
}

function Chargingform_nameform_submit($form, &$form_state) {
  $options = array();
  $options = array(
    'method' => 'POST',
    'xml' => $form_state['values']['xml'],
    'sign' => $form_state['values']['sign'],
  );
  $url = 'https//:url';
  $response = drupal_http_request($url, $options);
}

I don't know really how to manage it in JavaScript.

Any suggestions?


texts: How can I use the "Taxonomy display" view on the Panels taxonomy override page?

texts:
I'm trying to change the weight of Page Manager module to enable the taxonomy term template in Panels. This is the error I'm getting:

Page manager module is unable to enable taxonomy/term/%taxonomy_term because some other module already has overridden with views_page.

I tried to change the weight directly from phpmyadmin but the weight field in page_manager_handler table is empty. I also tried the util module but it is not adding the required 'module weight' column in the module listing. Also it clashes with Module Filter module causing drupal to go crazy with a lot of errors.

Any suggestions?


texts:
I have the memcache module installed on Drupal 7. While it works fine I would like to implement some custom caching in some of my modules. For example, if I want to store the array:

$data = array('hi'=>1,'bye'=>2);

I can normally do the following:

$memcache_obj = memcache_connect('memcache_host', 11211);
memcache_set($memcache_obj, 'var_key', $data, 0, 30);

How can I do the equivalent in Drupal using the memcache module. I am trying to avoid having to declare the $memcache_obj each time and just use the one designated by the module.


texts: In a form, I want subsequent fields depending upon previous field?

texts: I have an entity creation form and I have a radio button as a field. Now what I need is, if while adding the entity, if radio button is set, then one more field just below should appear otherwise not.


texts: How to install multiple modules with composer at once?

texts:
Let's say we need to install these 2 modules :

composer require 'drupal/redirect:^1.4'
composer require 'drupal/pathauto:^1.4'

I couldn't find the correct syntax so I've tried this but it doesn't work :

composer require 'drupal/redirect:^1.4'; 'drupal/pathauto:^1.4'
composer require 'drupal/redirect:^1.4', 'drupal/pathauto:^1.4'
composer require 'drupal/redirect:^1.4'/'drupal/pathauto:^1.4'

Actually I install 1st module "redirect " and after installation is completed, I install the 2nd one "pathauto".

I would like to create a script that will install all the necessary modules I need.


texts: Don't show Header view after clicking next on pager

texts:
I'm -very- close to finishing my first drupal site, I've got just one or two more hurdles to overcome and I'm hoping you can help me.

On my /news page (showing Articles), at the top I want to show the 4 most recent Articles as teasers. Below that, I want to show a grid of next 12 most recent Articles. Below that I want to include a pager to allow them to see older Articles.

Using Views and Page Manager I've created a page that gets me very close.

I have a View for "Most Recent Articles" which shows the 4 most recent teasers.

I have a View for "More Articles" which shows a grid of fields of 12 Articles with an offset of 4 so that it doesn't include the 4 most recent.

In Page Manager I created a page that includes the Most Recent Articles View and then includes the More Articles View. This works very well and gives me exactly what I want.

My Problem: When I click the "next" link in the pager at the bottom of the More Articles view, I don't want to show the Most Recent Articles anymore. I'd either like to hide that View on subsequent pages or I'd like to selective only include it on the 1st page (two different approaches to the same idea).

Help?


texts: Why is my custom block template applying to all blocks?

texts:
I have a region on my home page called home_area_1. It contains several blocks. I want those blocks to be formatted in the same way, so I created a template called block--home-area-1.tpl.php. It is formatting those blocks correctly, but it's also being applied to blocks in other regions on the home page.

What am I doing wrong? I only want the blocks in this particular region to use this template.

I'm on Drupal 7.35, and am fairly new at this.


texts: How to make a template for content type with panels

texts:
I´ve created a content type "Products" with "N" fields and I try to create a template for this content type, each product should have its own page.

How I do this?


texts: Is it possible to POST values to next page with a Drupal URL?

texts:
I have the following link that works if I link to an external page outside Drupal. However, when I place the same code in a Drupal page that is on orangeEDIT, and change this URL to point to the Drupal location, it says the page cannot be found.

<a href="http://host/drupal1/?q=node/17?orange_id=<?= $row['orange_id']; ?>">Edit

I should probably use the Form API for this, as it is a link that allows a form to be edited, but it seems a way too complicated, compared to the PHP solution.


texts: views_embed_view not working with multiple values argument

texts:
I'm trying to embed views like this:

 views_embed_view('articles_list', 'block_1', '11+13');

If I type 11 in arguments, it does take the argument. It works good if I preview the view and enter '11+13' in "Preview with contextual filters" field... But if I write '11+13' in the views_embed_view() function, it just takes the value of 11. How can I make it work and take both values: 11 and 13?


texts: Webform views - creating a filter using date from user-submitted data

texts:
We have a job submissions webform. In the form, there is a "closing date" field with a calendar picker (yyyymmdd format). When the closing date passes, the submission should be removed from view.

I created a relationship for the Submission Data: Expiry Date field so it can be used as a Filter.

Now that I have the data available as a filter, this is where I get stuck; I need the view to filter out the submission if the Expiry Date has passed. How can I do this?


texts: Is it possible to append Media's file browser to a certain node type?

texts:
I have a certain node type with a canvas on it, allowing users to draw on the node. Basic functionality such as lines are working, but I'd like to allow people to upload images to it as well. Since the rest of the site is using the Media module (V2 dev), allowing users to browse the library and their personal uploads... I was hoping to be able to use it here as well.

The same question was posted as a support request in Media issue queue as well but so far there is no reponse: https://www.drupal.org/node/2423415

What I am looking for is a way to embed the media browser on the node and catch the path of the returned file so the JavaScript and the canvas can read it.

So far I've managed to add the media widget to the node with:

function mymodule_node_view($node, $view_mode, $langcode) {
  if($node->type == 'mytype') {
    $form = drupal_get_form('mymodule_media_form');

    // append a new field to the content
    $node->content['imageupload'] = array(
      '#markup' => drupal_render($form), // and render the form there
      '#weight' => 10,
    );
  }
}

function mymodule_media_form($form, &$form_state) {
  $form['file'] = array(
    '#type' => 'media-widget',
    '#title' => t('Image'),
    '#description' => t('Upload a file'),
  );
  return $form;
}

It shows the Media file upload button, but the dialog does not popup (due to missing JavaScripts I suppose). Is there a better way to load this field with all required JS etc? I do suppose I need to at least use hook_form() assuming I can't display a form field outside form context.


texts: How to allow users to login with a particular role they have selected?

texts:
I have a multiple roles in my site, let's say I have role A, B, C, D.

I want users to be able to choose which role a user wants when logging in. And then the user should only be able to access the content for the selected role (even if the user has multiple roles).

Any suggestions about how to implement this?


texts: Hiding countdown field on 0 and show other field / fields

texts: Can you help me with this? I'm using conditional fields and it hides other field only on node edit form. I've also tried the field formatter conditions but there's no such an option... Thanks for help


texts: Views filter: how to compare two fields?

texts:
I have two content types "type1" and "type2" and one taxonomy. I have assigned the taxonomy to both of the content types. In type1 its name is "field_type1_test" and in type its name is "field_type2_test".

Now I want to fetch the title and body from the "type1" Where values of "field_type1_test" = "field_type2_test".

Is this possible?

If yes then how will I do this in views? Help please.


texts: How to check if a Vocabulary is translatable?

texts:
In Drupal Core, I found the following code:

$entity instanceof TranslatableDataInterface && $entity->isTranslatable()

But it looks like it is not working for the Taxonomy vocabularies


texts: How to display all the events in a week view of a calendar?

texts:
I have calendar installed on my site.
I have created a content type named events.
The events content type has three fields title, event time(time only not date and its of type time) and day.

I have modified the block of the calendar view. I have selected the week from calendar format settings so that it should display the week view.

Now I want to list all the events under the monday which have the monday selected in the day field, all the events under the tuesday which have the tuesday selected in the day field and so on.

Format:

Mon              tue                 Wed                 Thu    Fri                 Sat                 Sun

event1          event2

Monday        Tuesday

2:30              2:30


texts: Get tag(term) name for multiple nodes without a performance hit

texts:
I want to get a list of nodes and return them as JSON along with their tags (names included). After a lot of research, I've only come up with this solution:

I have an array of Nodes (\Drupal\Core\Entity\EntityInterface) loaded with Node::loadMultiple().

Iterating over the array of nodes, and getting their tags using $node->field_tags (or whatever the machine name of the tags is) which yields an array of \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem

Getting all the terms of the node using Term::loadMultiple() and then iterating over them and getting the name using $term->name[0]->value.

The problem is that there's an extra database read for every node, and I guess that the underlying query for this read is a JOIN :|.

Question: Is there an efficient way to load the tag (term) names along with target_id, target_type, target_uuid, etc? If no, is the current loop on each node the way to go???

More Info:

I'm paginating the results
The client can set the number of results per page, but there's a 50 nodes per page limit

Thanks

P.S.: I have two more types of tags so I have to do this two more times. Bright side is, the other two tags are 1to1.


texts: Display extra information adjacent to system_settings_form() output

texts:
I have a properly constructed set of data coming out of a call to system_settings_form().  How can I add to that data to display additional items on the form page?

I'm currently trying (and failing with):

// ...inside drupal_get_form callback
// $form has some form elements in it
$return =  system_settings_form($form);
if (!hay_problemas()){
    $return['warning'] = array(
        '#type' => 'div',
        '#class' => 'warning',
        '#markup' => 'WARNING:  Filesystem permission are broken'
    );
}
return $return;


texts: How to display a field of a referenced entity in views contextual block?

texts:
I have read several questions on topic, e.g. 1 2 3, but couldn't manage to get it work.

My setup:
In a Drupal 7 environment, I have a node type called organizer, which contains two fields: node title (default) and a link (to the organizer's website).
A second node type called event contains several fields one of which is an entity reference to organizer.

My site's design only has the node title and node body of an event being displayed in main content. All other fields are displayed in a sidebar using a views block with filter on node type (= event) and a contextual filter on node id. Among these fields is also the field organizer and it's displaying the organizer's name (title field) alright.

My goal:
Now I want to have the organizer's name link to the organizer's website. But the link is actually a field inside the organizer content type.

My approach:
I've added a relationship to Entity Reference: organizer. Then I added the link field that is used in the organizer content type to the list of fields using the relationship. I rearrange the fields to have this link field being loaded before the entity reference field. Then I set up the latter field to being rewritten as link using the plain url from the link field.
[The link field is currently being displayed for debug purposes, later I want to exclude it from display, of course.]

My result:
The link field is always empty. Hence, the organizer's name is never linked to the respective website.

Questions I stumbled upon:
When I add a relationship, I have two options like

Entity Reference: Referenced Entity
A bridge to the Content entity that is referenced via field_organizer
 Entity Reference: Referencing entity
A bridge to the Content entity that is referencing Content via organizer

My understanding is that I have to user the first one, because I want to load the organizer that is referenced in the event. [The second one I would be using, if I have a organizer and want to get all events that are referencing this organizer, right?] However, I tried both options to no avail.

Is the ordering of fields relevant? I've tried both having the link field before and after the entity reference field, it stays empty in both cases.

Since each event could have more than only one organizer, the entity reference field is set to allow unlimited values. Could that cause a problem?

Could anyone point me into the right direction of what I am missing?

UPDATE: It seems to break the system if you have both relationship types set up at the same time or maybe the ordering plays a role, too. However, when the first relationship in list is the one I need it kind of works.

It is working absolutely fine for a single organizer, the name is displayed and linked to the organizer's website. But it will not work for any additional organizers. The block lists all organizers (when having more than one) but each of them is linked to the first organizer's website.

Thinking about how that works, that is reasonable, since the relationship only adds one related object. When displaying a field (e.g.) from that relationship it will be the same for each delta of entity reference field.

Actually, in that case I should be able to define how the entity reference field is displayed. It already has an option to link to the entity itself but you can't define any fields from the entity to be shown (e.g. instead of title).


texts: 3-column fixed width Zen-based layout + SASS; giving exact width to columns

texts:
I'm using Zen theme with SASS (+Compass), and I have a site with fixed width layout. This means I include fixed-width.scss in my custom Zen subtheme's .info file.

I would like 3 columns - 2 for the sidebars, 1 for the main content. By default, I got these (I don't know why, because $zen-column-count is set to 5...).

OK, the problem is that when generating the CSS-files, the width of the columns get automatically calculated based on different SASS mixins. I don't want to mess up the automatic calculation of margins etc., I just want to set the exact parameters.

The main outer grid width should be 920px wide ($zen-grid-width: 920px;).

Now I have these automatically calculated parameters:

sidebars: 184px, 184px
main content: 552px

BUT I want it like this:

sidebars: 220px, 220px
main content: 480px

Here is my fixed-width.scss: http://vpaste.net/n4ve0

How should the exact parameters be set for the sidebar columns when using SASS in Zen?


texts: How to add an image property to an entity?

texts:
I have a requirement to add a unique icon to each bundle of an entity. My entity code is very similar to the model module. I have 2 entities, one for holding the actual entity instances, another for holding the type information.

Each entity type will have a unique icon which will be shown while adding that entity in the creation form. For this, I need to add a custom property to the entity which will hold the image file data.


texts: Can entities as users exist without being tied to nodes, I'm starting a site that I don't want a lot of overhead and it will have a lot of users and they will be contacting each other often.


texts:
I'm not sure if that was me messing around with Media, or is it Media's fault by de*fault*.
I'm using that module mainly for its ability to re-use uploaded media, but for some reason I cannot get the images real preview. What is the crucial setting to have an image file display its preview in the library and in the content type editor?

I must say with more and more experience using Drupal, I'm still perplexed when it comes to configuring Media file types and display options. Seems like one could fall into an endless loop when trying to manage files' display options.


texts: How can I recognize when the user is editing or inserting something?

texts: I have a form which adds some information. I used hook_form() for inserting and loading data. units/add calls the form to insert data and units/%unitid/edit calls the form to edit data. In hook_form_submit(), how can I recognize when the user is editing or inserting something? Should I use $delta, or is it no longer available in Drupal 7?


texts: 7 - Sorting in a view seems to not be alphabetical?

texts:
I've set up a Drupal 7.18 site with Views 7.x.35. I've created a content type "Course" and included it's content type as an entity reference in a "Product" content type.

I have a view for listing courses and it sorts alphabetically just fine. However, I have another view products, with a course column, and its alphabetical sort is not alphabetical. I would like advice on 1) why this is so and 2) how to make it alphabetical.

Things I've tried:
* Clearing caches via Admin section
* Removing all other sort criteria from view
* Removing and re-adding the field

I am attaching an image depicting the behavior and another showing the view setup. I'm happy to provide more detail as appropriate. TIA!

Here's links to the photos (sigh, first post, lack 10 points to post images)
Error behavior: http://www.flickr.com/photos/24745111@N00/8389442182/in/photostream

View admin pane: http://www.flickr.com/photos/24745111@N00/8389442184/in/photostream


texts: We have this large website where we would have to deploy html changes in Twig quite often. I'm looking for a solution to clear the Twig cache ONLY. So we do not have to do a general cache rebuild, which consumes a lot of CPU each time. drush cc render does not work, twig html still cached. Any suggestions?


texts: Display custom output if field doesn't have value in hook_field_formatter_view

texts:
Display custom output of field in hook_field_formatter_view() if field is empty.

function hook_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  //My Snippet to display custom output
  // Here $items variable is empty.
  $element = array();
  switch ($instance ['widget'] ['type']) {
  case 'my_widget' :
    if (!isset($items[0])) {
      $output = generate_custom_output();
      $element [0] = array ('#markup' => $output );
    }
    break;
  }
  return $element;
}

my custom field is empty, no $item is available. Now I want to return custom output. But above code doesn't work.

Please suggest any solution.


texts:
I am using bartik theme. I have an image that I like to use as background of the home page only. Admin > appearance > Bartik > settings > I see different colors to set as background. Can I have an image as background instead of the color for the home page. And for other pages I can use a color.

Thanks.

D


texts:
I have a regular node in my main menu that:

if an anonymous user clicks on it, the node should be shown regularly
if a logged in user clicks on it, there should be a redirect to an external website

I tried

HOOK_menu_link_alter
but that only is invoked on edit-and-save (if menu item is created via web)

HOOK_node_view
that seems to work but does not seem like a good solution to load the complete node and check for the user just to redirect


texts: Adding a Meta tags CMS function to drupal 7

texts:
I would like to be able to manually configure the meta tags, keywords and description,for each individual page of the sites. I couldn't find any module out there for drupal 7 that does so.
Anyone have heard of such a module? If not how hard would it be to make this a custom module ?


texts:
I am using a custom validation in my Drupal 7 comment form.I want to match the comment_body against a word "example" so if someone just type "example"in the comment body then it will show a error message that only the word "example" is not allowed. After reading drupal api documentation i codded like this:

function mango_form_comment_node_news_form_alter(&$form, &$form_state, $form_id){
    $form['comment_body']['#prefix'] = '
Post your comment now!
';
    $form['actions']['submit']['#value'] = 'Post Your Comment';
    $form['#validate'][] = 'banana';
}

function banana($form, &$form_state) {
  if ($form_state['comment_body'] == "example") {
    form_set_error('comment_body', 'Your comment can not contain example!');
  }
}

Do not working :'( what i'm missing? Thanks


texts: How to call module function in template file?

texts:
I have one custom function in .module file. Need to call that function .template file. Below is my code snnipet:

function non_login_preprocess_page(&$vars) {

  if(module_exists('test') && function_exists('test_get_rnd_data')){
    $vars['rnd_data'] = test_get_rnd_data();
    print_r("callled"); exit;
  }
}

the function exists does not return true. Is anything thing missing?


texts: Get field machine name inside HOOK_preprocess_file_link()?

texts:
I am hoping to get the field name inside the HOOK_preprocess_file_link.

Only wanting to alter the link of the file for certain field names.

Hook_preprocess_field() would probably work, but would prefer to use HOOK_preprocess_file_link().

Is it possible to get the field name in this hook?

MYMODULE.module:

function HOOK_preprocess_file_link(&$variables, $fieldName) {

  kpr($fieldName); // This returns "file_link" instead of the field name like "field_myfilefield".

}

function HOOK_preprocess_field(&$variables) {

  if (isset($variables['field_name'])) {
    $fieldName = $variables['field_name'];
  }
  HOOK_preprocess_file_link($variables, $fieldName);

}


texts:
Can anyone suggest a way, or a module to truncate very long filenames which are uploaded to a Drupal 7 website? I have a client who keeps uploading files that are actually sentences and I want to limit the filename to a reasonable and certain amount of characters (say 20).

Thanks for any help on this.


texts: how to show a message after a node form is submitted

texts:
How do I show a message (notice or alert) after the node form is submitted and saved?

I'm writing a module that synchronizes the node content with a remote endpoint. All working good. But, if for any reason the sync fails, I want to show a message on the page the user is redirected to.

My problem is that I don't find the hook or function which is invoked after the form is saved to databases but before the redirect happens, where I hopefully can set the message I want.


texts: Writing PHP into views field template twig

texts:
I'm less familiar with D8, but I need to re-write a views field output using some PHP. I've made a custom field template HTML.twig file, but I'm not sure what I need to do to be able to run a PHP execution on my field to render it out as I want.
edit:
I am trying to run a function on the User ID as I have a module which hashes it before sending it to an external platform, however, now the client wants the understand which user is which, and the only way I can think to do this is by performing the same hashing code on the User ID in a format I can easily cross reference the user with their hashed output
I have a very basic view table showing only the User ID and email address, and I've managed to create a views field override using this page which has overwritten my field successfully. But now I want to run a command I'm going to copy from my contrib module, the below to be specific, so that I can work out which User ID relates to which hashed code
return Crypt::hmacBase64($uid, \Drupal::service('private_key')->get() . Settings::getHashSalt());


texts:
I've installed CKEditor 4.3.5 on my Drupal 7 by simply copying it into the sites/all/libraries folder as described here: http://mtt.desk.com/customer/portal/articles/973377-how-to-install-the-ckeditor-on-drupal-7

I've done this successfully with CK Editor 4.3 and as of May 2014 it works fine with Wysiwyg 7.x-2.2.

I'm wondering if anyone has successfully installed CK Editor's widgets using the installation as in this method. There seems to be plenty of documentation for installing widgets if using the Drupal CK Editor module, which is an alternative installation route. However, I can't find any for this route.

Specifically, in the CK Editor widget tutorial, http://docs.ckeditor.com/#!/guide/widget_sdk_tutorial_1,
we are asked to register the widget in the extra plugins list, config.extraPlugins.
This seems to be placed wherever CK Editor is first called. So in Drupal, where do I place this code??
I tried the config.js file in sites/all/libraries/ckeditor but it doesn't seem to work.

I'd be grateful for any ideas.

Thanks and best wishes.


texts: Filter price according to Maximum Price of Product

texts:
I am using better exposed filters(https://www.drupal.org/project/better_exposed_filters) and have created a price filter and the range I have selected is 0 to 2000.But I want the maximum limit of the price filter to be the maximum price of the product on that page(I have multiple pages with different products).

Is there a way to do it using views?


texts: Where I can find examples of Drupal bootstrap levels?

texts:
I recently came through some Drupal apps that I needed to send some silent Ajax requests that performs a database update, and nothing else. Every such requests bootstraps Drupal to its full level which, as far as I can see, is a waste of resources.

Where I can find examples that someone would bootstrap Drupal, but not to its full level?

One example is the statistics module in core. ./modules/statistics/statistics.php. Do you know any others?

Please note this question is not about "how to bootstrap". Rather, in trying to see some examples of applications of it.

Thanks, and hats off everyone in advance.


texts:
I have an external application I have to add in my custom feature of Open Atrium. There is some JavaScript files I have already added to the module, and some CSS files.

To implement the application, I need to include an HTML file in the module's output. In which way can I do this?


texts:
Task: Create a view with link to it displayed among node tabs (View, Edit, etc.).

Solution: Create a view with page display and set its path to "node/%node/foo".

Issue: When the page "node/%node/foo" is visited, \Drupal::routeMatch()->getParameter('node') returns node ID instead of node object.

Is there a simple way to make it return the node object? (Currently I have to alter the view route and set the parameter type.)


texts:
Suddenly, I got my website down (drupal 6.19) and could not start mysql (too many tables got crashed).
by checking df -h, I found that the MySQL partition is full due to very large binary log files (I keep binary logs for one day only, expire_logs_days = 1); by checking mysqlbinlog for one of the bin logs I found out that most of the entries are for cache tables (cache_form, boost_cache, boost_cache_relationships, cache_content, etc) and for sessions table; some of the data is repeated many times.
by the way, i have watch ls -lh and the bin-log files got larger exponentially (every one or two minutes i got new binlog file with 100M file size!!)

Do you have any idea of what causes this? How can I fix this problem?


texts: Drush crashes after "command dispatch complete"

texts:
I have a custom drush script.
This script loads, changes and saves ~10000 drupal commerce products.

After that I get the message

Command dispatch complete [1140.43 sec, 663.25 МБ]                                                                                [notice]
 Timer                Cum (sec)  Count  Avg (msec)
 page                 1140.368   1      1140367.61
 drupal_http_request  67.66      1032   65.562
Peak memory usage was 784.48 МБ [1140.43 sec, 663.24 МБ]

And AFTER that script hangs and consumes more and more memory.
Finally, after long time, script reaches 1.5 G memory limit and dies.

PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 80 bytes) in /var/www/vhosts/mysite.ru/htdocs/sites/all/modules/contrib/entity/includes/entity.wrapper.inc on line 302

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 80 bytes) in /var/www/vhosts/mysite.ru/htdocs/sites/all/modules/contrib/entity/includes/entity.wrapper.inc on line 302

All products which were processed by the script are sucessfully changed.

The question: why drush script hangs when dispatch is complete and what it makes for such a long time when all products are processed?
Is it sort of a post-processing?

Denis


texts: Modify Userpoints List FormTo Show Entity ID?

texts:
How does one modify the List used to display userpoints?

eg.

http://example.com/user/123/points

I'd like to be able to modify that (table) to display the Entity ID (the source transaction id).

Apparently, it is generated as a form/table in the Userpoints module, right? I think that SQL field is already part of the query. But is there a way to hook into that form and add columns without hacking the module? How is that done?

The form ID is userpoints-list-transactions

I see a hook in userpoints.api.php

function hook_userpoints_list_alter

so I created a function in my own module (which I know is loading and working for other functions)

 function jch_utilities_userpoints_list_alter(&$output) {
    dpm($output);
    }

...and it never fires. What am I doing wrong?


texts: Other way to create a list of string other than taxonomies

texts:
Is there a method in Drupal to create s list of string dynamically and I would want to use a jsonapi to call it.

Expected output in jsonapi:

[
  "DOG",
  "CAT",
  "RAT"
]

When I added new string value, then it will be added in the top list of the api result

According to the answer on my previous thread in https://drupal.stackexchange.com/a/269610/70281, it mentions:

  To use your example,
  http://localhost:8080/jsonapi/node/article?fields[node--article]=body
  will return a JSONAPI document with all article nodes with only the
  body property in the attributes object.

But the output is a bit noisy.

{"data":[{"type":"node--symbols","id":"77d69b2e-ed9c-4173-b933-af89f634ba79","attributes":{"field_symbols":"EURUSD"},"links":{"self":"http:\/\/localhost:8080\/jsonapi\/node\/symbols\/77d69b2e-ed9c-4173-b933-af89f634ba79"}},{"type":"node--symbols","id":"dac4124d-9311-49b8-bd14-1fa5df2fc937","attributes":{"field_symbols":"EURGBP"},"links":{"self":"http:\/\/localhost:8080\/jsonapi\/node\/symbols\/dac4124d-9311-49b8-bd14-1fa5df2fc937"}}],"jsonapi":{"version":"1.0","meta":{"links":{"self":"http:\/\/jsonapi.org\/format\/1.0\/"}}},"links":{"self":"http:\/\/localhost:8080\/jsonapi\/node\/symbols?fields%5Bnode--symbols%5D=field_symbols"}}


texts: Creating first module, and How to alter text field on new content creation in Drupal 7?

texts:
I am trying to set the text in a custom content field when saving a node. I think I need to create a module to do this. (I am new to module creation.)

I started with a blank directory called - let's say myModule. I placed myModule into path sites/all/modules.

I placed into the myModule directory two files that I understand to be required and gave them the following naming conventions which I also believe to be the standard:
myModule.module
myModule.info

myModule.info holds the following text:
name = Some Descriptive Name
description = does stuff.
package = relatedName
core = 7.x

Inside myModule.module I have tried various things that are to much to elaborate , but include these exact functions and parameters.

Attempt 1:

function myModule_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
    if ($node->type == 'theNameOfACustomContentTypeICreated'){
        foreach ($items as $delta => $item) {
          //I am ver unclear at this point, and this function does not seem to be called when creating new content.
        }
    }

Attempt 2:

myModule_nodeapi($node){
    //this function does not seem to be called when creating new content.
}

I am at a loss. Neither function is even getting called - nor working.

Edit, the issue is resolved. The correct start was hook_jba_node_presave($node) , but I had syntax errors.


texts: How to add text to the user registration form?

texts:
I've been using the String Overrides module to change a few of the text fields in the user/register form. I've found this approach to be simple and effective.

However, I want to insert some text below the "User Account" heading but above the "Email" field. Just some general information about signing up. Unfortunately there is no text there currently so I can't use "String Overrides". Is there a simple way of adding some text? I don't want to create an entire custom registration form and reinvent the wheel, I just want to add some text to the existing form.


texts: Adding assets (css/js) for a custom module block (and withstanding a cache enabled install)

texts:
I've created my own block which calls a hook_theme implementation which then prepares some data and then renders myblock.tpl.php

All of the above is working fine but my module does have some required assets, specifically some css & js files, currently I was doing drupal_add_css/js in my hook_block($delta = 'view') but I've discovered that both the hook_block and hook_theme do not get called when the Admin > Config > Performance - Enable Block Cache has been turned on.

Obviously when I clear the cache the first load of a page (with my block included) loads all assets properly, but anon-users etc do not see any of my assets.

How should I be including these assets in a way that would withstand caching and only add assets on a page which includes my block?

Thanks!


texts:
I want to export a newly created content type which has bunch of fields to a new application installation. Also I need to export few views etc...

Exercise: I created a sandbox drupal 8 application. i have installed few modules to  my need and added a custom content type with few fields( taxanomy terms, file field, etc...). Added some content to test. I have finalized modules and content type.

Now In another environment, say dev, I installed drupal 8, used composer.json from sandbox and did composer update. this isntalled all the necessary modules in dev.

How do I export the custom content types with fields and also views that I created in sandbox.  I tried configuration synchronization. Imported the yaml files tar. I did not see any thing in sync tab and no content types.


texts: How can I render an image stocked in a custom module with an image style?

texts:
I'am learning Drupal 8, and I would like create a custom module who create a block to add share button. The link of this button should be an image who stocked in my custom module. I would like use an image style on my picture.

Last but not least, i want use a render array.

In my build() method of my customblock.php i have whrite :

//create url link
$url = Url::fromUri('https://www.facebook.com/sharer/sharer.php?u='.$base_url.Url::fromRoute('<current>')->toString());

//create uri image
$pathmodule=drupal_get_path('module', 'share_configurable');
$urifacebook=$pathmodule.'/src/img/facebook.png';

//render array of link
if ($this->configuration['network']['facebook']=='facebook'){
  $build['link_facebook'] = [
    '#title' => [
      '#theme' => 'image_style',
      '#style_name' => 'thumbnail',
      '#uri' => $urifacebook,
    ],
    '#type' => 'link',
    '#url' => $url
  ];
}

The link is create, but the image is not render... Can you help me please ?


texts: View does not display results when added as a block to a region

texts:
UPDATE 2: I'm not sure if this is relevant but when click 'demonstrate block regions' the only region it displays is content

UPDATE: I have just discovered that the block displays just fine when added to the content region. However when added to any other region such as the left sidebar or any custom region it does not display at all

I currently have a view that displays the results just fine in the view preview. It also works when I create a basic page and embed it like so:

<?php print views_embed_view('mobile_slide_menu','block');?>

However when I add this view to a region it displays no results. However I know that it's trying to display something because I see this in my source.

<div class="region region-slide-menu">

</div>

My info file that is defining the regions looks like this

;regions
regions[main_menu] = Main Menu
regions[header] = Header
regions[content] = Content
regions[help] = Help
regions[slide_menu] = Slide Menu
regions[footer] = Footer
regions[sidebar_first] = Left Sidebar
regions[sidebar_second] = Right Sidebar

and I'm calling the region like this

<?php print render($page['slide_menu']);?>

I'm using Drupal 7 and this is a custom theme I've built. I've cleared the cache multiple times.


texts: Views: How to sort in Table format naturally

texts:
Create view.
Select Format: Table.
Under the Table Settings toggle Sortable on.
Fields gets arranged/sorted unnaturally 1 2 3 4 40 5 50 51 6 60, etc. both ways ascending and descending.

The module Views Natural Sort does not solve the problem, it works only with fields under Sort criteria settings. And it's pretty broken in overall, the option to sort doesn't even appear in my Views.

We want to sort in normal natural way 1 2 3 4 5 6 7 8 9 10


texts: Protecting original images (D7, watermark, imagecache)

texts:
My goal is to have watermarked images and protected originals for a node image field in D7.

How to add a watermark to images has already been explained: add watermark to all images uploaded in the site

What I'm missing is how to protect the original images! These are still available via direct url.

Someone solved the problem for D5: http://drupal.org/node/424068 but the mentioned rights are not present in D7 anymore.

An other approach is presented in the comments of this page: http://drupal.org/documentation/modules/file

Create a private filesystem
Change the field's filesystem to the private one
Use the content access module to protect the node (a), or
create a custom module and use the file_download() hook to prevent access (b).

Possibility (a) doesn't work for me as I don't want to protect the access to nodes, but only to the plain original image files. Possibility (b) hides the imagecached images as well.


texts: Is there a way to attach HTML in  after the css links?

texts:
We currently can add HTML attachment to the <head> section like this.
function mymodule_page_attachments_alter(array &$page) {
  $page['#attached']['html_head'][] = [
    // some HTML declaration
  ];
}

But the attached items are always rendered before all the CSS and Javascript links. Is there a way to attach anything to after the CSS and JS links in <head>?


texts: How to allow HTML attribute with namespace using filter

texts: One of the analytics providers requires all the links to have a specific attribute sc:linkname to track details. Drupal 8 filter works for linkname but not with sc: prefix. From  https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 it looks like all attributes have default namespace (e.g. href => xlink:href).


texts: Apply page template suggestion to a specific view by a hook?

texts:
I have a website running Drupal 8.x with different views. I would like to use a page--template.html.twig template basing to the view ID. Is this possible?

I was thinking of using code similar to the following.

function mythemename_theme_suggestions_page_alter(array &$suggestions, array $variables, $hook) {
 if ($hook === 'views_view') {
   if ($variables['view']->id() === 'movies') {
     $suggestions[] = 'page__movies';
   }
 }
}


texts: What may cause duplicate nodes to be created using a Rules action to Create New Entity?

texts:
I am using a Rule, along with the Rules Block/Unblock User module, to create a specific type of node when a user is unblocked (a simple custom note called "Photo" that contains an image field and a token field for the title). The resulting node is authored by the newly unblocked user. The Rule is currently creating the node, but it is also creating a duplicate of that new node (with the same values). It is important that only one node be created, because I have imposed a limit on the number of nodes each user can create (5 total, including the node created by the Rule).

As a test, I removed the "user_was_unblocked" event and replaced it with "user_insert" ("After saving a new user account"), and that resulted in only one node (no duplicate), but it is important for my process that the node creation occur on unblock instead of creation.

What would cause these duplicates to occur?

Here is an export of my Rule:

{ "rules_create_default_public_photo_node_test" : {
    "LABEL" : "Create Default Public Photo Node TEST",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "user" ],
    "REQUIRES" : [ "rules", "rules_block_user" ],
    "ON" : { "user_was_unblocked" : [] },
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "node",
            "param_type" : "photo",
            "param_title" : "Default Photo for [account:name]",
            "param_author" : [ "account" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      }
    ]
  }
}


texts: Gating/Redirecting anonymous user back to an origin page after logging in/registration

texts:
I have a use case where I need to redirect a user visiting a page, let's say sprockets/order when a user clicks on an "order" link. We take them to a page with a login field (not user/login, but something with that form). Once they log in, we need to redirect them to that page, or for that matter, any origin page they click from to the login page.

I've looked into a couple of modules, right now Login Destination is the one i'm experimenting with, with no real success, even when its routing is configured to fire from this origin page. I'll keep experimenting with it, but I can't imagine its the only option at hand.

The question ultimately is, with the logic below, is there an approach I can take with how I send users to this specialized login page, and have them return to the origin?

The logic I have for this is as follows:

/**
 * Implements hook_menu()
 */
function hook_sprocket_menu() {
  $items['order/%order_id'] = array(
    "title" => t("Order Sprocket"),
    "page callback" => "example_order_sprocket",
    "page arguments" => array(1),
    'access arguments' => array('interact with orders'),
    "type" => MENU_LOCAL_TASK,
  );

  return $items;
}

/**
 * Routes the order call based on click
 */
function example_order_sprocket($orderid) {
  global $user;

  if(user_is_anonymous()) {
    drupal_goto("custom/user/login"); //The custom login/reg page
  } else {
    //Continue with Order logic here
  }
}


texts: How do I display the language settings (Site language field) on the user registration form?

texts:
I'm trying to display the user's language settings field on the registration page, but no success so far.

I've tried using a template (form--user-register-form.html.twig). This works for other fields, like mail, name, but I don't know how to access the language setting field.

I also tried form_alter (both in the theme and module MODULE_user_register_form_alter), and set $form['language']['#access'] = true; This hook doesn't seem to work at all, nothing happens when I try to use it (print out variables for example).


texts: Get taxonomy terms page based on exposed filters value

texts:
I've created two taxonomy vocabs: Language and Genre. LANGUAGE consists of the following terms: English,Spanish,French,etc and GENRE consists of Rock,Pop,etc.

Am using the taxonomy term page view with exposed filters for language and genre.

When am in a page that list all songs under the term english, the filter for genre and language also appears. All good till here.

Now, If i select spanish from the filter..i want the term page to reload and show the relative results.
 How can i work this out???


texts:
I would simply like to create a search bar (a text field) that when filled out will return a list of a certain content type on a new page.

Right now with Views I have created a search bar (text field) as an exposed filter but it also shows all the content with it. What I want is to have the search bar but have the results content show in a new window when the search bar is submitted.

Can this be accomplished with Views?


texts:
I'm running a apache2 server on Ubuntu. While I was in the middle of configuring new content on my local instance of drupal via Firefox, the site suddenly stopped working. My first thought was the the apache2 server was down, so I restarted it. Then I created an index.html, and index.php that both worked (outside the drupal directory).
Now let's say I go to localhost/drupal/ I get a blank page. However, if I go to localhost/drupal/update.php I get the update page. I found that out as I was trying to figure out if any page would load. /index.php does not work.
Any idea to what I should investigate next? What's weird is that I was in the middle of working on the site when it went down. I don't see a reason for that to happen.
Any help is appreciated.
Thank you!
Update: I found that apache log can be handy.
By typing into the terminal:sudo cat /var/log/apache2/error.log
I found that the log had the following error:
PHP Fatal error:  Cannot redeclare class QueryConditionInterface in /var/www/html/drupal/includes/database/query.inc on line 16

I tried replacing this file with the file from the original drupal package, didn't work. Nor should it have because I didn't change any code in this file.
Things I've tried:

Restart mysql and appache2 using sudo service mysql restart

Delete /drupal/includes/ and re-populate it with files from the original
package.


texts: How to change end date automatically after changing start date?

texts:
I would like to be able to automatically change the value of the end date to be the same as the start date after changing the start date.

Ex: right after changing the start date to 12-12-12, the end date would be the same.

Here's what I did so far:

Added the following code in a custom module (form_modif) :

$form['#attached']['js'][] = drupal_get_path('module', 'form_modif') . '/custom_alter.js';

Witch seems fine, I can see that the script is added in the code source of the page

The JS file's code is :

(function ($) {
  Drupal.behaviors.form_modif = {
    attach: function(context, settings) {
      $('.field_date_1').change(function(){
        $field_date1 = $(.FIELD_DATE_2').val();
        $('.field_date_2').val($field_date1);
      });
    }
  };
});(jQuery);

And that's where my problem seems to be, I'm not very good in JS, could someone help me with that?

Here's the HTML code of thoses fields if that can help:

Start date field:

<input class="date-clear form-text hasDatepicker date-popup-init" type="text" id="edit-field-date-und-0-value-datepicker-popup-0" name="field_date[und][0][value][date]" value="31/01/2014" size="20" maxlength="30">

End date field:

<input class="date-clear form-text hasDatepicker date-popup-init" type="text" id="edit-field-date-und-0-value2-datepicker-popup-0" name="field_date[und][0][value2][date]" value="31/01/2014" size="20" maxlength="30">


texts: How to programatically change a user image field to match the user's latest completed goal?

texts:
I created several goals with the Goals module. Every goal has an associated image.

My users have an image field 'Last goal' and I'd like to change it to the image associated with their latest completed goal. As this doesn't seem possible with the Rules module, I'd like to create a custom module. I found in the Goals API that I can use hook_goals_completed_goal($goal_id, $uid), but I'm stuck there.

How can I grab the user's 'Last goal' field and change it to goal_img?


texts: How to define caching for OutboundPathProcessor

texts:
I've got a customized OutboundPathProcesser that adds GET parameters to URLs starting from a specific node type targetting a specific node id. Basically whenever I'm on a node of type product, I add the node id as GET Parameter to all URLs leading to my enquiry node.

A simplified version of my code is below.

public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {

  $node = $request_stack->attributes->get('node');
  if ($node->bundle() == 'product') {
    if ($path == $enquiryNodePath) {
      $options['query']['product_id'] = $node->id();
    }
  }
}

This mostly works, especially for enquiry links inside the full view of my products. But for enquiry links in menu blocks, the parameters are cached: When starting on a product page after cache clear, the GET parameters is appended on every page, when starting on a normal page, the GET parameters is never appended.

I greenly tried to add caching similar to LanguageNegotiationUrl:

public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {

  $node = $request_stack->attributes->get('node');
  if ($node->bundle() == 'product') {
    if ($path == $enquiryNodePath) {
      if ($bubbleable_metadata) {
        $bubbleable_metadata
          ->addCacheContexts([
          'url.path',
        ]);
      }
      $options['query']['product_id'] = $node->id();
    }
  }
}

But this totally destroyed my site, it somehow corrupted the router table and even after disabling my module I was no longer able to rebuild the router table. I had to restore my site from a backup to fix the WSOD.

How do I correctly I make my OutboundPathProcessor / menu blocks cache-aware of the current node id?

(I do NOT want to disable caching for menu block with something like max-age=0)


texts: How to replace a Token in the PHP evaluation of a Rule?

texts:
I'm trying to grant Userpoints to users with a Rule. The Rule first calculates two integer values 'New value' and 'Old value'. Debugging these numbers shows that there's no problem with them. Naturally, I tried awarding the points with an action "Grant points to a user" and I'm using the following code in the PHP evaluation:

if ($value > 5) {
  return 0;
}
else {
  return token_replace('[new-value]');
}

where the default $value is old-value.  As the [new-value] token is available in the data selectors of the 'Points' section of the action, I suppose that one can use it in the PHP evaluation too. Therefore, after reading Token Replacements, I thought my code should work, but it doesn't: the Userpoints aren't granted to the user.

There's definitively something wrong with the Token, because the Rule is executed correctly when I use 1 instead of token_replace('[new-value]').

What am I doing wrong and how can I solve this?


texts: Menu link on hover is showing & instead of &

texts:
I have a Webform that provides a menu link. The webform is available in three languages (dutch, french, english).

For the dutch version I have a menu title of Informatie and description Vragen & Antwoorden.

But when I hover the link I don't get Vragen & Antwoorden. But i get Vragen &amp; Antwoorden.

He changes the & symbol to & . I also got this with ' . He changed it in &#039;.

How can I fix this?

UPDATE:

These are the menu settings of my webform:

UPDATE 2:

This only happens when I try to translate and use ' (apostrophe) in my translation. He will form the ' to &#039;.

Like this:


texts: How to disallow flags to get triggered if one of the user fields is empty?

texts:
I have a user flag "Status" and I have some fields for that user like name, phone etc.

How do I not let moderators trigger that flag if any of that user field is empty?


texts: Programmatically subscribing all users to Mailchimp list with module

texts:
I've installed the Mailchimp plugin and added a field to my user profile called field_mailchimp_test and I'm attempting to subscribe all current Drupal users to this list programmatically (since it seems this feature was taken out of the 7.3 branch for whatever reason).

I attempted this code:

function module_mailchimp_subscribe() {
  $users = entity_load('user');
  foreach ($users as $key => $user) {
    if ($user->uid != 1 && !empty($user->mail)) {
      $edit = array(
        'field_mailchimp_test' => array(
          'und' => array(
            0 => array(
              'value' => true
              )
            )
          )
        );
      var_dump(user_save($user, $edit)); exit;
    }
  }
}

Which returns a user object with the field_mailchimp_test field set to true, which I would think would subscribe them, but when checking the users page and/or var_dumping the user object, the field is no longer set to true.

So my question is either what is wrong with my code that it's not subscribing users, or what is a different (easier/more sensical) way of doing this?


texts: Load Preceding Nodes in a View Block Sorted by Date in Relation to the Current Node

texts:
Currently I have a basic View block just showing a bunch of articles in a teaser format. I added this view block to show up below the content of each article page. What I want is to be able to show the preceding articles in relation to the node you are currently viewing by the next future date.

The only extra thing in this view is that I added in contextual filters for NID. I am passing in multiple values into this view block, so YES i do have it "multiple values" checked off.

But I'm not sure why its not working. Technically it should be as it is in fact returning a string of NID's as outputted below:

if (arg(0) == 'node') {
  $node = menu_get_object();
}
$curNode = $node->nid;
$curNodeDate = $node->created;

dsm($node);

$type = "article";
$nodes = node_load_multiple(array(), array('type' => $type));

dsm($nodes);

$finalNid = array();

foreach($nodes as $products):
  if( intval($products->created) > intval($curNodeDate)  ){
dsm($products->created .'>'. $curNodeDate .'---'. $products->nid .'~~'. $products->title );
    $finalNid[] = $products->nid;
  }
endforeach;

foreach($nodes as $products):
  if( intval($products->created) < intval($curNodeDate)  ){
dsm($products->created .'<'. $curNodeDate .'---'. $products->nid .'~~'. $products->title );
    $finalNid[] = $products->nid;
  }
endforeach;

dsm(implode("," , $finalNid));

return implode("," , $finalNid);

When running that code I get the following dsm output:

1416508384>1416508382---65~~Rimmel's Georgia May Jagger & COTY partner with DBC
1416508383>1416508382---66~~Daisy Marc Jacobs Tweetshop Grabs the Attention of the Industry
1416508390>1416508382---68~~COTY's Mario Reis
1416508386>1416508382---71~~Beauty Trends for this Holiday Season
1416508385>1416508382---72~~COTY’s Catherine Walsh Honored
1416508388>1416508382---74~~ONE COTY - Looking at COTY as a Whole
1416508387>1416508382---75~~Roberto Cavalli
1416508389>1416508382---80~~A modern story of seduction
1416764226>1416508382---86~~Sir Ken Robinson
1416810455>1416508382---87~~COTY’s Svetlana Omelchenko makes the 2014 Top 100 OUTstanding LGBT Business Leaders List
1413318695<1416508382---2~~philosophy bringing hope & grace to mental health efforts
1413318711<1416508382---3~~Q&A with Ann Gottlieb
1413402303<1416508382---6~~Meet COTY CMO of Skincare
1416508381<1416508382---67~~Spotlight On Leadership: David Booth
1415666899<1416508382---73~~Creative Collaborations: COTY and Avon
65,66,68,71,72,74,75,80,86,87,2,3,6,67,73


texts: Drupal 7 Commerce Stock Decrease stock when reverting cancel the order

texts:
I have used drupal commerce module.
I have rules to increase stock when the order process is cancelled and decrease the stock after completed the order process.

When i cancelled the order status, the stock will be increased. It is fine.
When i trying to change the order status any of pending, processing, completed from cancelled, it didn't happened anything in my stocks.

But again when i changed status to cancelled, the stock will be increased.
So i want to write rule for "decrease stock when reverting from cancel the order process"

How to create rule for this edge cases?


texts:
In my drupal 8 Commerce, I have a view with product and filter criteria.

And I want to know, if it's possible to add result to this view with a result of webservice.

I try to inspect $view->result in hook_views_pre_render

and the result is view\ResultRow with entity Product

Is it possible to add results without creating an entity and from an webservice just read information like this schema:

/myviewurl

Product 1 (from drupal db)
Product 2 (from drupal db)
Product 3 (from drupal db)
Product 4 (from webservice not in db)
Product 5 (from webservice not in db)
Product 6 (from webservice not in db)


texts: How to restore $form_state when rebuilding a form after a redirect

texts:
We have a site where either authenticated or unauthenticated users can submit a form. When the form is validated, we check whether they are logged-in, and if not, we redirect them to authenticate, with a destination parameter of the original page. At this point, we cache the $form and $form_state in $_SESSION.

After authentication and redirection the form is redisplayed on the page (by retrieving the $form from $_SESSION) and ask them to confirm the submit.
Note the form is dynamically-generated which is why we have to store it.

What I can't seem to do on redisplay is set the form values to the choices that the user previously made, even though these are stored in the cached $form_state. What is the best way to do this?


texts:
I have a web app with a complex database that I created for a previous project. I'd like to integrate that old project into my new drupal site. I don't need it to be fully drupal-ized, but I need to at least leverage drupal's user authentication.

I'm trying to find a good tutorial about creating a module which provides an admin page and has a very customized UI. I don't need drupal to create form items for me. Any suggestions?

My UI fetches and updates all of its info via AJAX, so I need each of those AJAX calls to be at least minimally managed by drupal for user authentication purposes.

Does that make sense? Any suggestions?


texts: What security issues are involved with cross-domain logons using OpenID?

texts: I want to implement cross-domain logons for 3 sites. Is OpenID the best tool for protecting my site and users?


texts: Migration is not able to find legacy database tables for some migrations

texts:
The hosting server I am using is Pantheon.
I'm trying to migrate taxonomy over from D6 to D7 with a custom migration class.  The problem is that I'm getting different behaviors on my local repo and the one  on the server.  On the server, I get an error saying that

  Migration failed with source plugin exception: SQLSTATE[42S02]: Base
  table or view not found: 1146 Table
  'legacy_database_name.migrate_map_tdmchanneltermparent' doesn't exist, in
  /srv/bindings/3b34ee5b39e94f12ad1de632af512a5b/code/includes/database/database.inc:2171

I'm not sure why it is trying to connect to the legacy database for the map in this migration.

Here is my migration class:

class chalkTermParentMigration extends tdmTermMigration {
  public function __construct($arguments) {
    parent::__construct($arguments);
    $this->arguments = $arguments;

    $this->description = t('Chalk Term Parent Migration');

    $query = Database::getConnection('mig_dest', 'legacy')
      ->select('vocabulary', 'v');
    $or = db_or()->condition('v.vid', 10)
      ->condition('v.vid', 11, '=')
      ->condition('v.vid', 12, '=')
      ->condition('v.vid', 20, '=')
      ->condition('v.vid', 21, '=')
      ->condition('v.vid', 25, '=');
    $query->condition($or);
    $query->fields('v', array('vid', 'name'));

    $this->source = new MigrateSourceSQL($query);

    $this->destination = new MigrateDestinationTerm('chalk');

    $this->addFieldMapping('name', 'name');
    $this->addFieldMapping('field_legacy_id', 'vid');

    $source_key = array(
      'vid' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => 'Legacy Vocab ID',
      )
    );
    $this->map = new MigrateSQLMap($this->machineName, $source_key, MigrateDestinationTerm::getKeySchema());

  }

}

Here is how I have my legacy database connection information set up:

if (!defined(PANTHEON_ENVIRONMENT)) {
  $databases['mig_dest']['default'] = array(
    'database' => 'abc',
    'username' => 'abcdev',
    'password' => 'qwe123',
    'host' => 'localhost',
    'port' => '',
    'driver' => 'mysql',
    'prefix' => '',
  );
  $databases['default'] = $databases['mig_dest'];
} else {
  $databases['mig_dest']['default'] = array(
    'database' => $_ENV['DB_NAME'],
    'username' => $_ENV['DB_USER'],
    'password' => $_ENV['DB_PASSWORD'],
    'host' => $_ENV['DB_HOST'],
    'port' => $_ENV['DB_PORT'],
    'driver' => 'mysql',
    'prefix' => '',
  );
}

$databases['legacy']['default'] = array(
  'database' => 'legacy_db_name',
  'username' => 'uname',
  'password' => 'passwd',
  'host' => 'legacy_db_host',
  'port' => '',
  'driver' => 'mysql',
  'prefix' => '',
);


texts: how to find image style url from themed image

texts:
I've a code which theme & print the original image to specific image style.

print theme('image_style', array(
  'path' => $node->field_theme_image[$node->language][0]['uri'],
  'style_name' => 'home_theme',
));

I don't figure out how to get url of this new theme. I don't need to print the image but I need just url. Please suggest.


texts: error_get_last() doesn't show last warning

texts:
Drupal has its own custom error handler, so when I try to get the message from the last warning (e.g. for an invalid regex), there is nothing there:

if (@preg_match($regex, NULL) === FALSE) {
  dpm(error_get_last());
}

The @ prevents it from being displayed on the screen, and without that I can see a warning for a $regex of '/(/' (about an unmatched paren), but the warning is not shown by dpm(), but rather by Drupal.

Is there a way I can get the warning from an invalid regex in this example, so that I could have the message in a variable?


texts: Does the Bootstrap 3 Theme for Drupal meet WCAG 2.0 and ATAG 2.0 standards?

texts:
I'm currently creating a new website for work and I would like our drupal website to be accessible to users with disabilities, and I wanted to know if the Bootstrap 3 Theme meets web accessibility standards like the themes Zen and Adaptive.

I wanted to confirm that the Bootstrap 3 theme is accessible before moving forward with adding content.  I did not find any information on the Bootstrap 3 page on the drupal website specifying the accessibility aspect of the theme.


texts: Programmatically querying via SearchApiAcquiaSearchService

texts:
I am working on a site where querying using SearchApiSolrService is successful. However, when I deploy to Acquia Cloud and attempt to access the Acquia Search using the SearchApiAcquiaSearchService I get a 403 Forbidden.

Response

SearchApiException: "403" Status: Forbidden: Forbidden in SearchApiSolrConnection->checkResponse() (line 544 of ...sites/all/modules/contrib/search_api_solr/includes/solr_connection.inc).

The subscription information is correct (via Acquia Agent). Here's a piece of the code:

Code Sample

$server = search_api_server_load('my_acquia_solr_server');
$index = search_api_index_load('my_base_index');
$query = new SearchApiQuery($index);
$query = ... lots of random filters here that work for SearchApiSolrService calls so ignoring ...
$solr = new SearchApiAcquiaSearchService($server);
$result = $solr->search($query);

Thoughts?

Note: If you were to replace the SearchApiAcquiaSearchService with the regular SearchApiSolrService, the non-Acquia versions of the site integrate with Solr perfectly fine.


texts: How to handle private file uploads and downloads?

texts:
For a project I'm working on, I need to be able to:

Upload a file as Admin, assigning it to a user (this is working using the "author" field at the moment), attaching it to a node (ie. using the "FileField" field type)
Store the file in a private directory (not accessible by public users)
Allow the Admin and "author" users to download the files

We've setup a test project using Drupal 7 with a FileField on a custom content type. The FileField is set to use "Private" uploads.

What seems to happen is that the files are not accessible by their path on the disk (e.g. http://sitename.com/sites/default/files/filename.pdf) but are accessible by the Drupal private file download path (e.g. http://sitename.com/system/files/filename.pdf) - even when users aren't logged in, the private file download path still allows the file to be downloaded.

What we need to do is:
Stop users who aren't logged in, and aren't the author or admin of the node, from downloading the file from the private path.

We've already got a hook_node_view() in a custom module which stops people looking at the node if they don't have permission (i.e. the $user->uid matches the $node->uid) - it's just the private file path we need to hook and validate (check the user is accurate).

Any ideas what we're doing wrong?


texts: I'm looking for a module, that creates a special sitemap for media (using the Drupal Media 2 module).


texts:
All I want is to post a video embed, but the drupal form is forcing me to use an image for each, otherwise I can't upload my post.

Is there a way to override that field in particular?


texts: choosing image style during content creation

texts:
I am seeking for a method to enable users to:

choose image style (thumbnail, medium, large, ...) during content creation
change this style anytime during content update

Right now, with "Image" module on, the image field style can be decided only during content type creation.

I tried to use "Media" module 7.2, and there is possibility to choose image style during content creation, but no possibility to change it later.


texts:
I'm syncing a Drupal 8 webform to populate a MailChimp lits via the MailChimp module. As well as capturing the first and last name I also want to capture the City and Province.

However when I submit I only seem to capture the email address in MailChimp.

In Drupal 8 I configured my form for each field as the following:

Email Field (this works)
Title: Email
Key: email
Type: Email

First Name (this does not transfer to MailChimp)
Title: First Name
key: fname
Type: Text field

Last Name (this does not transfer to MailChimp)
Title: Last Name
key: lname
Type: Text field

In MailChimp I set up in the List fields and |MERGE| tags the following:

First Name *|FNAME|*
Last Name *|LNAME|*

Has anyone else had issues with merging fields from Drupal 8 into MailChimp via the MailChimp module?


texts:
I made some migration of pretty old website to d8. And urls ported fine from latest WP version:

/user1/article-name1
/user2/2009/article-about-something
/user3/2017/11/06/article-something

But from what I see in google many articles would be linked with index.php at the end i.e.:

/user1/article-name1/index.php
/user2/2009/article-about-something/index.php
/user3/2017/11/06/article-something/index.php

etc etc. Somehow WP could handle it (no traces of overrides in htaccess), but Drupal would not.

Puzzled how to fix it with htaccess, preferably with 301 redirect.

Thanks for your ideas!


texts: How to load a field from a user that is being viewed

texts:
I am looking to load a field from a user's profile that is being viewed.For example, I am looking at another users profile and it will load their associated field.

I am programmatically adding a picture to the tpl (probably should be template.php) and then I am adding it to the background-image of a div. My code loads the user but then switches the user to user being viewed. It is obviously not good to be able to switch users.

Here is my code:

<?php
   $user = user_load(arg(1));
   $picture = field_get_items('user', $user, 'field_picture');
   $file = $picture['filename'];
   $url = $base_url . '/files/' . $file;
<?

I cannot find a secure way to do this. Anyone have an idea?

Thank you for your time.


texts: Hook to import entity data in custom module installation in Drupal 7

texts: What would be 'the best' hook function to use in the custom module installation to import entity data? This is supposed to be a one-time activity during the module installation only, after entity schema is built in the database and entities are initialized (to be able to use Entity API in the data import).


texts: New Relic performance monitoring and the Features Module

texts:
We've just started using New Relic to monitor our D6 sites, and are also taking advantage of New Relic's ability to report on Drupal module performance.

Our sites contain several modules with configuration exports that are controlled by Features (views, content types, etc).

New Relic's module performance page shows features.module as being the slowest and as having the highest function call count.

It was my understanding that Features doesn't do too much of anything except for when you are creating/updating/reverting your features, so I'm confused as to why New Relic would report it as being such a drag in terms of site performance.

Can anyone confirm that Features does indeed significantly impact site performance? Or confirm that it doesn't (in which case this seems like a New Relic issue).


texts: Drupal 7 Feeds importer handle file types additional fields

texts:
I have feeds importer which imports images. It works. The image field in the content type related to file type "Image".
Recently we decided to add few additional fields (copyrights, caption) to file type "Image".
I'm trying to find a way how to import the data to additional field of file types.
1) I tried to check "/mappers/link.inc: file, it provides an opportunity separately import "URL" and "Title" for the link field, but link field is not file type. Anyway it was a good start.
2) Then I checked "/mappers/file.inc", but this file doesn't handle additional fields.

I can create a custom mapper for this case, but I'm not so familiar with Feeds API.

Does anybody already tried to handle additional fields for file types?
or Does anybody know any module which does it?


texts: How do I get the current taxonomy term from the plug-in context?

texts:
When on a node, the following annotation will obtain the node from the context:

/**
 * @Condition(
 *   id = "node_type",
 *   label = @Translation("Node Bundle"),
 *   context = {
 *     "node" = @ContextDefinition("entity:node", label = @Translation("Node"))
 *   }
 * )
 */

As shown here: https://www.drupal.org/docs/8/api/plugin-api/plugin-contexts

Is there an equivalent way to do this with taxonomy terms when on /taxonomy/term/%?

The code below certainly works but I'm wondering if there is a cleaner method like for nodes. Note that I'm also aware of the Term::load($tid) method but that still requires parsing the URL to obtain the tid and isn't portable (the code can be used only when run on a page).

  /**
   * Return current term.
   */
  public function getCurrentTerm() {
    $term = null;

    // Below we are using the general method to obtain the objects.
    // \Drupal\taxonomy\Entity\Term::load($tid) is the other

    // Get the unaliased path in the form /taxonomy/term/tid.
    $current_path = \Drupal::service('path.current')->getPath();

    preg_match('/\/taxonomy\/term\/\d+/', $current_path, $matches);

    // Return null if not in proper form.
    if (count($matches)) {
      // Find the parameters for this route.
      $params = \Drupal\Core\Url::fromUri("internal:" . $current_path)
        ->getRouteParameters();

      // Fetch the taxonomy object.
      $entity_type = key($params);
      $term = \Drupal::entityTypeManager()
        ->getStorage($entity_type)
        ->load($params[$entity_type]);
    }

    return $term;
  }
}


texts: Custom JS not loaded when JS aggregation is enabled

texts:
I have a couple of custom JS files in my theme that works as they should.
Except that when I enable the JS aggregation (in Config -> Performance) to speed things up these JS functions stop working, and the files are not even loaded, as far as I can see (I have tried to search for keywords in Firebug script tab to see if the functions are still being executed). I have chosen to simply include them in the theme's info file.

So my question is... must I add my custom JS files in some other way in order for the JS aggregation to include them?


texts: Comments on Arabic version of page are not shown under content after admin approval

texts: I am working with drupal8 website. Here am using both arabic and english translation. Authenticated users have the permission to post and view the comments. When an auhenticated user posted a comment to an arabic content and after admin approval the comment is not showing for authenticated users side. Admin can see the comments only authenticated users have this problem. There is no issue with english comments. Could i miss anything here?


texts:
I need a mechanism for managing users' storage space.  I have multiple content types with file upload fields.  Admin should be able to set it globally, or per individual user.

My initial approach is to add a field in the admin configuration menu, for admin to set the default limit, and a field for users for individual space allocations.

When a user goes to create new content, I check their used space to see if they are maxed out.  Then when they are about to upload a file, I'll check the file size and see if it will put the user over the limit.  If not, I let the upload occur.

The Drupal API gives us a file_space_used() function, which gives the total file space used by a particular user, so that's pretty cool.

Am I on the right track?

EDIT AFTER ANSWER: syd asked me to post my script, and I forgot.

function mymod_file_validate($file)
{
    global $user;
    $ulimit = 0;    // user limit

    // get the limits per role (I had two to check against, and vals are
    // in megabytes (hence the *1000000))
    if (array_search(HL_ROLE_REG, $user->roles))
        $ulimit = variable_get(HL_VARKEY_REGSPACE) * 1000000;

    if (array_search(HL_ROLE_PREM, $user->roles))
        $ulimit = variable_get(HL_VARKEY_PREMSPACE) * 1000000;

    return (file_validate_size($file, 0, $ulimit));
}


texts:
I have created a custom block of id downloadourapp and I would like to show/hide it base on certain statements.

I have create my custom module along with .module file where the code should be, however, I failed to find the right function to be used for that matter.

is hook_block_view_alter is the right function and how to hide or show this downloadourapp specific block.


texts: Having issues saving altered value in a view pre render

texts:
I am trying to remove image tags in the view prerender. I've looked through articles and StackExchange and I have set it up correctly. But when I refresh the page containing the view, all the HTML tags are now present as a string.

Here's my code.

function mytheme_views_pre_render(Drupal\views\ViewExecutable $view) {
  if ($view->id() == "news" && $view->current_display == 'block_1') {
    foreach ($view->result as $row) {
      $body = $row->_entity->body->value;
      $stripped_img = preg_replace('/<img[^>]+\>/i', '', $body);
      if ($stripped_img != $body) {
        $row->_entity->body->setValue($stripped_img);
      }
    }
  }
}


texts: How and where should I override the character length of the description field for an exposed filter

texts:
I've got an exposed filter with labels and descriptions in my Views. My design requires that the descriptions be displayed as tooltips on hover. In addition, I want this to be the general rule for all my exposed filters in all my views, so the fields that are exposed to visitors is different in each view (probably 10-12 different views with exposed filters). I've got all that working. However, I've run in to a problem with the character limit of the description field for the exposed filter and thus far, I've not been able to find a way around it. So my question is how and where should I override the character length of the description field for an exposed filter in my View?

I've found to possible places where this character limit is set. However, because it's in the core of the Views module I don't want to just change a setting only to have it overwritten the next time Views is updated.

Here are the two places I've found:

/Applications/MAMP/htdocs/d7_chp/sites/all/modules/views/includes/admin.inc:
  313    $form['name'] = array(
  314      '#type' => 'machine_name',
  315:     '#maxlength' => 128,
  316      '#machine_name' => array(
  317        'exists' => 'views_get_view',

and

/Applications/MAMP/htdocs/d7_chp/sites/all/modules/views/plugins/export_ui/views_ui.class.php:
  431      '#type' => 'machine_name',
  432      '#required' => TRUE,
  433:     '#maxlength' => 128,
  434      '#size' => 128,
  435      '#machine_name' => array(

I've looked at a variety of other options as well as adding additional fields to the content type but these are not options. Other than the fact that adding additional fields would be sloppy, the description field in the exposed filter perfectly fits what we need here and we were able to repurpose the tooltip styling and formatting we've created for other content in this piece so we believe that this is the best solution for our scenario and would prefer not to have to rebuild all the tooltip stuff we've already created for this instance.


texts: Is it possible to show views exposed filters in the facet current search block?

texts:
I have a facet search with Facet API, Search API, and a Solr backend with the Search API Views integration.  I am using the Current Search block (part of the Facet API module) to display the currently selected facet options.

However, I am also using Views, and I have two exposed filters with the autosubmit button on the page.  The problem is that users can select one of the views exposed filters and it will not appear in the Current Search block, so it is not obvious to the user that the results are being further filtered.

I am also using Facet API Pretty Paths, so I have a path that looks like this:

  myexample.com/s/n/1/b/2&items_per_page=8&jp=1&d=-

n/1  and b/2 are facets, &items_per_page=8 is the views pager, and &jp=1 and &d=- are the views exposed filters.

My goal is to somehow make it clear to the user that Views exposed filters are affecting the results.  If it's possible to modify the Current Search block, I would like to do that, but if not, creating a separate block/ctools content type to notify the user that the exposed filters are applied would also be acceptable.

I'm not aware of any modules that show the applied exposed filters, so I'm thinking about writing code to check the query string for jp and d and then printing messages based on the results.  If there is an easier approach, I would be glad to hear it.


texts: Views Exposed Filters AND result for multi select field

texts:
I'm working with a view with exposed filters for a directory style page.

One of the filters is a multi-select check list, however, we want the results to return AND results only. It is currently returning OR.

For example: Activity open to:
- Men
- Women
- Older People
- Children

So I only want to see results that have both selected.

All the testing I've done returns OR options, so they can have Men OR Women. I want Men AND Women returned.


texts: Conditionally send results to specific emails

texts:
Hello Looking for some advice on how to deal with sending conditional emails. I did some research and it can be done in Drupal 7 with Rules but since I'm new to Drupal 8 I haven't been able to figure it out.

Here is my scenario

I have a select list called - TOPICS

In that select list I select SPONSORSHIP

When I click submit result goes to a specific email based on that selection

OR if I select a different topic say ADVERTISING it goes to a different email based on that selection.

Thank You in advance for any help!


texts:
i have a basic admin form, which shows all content types with checkboxes and save button:

function MYMODULE_admin_settings() {
    $types = node_type_get_types();

    $form['content_types'] = array(
        '#type' => 'fieldset',
        '#title' => t('Content types'),
        '#description' => t('test'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
    );
    foreach ($types AS $typename => $type) {
        $form['content_types'][$typename] = array(
            '#type' => 'checkbox',
            '#title' => $type->name,
        );
        }
        $form['submit'] = array(
            '#type' => 'submit',
            '#value' => t('Submit'),
        );
        return $form;

}

When i submit i want to save checked content types somewhere(i don't know what is the best way - save to database or somewhere else like variable_set). And the question is how to show checked content types after submit form - #default_value. For example if i check Article and Basic page c.types submit it and save them to db i want to see them checked after page reload, how can i do this?


texts: When using a dev version of a module, how can I easily get a notification of the next stable release?

texts:
From time to time I need to install a dev release of a frequently updated module (Views, etc.) Usually, this is because I need a patch that has been applied to the dev branch that has not yet made it into a stable release.  For this reason, I don't want to stay on the dev branch, and I don't want to keep updating to new dev versions-- once I have a dev version with the patch, I am happy to keep that version until the next stable release.

I usually use drush up to get a list of modules that need updating.  However, this will prompt me to update to newer dev releases.  Is there any way to tell drush to ignore a dev module until its next stable release?  I assume nothing that convenient actually exists, so how else can I handle this situation?  I have a large number of modules and it's a real pain to check for updates manually.


texts: Which user does the Rules module execute as?

texts:
I've set up a rule which is triggered by "after saving a new user account". This rule simply sends an e-mail. The e-mail contains various tokens, one of them is the field [account:field_country].

I've enabled "custom permission" for this field, and through the Field Permissions module I've configured the following permissions :

All users (selected permissions):

Create own value for field Country
View own value for field country.

Moderators (all permissions) :

Create own value for field Country
Edit own value for field Country.
Edit anyone's value for field country.
View own value for field Country.
View anyone's value for field Country.

The problem is : the [account:field_country] gets replaced with an empty string when the rule sends the e-mail. Only when I let all users View anyone's value for field Country does the rule properly replace the token with the actually selected country value.

Why do I need to do this? Which user does the rule module run as since the rule apparently need to View anyone's value for field Country to be able to get the value for that field.


texts: Migrate old admin's posts to his new user

texts:
I'm taking over maintenance of a Drupal site but the old admin is staying on as a user.

I need to adjust the ownership of the posts currently under uid 1.

Is this query sufficient or is uid associated with a blog post in other ways?

Is there an admin module for this process?

UPDATE `drupal_node_revisions` r,
`drupal_node` n
SET n.uid = 13392, r.uid = 13392
WHERE
r.uid = 1
AND n.uid = 1
AND n.type = 'blog'
AND r.nid = n.nid


texts:
Back in Drupal 7, I was able to create a link  (Ajax enabled) like this:

$page['profile']['links']['videos'] = array(
        '#type' => 'link',
        '#title' => t('Videos'),
        '#href' => 'profile/videos/' . $uid . '/nojs',
        '#attributes' => array('class' => array('use-ajax', 'profile-button-videos')),
        '#prefix' => '
',
        '#suffix' => '
',
      );

Though there are plenty of examples about how to create a link from a URI, or external URL; and how to attach attributes, I can't find a shred of documentation on how to append something as simple as "nojs" on the end of the URL...

My code so far is this in Drupal 8 (and it works). But, it lacks the /nojs on the end.

Note: I an not using the the Forms API; strictly Render Elements.

$url = Url::fromRoute('people.profile', ['uid' => $uid]);
    $render_array['people']['bio'] = [
      '#title' => $this->t('Publications link'),
      '#type' => 'link',
      '#url' => $url,
      '#attributes' => array('class' => array('use-ajax', 'profile-button-bio')),
    ];

The end result should be a link that looks something like this:

  /profile/publications/{uid}/nojs


texts:
I have a website in Drupal 7 with "N" images in Sites/default/files and I need move this images to CDN.

Is this possible?