texts:
I want to create a block that contains somes links of a menu, without using the interface.
So I created a custom module. Inside, there are somes files.

a mymodule/test.links.menu.yml :

test.menu.listown:
  title: list
  route_name: test.listown

test.menu.addnew:
  title: Add new
  route_name: test.addnew
  weight: 0
  parent: test.menu.listown

and a mymodule/src/Plugin/Block/test_block_main.php

class test_block_main extends BlockBase {
  public function build(){

    $mp = \Drupal::menuTree()->getCurrentRouteMenuTreeParameters("test.menu.listown");
    $test = \Drupal::menuTree()->load("test.menu.listown", $mp);
    $render = \Drupal::menuTree()->build($test);

    return array('#markup' => \Drupal::service('renderer')->render($render));
  }

}

I cleared caches (drush cache-rebuild). When I go to my homepage, the "test_block_main" is displayed, but it is empty. Why is my custom block empty? Is the "test.menu.listown" parameter passed to the methods not correct?


texts: Remove duplicate records from views feed display for node with multiple grouped terms from one vocabulary

texts:
I have an RSS feed display in a view, and one of the fields in the view is a multi-value taxonomy reference field. The feed settings have a "Grouping field" setting, and I've chosen that field (and I also have DISTINCT selected in the query settings), but I still get duplicate records.

When I run the query in MYSQL, I can see that it returns one record per term, so I'm guessing the grouping like that is handled in the display layer that an RSS view doesn't have (even though it does have a grouping setting).

That being said, what is a good place to filter out duplicate results? I saw the Views Distinct module, but it doesn't have a D8 release. In looking at the views hooks, it looks like hook_views_pre_render would be the best place, because at that point the query is run and the $view object has the results.

If anyone has experience with this or a better way, I'm open to suggestions.

Thanks.


texts: How do I give the permission to add points, but not to moderate them?

texts:
When I give users the permission to administer user points, they can both add and moderate points. How do I give them only the permissions to add points, but give other users the permission to moderate points?

Can someone tell me how to use the hook_menu stuff, to set permissions? My email is lucas.famelli@gmail.com


texts: Only show view tab for current user profile

texts:
I created a HTML table view to show the current "listings" the user has created. I have everything set up (I think), but I am looking in how I can restrict access. The view is suppose to be a tab on the user profile page with the title of "My Listings". I need to only show it to the profile owner and also make it so people can't access it via URL itself (bypassing the tab)

I remember this was doable back in the Drupal 6 days, but my memory fails me.

Path: /user/%/listings (contextual filter % is set to UID)

So if user 1 goes to /user/1/listings They should see a tab next to View | Edit that says "My Listings"

But if user 4 goes to /user/2/listings they shouldn't see the "My Listing" tab. But if they go to /user/4 they should see their "my listings" tab.

Thanks for the help.


texts: How to create a render array for a location CCK field?

texts:
The situation should be common: I have a content class with one location field; in the page view of the class I show the location on map. But, at the top of the page, I want to print the address too.

In the 'manage display' of my content type, I can choose for 'map only' (formatter location_map); which is perfect for the map, or for 'default (address only)' (formatter location_default), which is perfect for the top of the page.

It is probably as easy as, something like, in the node.tpl.php, saying

// address here
$content['field_location']['#formatter']="location_default";
drupal_render($content['field_location']);

// google map here
$content['field_location']['#formatter']="location_map";
drupal_render($content['field_location']);

but that doesnt work. I also notice Location has a theming hook, described here

http://drupal.org/node/62486

unfortunately they forget to mention what goes in there. whatever i put in there, it doesnt pass to location.tpl.php (allthough it does pass that template in vain).

I have a workaround thats so ugly I'm not even going to post it here :-)
Does anyone know how to do this properly ?

*-pike


texts: How to split Views exposed filters into separate blocks

texts:
I would like more flexibility of my exposed filters so styling and organization can be better.

I will be using 3-5 exposed filters and rather that oranizing them by CSS only i thought it would be nice to have each one in separate blocks.

My reason for this is to display filtering options the way most are use to, Ascednig/descending and small to large(or cheap to expensive) up top fairly small

and on the left side a detailed selection of sub category options (size, brand etc...)

If there is a better solution im all ears.

Im using:
- Drupal 7
- Views 7.x-3.8
- better exposed filters


texts:
I am trying to load a node using the revisioning module to display an unpublished piece of content, by passing a version ID to node_load(). We also use the i18n module which may or may not have an affect on what I am trying to achieve. We are looking to implement a "preview" of a page which may be sent out to departments that do not have a user account of any sort (We do not want to create a login for this). The preview page is requested with the version &vid=12345 and a &preview URL parameter.

At the moment, if the specific revision is not published, the preview page will load the currently published content instead of the version we are passing to node_load().

I have tried to create a preview user with view unpublished permissions, but this does not work (still loads the published content).

Is it possible to prevent the fallback and load the specific revision?

UPDATE:
Thank you for the renewed interest. So we are using the "entity_translation module" and have extended this to include the preview functionality. This allows a page URL to be called with the node id and version id. These are both passed to node_load.
The node is then displayed via calls to $output = _revisioning_view($node); and finally drupal_deliver_page($output);


texts:
I have a type capitolo that has a field link (an external URL) and a numeric field. Each capitolo has its own link.

When I create a capitolo with number=1 and link = www.example.com/something/1 I would like my site to fetch that url to check if www.example.com/something/2 exists, and in that case create another capitolo with number = 2, then check www.example.com/something/3 and if it exists create another capitolo with number = 3 and as link that link etc. This loop should stop when there is no link with that given number.

All this is possible presuming that the links have all the same pattern obviously.

I would like to do so to automate the insertion of the capitolo type, because if, for example, there are 100 links avaliable for that site, a user should add that capitolo manually 100 times.

I would also like the starting url that has to be fetched by the site to be in any form. I mean, it could be www.example.com/something/1 or even www.example.com/something/otherstuff/12
or idontknow.org/a/b/c/d/e/2/f/5.

In this last case, the site should insert a capitolo with url idontknow.org/a/b/c/d/e/2/f/5, number=5 and look for idontknow.org/a/b/c/d/e/2/f/6, idontknow.org/a/b/c/d/e/2/f/7 etc...

Any ideas on how i could achieve that? I really don't know where to start from.


texts: How to user listen the songs after purchasing their songs or products using Drupal commerce?

texts: I am using Drupal commercekickstart.. I have installed Commerce file module  and Commerce license module also.If user purchasing their product after that their can download the files at the same time user can listen the songs through player inside this project.Is it possible? Anyone guide to me?


texts: "Upload Images" tab blank when adding media

texts:
I have successfully updated my Drupal 7.24 site to use Media 2.x dev (2014-Mar-19) and Media Gallery (2014-Feb-26). The existing galleries are displayed perfectly.

The only issue I'm facing is that when I click on "Add Media" in a gallery, the "Upload images" tab is blank. All the other tabs ("Embed from URL", "Library", "My Files",  "Library (MBP)", "My Files (MBP)") are visible and I can select existing pictures.

The blank tab is keeping me from uploading new images.

All modules required are installed (File Entity, Media Bulk Upload, Plupload). There are no errors in the log nor in the Apache access log.

Does


texts: How to change the widget of a multimedia asset from media browser to multiupload

texts:
On Drupal 7 I installed and enabled the multiupload_imagefield_widget
Now I would like to alter the widget type for the news articles from "Media Broswer" to "Multiupload".
I understand that I can add a new field and delete the old one, but I have a lot of previous articles with uploaded images to them.
Or maybe I'm looking at this the wrong way?

Any help would be greatly appreciated.

Edit: screenhots


texts: How to reset form page after it has been successfully submitted?

texts:
User is allowed to submit answers from the question node view page.

The form is redirected to the same question node view page after submission. But the form displayed still displays the older values. How can I reset these values?

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

  if (arg(0) == 'node' && is_numeric(arg(1)) && $node->type == 'question') {
    global $user;
        if(node_access("create", "answer", $user)) {
        $node1 = (object) array(
            'uid' => $user->uid,
            'name' => (isset($user->name) ? $user->name : ''),
            'type' => "answer",
            'language' => LANGUAGE_NONE,
        );
        $form_state['build_info']['args'] = array($node1);
        form_load_include($form_state, 'inc', 'node', 'node.pages');
        $form = drupal_build_form('answer_node_form', $form_state);
        $output = drupal_render($form);
        $node->content['answer_form'] = array(
            "#type" => "markup",
            "#markup" => $output,
        );
      }
   }
}

function answers_custom_form_alter(&$form, &$form_state, $form_id) {
   if($form_id == "answer_node_form") {
       if (arg(0) == 'node' && is_numeric(arg(1))) {
        $nid = arg(1);
        $node = node_load($nid);
        if($node->type == "question") {
             $form['#submit'][] = "answers_custom_destination";
        }
       }
   }
}

function answers_custom_destination($form, &$form_state){
   if (arg(0) == 'node' && is_numeric(arg(1))) {
    $nid = arg(1);
    $node = node_load($nid);
    if($node->type == "question") {
        $form_state['rebuild'] = TRUE;
        $form_state['redirect'] = drupal_get_path_alias('node/'. $node->nid);
     }
   }
}


texts: How do I use the mail manager without the $to value?

texts:
I want to send an email for multiple users without a to address. Setting $to NULL, and empty string 'undisclosed-recipients:;' doesn't work.
How can I send an email with just BCC recipients?


texts: Drupal 7 drop down menu not showing on other pages

texts:
I have the main menu with 4 links (home, services, portfolio, contact)

under "services" I created a sub-menu, (service1, service2, service3)

The problem is that the little arrow that drops down the sub-menu shows ONLY on the "services" page and NOT the other pages.

How to fix that? thanks.


texts:
I need to update data in HP Quality Center with Drupal.

After login with success, I get some data from QC with the following code (simplified):

$headers = array('Cookie' => $cookie);
$request = drupal_http_request('http://qc.intra.xxx.com:8090/qcbin/rest/domains/' . $domainname . '/projects/' . $projectname . '/test-instances?query={cycle-id["' . $id . '"]}',
    array('headers' => $headers),
    'GET'
);
$xml = simplexml_load_string($request->data);
$json = json_encode($xml);
$testset_array = json_decode($json, TRUE);

