texts: Webform block not rendered context in d8

texts:
After execution the Webform "context" not rendering. It throws error like
Message LogicException: Bubbling failed. in Drupal\Core\Render\Renderer->executeInRenderContext().

I tried to render programmatically like this:

return \Drupal::service('renderer')->render($block_content);

Below is the code,

if ($node->field_type->value == 'block') {
   try {
     $block = \Drupal\block\Entity\Block::load($node->field_structure->value);
                if ($block != null) {
                    $block_content = \Drupal::entityManager()
                    ->getViewBuilder('block')
                    ->view($block);
                    try {
                        if (!empty($_POST['form_token']) && $block->getPluginId() == 'webform_block') {
                            return \Drupal::service('renderer')->renderPlain($block_content);
                        } else {
                            return \Drupal::service('renderer')->render($block_content);
                        }
                    } catch (\Exception $e) {
                        return '';
                    }
                } else {
                    return '';
                }
            } catch (\Exception $e) {
                return '';
            }
        }

What did I do wrong?


texts: Install a custom empty module break my custom style

texts:
On Drupal 8, I have a style and a empty module :

/modules/kyna/nature/

/modules/kyna/nature/nature.info.yml

name: 'Nature Theme Structure and configuration'
type: module
description: 'Example Module description'
package: Kyna
version: VERSION
core: 8.x

When my module is installed and the cache clear, my custom theme is broken:

Why my custom and empty module break my custom theme please ?
Without the addon all is OK:

Thanks.


texts: How to alter the title of a views exposed form block with code

texts: The title says it all really. My views exposed form block has no title but I want to add one through code. I have been looking through the api for hours and am totally lost. I have tried tons of things but my drupal and php chops are limited.


texts: How do I Pass a Nid to a webform and create a token for a different field on that node?

texts:
Use Case:
I have a content type called "Team" which contains an email address.  I have a view that creates a link to create a webform to contact the Team member and prepopulate the email address in a hidden field.

The Team member does not have a user profile.
I do not want to pass the email to the webform url since that would expose it.
I do understand how to pass a value to a webform.
I want to avoid maintaining a custom module.

