texts: Multi-site variables table for shared variables (extending variable_set)

texts:
I have a multi-site setup with some shared tables using db_prefix. The variables table is NOT shared. Sharing ALL variables would cause lot of trouble, but sharing only some selected variables wont.

The picture below visualizes my problem:

The entries in the green box are shared and available on all multi-sites. Whereas the selected entry information is part of the config and stored in variables. Changes in the red box are not shared and lead to inconsistency when changed on one multi-site.

At the moment I use "drush @sites variable-set ..." to make consistent changes on all multi-sites. But to keep it more simple, I want to integrate it into Drupal's backend.

I found out that there was a failed patch request already. See issue here. The patch modifies variable_get() and variable_set() with an extended query-statement, if a defined variable is set in an array. I am aware of the fact, that the patch is for drupal 5, but it could be easily adapted to drupal 7.

The workaround in the patch modifies the core, but i cannot touch it. Overwriting variable_get() functionality is quite an easy job. You just have to hook_boot() or hook_init() and replace the desired values in $conf array with your custom values.

Whats the deal?

I need to extend variable_set() and variable_del() functionality without touching core. Any ideas how i get into that?


texts: Use VBO to send tokenised email in Drupal 6

texts:
I have a view table with bulk operations, and I have enabled the send tokenised email field. What I want to do with this is when this is selected and executed, it will take the email of the node which I have selected and send a mail with some content in it to the user. (e.g. we are looking at your support ticket).
When I select a node in the table currently, select send tokenised email from the dropdown and click execute, it does nothing.


texts: How can I have the nodes grouped in descending order and the nodes in ascending order?

texts:
I have a view listing articles grouped by year (on the post date) which returns me a HTML list like this.

2018

- Article Feb 01, 2018
- Article Jan 05, 2018

2017

- Article Dec 01, 2017
- Article Nov 05, 2017
- Article Oct 03, 2017
- Article Sep 05, 2017

The years are correctly sorted in descending order, but I would like to have the nodes of each year sorted in ascending order, as in the following list.

2018
- Article Jan 05, 2018
- Article Feb 01, 2018

2017
- Article Jan 10, 2017
- Article Oct 03, 2017
- Article Nov 05, 2017
- Article Dec 01, 2017

I have tried to apply an ascending sort on the content, but it also affects the years.

I have also checked Views: how to ASC sort the grouping field #1 and sort DESC its content?, but I don't want to add an extra field for the year.

I have also tried the solution posted on Views, Group By, can't specify order? but it didn't work for me.

How can I achieve it?


texts: Call node information when rendering links

texts:
Alright, this one is a bit tricky. I'm using the theme() function and theme_links__system_main_menu to render the main menu in a specific way on the front page. All the menu items link too basic pages.

The idea is that when hovering over a menu item, a pop-up appears with the content of a field called 'Preview' that's on the basic page of which the menu item is linked to. The pop-up itself is a simple CSS thing, so what I'm looking for is a way to access the information of the node in question.

I know $variables contains the link to the node, is there perhaps a function that gives you node information by link?


texts:
In Drupal 7 they can be found in object that is returned by field_info_instance().
Is there a way to get widget settings for certain field name and bundle in Drupal 8?


texts: Replace placeholder in custom block with preprocess hook

texts:
This is the first time I'm using the preprocees hook, apologies in advance.
I added a placeholder, {{user-uid}}, in a custom block body field, Advisor Page
.
My code is very simple, I have this hook theme.
    function boostrap_kampuster_preprocess_block(&$variables) {
        if (isset($variables['content']['#block_content'])) {
            $content = $variables['content']['#block_content'];

            /** custom block ID is 4 **/
            if( method_exists($content,'id') && $content->id() == '4') {

                $body = $variables['content']['body'][0]['#text'];

                $vars['user'] = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
                $body=str_replace('{{user-uid}}',$vars['user'],$body);
            }
        }
    }

I am not getting any errors but the function is not doing what it is supposed to do and replace {{user-uid}} with logged in user's ID either.
FYI, I cleared caches several times.


texts: Creating entity type using console doesn't work

texts:
I've installed Drupal 8.5.4 and followed these two steps to create a module and an entity type:

Ran drupal gm and filled in the info
Ran drupal geco and filled in the info (No bundles, No translation, No revisions)
Ran drush en mynewmodulename
Ran drush re

Out of the box, refreshing the Drupal main page throws an error complaining that the route is not found.

I had to manually create the module route file and fill it with all the paths from the entity generated files in order to pass the error and get the main page to render.

Now I am getting entity type not exist error.

e.g. routing entries I have added to mynewmodule.routing.yml

entity.mynewmodule_myentityname.add_form:
  path: '/mynewmodule/myentityname/add'
  defaults:
    _entity_form: mynewmodule_myentityname.add
    _title: 'Add myentityname'
  requirements:
    _entity_create_access: 'mynewmodule_myentityname'

I expected the entity forms and list page to work straightaway after creating it using Drupal console.
What am I doing wrong?

EDIT: I've also noticed that there is no table created in the database for the new entity.


texts: Add hidden field to checkbox and submit unchecked value

texts:
I want to submit a value if a checkbox is unchecked (on a node edit form).

Using theme_form_element I can add the hidden field as follows:

$variables['element']['#children'] = '$variables['element']['#name'] . '" value="0" />' . $variables['element']['#children'];

But on submit, because value 0 is not in the allowed values list, I get the 'An illegal choice has been detected. Please contact the site administrator.' error message.

How can I bypass this validation and/or submit the value 0 for each unchecked checkbox?


texts: What is the 'System' display option in Views?

texts:
Could you tell me what the "System" display in views is? (shown in red)

I suppose it's a presentation which is only available programmatically, but I'm not 100% sure.

Thanks.


texts: What are Ctools plugin (content type, access, etc), and how does one create them?

texts: What are Ctools plugins, and how does one create them?


texts: Why does drupal commerce create an empty order for every anonymous user?

texts:
Drupal Commmerce is creating an empty order for every single anonymous user in my website (over 13000 in just a few hours).

Users on my website have no direct access to the shopping basket, nor do they have any means of adding products to the cart, since for the moment, I'm only planning to use the Drupal Commerce functionality for specific users (i.e. I will create a product in the backend, then send the URL to the customer).

It doesn't seem right that so many orders are created for users who don't even have the shopping basket block in their page.

Why does this happen?

Is there a way to prevent it?

You can see in the screenshot how the empty-basket orders are being created for every anonymous user, this is slowing down the site!


texts: Best settings for xml sitemap, cron time and submission time?

texts:
i have news site for about 7 months.

The site get new feeds every hour but google take about 1 day to index them and only few of them.

I see other sites that instantly index. "1 hours ago etc". Mine newest in google says "19 hours ago"+. And after some errors with sitemap, now i have 0 links last 2-3 days.

So, i wan't to share my configs and you tell me if something is wrong:

Feeds module import feeds every hour
cron runs every 3 hours
xmlsitemap sumbission time to search engines is every 3 hour

I want to notice that i have arround 130.000 links. I have many feeds who import content. Maby are too much to index? idk

So, what im doing wrong?
PS: Also, every time i submit xml sitemap, i must ping google? if yes, i ping home page or xmlsitemap?


texts: Is there a way to merge / update result rows in Views with AJAX rather than the default which replaces the whole view div?

texts:
In a view with Use AJAX:Yes we see that upon filtering we get a completely new set of results and the div.view is completely replaced.

Is there a way to merge rows rather than replace all rows? i.e. - if we have 10 items, and after filtering we see that we have only 3 new items to be displayed, we remove the 3 that are no longer applicable and append the 3 new items.


texts: Stream_flush in not being called while using stream wrapper

texts:
I've created a stream wrapper foo:// and when I am using this wrapper and my file moved successfully but the flush_stream function is not called I don't why I also checked for the public:// stream wrapper and It calls the flush_stream function after moving file.

I backtracked the code while running for public:// stream wrapper I got this output