What I want now is to update some QC fields. For that, instead of GET, I need PUT. The code I've tried to update a test instance:

    $xml_data = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
            <Entity Type="test-instance">
                <Fields>
                    <Field Name="my_field">
                        <Value>my value</Value>
                    </Field>
                </Fields>
            </Entity>';

    $headers = array('Cookie' => $cookie, 'content-type' => 'application/xml');

    $url = 'http://qc.intra.xxx.com:8090/qcbin/rest/domains/' . $domainname . '/projects/' . $projectname . '/test-instances/404886';
    $request = drupal_http_request($url,
       array('headers' => $headers),
       'PUT',
       $data
    );

    $xml = simplexml_load_string($request->data);
    $json = json_encode($xml);
    $testset_array = json_decode($json, TRUE);

This is not working and I don't get any error also, what am I doing wrong?

Thanks


texts: What are best practices for reusing blocks between sites?

texts:
What's the best way of reusing blocks between sites in Drupal 7? I want to re-use not only the block, but also the block's position in my theme.

Apparently, Features extra is designed for this. However, on the project page, it says that UUID Features Integration is the future of the module.

UUID Features Integration, however, doesn't seem to work (although a patch is available to fix things). Also it has been dropped in favor of Deploy.

Deploy, however,doesn't seem to work with blocks and is designed more for exporting nodes. So, I'm not really sure how it is a replacement for UUID Features.

What is the best practice for what I want to achieve?

PS. this is a new version of the question "Latest Best Practise: Reusing content/functionality between Drupal 7 sites", as I was told to post it as a separate question.


texts: Module to suggest node revision to node author

texts: Is there a module which facilitates functionality of allowing users to suggest node revision to author and author finally can publish the revised suggestion. Till the author is not accepting or rejecting the revision the existing node will be displayed.


texts: How to login by single role if user have multiple roles?

texts:
In my latest project client asked me to add extra interface after login where all roles assigned to that user will be shown and user can choose the single role and login by that role only. But i don't know how to do this in drupal. I tried with role switcher and other module but they didn't  work for me ? Any suggestions will be appreciated.

Suppose
User x have roles A B C D
x can choose single role(eg A) after login and do the work only with that role.


texts:
What is the correct way to render a Drupal 7 image field and show the default image if the field is empty?

If I use field_get_items it will simply return FALSE when the field is empty.


texts: Is there a way to get zebra striping on a custom panels layout?  I've been looking hook_preprocess_panels, but I don't see a way to tell if I'm a certain layout is being used.  I don't want it on all layouts, just one in particular.  I have the layout made, and I figure if I can add a css even/odd class to a node in the panel, I should be able to get what I need.


texts:
I'm trying to add a button class to an internal file URL. The field itself is a normal file field type. Below is the twig code that I have tried to use with no success. I'm also using this code in a twig field template.

{% for item in items %}
 {{ item.content['#title']}}
{% endfor %}


texts: Unable to uninstall the Field Collection module

texts:
I want to remove field collection module in Drupal 8 as the module has been deprecated. When I try to uninstall after removing the fields from content type the option to uninstall is greyed out.

I get an error

  field_collection: There is content for the entity type: Field
  Collection Item. Remove
  field collection item entities.


texts: How can I get two different countdowns on the same page?

texts:
I am using the jQuery Countdown module, and I want to add two (or more) countdowns to my webpage.

I am using the following code for the first countdown.

echo '
10 seconds!
';
jquery_countdown_add(".countdown", array("until" => $a, "onExpiry" => "finished"));
drupal_add_js("function finished() { alert('You are done!'); }", 'inline');

If I use that code for 2 or more countdowns, they show the same countdown, not different countdowns.


texts: Dynamic, Conditioned Drupal Webforms Select Options

texts:
I'm a beginner in Drupal and I'm working on a project for a hospital, and I'm stuck in some issues that I didn't find any answers to, so here is my problem:

What I've done

created roles (doctor, patient, manager).
created a taxonomy vocabulary "specialty" that contains medical specialties as terms e.g eye department, surgery department, etc.
installed modules (Views, Webforms, Webforms term options) to create a medical appointments booking form that accepts name, mobile number, specialty, doctor, date and time.
for the specialty field I added an automatic Webform term option to take the values from the taxonomy vocabulary.

What I want to do

I want to assign doctors to a specific specialty, e.g. doctor_x & doctor_y are working in eye deptartment, doctor_a & doctor_b are working in surgery, and so on.
when the patient chooses eye dept. in the form, the 'doctor' option is filled with the doctors that work in this dept.
when the patient selects the same time & date for the same doctor a message should be shown: "This appointment is already reserved please choose another one!".
create a views page of the submissions of every doctor that appears on his account (no one can see it except him) arranged and separated by day.


texts:
I have Search API users index. I am trying to show them in views with my display mode (for example 'teaser') created by Display Suite.

But I only can show fields. For default user view I can show all modes: fields, display suite, rendered entity and so on.

How I can show them via rendered entity?


texts: Upload a drupal site to the server to test

texts:
I have finished the drupal website on my localhost. I want to upload everything to the server, but only to test before officially launching it. Is there a way that I can keep my current non-drupal website running normally, but also upload this drupal site and test it at the same time?

If I create a new directory on the root, say '/drupal_test, and put everything there for now, will that be a problem when I copy everything to the root later? Or is there any standard drupal way to do it?

Thanks!


texts: How do I display the IMCE file browser in the same window?

texts: When users access the IMCE file browser from their user profile it show in new pop up window. I want it to be integrated in the websites main content. Does anyone know how to do that?


texts: How to solve tput problem when installing drush on Windows?

texts:
I am trying to get Drush running on my local development site. Drush & Cygwin are installed and the cygwin command prompt responds to Drush commands such as "Drush topic" but precedes the command output with:

  "which: no tput in + a long list of directory paths"

and then gives the topic list.  When I respond with 16 (Drupal help for error messages) I get:

  fwrite(): supplied argument is not a valid stream resource [warning]
  output.inc:29

I believe I have to add path definitions, but am not certain where to define them.  My current configuration on a windows OS has apache & php under C:/Program Files/acquai drupal/ (I used their setup for php and apache, but not their Drupal Site setup.)  I have Drush located under C:/Drush and my site located under C:/Documents and Settings/admin/my-site.


texts: How to generate breadcrumb title for custom routes?

texts:
I'm using a custom theme for our Drupal 8 based website, for breadcrumbs I'm using the easy breadcrumbs module.
We have a custom module where the nodes are generated in a custom block dynamically.
Below is the current structure in the module.routing.yml file
testmodule.res:
  path: '/subject/{node}'
  defaults:
    _controller: '\Drupal\testmodule\Controller\resController::res'
    _title: ''
  requirements:
    _permission: 'access content'

In the path - /subject/{node} the node contains a subject name belonging to a group, for instance resources group subject contain - Physics, Math and Chemistry.
The node in the path /random/{node} will contain the subject name
The breadcrumb pattern will be home>>subject>>Math
But I'm unable to find a way to display the subject name as the last breadcrumb. Do let me know what can be done


texts: Where does Drupal 7 store custom user account fields?

texts:
I imported 8500+ external users from an external user table using Feeds module successfully. Now, I am trying to add some more attributes to these users (ie. age, gender, ...). I proceeded to create several new fields for my users under admin/configuration/account settings/manage fields (ie. Age, Gender, ...). However, these fields are now all empty and it would not be possible for me to manually edit these fields for all users.

Could someone please tell me where D7 stores these new fields in the database (which table)? I would like to use a SQL script to automatically update the users with these fields.

PS. Is using a SQL script to update these information the correct approach?


texts:
I've around 300 pages in wiki style (word -> explanation).

I need to create an overview page with all words categorized by first letter of page title/custom field (so basically [0-9] or a, b, c etc).

I would like to know you there are any already some good solution to do that?
Also considering in best way to go :)

I need something like this (actually in 3 columns)

Thanks.


texts: List of content types posted/commented by users I follow

texts:
I'm running a D7 system Where users can follow each other using 'Follow' flag on user's profile.

Now I've been assigned a task to come up with a view where I can have a list of content posted/commented by people I follow.

I tried so many ways but no luck.


texts: Can I get all the possible values of a field of a content type

texts:
I've got a field on a content type that is a taxonomy reference with multiple terms.
I'm trying to pull all this values from my custom module config so I can limit my module only displaying on specific pages of the content type.
$form['field_type'] = [
  '#type' => 'select',
  '#title' => $this->t('Field Types'),
  '#empty_option' => $this->t('-None-'),
  '#options' => $fieldOptions,
  '#default_value' => isset($this->configuration['field_type']) ? $this->configuration['field_type'] : '',
  '#required' => TRUE,
];

Where $fieldOptions would be the multiple terms from this specific field.
At the moment i've only been able to get all content types using this method but is this possible for fields?


texts: How to change Contact Form sendto from admin dynamically

texts: In D7 I have a hook_form_alter to make changes to the Contact Form (Core). How can I  change the sendto address from the admin to another email addres that is determined when the user requests the form?


texts: Views with tables have different column width with same setting

texts:
I'm having problems with drupal views. I used a table to make a list of items with an image, a title and a body each. The first time I tried it it worked perfectly, each column only taking the necessary space but when I tried to recreate it, the title column is very wide. I check all the settings in both the views and the content and they are the exact same.

Here is the first table

And this is what the new ones look like

Do you know why that could be?

Thanks in advance!


texts: how to use cookie to protect other node pages in Drupal

texts:
some bots are grabbing my site's content everyday,I confirm if I set cookie protection the bots will not work again.

My question is how to use cookie to protect my content? if someone has no cookie then he can't go to next page.


texts: How to set fields (widgets) to readonly in hook_form_alter

texts:
Some fields of my nodes get regularly updated by an external datasource and therefore should not be edited by editors in Drupal. But for UX reasons I still need those fields visible on the edit form.

For input fields I've added the HTML readonly attribute, which works quite well:

function MYMODULE_form_node_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  $node = $form_state->getFormObject()->getEntity();

  if ($form_id == 'node_MYBUNDLE_form' || $form_id == 'node_MYBUNDLE_edit_form') {
    if ($node->hasField('remote_id') && $node->hasField('remote_datasource')) {
      if ($node->get('remote_id')->value && $node->hasField('remote_datasource') == 'SET_BY_MY_IMPORTER') {
        $readonlyFields = ['title', 'body', 'field_image', 'remote_id', 'field_minprice', 'field_roomsize', 'field_minoccupancy', 'field_stdoccupancy', 'field_maxoccupancy', 'field_roomamenity'];
        foreach ($readonlyFields as $rof) {
          $form[$rof]['widget'][0]['value']['#attributes']['readonly'] = 'readonly';
          $form[$rof]['widget'][0]['value']['#description'] = t('This is a readonly import field');
        }
      }
    }
  }
}

But I've got problems with those fields with the "advanced" (non HTML <input type="text|number|...">) widgets:

body is a text field with CKeditor
field_image is an ER field with Entity browser widget for media entities
field_roomamenity is an ER field with autocomplete widget for taxonomy terms

Can anybody give me a hint how to set those widgets programmatically to readonly?

Sidenote:
I know there is a Read-only Field Widget module. But I don't want to change the widget type, because editors can create their own items, which are not served by an external datasource (hence fields remote_XXX). In those cases the editors need those widgets in "write mode".


texts: Add javascript scolbar & effects to Block from module

texts:
I have a block that was created with Social Feed Module. The block aggregate social feeds. I want to add a scroll-bar to the block it self. I have seen some examples:http://mydrupal.com/add_scrollbars_in_blocks

However, I would like the block scroll-bar to be visible ONLY when the user hovers over the scroll-bar. I would think I would need to use javascript with the scrolbar? Any suggestions?


texts:
I'm working on an install profile which brings in various modules and I was curious about the proper (or popular) convention for setting global variables  Right now I have two different ways of doing this:

In my settings.php file I set some variables directly in the $conf array:

  $conf['var'] = 'setting';

In the install function of my profile I set some variables using variable_set:

  variable_set('var', 'setting');

I recognize that the first one will permanently retain the setting until the php file is altered, while the other can be changed at any time.

Is there any popular opinion/convention on the method of setting these variables(in the context of using an install profile)?

Thanks!


texts: Views: displaying related (referenced) content in a block

texts:
I tried solving the following with "node_reference" and "entityreference" modules but failed.

I have the content types recipe and cook. A recipe has a mandatory field which points to a cook.

When Drupal renders a recipe I want to have a block on the sidebar (implemented via "views") which will be displaying info on the recipe's cook.

How can the block know which recipe is being rendered on screen in order to use the relationship and pull the cook's data as fields which I'll use for display within the block?

thanks

More info: The problem is that in the block I'm getting all referenced (from recipes) cooks and not just the one cook for the specific recipe. So for the following data:

recipe#1 -> cook#1
recipe#2 -> cook#1
recipe#3 -> cook#1
recipe#4 -> cook#2

When I visit any of the recipes the block displays data from:

cook#1
cook#1
cook#1
cook#2


texts:
I am trying to change the footer on a Drupal 7.2 site.

How can I achieve it?


texts:
In drupal7 I used this code in my template file (node--article.tpl.php) to display the author bio. This is a custom profile field named field_author_bio.

<?php print user_load($uid)->field_author_bio['und'][0]['value']; ?>

In drupal8 I have the same setup.But I'm stuck how to do this with a twig template?

Any advise?
Thanks.


texts:
I'm using Drupal 7 and the services module and I'm trying to update a user profile using PHP & Curl.
Do I always have to login before sending  a "PUT/update" ?

This is my code so far :

<?php

// REST Server URL
$request_url = 'http://mywebsite/end/user/login';

// User data
$user_data = array(
  'username' => 'user2',
  'password' => 'pass1',
);

// cURL
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $request_url);
curl_setopt($curl, CURLOPT_POST, 1); // Do a regular HTTP POST
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));

curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($user_data)); // Set POST data
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$response = curl_exec($curl);

print $response;

$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// Check if login was successful
if ($http_code == 200) {
  // Convert json response as array
  $logged_user = json_decode($response);
}
else {
  // Get error msg
  $http_message = curl_error($curl);
  die($http_message);
}

print_r($logged_user);

// REST Server URL
$request_url = 'http://mywebsite.com/end/user/8&XDEBUG_SESSION_START=netbeans-xdebug';

$user_data = array('current_pass' => 'pass1', 'pass' => 'pass2');

// Define cookie session
$cookie_session = $logged_user->session_name . '=' . $logged_user->sessid;

// cURL
$curl = curl_init($request_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json',
    'Content-type: application/json')); // Accept JSON response
curl_setopt($curl, CURLOPT_PUT, TRUE);
curl_setopt($curl, CURLOPT_HEADER, TRUE); // FALSE);  // Ask to not return Header
curl_setopt($curl, CURLOPT_COOKIE, "$cookie_session"); // use the previously saved session
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);

// Emulate file.
$serialize_args = json_encode($user_data);
    $putData = fopen('php://temp', 'rw+');
    fwrite($putData, $serialize_args);
    fseek($putData, 0);
curl_setopt($curl, CURLOPT_INFILE, $putData);
curl_setopt($curl, CURLOPT_INFILESIZE, drupal_strlen($serialize_args));

$response = curl_exec($curl);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);

// Check if login was successful
$ret;
if ($http_code == 200) {
  // Convert json response as array
  $ret = json_decode($response);
}
else {
  // Get error msg
  $http_message = curl_error($curl);
  die($http_message);
}

print_r($ret);

curl_close($curl);

}

?>

What am I missing here?
Nothing happens to my profile.

Any answer is welcomed!


texts: How do I get access to fields of a node that a menu item links to?

texts: For example, a menu item links to node/5. How do I retrieve that node so I can get its 'description' field?


texts:
I'm trying to create a field widget which is a collection of multiple fields. I'm using hook_field_widget_info() and hook_field_widget_form(), something like this:

function module_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $element += array(
    '#type' => 'container',
    '#element_validate' => array('custom_validation_function'),
  );

  $options = array('some values here');
  $element['existing'] = array(
    '#type' => 'select',
    '#title' => 'Recipient & delivery address',
    '#options' => $options,
    '#ajax' => array(
      'wrapper' => $wrapper_id,
      'callback' => '_my_custom_ajax_callback'
    )
  );
  $element['new'] = array(
    '#prefix' => '
',
    '#suffix' => '
',
  );

  $new_entity = entity_create('entity_type', array('type' => 'bundle'));

  field_attach_form('entity_type', $new_entity, $element['new'], $form_state);

  return $element;
}

function _my_custom_ajax_callback($form, &$form_state) {
  return $form['new'];
}

The problem is that in the ajax callback the $form array is different than the one in the hook_field_widget_form(). In the ajax callback the form array is the entire form structure, not just the one defining that widget...

Any ideas?


texts: Drupal 7.16 started sending duplicate account activation emails

texts:
Could anyone help me debug why Drupal is sending two account activation emails when a new user account is activated?

I also see from the rules logs, that certain workflow rules are also sending two emails for each one.

I have looked in /admin/reports/dblog but there are no errors or warnings there.

Any idea where I can start looking?

thanks,
Darren