Issue:
I hoped I could pass the Nid of the content entity and use an entity token to "lookup" the email as a default, hidden field and use that to generate the webform.  I'm sure I'm missing something fundamental (please don't down the question ...)

Question:
If I can get a token such as [current-page:query:nid] from the URL, how do I use that to get the email field [node:field-email] for say Nid=5?  Should token chaining something like [current-page:query:nid:field-email] work?  I can't seem to find good documentation on token reference chaining - that would be very helpful.

Installed D7.33, Token, Entity Token, Entity Reference.

I have viewed several similar cases that do not apply:
https://drupal.stackexchange.com/questions/95774/how-to-pass-a-token-to-webform-from-a-node-relationship
referencing/linking to an entityform and passing nid/other field information through the URL
Creating a token for the image field file path with node reference nid
https://drupal.stackexchange.com/questions/95774/how-to-pass-a-token-to-webform-from-a-node-relationship

Note: I found this module, but not sure if it is necessary: https://www.drupal.org/project/aet


texts: How to attach email from a private folder(outside root)

texts:
I'm trying to attach a file to an email. It's part of job application so a person goes to a node, presses apply and it sends an email to the creator of the node. I want to attach a CV & cover letter to it.

The problem is I'm storing the CV & cover letter in a private folder outside of drupal root. (Personal info security and all that.) The code below works for public folders. How would I got about altering it to access private ones?

function tellafriend_mail($key, &$message, $params) {

        global $base_url;

        $message['subject'] = t('Your friend thought you might like this site');

        $message['body'][] = t("Hello,\nYour friend thought you might like this site.  Please click the link below to visit.\n\n!link", array('!link' => $base_url));
        $attachment = array(
          'filecontent' => file_get_contents('http://localhost/private/counciltax.txt'),
          'filename' => 'test.txt',
          'filemime' => 'textplain',
        );
        $message['params']['attachments'][] = $attachment;
   }


texts:
In using drupal 7

1 .Is there any way to get List of logged out users for last 30 mins?
2. can we track browser close ?


texts: Performance: is preferable to use Rules or node_presave/node_save/other hook ?

texts:
we know that via hook_* we can make everything, but my question is about the use of Rules vs hook_. At high level performance programming  hook_ is better that rules, but if we consider a normal level performance ?

In a site where you have installed rules (like a commerce) is better to use hook_* or I can create a rule that exec an PHP function? In the first way (hook_*) I need to remember in which module an FooBar thing happen (say does something before node's saving, hook_node_presave) but I have max performance; second way is  via Rules module where I have all rules in one path and I can crete a Rules that is "called" when "condition" "before saving new node of node type XYZ" appair.

Which is better in a normal site ? Or in a site more than normal ?

M.

PS: sorry for my bad english.


texts: How can I make a view contextual filter work with a term name that may contain forward slashes?

texts:
I need to create a view filtered by a term name that has spaces converted to dashes and non-alpha-numeric characters removed. A non-alpha-numeric is required  to match the existing/old site path structure and remove forward slashes in the term names that are causing the view term name contextual filter to fail.

For example, a node may have a term reference with the term name of Americas/Caribbean. The URL arg passed to the view would be americas-caribbean. There does not seem to be a way to use the term name context filter with sanitized term name arg.

I've spent days and got very close, but my filter view breaks if the term name contains forward slashes. I suspect other characters in the term name may cause it to fail also.


texts: Entityform Recaptcha doesn't show notifications

texts:
I have an entityform in Drupal 7 site that uses the recaptcha module to protect against spam. It works nicely except for the fact that it doesn't show a warning or notification when it's not filled out/didn't pass.

What could be the problem here? If I change it back to the simpler math captcha then validation does work.


texts: How to move fields from profile page to a new page

texts:
By default, there are some settings that are on the edit profile page in drupal. e.g. contact settings. Others appear e.g. private message and share content settings as modules (private message and user relationship) are installed.

Is it possible to move all these to a new page with its own path (www.example.com/settings) and menu (named settings)?
Can this be done with Views? If yes, can the concerned field on the profile page be hidden?

Thanks in anticipation.


texts: New User Registration Sequence for Services 3.4?

texts:
This comment outlines a working way to login with the new CSRF token:

POST to /rest/user/login (nothing in headers). Construct the $cookie from session name + id
GET to /services/session/token (include $cookie in the headers). Save the $token returned.
Include $cookie and $token in the headers of subsequent requests of a logged in user.

That sequence works even though the first POST happens without sending the token. (The documentation suggests that the token should be used for any POST requests, which does not work in this case.)

What is a working sequence of HTTP requests to register a new user account? I'm looking for what requests to make in what order - not implementation code.

UPDATE: To be clear, I'm not looking for the login sequence. I need a sequence of requests (similar to login example above) that allow a new user to *register* their account.

Failed Attempt with system/connect:

1. GET:services/session/token

2. POST:system/connect
      Content-Type: application/json
      Accepts: application/json

3. POST:user/register
      Content-Type: application/json
      Accepts: application/json
      X-CSRF-Token: [token]
      Cookie: [session_name]=[sessid]
      Body: {
               "name":"drupalspec0rVzsWAU",
               "pass":"PYKSItFK",
               "mail":"drupalspec0rVzsWAU@drupalspec.com"
      }

The Drupal user is created correctly, but the request in step 3. times out.


texts: Change name of a tab for a specific content type

texts:
I have a content type Organizations which is an OG Group. I would like to change the default tab name "View" only for this OG group(or content type). Tab tamer module helps with it but it does not allow the change of the name of tabs for a specific content type.

I use sky theme(an Adaptive theme). I wrote the following code in the theme template file,

function sky_preprocess_page(&$vars) {
  if ($vars['node']->type == 'organization') {
    foreach($vars['tabs']['#primary'] AS $index => $tab) {
      if($tab['#link']['title'] == t('View')) {
        $vars['tabs']['#primary'][$index]['#link']['title'] = t('Organization Home');
      }
    }
  }
}

But this doesn't help too


texts: Drupal incorrectly reporting that permissions need to be set on settings.php

texts:
I've updated a site to v8.5.3.  Checking the status report I have various messages.  One says:

Not protected
    Protection disabled
   - The file sites/default/settings.php is not protected from modifications and
    poses a security risk. You must change the file's permissions to be non-
    writable.
   - The file sites/default/settings.local.php is not protected from
     modifications and poses a security risk. You must change the file's
     permissions to be non-writable.

I've checked these files and they are set to 444, there are no write permissions set.  Drupal seems to be reporting this incorrectly.

Is there anything else I need to do or am I missing anything?


texts: I would like to load my own, but Drupal seems to forcefully load it's own by default behind the scenes.


texts: How to displayed fixed menus, extracted from the main menu?

texts:
I am using a Bartik subtheme, and would like to split the main menu into 4 smaller menus, and display them in the four footer columns, side by side. I would like the same menus to be displayed on all pages.

How would I do this?


texts: drupal 7 - views conditional not working

texts:
I have a content type that has an External Link (field type: Link) which is an optional field. So users can either type in a url or not. I've created a View where I want to show the latest 2 content types.

I want to be able to display the nodes where its Title either links to the External Link or the url of the content. I already have Views Conditional enabled but I dont think Im setting it up correctly because the nodes arent using the proper url. The url is "http://localhost.test:8888/[path]. The 2nd node is correct though, it has http://yahoo.ca which is the External Link that I used.

If anyone has any clue why the settings arent correct, please let me know why. THanks.


texts: How to change the image style for image preview in node-add/edit form?

texts:
IN a related question, "How to set image style for media browser in node edit form?" one response noted that "Once you have chosen the image and clicked save and the overlay is closed, images are display in the "Media thumbnail" image style."

How can I change this automatic behavior such that the preview image is displayed in my custom image style?


texts: How to use search_excerpt() function from core search module?

texts:
I want to use the function search_excerpt() to generate excerpts. Unfortunately this function is returning exactly same text as I submit. For example I tried this:

$test = (search_excerpt('test', 'this is a test'));
print $test;

This is returning "this is a test".

I was expecting more something like:

  "this is a test"

What is wrong in my code?


texts: How can I hide the username on a custom user-profile.tpl.php page?

texts:
I'm making a custom user-profile.tpl.php page and want to put the "business name" field where the Title/Username normally occurs and print the username elsewhere.

The username doesn't appear in the list at:
Administration » Configuration » People » Account settings » Manage Display so I can't remove it there.

My guess is that I need to add some logic to page.tpl.php to not print it on user profiles and then I need to know the variable to add it to user-profile.tpl.php.

Can anyone help me with this?


texts: How can I filter SOLR results to show only nodes with images? There seems to be no support for image fields. I don't mind writing custom field mapping or something like that but some guidelines would be really appreciated.


texts: JSON Menu Link Without Invoking Init Hooks?

texts:
Our Drupal site utilizes a number of menu hooks to return JSON from an API we manage in a separate Web API. We also have a number of intensive tasks that happen on each page load via the hooks_init in several custom modules.

The issue we're facing is that the tasks in hook_init are only required for actual pages, and should not be executed when all we want is JSON output. Is there a way to ONLY execute the hook_menu endpoint, and no other Drupal code?

We have several pages that make 3-4 requests to Drupal JSON menu links, which means that we also run our unnecessary hook_init tasks 3-4 times as well -- plus once for the actual page request.

There must be a way to circumvent the usual Drupal pipeline to perform these actions?

Here is an example of one of our JSON menu hooks:

function membership_details()
{

    // Get membership details from API, and return as JSON
    $details =  sendCurlResponse(/* ENDPOINT */);
    drupal_json_output($details);
    drupal_exit();
}


texts: How do I find which file contains a function?

texts: How do I find where a Drupal function is defined? For example, in which Drupal file is db_query() defined?


texts: What kind of attacks does the patch for SA-CORE-2014-005 (Drupal 7.32) prevent?

texts:
Reading up on https://www.drupal.org/node/2357241 and the technical details at https://www.drupal.org/SA-CORE-2014-005, as well as the actual patch which is simply:

diff --git a/includes/database/database.inc b/includes/database/database.inc
index f78098b..01b6385 100644
--- a/includes/database/database.inc
+++ b/includes/database/database.inc
@@ -736,7 +736,7 @@ abstract class DatabaseConnection extends PDO {
     // to expand it out into a comma-delimited set of placeholders.
     foreach (array_filter($args, 'is_array') as $key => $data) {
       $new_keys = array();
-      foreach ($data as $i => $value) {
+      foreach (array_values($data) as $i => $value) {
         // This assumes that there are no other placeholders that use the same
         // name.  For example, if the array placeholder is defined as :example
         // and there is already an :example_2 placeholder, this will generate

I'm wondering what kind of request could be made that utilizes this exploit?


texts: "Trying to get property of non-object" for image_get_info

texts:
I have the following code:

  $imageinfo = image_get_info($newfile->uri, $toolkit = FALSE);

  $newrecord = array(
     blah blah blah
     'width' => $imageinfo->width,
     'height' => $imageinfo->height
    );

The width and height lines get the "Trying to get property of non-object" error.

If I print the contents of the $imageinfo array, it's this:

Array
(
    [width] => 630
    [height] => 315
    [extension] => jpg
    [mime_type] => image/jpeg
    [file_size] => 30334
)

I must be doing something stupid here.  What is it?


texts: I am using poorman Cron Run and it is giving error like this: "Cron has been running for more than an hour and is most likely stuck." plz help if any solution for it??


texts: Multisite Drupal with Organic Groups problem.. custom /user and /user/register links for each group?

texts:
I am using Organic Groups for as a solution for Drupal Sub sites, it is working perfectly, even themes are switching via Organic groups theme but I am having problem with /user/register and /user pages.

I want to pass context to user pages like user/groupname/register or user/groupname , so how can I do it ? because /user currently throws me out of the currently active theme for Organic Group.

Also one more thing, the Group Id which I want to pass should be as alias?like pathauto paths.


texts:
I'm working in a projet where I have to show a collection of books. In this website I managed using the books navigation block, for one collection with many books, with css I managed to set a tree view and indication where you are, but only allows one collection of books.
The problem is that I have to make as least 23 collections, each of them belonging to a province.

Is there a way to replicate that book navigation for each collection?
Could I make them with block menu with tree view and the same CSS style?
I think the concept of book collections is missing, from the editorial point of view.


texts: How to manage by cron a long-running queue of very many items

texts:
I'm creating a File Checker module that verifies files managed by Drupal actually exist at the uri where Drupal believes they are.

It places an item in a queue for each file entity. As there could be large amounts of files on a site, so there can be large amounts of queue items (10000, 100000 ...). Each item (file entity) can take a few seconds to process if the files are stored remotely e.g. on Amazon S3 or Dropbox. So the queue could take hours to process.

File checking can be scheduled to happen at regular intervals, i.e. by cron, so queue processing needs to happen by cron queueWorkers.

What is the best way to handle the duration of these cron queueWorkers? Their plugin annotation has a cron time option (default 15 seconds) that controls how long they run for when awoken by cron. I could either:

1) set their time option to something very long like 86400, so they can process queue items for a whole 24 hours if they need to; or

2) set their time short like 60 seconds, and use something like the Ultimate Cron module to specify that just this queueWorker is woken up every 60 seconds (and not other cron tasks).


texts: Can hook_field_extra_fields be used with field collections?

texts:
I have a field collection view that I have to manipulate some data on before it gets displayed, so I was going to use hook_field_extra_fields with the extrafield_views_integration module.  This worked great for me on nodes, but I'm not seeing the extra field get displayed on field collections.  Is there any way to get around this?

function my_module_field_extra_fields() {
  $extra['field_collection']['my_field_collection']['display'] = array(
    'some_extra_field' => array(
      'label' => 'TESTING FIELD 123',
      'description' => 'This is a test of hook_field_extra_fields on FCs',
      'weight' => 100
    ),
  );

  return $extra;
}


texts:
I am trying to understand the code in EntityAutocomplete::validateEntityAutocomplete().

if ($match !== NULL) {
  $value[] = array(
    'target_id' => $match,
  );
}
elseif ($autocreate) {
  /** @var  Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface $handler */
  // Auto-create item. See an example of how this is handled in
  // \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::presave().
  $value[] = array(
    'entity' => $handler->createNewEntity($element['#target_type'], $element['#autocreate']['bundle'], $input, $element['#autocreate']['uid']),
  );
}

What is $handler->createNewEntity() actually doing?

Does it directly create a new entity in database? If the answer is yes, why is the entity created during validation? What is the purpose of this?

Still in validateEntityAutocomplete if you scroll further down, you can see:

$valid_ids = $handler->validateReferenceableEntities($ids);

$valid_new_entities = $handler->validateReferenceableNewEntities($new_entities);

I understand that one is validating the ID and the other one is validating $newEntities, but what exactly does it do?


texts: Drupal.behaviors when no AJAX is involved?

texts:
I would think there would already be a straight forward answer to my very simple question however I couldn't find it.  Forgive me if this is a duplicate.

My question is:

If I only want my jQuery to run on normal page load and don't care about when data is loaded by AJAX, should I still be using Drupal.behaviors instead of $(document).ready ?  If so should I be doing anything with the context and settings parameters?

I'm mostly adding/ removing classes however there a couple of instances where I'm appending/ removing elements.

Thank you.


texts:
I dont know what i doing wrong but for reasons the tab on user page doesnt appear!
i have like three tabs which i place my self in custom module and they ok.. But now trying to use the principle i used nothing works.
below is my code! Any suggestions?

$items=array();

$items['user/%user/mysite-news'] = array(
'title' =>t('Мой Новости'),
'description' => t('yo news.'),
'page callback' => 'mysite_news',
'page arguments' => array(1),
'access callback' =>array('view kupon'),
'type' =>MENU_LOCAL_TASK,
);
$items['user/%user/mysite-news/my-news'] = array(
'title' =>t('Мой Новости'),
'description' => t('see your news.'),
'page callback' => 'mysite_news',
'page arguments' => array(1),
'access callback' => TRUE,
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight'=>-15,
);

//and my call back function
function mysite_news($account){
  $my_name=t('my name is $c',array('$c'=>$account->name));
return $my_name;
}
?>

if i visit the link
user/1/mysite-news/my-news

the result is displayed, "my name is admin".
But the tab doesnt show on user page.. please help.


texts:
I need to get all the names of the entity, my entity is called 'a_process'?
How can I write such query in Drupal 8?

$nodes = entity_load_multiple('a_process', $name);


texts: How to set paragraph margin when editing in CKeditor?

texts:
I want to make a subtitle on a page, which needs to be centered and to have no space between it and the title.

In the CKeditor window, I entered the subtitle as the first line of text and centered it. In source, CKeditor represented this as:

...

which results in a blank line above. I tried to remove the blank line by changing the above code to:

...

or just

...

But CKeditor didn't like either of those. It removed the center tag and replaced the
 with
.
I also tried to add an instruction in CSS as either:

...

or as:

...</style>

CKeditor also didn't like either of those and just removed the style attribute from the first one and removed the span tag from the second.

I'm not very conversant in CSS, so I'm not sure the above code is properly formed. But the problem is that CKeditor is just removing it so I don't even get a chance to troubleshoot errors in the CSS.

CKeditor seems determined to have that blank line there. How can I get it to let me adjust this spacing between paragraphs (not globally, but on an individual paragraph)?

Thank you.


texts: How to set defined image weight in Drupal

texts:
I just now noticed this:

My uploaded image for article has more weight in kb as my uploaded original image;

I have set my GD toolkit image quality to 100% because I am compressing images myself as I wish (in IrfanView) ...

So, my original image is of dimensions: 549 X 803 58.1 kb

In webpage I see image of dimensions: 328 X 480 and 113.73 kb !!!

I expect the image to be of my defined weight ; or even smaller , if the size is smaller; but not larger....


texts: Set value of List field of a node with multiple values

texts:
I'm attempting to programmatically generate nodes of a custom content type from a form plugin. For most fields I don't have any trouble at all. For example for the title field I can set the value like so.

$node->title->value = t('My title');
$node->save();

However there is also a list(text) field that allows for multiple values. And I'm not sure how to go about saving values of field with multiple values. I'm assuming if there was only one value allowed I could do it just like I set the title in the previous example, but how do I deal with it when the field is an array? As a test I performed a die statement of the field on a node that already had values in that field to take a look at what it looks like and this was generated:

Array ( [0] => Array ( [value] => test_3 ) [1] => Array ( [value] => test_4 ) ) 1

But I'm not sure what to do with that. How would I set the field value of a list field with multiple values allowed?


texts: How do I query entities to get all fields values - including referenced ones (INNER JOIN)

texts:
I have custom content types in my Drupal 8 module and want to query nodes of those content types programmatically.

Querying through entityQuery is easy. However, I have also entity reference fields (so a node of one content type has a relation to a node of another content type).

Is there a way how to make a query that will return 'rows' of field values, exactly as when I use raw SQL INNER JOIN? I want to have an associative array of all field values, not only the specific node, but also the referenced nodes/entities.

Right now I have an own class to handle this, but it's way too much complicated and, I believe, unnecessary, so I guess I'm missing something.

Thank you.


texts: How to translate field collection which has unlimited values?

texts:
My configuration:
latest dev entity translation and field collection module + patch.
I tried:
1. Entity translation is on just for taxonomy term and node, but not for field collection (it triggers notice: not translatable because of valid base path...)
I have taxonomy term with field collection (unlimited value). In FC field there are just two fields that needs to be translated. FC and fields inside FC have set "enable field translation by users".
With these settings I can create a term, set values to FC fields on default language and save. Then I can translate and set values to FC fields for second language and save. All good when checking if it did saved 2 different values - each for own language. Then I create view which is used on panels and is using termID as context filter. View has relationship on FC field and I added FC fields to show.
What happens: on view when I preview with term ID (context filter) I get correct result for the language in URL (en/admin/structure/views..). Also when I change URL to another language prefix I get translated fields in that language. But translated fields don't show on actual term pages.
2. Beside what I described in 1, I also enable entity translation for field collection. Notice about valid base path is still there, but I applied patch and i don't get errors when adding or translating FC.
With this configuration I create fresh FC with new fields and enable field translation for all of them. On term I set some values for FC fields and save it. I repeat this step when translating. But when I save translations and open them they are empty. On the next fill they remain. But the view for this configuration is still not showing right values for selected languages.
Does anyone have any hint what I am doing wrong? I really need to fix this issue on my site and I am short on time.
What I need is to translate FC field (and it's fields) which can have unlimited values.


texts:
I have added scripts[] = js/add_property.js to my .info file which works perfectly.

That loads the JavaScript for every page though, so how do you do it so that it only loads for the .tpl that it is used in?


texts: Tell me, how do I enter, via the module Services has, if I have "pass_reset_token" and then change the user password? How to password recovery. Tell me please! I'm desperate =(


texts: Fatal error while editing and deleting menu items

texts:
Facing one issue in deleting the menu items on my Drupal 8 Site.
Steps to reproduce:
Add a link to main menu.
Create Child terms under one link.
Delete the parent term.
After deleting the parent link child links stays they don't get deleted
automatically.
If you want to edit/manually delete those links then a Fatal error is
coming.
Error Message : Drupal\Component\Plugin\Exception\PluginNotFoundException: Plugin ID 'menu_link_content:adad91f8-19c7-48c7-a88e-67aae4edd21e' was not found. in Drupal\Core\Menu\MenuLinkManager->getDefinition() (line 207 of /var/www/crain-platform/docroot/core/lib/Drupal/Core/Menu/MenuLinkManager.php).
After doing some debugging i see the menu data missing from menu_link_content table.Anyone have any idea why this is coming and how to fix this issue?


texts: Using Views and adding ALT and TITLE to an image

texts:
I've been attempting to add my node Title to the image ALT and TITLE fields during their output in a view.

I am using the Media module to mange my images, and I have included the image_url_formatter module to offer up the image URL information in my view.

I attempted the advice in this post How to add alt and title attributes to an image gallery View?
and it almost works however this is occurring:

Within the View, If I alter the Image field to output the Image URL this works and I get my option of URL information in both preview and actual view.
If I then attempt to Rewrite the results, I suffer from two issues.

The [field_image-fid] outputs a numerical number only. i.e 1 or 4 etc...
The [field_image-width] & [field_image-height] output the actual image height and width rather then the selected image style, i.e. Thumbnail.

Anyone suffered from these issues, or know the answer?


texts:
How can I add custom classes for links into main menu in Drupal 8. This is template for my main menu called menu--main.html.twig

{% import _self as menus %}
{{ menus.menu_links(items, attributes, 0) }}

{% macro menu_links(items, attributes, menu_level) %}
  {% import _self as menus %}
  {% if items %}
    {% if menu_level == 0 %}

        {% for item in items %}

            {{ link(item.title, item.url) }}
            {% if item.below %}
                {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
            {% endif %}

        {% endfor %}
    {% else %}

        {% for item in items %}

            {{ link(item.title, item.url) }}
            {% if item.below %}
                {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
            {% endif %}

        {% endfor %}
    {% endif %}

  {% endif %}
{% endmacro %}

And I need to achieve this result:

Úvod

O škole

Aktuality

Pedagógovia

Dokumenty

História

Informácie o štúdiu

Fotogaléria

Kontakt

My problem is that I don't know how to set custom class for  tags. Is there any way how can do it using link() function. In Drupal 7 is l() function but attributes aren't similar. l() has also third attribute with possibility to add options. Is it true, that link($title, $url) accepts only 2 parameters? Because I can't find the way how to send options for link($title, $url). I don't insit on link() function, so if there is some better way please let me know. I'm open to new ideas :)

Thanks


texts: Access CiviCRM event fees via Drupal Views

texts: I'm trying to access the Regular Fees data inside of Drupal Views 3. I can see the Fee Label but can't see how I pull in Regular Fees? I've looked at Price sets and setting up a relationship but this seems overly complex for whats required. Wondering if anyone has attempted this/had any joy? Using Drupal 7.42 and CiviCRM 4.7.1


texts:
Using a view to display links to nodes sorted into categories (using grouped field on taxonomy) it's working great, however there is upwards of 20 nodes per term and I would only like to show 5 at a time. Ultimately an ajax load more on each of the terms is what I'm after, but a simple ajax pagination would work fine also.

Obviously standard pagination doesn't work for this use case as its paging all of the results where I want to add pagination to each of the terms.

I have been messing with views_limit_grouping, which could be a reasonable base to work from.

Another idea would be to create an individual views for each of the terms and insert them however with upwards of 30 terms creates a very messy views setup.

Appreciate any and all insights.


texts: How do I render a block programmatically with the standard template?

texts:
I'm using the following code to render a set of blocks programmatically:

$region_content = [];
$block_manager = \Drupal::service('plugin.manager.block');
$blocks = $this->getBlocks();
foreach ($blocks[$region_name] as $key=>$block_config) {
  $instance = $block_manager->createInstance($block_config['plugin_id'], $block_config['config']);
  $region_content[] = [
    $instance->build();
  ];
}

The contents of $block_config['config'] look like this:

[
  'provider' => 'search',
  'admin_label' => '',
  'label' => 'Search form',
  'label_display' => TRUE,
  'third_party_settings' => [
    'block_aria_landmark_roles' => [
      'role' => '',
    ],
  ],
]

The resulting $instance object seems to work correctly, and when I render $region_content I do indeed get the contents of the blocks as expected. But they are not wrapped in the block template. I thought I might have to do something like this:

$region_content[] = [
  '#theme' => 'block',
  'contents' => $instance->build(),
];

...but that doesn't work at all. How do I take this $instance object and render it using the standard block template? Or am I completely off course here?


texts: Is it possible to control a User's Role based on their Email Address?

texts:
Currently I am emailed everytime time an employee at my company needs their account role upgraded to 'Authenticated' to 'Employee', any suggestions on a way to automate that process?

Thanks!


texts: How to fetch all the details of a marketplace organization's page on Drupal.org

texts:
I am new to Drupal.
I am trying to fetch all the details of a marketplace organisation's page, which are visible on drupal.org.

I am using the node id to access "https://www.drupal.org/api-d7/node/xxxxxxx.json" (where "xxxxxxx" is the node id).

I am not getting all the data in the response.

Is there any way to fetch all the data of a particular page in json?


texts:
I use module commerce_stock on Drupal 8.

I get back product data and I create a product with its data. I have to create a field field_stock (Stock level) in variations, which I create with the following code.

$variation =  ProductVariation::create(['type' => 'default', 'sku' => 'sku1', 'status' => TRUE, 'price' => $price]);

How do I add the value to field_stock?


texts:
I am using Drupal 8.1.8. It is giving me many JavaScript errors.

Uncaught TypeError: Cannot read property 'permissionsHash' of undefined
Uncaught TypeError: Cannot set property 'StateModel' of undefined
Uncaught TypeError: Cannot set property 'AuralView' of undefined
Uncaught TypeError: Cannot set property 'KeyboardView' of undefined
Uncaught TypeError: Cannot set property 'RegionView' of undefined
Uncaught TypeError: Cannot set property 'VisualView' of undefined
Uncaught TypeError: Cannot read property 'uid' of undefined
Uncaught TypeError: Cannot read property 'currentPath' of undefined
Uncaught TypeError: Cannot read property 'currentPathIsAdmin' of undefined
Uncaught TypeError: Cannot read property 'url' of undefined
Uncaught TypeError: Cannot read property 'currentQuery' of undefined

There is no error in my local copy, but it happen when I uploaded in live hosting.

How can I fix this?


texts: image style not applied porgrammatically

texts:
I create below function to create image style programmatically

function imh_get_image_from_uri($image_uri, $style) {
    $derivative_uri = image_style_path($style, $image_uri);
    $success = file_exists($derivative_uri) || image_style_create_derivative($style, $image_uri, $derivative_uri);
    $new_image_url = file_create_url($derivative_uri);
    return theme_image(array('path' => $new_image_url));
}

and call in my tpl with

 imh_get_image_from_uri($node->field_cast_image['und'][0]['uri'],'215x317');

and  a example of image created path is

http://mydomain.com/sites/default/files/styles/215x317/public/Hugh%20Jackman-2.jpg

I check the images style , as expamle this image image style  set  to scale 215 * 317,every thing seems work good but when I see image directly I see the image in this path not resized ( I call my function with another image style but also they are not resize or scale or ....) ,
The images that use build-in drupal image style work correctly but when I use top function to load image style programmatically the image style action (resize, scale ,... ) not applied, the image create on that path but noting applied on it.

where is problem?

update
Also I try

$build = array(
  '#theme' => 'image_style',
  '#path' => $image_uri,
  '#style_name' => $style,
    );
return render($build);

output
<img src="http://mydomain.com/sites/default/files/styles/215x317/public/Hugh%20Jackman-2.jpg?itok=PcP0uFjT" width="215" height="317">

but the problem exists yet, the file in the image path exists but not resized.
it seems change it by style ( not resized main image)


texts: How do I set a content entity field as required?

texts:
How do I make a field in a content entity required in Drupal 8?
I tried FieldConfigInterface::setRequired(), but it doesn't seem to work.


texts: Adding a dependent field with the Business Rules module makes the loading time and queries increase abnormally

texts:
I have an entity form with a dependent field. The dependent field is created following this guide and using Business Rules module.
Everything works fine, but now the form takes an insane amount of time to load (7011.24 ms) and makes an insane amount of queries (4040).
These queries come from business_rules.process and many of them are repeated. For example, this one SELECT name, value FROM key_value_expire WHERE collection = :collection AND expire > :now is made 1287 times.
If I disable the Bussines Rules module or remove the dependent field, everything goes to normal, with ~120 queries and normal form loading time.
Is there something I am missing? If not, any alternatives to make a dependent field?


texts: Is there any way to use Facets for a Views' exposed filters without using Search API? This is for Drupal 7.


texts: Using FormState::setError() in Form::submitForm()

texts:
I am writing a form in Drupal 8 that provides user values to a web service, which will either act on them or send back an error.

How can I display that error message to the user?

Here's the situation in code:

class FooForm extends BarForm implements FormInterface {

  protected $fooClient;

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state {

    $result = $this->fooClient->post($form_state->getValue('bar'));

    if ($result->hasProblems()) {
      // This doesn't seem correct: Posting to a web service is not idempotent.
      $form_state->setErrorByName('bar', $this->t('Problems.'));
    }
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {

    $result = $this->fooClient->post($form_state->getValue('bar'));

    if ($result->hasProblems()) {
      // This throws a LogicException.
      $form_state->setErrorByName('bar', $this->t('Problems.'));
    }
  }
}

Drupal treats 'validate' and 'submit' as two separate steps, but the web service doesn't. The only way to determine if the values are fully 'valid' is to get the web service to look at them, which is an operation that potentially has side effects.

validateForm() and other form validation handlers are not supposed to contain business logic, since they may get called multiple times during the life of the form, particularly if AJAX is involved.

However, all errors are meant to be resolved before submitForm() and any other submission handlers are called. FormState::setError() enforces this by throwing a LogicException if you try to create any. Also, submitForm() clears away the user's values, and the next page builds the form from scratch.

I've seen this similar question for Drupal 7. Back then, it was possible (if discouraged and ugly) to use form_set_error() in the submit handler or the form builder. As far as I can tell, that flat-out doesn't work in Drupal 8.

How am I supposed to interact with RESTful web services? Is there a way to pass errors up from a form submit handler? Or is there a way to ensure a validation handler runs once, only once, and only if all other validation passes? Or is there some way to do this with multi-step forms?


texts: Views, getting nodes type 1 which user have NO node of type 2 published that references the node type 1

texts:
I'm using drupal 7.20 with Views 3 module.

I've a content type "Homework" and a content type "Solution". The Solution content type has an entity reference field that references nodes of type "Homework".

Well, I'm trying to set up with Views a new Tab in the user profile menu: "Pending Homeworks" that lists all Homeworks that has no Solution referencing them and published by that user.

Best an example:

"Homework 1" <- "Solution (by user 1)"
             <- "Solution (by user 2)"
             <- "Solution (by user 3)"

"Homework 2" <- "Solution (by user 1)"
             <- "Solution (by user 3)"

"Homework 3" <- "Solution (by user 3)"

In this example, user 2 hasn't published yet his Solution for Homework 2 and Homework 3, so, the View I want, must output: Homework 2 and Homework 3.

Thanks in advance.


texts: hook_node_insert, hook_entity_insert, hool_node_presave not triggering

texts:
I just got a  drupal 7 site with a custom theme handed over to me.

I have to do some stuff when a curtain content type is created by a user, but i am so far unable to get any related hooks working.

So far i tried to add the following to the tempalte.php file

function MYTHEME_node_insert($node) {}

function MYTHEME_entity_insert($entity, $type) {}

function MYTHEME_node_presave($node) {}

Changing MYTHEME to the name of my theme.
I doubbledchecked and the template.php file is used.


texts: How can I keep a record of user email addresses when users update their email address?

texts:
I have a site where a minority of users are causing trouble by registering with one email address and then changing to another email address. Email Change Confirmation helps with this, but I would also like to keep a record of changed email addresses per-user, preferably in the Drupal UI.

I am thinking about making an email address field and using rules to automatically add an old email address when the user changes his or her email, but if there is a more robust solution I would love to know about it.


texts: Display Suite View Only Showing Default Display

texts:
Custom displays are no longer showing up on the Front-End; instead only the default view is showing. The following message displays next to the template section on the display page (structure/types/manage/contenttype/display/display_name) "This layout is defined in code: disable layout." When I click "Disable Layout" link it takes me to a new page and displays: "This operation is not possible."
What does this error mean? What is the cause? How can it be corrected?

It is not clear whether this error is the reason the display is not showing on the frontend. I have tried accessing the display several different ways include through a view, shows the default (view-mode-full) content display, not the one it is set to. Though the default view is picking up my assigned custom classes.

It is as if Display Suite will not display more than one display on front-end. I can customize and edit "full content" display but this displays on front-end regardless.


texts: Nodes being imported from the Feed module not being published

texts: I have finally accomplished the communication between my 2 websites through the Feed module. I am exporting xml and I am using the XPath XML Parser to receive the nodes. The problem that I have now is that it is only updating nodes that have been previously imported through the feed, even though some of that content was already on the other website. The ones that are being imported are left with the Unpublished status, even though they were initially published on the website that exported them. How can I change this?


texts: How can I alter Entity Auto Complete Results?

texts:
I want to alter entity auto complete results in hook_form_alter.
My functionality is

  1) I have a entity reference of taxonomy and bundle is tags which is
  Level 2 (Field Name: Product Child)

  2) In this I select one term from Level2

  3) I have another entity autocomplete which refers to taxonomy
  tags Level 1 (Field Name: Product Parent)

Now my question is if i select one Level 2 Term in Product Child Field , is there any option to show only parent terms of that Product child field in Product Parent Field
Like :

Cabbage (L1)
 -> Fruit (L2)
 -> Flower (L2)

Lemon(L1)
 -> Lemon Fruit(L2)
 -> Eatable (L2)

If I select Fruit in Product Child field I want to show only Lemon in Product Parent Field. Is there any way to do this.


texts: Upgrading Drush 6 to Drush 9 on Centos 5 server

texts:
I haven't updated drush in awhile and looking to update it to the latest. I'm not exactly sure how it was installed originally. But when I do a which drush, it shows it resides in /usr/bin/drush

When I do a drush dl drush - I only get the option to upgrade to 7.x only.

How can I update it to Drush 9?

Can I just do a git clone of the drush repo from: https://github.com/drush-ops/drush

Then do I just do a checkout of the drush 9 tag? But how do I make it the default drush application to run? Or do I just overwrite the file in /usr/bin/drush?

FYI: My linux server admin skills aren't up to par.


texts: The TB Mega Menu Responsive Menu Icon Not Working Correctly

texts:
For some reason the responsive menu icon is showing at the bottom and to the left of the menu bar on mobile devices. Specifically on iPads. On Andriod devices the menu icon doesn't even show where it should be. I inspected the elements and noticed that the placement section where the icon menu supposed to go (tb-special-menu) is set to display none:

Not sure if that's the issue. When I set it to tb-mega-menu it works but it replaces the design of the full site as well.

Example of it not working: http://quirktools.com/screenfly/#u=http%3A//thepoliticus.com/content/why-bernie-sanders-was-right-ignore-question-religion&w=768&h=1024&a=22

Example of how it should look: http://quirktools.com/screenfly/#u=http%3A//demo.themebrain.com/%23magz&w=768&h=1024&a=22


texts:
I have a custom 404 error page, and I just want a quick module that hides the 404 page title, if the user arrives at a 404 error.

I've found a D7 function that looks like it would work, checking for '404 Not Found' in the http header, and adding a class that I can target with CSS. But I'm not sure how I'd do something like this for D8.

Here's what I've got:

function MYMODULE_preprocess_html(&$variables) {
  $headers = drupal_get_http_header();

  if (isset($headers['status']) && $headers['status'] == '404 Not Found') {
    $variables['classes_array'][] = 'page-404';
  }
}


texts: What is the best way to update Drupal periodically using a cron job?

texts:
Previously I periodically updated Drupal sites by using a cron-job with a "drush up -y" script running every Wednesday 15,16,17,18,19,20,21,22 hours UTC. which is when "Security releases happen" according to https://www.drupal.org/node/1173280

Lately I noticed that when security issues are really urgent, the update can take place just any time during the week. I now let the update cron take place every hour every day. I am aware this is not an ideal solution. What is the better solution to update Drupal with a cron script say within the hour of any release?


texts: How to preserve kint output upon form submit redirection?

texts:
I've attached a custom submit handler to node add/edit form for the article content type:

$form['actions']['publish']['#submit'][] = 'my_module_node_edit_submit';

In the handler, I am trying to inspect the form state values with kint (via the devel module):

kint($form_state->getValues());

Upon submission of the form, I'm able to briefly see the kint output on the screen, but I am also presented with this message:

  Redirecting to http://localhost/example.com/node/123

The page then redirects back to view the node, and the kint output is gone. How can I preserve the kint output so it is available after the redirection?


texts: Comment notify options confusing for users

texts:
I am using the Comment Notify module so that users can be notified when someone responds to their comments in forums. On a users account page the options are very confusing - there is a tick-box to receive notifications, and also a drop-down, which only contains two options: "No notifications" and "Replies to my content". The text below the drop-down is also confusing.

Have I got a configuration issue, or is this working as designed?


texts: How to choose different dimensions for the video player in different views (views and video module)

texts:
I've created a new content type with a video. For the content i choose as the default resolution 640*360. Now i need to create a grid with the views module and i'd like to be able to choose a different (smaller) resolution.

How can i do this?Do i need to do this programmatically or can i do this through the interface?


texts: Do something in hook_node_load only when displaying node

texts:
Is there a way to run a specific block of instructions in hook_node_load only when the node is loaded do be displayed and not when it's loaded in the edit form?

The only way I can imagine is analyzing the url and if the pattern is node/%/edit don't execute the code.

I know I can also use hook_node_view, but in this case I have to add render arrays instead of simple values


texts: Commerce Billy: adding new textarea in form

texts:
To add an new textarea ('invoice_special') for input on admin form of module commerce_billy, I copied the below code from commerce_billy_pdf.admin.inc into a custom module, but the new form field does not appear. If I edit file commerce_billy_pdf.admin.inc directly, the field appears. What I am doing wrong here?

    function commerce_billy_pdf_admin_form($form, &$form_state) {

  $settings = variable_get('commerce_billy_pdf_text_settings', array());

  $form['commerce_billy_pdf_settings'] = array(
    '#tree' => TRUE,
    '#type' => 'fieldset',
    '#title' => t('PDF Text settings'),
  );

  $form['commerce_billy_pdf_settings']['invoice_header'] = array(
    '#type' => 'textarea',
    '#title' => t('Invoice header'),
    '#default_value' => isset($settings['invoice_header']) ? $settings['invoice_header'] : '',
  );
  $form['commerce_billy_pdf_settings']['invoice_location'] = array(
    '#type' => 'textfield',
    '#title' => t('Location'),
    '#default_value' => isset($settings['invoice_location']) ? $settings['invoice_location'] : '',
  );
  $form['commerce_billy_pdf_settings']['invoice_date_format'] = array(
    '#type' => 'textfield',
    '#title' => t('Date format'),
    '#default_value' => isset($settings['invoice_date_format']) ? $settings['invoice_date_format'] : 'Y-m-d',
  );
  $form['commerce_billy_pdf_settings']['invoice_text'] = array(
    '#type' => 'textarea',
    '#title' => t('Invoice text'),
    '#default_value' => isset($settings['invoice_text']) ? $settings['invoice_text'] : '',
  );
  $form['commerce_billy_pdf_settings']['invoice_footer'] = array(
    '#type' => 'textarea',
    '#title' => t('Invoice footer'),
    '#default_value' => isset($settings['invoice_footer']) ? $settings['invoice_footer'] : '',
  );

  $form['commerce_billy_pdf_settings']['invoice_special'] = array(
    '#type' => 'textarea',
    '#title' => t('Invoice special'),
    '#default_value' => isset($settings['invoice_special']) ? $settings['invoice_special'] : '',
  );

  $form['commerce_billy_pdf_logo'] = array(
    '#type' => 'textfield',
    '#title' => t('Logo'),
    '#default_value' => variable_get('commerce_billy_pdf_logo', 'misc/druplicon.png'),
    '#required' => TRUE,
    '#description' => t('Path to invoice logo.'),
  );

  $css_files = variable_get('commerce_billy_pdf_css_files', array(drupal_get_path('module', 'commerce_billy_pdf') . '/css/pdf.css'));
  $default_value = "";
  foreach ($css_files as $file) {
    $default_value .= $file . "\n";
  }
  $form['commerce_billy_pdf_css_files'] = array(
    '#type' => 'textarea',
    '#title' => t('Inline CSS files'),
    '#default_value' => $default_value,
    '#required' => TRUE,
    '#description' => t('One CSS file per line.'),
  );

  $form = system_settings_form($form);
  // Use custom submit handler.
  $form['#submit'] = array('commerce_billy_pdf_admin_form_submit');
  return $form;
}


texts: How to control content access based on value of a List (text) field in user profile?

texts:
When my users sign up, they must choose whether they are a Man or a Woman, via a List (text) field. If a user chooses "Man", they should only be able to see Woman users on the site. Likewise, if a user chooses "Woman", they should only be able to see Man users on the site. The users cannot edit the value of this field once it is set. The user is assigned a custom user role (man or woman) when they sign up, based on what they choose from that field.

I am also open to using Profile2 with two Profile types (man and woman), but I would still need a method to restrict one profile type from viewing other users of that same profile type.

How can I set up a permission that will allow this type of access restriction? I have not been able to find a solution to solve this scenario.


texts: How to add a Custom Operation in the Book Admin Edit Form's Operations?

texts:
As the title says I want to know how to add a custom operation in the drupal 8 book admin edit form's operations. I need this for my module in which I want to provide Add Sub Page operation for the user.

Upon clicking on the operation, I want to execute a function to add a new page to the parent page. I know how to add pages programmatically (Thanks to Lisa regarding help for adding pages in the book) , the only thing that I need is this operation entry in the drop down list.

Can somebody please help?


texts: Create Nodes for multiple languages in webform?

texts:
I have a default Node for English, which will be translated when user logs in based on the user locale. Beside I need to create a separate node for ja(Japanese) like (mydomain.com/node/7).

I created a node(nid=7) by changing the 'Language neutral' to 'Japanese' language. when I hit the node it not gets translated to Japanese.

Is there any way to get it translated?


texts: How to override output of checkout page in Commerce

texts: I want to override the output of the order completion page. I need to include custom markup, as well as data from the order. As a matter of personal preference (and for organizational purposes), I'd rather do this in code, in my module, rather than in Rules. Can anyone point me in the right direction?


texts: How to add new fields to field collection programatically Drupal 7

texts: Is there any way to add new fields to a field collection programatically Drupal 7?


texts: Weird spacing in Views content after unspecified module update

texts:
I'll preface this by saying, I am very new to Drupal and pretty much have no idea what I am doing.  I did not develop the site I am going to reference.  With that said, recently I updated a handful of modules, I couldn't say which ones (I can't remember) and now there is some weird spacing on one of our pages which was created with Views.

The page that is throwing a weird spacing issue is https://tarltontest.law.utexas.edu/about-the-library/hours

The issue is that the data range between parentheses is now on three lines, rather than inline with the title, ie Fall Semester Hours, Fall Finals Hours, etc.

I cannot figure out where the spacing is coming from.  I cannot see anything in the Views settings that would cause this.  IS this a template file>  CSS? I don't even know where the parentheses are coming from.

I would love any help in identifying where to possibly look to fix this.


texts:
Sometimes when I submit a new post (story node) or update one, it take 10-15 minutes for the page to finish loading. I figured it was some problem with the database so I did a SHOW FULL PROCESSLIST the next time I noticed it happening. It was stuck deleting from the boost_cache_relationships table. Why is this taking so long and what can I do to fix this?

Here's part of the output from SHOW FULL PROCESSLIST showing the problem query:

+---------+---------+-----------+-----------------+---------+------+----------------+------------------------------------------------------------------------------------------------------+
| Id      | User    | Host      | db              | Command | Time | State          | Info                                                                                |
+---------+---------+-----------+-----------------+---------+------+----------------+------------------------------------------------------------------------------------------------------+
| 2208461 | upgrade | localhost | dane101_upgrade | Query   |   28 | Sending data   | SELECT SUM(score) FROM search_index WHERE word = 'when'                                              |
| 2208478 | upgrade | localhost | dane101_upgrade | Query   | *1088* | updating       | **DELETE FROM boost_cache_relationships WHERE base_dir = 'cache/normal/www.dane101.com' AND page_callb**  |
|


texts:
I created my form but inserting the base does not work also radios type does not appear in the form

<?php

/**
 * @file
 * Contains \Drupal\contact_form\Form\ContributeForm.
 */

namespace Drupal\contact_form\Form;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ChangedCommand;
use Drupal\Core\Ajax\CssCommand;
use Drupal\Core\Ajax\HtmlCommand;
use Drupal\Core\Ajax\InvokeCommand;

/**
 * Contribute form.
 */

class ContributeForm extends FormBase implements FormInterface{
    protected $accepted_domains = ['gmail.com', 'yahoo.com'];

    /**
     * {@inheritdoc}
     */
    public function getFormId() {
        return 'contact_form_contribute_form';
    }

    /**
     * {@inheritdoc}
     */

    public function buildForm(array $form, FormStateInterface $form_state) {

        $form['FullName'] = array(
            '#type' => 'textfield',
            '#title' => $this->t('Full Name'),
            '#required' => TRUE,

        );
        $form['Email'] = array(
            '#type' => 'email',
            '#title' => $this->t('Email address'),
            '#required' => true,
            '#size' => 60,
            '#maxlength' => 128,

        );

        $form['Feedback'] = array(
            '#type' => 'radios',
            '#title' => $this->t('Feedback'),
            '#description' => t('Type of feedback'),
            '#default_value' => 0,
            '#options' => array(
                0 =>'Comments or suggestions',
                1 => 'Questions',
                2 =>'Report a problem(s)',
                3 =>'Other',
            )
        );
        $form['Subject'] = array(
            '#type' => 'textfield',
            '#title' => $this->t('Subject'),
            '#required' => true,
        );
        $form['Message'] = array(
            '#type' => 'textarea',
            '#title' => $this->t('Your Message'),
            '#required' => true,
            '#cols' => 90,
            '#rows' => 10,
        );

        $form['captcha'] = array(
            '#type' => 'captcha',
            '#captcha_type' => 'recaptcha/reCAPTCHA',
            '#title' => $this->t('Captcha:'),
            '#required' => true,
        );

        $form['save'] = array(
            '#type' => 'submit',
            '#input' => TRUE,
            '#value' => 'save',
            '#submit' => array('buildForm')
        );

        return array(
            '#form' => $form,
            '#theme' => 'contribute',

        );

    }

    /**
     * {@inheritdoc}
     */

    public function validateForm(array &$form, FormStateInterface $form_state) {
    }

    /**
     * {@inheritdoc}
     */
    public function submitForm(array &$form, FormStateInterface $form_state) {
        $name = $form_state->getValue('FullName');
        $email = $form_state->getValue('Email');
        $subject = $form_state->getValue('Subject');
        $type = $form_state->getValue('TypeFeedback');
        $msg = $form_state->getValue('Message');
        $field = array(

            'FullName' =>  $name,
            'Email' => $email,
            'TypeFeedback' =>  $type ,
            'Subject' => $subject,
            'Message' =>  $msg,
            'Etat_message'=>  '',
            'Date_contact'=>  '',
            'adresse_IP'=>  '',
        );
        db_insert('contact')
            ->fields($field)
            ->execute();
        drupal_set_message("succesfully saved");

    }
}


texts: field_type with existing data cannot have its keys changed

texts:
our site is throwing up the following error:

A list field (field_type) with existing data cannot have its keys changed. in list_field_update_forbid() (line 363 of /modules/field/modules/list/list.module).

I've already researched and found on the drupal developer site a documentation about this error: https://drupal.org/node/1294264

But honestly I don't know what to do.

Has anybody an idea?

Thank you and best wishes

Chris


texts: How do you add a input and a select field with webforms?

texts: I would like to add a select element that has an input field attached, so the user can input a value from the list without having to scroll through hundreds of options. Is this possible to do with the module webforms? I have researched it and the only thing I can find is the chosen module but I have no idea how the two integrate, and alot of people say it is incompatible in some browsers. Thank you for your help.


texts:
I have a paged table that extends the TableSort class. The thing is, I would like to add some special parameters to the header links, so I need to extend the TableSort class. The problem is, it is not recognizing my new extended TableSort (MyTableSort) class. This is the code, any help would be greatly appreciated:

<?php
// $Id: RadiosDemo.module $
//This module demonstrates the radios default value problem.

class MyTableSort extends TableSort {
/**
* Compose a URL query parameter array for table sorting links.
*
* @return
*   A URL query parameter array that consists of all components of the current
*   page request except for those pertaining to table sorting.
*/
  public function tablesort_get_query_parameters() {
    return drupal_get_query_parameters($_GET, array('q', 'sort', 'order', 'nid'));
  }
}

/**
* Implementation of hook_menu().
*/
function RadiosDemo_menu() {

  // Added a link to navigate to the demo node display page
  $items['RadiosDemo/Problem'] = array(
    'title' => 'Demo of Pager Problem',
    'page callback' => 'RadiosDemo_displaynodes',
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

/**
 * Function which will display all the nids in a paged table
 */
function RadiosDemo_displaynodes() {

  $headers = array(
    array('data' => 'nid', 'field' => 'nid', 'sort' => 'ASC'),
    array('data' => 'status', 'field' => 'status'),
    array('data' => 'title', 'field' => 'title'),
  );

  // Select nid from published nodes with 20 pager limit
  $query = db_select('node', 'n')
    ->condition('status', 1)
    ->extend('MyTableSort')
    ->extend('PagerDefault')
    ->orderByHeader($headers)
    ->limit(30)
    ->fields('n', array('nid', 'title', 'status'));

  $results = $query->execute();

  $rows = array();

  foreach ($results as $result) {
    $row = array();
    $row[] = $result->nid;
    $row[] = $result->status;
    $row[] = $result->title;

    $rows[] = $row;
  }

  $html = theme('table', array(
   'header' => $headers,
   'rows' => $rows,
  ));

  $html .= theme('pager', array(
    'parameters' => array(
      'banana' => 'banana'
  )));

  return $html;
}


texts: What encoding does Drupal use for generating URLs

texts:
I wanted to decode the 81f4c5ed/5a05/4432/a542/6205dde00d46 bits of the URL into something which can be understood, like a date etc.

The URL was generated through Drupal CMS. What kind does Drupal use to encode URL, I would like to decode these


texts:
Our multisite is having issues.

we have a subsite called /wikifix
some of the URLs in this subsite are /wikifix/wiki/...

now we have another subsite called /wiki.
as soon as we make our symlink, the pages on /wikifix that have wikifix/wiki/ in their path start giving drupal page not found errors.
Testing on another subsite in the multisite /kids shows similar issues, /kids/wiki also gives page not found errors

both sites work and are accessible, the issue is only when the path contains the name of a different subsite.


texts: Custom Content Entity Type: links annotation

texts:
I created a Custom Content Entity Type with all the basic CRUD operations. It is working but I do not understand how the links work in the entity annotation and therefore not why they are necessary.

My annotation:

/**
* @ContentEntityType(
*   id = "myent",
*   label = @Translation("My entity"),
*   handlers = {
*     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
*     "list_builder" = "Drupal\myent\Controller\MyentListBuilder",
*     "form" = {
*       "add" = "Drupal\Core\Entity\ContentEntityForm",
*       "edit" = "Drupal\Core\Entity\ContentEntityForm",
*       "delete" = "Drupal\Core\Entity\ContentEntityDeleteForm",
*     },
*     "access" = "Drupal\myent\ContactAccessControlHandler",
*   },
*   base_table = "myent",
*   entity_keys = {
*     "id" = "id",
*     "uuid" = "uuid",
*   },
*   links = {
*     "edit-form" = "/",
*     "delete-form" = "/",
*   },
* )
*/

As you can see I just inserted the necessary slash at the links section. The actual routes to the operations have to be defined in the "myent.routing.yml" no matter what so I do not see why I should write them again in the annotation.

If I remove the links section completely the operations are gone too. So I have to write the links section in the annotation even though they have no additional information for the operations.

What am I missing?


texts: dbQuery with condition and date_format()

texts:
I have a request that should return a list of nodes that have a creation date <= 6 months. It works well with $query->where() but I want to use $query->condition ().

Query with CONDITION:

$query = db_select('node', 'n');
$query->innerJoin('field_data_field_date_de_publication_news', 'fn', 'fn.entity_id = n.nid');
$query->innerJoin('field_data_body', 'fb', 'fb.entity_id = n.nid');
$query->fields('n', array('title', 'status', 'nid'));
$query->fields('fn', array('field_date_de_publication_news_value') );
$query->condition('fn.field_date_de_publication_news_value', 'MONTH(NOW())-6', '<=');
$query->orderBy('fn.field_date_de_publication_news_value', 'DESC');
$rows = $query->execute();

But if I replace CONDITION with WHERE it works:

$query->where(" MONTH(fn.field_date_de_publication_news_value) <= MONTH(NOW())-6" );

I also tried:

$query->fields('fn', array("DATE_FORMAT(FROM_UNIXTIME(field_date_de_publication_news_value), '%m')") );


texts: open node-reference links title in popup

texts:
I want in my node view pages, node reference links open in popup window or lightbox window.
Does anyone have a solution?


texts: How to override page.tpl.php for given content type?

texts:
Please suggest that naming convention for content type

content type machine name : test_content

I need to define separate page.tpl for this content type.

I tried page--test_content.tpl.php and cleared cache. But that template is not activared.
Any issue in naming convention.


texts: Modifying only one field with a twig template

texts:
I have a content type that has multiple fields.   I'm fine with the generic display view for all but one of those fields.   Is it possible to use a twig template to modify only one of those fields?
For example:
Content type: Stuff and Things
with Fields:
Body,
URL,
Notes,
Status,
Peer Review
I want to modify the URL field and leave the rest alone... is this doable, or do I have to render each field in the twig template?


texts: How to display fields horizontally in a node?

texts:
A node lists all its field vertically one after the other by default. Does anyone know of a way to display at least some of the fields horizontally?

Like so:

FIELD 1               FIELD 2              FIELD 3


texts:
Is it possible to change node content types? I have a bunch of story nodes and I would like to create several content types and reassign each story to a different content type. Is there a way to automate this either through the drupal administration area or the database?

Thanks!
Jane


texts: Drupal Less cache keeps generating cache file that does allow access to the apache server

texts:
How do I ensure that auto-generated css cache files (related to the Less module) are being generated with the permissions necessary for the server to access.

Currently, whenever I clear all caches (with drush cc all), I lose all of my site's css styles and get the following error:

  LESS could not create a directory in sites/default/files/less/52741f7e343834.56376384/sites/all/themes/my_custom_theme/css

When I go to look at the permissions (ls -l) for the files in sites/default/files/less, the directory 52741f7e343834.56376384 (which I assume is the new cache file the server is trying to create the other stuff in) it has the wrong ownership <correct-user>:<correct-user>, rather than <correct-user>:apache (it's centos, so that's the apache server group). All the other cache directories have the correct owner permissions.

So how do I ensure that the system is creating these cache files properly such that I don't have to set the file ownership every time I clear the cache to get my styles back?

This is a new problem for my site and I suspect it is because I updated the Less module for Drupal 6 and added the lessphp library to my site (though perhaps I am mistaken).


texts: Is it possible to load next page of the view inside a pane (by using pager)?


texts: Why does my D7 User view only display 6 results in Block View, but all results in Page view?

texts:
I have a simple  D7 view that lists all usernames and a couple of associated fields (business name, contact name) in table format.  It has exposed filters on those fields, and about 200 users to list, sorted by creation date.

In Page View, this works perfectly as expected : I can page through a list of active users, and filter them.

However, when I try to embed the same view as a block, it displays only 6 results and no pager or exposed fields.

I've changed the pager ID - didn't help.  I changed the pager ID on the other block shown with this one, too.  I have no contextual filters or relationships set up. I tried changing to 'show all results' without a pager - still just those six results.

Any thoughts on where to start looking to fix this?

ETA
I checked the queries being run, and as suggested, they turn out to be different in page view to block view.

This is my page view query:

SELECT users.name AS users_name, users.uid AS uid, users.status AS users_status,
 users.created AS users_created, 'user'
AS field_data_field_business_name_user_entity_type
FROM
{users} users
WHERE (( (users.status <> '0') ))
ORDER BY users_created DESC
LIMIT 30 OFFSET 0

But my block view query is different, all the exposed filters are applied, and I can't change them:

SELECT users.name AS users_name, users.uid AS uid, users.status AS users_status,
users.created AS users_created, 'user'
AS field_data_field_business_name_user_entity_type
FROM
{users} users
LEFT JOIN {field_data_field_business_name} field_data_field_business_name
ON users.uid = field_data_field_business_name.entity_id AND
(field_data_field_business_name.entity_type = 'user' AND
 field_data_field_business_name.deleted = '0')
LEFT JOIN {field_data_field_contact_name} field_data_field_contact_name
ON users.uid = field_data_field_contact_name.entity_id
AND (field_data_field_contact_name.entity_type = 'user'
AND field_data_field_contact_name.deleted = '0')
WHERE (( (users.status <> '0') AND
(field_data_field_business_name.field_business_name_value LIKE '%%' ESCAPE '\\')
AND (field_data_field_contact_name.field_contact_name_value LIKE '%%' ESCAPE '\\') ))
ORDER BY users_created DESC
LIMIT 30 OFFSET 0


texts: drush Destination directory already exists

texts:
I am currently running Drush on windows via cygwin.

$ drush --version

drush version 5.9

Now when I am trying to do a $drush up; I am getting the following error :

$ drush up

Checking available update data ...                                   [ok]
Update information last refreshed: Thu, 11/21/2013 - 11:11

Update status information on all installed and enabled Drupal projects:
 Name     Install  Proposed  Status
          ed       version
          version
 Drupal   7.23     7.24      SECURITY UPDATE available
Do you really want to continue? (y/n): y
Destination directory                                                [error]
c:/websites/www.website.com/drupal-7.24 already exists.

So at the moment I have now way of updating drupal via drush.
Previous updates worked fine. I have even tried the version from github, and still has the same issue.

When looking at the --debug info :
It downloads the file fine,
extracts the files to drupal-7.24 (summary just before the error)

  x drupal-7.24/robots.txt
  x drupal-7.24/COPYRIGHT.txt
Calling chdir(C:/websites/www.website.com) [31.37 sec,    [debug]
13.26 MB]
Destination directory                                                [error]
c:/websites/www.website.com/drupal-7.24 already
exists. [31.37 sec, 13.43 MB]

So I am not sure how to get around this, or if there are some other commands I can try.

[updated edit]

More info:
My Cygwin Version

$ uname -r
1.7.20(0.266/5/3)

O/S
Windows 8.1

This might be a cygwin error, as I am getting a problem with "FAST_CWD pointer."
And I am running an older version of cygwin.


texts: Relation and Entity Share a Field / Reference Each Other

texts:
I can't seem to get this to work. I've searched and search, and maybe I'm not using the correct terminology, but I need to add a custom field to a Relation that reads a value from the Entity its related to. Or another way to put this, I need a field from the Relation to update a field in an Entity when the Relation is updated. Example:

Entity -> Worker
Relation -> Employed At
Entity -> Company

I want to update my custom field "classification" through the Employed At Relation and then see that change reflected in the "classification" custom field in my Worker Entity.


texts: How do I allow user to select table column they want in Drupal View?

texts:
I am trying to create a Human Resources Portal for my organisation.
I have to create a table via View to show all the list of staff of the organisation which is about 500 employees.
My major problem is that not all the column is needed at every situation, sometimes they need to create a table with only few columns at a time, so I need to expose the users (HR Dept) the columns so they can decide which one they need at a time.
I have tried MediaTable module but that does not allow the user to hide columns themselves.
I need like a checkbox of columns to be selected.
Thank you


texts:
Since the "Plain Text" format can't be deleted (within /admin/config/content/formats) the Text format pull-down will always contain it plus the default format that you would like for the user to use (i.e. Full HTML) when creating content.

When the user creates content (i.e. /node/add/article) I would like the "Text format" pull-down to be disabled so that they can't change it for non-administrators.

How can I disable the "Text format" pull-down for users that are creating or editing content?


texts: How to add link to custom module configuration form in Drupal 8

texts:
I'm working on a custom module that has a couple configuration form for controlling it's settings. I want to add a link to this form to the admin configuration UI. The new link to my settings isn't appearing, but the form works fine if I navigate directly to it using the URL.

# stripedonation.links.menu.yml

stripedonation.admin:
  title: 'Stripe Donation'
  description: 'Manage settings for strip donations'
  parent: system.admin_config_system
  # menu_name: main
  route_name: stripedonation.settings
  weight: 1

NOTE: I cleared the cache after adding this.

# stripedonation.routing.yml

stripedonation.settings:
  path: '/admin/config/stripedonation'
  defaults:
    _form: '\Drupal\stripedonation\Form\SettingsForm'
    _title: 'Stipe Donation Settings'
  requirements:
    _permission: 'administer site config'

I also tried adding the key shown below to my *.info.yml file and it didn't help

# stripedonation.info.yml

name: "Stripe Donation"
type: module
description: "Adds Stripe Donation form for ThinkShout vetting exercrise"
package: EmersonThis
core: 8.x
# configure: stripedonation.settings

In case it matters...

# stripedonation.settings.yml
stripe_pub_key: ''
stripe_secret_key: ''

I'm expecting my menu link to show up here (but obviously it is not):

I've studied the following documentation:

https://www.drupal.org/docs/8/creating-custom-modules/defining-and-using-your-own-configuration-in-drupal-8
https://www.drupal.org/docs/8/api/configuration-api/working-with-configuration-forms

I've also studied every "how-to" I could find:

http://befused.com/drupal/menu-links-custom-module-d8
https://www.thirdandgrove.com/creating-a-simple-configuration-form-Drupal-8
http://valuebound.com/resources/blog/step-by-step-method-to-create-a-custom-form-in-drupal-8

Still no menu in the admin UI. What am I doing wrong?


texts: Possible cause of the one time login link sent via e-mail to be broken?

texts:
edit: it appears to be a bug, reported here https://www.drupal.org/node/2329723

When I, as the Admin, add a new user and let Drupal notify him via mail, the one-time login link is broken:

http://www.exmaple.com///www.exmaple.com/user/reset/...

Any idea why Drupal would create such a link? There is no module which alters this mail or tokens.


texts: Changed Comment Module and database table - how to revert changes?

texts:
Yesterday, I posted this thread which was subsequently locked for being too localized. I think this is much more searchable (and I still need help!) but I'm sorry for the bad thread.

Like mentioned in that thread, I changed different files in the comments module folder and added columns to the database table. This sort of disabled comments, both the settings in page content settings and their appearance on the page normally.

I tried to fix this by: uploading a completely new 'comments' folder (I have a back up if that was a bad idea) from a new copy of the core, and deleted those table fields. Still no sign of fixing any of the problems I created.

How do I return the comments to their normal setting so I can approach the altering I was planning on doing the right way this time?


texts: drupal 7 user registration custom url returning a blank page

texts:
I dont think my url is working. I am trying to use page/medical then use the page callback to redirect to medical_reg_form_user_register_form_alter. Instead of displaying the form I get a blank page.

function medical_reg_user_register_menu() {
  $items['page/medical'] = array(
    'page callback' => 'medical_reg_form_user_register_form_alter',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK
    );
  return $items;
}

function medical_reg_form_user_register_form_alter(&$form, &$form_state, $form_id) {
  $form['#theme'] = 'medical_register';
  $form['actions']['submit']['#value'] = t('Nextdfd');
}


texts: What is the best practice for writing a link to the screen through t()?

texts:
In Drupal 7, one could do the following one line::

t('Visit !mylink', ['!mylink' => l('my website', 'http://example.com')]);

But that no longer works in Drupal 8 or 9 .  So far, I've tried this:

First I create a link, Drupal 8 style:

$mylink = Link::fromTextAndUrl('my website', Url::fromUri('http://example.com'));

Then try to create a string that can be printed.  I've tried toString():

t('Visit @mylink', ['@mylink' => $mylink->toString()]);

However, we're not supposed to do this. The API docs says:

  Do not use this method to render a link in an HTML context. In an HTML context, self::toRenderable() should be used so that render cache information is maintained.

So I try to use toRenderable():

t('Visit @mylink', ['@mylink' => render($mylink->toRenderable()]);

But PHP 7.2 doesn't like it.  The call to t() produces the following Notice:

  Notice: Only variables should be passed by reference ...

Fair enough - but how is this done?

I could not find how to do this described in any of the obvious docs, such as:

https://www.drupal.org/docs/security-in-drupal/sanitizing-output
https://www.drupal.org/docs/security-in-drupal/writing-secure-code-for-drupal

So my question is:
What is the best practice for writing a link to the screen in Drupal 8?

(Environment: Ubuntu 20.04 LTS, Drupal 8.8.6 (core + devel), procedural code - e.g. hook_help()).


texts: How do I set 'Locale settings' fieldset, in the user profile form, to uncollapsible?

texts:
After running a dpm($form) via hook_form_FORM_ID_alter I couldn't see the 'Local settings' in the form defintion of the user profile form. I did a search for 'locale settings' on all the code and found the value I need to alter (I think) on line 2016 of system.module. So I tried:

function MY_MODULE_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
  $form['timezone']['#collapsible'] == FALSE;
}

Cleared the cache. Fieldset is still collapsible?


texts: Character escaping rules for $form_state['redirect']

texts:
I'm writing a redirect for the form submit function, the redirect part looks like this

$form_state['redirect'] = array(
// $path
'catalog/search',
// $options
array('query' => array("circle_op=<&a%5Bvalue%5D=28&a%5Bl%5D" => $location, 'p' => $keyword,)),
// $http_response_code
    302,
  );

The problem is that the "circle_op=<&a%5Bvalue%5D=28&a%5Bl%5D" part on redirect transforms into "%253Ccircle_op%3D<%26a%255Bvalue%255D%3D28%26a%255Bl%255D%3D" inside URL.

Please explain, how to pass this key value correctly?

Thanks


texts: Using custom ranking for some searches and not others in D7

texts:
I want to define a custom search ranking, and only use it on a special page, without affecting the regular search feature.

Looking at the code in node.module, I see how I could hook MODULE_ranking() in a custom module, however it won't be applied to the query unless global variable node_rank_X setting is enabled in the global config.

I could munge the global $conf for my one specific page, but this seems ugly.  Is there a more sensible way to approach this?


texts:
How can I make a pager for views output to limit them at 10 entries?

$view = views_get_view('myview', 'default');
$view->override_path = $_GET['q'];
$view_output = $view->execute_display('page_1', array($tid));


texts: Is it possible to redirect user to another form depending on values entered in the first form

texts:
I have 3 Webforms named A, AA and AB, In form A there are few question with Yes and No options.

I am looking for a way to direct user depending on the selected options, If user select all the options as Yes and press submit the form should direct the user to form AA else to form AB.

Is there any easy way/Module to check the Form A and direct user to either AA or AB depending on the selected options

I assume rules could be a choice, but i can't figure out.


texts:
I'm looking for a way to build what I call 'StackExchange style' url's with Drupal 7. In my definition, that means:

A node has a path alias containing both a unique identifier and the node title. For instance, if I'm writing a story and every chapter is a node, chapter 4 (titled "The day I became a lobster") would get www.example.com/chapter/4/the-day-i-became-a-lobster.
If a user knows the chapter, but not the title, he can just go to www.example.com/chapter/4, which will redirect to www.example.com/chapter/4/the-day-i-became-a-lobster.
If the title changes (www.example.com/chapter/4/the-day-i-became-a-lobster becomes www.example.com/chapter/4/the-day-i-became-a-penguin), or if the url is mistyped (www.example.com/chapter/4/the-day-i-become-a-lobster), the old or incorrect url redirects to the new / correct url.

I want this behavior because:

In some cases, my users know a product number but not the title. This way they can easily figure out the url.
Having the title in the url is good for SEO and user experience.

I guess the best approach would be to build the complete url using Pathauto and set up a redirecting mechanism that kicks in when the path start with 'chapter/[id]' but it's not a valid path alias.

Of course I can create a custom module, implementing hook_menu for the 'chapter/%' path, lookup the correct chapter node and call drupal_goto, but maybe there are better methods. How would you do it?

PS. I posted a similar question in the issue queue of Redirect, because that module looks related and very promising.


texts:
I have develop many custom form and added ajax functionality with the form field, Ajax code works like a charm with my custom form.

But now i have a situation where i have add ajax callback to the title field of node.

For this i am using hook_form_alter, and adding same ajax code to title, but ajax event is not firing up for title field.

below is my code:

function module_form_FORM_ID_alter(&$form, FormStateInterface $form_state, $form_id){

  $form['title']['#ajax'] = [
    'callback' => 'module_updateCategoryDropDown',
    'event' => 'change',
    'progress' => [
      'type' => 'throbber',
      'message' => t('Verifying...'),
     ],
 ];
}

function module_updateCategoryDropDown(array &$form, FormStateInterface $form_state){
  /* form category dropdown code is here */
}


texts: Horizontally sliding gallery with visible neighbors?

texts:
I'm looking for a way to create a horizontally sliding gallery, where the non-"highlighted" images can be seen to the left and right of the "highlighted" image, instead of a normal slideshow where there is just a transition to the next image in a static box.

Essentially, the functionality shown by Royal Slider, and also demonstrated on the WeArInteractive homepage under "Featured Works."

The only thing that I can find that's close is ImageFlow, but it's not quite the same and has some other odd functionality that I don't prefer.

The popular gallery/slider modules that I have found don't seem to have a built in way to do this, but maybe somebody has figure out a way to do it? I don't mind using views as part of the solution, as I'm assuming that will probably be a necessity.


texts: Form API: Hiding form option on node forces node to be unpublished

texts:
I'm using Drupal 7

I'm creating a node through a node add form. The settings are such that it should by default be published. I'm trying to hide some of the options from the user, but when I

hide($form['options']);

for some reason the node does is no longer published by default. I've tried tracing out the value of that portion of the form

drupal_set_message('Options'.'<pre>'.   print_r($form['options'], TRUE) .'</pre>');

and I get the same values when the field is visible as when it is hidden. Seems like perhaps something is fishy?


texts: How to control field_group quantity - control field group quantity

texts:
I Cant speak english very well.So sorry if my post is not very good.

When we add a field like text input or file field , we can control number of quantity of thats field.for example if number of a text field set "unlimite",user can click on a button for add another field.

So I want to give possibility to user that after click on "ADD BUTTON" a new field group add to form fields.

If show a table bottom of form (involve added field groups) , this is very good.

example :

textfield1     textfield2    textfield3

  add button

(after click this button or submit above fields , another 3 textfields show to me and submitted textfields show bellow on a table)

Is any module for this work?
thank you for your response beforehand.


texts: User profile image update from a popup window

texts: Is there a way to make the user profile image updated using overlay window from different page other than /user/edit


texts: How to access database table with drupal 7

texts:
I am quite new to Drupal. I am creating custom module which connects to the database table. I have gone through the API documentation and created a test function and tried db connect, but there seems to be an error. This is my code:

function first_db_insert() {
  db_insert('imports')
    ->fields(array(
      'name' => 'Groucho',
      'address' => '123 Casablanca Ave.',
      'phone' => '555-1212',
    )
    )
  ->execute();
  drupal_set_message('database updated');
}


texts: How do I create a view with filter on a field built using the date module?

texts: I created a content type that includes a date field.  I want to create a view that filters on this field, but it appears that the field is being seen as a text field because there are no operators for greater than or less than like I would see if I were filtering on the posted date.  I only see text based operators like length, starts with, etc.  What do I need to do?  I'm running Drupal 7.  How do I make this work?


texts:
I have made the following .tpl.php template:

<?php print drupal_render($element["term"]); ?>
<?php print drupal_render($element["search"]);?>
<?php print drupal_render($element["advanced_search"]);?>
<?php print drupal_render_children($element);?>

But the form tag is not generated, so the form cannot be submitted ... what am i doing wrong?


texts:
So, I create a view page that list the webform results, and I want to affect the administration theme to this page, How ?

Thank you.


texts: Does Drupal CORE have any built-in analytics?

texts:
I've always used Google Analtyics for my sites, but for one however I've forgotten to set it up.

Does Drupal have any built-in analytics, i.e. a module that comes with Drupal core, that I can look at just to get an idea of traffic volume?


texts: Display referenced user's email address instead of username

texts: I have a user reference field as a select list in my content type. When adding node I got a list of usernames. What I want is to display E-mails/ (or other user fields) instead of username. I tried to create entity reference view but it does not show the selected fields in the view either.


texts: Node template.tpl.php for custom view mode?

texts:
I tried this http://www.fredparke.com/blog/using-custom-template-files-different-display-modes-drupal-7, but doesn't work, gives errors and tried this How to provide template for particular view mode? kind of works, but gives errors.

My content type is product_display and view mode is Product List, created with display suite. I need this, so I could delete h2 title from it, because views forces title output via rendered entity format no matter what.

Errors I get are either Notice: Undefined index: product_display in mytheme_preprocess_node() (line 170 of /template.php).

or this http://i.imgur.com/a26bQeX.jpg


texts: is it ok to have multiple versions of jquery?

texts:
I'm facing some peculiar problems(my devel_themer is also not working). There are multiple versions of jquery included. Its not me who included them, its different modules:

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>window.jQuery2 = jQuery.noConflict();</script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
window.jQuery || document.write("<script src='/drupal/sites/all/modules/contrib/jquery_update/replace/jquery/1.10/jquery.min.js'>\x3C/script>")
//--><!]]>
</script>

I don't know if any of the following errors relate to problems:

SyntaxError: Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead jquery-1.9.1.min.js:1
Error: http://code.jquery.com/jquery-1.9.1.min.js is being assigned a //# sourceMappingURL, but already has one
SyntaxError: Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead jquery.min.js:1
Error: https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js is being assigned a //# sourceMappingURL, but already has one

should I remove them?


texts: drupal_set_message doesn't display message sometimes

texts:
I'm uploading a file, to process and display a message at the end. However, the messages that drupal_set_message is set to display are displayed sometimes and don't display sometimes, even, if the processing runs successfully in the background. The reload time restriction isn't a problem as it is set to multiple minutes and the processing hardly takes 10-60 seconds on average. Is there a way to force the page to show the messages at any cost? The drupal_set_messages that I am concerned about are the last two drupal_set_messages in the code. I've even tried using drupal_set_message(t('!shell_c', array('!shell_c'=>$shell_command)), 'status'); but the issue persists where the drupal_set_message messages are shown sometimes and not shown sometimes, rather erratically.
//Before this part of the code, there is function to create Menu ($items[])
function g_p_proc_form($form, &$form_state, $values) {
    $form['#attributes']['enctype'] = 'multipart/form-data';
    $form['filter'] = array (
        "#type" => "fieldset",
        "#title" => t("File Process <BR> "),
        "#collapsible" => TRUE,
    );
  // without this attribute, upload may fail on submit
    $form['#attributes']['enctype'] = 'multipart/form-data';
    $form['filter']['file'] = array(
        // '#title' => t('File processing'),
        '#type'  => 'file',
        '#name' => 'files[]',
        '#description' => t('Select Submit to start processing the file'),
        '#type'  => 'file'),
        '#upload_location' => 'public://',
        '#attributes' => array('multiple' => 'multiple'),
    );
    // echo '<script type="text/javascript">Drupal.behaviors.DSU_batch_report;</script>'; //christ
    if (isset($_SERVER['CONTENT_LENGTH']) && (int) $_SERVER['CONTENT_LENGTH'] > 'size based on my requirements') {
        drupal_set_message(t(" Warning message on file size"));));
        // unset($_SERVER['CONTENT_LENGTH']);
    }

    $form['filter']['submit_upload'] = array(
        '#type'  =>  'submit',
        '#value' =>  t('Submit'),

    );

    // drupal_set_message(t("in fn"));

    return $form;
}

function g_p_proc_form_submit($form, &$form_state) {
    header(current page)
    try{
        $number_file = count($_FILES['files']['name']);
        $f_name = array();
        for ($i=0; $i<$number_file;$i++)
        {
            $file = file_save_upload($i, array('file_validate_extensions' => array('pdf PDF')), 'public://', FILE_EXISTS_REPLACE);
            $f_name[] = $_FILES['files']['name'][$i]; //[]
        }
            }catch (Exception $error){
        echo 'Exception: ',  $error->getMessage(), "\n";
    }
    $n_f = count($f_name);
    drupal_set_message(t('Number of files to process: !n_f', array('!number_f'=>$n_f)));
    $fn_name = 'g_p';
    $fn_call = $fn_name($f_name);
function g_p($f_name=array()){
    $curr_l = getcwd();
    chdir('My file processing PHP script location ');
    $n_f = count($f_name);
    $shell_command = shell_exec("file_processing_php_script_name.php");
    //header("Location: "Current file processing module menu site"); //Commented out
    drupal_set_message($shell_command); //print_r statements from the file_processing_php_script_name.php
    chdir($curr_l);
}


texts: "An illegal choice has been detected. Please contact the site administrator." with exposed sort fields

texts:
I have a panel which displays a page that was created in views. When a user clicks the next button on the pager, it displays the error "An illegal choice has been detected. Please contact the site administrator."

I've tracked this problem down to being caused by my exposed fields I use for sorting: When the pager is clicked, it submits to a URL like http://mysite.com/reviews?myfieldtosort_tid=All&sort_by=&sort_order=DESC&page=0%2C0%2C1.

The problem is that sort_by is empty; if I remove that attribute entirely the problem goes away. Alternatively, if I use the exposed sort, it adds the sort field and also works correctly.

What can I do to still use the pager, but have it remove the sort_by field when it is not needed?


texts: Images Not Uploading to sites/default/files/*

texts: I transferred my website to a live hosting from my local computer. Now the image files don't seem to upload to the correct folders. The images that I added while the site was local appear fine, but if I try to add new ones the preview is broken. However, if I click the link next to the preview I get the image. It seems like the images are not going into the sites/default/files/style/... sub directories. All of directories have permissions of 0755 or 0775.


texts: When creating rules I use to create System Message actions to print out some values for checking purposes. Then in production I'd like to disable instead of deleting these actions. Is there any way to do it?


texts:
I'm using views and I sort nodes by title. Now it works perfectly, but problem is that I have umlauts too and it doesn't recognise those. For example I have nodes with title "Dähne Mit" and "Dahne Ohne". The correct order of course would be:

Dahne Ohne
Dähne Mit

But now Drupal list them as:

Dähne Mit
Dahne Ohne

So Dähne becames before Dahne :/