Array
(
[0] => Array
    (
        [function] => stream_flush
        [class] => DrupalLocalStreamWrapper
        [object] => DrupalPublicStreamWrapper Object
            (
                [context] =>
                [handle] => Resource id #11
                [uri:protected] => public://a1a1211127_aa_0.jpg
            )

        [type] => ->
        [args] => Array
            (
            )

    )

[1] => Array
    (
        [file] => /var/www/html/includes/file.inc
        [line] => 1633
        [function] => move_uploaded_file
        [args] => Array
            (
                [0] => /tmp/phpPaIdAn
                [1] => public://a1a1211127_aa_0.jpg
            )

    )
[2] => Array
    (
        [file] => /var/www/html/includes/file.inc
        [line] => 1585
        [function] => drupal_move_uploaded_file
        [args] => Array
            (
                [0] => /tmp/phpPaIdAn
                [1] => public://a1a1211127_aa_0.jpg
            )

    )

It means stream_flush is called after the move_uploaded_file function. But in my case the move_uploaded_file function is called but stream_flush is not.

Any idea why?


texts: How can I tell to the rule I am writing that the value of region field is the value coming from webform data?

texts:
I successfully created a webform using the Webform module.

Using Webform Rules I can create a new entity of type user and I fill the requested fields using, for example, [data:name-value-raw] for name, [data:surname-value-raw] for surname, etc...

This is very easy for text fields but I have troubles with text list fields, in my custom user fields I have two text-list fields (region list and country list), I set the same list in the webform.

In the Rules Action "Create a new entity" the Rules UI tells me to set a value for these fields but I'm forced to choose from a value in the list.

If I Switch to data selection I can't find submitted values, so how can I tell to the rule I am writing that the value of region field is the value coming from Webform data?


texts:
I have the following code in my module in a hook_form_alter...

if($form_id == "privatemsg_new") {
        dsm($form);
        $form['recipient']['#type'] = 'select';
        $form['recipient']['#title'] = 'Choose Recipient';
        unset($form['recipient']['#autocomplete_path']);
    }

The code works just fine, the title is changed, the form field turns into a select list

However in Krumo, the fields are not being updated. I guess its not the end of the world, but its annoying to not be able to see my changes!

Type, Title and #autocomplete_path should all have changed.

I've run cron, flushed caches etc. Anything else I can try?


texts: Drupal commerce and multiple products sharing SKU

texts:
I have a commerce shop, and a question about product "sharing" SKU.

I have products which is sold as single products, but also in a box.

Lets say I have "Product A" with price $ 1 , with SKU 00001.

I have a box with 10 x "product A" which on the website should appear as "Product A box" and price $ 9. (I need it to be the same product, but shown as separate "product"

I need it because, if I have two separate products, then I can't be sure I have the correct amount in stock.

Is that even possible ?


texts: How to add custom CSS per media query in Omega 3 theme?

texts:
My Omega 3 theme has the following layouts in the grid settings:

Narrow layout: all and (min-width: 740px) and (min-device-width: 740px), (max-device-width: 800px) and (min-width: 740px) and (orientation:landscape)

Normal layout: all and (min-width: 980px) and (min-device-width: 980px), all and (max-device-width: 1024px) and (min-width: 1024px) and (orientation:landscape)

Wide Layout: all and (min-width: 1220px)

I need to add some custom CSS within each media query. At the moment ive added them within my existing custom CSS file by copying the media query and adding an @import.

@media all and (max-width: 739px) {
    //styles
}

@media all and (min-width: 740px) and (min-device-width: 740px),
(max-device-width: 800px) and (min-width: 740px) and (orientation:landscape) {
    //styles
}

@media all and (min-width: 980px) and (min-device-width: 980px),
all and (max-device-width: 1024px) and (min-width: 1024px) and (orientation:landscape) {
    //styles
}

@media all and (min-width: 1220px) {
    //styles
}

Is there a better practice way of doing this / what are the other ways? Is there a way that integrates with the theme more fully?


texts: How to display the rendered entity of the "compact" display of the user account in the profile?

texts:
I have a site with Drupal 8 and I want to customize the templates of my pages.

I use the Profile module.

How to display the rendered entity of the "compact" display of the user account in the profile ?

This is the template to customize the profile page.

{#
/**
 * @file
 *
 * Default theme implementation for profiles.
 *
 * Available variables:
 * - content: Items for the content of the profile.
 *   Use 'content' to print them all, or print a subset such as
 *   'content.title'. Use the following code to exclude the
 *   printing of a given child element:
 *   @code
 *   {{ content|without('title') }}
 *   @endcode
 * - attributes: HTML attributes for the wrapper.
 * - profile: The profile object.
 * - url: The profile URL, if available.
 *
 * @ingroup themeable
 */
#}

      {{ ??? RENDERED ENTITY USER COMPACT ??? }}

UPDATE

      {{ profile.type.entity.label }}

      {{ drupal_entity('user', profile.uid.target_id, 'compact') }}

      {{ profile.getOwner().name.value }}

      {{ content.field_personnel_sexe }}

      {{ content.field_personnel_naissance }}

      {{ content.field_personnel_adresse }}

         Envoyer un message

      Voir son profil


texts: After saving entity bundle, entity_get_info('node') missing 'token type' property

texts:
After saving any entity bundle, e.g. node type on admin/structure/types/manage/node-type page, node 'token type' is gone:

$info = entity_get_info('node');
// isset($info['token type'])) == FALSE

After I change common.inc to regenerate entity info like this

if (FALSE && $cache = cache_get("entity_info:$langcode")) {
  $entity_info = $cache->data;
}

it started to work as expected.

Only 'node' entity type is affected.

In order to fix this I had to patch entity_get_info:

   $entity_info = &$drupal_static_fast['entity_info'];

+  if (!empty($entity_info) && !isset($entity_info['node']['token type'])) {
+    $entity_info = NULL;
+  }
+
   // hook_entity_info() includes translated strings, so each language is cached
   // separately.
   $langcode = $language->language;
@@ -7857,7 +7861,7 @@ function entity_get_info($entity_type = NULL) {
     if ($cache = cache_get("entity_info:$langcode")) {
       $entity_info = $cache->data;
     }
-    else {
+    if (empty($entity_info) || !isset($entity_info['node']['token type'])) {
       $entity_info = module_invoke_all('entity_info');

What can be the root cause of this issue and how can it be fixed?

I searched for an answer and found several similar questions on Drupal.org, but the only recommended thing is to clear cache several times (which does not even help in my case).


texts:
I am trying to create a view where I have the same taxonomy term for a node and profile to link the two together.  Here is what I did:

I created a profile with a taxonomy(Current Company) with a value of: company1

I create a node with a taxonomy(Current Company) with a value of: company1

I created a user view and created a relationship to see all content. This works but I tried to create a filter where the logged in user profile (company1) = the value of the node taxonomy (company1).

So basically since the logged in user belongs to company1 he only see content related to company1.

I have been trying different combinations and cannot get this to work, I know it has to be possible.

Thanks


texts: Access currently logged in User profile from search index view?

texts:
I have a Product Display listing of indexed nodes that show a "List Price" I want to do math on them (if I can get the multipliers I can do the math) in the view to show a users "Cost" and "Selling Price" the multipliers that I need are on the users Profile however I can't seem to find a way to access the current UID/ users profile fields in this type of view.

a) is this even possible to do?
b) can someone explain to me how I can do it?

Thanks in advance t anyone who can help


texts: Content type subtypes with no bundles or clientside

texts:
SHORT DESCRIPTION

I want subtypes without bundles.

Longer:

GIVEN

A content type which represents a bibliography item.
A list(text) field ("Subtype") which is used with a selectlist widget.  Values include: a book, a phd thesis, a conference paper, etc (I have more than a dozen of them).
Many text fields, each should be used only for some subtypes, not all of them. Example: The "Edition" text field should be filled for a book subtype, but not for a phd thesis subtype.
A bibliography item should not change its subtype (i.e., convert to another subtype).

NEED

Creating a new item form: Selecting a subtype from a selectlist, then continue to edit item form. That is, 2 steps on creation.
Editing an item: all other fields of the content types - only the ones that make sense in the context of the subtype. This form is used as the second step when creating a new item and as a single step when editing an existing item.

CONSIDERATIONS

As there are so many subtypes I do not want to make each of them a separated content type using the shared fields approach.
A custom entity type with bundles is gives a too narrow result as indeed there is a need for all node capabilities.
Counting of client-side is not an option (e.g., hiding/disabling fields).

Any ideas how to implement this? All code snippets and modules which I have found use client-side techniques (w/ or w/o FAPI's #states).

Thanks!


texts:
I have a query like the following:

SELECT t.tid, t.name, t.description, COUNT(i.nid)
  FROM taxonomy_term_data t
  LEFT JOIN taxonomy_index AS i ON i.tid = t.tid
  GROUP BY i.nid
  LIMIT 60

I wish to write this as a dynamic query.

This is what I come up with, but it fails on the COUNT() part.

$query = db_select('taxonomy_term_data', 't');
$query->addField('t', 'tid');
$query->addField('t', 'name');
$query->addField('t', 'description');
$query->addField('COUNT(i.nid)', 'count');
$query->leftjoin('taxonomy_index', 'i', 'i.nid = t.nid');
$query->range(0, 60)->groupBy('i.nid');

The string representation of the query is:

SELECT t.tid AS tid, t.name AS name, t.description AS description, COUNTi.nid.count AS count FROM {taxonomy_term_data} t LEFT OUTER JOIN {taxonomy_index} i ON i.nid = t.nid GROUP BY i.nid LIMIT 60 OFFSET 0

COUNTi.nid.count AS count is obviously wrong.

How do I add COUNT(foo.bar) to a dynamic query?


texts: Custom entity to load another custom reference entity fields

texts:
I have two custom entities (Car and Car Type) and I am using one as a reference for the other.

When I load the "Car" entity I can only get the ID from "Car Type". I know I can then run entity_load to get the fields on "Car Type", but when I have multiple results of "Car" querying every record become inefficient.

Is there any way to load the "Car Type" entity fields when loading "Car" entity?


texts: Display values in the order they are in the form field

texts:
I created a field called Authors, that can take multiple values (Users registered on the site).
I would like to display the authors in the same order I add them in the field.

They are currently displayed with no logical order (it is neither the order they appear in the field, nor the alphabetical order, nor the UUID of the users...)


texts: route: looses styling and not working correctly in Superfish menu

texts:
I have set the parent item (reaching-out) on my main superfish menu as a "no link" item so that only the dropdown menu items link to pages. On doing so I lose my styling which is OK because somehow I manage to locate that specific menu item to style and match the others.
On hover the select icon replaces the arrow which is no big deal but it should not be so.
I notice the accordion menu needs separate styling - again I have managed to do this but very laborious.
I could live with all this but I notice in the accordion position for mobiles the "reaching-out" link now doesn't expand to show the sub-1 menus on hover or press.

I am wondering is there a better way than altering the no link on the Drupal menu system (ie via admin/structure/menu) which Superfish doesn't seem to be picking up correctly? Perhaps there are some superfish settings I have failed to pick up on which need no additional styling and function correctly.
(In the pics I have removed the styling to show original problems. Its difficult to get a snip of an expanded menu in full screen view because you need to be on hover and cant click snip at the same time!)


texts: How to resolve the "undefined variable" notce when I put a flag on a Views page?

texts:
I want to place a flag link on a page, as suggested on that page: https://www.drupal.org/node/295383

The flag will subscribe the user to the most recent content page, which is done in Views.

I have the Flags: subscribe (by current user) Relationship.

I have installed Views PHP and I want to add to the header of the view a Global:PHP with the code <?php print flag_create_link('subscribe', $node->nid); ?>

Unfortunately I receive an error:

  Notice: Undefined variable: node in __lambda_func() (line 1 of .../sites/all/modules/views_php/plugins/views/views_php_handler_area.inc(39) : runtime-created function).
  Notice: Trying to get property of non-object in __lambda_func() (line 1 of .../sites/all/modules/views_php/plugins/views/views_php_handler_area.inc(39) : runtime-created function).

What could be the reason for that?

Any help appreciated.


texts: Theme the “save” button in a profile page, on a Drupal 6 installation?

texts:
How do you theme the "save" button in the profile page (user/uid), on a Drupal 6 installation? I´ve tried and when I try to theme it, it theme all "save" buttons on the site.

Thanks!!

Rosamunda


texts: Pass parameters for node access on RESTful call

texts:
I'm trying to figure out how to pass a filter parameter on a Services rest call.  I've got a node of a specific type that I'd like to access through the Services module and rest.  I'm testing with FireFox RestClient and I can get all nodes of the particular type by typing

http://localhost/drupal/gpa/node/?parameters[type]=node_type

But, I'd like to be able to get one specific instance of 'node_type' that contains a specific field value.  I've taken a look at node_resource.inc, but, I can't seem to make heads or tails of what I need to use as parameters.  I've tried several variations that typically return no result, or, all instances of, 'node_type'.

Is it possible to filter the returned results, or, is my approach incorrect?

EDIT: If any C# programmer stumbles across this, I was able to use the Basic HTTP Authentication module to prevent unauthorized access to the view.  First, as Tyler indicated, I needed to change the permissions settings.  In My case, I chose a Role (Administrator).


texts: How can I act on a taxonomy term in my twig template?

texts:
I'm trying to use two taxonomy items to build a button on my template. The logic is:

If this node is exactly equal to taxonomyTermFromVocabularyA
Print a button on the page with a URL built out of taxonomyTermFromVocabularyB

I thought I was doing well when a simple test proved that my terms were available. In the template, I tested by adding:

{{ content.field_taxonomy_resource_type }}

{{ content.field_taxonomy_topic }}

And out came the expected values on the page:

  Topic Page

  Oral Health

However, once I tried to actually use the terms I captured it never worked. The first part of the logic, where the button will eventually be built, I wrote as:

{% if content.field_taxonomy_resource_type == "Topic Page" %}

 hello, it's working!

{% endif %}

produces no content at all. I expected to see my test paragraph sentence "hello, it's working!" appear on the page.

My best google-foo hasn't helped me at all and, alas, my soul is being crushed. I fear it's something completely obvious that I am just ignorant about.

Can anyone point me to the error of my ways? Why doesn't my twig if statement work?

@clive was absolutely right in the suggestion below that I was naming the array and not the particular item I needed when constructing my if statement. His correction to my code:

{% if node.field_taxonomy_resource_type.entity.label == "Topic Page" %}

is not working though, and the best I can tell is that the variable is unavailable to me. When I dump the variable using {{ dump(node.field_taxonomy_resource_type.entity) }}, I just get NULL.

Clive's answer worked as soon as I changed out node to paragraph. Thanks!

{% if paragraph.field_taxonomy_resource_type.entity.label == "Topic Page" %}


texts: How to call disclaimer page on all media files in Drupal?

texts:
I want to display a terms n condition page on every media of website. I collect all media from file managed table of database. I also convert fid to url. Now for each media url I need a disclaimer page.

My issue is something related to this link.

For example:

When I click on each report of news table shown below, on clicking of (say) linux-minimal.pdf , it first redirect to some node which is my disclaimer url, and then pdf open.

How can I achieve this?

I have tried some code which is actually not working. It is:

function hook_init(){
    $get_current_path_media = $GLOBALS['base_url'].'/'.current_path();
    if($get_current_path_media == 'http://my-website/sites/default/files/569338.pdf'){
        drupal_goto('disclaimer');
    }
}


texts: Multiple site with multiple databases and single login

texts:
I have two instances of Drupal on same server instance 1 and instance 2 with different databases. I want the following feature: unique login for both instances.

When I login to instance 1 and if I open the URL of instance 2 on same browser then it should not ask me to log in again.
While any add/update operation is performed on instance 1 or instance 2, the user table should be updated in both databases.


texts: Custom Region doesnt render at the same position

texts:
I have created a region in my theme that contains only menus. Each menu has its own visibility settings. For e.g. my main-menu is everywhere visible except at /blog/* and my blog-menu only at /blog/*. I use this as my main navigation bar region.

My issue is that i call this region in my page.tpl.php with

<?php //print zurb_foundation_links__topbar_main_menu($main_menu); ?>
    <?php print render($page['menu']);
    ?>

but the html structure that is printed is different to what I need. The following is what gets printed. As you can see its creating a new section with a list inside. I want to get that menu in the section that is currently empty (be aware that I'm printing it at the correct position in my tpl.). I also need to change its ID & CSS Classes.

Lernumgebungen

Unterstützung

Förderung

Projekte

Kontakt

I want to avoid to call the menu directly instead of the region. The reason behind it is as I wrote in the beginning the visibility settings. The region contains menus that differ by the URL.


texts: Cloning the Base theme bartik, seven, and stark in Drupal 8

texts:
I tried copying the seven theme from /core/theme into my own /theme folder. I renamed all the files that starts with seven to sevenx and also renamed the seven_ functions to sevenx_ and it still not showing up on the theme pages.

What else do I need to change to make drupal 8 see this new cloned theme?
Is there a quick tool to get this done without having me to rename everything?


texts: How to create eshop for product hiring counting price per day

texts: Currently I'm working on specific project which is product hiring and price per day depends on hiring interval. It means 2 days hiring for certain product the per day price differs from 5 days hiring. Also in this case instead of product quantity I'm using days. My question is how can I organize above mentioned structure using commerce?


texts: Combining entity forms on one page breaks file upload

texts:
In Drupal 8 I have combined a number of custom entity forms on one page using this example.
Everything works perfectly except for file uploads which do not load.

In the console it returns :

  XHR Loaded (product-application - 200 OK - 3.77340402601551s - 7.562KB) with the url: aslpd.dd:8083/products/product-application?element_parents=file_uploads/form/field_fu_1_photo/widget/0&ajax_form=1&_wrapper_format=drupal_ajax&regulatory_details[field_am_3_recordstatus]=draft&regulatory_details[field_am_16_commentstoapplicant][0][value]=&regulatory_details[field_am_17_regulatorsnotes][0][value]=&product_identification[field_pi_3_familyname][0][value]=&obj=O

It works perfectly when the form is on its own (Not in the combined form).

Any ideas on why it breaks and how to fix?

After further investigation I have discovered it has to do with all ajax calls, the full form is sent to the ajax call ,not just the inner_form. This then causes issues with the return of the ajax data and the element it needs to replace. The ajax call executes correctly but on return it does not replace the element. Not sure how to fix this.


texts: Is this the correct way to complete aliases.drushrc.php in order to avoid messing with other accounts?

texts:
I´ve read many questions about drush in a multisite configuration. This case isn't a multisite, but several different installations in a single VPS. Something like a reseller account. They are all my sites, but I don't want to mess them up. I need drush commands to be applied to a single site each time.

I´ve installed drush using my root access, under home/root/drush.
So when I try to access ssh using one of my site´s credentials (not the root user, but one of the site´s admin), it doesn´t recognize drush commands.

Should I install drush in every single account, right outside /public_html, or should I edit the .bashrc file in any way? And in that case, how may I prevent the commands to affect other sites when I try to do something with a single specific installation?

I'm using Drupal 7 and Drush 5.x because of my php version (5.2.17).

I understand that I should have (inside the drush folder?) a file called aliases.drushrc.php, with something like this.

$aliases['site1'] = array(
    'uri' => 'mysite1.com',
    'root' => '/home/site1username/public_html',
    'remote-user' => 'site1username',
  );
$aliases['site2'] = array(
    'uri' => 'mysite2.com',
    'root' => '/home/site2username/public_html',
    'remote-user' => 'site2username',
  );

Is this correct? And how may I access drush only to a specific site?


texts: Trying to migrate user data into multi value term reference field

texts:
FYI: I'm using the module Migrate 7.x-2.5

I'm trying to migrate users from a custom built PHP website, backed by a mysql database, into Drupal.

Each user can have multiple statutes assigned to him. In the source database I have a table 'users' with a column 'stat_id'.

+---------+---------+
| user_id | stat_id |
+---------+---------+
|       1 | ;2;     |
|       2 | ;26;    |
|       3 | ;3;     |
|       4 | ;27;28; |
|       5 | ;19;2;  |
+---------+---------+

The name of the statutes is stored in the table 'users_statuut'.

+---------+----------------------------+
| stat_id | statuut_nl                 |
+---------+----------------------------+
|       1 | Doctoraatsstudent          |
|       2 | Postdoctoraal onderzoeker  |
|       3 | Administratieve medewerker |
|       6 | Diensthoofd                |
|       7 | Laborant                   |
+---------+----------------------------+

In Drupal I created a term vocabulary 'statutes' with the names of all the statutes.
And I added a term reference field to the user profile that can select multiple values from this vocabulary.

What I can't figure out is how to migrate the data from the source table into Drupal.
I've already managed to migrate simple fields like username, email, password,... so that's working, but I have no idea how to get the statutes into the term reference field.

Any help is really appreciated.


texts: How can I do with Views and Drupal 7 what the Views Or module does in Drupal 6?

texts:
I'm trying to find a way to do in Drupal 7 what the Views Or module does in Drupal 6.
I read that this module (or at least what it does) has been migrated to the core Views 3 module.

How can I do the same thing as on this picture (marked in yellow) within Drupal 7 Views 3?


texts:
In my view I am exposing two sort options in the following order:
Date > Newest First
Title > A-Z

When both sort options are exposed it will correctly display the nodes sorted by date but will randomly sort the nodes by title. So for example titles starting with a R will appear for nodes which have titles starting with a D. When I turn off exposing the Title sort it will display correctly. First sorted by date and correctly sorted from A to Z. But I do need to expose the Title sort. So what am I missing? Or is it just a bug?

My Views settings

Sort settings date field

Sort settings title field


texts: The test case is not recognized by the Simpletest module

texts:
I am using Drupal 7, and the latest version of the Simpletest module. I have written a test case like the following one:

class SimpleTestDemoTestCase extends DrupalWebTestCase {
  function setUp($modules = array()) {
    parent::setUp('simpletestdemo');
  }

  public function getInfo(){
    return array(
      'name' => 'Simpletestdemo testcase',
      'description' => 'Simpletestdemo testcase desc',
      'group' => 'Simpletestdemo'
    );
  }

  public function testBlockView() {
    $simpletestblockview = module_invoke('simpletestdemo','block_view);
    $this->assertTrue(t('Simpletest Demo'),$simpletestblockview['title']);
  }
}
?>

This does not get recognized by the Simpletest module. Is there anything wrong in this test case?


texts: hook_form_alter inside of hook_block_view - drupal 7

texts:
I have a form which I am calling inside of a custom block module. When the form is submitted it creates a session variable. I have hook_form_alter check to see if that variable is set; if it is, it will create a new form.

When I place the form inside of a block, it will not create the new form. Almost as if hook_form_alter is not being called.
Is there a better way to do this? Do I need to some how use hook_view_alter?

The form works fine outside of the block. It is only inside of the block I am having issues

Thanks in advance

Sample Code:

    function mymodule_block_info() {
        $blocks['mymodule-form-block'] = array(
            'info' => t('My Module Form Block'),
            'cache' => DRUPAL_NO_CACHE,
        );
        return $blocks;
    }

    /**
     * Implements hook_block_view().
     */
    function mymodule_block_view($delta = '') {
        $block = array();
        switch ($delta) {
            case 'mymodule-form-block':
                $block['subject'] = t('Subject');
                $block['content'] = drupal_get_form('mymodule_form');
                break;
        }
        return $block;
    }

    function mymodule_form() {
        $form['address'] = array(
            '#type' => 'textfield',
            '#title' => t('Your Address'),
            '#size' => 60,
            '#maxlength' => 128,
            '#required' => TRUE,
        );
        $form['find_submit'] = array(
            '#type' => 'submit',
            '#value' => t('Value'),
            '#submit' => array('mymodule_form_submit'),
        );
        return $form;
    }

    function mymodule_form_submit($form, &$form_state){
        $_SESSION['readyToRender'] = $readyToRender;
    }
function contact_rep_form_alter(&$form, &$form_state, $form_id) {
    if (isset($_SESSION['readyToRender'])) {
        /* render some different form elements*/
         $form['submit'] = array(
            '#type' => 'submit',
            '#value' => t('Value'),
            '#submit' => array('mymodule_other_form_submit'),
        )

    unset($_SESSION['readyToRender']);
    }
}
    function mymodule_other_form_submit($form, &$form_state){
        /*Do things*/
    }


texts: Adding an auto-complete field to a custom module form

texts:
I am trying to add two auto-complete fields to a form I am using to generate two types of reports. What I have going on is that we have interfaced the CometChat chat system with Drupal using a custom module and now the customer wants reports for it. We realized that the best way for the user to narrow the result set is to let them use an auto-complete field for chatrooms by name and instant messages by individual.

Since I will be querying non-Drupal tables in the DB to do so I cannot just use a CCK field and the autocomplete widgets module (unless you know a trick on how to do that). I have never done an auto-complete field before in my life.

I know that I need to create the menu hook page callback, but I am not entirely sure how the JS and pingback should work to best do something like this. Does anyone know how to get started?

I am going over the code for the autocomplete widgets module to learn from it right now. But I would love any help with this.

Thanks!


texts: How to add page "Contact us"/"Terms of usage" using a link in the footer but page's content to be in the main content(middle region)?

texts:
This seems to be a very newbie question. This is what I want to do:

I 'd like to have a link of type "Terms of usage"/"contact us" in the footer, and when the user clicks on it, a page to be appeared in the main region.
How that could be done? Is it possible? Because from what I 've already seen, the page appears in the same theme region with its parent menu.


texts: Views Grouping field:Add Ordered class to Grouping row

texts:
I use Views and Grouping field to integrate my data.
But i need each grouping row ordered.

I want to override the views-view-grouping.tpl.php, and change the "view-grouping" class to "view-grouping-1","view-grouping-2","view-grouping-3"...

The original code is belowed:

    <?php

/**
 * @file
 * This template is used to print a single grouping in a view.
 *
 * It is not actually used in default Views, as this is registered as a theme
 * function which has better performance. For single overrides, the template is
 * perfectly okay.
 *
 * Variables available:
 * - $view: The view object
 * - $grouping: The grouping instruction.
 * - $grouping_level: Integer indicating the hierarchical level of the grouping.
 * - $rows: The rows contained in this grouping.
 * - $title: The title of this grouping.
 * - $content: The processed content output that will normally be used.
 */

?>

<?php print $title; ?>

    <?php print $content; ?>

The File is located at all/module/views/theme/

Does someone meet the same problem before?

Thx for help.


texts:
I've got a block view set up to get the latest 3 blog posts by term. I'm providing the default argument with the following:

$path = drupal_get_path_alias($_GET['q']);
$path = explode('/', $path);
if($path[0] == 'laws' || $path[0] == 'issues' || $path[0] == 'culprits' || $path[0] == 'themes' :
return $path[1];
endif;

Using dpm on $path[1] gives me the term alias and I assumed that the Argument validator for Taxonomy Terms, which is set to "Term Name converted to Term ID", would get me the ID, but maybe not?

Works fine in views preview with arguments entered, but on an actual page it returns nothing. Never had a problem with this before in 6.x. Is there something new I'm completely missing? I've read through docs and tried a few different ways to return the default arg, but no luck.

Any help would be appreciated.

Thanks

Edited to fix code


texts: On/Off Checkbox to toggle filter value in views exposed filter

texts:
I am using Better Exposed Filters Module and Has Boyfriend field is Boolean Yes/No field type of the content.

The Current View I have is:

When I click the Yes Checkbox I get:

My quest is when the checkbox is not-checked it'd only display girls without boyfriend like: (please ignore the filters here, I just showed it to explain my question, the filter should not have No, it should be default filter)

I can acheive this with such multiple-checkbox as above but I have the requirements to display only Girls without Boyfriend as default display list. When the checkbox Yes is clicked it'd hide all the Girls without boyfriends and display only Girls who has boyfriend.

There were few similar questions like this when I was searching like This and This but the answers doesn't satisfy my requirements.


texts: Get a module version for a list of modules

texts:
Context

Drush version 8.x
Drupal 7 site

Problem

Mr. HtraenuRekaos has a text file with a list of Drupal contrib modules.
He wants to get the recommended-install version of all the modules in the list.
This list is not associated with any pre-existing site, and none of the modules are currently installed.

Non-solutions

Mr. H has already looked at this SO post: Using wget to get the latest module version, but he does not want to use wget, he wants to use drush
Mr. H does not want to actually download or install the relevant modules, he only wants to get a list with the latest recommended D7.x version.

Question(s)

Is there a drush command that will turn before into after?

Before

MODULE_NAME_HERE    ;; RECCO_VERSION_HERE
contrib_module_001   ;;   __blank__
foobar_module        ;;   __blank__
htraenurekaos        ;;   __blank__

After

MODULE_NAME_HERE    ;; RECCO_VERSION_HERE
contrib_module_001   ;;   7.x-1.6
foobar_module        ;;   7.x-2.2
htraenurekaos        ;;   7.x-3.6


texts: What would be the reason for a registration page to hangs after submit?

texts:
For some reason whenever i try to submit a new user registration (on a fresh drupal 7 install), the data is correctly sent to the Back end but the page doesn't seem to redirect to the intended location (by default the home page)but instead seems to endlessly submit.

I am pretty sure this come from my testing server as it does it even on a fresh drupal install.
Is there anything that would come to your minds on what could be the cause of this problem ?
We are using ubuntu server with all latest software updates.


texts:
I am redirecting my users with the following code:

drupal_goto("event/registration/failed",
    array(
      'query' => array('nid'=>$submission->nid, 'sid'=>$submission->sid),
    )
);

On the target page I am executing the following function:

function _event_registration_failed($nid, $sid){
  dsm($_REQUEST);

  drupal_set_message("TESTING NID: {$nid}");
  drupal_set_message("TESTING SID: {$sid}");
}

My the variables in the drupal_set_message calls do not have any data.
But, the $_REQUEST object above has the data I expected.

Is there a correct way to access argument passed with drupal_goto or is it correct to use the $_REQUEST object array?


texts:
I need to customize the search results of a drupal 8 (8.7.0 currently) page a bit and need the node_type for this. According to search-result.html.twig, this should be stored in info_split.type, but the whole variable is empty.

How can I get the node type inside the search-result.html.twig file?


texts: Split node edit tab in several tabs with panels (or programmatically)

texts:
I have a content type with many fields, so that loading node/%node/edit is a pain ! In order to split node edit form in smaller forms (menu tabs), I used Page Manager.

What I did so far

Enable the Node add/edit form coming with Page Manager, with selection rule node being edited is from foo_type
Add three new custom panels pages in admin/structure/pages, with paths /node/%node/photos, /node/%node/prices, /node/%node/fd ; with selection rule node being edited is from foo_type
Define its menu as local menu tab.
Share foo_type fields between these forms, and add a submit node form to each.

This renders correctly three node edit forms accessible in new local task menu tabs :

The buggy part

If I edit the node from any of these forms :

the fields present in it are saved
the data from other fields saved before is still in the database, and also readable in the form fields if I show up the other forms (except for pictures), but it is not displayed anymore in the node.

As per @Letharion comments : " [...] while Panels happens to let you output only half the form as well, that is not supported by form api. One way or another, every field must be present. If not, form api will interpret it as "the user deleted the content of those fields" [...]

The question

I'm searching a way to patch the current solution, or a fully programmatic way to split node edit into tabs. Thanks for your contribution!

Edit:

Most of the issue is solved thanks to flexiform, except for inline entity commerce products. So I'm trying with MrD answer for this specific field, as exposed below.

The commerce product is saved (corresponding DB tables commerce_product, field_data_commerce_price and so on have a new record), but not attached to its product display (and no record in field_data_field_product). No error is returned.

How to correctly save that commerce product so that it is attached to its node display ?

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

  $items['node/%node/prices'] = array(
    'title' => 'Prix et dates',
    'page callback' => 'node_page_prices',
    'page arguments' => array(1),
    'access callback' => 'node_access',
    'access arguments' => array('update', 1),
    'weight' => 4,
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  );

  return $items;
}

function node_page_prices($node) {
  $form = drupal_get_form('vts_nodedit_form', $node, 'field_product');
  return $form;
}

function vts_nodedit_form($form, &$form_state, $node, $field_name) {
  $form = array();
  field_attach_form('node', $node, $form, $form_state, NULL, array('field_name' => $field_name));
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save')
  );
  return $form;
}

function vts_nodedit_form_submit($form, &$form_state) {
  $node = $form_state['build_info']['args'][0];

  //retrieve commerce product to be saved... NON DRUPAL way... :(
  $item = key($form_state['inline_entity_form']);
  $entities = end($form_state['inline_entity_form'][$item]['entities']);
  $product =$entities['entity'];//this is the correct product entity
  //SAVE THE COMMERCE PRODUCT
  commerce_product_save($product);
  //MrD solution
  field_attach_submit('node', $node, $form, $form_state);
}


texts: different content based on choice on homepage

texts:
I would like to make a homepage where an anonymous visitor makes a choice (teacher or student). Based on this choice an adapted menu should be visible, and the visitor has access to specific pages.

I know this is easily done if a visitor has to register, but it's just a website with some text and documents, nothing special. So asking the visitor to register before having this information is serious overshooting. I am looking for a way to influence the display of pages just by a choice made once per visit.

Does anyone know if there is a module for this? Or is there another way to do this?

Many thanks.
Steven


texts: function theme_field__content_type() isn't working

texts:
I'm trying to modify all fields output for a specific content-type called Netrunner-Card.

After digging through Stack Exchange I ran across someone that suggested using:

function theme_field__content_type()

But it isn't working. My implementation is:

function blinks_responsive_field__netrunner_card($variables)
{
    $output = 'TEST';
    return $output;
}

Which if I understand correctly, this should remove all field data for a content type of 'Netrunner Card' but it doesn't.

I have multiple fields for each card. There are also card types which I want to output differently, (i.e. An Operation card should look like this, an Identity card should look like this, etc.). So I want to use a switch function (PHP) to check the card types and adjust fields as needed. First I have to get access to the fields and I'm trying to do this inside of ONE function versus a separate function for each field which would add a lot of duplication.

My theme is called blinks_responsive. My content type is netrunner_card.
I am out of ideas.

UPDATE: I don't know if it matters but I discovered that I had a field.tpl.php file in my theme templates folder. Wondering if that caused me issues. Still not working tho.


texts: Trying to install Drupal modules and themes: keep getting error "does not contain any .info.yml files."

texts:
I am new to Drupal. I am running Drupal 8. I have tried to install three different themes and modules, and keep getting this error:

  does not contain any .info.yml files

Including with the Beale Street module with a 8.x release.

Why am I seeing this error? Are .info.yml files a newish requirement that most themes don't have yet? Where can I get themes that include .info.yml files?


texts: How do I add an image upload field to menu content items?

texts: So admins currently have the ability to add custom menu items. I would like to add an image upload field to this form so we can display it in the megamenu alongside the link. How can I add this field?


texts: How to show newsletters lists options in the mailchimp free form?

texts:
When I try to create a list on my drupal site, i should only select one list from the mailchimp list dropdown so the user should subscribe to that list only using hte mailchimp free form.

But I want that user should select the list using the mailchimp free form to which list he wants to subscribe?

Is it possible? How will I do that?


texts:
Drupal 7. On form validate, I want to:

check the value of one of the form fields [field-1]
based on that value, completely remove another field [field-2] together with its values, from the form

If it makes any difference, [field-2] is a multiple-value entity-reference field.

I think I need to do something like --- get hold of $form_state['values']['field_2'] and set it so that it is in the same state it is before any data was entered by the user.

Am I on the right lines? I haven't been able to find examples or documentation on this.

EDIT:

This is what worked for me in the end:

In the submit function (not the validate function):

// Start with a clean array for the field we want to change.
$form_state['values']['field_2'] = array();
// Restore the array values that correspond to 'empty' for this field.
// In my case this was as follows:
$form_state['values']['field_2']['und'][0]['target_id'] = '';


texts:
my code not working. I'm trying to get custom breadcrumbs if user is different taxonomy vocabulary category page. if elseif's not working, but I don't know why..

Example: If I go to taxonomy term page that vocabulary id is 2, breadcrumbs is:

Page 1 > Page 1 > Term name

and vocabulary id 2, breadcrumb looks like this:

Page 2 > Page 2 > Term name

and if ID is not defined it shows default breadcrumbs ( else )..

It shows page 1 and else breadcrumbs but else if statement not working..

Is that code correct or what?

 /*
 * Taxonomy term callback page
 */

function taxonomy_taxonomy_term_page($term_id) {
$term = taxonomy_term_load($term_id);
$html = '';
$breadcrumb = array();
$parents = taxonomy_get_parents($term->tid);
$desired_vocab_1 = 1; // Vocabulary ID
$desired_vocab_2 = 2; // Vocabulary ID
$desired_vocab_3 = 3; // Vocabulary ID

if(count($parents) > 0) {

    $show_sub_cat = false;
    $list = get_legal_articles($term->tid);
    foreach($parents as $item)
        $_parent = $item;

    $breadcrumb[] = l(t('Default page'), 'Default page');
    $breadcrumb[] = l($_parent->name, 'taxonomy/term/'.$_parent->tid);

    $html =  theme('category_details', array('term' => $term, 'list' => $list, 'is_sub_cat' => $show_sub_cat));

 } else {

 if (((arg(0) == 'taxonomy')
 && (arg(1) == 'term')
 && is_numeric(arg(2))
 && ($term = taxonomy_term_load(arg(2)))
 && ($term->vid == $desired_vocab_1))) {

$breadcrumb[] = l(t('Page 1'), 'Page 1');

$childs = taxonomy_get_children($term->tid);

$html = theme('parent_category_details', array('term' => $term, 'list' => $childs));

 } elseif (((arg(0) == 'taxonomy')
  && (arg(1) == 'term')
  && is_numeric(arg(2))
  && ($term = taxonomy_term_load(arg(2)))
  && ($term->vid == $desired_vocab_2))) {

$breadcrumb[] = l(t('Page 2'), 'Page 2');
$breadcrumb[] = l(t('Page 2.1'), 'Page 2.1');

$childs = taxonomy_get_children($term->tid);

$html = theme('private_category_details', array('term' => $term, 'list' => $childs));

} else {

$breadcrumb[] = l(t('Page 3'), 'Page 3');
$breadcrumb[] = l(t('Page 3.1'), 'Page 3.1');

$childs = taxonomy_get_children($term->tid);

$html = theme('private_category_details', array('term' => $term, 'list' => $childs));

}

// Set Breadcrumbs
drupal_set_breadcrumb($breadcrumb);
drupal_set_title($term->name);

return $html;
}


texts: what is the hook name in order to alter theme function of specific element

texts:
imagine that we have a list if items in $items array that it's theme function is list_item in specific page.

code is

theme('item_list', array('items' => $items));

but in my module, I want to alter the parameter 'item_list' and I want to use my custom render function 'custom_item_list'

I know that I must register and define custom_item_list function but I don't know in what hook I am able to alter the theme_function parameter of specific element.


texts:
I am using Zen3 theme , i created a subtheme ,i want have a big search box in front page , for doing this , i created  a front page template page--front.tpl.php.
also i added a custom css to my search-box by this code in template.php

function myrtheme_form_search_block_form_alter(&$form, &$form_state) {
    $form['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/images/search-icon.png');
    $form['actions']['submit']['#attributes']['class'][] = 'search-icon';
    $form['search_block_form']['#attributes']['class'][] = 'search-box';
    }

my problem is how can add css class only to the frontpage in page--front.tpl.php.


texts: Lookin for the the correct way to alter a field

texts:
I am trying to find the correct way to alter a field on a multilingual Drupal 7 site. I am using multilingual nodes but not multilingual fields.

I can alter the field with:

$form['field_uploaded_files']['#prefix'] = 'This is a test';

This works without a hitch.

If I try and then do something slightly more complicated like

$form['field_uploaded_files'][LANGUAGE_NONE][0]['#upload_validators']['_app_magic_number_validator'] = array($form_id);

then it does not work at all.  I have tried with and without [LANGUAGE_NONE]. I have tried with and without [0].

I am at a loss for why this is not working and would appreciate any help.


texts: Given I have a node, how to programmatically find out all the nodequeues it belongs to? Is there any ready functionality in Drupal 6 or do I just have query this from the DB myself?


texts:
We have installed node queue module on Pressflow 6 + Varnish. For clearing the varnish cache for node queues, we developed rules using the Rules, and Cache action modules. Whenever we update the content, it is reflecting for logged in users, but it is not reflecting for anonymous users.

Could you please suggest us for how to clear varnish cache with rules or any custom code?


texts: Contextual Filter Problem in Drupal Commerce Using Indexed Textfield

texts:
I am trying to filter products by brands, which have been inputed into a text field in Drupal Commerce and indexed.

If I try for instance "Breitling" in the contextual filter it works perfectly and I can see the correct products shown in the Views preview. I am using PHP code for the contextual filter. So as a test I just used the following in the contextual field and it does not work (I have tried both options for using the contextual field)

    return "Breitling";

What I do get is no results.


texts:
I just migrated a website, and I can't upload any files now.
I checked the file path , it's ok
I checked the files and tmp permission , its ok (775)

When I try to upload an image, it does the 'ajax loading' and then boom everything's gone. It's like I just came and didnt try to upload anything.
I have no js , php or ajax error.

I really don't know what to do, have someone already face this ?

Thank you.


texts: Toolbar broken, permission errors after permission changes

texts:
After performing the most recent core update, which required me to temporarily disable layout builder, my admin toolbar somehow became grey and unformatted as shown below. I've tried changing the admin theme, rebuilding the cache, disabling CSS, etc. but to no avail.

After updating, I ran the security check, which gave some apparently very bad advice about changing permissions of hundreds of files to 744. I followed the advice, which totally broke the site. After reading the various guidance on permissions, I restored permissions to the best recommended ones I could, find but there are still permission errors occurring in the logs, which may or may not be related to this issue.

13498   11/Jun 17:49   file   Error      The specified file 'temporary://fileiFPN8R' could not be copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permiss
13497   11/Jun 17:49   file   Error      The file permissions could not be set on public://css.
13496   11/Jun 17:49   php    Warning    User warning: mkdir(): Permission Denied in Drupal\Component\PhpStorage\FileStorage->createDirectory() (line 145 of /home/public/core/lib/Drupal/Component/PhpStorage/FileStorage.php) #0 /h

What other troubleshooting steps can I perform short of attempting to restore a backup pre-update?


texts: How can I get the name of the currently logged in user in Drupal 7 in the external file?

texts:
In an external file I use the following code:

$path = $_SERVER['DOCUMENT_ROOT'];
chdir($path."/drupal");
define('DRUPAL_ROOT', getcwd());
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

global $user;
print $user->name;

The code doesn't print anything, but this code works:

$account = user_load(2);
print $account->name;

How can I get the name of the current user in Drupal 7?


texts:
I am using conditional field in content type.

Is it possible to do the same in views
i want to show one field dependent on value of first.

Thanks


texts: Access to private file only from website, not using direct link

texts:
My private files has a visible URL like the following: https://mywebsite.com/system/files/myimage.jpg.

How can I restrict access to the file, so it cannot be viewed directly from this URL but only from link on my website?

I have tried to use SESSION as follows.

$_SESSION['file-access'] = TRUE;
$output = theme('image_style', array('style_name' => 'foto_preview', 'path' => $uri));

Then I controlled in hook_file_download() if the SESSION key 'file-access' exists, but the session key never exists.
The image I wish to display is the value of an image field. I cannot use $user because I wish to display private files also for anonymous users.

Can anybody help on how to restrict the direct access to a private file, but allow access from website?

EDIT 30.7.2013: my mistake, using sessios works OK, I had a mistake in another unrelated part of code. The problem is solved.


texts: Adding a Serial (cck field) to the Page Title

texts:
I don't really know PHP or how to modify the Drupal API so it would probably have to be a solution in the Drupal interface or rather simple programming.

Is it possible to have a Serial cck field automatically combine with the page/node title? Example, Title: Update Example Task. Serial (job number): 225 -- Automatically combine to make the page/node title: 225 Update Example Task  -- So it can be referenced as a autocomplete term with either the Serial field or the Title

Thanks for any input!


texts: Is It Safe to Delete Content Types "Article" and "Basic Page"?

texts: It is highly unlikely we will ever use these in our CMS that we're implementing.  They're just cluttering things up.  Any reason why I shouldn't delete them?


texts: Configuring a public file directory & sub-directories

texts:
I'm doing some configuration updates to my site and I had a question regarding the permission configurations. I've setup a directory on the base level of site titled "publicuploads" which I've added into the "Public file system path" as "publicuploads".

It's permissions are currently set to 755.

After looking around my site's directory though, I am noticing though that the files and sub-directories inside of that directory are varying between 755, 775, and 644.

My question: What are the appropriate permissions be for this public directory?

Thanks in advance!


texts:
In Drupal 7, can I use hook_block_info() in a theme?

I would like my theme to create a block (which would contain dynamic content). This will allow the user to move it around where he wants to, or simply hide it.

Is this the way to go?

/**
 * Implements hook_block_info()
 */
function mytemplate_block_info()
{
  $blocks['mytemplate-block'] = array(
    'info' => t('TemplateBlock'),
    'weight' => -100,
    'status' => 1,
    'region' => 'content',
    'visibility' => BLOCK_VISIBILITY_LISTED,
    'pages' => '<front>',
  );

  return $blocks;
}

/**
 * Implements hook_block_view()
 */
function mytemplate_block_view($delta = '')
{
  $block = array();

  switch ($delta) {
    case 'mytemplate-block':
      $block['content'] = 'some custom html';
    break;

  }

  return $block;
}


texts: Bulk Generating URL aliases for taxonomy terms doesn't do anything

texts:
In D7, I've imported ~8000 taxonomy terms. All these need to have a url alias, based off their names.

I can check the 'Generate automatic URL alias' checkbox when editing each taxonomy term individually but I cannot go through and do this for all 8000.

I tried updating the paths with Bulk Generate. In the Patterns tab for my taxonomy term vocab I have set [term:name]. But when I hit Bulk Generate it doesn't update anything.

Would anyone know of a solution? An SQL query perhaps?


texts:
I want my node page turned off.  I don't want mysite/node/3 to work.  I want it to display 404.  I tried rabbit hole and it worked but the problem ws that it also stopped the aliases from working.

Is there a solution where I can turn off the node/whatever but keep my aliases?


texts: How to pass a Flag field's value to a Rules Component triggered by the flag?

texts:
Assume a flag (created using the Flag module) which triggers a rule, using Rules Event "When something is flagged" (with this flag). And assume that this flag has 2 fields defined for it also, i.e.:

"Date from", with machine name field_flag_a_group_date_from.
"Date to", with machine name field_flag_a_group_date_to.

When such rule is triggered, assume it performs a Rules Component, which contains a Rules Action to "Send an eMail".

Question: How to pass the values of those Flag fields to that Rules Component, so that they can be used in the message body of that eMail?


texts: Drupal 7 change default user login functionality

texts:
I want to change the default login functionality to look at a web service and if true log in else do not log in.

I have tried to use in hook_form_alter

 $form['#submit'] = 'user_change_login_submit';
  $form['actions']['submit']['#submit'][]= 'user_change_login_submit';

But it doesn't call this function.


texts:
It is Drupal 7.

This is kind of strange behaviour of the website.

This is my website http://www.protecdental.com. If you visit this website, you will see the right-hand top search field. Please see the screenshot https://snag.gy/LfCDxs.jpg

If you type any junk keyword (That means the site will definitely throw 0 results) for example "werewe" then you will see the proper search result page with no result.

But if you type a keyword related to the website's content for example "dental" or "contact" or any related meaning full keyword then you will see the broken page with no content at all.

Not too sure the issues is: it seems like if there is a search result data, then it is somehow breaking the page:

I didn't find any error log for it even when I tried watchdog.

I cleared the cache
I re-indexed the search
I manually ran the cron

But no luck. Can anyone please help to at least narrow down the cause of this issue.

My default search result template:

<?php if ($search_results): ?>

<?php print t('Search results');?>

    <ol class="search-results <?php print $module; ?>-results">
        <?php print $search_results; ?>

    <?php print $pager; ?>
<?php else : ?>

<?php print t('Your search yielded no results');?>

    <?php print search_help('search#noresults', drupal_help_arg()); ?>
<?php endif; ?>


texts: Why do my main menu tabs show up on two lines instead of one?

texts:
In Drupal 8, I have a main menu in the "Primary menu" block of the default Bartik theme. You can see a screenshot below. This site was upgraded from Drupal 7.

Why does the menu show up on two lines instead of one? There is plenty of space available for the menu items. I have tried adjusting the menu and block settings, but have not managed to reduce these to one line. All of the menu items other than "WOW" and "About" have "WOW" as the parent item.

You can see the site here:

http://worldsowisdom.com/wow/

Thank you!


texts: How to access actual JS settings of my module after ajax call?

texts:
I need to add some additional JS data for my views page.

I write in my module:

function mymodule_views_pre_render(&$view) {
if ($view->name == "myview") {

$outdata=array('dataset'=>my_custom_function_which_generates_data());
drupal_add_js(array('mymodule' => $outdata), 'setting');
drupal_add_js(drupal_get_path('module', 'mymodule') . '/js/init.js');
 }

 }

When the page loads, I can easily access to my data with JS using Drupal.settings.mymodule.dataset object.

(function ($) {

Drupal.behaviors.mymodule = {
    attach: function (context, settings) {

    console.log(Drupal.settings.mymodule.dataset);  //this code executes on page load and on AJAX refresh of the view

    }

    }

    });

But I need to change/refresh data with each view executing when the view refreshes by AJAX.
When I use exposed filters and enable AJAX, I expect to get fresh data.

The view content refreshes normally. Also I see in FF console, that my fresh data of Drupal.settings.mymodule.dataset is in JSON.

But variable Drupal.settings.mymodule.dataset stays the same as on the page load when I access it in my code.
What are I doing wrong?
How to access fresh data of Drupal.settings.mymodule.dataset?


texts: Delete directory from private folder programatically?

texts:
I'm using D8, and am writing a cron task to remove old backups from my private files directory. The backups are generated in private://db_backups/date-of-backups/backup.gz. The following code is properly deleting the actual backup files, but it is not removing the parent date directory. I am not receiving any errors in the drupal or server logs, so I'm a bit lost as to what's causing the failure.

function custom_changes_cron() {
    drupal_set_message(t('Custom cron function has run.'), 'status');
    $private_path = PrivateStream::basePath();
    $interval = strtotime('-430 hours');
    foreach(glob($private_path . '/backup_db/*' , GLOB_ONLYDIR) as $folder) {
        if (filemtime($folder) <= $interval ) {
            $files = glob("$folder/*"); // get all file names
            foreach($files as $file){ // iterate files
              if(is_file($file))
              unlink($file); // delete file
            }

            // Have tried both of the following
            rm_dir($folder);
            drupal_rmdir($folder);
        }
    }
}


texts: Kernel Test: Programmatically create a vocabulary and add a field to it

texts:
I want to add a taxonomy term and add field to it. My current code looks this way:

<?php

namespace Drupal\Tests\permissions_by_term\Kernel;

use Drupal\KernelTests\KernelTestBase;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\taxonomy\Entity\Vocabulary;

/**
 * Tests the ERR composite relationship upgrade path.
 *
 * @group permissions_by_term
 */
class SelectTermTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  public static $modules = array('taxonomy', 'text');

  /**
   * List of taxonomy term names by language.
   *
   * @var array
   */
  public $termNames = [];

  /**
   * The vocabulary used for creating terms.
   *
   * @var \Drupal\taxonomy\VocabularyInterface
   */
  protected $vocabulary;

  function setUp() {
    parent::setUp();

    $this->installEntitySchema('taxonomy_term');

    // Create a vocabulary.
    $this->vocabulary = Vocabulary::create([
      'name' => 'Views testing tags',
      'vid' => 'views_testing_tags',
    ]);
    $this->vocabulary->save();

    // Add a translatable field to the vocabulary.
    $field = FieldStorageConfig::create(array(
      'field_name' => 'field_foo',
      'entity_type' => 'taxonomy_term',
      'type' => 'text',
    ));
    $field->save();
    FieldConfig::create([
      'field_name' => 'field_foo',
      'entity_type' => 'taxonomy_term',
      'label' => 'Foo',
      'bundle' => 'views_testing_tags',
    ])->save();
  }

  public function testSomething() {
  }

}

If I run the test by the following command:

  vendor/bin/phpunit -c modules/permissions_by_term
  modules/permissions_by_term/tests/src/Kernel/SelectTermTest.php

I'm getting the following output:

  PHPUnit 4.8.11 by Sebastian Bergmann and contributors.

  E

  Time: 882 ms, Memory: 6.00Mb

  There was 1 error:

  1)
  Drupal\Tests\permissions_by_term\Kernel\SelectTermTest::testSomething
  Drupal\Core\Entity\Exception\NoCorrespondingEntityClassException: The
  Drupal\field\Entity\FieldStorageConfig class does not correspond to an
  entity type.

  /home/peter/Websites/pbt-d8/core/lib/Drupal/Core/Entity/EntityTypeRepository.php:98
  /home/peter/Websites/pbt-d8/core/lib/Drupal/Core/Entity/EntityManager.php:375
  /home/peter/Websites/pbt-d8/core/lib/Drupal/Core/Entity/Entity.php:509
  /home/peter/Websites/pbt-d8/modules/permissions_by_term/tests/src/Kernel/SelectTermTest.php:49

  FAILURES! Tests: 1, Assertions: 1, Errors: 1.

I do not understand this part:

  Drupal\Core\Entity\Exception\NoCorrespondingEntityClassException: The
  Drupal\field\Entity\FieldStorageConfig class does not correspond to an
  entity type.

As an example I have used the Drupal core taxonomy test from

  core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php

This test does what I want to do, but is not a Kernel test. It is a Simpletest, since it inherits from WebTestBase. If I use WebTestBase, it works. But the test is much slower then. Do you know what's missing in my code for running it as a Kernel Test?


texts: I can not change the author of the material, an error occurs. error code inside, along with a screenshot

texts:
I want to change the author of the material, but the Ajax work with error

Failed to load resource: the server responded with a status of 403 (Forbidden)


texts: Adding Input to Logged in User Interface Customize Look

texts:
With Drupal 7, can I add the ability for the logged in user to update and save a few form fields that then populate a list below the form? They could then edit / delete entries?

Is there a module that creates custom interfaces, or is this something I would be doing in the template?


texts: Popular Content with statistics module incorrect

texts:
So I wrote a custom module for displaying popular nodes, that is based on the buzzworthy module, but with a few tweaks. Buzzworthy has dependencies with the core statistics module.

The results are inaccurate, because when I compare with google analytics, GA yields different results. I know that GA has a latency issue, so it's like comparing apples and oranges, but another reason I know the list that my custom module displays is incorrect, is because it shows a blog post having waaaaaay more page views than it does normally.

Has anybody else had trouble with the accuracy produced by the statistics module? Is there a reason why my counts are incorrect?


texts: file_usage_add: custom type for my module

texts:
I have a custom calendar module I've created. When a user creates an event they have the ability to attach a thumbnail image to it. I'm trying to make it use the managed_file type. In the documentation it appears I need to use file_usage_add to keep it from throwing an error. The problem is I'm not sure what to put in the 'type' and 'id' parameters. The documentation lists these required parameters:

$file: A file object.
$module: The name of the module using the file.
$type: The type of the object that contains the referenced file.
$id: The unique, numeric ID of the object containing the referenced file.

$file and $module are easy. However, this module doesn't create a node or anything else. I have my own table structure for this information. Is there a way to define my table that events get stored in as a 'type' and pass that with the unique id from that table?


texts: How to render-print content type fields in an article?

texts:
I am building a Drupal website and came across with an issue.

I have created a content type called "comments" with 4 fields :

    -comment1 with machine name: **field_comment_1**

    - comment2 with machine name: **field_comment_2**

    - image1 with machine name: **field_image_1**

    - image2 with machine name: **field_image_2**

I have created an article and put the code below:

    <?php print render($content['field_comment_1']);?>
    <?php print render($content['field_comment_2']);?>

    <?php print render($content['field_image_1']);?>
    <?php print render($content['field_image_2']);?>

Unfortunately nothing shows... Any idea what I am doing wrong?

Many thanks for your help!


texts: How to create wrapping menu tabs with CSS in Omega

texts: I'm using the menu api (MENU_LOCAL_TASK) to create tabs in Drupal 7. In Omega, I can't figure out how to wrap the tabs in css so that they are responsive. I'm new to Omega. This was easily accomplished in other themes.


texts: How do you make an existing variable (from a module) available for use in my__node.tpl.php? D7

texts:
The contrib module i'm using (media gallery) outputs a block with a single thumbnail used to trigger a lightbox gallery.

The module has a tpl file used to render the thumbnail.

I want to isolate the single block thumbnail image ($media_gallery_item used in media_gallery_media_item_thumbnail.tpl.php) and insert it directly into a new node template (node--media-gallery.tpl.php)so that I can float the image in the body field (and preserve the lightbox trigger).

This is my first attempt at using a preprocessor.
Incidentally, I posted in the modules issue queue two weeks ago. I'm posting here as well to hopefully get a quicker response.


texts:
I have pressflow 6.22 website (drupal 6.22). I need to add UTM Source to RSS links so i can track the page views that come from RSS in google analytics.
how can i do so?
Thanks for your help


texts:
Never thought Drupal's way to use relative URLs everywhere in template files was a problem until I happened on https://stackoverflow.com/questions/17187437/relative-urls-in-wordpress and read some arguments against using relative urls of many WP developers including core ones. Copying them here:

  Root-relative URLs aren't really proper. /path/ might not be    WordPress, it might be outside of the install. So really it's not
  much different than an absolute URL.
  Any relative URLs also make it significantly more difficult to    perform transformations when the install is moved. The find-replace
  is going to be necessary in most situations, and having an absolute
  URL is ironically more portable for those reasons.
  absolute URLs are needed in numerous other places. Needing to add    these in conditionally will add to processing, as well as introduce
  potential bugs (and incompatibilities with plugins).
  Relative to what, I'm not sure, as WordPress is often in a subdirectory,    which means we'll always need to process the content
  to then add in the      rest of the path. This introduces overhead.
  Keep in mind that there are two types of relative URLs, with and without the leading slash. Both have caveats that make this impossible
  to properly implement.
  WordPress should (and does) store absolute URLs. This requires no pre-processing of content, no overhead, no ambiguity. If you need to
  relocate, it is a global find-replace in the database.

Now I wonder how much those concerns are legitimate in general, in if they or some of them are, then how much this relates to Drupal in particular?


texts: Pass no. of pages arguement to Drupal views pager

texts:
I have created views with display as page. In pager there is option to set no. of page to show. How can I set this dynamically by passing it through url? I can pass the page using
?page=2 and offset using ?offset=2 but I cant find a way to pass the no. of pages to show.


texts: CSS still requiring clearing cache after following steps to switch caching off

texts:
I have followed the steps detailed in this tutorial and many others -> https://knackforge.com/blog/rajamohamed/disable-drupal-8-cache-during-development

I have copied and renamed the sites/example.settings.local.php file as sites/default/settings.local.php

Opened settings.php file in sites/default directory and uncomment these lines:

if (file_exists(__DIR__ . '/settings.local.php')) {
  include __DIR__ . '/settings.local.php';
}

I have uncommented the following lines in settings.local.php to disable the render cache and dynamic page

$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';

I have opened development.services.yml in the sites folder and added the following lines (to disable twig cache)

parameters:
  twig.config:
    debug : true
    auto_reload: true
    cache: false

I have then cleared cache, this has worked for twig it seems as I am able to make changes in my page.html.twig and these update on a standard browser refresh.

However, any changes to by CSS files are requiring a clear cache every time, slowing development down quite a lot over time.

Hoping for some help here.


texts: Determine if menu link is current/active

texts:
When rendering a menu, in the twig file, you can set a class if item.in_active_trail is set:

  {% for item in items %}
    {%
      set classes = [
        item.in_active_trail ? 'is-active',
      ]
    %}

However this class is applied to each link in the trail - so if you are on the third level, three links get this class.

Is there anything I can see OOTB on item or add to it if the menu link is the current page? I need to highlight it and not just items in the trail itself.


texts: How do I 'subscribe' to user event creation, so I can run my own code when a user is created?

texts:
In Drupal 7, this was done with a hook.
And there also seems to be a hook available in Drupal 8/9:  8 - Drupal 8 hook into registration
Is this still the way to do it or is it being deprecated and Event Subscription is the way forward? If it is Event Subscription, is there an example code snippet for adding custom code on user creation please? Thank you.


texts: Invalid form POST data in AJAX Login form

texts:
I am working on a drupal 7 website using an AJAX login form. I have a problem, the form work fine once and then doesn't work when I logout and try again. I need to empty cache and try again to have it work again.
I think this is something linked to the form_id not found in cache but I don't know how to fix it.

Any solution?

Thanks


texts: Change file path of aggregated CSS file path

texts:
How do I go about changing the file path of the aggregated CSS file paths?

As most of you know, when using the Drupal option (from admin/config/development/performance) to 'Aggregate and compress CSS files' Drupal creates different CSS files that look something like this:

My issue is that my site visitors are always seeing the cached (old) version of my stylesheet when they visit my site. Of course I always want them to see the newest version, but I also want to optimize my website as well as possible.

Back to my original question. Is there any way to change the path that looks like gibberish (first example starts with "791YXB.....") ? I've gone through several of the questions here, but I can't find an exact answer for this.

Just for reference, this is how my performance options are setup:

After making changes to my CSS files I also always click the button to 'Clear all caches'.


texts: Imagecache_external: Thumbnails of external URLs aren't accessible

texts:
Modules:

Imagecache External, Media, Remote Stream Wrapper

Scenario:

I created a content type, in which I want to collect Movie Actors. My aim is to add images of those actors which arent hosted on my drupal site itself. They are being linked via Remote Stream Wrapper but RSW doesnt allow to use Image Styles on those external images (for example thumbnails). The solution is Imagecache External, which allow Image Styles even on external hosted images.

Problem:

Imagecache External returns Image-URLs which ends with a cryptic snippet, which resolves into an error message: Access denied

  localhost/drupal/sites/default/files/styles/cover/http/img4.picload.org/image/acdcwwi/imagestyle_examp.png%3Fitok%3DAyQfRnDQ

Thumbnails are being saved in a directory, which represents the URL of the external image:

  drupal\sites\default\files\styles\cover\http\img4.picload.org\image\acdcwwi\imagestyle_examp.png

Detailed Problem Description:

Imagecache External creates thumbnails with such URLs:

  localhost/drupal/sites/default/files/styles/cover/http/img4.picload.org/image/acdcwwi/imagestyle_examp.png%3Fitok%3DAyQfRnDQ

If I open this URL directly, I get an "Access Denied" error because I dont have permission for that page (-> even as an admin!?). If I remove this cryptic snippet at the end of the URL (%3Fitok%3DAyQfRnDQ), the Thumbnail is accessible.

The other problem is that the thumbnails are saved in a directory, which is equal to the external URL:

  drupal\sites\default\files\styles\cover\http\img4.picload.org\image\acdcwwi\imagestyle_examp.png

This will result in a not overviewable directory tree.

The external image I linked externally for example is this one:
http://img4.picload.org/image/acdcwwi/imagestyle_examp.png

I hope anybody has a solution to my problem. :-/

Greetings,
KG


texts: How to override node content in Drupal 7

texts: So I see in the archives how to override a node's $title (How do I overwrite node title for specific content type?), but how would I override the node's content in Drupal 7? I see that Drupal 7 no longer uses $vars['content'], which was really handy in Drupal 6


texts:
Where can I see the each table usage, which is getting created in default installation of a Drupal site.

Likes node table - used to store all nodes in them. For other tables where i can get the information. Any documentation for each table usage in database??

Thanks in advance.


texts:
So I am trying to get the code coverage report to work with my functional JS tests.  I have been looking everywhere and trying everything, but I just can not seem to get the report to work, even though I know my code is being touched.  The report just keeps saying 0% of code.
Here are my tests: https://git.uwaterloo.ca/ece-651-drupal-project/uw_news_profile/-/blob/1.x/tests/src/Functional/UwNewsTests.php
Here is the script I run to try and get the code coverage: https://git.uwaterloo.ca/ece-651-drupal-project/uw_news_profile/-/blob/1.x/code_coverage.sh
Here is my phpunit.xml file: https://git.uwaterloo.ca/ece-651-drupal-project/uw_news_profile/-/blob/1.x/phpunit.xml
I am using Drupal4Docker as my docker container, with xdebug3 turned on and mode set to coverage:
php:
    image: wodby/drupal-php:$PHP_TAG
    container_name: "${PROJECT_NAME}_php"
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
      PHP_FPM_USER: wodby
      PHP_FPM_GROUP: wodby
      PHP_XDEBUG: 1
      PHP_XDEBUG_MODE: coverage
      PHP_XDEBUG_CLIENT_HOST: 172.17.0.1 # Linux

Any help will be appreciated, I am doing this for my Master's degree course in Software Engineering and if I don't get code coverage working, then I will fail the project.  I have spent weeks at this with many late nights, PLEASE HELP if you can.


texts:
I'm using Search API with it's build in Database search, and while the results are much better than the default Drupal search, the speed is quite slow. I'm seeing 10-15 seconds to get the results page to load. Any pointers to speed things up?
Currently there's just under 1,500 items in the index. Happy to get more specific with setup, but any general help would be appreciated to start.


texts: How to fetch a single value with an entity metadata wrapper?

texts:
Say I want to fetch a single value from the node table: I could use the database API:

$value = db_query('
  SELECT title FROM {node} WHERE nid = :nid
', array(':nid' => $nid,))->fetchField();

What is the equivalent using an entity metadata wrapper?

Thanks.


texts: How to add sub title name in the header using pixture reloaded sub theme of drupal 7.x?

texts:
I need to add sub title name(with different font) next line of the "site name" in the header.
Am using  pixture-reloaded sub theme. could anybody, please help me out, where should i change and what piece of code i should add to diplay it out.

for example:
site name: Drupal Answers
next line of the site name, i need one more line to display :  Welcome to out job portal.

How can i alter my coding. Please help me out.thanks


texts: Track Simplenews newsletter open per user

texts:
I send newsletters from my Drupal 7 site, using the Simplenews module.  I'm using this tracking code, but it isn't tracking uniqueness:

<img src="http://www.google-analytics.com/collect?v=1&amp;tid=test-&#10;&#10;1&amp;cid=123445678&amp;t=event&amp;ec=email&amp;ea=open_my_newsletter_june2016&amp;el=recipient_id&amp;cs=newsletter&amp;cm=email&amp;cn=Campaign_Name">

I change the tid according to my Google Analytics account and the ea attribute to the name of my newsletter and the date, but these aren't unique URL's for users.

How can I track unique opens of my newsletter, using Google Analytics?


texts:
I have created a rule to trigger an email in user profile. But I could see the email after running cron only or else I could not see email in my inbox. Why is this? Can any one help in this please? I want to send an email automatically on particular date even though if I don't run the cron.

Can anyone help me? You will be appreciated.


texts:
I want when a node saved,one block region be change.

for example: when a node be save,"user-login block" move to the content region.

please help me for resolve this problem.

thank you


texts: How can the Feeds module fetch a file from a dynamic URL?

texts:
The feeds module does fine importing a source file (CSV, in my case) from an external URL. However, I'm trying to schedule Feeds to pull in a report every X days. I need Feeds to fetch at a dynamic URL,
say:
www.example.com/report/%start-date%/%end-date%

I'm guessing this would use the Token module, but aside from that I'm not sure what to do.


texts: How to alter and rewritte current path programmatically in Drupal 8?

texts:
Here is what I'm trying to achieve :

I have a multilingual site with 2 languages (en, fr) but I I also have 4 iso_codes (us, gb, fr, be).

I want Drupal to understand that /us and /gb for example is an alias of /en (they share the exact same content).

Do you know if there is a way to  achieve that programmatically or with a module ?

I'm currently looking into two event subscriber to setPath on the go : RouteCollection and KernelEvents::Request, but no result for now.

Any help would be greatly appreciated.


texts: I am using Drupal 6. I am unable to access node type edit pages. because it redirects it to site data management page. i searched on google but not find any reason. can any one suggest what is the reason.


texts:
How can I get the effect like on StackExchange where user information is displayed when you hover over their avatar?

I have a site that only has images on the front page, and would like the user to be able to get some information about the image before they click through.

I am using Drupal 7.


texts: Get the submitted values of a multistep webform

texts:
I need to get the submitted values of a multistep webform. It looks like webform doesn't save values from earlier steps in the usual place: $form_state['values']['submitted'] or $form_state['input']['submitted']. I just need the submitted values of every form component at the last page.

I actually made a custom submit handler to store the values from each form in my own location in $form_state, but I was wondering if there was a better way.


texts: Customise main-menu link - adding a '/' between  items

texts:
I am using the Omega HTML5 base theme and am attempting to add a '/' delimiter between main_menu items on my site.

I have searched high and low and the closest I've come is the following:

function MYTHEME_menu_link(array $variables) {
$delimiter = '';
  // Only add delimiter to the main menu
  if (strpos($variables['element']['#theme'], 'main_menu') !== FALSE ) {
    // Only add delimiter if item is not the last one
    if (!in_array('last', $variables['element']['#attributes']['class'])) {
      $delimiter = '/';
    }
  }
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  // Add delimiter just before the closing
 tag
  return '
' . $output . $sub_menu . $delimiter. "
\n";
}

This actually works on any another template (just not OMEGA). Irrespective does anyone have an approach to adding this forward slash on main-menu items?

Thanks!


texts:
I created a custom twig file that outputs a few basic fields, such as images and text. Here's what my twig file looks like:

    {{content.field_image}}

    {{content.field_year}}

{{content.field_heading_text}}

I'm trying to have a little more control of the HTML that gets output. Here's what I'm seeing for a few of these fields:

I want to either, A, get rid of the div element that outputs "1963" or "Imagining a better world" or, B, get control over the div element so I can add a class to it and later style it.

Thank you in advance!


texts:
I'm writing a module that will have to make a connection to a seperate database. In order for the user to configure the database, I'm allowing the user to fill out the database connection info in the module configuration form.

How can I test the database connection before submitting the form?

I added the relevant code below:

function mymodule_form($form, &$form_state) {
  //Form code omitted
  $form['#submit'][] = 'mymodule_form_submit';
  $form = system_settings_form($form);
  return $form;
}

function mymodule_form_validate($form, &$form_state){
  // Validation code, test db connection, need help here.
}

function mymodule_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  $database = array(
    'database' => $values['database_name'],
    'username' => $values['database_username'],
    'password' => $values['database_password'],
    'host' => $values['database_host'],
    'driver' => $values['database_driver'],
  );
  Database::addConnectionInfo('mymoduleDB', 'default', $database);
}


texts:
I have created a view, with few exposed filter in it. It is working fine, but I when I filter view using some exposed filter, it appends query string to URL ie

mysite.com/search?field1=value_1&field_2=value2

Instead I wanted to make it SEO friendly like,

mysite.com/search/value_1/value2

Please guide how should I proceed. I have searched for it, but didn't get any solution or I have missed something.

Thanks for your time.


texts:
I have installed phpMyAdmin.

I can see the admin user (uid=1) in each of the two databases

I have reset the password using;

update users_field_data set pass=Password("new_password");

I can see that the pass hash has changed confirming a changed password.

I got to http://mysiteURL/user/login and enter the admin name (shown in users_field_data table) and the new password.

Upon submit I only get the border of the login name field changed to red.

I have cleared the sessions table and removed the cache_entity data for uid=1 with no change in behaviour.

yum list | grep -i php

returns a lot of php packages from version 5.6 to 7.3. I am not sure if this is normal but php seems to work since both websites load and I can use phpMyAdmin and phpinfo() returns php7.2.7

I have checked error logs for each website, nginx, drupal and php with no obvious errors.

Curiously drush cli does not work i.e.

./drush uli

sh: module: line 1: syntax error: unexpected end of file
sh: error importing function definition for `BASH_FUNC_module'
Drupal\Core\Database\ConnectionNotDefinedException: The specified database          [error]
connection is not defined: default in
/app/jbi2/core/lib/Drupal/Core/Database/Database.php:361

I have now resorted to reviewing the Drupal 7 installation steps.

Thanks in advance for any well informed replies.


texts:
I set up an account at BlueHost and my unfinished site is now live at columbiablooms.org.

My understanding is that when I make modifications, such as enhancements, that changes are made not only to the file structure, but also the database meaning that from this point forward I need to make all my changes and content additions to this live site. Also, I want to be very careful to backup both the file structure and the database before I make changes in case I mess things up.

At this point my Acquia Dev Desktop is not very useful since there appears to be no way to merge what I've done on my local machine with what's live out there on the web.


texts: an error occurred while installing jplayer and audiofield module on server in drupal 7

texts:
I tried to install jplayer and audiofield modules on server but the following error reported and I could not understand what it is and how to solve it:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: http://mywebsite.com/authorize.php?batch=1&render=overlay&id=28&op=do StatusText: Internal Server Error ResponseText: UnexpectedValueException: RecursiveDirectoryIterator::__construct(/home/username/public_html/C:/xampp/tmp/update-extraction-7a580f22/jplayer) [recursivedirectoryiterator.--construct]: failed to open dir: No such file or directory in RecursiveDirectoryIterator->__construct() (line 408 of /home/username/public_html/includes/filetransfer/filetransfer.inc

I installed these modules on localhost and there was no error.


texts: How to upcast webform submission in custom routes resp. controller?

texts:
Using this route:

confirm:
  path: '/node/{node}/submission/{webform_submission}/confirm'
  defaults:
    _controller: '\Drupal\mymodule\Controller\MymoduleController::confirm'
    _title: 'Confirm your submission'
  requirements:
    _permission: 'confirm webform submission'

And visiting node/15/submission/15/confirm I get the error:

  RuntimeException: Controller
  "Drupal\mymodule\Controller\MymoduleController::confirm()" requires
  that you provide a value for the "$submission" argument. Either the
  argument is nullable and no null value has been provided, no default
  value has been provided or because there is a non optional argument
  after this one. in
  Symfony\Component\HttpKernel\Controller\ArgumentResolver->getArguments()

What am I doing wrong? Why doesnt it load the submission 15? It does exist.

Edit: this is my Controller, the second argument is always null:

<?php

namespace Drupal\mymodule\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\Controller\EntityViewController;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Entity\EntityInterface;
use Drupal\webform\WebformSubmissionInterface;
use Drupal\webform\WebformSubmission;

/**
 * @todo
 */
// class MymoduleController extends ControllerBase { // doesnt make a difference
class MymoduleController extends EntityViewController {
  public function confirm(EntityInterface $node = null, EntityInterface $submission = null) {

    debug($submission);

    $response = new Response( 'test' );

    return $response;
  }
}


texts:
Is it possible to partially transliterate URL alias, so to leave for example the case of the node title unchanged, such as in:

/this/is/my/transliterated/path/THIS-IS-UNCHANGED-Node-Title-888

with the purpose behind it being to preserve product symbols, where similarity between lower and uppercase is unwanted.

And I mean fully automated behavior, such as with a template function or a module.


texts: How do I restrict the type of characters that can be used at registrations?

texts: I want to disallow the use of spaces and all symbols except "_".