texts: Why node/*/track appears as Referrer to node/*?

texts:
I have the Statistics core module turned on in my Drupal 7 site.

When I visit the 'Track' tab of a node (node/X/track), the table shows that same page – node/X/track – listed several times as the 'Referrer' to the page itself – node/X. These visits are made by 'Anonymous (not verified)' users.

How can that happen if only the admin (myself) has the permission to view the 'Track' tab??

However, if I click on 'Details' for one of these anonymous visits (/admin/reports/access/*), the "Referrer' information is blank.

Is there some misconfiguration in my site or I did not understand how the Statistics module works?


texts:
I'm looking into creating a Drupal 7 custom entity for panels pages created with ctools Page Manager, in order to index this content with the Search API. An existing project, Page Manager Search, seems to be doing just that, but I'm hitting an issue where an exception thrown when attempting to index. So I wanted to better understand the process, and whether or not it's recommended / feasible to build a custom entity off of existing data.

From what I've seen in the Page Manager Search project, it looks like it's maybe possible to create a custom entity without using hook_schema(). Anyone have any experience doing so, and any potential pitfalls?


texts: How do I implement the equivalent of hook_url_inbound_alter()?

texts:
I'm working on a module which will resolve URLs to entities by altering inbound URLs so that if they contain an entity ID with following pattern "-{entity_id}" user will be redirected to correct URL.

A working example of the above:

Final URL:

http://romajazz.it/concerti/pozzovio-de-angelis-4902
Using the aliases:
http://romajazz.it/concerti/-4902
http://romajazz.it/concerti/i-can-type-anything-here-4902

I researched for a while; I found out there was hook_url_inbound_alter() in Drupal 7 which could solve this problem.

I also found that there is InboundPathProcessorInterface in Drupal 8.

I thought about implementing InboundPathProcessorInterface and use it in EventSubscriberInterface implementation which will subscribe on KernelEvents::REQUEST.

I wonder if this approach is correct. Are there any other ways of doing this in Drupal 8?


texts: Contexual filter does not work when the page is loaded via AJAX

texts:
I created a node--type.tpl.php file, deactivated all displays (I don't need them), and wrote custom HTML code. I created a view which outputs the list of nodes associated to term. I created it with the contextual filters "Content:Nid" and "Content: Has Taxonomy Term Id." I embedded it to the node I created. (I can activate it as block, because I want to load a whole node with AJAX.)

If I open a node with normal load, the list is beeing showed, but with AJAX load the list is gone. I tried to add an argument to the view like with views_embed_view('tratata', 'tata', $myarg), but it doesn't work. Can anybody help me to solve this problem?

The module which is responsible of loading a node via AJAX is my custom module, which depends from the Chaos tool suite module.


texts: Drupal 7: can't get SQL query to work that works outside of Drupal

texts:
I have a SQL query that works just fine on it's own as follows:

SELECT timestamp FROM accesslog
WHERE uid = 1
AND path = 'mypath'
AND timestamp > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 4 WEEK));

I've tried two methods, and the first one returns all values for the user from the beginning of time, and the second results in a PDOException.

Method 1:

$ts = 'UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL '.$interval.'))';
$query = db_select('accesslog', 'a');
$query->addField('a', 'uid');
$query->addField('a', 'path');
$query->addField('a', 'timestamp');
$query->condition('a.uid', $uid);
$query->condition('a.path', $path);
$query->condition('a.timestamp', $ts, '>');
$result = $query->execute();

Method 2:

$result = db_query("
SELECT timestamp
FROM accesslog
WHERE uid = :uid
AND path = :path
AND timestamp > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL :interval))",
array(':uid'=>$uid,
      ':path'=>$path,
      ':interval'=>$interval))->fetch();

I'm guessing the issue is with the timestamp > part, but I'm just not sure how to get that part done.

Can someone point me in the right direction?

Thanks


texts: Should you use check_plain() prior to inserting into database?

texts:
I am currently using check_plain() etc on displaying user entered data in HTML, and I am also using check_plain() etc prior to inserting the user data into my custom tables.

When inserting or updating the DB, I am always using db_insert or db_merge. Do I need to validate like I am, or are those functions doing it for me already?

If they are doing that already, do I need to use check_plain() on output still?


texts: How to programmatically toggle webform required field

texts:
Using webform4, how to programmatically toggle the required option based on another condition?
I have done jQuery('#edit-submitted-fld4-rgistered-with').removeClass('required'); but it seems the validation is handled on the server side.


texts: Change order (weight) of blocks before page load programatically

texts: Is there a way to change order of blocks before page load (according to current node id for expample)? In hook_preprocess_page or something like that? I don't want to use any modules for this.


texts: Drupal 7 Services -- hook_services_request_postprocess_alter() does not identify the requested resource

texts:
According to the Services API in Drupal 7, we can use hook_services_request_postprocess_alter() to alter drupal's REST response before returning it to the user. This is useful if you want to alter the structure of an array, or strip out data we don't want returned to the API user. However, I don't see any way to identify what resource is being requested explicitly.

The Hooks passes: ($controller, $args, &$result);

The controller has semi-identifiable information, such as the callback which was fired, or the file where this resource exists. For instance, when firing a node INDEX request, we'd see:

[help] => List all nodes
[file] => Array
    (
        [type] => inc
        [module] => services
        [name] => resources/node_resource
    )

[callback] => _node_resource_index
[args] => Array
    (
        [0] => Array
            (
                [name] => page
                [optional] => 1
                [type] => int
                [description] => The zero-based index of the page to get, defaults to 0.
                [default value] => 0
                [source] => Array
                    (
                        [param] => page
                    )

            )

Etc. However, there is nothing standard here across services which would tell us: "This is a node INDEX request, using the NODE endpoint."

To be clear, we're referring to node in the resource sense, such as my_host/my_endpoint/node.json. Meaning, which of our endpoint's resources is being requested here, and what (if any) method/operation are we performing.

I was hoping there was something standard within this hook to identify this information, as opposed to relying on more external data, such as the GET or POST variables.

Anyone have insight into this?

[edit]:

hook_services_request_preprocess_alter() is passed an $options array, which contains the endpoint resource and method. I need access to this information in the postprocess hook mentioned above, but don't see any clean, Drupal-way to do that. this is what I am looking for.

The array looks as follows:

Array(
  [version] => ,
  [resource] => node,
  [method] => 1.json
);


texts: Language switcher block hides for authenticated user

texts:
I have a language switcher added to my site. It works fine as long as I'm an unauthenticated user. Logging into site replaces it with:

I see this behavior also  when I add a message block to any of the regions.

I'm also using big pipe. Could it be causing some issue? Is this a bug with language switcher block?

Any help is appreciated.

Thank you


texts:
I want to replace some of the links which I am using in my website, i came to know there is a module called Drush Search & Replace. I have installed also to use this module. But I am not getting where should I keep this module in the drush installed folder or modules folder. I tried by placing this in module folder It will not list out in the modules list because it doesn't have .module file.

I have installed drush in this path

Drush script  C:\Users\name\AppData\Roaming\Composer\vendor\drush\drush\drush

According to the README.txt of this module:

Place the sar directory in ~/.drush/commands (create it if you don't have one)
and run `drush help sar'.

I tried by placing this module in the C:\Users\name\AppData\Roaming\Composer\vendor\drush\drush\commands folder also,but when I use drush help sar command it will say invalid command sar. Please help me regarding this, Thanks in advance..


texts:
I accidentally deleted the Drupal 8 files, but the database is not damaged. Is there anyway I can bring my site back to live?

I have an old backup of only files. I restored the file of that backup in the root folder, and replaced the database credentials in the settings.php file. It didn't work.

Is there any other way to bring back the site to live from the database?

Note: this is shared hosting.


texts: How would I add an image to a Drupal Webform?


texts:
I have a content type in D8 that requires translation, however at the moment I appear to be only able to translate the individual fields and not the title.

The language selector is available on the content type edit page, but there seems to be no way of selecting to translate the title:

Other fields have a checkbox that allows them to be translatable:

Any ideas? Thanks in advance!


texts: Some module is adding info below 'Nice Menus'

texts:
I believe some module is somehow hooking into nice menus and adding a div of content below the menu. However I can't for the life of me find out which one.

Here's what I know:

There is a content type called 'nice_menu_addition'. When creating an item of that content type you chose which menu item you would like it placed beneath, and it shows up there. However, I can't find ANY modules anywhere, or any theme info that shows where this is being done. Any suggestions as to where to look?


texts: Pass Variable to Custom Block template file

texts:
I want to create my custom block with custom content in Drupal 8,in start I create  Block with just simple text on it, and work correctly, my Problem is how can I pass my custom variable to it?
I saw some tutorial about it , my Module name is tcdev and this is content of .module file.

function tcdev_theme($existing, $type, $theme, $path) {
    return array('tcdev' =>
        array(
            'variables' => array(
                'title' => 'Default title',
                'description' => null
            ),
            'template' => 'block--sliderblock'
        )
    );
}

and my SliderBlock.php

    namespace  Drupal\tcdev\Plugin\Block;
use Drupal\Core\block\BlockBase;

/**
 * Provides a 'SliderBlock' block.
 *
 * @Block(
 * id = "slider_block",
 * admin_label = @Translation("Slider Block"),
 * )
 */

class SliderBlock extends BlockBase{
    /**
     * {@inheritdoc}
     */
    public function build(){
        return array(
            '#title' => 'my title ',
            '#description' => 'my custom desc'
        );
}
}

and finally my template file block--sliderblock.html.twig

My Custom Block{{ title }}-{{ description }}

But Result is only "My Custom Block-" .
The problem is variables not getting passed to template file,where is my fault?

appreciate any help


texts:
I am using the Commerce module and Paypal WPS on Drupal 7. When logged in as Admin to my website on a product page I can see the 'Check out' link next to 'View Cart'. However, if I log out and select the same product the 'Check out' option is not there. All I can see is the shopping cart.

What can I do about this?


texts: How to migrate a book from Drupal 6 to a menu in Drupal 7

texts:
Recently I came across a situation where I had to migrate a book with lots of links into a menu (since the customer wanted a simple navigational menu).

I came up with some code that worked pretty fine, so I decided to share it as an answer.

If you believe it could have been done in a better way, please feel free to comment and propose your ideas and methods. This code requires you to be somewhat familiar with the Migration process and the Migrate module.


texts: Change target type of entity reference field in update hook

texts:
In an update function, I'm trying to change the target_type of an entity reference field, following the approach outlined on https://www.drupal.org/node/2535476). The previously used target entity type (its class) has been removed from my site (I'm removing it as part of the update).

Something like this in the update function:

$field_storage_config = FieldStorageConfig::loadByName('entity_type', 'field_name');
$field_storage_config->setSetting('target_type', 'new_entity_type');
$field_storage_config->save();

When I call $field_storage_config->save(), I get a fatal error saying the previously used target type (the one that's been removed) no longer exists. It seems that the save() method eventually calls \Drupal\Core\Entity\EntityTypeManager::getDefinition for the removed entity type, leading to the fatal error.

Any way to get around this, so I can switch the target type from the removed entity type to an existing one in my update function?


texts: In the specific page.tpl.php adding an include file

texts:
I was recently asked to create a blank page without a header and footer. I implemented that following this comment.
Now the issue is that the team for whom I've created it do not want the html, body tags either that show up in view source! They have directly included a php file in the specific page-simple.tpl.php . I know this is not the right approach. If someone could point out the issue doing it this way and another approach if possible. I'd really appreciate it.

Thanks.


texts: Theming html output of privatemsg 6.x-2.x module

texts:
How can I theme the output of Privatemsg? I took look at http://api.worldempire.ch/api/privatemsg/privatemsg.theme.inc/group/theming/1, but I didn't understood how to use that.
I want to totally change the HTML output for the message list.

How do I use my custom date format in the messages? I guess the format_date() function would help me, but how do I use it correctly?

print format_date($messages_timestamp, 'custom', 'd=m=Y') returns "01.01.1970." What is that?


texts: How to print parent taxonomy term name in a block?

texts:
Using Drupal 7, I want to create a simple block that will be on all taxonomy term pages that will show the first parent of the current term (there will be a tree of parents, but I want just the next highest).

The below code works to pull the current term name, but I'm unsure how to go about pulling the parent term  of this term page.

$current = taxonomy_term_load(arg(2));
if ($current):
echo $current->name;
endif;

Any suggestions?


texts: Filtering exposed filters with views_get_view_result() function

texts:
I have built a module so that I can display PDFs with phpwkhtmltopdf. I am currently calling my view data using:

$view = views_get_view_result('course_catalog');

My question is, is there a way to have filter my exposed filters with this function? If not, what is the best way to go about this? --I suppose I could manually filter through the results with PHP, but that hardly seems efficient.


texts:
So let's say I have a content type Product with two fields: name and date. I want to have another field called profit to be filled in automatically according to the name of the product.
Any ideas on how I can do that easily?


texts:
I moved a Drupal site to a development domain, but for some reason none of the menu links have updated. For example, in the main menu, one of the links is www.example.com/product. I would expect it to change to www.devdomain.com/product after moving it to my dev domain, but it doesn't.

Similarly, even the links in the Seven admin theme still point to www.example.com (my live site) instead of the dev domain. So clicking "Structure", for example, tries to route me back to the live site.

Anyone ever experience this and know how to solve? There are no references to base_url in my settings.php file for this site, and I am not using the trusted host patterns setting (though I have tried with and without).

A few other things I have tried:

running update.php
drush cr
searching for instances of example.com in codebase (there are none)

Any help on this would be appreciated.


texts: Why is drupal_json_output only returning page HTML?

texts:
I'm trying to get drupal to return some rendered views content that I request through ajax, but all it seems to want to output is what looks like a rendered page. What am I doing wrong here?

// This is logging a ton of page HTML

jQuery(function($) {
    $.ajax({
        url: 'fetch/explore/' . category,
        success: function(data) {
            console.log(data);
        }
    });
});

// This is from my custom module

function wdfm_menu() {
    $items['fetch/explore/%'] = array(
    'page callback' => 'fetch_explore_content',
    'type' => MENU_CALLBACK,
    'access arguments' => array('access content'),
        'page arguments' => array(2)
  );
    return $items;
}

// Nothing is showing up in my log from this so I'm unsure it's even being called.

function fetch_explore_content($category) {
    watchdog('blargh', 'something');
    $data = array();
    $data['test'] = 'test';

  drupal_json_output($data);
    exit;
}


texts: How to create a family tree structure of nodes?

texts:
I have to create a family tree in Drupal. I am trying to use tree views module to do the same.

I have 3 nodes (A, B and C) of the contact type (I have created custom node), whereas C is son of A (Father ) & B (Mother).

I need to show the same in a tree like structure.

I have used relationship module and made these relations:

A isFatherof C
B isMotherof C

How do I show them as a tree like structure? Something like so:

A - B
  |
  C

I have tried using the trees views module.


texts: Get parent entity in media preprocess hook

texts:
I am having a paragraph with a media entity ref field   "field_paragraph_image_ref".
I would need to modiy the media twig template depending on a field value of the parent, which is a paragraph entity.
How can i get the field value from the parent entity in the media preprocess
  function hook_preprocess_media__picture__image_without_link(array &$variables) {
      $media = $variables['elements']['#media'];
      //A method to get the parent entity, that i cannot find in var_dump(get_class_methods($media));
      // and finally get a field value from the parent paragraph entity
}


texts: Execute a view in code and pass multiple arguments to an exposed filter?

texts:
I am executing a View in code of a paragraph preprocess to allow dynamic listings. The user selects which content types they would like to show, and the View should return nodes of those types with the same taxonomy selected. The idea is they can add multiple paragraphs with different configuration, leveraging the same View just with different arguments.

In this view, Content Type is an exposed filter, set to allow multiple. Here is the code in the preprocess_paragraph hook:

$types = $paragraph->field_related_content_types->getValue();
$content_types = [];

foreach ($types as $type) {
  $content_types[] = $type['target_id'];
}

$view = Views::getView('related_content');
$view->setDisplay('related_content_display');
$view->setArguments(['type' => $content_types]);
$view->setExposedInput(['type' => $content_types]);
$view->preExecute();
$view->execute();

if (count($view->result)) {
  $variables['results'] = $view->buildRenderable('related_content_display', ['type' => $content_types]);
}

'type' is the filter name in the View. If I change it to only allow one value and pass it as a string, it works. So it seems like a syntax issue, but I cannot figure it out.

The method seems to indicate that this is possible:

  /**
   * Sets the arguments for the view.
   *
   * @param array $args
   *   The arguments passed to the view.
   */
  public function setArguments(array $args) {
    // The array keys of the arguments will be incorrect if set by
    // views_embed_view() or \Drupal\views\ViewExecutable:preview().
    $this->args = array_values($args);
  }


texts: D7: Newsletter type project.The articles are grouped in a set (newsletter) published on a regular basis

texts:
My project is as follows:

News will be published like printed news letters meaning that no ongoing updating&publishing but clear intervals (in other words the articles need to be grouped together on the criteria of issue..issue January, issue February etc... At the moment plan is that publishing interval would be a few months.

What modules and approach would you choose for this? I know prosepoint can do this...but is no longer free and I need to make it in Drupal.

I need to dismiss the confusion with simplenews module. The newsletter doesn't need to be delivered by email (tough this would be one functionality) but displayed on the website.

Regards


texts:
I have a problem that's driving me bananas on Drupal 7.

My need is very simple. I have a site with a bunch of communities with URLs like

http://domain.example/community/communityname

All of these communities have similar structures with pages like "learning", "blog" etc. which are at URLs such as

http://domain.example/community/communityname/learning

I need to create a navigation menu for each of these communities without actually creating a separate menu item for each. How can this be achieved?

I tried doing this with hook_menu and even after 3 hours of relentless googling and fiddling about I just can't seem to get this working.

Any help is much appreciated.

Here's my non-working code:

function mymodule_menu(){
    $items = array();
    $items['community/%mymodule_arg/learning'] = array(
        'title' => 'Learning',
        'page callback' => 'mymodule_view_page',
        'page arguments' => array(1),
        'menu_name' => 'menu-community-menu',
        'type' => MENU_NORMAL_ITEM,
        'access callback'=>TRUE
    );
    return $items;
}

function mymodule_arg_to_arg($arg) {
    return (empty($arg) || $arg == '%') ? "community-a" : $arg;
}

function mymodule_view_page($context) {
    return drupal_goto("community/" . $context . "/learning");
}

If I replace the wildcard from the items array key and replace it with a static string, the code works. Also if I just return a string from mymodule_arg_to_arg() it works. But I just can't seem to make it dynamic.


texts: List of referenced entities appended to a node

texts:
I have two content types: "project" and "task"
Using flag and with support of entity reference + flagging form, users can append very rapidly new "task" nodes to the current "project" node they are viewing.
The structure then is the following:

Node type 1 >> project
Node type 2 >> task
Flag >> task appended to project; actually is a "container" of an Entity
Reference(with multiple value) field linked to task

My target is create with views, a list of appended "task" nodes and show that list in a block to the related "project" node.
I believe that I should use relationship + contextual filter, but I have no idea on how to achieve my needs.

Could you help me? Thank you all in advance!

Update on 13-01-2017 16:45:
Attached step by step after suggestion from pierostz. These steps were done before the configuration window uploaded at 15:00.

Update on 13-01-2017 15:00:
Attached contextual filter Nid after a first aattempt after suggestion from pierostz.


texts:
In SMTP module configuration I have set the following fields:

SMTP Server: smtp.live.com
SMTP port:25
Use encrypted protocol: NO

In E-MAIL OPTIONS,

E-mail from address: myadress@hotmail.com
SEND TEST E-MAIL: myadress@hotmail.com.

but it gives me the long detail of errors with the last line SMTP Error: Could not authenticate. Same error when I try to use below configuration:

 SMTP Server: smtp.gmail.com
 SMTP port:25
 Use encrypted protocol: SSL

In E-MAIL OPTIONS,

E-mail from address: my_gmail_address
SEND TEST E-MAIL: my_another_address.

But when I used port 80 instead of 25 then it gives me the following error for SMTP.live.com

SMTP -> ERROR: Failed to connect to server: Connection timed out (110) drupal 7

UPDATED:

Below is the screen shot for gmail configuration.


texts:
In node.html.twig, I want to show a field when I click on it, as what the Field Value Loader (Show field on click) module does, but this module doesn't have releases for Drupal 8.

How can I do this?


texts:
I have some data of type Images where I want to import in the format of xml named 'images.xml' which containing images url and information.

I want to import this file programatically using feeds API.

How can I achieve this?

for this i use following code:

$source = feeds_source($importerId);
$config = array(
  'fetcher' => array(
    'plugin_key' => 'FeedsHTTPFetcher',
    'config' => array(
      'auto_detect_feeds' => FALSE,
      'use_pubsubhubbub' => FALSE,
      'designated_hub' => '',
      'request_timeout' => NULL,
      ),
    ),
  'parser' => array(
    'plugin_key' => 'FeedsXPathParserXML',
    'config' => array(
      'sources' => array(
        'xpathparser:0' => 'url',
        ),
      'rawXML' => array(
        'xpathparser:0' => 'xpathparser:0',
        ),
      'context' => '//image',
      'exp' => array(
        'errors' => 0,
        'debug' => array(
          'context' => 0,
          'xpathparser:0' => 0,
          ),
        ),
      'allow_override' => 1,
      ),
    ),
  'processor' => array(
    'plugin_key' => 'FeedsNodeProcessor',
    'config' => array(
      'expire' => '-1',
      'author' => 0,
      'authorize' => 1,
      'mappings' => array(
        0 => array(
          'source' => 'xpathparser:0',
          'target' => 'url',
          'unique' => FALSE,
          ),
        ),
      'update_existing' => '0',
      'input_format' => 'full_html',
      'skip_hash_check' => 0,
      'bundle' => 'images',
      ),
    ),
  'content_type' => 'images',
  'type' => 'images',
  'update' => 0,
  'import_period' => '-1',
  'expire_period' => 3600,
  'import_on_create' => 1,
  'process_in_background' => 0,
  );
$source->importer->addConfig($config);

$featcher_config = $source->getConfigFor($source->importer->fetcher);
$featcher_config['source'] = $url;
$source->setConfigFor($source->importer->fetcher, $featcher_config);
//$source->save();
//node_save($source);
$source->startImport();

But this code show "Download of failed with code -1002" and no images are import...


texts: Image field - 'Number of values' is not showing up in admin form

texts:
Something's very wierd with my existing Drupal 7 setup (current Drupal version, set up in early 2013, custom Zen Subtheme). When I create a new Content Type with a new Field Type "Image" this 'Number of values' pulldown isn't showing up where it should. I've now spent the whole day researching how this could be, without any luck.

I've tried default themes, checked user permissions and also file permissions (while always rebuilding the theme registry). I googled around for hours but I couldn't find any clue how to fix this .

What could be the reason for this?

Any tips for further testing are welcome.

Edit:

The field value is internally called cardinality.
The problem seems to affect all field types of this installation.


texts: ExtensionDiscovery::scanDirectory() takes too long

texts:
I have been debugging a bit an issue on our platform and I notice that our scanDirectory takes, from time to time, way to long, more than 100seconds.
I have been looking at the default.settings.php and I noticed
/**
 * The default list of directories that will be ignored by Drupal's file API.
 *
 * By default ignore node_modules and bower_components folders to avoid issues
 * with common frontend tools and recursive scanning of directories looking for
 * extensions.
 *
 * @see file_scan_directory()
 * @see \Drupal\Core\Extension\ExtensionDiscovery::scanDirectory()
 */
$settings['file_scan_ignore_directories'] = [
  'node_modules',
  'bower_components',
  'vendor',
];

I found that out that our sites/default directory is the one to blame.
Can I just add it here? Or should I include the subdirectories(fx sites/default/files)?
I am really surprised about this one. Been working with drupal years now and I see this first time!


texts: Programmically create a content type with publishing options

texts:
I've been able to successfully create a content type on the install of my module by following Creating a custom content type in Drupal 8 in the drupal.org documentation, but I can't find a way to add the publishing options.

How should I add the publishing options when creating a content type?


texts: How to sort by title using Search API / fuzzy search?

texts:
In d7 i'm using fuzzysearch together with a table view for a quite long list of contacts. So far this works quite well – searching for "Mill" will list all "Miller" entries. Problem is: there is no option for sorting the results other than by relevance, ID, content type, random or PHP.

It would be great if the table was sortable by any of the fields – like it is possible in a regular table view – or at least by the title field. I'm not sure if I'm missing something – or if this is anyways not possible?

These are all the option I currently have in the sorting section of the table view:

(sorry, screenshot is partly in german)

All pointers / hints gladly appreciated. Thank you!


texts: Ubercart shipping quotes silently fails on server migration

texts:
I'm having a hard time figuring out why shipping quotes are failing after migrating to a new server.

I can clone the repo in my local machine, and shipping quotes come in fine. I can't find anything in the AJAX request/response headers that tells me why they're failing on the development site. They work on the live site. (It uses Drupal 7.7, while the development site is using Drupal 7.15.)

They work on my local machine (cloned from the same, updated the repository as development).

I get the following error messages on the watchdog log every time I try to get a shipping quote.

  Type: Rules
  Location: /system/ajax
  Referrer: /cart
  Message: Unable to evaluate condition data_is

  Type: Rules
  Location: /system/ajax
  Referrer: /cart
  Message: Unable to apply data selector order:delivery-address:country: Unknown data property delivery_address

I enabled the Rules UI module to view active/disabled rules. And it looks like some rules are based on parameters that no longer exist, perhaps due to updating the Ubercart module. This is confusing because I did the upgrade locally, and I did not find this issue.

These are the active rules with errors:

E-mail an order update notification
Machine name: uc_order_update_email_customer
Weight: 0
Error: Data selector order:order-status for parameter data is invalid

Complete non-shippable order after payment received
Machine name: uc_checkout_complete_paid
Weight: 0
Error: Data selector updated_order:order-status for parameter data is invalid


texts:
I made a custom theme based on bartik.

In this custom theme I add just one CSS file and a very simple specific view template file.

When I am connected with a user with 'Administrator' Role all is OK. It means that my customed class are loaded an applyed

But when i am connected with a user without 'Administrator' Role all is KO. It's like my customed class are not in the theme.

Any Idea ?


texts: Problem changing colors in the mayo theme

texts:
I have installed the mayo theme on my new site. When I try to go to "appearance" menu, and change the color combination from mayo (default) to anything else, the system saves the settings. but the website is not using the colors I chose.

What could be the cause?

I'm trying to change colors, but nothing I do works; the colors are correct only with the default color combination.


texts:
In Drupal 8 you can load an entity with:

$node = \Drupal::entityManager()->getStorage('node')->load(123);

This looks for the entity definitions and finds that node is defined by Drupal\node\Entity\Node - so (I guess) Drupal\node\NodeStorage will instantiate a new Drupal\node\Entity\Node instance.

What I'd like to achieve is subclassing Drupal\node\Entity\Node and being able to instantiate this subclass when it's appropriate. For example if I have a node bundle article, there would be a class:

namespace Drupal\my_module\Entity\Article;
class Article extends Drupal\node\Entity\Node {
}

And I'd call:

$node = \Drupal::entityManager()->getStorage('node_article')->load(123);

And the return would be my Article subclass.

I can achieve this by creating a new entity type and wiring it back to another existing entity definitions, for example the node-article example would be this class:

namespace Drupal\my_module\Entity;
use Drupal\node\Entity\Node;
/**
 * @ContentEntityType(
 *   id = "node_article",
 *   label = @Translation("Content"),
 *   bundle_label = @Translation("Content type"),
 *   handlers = {
 *     "storage" = "Drupal\node\NodeStorage",
 *     "storage_schema" = "Drupal\node\NodeStorageSchema",
 *     "view_builder" = "Drupal\node\NodeViewBuilder",
 *     "access" = "Drupal\node\NodeAccessControlHandler",
 *     "views_data" = "Drupal\node\NodeViewsData",
 *     "form" = {
 *       "default" = "Drupal\node\NodeForm",
 *       "delete" = "Drupal\node\Form\NodeDeleteForm",
 *       "edit" = "Drupal\node\NodeForm"
 *     },
 *     "route_provider" = {
 *       "html" = "Drupal\node\Entity\NodeRouteProvider",
 *     },
 *     "list_builder" = "Drupal\node\NodeListBuilder",
 *     "translation" = "Drupal\node\NodeTranslationHandler"
 *   },
 *   base_table = "node",
 *   data_table = "node_field_data",
 *   revision_table = "node_revision",
 *   revision_data_table = "node_field_revision",
 *   translatable = TRUE,
 *   list_cache_contexts = { "user.node_grants:view" },
 *   entity_keys = {
 *     "id" = "nid",
 *     "revision" = "vid",
 *     "bundle" = "type",
 *     "label" = "title",
 *     "langcode" = "langcode",
 *     "uuid" = "uuid",
 *     "status" = "status",
 *     "uid" = "uid",
 *   },
 *   bundle_entity_type = "node_type",
 *   field_ui_base_route = "entity.node_type.edit_form",
 *   common_reference_target = TRUE,
 *   permission_granularity = "bundle",
 *   links = {
 *     "canonical" = "/node/{node}",
 *     "delete-form" = "/node/{node}/delete",
 *     "edit-form" = "/node/{node}/edit",
 *     "version-history" = "/node/{node}/revisions",
 *     "revision" = "/node/{node}/revisions/{node_revision}/view",
 *   }
 * )
 */
class Article extends Node { }

// Results my Article sub type.
$node = \Drupal::entityManager()->getStorage('node_article')->load(123);

This works fine (as much as I can see); however, it smells. It adds a new entity type, which is not true, and might cause other troubles in the future.

How do I define a subclass for an entity bundle so that loading the entity would return an object of that class?


texts: Radioactivity module. "how-to" most popular article in one day questions

texts:
thanks for the time to read this question.

to me not is clear the concept of Radiactivity measures. how to get the most popular article in one day? I must use the half-life in 43200 seconds (12 hours)? when change this results? (each day in this case?), what's happen if I Cut-off energy to 0?. where is stored this results if I want a report per days?

thanks in advance.


texts: How should I add multiple markers using geofield module?

texts:
Whenever I set the module with unlimited values there are more the one maps with location. However they show the location which I want, but in two or more different maps.

My problem is I want to integrate multiple location with a single map. My project is kind of setting the route for people.

How do I do that? Should I create a hook for the Geofield module?


texts:
I am trying to open a webform in a modal window through following link, which works fine when I am logged in, but when I logout it simply stops working

Get a Call Back

It seems like we need to load ajax on pages where we want to use this link, so I want to know how can I load ajax sitewide.


texts: How can I repeat a group of fields in a content type?

texts:
I'd like to create a content type named image gallery then add two fields as caption as text and image as image. Then make these two bundled and repeatable indefinitely when entering content for this content type.

Is it something possible to achieve without using third party modules or creating multiple content types?
If so, how?
If not, what would you suggest to use to do this?

I've tried to use Paragraph module and working fine but it seems it doesn't provide the image dimensions unless you loop the whole bit and get the dimensions for each item.

PS: Sorry about the tag by the way but it seems tags for content type and structure doesn't exist.


texts: Show comment link function based on node comment settings and not user privilege

texts:
I'm creating a custom theme and module for one of my content types. I want to show the comments link in a specific content type only if comments are turned on for the node or even globally for the content type specifically. I had originally used the following, simplified for example, in my tpl.php, which shows the link if the user has the privilege to comment. However, in my case, while I allow comments all over the site, I don't allow them on this particular content type. I want to leave the option open in case we do allow comments in the future.

<?php
 if (user_access('post comments')) {
  print 'Comment';
 }
?>

I was hoping that the system would recognize that a user that has privilege to comment every else still doesn't have privileges to comment on this node, and the link would not show, but it seems to show to anyone that has comment privileges, regardless of node.

What should replace user_access()?


texts: Display another field as 'Node author' if node posted anonymously

texts:
Currently on my D6 site registered as well as anonymous users can post articles. A custom text field has to be filled by unregistered users while creating an article. This text field's value is shown as Node author for anonymous posters.

Now I am all set to upgrade this site to D7. I tried using the following snippet to display custom text field value as the 'node author' if posted by Anonymous user, But it has some issues...

menu_get_object() works only for full node view and not for teasers etc.
It also changes $name every where on the page eg: for unregistered comments too.

function mytheme_username_alter(&$name, $account) {
  $node = menu_get_object();
    if($account->uid == "0") {
      $name = $node->field_custom_author['und'][0]['value'];
     }
}

Question: How can I tweak this function to display custom text field's value as 'Node Author' if the node is created by an anonymous user, without changing $name elsewhere on the page?

If there's a better function/solution than this, i am all open to try that too.


texts: I've a problem trying to create users with roles

texts:
I'm using simpletest_clone to do my tests.
what i want now is just to create an user for every existing role i've created
(I dont need just the list of permissions, i need the user to have the exact role i want)

public function testProbando(){
 foreach(user_roles() as $clave => $rol){
   $this->privilegedUser=$this->drupalCreateUser(array());
   $this->privilegedUser->roles = array($clave => $rol);
   user_save($this->privilegedUser);
   $this->drupalLogin($this->privilegedUser);
   $this->drupalLogout();
 }
}

but in the verbose it simply doesn't log in and i can't get any clue what to do


texts: Can I combine multiple "no results behavior" to avoid repetition?

texts:
I have a Search API view that has 3 attachments. This is so I can display different content type results with unique layouts.

If the user searches something too specific, they'll see the No Results Behavior up to 4 times in a row. This looks bad.

How can I only display the No Results Behavior (custom textarea) when there are no results in the view AND its 3 attachments?


texts: Can we use a hook_update_N for a module without hook_install?

texts: I am working on a custom module which does not have an install file but nevertheless uses a lot of tables. The one who worked on it previously, created the database tables manually. Now I want to add more tables to it. I could run the query manually to get the job done but I wanted to use the 'Drupal' way to do that. So I was wondering if we could use a hook_update_N for a module without hook_install?


texts: Fetch view results from mymodule_preprocess_page hook

texts:
We have a View page that is coming from myview. Using the header setting in the view we have added @total results already, which displays in the views-view--myview--page-1.html.twig using the {{ header }} variable.

We want to be able to fetch the view results within our mymodule_preprocess_page() hook. On the View page, we added facet blocks that will return a list of checkboxes (this is from the Article's category tag).

Issue

When we modify the facet value to some value such as value1, the ksm($view->total_results) returns NULL value.

Questions:

How would i fetch the results using mymodule_preprocess_page() hook?
Is there a way to do it without running a query within mymodule_preprocess_page() hook?

View Setup

Display: page

Format

unformatted list
rendered entity | "my_view_mode"

Filter criteria

published = true
content type = article

Header

Global: result summary (global: result summary)

Other
 - Machine name: page_1
 - Use Ajax = yes

What we tried:

function mymodule_preprocess_page($variables) {
  $view_id = \Drupal::routeMatch()->getParameter('view_id');
  $display_id = \Drupal::routeMatch()->getParameter('display_id');

  if($view_id == 'myviewId' && $display_id = 'page_1') {
    // first check we are on view page.
    $view = \Drupal\views\Views::getView($view_id);
    ksm($view->total_results); // returns null.
  }
}


texts: Display user picture in User Relationship block

texts:
In my social networking site, i have provided for users to be able to forge relationships between themselves using the User relationship module. This is working fine. I am creating a tab using quicktab to display the user their relations when he or she clicks on them. I assign my tab the block value :
My Relationships: All relationships (user_relationship_blocks:my-all)
which is already available in DRUPAL. However it does not show the picture of the user with whom the relationship is. I thought of using views but in views all relationship are showed. What i need is something like this:

Followers

User A (A's Picture)   User B (B's Picture)

Following

User C (C's Picture)   User D (D's Picture)

If this can be done using views or any other way, please advice...thanks

Edit/Update:

I tried using the default block provided:
My Relationships: All relationships (user_relationships_blocks:my-all)
This is under structure/blocks...I just enable it and display it...Its showing:

Now i just need that the user picture also appears besides their name...Please advice/help...DO i have to do some changes in this block, if so, then just get me on starting line, i will carry it forward :)
Thanks


texts: Why is an empty field on translated taxonomy term showing default language value?

texts:
I have a list of translated taxonomy terms (title, description, link, image). Only some of the translated terms have a value in the link field. Set up as Entity translation

My view pulls all fields and displays the default language link when no value is present on the translated term. I actually do not want to see the default link. I'd like that field to remain empty if it does not exist on the translated term.

I've deselected language fall back in the language config and set the view to hide the field if empty, but I am still showing the default language field value.

Any suggestions?


texts: Why does core update result in 'The requested page could not be found'?

texts:
I have Drupal 8 rc-3 and I unzip 8.0.0 version files cause need to update. Site works fine and all external site pages shows but when I go to update.php and push Run database updates it goes to update.php/selection and displays the error:

The requested page could not be found.

Also this error appears in /admin/modules and /admin/appearance/settings and may be others don't know.

I run Drupal 8 on Nginx and think my config is wrong. What I need in this case? My config files you can read here tlito.ru/node/253


texts: Put a field in views with the vocabulary of the taxonomy term from a contextual filter

texts:
I have a view which accepts taxonomy terms as contextual filters.
Now, what I would like to have is to put the vocabulary of the term in a field. Relationships?...
On the nodes that arewhown by views there are two fields with taxonony terms, and the view can be sorted by both. I want to access the very one the view is filtered with.


texts: How to create a drush command without drupal?

texts:
I'm attempting to create a drush command for use outside of a Drupal install.  It's basically a script to make a copy of a distribution starter kit and do some string replacing.  I'm following the sandwich example.

I'm running into two issues...

1) I created mycommandfile.drush.inc in a new folder.  If I try to run the command it says the drush command cannot be found. So I copied the file to my /.drush folder and it finds the command.  Any idea why that would be the case?

2) The second issue is that with the file in the /.drush folder it is telling me that I need a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command.  In my command declaration I have 'bootstrap' => DRUSH_BOOTSTRAP_DRUSH.


texts: Where should I put a method that loads referencing entities?

texts:
I have done the following more than once in my module now:

<?php
$fields = FillPdfFormField::loadMultiple(
  $this->entityQuery->get('fillpdf_form_field')
    ->condition('fillpdf_form', $entity->id())
    ->execute());

fillpdf_form_field.fillpdf_form is an entity reference field pointing at a FillPdfForm. One form can have many fields.

I want to refactor this out into its own helper. My first thought is to do it in a service (because I need to inject QueryFactory), but I wasn't sure if there was a more clever place to put it. I also couldn't find a generic "load referencing entities" method anywhere.


texts: I'm new in drupal(2 days), never used it before. I have taken over this site knowing nothing about it and right away got new assigment to create clustered looking map and markers should be put from already data in drupal site. So there is a page on the site https://esc.gsfc.nasa.gov/view-all-saves that shows all information needed to place markers on the map. How do I connect to that table, loop through records to call google API to place markers. Do I have to create my own php file and put inside the root? I looked in database and couldn't find any tables that stores that data.


texts:
I have this situation that I need to redirect to a certain page (internal) after the delete of account of user.

I tried using Rules but it isn't working, also tried using $form_state['redirect'] but still FAILED.

Any help will be greatly appreciated.

Thank you!


texts:
In drupal 7, I want to render block into another block, for example block-1 into block-2.
I guess I should put some PHP code into block-2, but I don't know what the code could be?


texts: Bibliography module and zen subtheme - export not working properly

texts:
I have a problem with the Bibliography Module and a zen subtheme in D7. When I go to the main /biblio page, to watch all my publications, up right there is my export all link "Export 0 results: BibTex". It is zero, though there are several publications showed and when I click on the BibTex link I can download them all as a bib-file properly.

In the moment I switch to any other theme or the zen main theme (no subtheme) the zero is disappearing and the proper number shows up next to the export link. Even when I use a plan new zen subtheme, without any customizations, it does not work again.

What could be the issue here, any ideas?


texts: I want a Functionality in Private message module drupal 7.x. That the message I am creating should be saved as a draft. how do I achieve this ?


texts: How to let site member to access vertical tab?

texts: How to let site member access the picture above?


texts: How to add a comment using service api when uuid_service module is enabled

texts:
How to add a comment when UUID and services are enabled
The url which we tried is :

http://localhost/api/comment/uuid_of_new_comment (PUT request)
with json raw data:

{
    "comment": {
        "uuid":"uuid_of_forum ",
        "subject": "testing"
    },
    "uuid":"uuid_of_new_comment ",
    "type":"comment"
}

I know that it is not correct. But was not able to find a proper documentation for this any where. So trying some random things !!!

It will be highly helpful if some one can suggest where to find proper documentation for uuid with services .


texts: Module always returns the default language in hook_theme()

texts:
I am developing a custom block that shows a different image URLs for different languages. Currently, I enabled English and French.

The code I am using is the following one.

function MODULENAME_theme($existing, $type, $theme, $path) {
    $currentLangCode = \Drupal::service('language_manager')->getCurrentLanguage()->getId();
    $imageUrl = "";
    # If current language code is english
    if ($currentLangCode == "en") {
        $imageUrl = "English image url"
    } elseif ($currentLangCode == "fr") {
        $imageUrl = "French image url"
    }
    return [
       "modulename_block_template" => [
            "variables" => [
               "description" => [],
               "image" => $imageUrl,
               "current_language" => $currentLangCode
            ],
       ],
    ];
}

The problem is that the value for $currentLangCode is always 'en'.

What can I do to get the current language?


texts: After moving document root, pages can't be found

texts:
Drupal 8 installed on shared hosting.  To access the site from the web during development, I installed D8 in /www/d7/d8.

Then I moved d8, which contains the D8 install, to /www/d8 and then set my document root in Cpanel to d8.

The theme and blocks load, and I can fill out the form at /user/login, but after that, every time I try to access a page, I get an "access denied" message and the link is pointing at mysite.com/d8/page instead of mysite.com/page.

I looked in settings.php and .htaccess but I couldn't find any references to a base directory.

How can I get my D8 site working after moving the directory and changing the document root?


texts: how to request multiple public image sizes from a field's filename?

texts:
this node endpoint - http://cms.tripchi.com/drupalgap/node/35921 - in my Service includes...

field_photo: {
und: [
{
fid: "810",
uid: "1",
filename: "dxb-airport_1.jpg",
uri: "public://dxb-airport_1.jpg",
filemime: "image/jpeg",
filesize: "64389",
status: "1",
timestamp: "1408433735",
uuid: "697b5fd7-a968-4f6d-b5a0-558ff0f76680",
rdf_mapping: [ ],
alt: "DXB",
title: "DXB Airport",
width: "390",
height: "270"
}
]
},...

using javascript - similiar to this http://cms.tripchi.com/mobile-app/js/index.js - I want to be able to request the large/medium/small dimensions of this public image dynamically - without changing the field_photo's settings in Drupal's.

I have the content-type's image style configured per the image below:

When the field's "Preview image style" is set to "Thumbnail (100x100)", I can do

var size = 'thumbnail';
sDomain + '/sites/default/files/styles/'+size+'/public/' + utils.getLang('field_photo', obj, 'uri');

However, when I change the size variable to 'large', I get an Access Denied error.

Changing the field_photo settings to the "Large (480x480)" size does fix that, but I only want this size returned for the API via JavaScript and this changings the Drupal's front-end view/template as well.

When I change the API's Display-Suite I get no difference to what the API returns and manually reconstructing the URL with 'large' still returns Access Denied.

Is there a way to expose requesting multiple image sizes without changing Drupal's field configurations? I would accept a solution that includes a Drupal hook to create the other image sizes on the presence of a parameter.


texts: How can I get the field settings in a field preprocess hook?


texts: Simulate submission of custom form as a webform

texts:
I've a custom module that generate a form, it allows user to submit some data to website.
I'm looking for a nice way to display those submit and I would very much like to use webform module for this (because it is already used a lot in company).

I would appreciate any help especially with some snippets.

I found only this post:
Submit a custom form as a webform submission
but that is almost nothing.


texts:
I am trying to use superfish menu with Omega 7.x-3.0-rc3 and so far from bits and pieces on the internet I did the following.

Create sub-theme from the '\omega\starterkits\omega-xhtml' folder.
Add 'regions[superfish_menu] = Superfish Menu' in sub-theme info file.
Add the following in the sub-theme info file: (the paths are correct - sf folder is in my sub-theme folder.

;Superfish Stuff
stylesheets[all][] = sf/css/superfish.css
stylesheets[all][] = sf/css/superfish-navbar.css
scripts[]          = sf/js/superfish.js

Add a Menu called 'Top Navigation' to the region with an expandable Menu Item/Sub-Items.

This is where it seems I got stuck...to add the following to page.tpl.php: (I have renamed the div in the code so that it matches the correct Omega region div - region-superfish-menu)

<script type="text/javascript">
  $(document).ready(function() {
   $("#region-superfish-menu ul.menu").superfish();
  });
</script>

I cannot seem to make it work as page.tpl.php does not exist in omega theme. Any clues? Thanks for helping!

Kevin


texts: Trying to display or render values from links field within paragraph field base on its current language

texts:
I'm currently using Drupal 8 Paragraph and I'm trying to figure out how I can display or output the url and title of a link field from within a Paragraph base on the current language via preprocess. Here is a snippet of the code I'm working on.

function iom_preprocess_paragraph(&$variables) {

    $language = \Drupal::languageManager()->getCurrentLanguage();
    $variables['lang_code'] = $language->getId();
}

function _generatePrimaryLinkElement($currentNode, $entity, $title, $url) {

    $attributes = new Attribute(['class' => ['menu-item']]);

    if ($entity && ($currentNode->id() === $entity->id())) {
        $attributes['class'][] = '-active';
    }

    return [
        'attributes' => $attributes,
        'link' => [
            'attributes' => new Attribute([
                'href' => $url,
                'class' => ['link']
            ])
        ],
        'title' => $title
    ];
}

function _preprocess_primary_links_paragraph($paragraph, &$variables) {
    // Current page node
    $currentNode = \Drupal::request()->attributes->get('node');
    $activeLanguage = \Drupal::languageManager()->getCurrentLanguage()->getId();
    $links = [];

    foreach ($paragraph->field_link as $link) {
        $entity = _loadEntityByUri($link->uri);

        $title = $link->title;

        // If there is an entity and the title is not set of the link
        // use the entity title instead
        if ($entity && !$title) {
            $title = $entity->title->value;
        }

        $links[] = _generatePrimaryLinkElement($currentNode, $entity, $title, $link->getUrl()->toString());
    }

    $variables['label'] = $paragraph->field_label->value;
    $variables['links'] = $links;
}

    {{ label }}

        {% for link in links %}

                {{link.title}}

        {% endfor %}


texts: How to render a contact form as rendered entity

texts:
I have a question about rendering a contact form as a rendered entity. I have a field in my contenttype where form should be displayed. The field has the type Contact form.

In the Manage display section in the contenttype where the field is added i got only the possibility to choose Label, Entity ID or Hidden for the format.

On the page itself i got only a link to the page where the form is embedded. I searched about a solution and got something like loading and handling the form with an own module, loading the form in a hook or create a block.

So are those the only possiblities or is there a way to include the form like another entity reference (where i choose Rendered entity as the format).


texts:
The array generated gets me the information that I need, but it's created a keyed array where the key is numeric (0..length-1).  How do I change it so that key is equal to the value, so that the option value is equal to what is displayed?

$page = $sql->execute();
$pages = array();

    // Populate page dropdown
    foreach($page as $p)
    {
      $pages[] = $p->title;
    }
// Display only unique values in the array
$paged = array_unique($pages);

// Sort the array in ASC Order
sort($paged);

$form['group_owner_filter']['select'] = array(
    '#type' => 'select',
    '#title' => t('Filter by Name'),
    '#default_value' => t('Make a selection...'),
    '#options' => $option
  );

This generates:

<select id="edit-pages" name="pages" class="form-select">
    <option value="0">About Davenport</option>
    <option value="1">Academic Support Center</option>
    <option value="2">Academics</option>
    <option value="3">Adjunct Insurance Scholar Opportunity</option>
    <option value="4">Admissions</option>


texts: Webform Conditional fields showing by default

texts:
I am using the Webform Conditional module to control visibility of some webform components until a checkbox has been ticked.

I found recently that the conditional fields were showing by default (they were not doing so previously).

To add to my confusion, the same set of related fields worked just fine on some nodes but not on others.

Then just as suddenly as the problem appeared, it vanished and my conditional fields began working as expected again.

The site is soon to be LIVE and it be really bad if this problem unexpectedly returns.

Can anyone offer some opinion as to why that happened, especially if it has happened to you before, and how I can make it more stable, please?


texts: Using Drupal Commons, how can I create a node of a specific content type on group creation?

texts:
I am looking for a way to create a node of a specific content type at the same time as a group is created.

So basically, when a group is created a node of type my-content-type is created at the same time with og_group_ref pre-populated to associate it with the group just created...

I don't think there is a module for this, so... any pointers on to how to code this?


texts: Operations bulk form for custom content entity

texts:
There is a custom entity called organisation. I am trying to build a view to allow bulk delete of the entities.

I checked the view for display content and there is a field to display the checkbox(Node operations bulk form).

This field doesn't show up for the custom entity. Enabling the actions module does not help.

Adding a custom action for delete organisation does not help either. The new action shows up on the list of actions, but the "operations bulk form" does not show up on views for the entity.

Thanks in advance for your help


texts: Change drupal language from neutral to en

texts:
i have a huge drupal website(nodes) and i have to implement a multi language system now it has only one language.

I have installed the i18n module, and set another language but o can`t update the existing nodes from neutral language to EN or RO.

How can i update all the existing nodes from neutral language to EN.

Thanks


texts: Problem in finding value field--[my-field-name].tpl.php

texts:
I have a node of product content type,in which a field needs to be alter.I have created a field--[my-field-name].tpl.php and tried to override,my requirement is, field needs to check condition on field value,if condition 1 satisfies then an image will show,else a different image show,but i am unable to find the solution.

Any help is appreciated.

My written code that doesn't work,anything wrong?

<?php
    if($items['field-meal-type'] == "Non Veg"){ ?>

<?php } else{ ?>

<?php } ?>


texts:
I'm using a cck_time field (field_check_in) in my content type.
I want create a notify when this field is changed but when I try to set Data comparition in Rules Conditions I not find the entity of the field ([node:field-check-in]).
How I can do it?


texts:
is it possible to call a javascript(jquery) function once a particular page is loaded. It should be hacking the  of the whole site and to detect what the current page is and call the function. How can I actually do this?

So in a non-drupal php site, I would add a js file and have a start_product_content() function there. In the head.php file it would be something like this:

...
<head>
    ...
    <?php if $current_page = "product" ?>
    start_product_content()
    ...
</head>
...

I have explained in a different post about what I really want to achieve, long story: footer link to a page with hash changed content ready

I have achieved this when I was doing a non-drupal website, now I just want to be able to do this so that I can be closer to the target.

Thanks


texts: Videos on Views Slideshow start at the same time (Drupal 7)

texts:
I have a slider on my homepage created with views slideshow.

When I only have images on this slider, it works perfectly.

However when I have videos only (these videos are not from Youtube but are uploaded from my drive (format .mov)), as soon as the slider starts, both videos are playing... I can see my first video and there is the sound of the second video on the background...

Has anyone ever experienced this before?

Could you help me with any solution please?

Many thanks

PS: To read the videos I am using jwplayer.


texts: How to show hidden fields when using Display Suite module to manage display?

texts:
I'm an addicted user of the fantastic Display Suite module to manage the displays of content types. But it sometime happens that after changing the layout of a content type (e.g. Two stacked column) some field doesn't show up. This happened with the location node field solved in this issue by its author.

Now, I'm using the Ubercart Auction module which create a content type called 'product'. When you add a product you fill some auction settings. Then when you load the node it shows a form with auction info and links. This one:

So far so good. Now if I go to admin/structure/types/manage/product/display and change the Layout to Two stacked column I get no field to show this form. I get all other fields (body, title, images,...) but no one to show that auction form.

I know that the field is a form but I don't know how make available as field.

How can I solve this?

@lance:
Maybe I should show where are the auction setting in the node. Look this picture:


texts: Copy the images to the public folder after form submit with PLupload in a custom module

texts:
I have a custom module to create galleries using PLupload to upload multiple files. These files have a ".tmp" extension in my "/tmp" folder.

Here is an extract of my $form_state['values']:

[0] => Array(
    [tmppath] => temporary://p17g31n52jo4fvj31ds01efd189b4.tmp
    [tmpname] => p17g31n52jo4fvj31ds01efd189b4.tmp
    [name] => photo_1.jpg
    [status] => done
)

How do I save the files in my public folder with the good extension (like .jpg)?
I've tried using file_save_upload() or file_copy() but without success.

Can anyone help me?

I'm on a local server (wamp) as administrator with all permissions. The folders (tmp and site/default) are writable.

I copy here some extracts of my code.

hook_form() :

$form['create']['photos'] = array(
    '#type' => 'plupload',
    '#title' => 'Photos',
    '#upload_validators' => array(
        'file_validate_extensions' => array('jpg jpeg gif png'),
    ),
    '#plupload_settings' => array(
        'runtimes' => 'html5',
        'chunk_size' => '1mb',
    ),
);

hook_form_validate() :

$file = file_save_upload('photos', array(
    'file_validate_is_image' => array(),
    'file_validate_extensions' => array('png gif jpg jpeg'),
));

if ($file) {
    if ($file = file_move($file, 'public://')) {
        $form_state['storage']['file'] = $file;
    } else {
        form_set_error('file', t('Failed to write the uploaded file the site\'s file folder.'));
    }
} else {
    form_set_error('file', t('No file was uploaded.'));
}

It returns "No file was uploaded." I don't understand what I should put as first arguments to the file_save_upload function.