texts: metatag_panels does not work on panel pages

texts:
I want to add the

<meta name="keywords"/>

tag to my pages.

For this, I have installed the metatag module.

It works fine for all pages except the panel pages. So I activate the metatag_panels module, but it does not help. I can’t find any configuration or special field to activate meta tag on panel pages.

Is there any special configuration or something? Does somebody has any idea how I can get it work?


texts:
I am getting a lot of bad requests from a crawler at a specific IP Address non-stop. I added the IP to the blocked list and cleared the cache, but I still see more requests in the dblog coming in from the IP:

HTTP response: Bad Request. URL: https://valid.url.example.com/api/123456>; rel="canonical",<https:.json.

Why can they still send requests? Is there a way to prevent these?


texts: menu block or view that shows only siblings and parents

texts:
It seems like this function was removed in drupal 8 so I am trying to find a solution that doesn't involve created a large amount of blocks or hard coding something. (Best would be a block or a view)

I have menu structure like this:

Parent 1
- Child 1.1
-- Grandchild 1.1.1
-- Grandchild 1.1.2
- Child 1.2
-- Grandchild 1.2.1
-- Grandchild 1.2.2
Parent 2
- Child 2.2
-- Grandchild 2.2.1
-- Grandchild 2.2.2

When I am on Grandchild 1.1.1 I want to see only the entire tree of Parent 1 (that means parent 1 plus all of its child and grandchild items), nothing from Parent 2 and below.


texts: "This view has been automatically updated to fix missing relationships" - fields removed from a working view for no reason

texts:
I have a site built on Commerce Kickstart 1 - Views 3.7.
I have a standard cart, to which I wanted to add photos of the products. It is a view that includes a relationship to Commerce Order: Line items and  a contextual filter by Order ID.

Now, I added a reference to the product in order to be able to access the photos.     The view works OK, all the initial elements and the images are there, but when i try to edit it, all the relationships are gone and I receive the "This view has been automatically updated to fix missing relationships" message. Both the relationship I added and the default relationship to line items are gone.

RELATIONSHIPS
Commerce Order: Line items
(Line Item) Commerce Line item: Product

FIELDS:
(Line Item) Commerce Line item: Display path
(Product) Field: Image (Image)
(Line Item) Commerce Line Item: Title
(Line Item) Commerce Line item: Unit price
(Line Item) Commerce Line Item: Quantity text field
(Line Item) Commerce Line item: Total
(Line Item) Commerce Line Item: Delete button

To me it looks like a bug in Views? There is a discussion of a similar issue https://drupal.org/node/1860380 (the last post is actually mine). Maybe I am wrong, though, maybe it's me who's doing something wrong?


texts: View with dropdown filter criteria for all nodes

texts: I want to make a view of a Content Type with exposed filters as the attached image shows. First criteria filter would be the book type that is a field of the Content Type BOOK. Second filter criteria would be all the nodes of the Content Type BOOK. Is it possible?


texts: Change view & edit route or URL of Entities generated by Drupal Console

texts:
I have generated a custom entity using Drupal Console.

drupal generate:entity:content

However, there is one serious problem. All the default route for the various operation related to that entity are coming under /admin/.. route. Which prevent non-admins from accessing those pages even if given permission for example to edit it.

When I generate an entity called company. My routes are as below:

View Single Entiy: /admin/structure/company_entity/{company_entity}
Add Entity: /admin/structure/company_entity/add
Edit Entity: /admin/structure/company_entity/{company_entity}/edit
Delete Entity: /admin/structure/company_entity/{company_entity}/delete
List all Enitities: /admin/structure/company_entity

Where should we edit the module to override or change these settings.


texts:
There is a week since Drupal 6.30 is released to fix some XSS vulnerability, but Pressflow is still on 6.29.

I am wondering if it is discontinued. If so, are there any new forks that up to date?


texts: Accessing the cell phone camera to populate the profile picture field

texts:
I have a mobile website, and I thought it would be cool if there were a way for the user to take a picture with their phones camera to populate the field rather than have them go and upload a picture they have on their phone, similarly to the way used from some websites to access the computer's webcam to let you take pictures.

I'm not sure if this is even possible to do from within a web browser on a phone. I've seen Flash soultions that access the webcam of a computer via the browser, would any of those solutions work for Drupal?


texts: drupal_render() is deprecated. What replaces it?

texts: I have a render array and I want to convert it to HTML and place it in a WYSIWYG field. What is the generally accepted way to do that since drupal_render() is deprecated?


texts:
I'm migrating contents from D7 to D8. I'm exporting nodes with services_views and importing with migrate.

I would like to import also revisions. How should I do? Revisions on D8 don't seem entities, so what kind of "target" should I use to import them?


texts: How does a view (/admin/build/views/) relate to a .tpl file

texts:
I am new to Drupal and now maintaining a completed Drupal site and I am struggling to understand how it all came into existence :)

What I have gathered from poking around the current code base is that there is some kind of relation from a view you create in the admin section to a .tpl file, and for the life of me I cannot figure out what it is.... am I even on the right track?

Any help or good reads would be much appreciated!


texts: How do I Import users in the database without re-hashing the password

texts:
I want to import users from one database to another, without changing password.

Suppose the password is saved as $S$DfAoLR.OJWl04tkzgnZeE3TdJHlz6NxBNpArOKhQAewyyHDFDD in the database; I want to save the same value in the database of the other site.

Can anyone suggest me how to achieve this?


texts:
I am trying to create a block (that I can reuse in different templates and pages)that shows taxonomy terms (for a specific vocabulary).

I have already created a view to get the term list, and started overriding twig files to modify the display of the view. I modified the following files so far:

block--views-block.html.twig
views-view-fields.html.twig

The idea is to implement a bootstrap layout where the "row" div is on the first file and the "col" divs are in the second one.

Overriding those files is working but the layout breaks because there is a lot of unwanted code rendering. For example, the code generated by:

core/modules/system/templates/container.html.twig
core/modules/views/templates/views-view.html.twig

Which as I understand I can't override and I shouldn't modify (because they are in /core).

How can I get rid of all the unwanted code those files generate?


texts: How to define custom permissions for organic groups?

texts:
I would like to define some organic group permissions for a custom entity. The permissions should look like:

  $perms += array(
        "create $type content" => array(
          'title' => t('Create %type_name content', array('%type_name' => $name)),
        ),
        "update own $type content" => array(
          'title' => t('Edit own %type_name content', array('%type_name' => $name)),
        ),
        "update any $type content" => array(
          'title' => t('Edit any %type_name content', array('%type_name' => $name)),
        ),
        "delete own $type content" => array(
          'title' => t('Delete own %type_name content', array('%type_name' => $name)),
        ),
        "delete any $type content" => array(
          'title' => t('Delete any %type_name content', array('%type_name' => $name)),
        ),
      );

How do I do this? I found the function  og_get_permissions() to get all set permission, but how to modify this array?

Or may be it should be another way round? You set a normal drupal permission first with:

function custom_example_permission() {
  return array(
    'administer my module' => array(
      'title' => t('Administer my module'),
      'description' => t('Perform administration tasks for my module.'),
    ),
  );
}

And then make it eligible on the permission preferences page of OG? But how?


texts:
i got a user-login-block.tpl.php to customize user login block of Drupal 7. here is that code:user-login-block.tpl.php:

<?php print $name; // Display username field ?>
<?php print $pass; // Display Password field ?>
<?php print $submit; // Display submit button ?>
<?php print $rendered; // Display hidden elements (required for successful login) ?>

Create an Account | Forgot Password

this works; here is the screenshot:

but i want to print only the username field, password field and the submit button so i can easily position them, using css, adding custom label etc.. Also delete the blue marked default drupal 7 links..  any idea? thanks..


texts: How do you allow logged in users to comment via Disqus without extra login?

texts:
I have a Drupal site that utilizes Disqus commenting, but want users to be able to use commenting function, without having to login to Disqus.

Is there a way to make Disqus automatically inherit the user information of a person already logged onto my Drupal site?


texts: How do I add an access condition to a menu item?

texts:
How can I add new conditions on top of existing conditions that determine whether a menu item is visible? These conditions should not be limited to permissions settings.

As an example use case (not necessarily the reason for this question): Suppose I have a content type of which users are only allowed to create one node. I have a menu item for adding that type of content. But if the user has already created a node of that content type, I want to hide the menu item. My first thought is to run a query to check for the existence of a node created by the current user that is of the specific content type. If one exists, hide the menu item.

I would think this type of functionality should go into hook_menu_alter() and add the required logic there. But I'm not sure how to do that without bypassing the existing checks, like checking if the user has permissions to create that type of content. Would I have to include that logic within my own condition? Or can I add to the existing access logic without overwriting it?

Edit: Some people seem focused on answering "how do I limit a user to creating one node of a content type". That is not the question here. The question is how to I add custom access conditions to a menu item.


texts:
I need to do a couple of things:

Inject guzzle's httpclient into class A
Inject class A into my service

What I've tried so far:

services:
  my_module.field_fetcher:
    class: Drupal\my_module\ClassB
    arguments: ['@my_module.obj', '@logger.factory', '@config.factory']

  my_module.obj:
    class: Drupal\my_module\ClassA
    arguments: ['@http.client']

parameters:
  my_module.http_client.config:
    base_uri: 'http://myurl.com/'

services:
  my_module.http_client:
    factory: '@http_client_factory:fromOptions'
    arguments: ['%my_module.http_client.config%']

  my_module.obj:
    class: Drupal\my_module\ClassA
    arguments: ['@my_module.http_client']

  my_module.field_fetcher:
    class: Drupal\my_module\ClassB
    arguments: ['@my_module.obj', '@logger.factory', '@config.factory']

Simple versions of classes A and B look like this:
ClassA:
<?php

namespace Drupal\my_module;

use GuzzleHttp\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class A {

  /**
   * @var \GuzzleHttp\ClientInterface
   */
  private $httpClient;

  public function __construct(ClientInterface $httpClient) {
    $this->httpClient = $httpClient;
  }
}

ClassB:
<?php

namespace Drupal\my_module;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Psr\Log\LoggerInterface;
use Drupal\Core\Logger\LoggerChannelFactory;

class B implements BInterface {

  /**
   * @var \Drupal\my_module\A
   */
  private $a;

  /**
   * @var \Drupal\Core\Logger\LoggerChannelFactory
   */
  private $logger;

  public function __construct(A $a, LoggerChannelFactory $logger, ConfigFactoryInterface $config) {
    $this->a = $a;
    $this->logger = $logger;
  }

  public static function create(ContainerInterface $container) {
    return new static(
      A::create($container),
      $container->get('my_module.obj'),
      $container->get('logger.factory')->get('my_module'),
      $container->get('config.factory')
    );
  }
}

No matter what I try, I keep running into the same issue of drupal error logs telling me that "argument 1 passed to Drupal\my_module\ClassB::__construct() must be an instance of Drupal\my_module\ClassA, string given"
Edit: Updated classes A and B to reflect changes suggested.


texts: Module for username suggestions on registration

texts: Is there any Drupal module which checks the username in the database, if its present then it should display some suggestions to be selected just like the yahoo or gmail gives on registration?


texts: Views shows the page for deleted nodes, instead of the 404 error page

texts:
I am running Drupal 7, and have created several views. I am noticing a problem: If one adds a node ID in the URL, it returns the views page for that content type instead of 404 error.

I want that when someone enter http://www.muktware.com/articles/3583, Drupal returns the 404 error page.


texts: Migration from CSV: how to define a default value for autoincremental id field?

texts:
I run migrations from CSV using Migrate Source CSV, Migrate Plus and Migrate Tools modules and it works fine.
The result of one of these migration is a custom entity which key is a 'id' field that has the 'AUTO_INCREMENT' property in the database.
Here is my migration_contractssubscriptions.yaml

id: migration_contractssubscriptions
migration_group: null
label: 'Contract Subscriptions migration from CSV'
source:
  plugin: csv
  path: /mypathto/migration_ContractsSubscriptions.csv
  delimiter: ';'
  enclosure: '"'
  header_row_count: 1
  keys:
    - id
process:
  id: id
  contract_id: contract_id
  member_id: member_id
  sharedwith_member_id: sharedwith_member_id
  comment: comment
  quantity01: quantity01
  quantity02: quantity02
  quantity03: quantity03
  quantity04: quantity04
  owner_id:
    plugin: default_value
    default_value: 1
destination:
  plugin: 'entity:contract_subscription'

I'd like to get rid of 'id' in my csv file and let the migration process handle the value of the resulting id.
I tried to remove keys: - id and id: id but I get an error...
How can I achieve that?


texts: How to add a CSS class to fields in Drupal 7?

texts:
I want to add a CSS class to the HTML output of each field in my field collection.

Please recommend me some module or method to achieve this. I have tried the Fences and Field Formatter Class modules but they did not work.


texts: How do I get the UID in user-profile.tpl.php?

texts:
I'm trying to make a custom view mode for user profiles. In my user-profile--myviewmode.tpl.php, I want to get the UID for the user whose profile it is.

The help text for user-profile.tpl.php states:

  $user_profile: An array of profile items. Use render() to print them.
  Field variables: for each field instance attached to the user a
  corresponding variable is defined; e.g., $account->field_example has a
  variable $field_example defined. When needing to access a field's raw
  values, developers/themers are strongly encouraged to use these
  variables. Otherwise they will have to explicitly specify the desired
  field language, e.g. $account->field_example['en'], thus overriding
  any language negotiation rule that was previously applied.

I used dpm() to print out the array $user_profile, but I couldn't find the UID anywhere.

Then I tried:

global $user;
$uid = $user->uid;

However, this doesn't work because when I use Views to render the view mode, it gives me the UID of the logged-in user, not the user whose profile is being rendered.

Is there a way to get the UID in user-profile.tpl.php?  I need to get the UID to build some custom links based on it.


texts: Set field to calculate sell price in Commerce

texts:
I've got two prices on each of my Commerce products; the standard price field and a retailer price field.

In order to minimize both possible manual miscalculations and time spent on adding products I'd love if the standard price could be automatically calculated based on a formula I provide (Retailer price + Packaging + Copyright fee + Payment gateway fee + markup). I'd need to be able to change the values per Product Type via the UI at any time.

I've never done any math in drupal so any pointers would be greatly appreciated.


texts:
I have a site that is developed with panes. There are "Contact Us" forms at the bottom with bad links. Some pages share the same pane, some have different panes.

My task is to standardize all the pages so that they use the same pane, so that fixing a link in one will fix the link in all of them.

What I see as the title is Contact Us (id: 1740). That's the title of the pane that is shared among certain pages. On other pages, it's Contact Us (id: 1738), with different ids for different pages.

What I would like to do is copy the pane entitled Contact Us (id:1740) to all the pages that have the Contact Us section. However, I am not sure how to copy it from one page to another.

When I click on the gear icon of the page and choose Edit, I can edit the values, but I don't see what type it is. I've looked at node of nid 1740-- it's not that node. Also, I don't see that title in the list of re-useable panel panes.

How can I copy this panel pane to other pages where it doesn't already exist?


texts: How to assign permissions to roles programmatically?

texts:
I have some permissions that I would like to assign to some roles programmatically for easier installation.

Because I'm installing the module and creating both permission and roles, I don't have the role id's, where I want to set the permissions. So far I have only found ways to assign roles programmatically that need the role ID.

I wonder if I somehow could look up the roles with their name (string), retrieve the role ID and then assign permission. It just doesn't feel right.


texts: Can anyone tell me the best possible way of how to reinstall Drupal 7 from ubuntu 13.04? After googling came through many options that is making me confused!


texts: Display Related Nodes by Taxonomy Terms in Block

texts:
There are numerous articles on how to display related nodes from taxonomy. In all these articles, it states to set contextual filter: Has Taxonomy Term & select option: Taxonomy Term ID from URL.

In my case, I do not have any taxonomy term in the node URL

I want to display nodes which have common terms when the term is NOT in the URL.

I have tried the approach in many articles that require the option: Taxonomy Term ID from URL & select "Load default filter from node page, that's good for related taxonomy blocks" and further to select the Vocabulary.

I have tried this approach, however, it does not show any related content, possibly as I do not have any terms in the URL?

Please advice.


texts:
I find the perfect module to do what i want to do in private messages (put a "Send author a message" to open a contact between a user and an author)

Unfortunately, i didn't find a way to put that "Send author a message" when i use views module. I display my article by fields and i don't find that field.
I'm just begin to discover Drupal 7 so i don't know if i do the right thing.

I searched on the module section in drupal.org and i saw that the only module available for views with private messages was for Drupal 6.

Maybe someone know if there is a solution to integrate private messages with views (i'd love to have the same behavior that flags has with views: add the flag with add field)
I looked at "advanced section" and "add relationship" to see if i can find something to add like flag but i didn't find anything.

ps: sorry if i made many mistake in english.

Thanks,
Arno


texts: Noitifications about security updates keeps coming after the update is done

texts: I have updated to core version 7.52 and I also ran the database updates accordingly. So why do the notifications keep coming? I have set the update check to be done once a day, and every morning I get an email that states that a security update is available for my version of Drupal. When I click the link the page opens and says that Drupal core is up to date.


texts: How to deactivate keyboard navigation when using the “Views Slideshow: Swiper JS” module

texts:
So I am using the Views Slideshow (7.x-3.9) module in conjunction with the Views Slideshow: Swiper JS (7.x-4.0) under Drupal 7.61 and it’s working great for my needs. But have run into an issue. The version of the Swiper JS library I have installed is 4.4.6.

While the “Format > Slideshow > Settings” clearly has an option that you need to check a checkbox to enable keyboard navigation, and I have that option unchecked, I can assure you that keyboard navigation is clearly enabled.

Looking at this issue request on the Drupal page for Views Slideshow: Swiper JS shows a similar issue where the Drupal module settings seem to not be respected by Swipe JS when loaded, but the “solution” (kludge?) of downgrading to a 3.x.x version (such as 3.4.2) doesn’t work for me. Beyond not wanting to be behind the curve in patches and development on Swiper JS, when I attempted to swap my 4.4.6 version to 3.4.2 made the slideshow go a bit haywire.

So what can practically and simply be done to disable the keyboard functionality of Swiper JS under Drupal?


texts: Edit Block body content directly in database

texts: I've used some php code in a block that appears on all pages and now receive a fatal error and cannot access the site. In what table and field can I find the Block body content in the database for a Drupal 7 site? I plan to edit the Block body content directly in phpMyAdmin.


texts:
I have 2 sections that are accessed as section1, section2 that have thier own node templates. Each section has a resource subsection, which should share a node template (node--resources.tpl.php).

How can I configure my url using Pathauto such that urls section1/resources and section2/resources, both use the node--resource.tpl.php? Is this possible? All attempts have failed.


texts: How to display 9 products WITH images on one page

texts:
I've managed to add products and even create a "Store" node that gives me a dropdown of my CDs. BUT, I have yet to figure out how to display all 9 products on that "store" node or, at the very least, have each product show a thumbnail image so that it's not just a plain dropdown menu.

In addition, I followed another tutorial that instructed me to create add content using the "Display" content type I created but this still only shows one product. {http://drupal.stackexchange.com/questions/1849/how-do-i-display-my-products

Please help.

…Drupal Newbie…


texts: How to restore complete database keeping the site in maintenance mode in Drupal 7

texts:
I need to restore complete database in a regular basis (weekly). I am using pure PHP + system call to mysqldump and mysql to backup and restore full database. The restore process takes 2 minutes. What would be the correct procedure in order to keep the site in maintenance instead of getting a Drupal database error? Is there some sequence of table restoration?

For example, I use UPDATE variable SET value = 's:1:\"1\";' WHERE name= 'maintenance_mode';" just before the restoration, but obviously as there is a DROP TABLE if exists maintenance_mode in the SQL backup file, the site will show an error instead of the maintenance screen for a moment, and maybe in more occasions if there are incongruences among the different tables as they are updated.

I was thinking of controlling the process with the .htaccess, forwarding all traffic to a static HTML maintenance page.

Update: I have created my own module as there are many other tables which are outside Drupal and the product has to be specifically integrated with the requirements of the customer. So I cannot use the Backup and Migrate module (as suggested in one of the answers).


texts:
I have plenty of Panels pages that I track using the Features module. Currently, if I create put a Custom Content pane inside of a page, all of the content that is inside that pane is then stored in code.

If I make the custom content pane reusable or use a block instead, it is referenced by id. I don't want this behavior, either. For example, I create the block on my development environment, add it to my page, and commit my feature containing that page to version control. When I pull those changes into my test environment, the page is looking for a block with a specific id. Chances are the block won't exist, and I have to go create it. When I do that, though, there's no guarantee that my block will have the same id. Even worse, a block might already exist with that id, and the page will be using a block with completely unwanted content!

Blocks that are organized using the Context module rather than Panels have the same problem, I think.

I'm looking for a module or an approach that lets me reserve a space for content. I don't want that content to be kept in code (my feature) at all, but I do want the feature to know that my panel or context has a space reserved for that content. Modifying the content shouldn't cause the feature to show up as overridden.

Is there an existing module that allows for this functionality? If not, which module developers should I contact in order to get this sort of thing implemented? Or will a whole new module need to be created for this?

Maybe I'm misunderstanding the current behavior of these modules, even. Any help would be appreciated.

By the way, I don't think this is a problem that's specific to one version of Drupal, but if you have to pick a Drupal version to talk about, I'd say 7.


texts: Front page works; the rest returns "URL not found"

texts:
I have been trying to migrate a Drupal site to do some development locally. After moving the code, restoring the DB and doing some settings, I got the front page of the site to show up (minus some images). However, when I click on any of the menu links, I get the following error:

  Not Found

  The requested URL was not found on this server.

Now, I made sure that my base_url is set properly in settings.php. No trailing slash and all that. Currently it is of the type: http://example.com/drupal_directory, where drupal_directory is the directory with the site within Apache's /html folder.

What can I do to fix this? Is there some kind of a setting I am missing? There are no errors in PHP error log.


texts: Drush cron - how to provide the actual task

texts:
Based on this documentation the drush cron can be set up as

10 * * * * /usr/bin/env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
COLUMNS=72 /usr/local/drush/drush --root=/path/to/your/drupalroot
--uri=your.drupalsite.org --quiet cron

Where is the actual task being set here? I would like to invoke a certain url on each cron run. How do I provide that url to be ran in this cron or invoke a function using this drush cron.
Thanks.


texts: Omega and Panels: Is there a way to change "Omega XX column grid" layouts?

texts:
I´m trying to work with the 3.x Omega version and Panels.
I´ve selected "Omega 16 column grid" at the panel´s layout category.
Is there a way to change those layouts?

ie. There´s this "Two Column 8-8" and I need "Two Column 9-7"
I´ve tried with "create custom layout", but can´t make that work.

Thanks for your help!


texts:
I'm trying to re-create a field in my custom form with a date-picker. A dpm of my already existing form learned me the form looks like this:

Is it correctly to assume you can create the field with following code? Because I get an empty result...

$form['my_field_field_periods'] = array(
    '#title' => t('Periode 1'),
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'field-type-datetime', 'field-name-field-periods','field-widget-date-popup')
    ),
    - and so on -
  );


texts:
I want to remove post featured image from http://bit.ly/XkE8vG.
I have tried a lot by looking in to theme files but couldn't find any way.


texts: How do I show a Drupal 8 contact form on a page?

texts: I've created a new content type called "Form Page", with a required field being a reference to a contact form. So on the page you would have a body, and under that the contact form itself. I can't seem to figure out how to display the form on the page. I either get a link, or the system name of the contact form printed out. How would I go about this?


texts: How to show comments for an unpublished node

texts:
this is my problem,

A node is in unpublished state
The "View own unpublished content" permission is set
The node author posted a comment on the node, but the comment is not getting rendered in the node page
The super admin user though can see the comment.

Is this normal in Drupal 7? If so, how can I make those comments visible for the node author?

Hope I can explain my problem, thanks...


texts:
I have a "Document" media bundle, and I have a custom view mode called "Embed".

In that view mode, I have removed everything except the media name property and my document file field.

For media name the only format available is plain text, with an option to "Link to Media". This provides a link like media/2, where you can click on a link to download the file.

For my document field, I get Generic file (the file name with a link to it), RSS enclosure, Table of files, and URL to file.

Does anyone have a simple way to generate a link like Generic file but show the media name instead of the file name? e.g. Handbook vs handbook__2017_fin_updated_some_other_rubish_26.pdf


texts: How to print particular referenced paragraphs in twig?

texts:
I have a content type (say "Ranking") with following fields:

field_paragraph can reference any number of different paragraphs created with the Paragraphs Module:

So when I print

{{ content.field_paragraph }}

in a template for this node (say node--ranking--full.html.twig), Drupal renders it starting from field.html.twig and iterating

  for item in items

over every referenced paragraph and their twigs.

But I need to print a single referenced paragraph (like sub_ranking) somewhere else in my node--ranking--full.html.twig.

Searching through answers to similiar questions and trying to understand anything from kint() I have already produced some crazy variations, none of which worked:

{{ content.field_paragraph.entity.field_sub_ranking.value }}
{{ content.field_paragraph.0.entity.field_sub_ranking.0.value }}
{{ content.field_paragraph.0.entity.sub_ranking.0.value }}
{{ content.field_paragraph[0]['#node'].field_sub_ranking.0.value }}
{{ content.field_paragraph[0]['#node'].field_sub_ranking.value }}
{{ content.field_paragraph.0.entity.field_paragraph.0.entity.sub_ranking.0.value }}
{{ content.field_paragraph.0.entity.field_paragraph.0.entity.field_sub_ranking.0.value }}

How can I render my referenced sub_ranking in my node template?


texts: there is no edit option on certain views of drupal site

texts: There are certain blocks/views in drupal site where edit option is not coming and i am unable to figure out how to change them.


texts: Is there a Rules Action to set an entity reference field to null / empty?

texts:
Is there any rules action you can use to set an entity reference field to null or empty?

Thanks very much and have a great day.


texts:
I have an e-commerce site with drupal commerce kickstart and I added an additional field called "list price" and setted it as Price field (the same type of the default price).

Now I'm trying to update some of these prices via drupal views and VBO but I can't set them to NULL, I have an error:
"Integrity constraint violation: 1048 Column 'field_list_price_amount' cannot be null"

But if I change that price manually via the standard windows and leaving the field empty, drupal accepts the update, why?!

Via VBO I can update normal prices (increase, decrease and more other things) but I can't reset them to its default values...


texts: I don't know if I am asking this question correctly or if it has already been asked elsewhere, but I thought it couldn't hurt to ask. Would it be possible to add the panelizer page manager to a custom form? Basically the node would be created firstnode_save($node), then loaded node_load($node), and then the layout change would occur through a user's selection in page manager. See image below for an idea of what I am referring to. Any help would be much appreciated! Thanks!


texts:
I've been trying to set up some Drush aliases. However, when I try to run any command, it will echo the contents of all aliases files, and drush sa simply returns the contents of those files twice, and then the @none, @self and @default aliases (since I'm in the folder of a Drupal installation). When trying to run any command with an alias, e.g. drush @local status, I once again get a dump of those files, and finally a Could not find the alias @local error.

I've tried putting the aliases in ~/.drush/aliases.drushrc.php and in ~/.drush/local.aliases.drushrc.php. In the latter case, I tried two formats:

$aliases['local'] = array(
    'root' => '/home/user/subdomain/public_html',
    'uri' => 'subdomain.domain.com'
);

and

@code
    $options['uri'] = 'subdomain.domain.com';
    $options['root'] = '/home/user/subdomain/public_html';
@endcode

both without any different effect, apart from different contents being dumped. No other errors are thrown, it seems. I've also done a drush cache-clear all after each attempt.

Any thoughts as to what might cause this?


texts: How do I redirect a domain but keep the URL structure?

texts:
I have example.com and example.co.uk. They both point to the same Drupal installation on my server, so both domains load the exact same site.
I am now trying to redirect the .co.uk to the .com domain. I have tried using the following lines in the .htaccess file, but it always redirects to /index.php.
RewriteCond %{HTTP_HOST} ^example.co.uk
RewriteRule ^(.*) https://example.com/$1 [P]

The following lines didn't work either.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.co.uk$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]

The site redirects. but it doesn't keep the URL structure as it should. If I go to example.co.uk, I get redirected to example.com. If I go to example.co.uk/node/1, I get redirect to example.com/index.
How can I set up the correct redirect?


texts: How do I redirect a user basing on its roles?

texts:
I'm having an issue with writing a redirect based on whether or not the current user's role matches the one listed or not

I've been trying to find solutions related to getting the current path for Drupal 8. I'm not sure if that is one of the issues or not.

class FacultyStaffRedirectSubscriber implements EventSubscriberInterface {

  public function checkForRedirection(GetResponseEvent $event) {
    $request = \Drupal::request();
    $requestUrl = \Drupal::service('path.current')->getPath();
    $current_user = \Drupal::currentUser();
    $roles = $current_user->getRoles();

    if ($requestUrl == '/faculty-staff') {
        if (
          !in_array('faculty', $roles) ||
          !in_array('staff', $roles)
        ) {

            $path =  '/404';
        $response = new RedirectResponse($path);
        $response->send();
        return;
            }
    }
  }
 public static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = array('checkForRedirection');
    return $events;
  }

}

What I'm wanting is to redirect a user to 404 if they attempt to access the path without having the proper role assigned to them. Currently, nothing happens at all and logged in users can see the page.


texts:
I would like to have a block (panel pane) that shows up for administrators, showing a summary of the panel being used and its settings. I couldnt find a module that does this, but I may have overlooked one. Because of the many panels I use in the website, I need the admin to see info about the panel name, link to edit the panel, and other settings.
I currently insert manually a custom pane with the info, but would like this be be shown automatically.


texts: What is the correct way for adding Language Switcher (Dropdown) or links on the admin toolbar menu from my custom module or from a contributed module?


texts: How do I use entity_metadata_wrapper to create a node and at the same time multiple node references?

texts:
I have an XML response from a REST api call that returns an object with an array of sub-objects contained in it.

I need to create a node with all the properties of the top level object and node references to nodes created from the sub-objects. I probably will make them nodes but I would prefer to use the Entity API instead of the Node API even if they are nodes.

<toplevel>
  <prop1></prop1>
  <prop2></prop2>
  <array_of_sub_objects>
    <sub1>
      <sub_prop1></sub_prop1>
      <sub_prop2></sub_prop2>
      <sub_prop3></sub_prop3>
    </sub1>
    <sub2>
      <sub_prop1></sub_prop1>
      <sub_prop2></sub_prop2>
      <sub_prop3></sub_prop3>
    </sub2>
  <array_of_sub_objects>
</toplevel>

Here is an example of 3 objects with 2 contained inside the 1. I need to create 3 nodes or entities with an entity reference of the 2 sub-objects to the toplevel object. How do I use the Entity API to programmatically do this?


texts: Cannot log in to drupal admin in a new installation (access denied)

texts:
I've just made a Drupal 7 installation on localhost with XAMPP. I created an SQL database and did the installation without any error.

However, when I try to login on Drupal admin from localhost/mytest?q=user, I get an error like "Access denied. You are not authorized to access this page".

I tried to change the password on PhpMyAdmin manually, but I still have this error. I don't have any other drupal installation on my laptop.

These are the latest lines on logs.txt in logs file:

[Thu Mar 05 17:43:11.022491 2015] [mpm_prefork:notice] [pid 4801] AH00169: caught SIGTERM, shutting down
[Thu Mar 05 17:43:15.000852 2015] [ssl:warn] [pid 5867] AH01906: www.example.com:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Thu Mar 05 17:43:15.001021 2015] [ssl:warn] [pid 5867] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Thu Mar 05 17:43:15.001398 2015] [suexec:notice] [pid 5867] AH01232: suEXEC mechanism enabled (wrapper: /opt/lampp/bin/suexec)
[Thu Mar 05 17:43:15.052113 2015] [auth_digest:notice] [pid 5868] AH01757: generating secret for digest authentication ...
[Thu Mar 05 17:43:16.002626 2015] [ssl:warn] [pid 5868] AH01906: www.example.com:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Thu Mar 05 17:43:16.002750 2015] [ssl:warn] [pid 5868] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Thu Mar 05 17:43:16.003085 2015] [lbmethod_heartbeat:notice] [pid 5868] AH02282: No slotmem from mod_heartmonitor
[Thu Mar 05 17:43:16.015087 2015] [mpm_prefork:notice] [pid 5868] AH00163: Apache/2.4.10 (Unix) OpenSSL/1.0.1j PHP/5.6.3 mod_perl/2.0.8-dev Perl/v5.16.3 configured -- resuming normal operations
[Thu Mar 05 17:43:16.015126 2015] [core:notice] [pid 5868] AH00094: Command line: '/opt/lampp/bin/httpd -E /opt/lampp/logs/error_log -D SSL -D PHP'
sh: 1: -t: not found


texts: How to display one of the fields once in drupal views?

texts:
I have created a gallery view using nid as contextual filter, all images have the same album title. I need to output the album title field once. How can this be done?

I'm using views 3.


texts: Change Log in or register to post comments for content type

texts:
We are using the comments for a particular content type to post reviews for that content type. I have searched the web but can't find a proper solution how to change the text

"Log in or Register to post comments" to something like "Log in or Register to add Review"

only for this one content type. Any suggestions how this can be done, also happy if I can figure out how to hide this for this content type.

I don't believe I can alter comment_links() via template file or custom module (in drupal 7)

Thanks


texts: Active menu trail for multiple menu item with the same path

texts:
It is possible to have menu items that point to the same node and have the active state dynamic?

If I click the link 'List item A1' I would like to become active the link 'List item A'.

If I click the link 'List item B1' I would like to become active the link 'List item B'.

 - List item A (node/1)
 --  List item A1 (node/2)

 - List item B (node/3)
 --  List item B1 (node/2)


texts: How to create user programatically if not exist?

texts:
I am using this code to create user.

  if(user_validate_name('czxc') != ""){
        $user = User::create([
                'name' =>'czxc',
                'mail' => 'user@gmail.comgczxcdfa',
                'pass' => 'password',
                'status' => 1
             ]);
            $user->save();
            drupal_set_message($user->id());

    }else{
        drupal_set_message('Already exist user');
    }
   This code works only one time for me.


texts: Where to export i18n mode for menus in features?

texts:
I'm using a combination of Entity Translation and Node Translation for a site and when I go and set up the menu, I need to edit each menu and select Translate and Localize.

Where is the feature to export this?


texts: How do I verify emails on a contact form?

texts:
I want to implement a functionality where anonymous users can contact node authors. I have created a contact form with email field for each node. I would like to send an email verification link to the email address for email ownership confirmation. The form submit should be complete only when that happens.
What would be the best approach to handle this? There is a module in drupal 7 which could work but I didn't come across anything for D8. Will appreciate any help with this.


texts: Displaying the username of the user who created the node in the node template file

texts:
I created file node--my_content_type.tpl.php, where I'd like to print the username as string. I tried the following code, but unfortunately it doesn't work. How can I do it?

<?php
  print $name;
?>


texts: Drupal 7 - Add two menu items with the same path but different query string

texts:
On Drupal 7, there is a difficulty adding two or more items to a menu which are having the same URL but a different query string.

For example, when I add two similar paths:

node/add/alert?kind=regular
node/add/alert?kind=news

Only one of the links is randomly displayed. So frustrating...

Any ideas of how to by bypass this issue?


texts: What is the difference between State API vs UserData API?

texts:
In which case we will use State API ? Instead of UserData API ?

Some Use cases where we will use State API ?

Some use cases where we will UserData API?

Is there any difference apart from the following?

Information stored is not configuration that should be exported.

Real world examples for both. Is any popular contrib or core modules using this concepts(except user module) ?


texts: Making fields, condition and join dynamic in db_select query

texts:
What is the Drupal way of creating queries which are dynamic in nature ?
What I mean is for example- In my module I am asking the user to select some content types and the fields associated with each of them. If node type "article" is present the user can select it and also select some fields lets say- field3, field4 - out of all the fields present field1-10. This custom selection is then stored in a table lets say "custom_table"

How can i create queries of the form-
db_select('node','n')
->fields('n','field3','field4') //fields are dynamic based on user's choice stored in custom_table
->condition('n.node-type', 'article') //node type is dynamic based on user's choice stored in custom_table
->join with fields table to get field value //only for value fields

I really dont want to use php string handling and create a "select from node..." type string while looping over values in custom_table.

Is there a less time and space complex drupal way to achieve this ?


texts:
I have a node form in a block, that is submitted using AJAX.

I've created my own callback, because I'm adding the created node to the page if the submission was successful.

Now, I want to reset the node form to the default values. Any ideas on how to accomplish that?

Update:
I've managed to replace the form, by looking at the way node_add() works.

$new_node = (object) array(
  'uid' => $user->uid,
  'name' => (isset($user->name) ? $user->name : ''),
  'type' => 'node_type',
  'language' => LANGUAGE_NONE,
);

And then, I'm replacing the entire form with the return value from drupal_render(drupal_get_form('node_form', $new_node));

The form gets replaced as it should be, apart from some ids being different. However, when I submit the new form, I'll get a javascript alert window, with the entire contents of a new page. I can see from the HTML, that it's the page for the node that has been created. I suppose the AJAX callback gets redirected to the new node, but I don't know why.

Any clues?


texts: How to give the user the option to make updates to or delete a node with a unique field without showing the administrative toolbar?

texts:
I'm fairly new to Drupal and am working on a Drupal 7 site for an internship. I've created a custom content type for links to be in an A-Z link directory where both authenticated users and administrators have the permission of adding, editing, or deleting their own content. I've used the Unique Fields module to prevent nodes with the same URL from being created. I am also implementing the Workflow module to make sure an administrator oversees authenticated user's actions.

Here's the functionality I want:

Ideally, an authenticated user would be brought to a form giving them the options to add, edit, or delete a node. Is there a form module I can use to make this form self-containing, or would I have to link to corresponding pages (add content page for add, etc.)? I'd also like to implement a check in real-time on the unique field should the user choose to add a node. Again, the authenticated users are not going to have access to the administrative toolbar.

Any help is greatly appreciated.


texts: Using Drupal.settings.basePath in Modernizer / yepnope.js loads

texts:
I am currently starting development of drupal sites on Acquia. Using git and working locally is a new workflow for me. When building locally and trying to utilize  Modernizr load / yepnope, my JS in my script.js file typically looks like this..

Modernizr.load([
    {
    test: Modernizr.mq('only all'),
    nope: '/sitename/docroot/sites/all/themes/theme/js/libs/polyfill.js'
    },
    ....

So that works locally on my machine, but when I commit my changes and push to my acquia development server the file path for the loaded scripts is incorrect, since it's not the same setup I guess.

http://mysite.devcloud.acquia-sites.com/mysite/docroot/sites/all/themes/theme/js/libs/polyfill.js

It needs to be the below, without the mysite/docroot in the URL.

http://mysite.devcloud.acquia-sites.com/sites/all/themes/theme/js/libs/polyfill.js

So that brings me to Drupal.settings.basePath. If I print this out it gives me /mysite/docroot/ on my local setup. If I do it on the dev server, it would print out something different (probably just / ).

So me being the amateur assumed I could do something like this.. (forgive the poor sample, I know it can be done better)

var myroot = Drupal.settings.basePath

Modernizr.load([
{
test: Modernizr.mq('only all'),
nope: myroot + 'sites/all/themes/theme/js/libs/polyfill.js'
},
....

And this of course does not work. Just returns query1 is not defined.

So I am sure there are faults in many of my attempts to make this work.. so if anyone can suggest something to me, either workflow related or how to fix my setup / code, that would be great.

Thanks


texts: Inserting a select box before the search box (Drupal 7)

texts:
I am pretty new to Drupal dev world. I wanted to know how to insert a select box before the search box. I used the below code to alter the search form and set the #weight to a higher value but the select box still shows up after the search box.

function mymodule_form_search_block_form_alter(&$form, &$form_state) {
  $form['my_field']= array(
    '#type' => 'select',
    '#title' => t('whatever'),
    '#options' => array(
      0 => 'option1',
      1 => 'option2',
    ),
    '#default_value' => 255,
    '#weight' => 10,
  );
}


texts:
I want to add a Login link in the user menu. When I give it the path 'user/login', I get the message:
The path 'user/login' is either invalid or you do not have access to it.

If I give it a path of 'user', it works.  However, that's not the path I want, because it will still be visible to the logged-in user.

If I give it a full path, http://mysite.com/user/login, it works BUT isn't hidden from the logged-in user.  Puzzling.

Any ideas?  I am pretty sure I could use a module to handle this, but it seems like overkill.


texts: how to add the value of a (list text) field as a class

texts:
I have a CT on which I have a field called monetary-type which is of type List (text) and its "Allowed values list" is:

EUR|Euros
USD|Dollars
GBP|Pounds

When this field is rendered from a view (FORMAT: Show: Fields) it's being rendered as:

  Dollars

When rendered from a node view it shows as:

  Dollars

For both those 2 cases I'd like to also have a class with the selected value, in this case value-USD, appended into the classnames of the wrapper.

What is the easiest (non intrusive) way I can achieve this? Ideally without having to touch existing views or node displays.

I use https://www.drupal.org/project/zurb_foundation if it matters.


texts:
In D7, it seems the token for fields (e.g., [node:field_date]) just returns the rendering of the field. So if the field is multi-valued, this token returns all the values rendered together. However, I'd like to be able to access specific delta values of the field separately using tokens, e.g. using [node:field_date:0] or similar syntax. I also want to be able to chain the token, e.g. [node:field_date:0:long].

Has this been done before? My solution would be to use hook_token_info_alter to mark the field's token as dynamic, then do my own parsing in hook_tokens_alter. But if I do this, will I lose the ability to chain the token?


texts: I am using Apache Solr Search on my site, and would like links on the search results page to open in a new window/tab.  How can I accomplish this?


texts: remove email field from registration form

texts:
From core\modules\user\src\AccountForm.php, user module developer added following comment to Email fields.

 // **The mail field is NOT required if account originally had no mail set**
    // and the user performing the edit has 'administer users' permission.
    // This allows users without email address to be edited and deleted.
    // Also see \Drupal\user\Plugin\Validation\Constraint\UserMailRequired.

    $form['account']['mail'] = array(
      '#type' => 'email',
      '#title' => $this->t('Email address'),
      '#description' => $this->t('A valid email address. All emails from the system will be sent to this address. The email address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by email.'),
      '#required' => !(!$account->getEmail() && $user->hasPermission('administer users')),
      '#default_value' => (!$register ? $account->getEmail() : ''),
    );

I do not understand what is "originally had no mail set" mean.
it looks like , there is a config option which can turn off Email requirement, but I am unable to find the config option.


texts: Example Hook form validate, get all node information after save news field

texts:
In a custom module, I do some operations on several content node (add field_collections and save)
After that, I need to get all field_collections of my content nodes.
But when I get, I have the old field_collections and not the new field_collections I just save.

Exemple :

//I have this node in my submit hook
node0
    ->field0
    ->filed1

//I save a new field (via entity_metadata_wrapper and save() ), and I get this node after
//I Have
node0
    ->field0
    ->filed1

//But I would like have
node0
    ->field0
    ->filed1
    ->field2 //the new field I just save

Are there a Hook I can use after a validate form ? But I would like keep the information about who nodes has been save...for get only them
Or an other way I don't know ?

I don't think I can clear the cache because my operations "save" and after "get" are in a heavy foreach


texts: CommerceKickstart; Slideshow content/pages disappear if I add a Product Reference field under Slideshow Content Type

texts:
I am trying to add the "Add to Cart" button into a Slideshow. The problem is as soon as i add a Product Reference field under the Slideshow Content Type, if i than go to Content>Manage Content the Slideshow Content Type/pages are no longer visible.
At this point to add a new slideshow image/content i have to go to Products>Add a Product.
Somethings not functioning right.
Im pretty sure theres something that im doing wrong but i cant figure it out....


texts: How can I sort Labels in config entity list builder?

texts:
I have a very simple config entity with a few fields. In the list builder I want to sort the label field by creation date rather than by alphabetical order.

I originally thought this should be fairly easy, but it's proving way more difficult than I expected.

Can anybody point me in the right direction?


texts: Multiple/Bulk Image Upload Tutorial? Plupload etc

texts:
I want my users to be able to upload multiple images at once. They need to be able to upload 60 images for one gallery and doing that one at a time is just not feasible. I've been reading other posts here and doing a ton of searches. I'm told that using the Media module and plupload (I have the javascript library and the drupal integration module installed) that I can do it, but I can't figure out how to actually make it work.

Would anyone be willing to explain it below? I've seen at least one video on youtube that shows the person clicking the Select Media button which pops up a little window, and that window has a drag and drop plupload area where they drop their images. I don't see anything like that.


texts: FacebookforDrupal Publish to stream isnt working?

texts:
I am trying to publish a node onto facebook. Below is my code. In hook_nodeapi(), I have placed a dpm("test") but it isnt showing. I am assuming that this function is not called at all?

function fb_stream_ext_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  dpm("test");
  if ($op == 'insert' || $op == 'update') {
    if (isset($node->stream_publish) && $node->stream_publish) {
      $attachment = array(
        'name' => $node->title,
        'href' => url('node/' . $node->nid, array('absolute' => TRUE)),
        'description' => filter_xss($node->teaser, array()),
      );

      /*
        if ($picture = $GLOBALS['user']->picture) {
        $url = url($picture, array('absolute' => TRUE));
        $attachment['media'][] = array(
        'type' => 'image',
        'src' => $url,
        'href' => $url,
        );
        }
      */
      if ($logo_path = theme_get_setting('logo_path')) {
        $url = url($logo_path, array('absolute' => TRUE));
        //dpm($logo_path, "logo_path is $logo_path and url is $url");
        $attachment['media'][] = array(
          'type' => 'image',
          'src' => $url,
          'href' => $url,
        );
      }

      $user_message = t('Check out my latest post on !site...',
                        array('!site' => variable_get('site_name', t('my Drupal for Facebook powered site'))));
      $actions = array();
      $actions[] = array(
        'text' => t('Read More'),
        'href' => url('node/' . $node->nid, array('absolute' => TRUE)),
      );
      fb_stream_publish_dialog(array('message' => $user_message,
                                     'attachment' => $attachment,
                                     'action_links' => $actions,
                               ));
    }
  }

  // Another way to add like button, as part of a node.
  if ($op == 'view' && variable_get('fb_stream_ext_nodeapi_add_like', FALSE)) {
    $url = fb_scrub_urls(url('node/' . $node->nid, array('absolute' => TRUE)));
    $node->content['dff_like'] = array(
      '#value' => "<fb:like href={$url}></fb:like>",
      '#type' => 'markup',
      '#prefix' => '
',
      '#suffix' => '
',
    );
  }
}

Any known solution for this?


texts:
I keep getting a cache related error.

  PDOException: SQLSTATE[HY000]: General error: 1030 Got error -1 from storage engine: TRUNCATE {cache} ; Array ( ) in cache_clear_all() (line 165 of C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\projects\web2\includes\cache.inc).

The issue is tied to the query file. The fix is to replace TRUNCATE with DELETE FROM in a query.inc file. That's all fine and dandy, and that error is gone. But, now I have a new one: The site is completely broken and thinks that the cache database folder still exists, which prevents me from importing the backup database, even if I drop the whole database.
In short: Backups are useless, as this error seems to do some heavy damage. As well, it shuts down the EasyPHP server.

To make things even worse, I was going over the huge site-crashing error report I just got, and it looks like the fix doesn't even work.

In regards with the above, I think it worked, but something else tied in with it is causing more cache errors.

  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'webone.cache_views_data' doesn't exist: DELETE FROM {cache_views_data} ; Array ( ) in cache_clear_all() (line 165 of C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\webONE\includes\cache.inc).

I applied the fix I first mention to a new website, as a preventative this time. Low and behold, it came back on the first module install.


texts:
I have one type of custom node called "Concerts", and another type called "Conductors".  I would like to add a field to Concerts indicating which conductor led the concert.  However, the field types I can select from are just the basic things like Date, Float, Integer, Text, etc. - nothing about references to other nodes.

The reason this would be nice is that I assume it would let me generate content like "also led by this conductor" on the concert pages, and "concerts by this conductor" on the conductor pages.

Is this something I can accomplish with a Module?  I haven't found one yet that seems to fit the bill.


texts:
I've an entity called "guy" with a field "location" and i've 9-10.000 location that i want to reference. I must use a simple list (1|bla, 2|blabla) or an entity reference field that target the location entity? I need the autocomplete function but drupal is very slow with a great number of location. But i don't know if i can load a list of 9-10k lines.
I don't wont to use taxonomy.
To speed up the autocomplete, how i can create a list of frequently selected location?


texts: How to create dynamic select list in form using FAPI

texts:
I am using Drupal 7. I have created two form (FAPI) fields of type select , State and District.
The district field should contain the dynamic options based on the state selected.

State field:

 $form['state'] = array(
  '#title' => t('Name of your State:') ,
  '#type' => 'select',
  '#default_value' => array(
  ),
  '#options' => $options,
  '#required' => '1',
  );

District field:

 $form['district'] = array(
  '#title' => t('Name of your District:') ,
  '#type' => 'select',
  '#default_value' => array(
  ),
  '#options' => district_list($form_state['values']['state']), // district_list is the function which will return the list of district based on name of state passed.
  '#required' => '1',
  );

The above code doesn't work, is there anything I am missing ?


texts: Which type to use for checkbox fields in hook_field_schema?

texts:
Task:

Create a custom field which contains a single checkbox by implementing hook_field_schema etc.

Question:

Which data type is (or should) be used to define the corresponding database column to save checkbox values?

Sample code:

function field_test_field_schema ($field)
{
    $columns = array();
    switch ($field['type']) {
        case 'test':
            $columns = array(
                    'value' => array(
                            'type' => '???',
                            'not null' => TRUE
                    ),
            );
            break;
    }
    return array('columns'=> $columns);
}

Update:
node_schema uses int for boolean columns. e.g. :

'status' => array(
  'description' => 'Boolean indicating whether the node is published (visible to non-administrators).',
  'type' => 'int',
  'not null' => TRUE,
  'default' => 1,
)


texts:
After clicking Continue @ /update.php, we receive:

Fatal error: Cannot redeclare uc_order_views_data() (previously
declared in
/home/user/public_html/sites/all/modules/ubercart/uc_order/views/uc_order.views.inc:13) in
/home/user/public_html/sites/all/modules/contrib/ubercart/uc_order/views/uc_order.views.inc
on line 708

When I remove either version of the ubercart directories, the /update.php process complains that the directory is missing.
I can't see a double-up of modules in /admin/modules
The two ubercart directories both contain the same subfolders.
I did not develop the website, but took over maintenance of it.


texts: How to make friends ajax with dynamically created links?

texts:
I created leaflet map, when you hover the marker in popup window is a reference to the content.

I wrote module that loads ajax content in the custom region. For dynamic links added class use-ajax, but Drupal does not process them as I needed.
I check and found that static links with class use-ajax have additional class ajax-processing.
My dynamic link looks like:

засорение реки

Static link looks like:

node

As I understand Ajax Drupal does not work with dynamic links.
I found issue in what asks in what need to change the href attribute of a link and make the ajax call to the new url.  Change 'href' attribute in AJAX enabled links
Wrote JS code but it doesn't work for me.

(function ($) {
  Drupal.behaviors.test_module = {
    attach: function (context, settings) {
        $("#jslink").click(function(){
            var href = $("#jslink").attr("href");
            Drupal.ajax['jslink'].options.url = href;

        });
    }
  };
})(jQuery);

Is it possible to somehow make Drupal to work with dynamic links?
What am I doing wrong?


texts: drush sql-sync doesnt extract gzipped sql

texts:
I run the following command from a script:

drush -v sql-sync @tmp.stage @tmp.coe | tee ./sql-sync.log

My @tmp.stage server is Drush 7.0 and @tmp.coe servers is Drush 6.2.0

An SQL dumpfile is created locally rsynced to the destination server and attempted to be imported by mysql without first uncompressing. Is there a workaround? The source and destination servers have gzip installed.

Log Output

You will destroy data in server1/tmp and replace with data from 2016_tmp_mirror.
Do you really want to continue? (y/n): Include /var/www/2016/tmp/vendor/drush/     [notice]

Executing: mysql --defaults-extra-file=/tmp/drush_jUBS0A --database=2016_tmp_mirror --host=localhost --silent  < /tmp/drush_H19MvV
Calling system(mysqldump --defaults-extra-file=/tmp/drush_QRO7xg  2016_tmp_mirror --host=localhost --no-autocommit --single-transaction --opt -Q  | gzip -f > /home/dgurba/drush-backups/2016_tmp_mirror/20160407200242/2016_tmp_mirror_20160407_200242.sql.gz);
Include /var/www/2016/tmp/vendor/drush/         [notice]
You will destroy data from webuser@server1:/tmp/2016_tmp_mirror_20160407_200242.sql.gz and replace with data from /home/dgurba/drush-backups/2016_tmp_mirror/20160407200242/2016_tmp_mirror_20160407_200242.sql.gz
Do you really want to continue? (y/n): y
Calling system(rsync -e 'ssh -T' -akzv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --include="sites/mysite.foo.com/" --include="sites/all" --exclude="sites/*" --stats --progress --remove-source-files /home/dgurba/drush-backups/2016_tmp_mirror/20160407200242/2016_tmp_mirror_20160407_200242.sql.gz webuser@server1:/tmp/2016_tmp_mirror_20160407_200242.sql.gz);
sending incremental file list
2016_tmp_mirror_20160407_200242.sql.gz

         32,768   1%    0.00kB/s    0:00:00
      2,591,074 100%   26.52MB/s    0:00:00 (xfr#1, to-chk=0/1)
Number of files: 1 (reg: 1)
Number of created files: 1 (reg: 1)
Number of regular files transferred: 1
Total file size: 2,591,074 bytes
Total transferred file size: 2,591,074 bytes
Literal data: 2,591,074 bytes
Matched data: 0 bytes
File list size: 0
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 2,584,839
Total bytes received: 42

sent 2,584,839 bytes  received 42 bytes  469,978.36 bytes/sec
total size is 2,591,074  speedup is 1.00
Calling system(mysql --database=bar --host=localhost --user=foo --password='*****'  < /tmp/2016_tmp_mirror_20160407_200242.sql.gz);
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\8B


texts:
Below code changes the all quantity label to none. i am trying to change quantity field label for specific views block for ubercart3. (so in product node, quantity labeled as quantity and in product views block, quantity field is not labeled.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if(strpos($form_id, 'uc_product_add_to_cart') !== FALSE){
    $form['qty']['#title'] = t('');
  }
}

How to call specific views from module? or is this something i should do in views template?
i tried the below code and qty label doesn't change.

if(strpos($form_id, 'uc_product_add_to_cart') !== FALSE){
  $view = $form_state['view'];
  if ($view->name == 'my_view_machine_name') {
    $form['qty']['#title'] = t('');
  }
}


texts: How to set a default date when extending DateRangeItem FieldType plugin

texts:
I created a new field type plugin that extends DateRangeItem. My plugin only adds some more settings. I also created an own widget that extends DateRangeWidgetBase. My formElement function looks like this:

public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
  $element = parent::formElement($items, $delta, $element, $form, $form_state);
  $time_type = 'time';
  $time_format = $this->dateStorage->load('html_time')->getPattern();

  $element['value'] += [
    '#date_date_format' => 'none',
    '#date_date_element' => 'none',
    '#date_date_callbacks' => [],
    '#date_time_format' => $time_format,
    '#date_time_element' => $time_type,
    '#date_time_callbacks' => [],
    '#default_value' => $this->createDefaultValue($items[$delta]->start_date, $element['value']['#date_timezone'])
  ];

  ...
}

protected function createDefaultValue($date, $timezone) {
  $date = parent::createDefaultValue($date, $timezone);
  $date->setDate(2018, 01, 01);
  return $date;
}

I only want the user to be able to enter a time value, but no date value. This works.

My problem is that when saving the field value it is always stored with the date of the current day - this seems to be the default value. (The time is set correctly according to what the user enters). I want to set a different fixed date instead.

So I'm overwriting createDefaultValue as shown above, but without any effect.

If I comment out the two lines

//'#date_date_format' => 'none',
//'#date_date_element' => 'none',

my new default value is shown and also saved correctly. But if set the two lines to not show the date, my default value is ignored.

How can I set a default value and not show the date (only time)?


texts: Need to override block.tpl.php in a module

texts:
I need to define a block--custom.tpl.php file in a custom module and have that override the theme block.tpl.php.

Here is where I have ended up and it's not working.

Tell Drupal to look in my module:

function MODULE_theme_registry_alter(&$theme_registry) {
  $theme_registry['block']['theme paths'][] = drupal_get_path('module', 'MODULE');
  $theme_registry['block']['theme paths'][] = drupal_get_path('module', 'MODULE') . '/theme';
}

In hook_preprocess_HOOK() suggest a new theme file:

function MODULE_preprocess_block(&$variables) {
  $block = $variables['block'];

  if ($block->CONDITION) {
    $variables['theme_hook_suggestions'][] = 'block__MODULE';
  }
}

Now, I've created the file in the module's theme/ folder and called it block--MODULE.tpl.php.

I've turned on theme debugging in the settings file by un-commenting out $conf['theme_debug'] = TRUE;

Caches have been cleared multiple times. When I load the page I see in the debug comments:

<!-- THEME DEBUG -->
<!-- CALL: theme('block') -->
<!-- FILE NAME SUGGESTIONS:
   * block--MODULE.tpl.php
   * block--block--6.tpl.php
   * block--block.tpl.php
   * block--content.tpl.php
   x block.tpl.php
-->
<!-- BEGIN OUTPUT from 'sites/all/themes/THEME/templates/block.tpl.php' -->

And as you can see from the debug it is using the theme template file.

How do I get Drupal to select the proper theme file?


texts: Is it possible to have an entity with fields, which doesn't use bundles?

texts:
I have an entity (using entity API) for which I would like a fixed number of fields (and would prefer to use fields and the API rather than just creating properties) - it makes no sense to make a bundle - but do I need to create a bundle nonetheless to allow fields to be attached?

I'm thinking this is the case since field_attach_instance takes a 'bundle' value in the array to pass in (and field_config_instance contains the bundle column).


texts:
I want to display taxonomy term from it's id. I have the following code that get's me id of this term but I don't how to convert this id into term name to display it.

function menu_custom_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  dpm($items);
  $element = array();
  foreach ($items as $delta => $item) {
    $element[$delta] =  l(check_plain($item['target_id']));
    }
  return array(
    0 => array(
      '#markup' => theme('item_list', array('items' => $item)),
    ),
  );
  return theme('item_list', array());
}


texts: translate drupal commerce product titles in views

texts:
I have enabled the necessary i18n and l10n modules and I have been able to translate content without any trouble. I am now trying to translate some drupal commerce products. Using the title module I replaced the title of the product with a title field.

The product translations are showing correctly on the product display and cart pages but I also created a view with some products. For some reason the product title doesn't get translated in the view. The add to cart button does get translated however.

How can I get my products to show the correctly translated title in my view like they do on the product display page?


texts: Email notification based on purchased item

texts:
I am working on the magazine site using Ubercart. In this site individual magazines can be bought or subscribed to. When a new issue of a magazine which the customer has subscribed to is created, I need to send a notification to all the customers who have subscribed to that magazine.

Can I achieve this using the messaging and notification module? Is there any other way?


texts: Entity Update Failing: How can I clean this up?

texts:
I recently uninstalled a module and it left behind a bit of a mess in the database. Running drush entup lists a number of fields related to this module that need to be uninstalled across a few entity types.

This fails, though. In addition to these field definitions there are a number of other tables that didn't get removed.

How can I clean this up? I'm comfortable manipulating the database and I'm able to find the fields. I'm just unsure of how to clean it up to satisfy drush entup so it stops listing it as a pending action.

Edit-Including Error:

The following updates are pending:

node entity type :
  The Lingotek translation source field needs to be uninstalled.
  The Lingotek translation status field needs to be uninstalled.
menu_link_content entity type :
  The Lingotek document id field needs to be uninstalled.
  The Lingotek hash field needs to be uninstalled.
  The Lingotek profile field needs to be uninstalled.
  The Lingotek translation source field needs to be uninstalled.
  The Lingotek translation status field needs to be uninstalled.
  The Lingotek translation created time field needs to be uninstalled.
paragraph entity type :
  The Lingotek document id field needs to be uninstalled.
  The Lingotek hash field needs to be uninstalled.
  The Lingotek profile field needs to be uninstalled.
  The Lingotek translation source field needs to be uninstalled.
  The Lingotek translation status field needs to be uninstalled.
  The Translation changed time field needs to be uninstalled.
Do you wish to run all pending updates? (y/n): y
Drupal\Core\Entity\EntityStorageException: The field lingotek_translation_source has already been deleted and it is in the process of being purged. in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->onFieldStorageDefinitionDelete() (line 512 of           [error]
/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).
Failed: Drupal\Core\Entity\EntityStorageException: !message in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema-&gt;onFieldStorageDefinitionDelete() (line 512 of /docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).       [error]
Cache rebuild complete.                                                                                [ok]
Finished performing updates.


texts: Domain access: users of subdomain1 should not see users of subdomain2

texts:
I would like to restrict users and content to a certain sub domain. I am currently using Domain Access module and it's going quite well. The only problem is that I cannot figure out how to configure it so that a user that is assigned to domain1 cannot see1 users assigned to domain2.

Is this possible in Drupal 6, and how?

1 By 'see' I mean that they should be aware of their existence. They should not see them when using a user reference field, not when going to the user's profile URL etc, etc.


texts: how to override the timeline-twitter css

texts:
I embedded a feed from twitter into a block and I am trying to override the size of font by adding this to my css , but it still only picks up the css that is coming from twitter.  is there any way to override this on my drupal site without logging into their twitter page?

.timeline-Tweet-text {
       font-size: 18px; !important;
       line-height: 24px;
       font-weight: 300;
   }


texts: Is there an advantage to Featurizing a view, over using Views' export?

texts: I've created a View in Drupal 6 with Views 2. If I want to get this view from my dev site to production, is there a compelling advantage offered by using Features over using the built-in Views export?


texts: Using drush to change options of contrib module

texts:
I would like to use drush to change one of the options stored in a large options field of a contrib module configuration table.

drush vset/vget, as far as I know, only work on the options that are stored in the variables table.

Is there a way to do this using drush on the variable directly, short of retrieving the whole field (using drush sql-query), modifying it (using unix tools), and updating it (again, using drush sql-query)? It needs to be automated, as this is a frequent task.

Or can anybody suggest a different approach that is more elegant?


texts: "Cannot use string offset as an array" when attempting to run SOLR index

texts:
We recently moved our site over to Drupal 7. During development, we were able to index the site using Acquia search and the solr modules without issue. However, sometime between our last tests and our launch something went wrong and our index will now no longer run.

We receive the error: Fatal error: Cannot use string offset as an array in /var/www/[...]/public/profiles/acquia/modules/apachesolr/apachesolr.index.inc on line 853

Cron is not running on our site due to this error, and this is causing massive problems as emails and other notifications are not being sent. In addition, half our content has not been indexed so our search is basically useless.

I have tried the following to attempt to fix the issue with no avail:

Checked database field_body_value for any php code that may be causing problems, such as drupal_goto, etc.
Removed all pages that use the PHP filter except where absolutely necessary

Our site successfully indexed about 1200 nodes out of 2400, but it will progress no further. The error gives us absolutely no indication of which node it is stuck on so we can fix it!

Is there any way to determine which node was indexed last so we have a better idea of where the error exists, or does anyone else have any suggestions on how to repair this error?


texts: After installing and configuring simplesamlphp_auth module gives Error on clearing cache

texts:
I installed simplesamlphp_auth(8x-3.2) module with drupal (9.1.x). SimpleSAMLphp (1.18.8) is configured correctly. saml authentication works fine, but while clearing cache i am getting the below error.
Error: Call to undefined method Symfony\Component\DependencyInjection\Alias::setDeprecated() in Drupal\Core\DependencyInjection\YamlFileLoader->parseDefinition() (line 157 of /docroot/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php).
After spending few hours I found that drush is using Symfony\Component\DependencyInjection\Alias from SimpleSAMLphp instead of drupal.
Symfony DependencyInjection library is different between SimpleSAMLphp Library and Drupal. In Drupal Symfony\Component\DependencyInjection\Alias::setDeprecated method is available but not in SimpleSAMLphp. I did not find why all logged-in page namespaces other than Drupal* are taken from SimpleSAMLphp Library. SimpleSAMLphp Library folder is parallel to drupal docroot and it has its own composer.json.


texts: How can I tell if a config entity hasn’t been saved yet?


texts: Lightbox/colorbox slideshow and trigger thumbnails

texts:
I a have problem getting a slideshow and colorbox to play together.

How would you go if you wanted to:

have a set of images in a node (let's say it's a multi-value image field)
display just a single thumbnail as a colorbox trigger
open up a colorbox with a slideshow of all images in that field.

The thing I want to emphasize is the distinction between having a single thumbnail on a node display level, and the slideshow on a colorbox level. By saying 'colorbox' I mean not necessarily that particular plugin/module. I'm open to any working solution, however I must say I gave up Lightbox2 after I found it poorly configurable.


texts: I just learned about the creating fields and content types and had a quick question about the file field.  When you create a file field you can specify a relative path that the uploaded resource will be stored by entering a path in the "File Directory" text field, but what I am going to need is to have the value be different depending on the circumstances.  For example I might want to clump all of the files uploaded by a certain user so I might want the relative path to depend on the user's name.  Is there a way to specify this type of dynamic path?  Is the something people normally do?   Or would they just organize files based on type?


texts:
I use the Rules module. I want to add 1 to a CCK integer field on an action. Someone told me to create a custom token doing this addition.

So, I installed the tokenSTARTER module.

Now, how do I access the content profile (I load it in the rules chain) where the needed CCK field is in?


texts: How do I setup Drupal/Varnish caching so Content Editors don't see browser-cached pages after logging in?

texts:
I've got a bit of a situation going on with our caching solution and would love some input.

We use a solution of HAProxy -> Varnish -> Apache. HAProxy terminates SSL and sends that to Varnish which then requests from Apache if needed.

We are using Drupal 7, Purge, and Cache Expiration.  We have Cache Expiration set to use external expiration and include the baseurls.  Our sites have "Minimum cache lifetime" set to "none" and "Expiration of cached pages" set to "6h".

The Varnish cache always has the correct versions of the cached pages and those get expired correctly.

If an anonymous user visits a page, say node/123, and then logs in and subsequently navigates back to the same page the browser still serves the browser cached version of the page.  This is the expected behavior from Drupal as I would expect the page to stay cached for an anonymous user.

Our content editors are required to reload the page (F5) and think there is an "error" because they need to perform this in order to see the expected, authenticated, version of their page.

How do other administrators who allow editing on production instances tackle the issue?

I toyed around with the idea of shortening the cache lifetime that comes out of Varnish, but that feels like a band-aid (30s cache vs. 6h).  I also toyed with the idea of removing the cache headers coming out of Varnish, but allowing Varnish to hold the cache for its lifetime.

I'd like to be able to cache responses to keep the load off of our server if at all possible.

Thanks in advance!


texts: Creating a dynamic contextual filter list

texts:
I would like to make a grouping of articles based on the year and month.  In other words something like

April, 2013
March, 2013
February, 2013
January, 2013

Each would be a link to the articles section and provide a contextual filter (/articles/2013/1 for January 2013).

I've tried playing with the views module to create this view.  I selected only the posted date and then formatted it to show only the Month and Year.  Then I turned on aggregation to group the results together, but it appears aggregation is using the entire date (including the day).  I also tried grouping by the posted date in the table settings but there doesn't appear to be a way to rewrite the results of the group header.

Is there a way to do this with views or some other module?


texts:
I have a use case (in D8) where file and corresponding directory needs to be deleted from the file system. The standard mechanism suggested by Drupal is to mark file as temporary and let cron take care of deletion. This means, in my case, that I need to keep track of the file deletion and only then delete the corresponding directory, if it empty. This can be easily avoided by simply using file_delete().

Why is this method not recommended?

The standard cron based deferred deletion causes other side effects with file replacement, etc.


texts: Moving New Content from Local to Remote Prod Site

texts:
I have a local development Drupal site using WAMP to build. I moved it over to Bluehost successfully. But now I would like a process to regularly update my remote site with local changes I'm making. I know this is a common issue but I'm hoping an expert here could provide me with some best practices. I tried doing an update myself, these were my steps and the complications that arose. Failure is the best learning opportunity right?
I exported the db from both the local and remote mysql. Then I saved a copy of the remote 'sites' folder. Then I made sure to switch my settings.php file to use the remote db creds. Then I just moved the entire Sites folder from local to remote. That worked fine.
Moving the db was the challenge. Keep in mind there is nothing happening on the remote server yet because no one is using it, it's still in development. For now, I don't have to worry about syncing changes. So I tried just importing my local sql file...but got the following error:
-- -- Dumping data for table dr_accesslog -- INSERT INTO dr_accesslog (aid, sid, title, path, url, hostname, uid, timer, timestamp) VALUES (6707, 'P5lbV-jGxB54nNQw_zIkbYyHQK1OaWADg5Vy7yXqjT4', '', 'node', '', '98.207.254.151', 1, 193, 1421403472), (6708, 'P5lbV-jGxB54nNQw_zIkbYyHQK1OaWADg5Vy7yXqjT4', '', 'node', '', '98.207.254.151', 1, 194, 1421404545), (6709, 'P5lbV-jGxB54nNQw_zIkbYyHQK1OaWADg5Vy7yXqjT4', '', 'node', '', '98.207.254.151', 1, 196, 1421404551), (6710, 'P5lbV-jGxB54nNQw_zIkbYyHQK1OaWADg5Vy7yXqjT4', '', 'node', '', '98.207.254.151', 1, 191, 1421404617), (6711, 'rpjGdoYWValMQ7BG7ZaOmQsp2qfLGdgfhyJ9VvZDbzk', '', 'node', '', '66.249.65.164', 0, 211, 1421407113), (6712, 'Q2i-LExlMQC5xFRmnX4lZ9hzpbM1ON9hti9ZwR_9NJQ', 'About Sage', 'node/1', '', '66.249.65.137', 0, 180, 1421407713), (6713, 'vRW3zsgiUNX3xStP83tnKYxTlovWOipVuJ3tG3JfCB8', 'Tutorials', 'tutorials', '', '66.249.65.137', 0, 254, 1421408230), (6714, 'M-QkySdvAY9L_k9825ZDAjHl5sQ308saGYl5qz4BvM[...]
MySQL said: Documentation
1062 - Duplicate entry '6764' for key 'PRIMARY'
Yikes. Not sure how this is happening. A duplicate primary key it looks like but if I'm overriding the entire db I'm not sure how this can happen.
At any rate, I just deleted the remote db entirely and re-created it, and THEN did the import of my local file. This STILL caused the error somehow, but now the site works just as if the import had worked successfully.
Then I had to change (ie. just remove the tmp files directory in config - otherwise it kept giving me an error about that) and turn on clean URLs again.
Wow. What a messy process! Can someone please recommend another workflow for me that's not so complicated and time consuming? Or is this just how it is...
I'd like to have one for now while I'm still doing development...and another for after I go live when I need to sync my changes.
Thanks.


texts: Add html to wrap custom panels layout programaticly

texts:
How to add html to wrap custom panels layout programaticly?
I know that i can change html in *.tpl.php but i want to avoid it.
Also i want to know, how to add class to panals programaticly too.

UPD:
I create custom panels layout and want to add html with custom class to wrapp regions of custom panel layout.
I found good decision to use module Semantic panels, but it add markup to field, not to whole region.

This is part of my html

 <?php if ($content['left'] || $content['middle'] || $content['middle_two'] || $content['right']): ?>

            <?php print $content['left']; ?>

  <?php endif ?>

I want to make it like that

 <?php if ($content['left'] || $content['middle'] || $content['middle_two'] || $content['right']): ?>

            <?php print $content['left']; ?>

  <?php endif ?>

UPD2: I try to add variable through themenaame_preprocess_panels_pane, but it doesn't appear in .tpl.php file.

Code

function dmits_preprocess_panels_pane(&$vars){

$vars['custom_article_class'] = 'seriveces-wrapp';
  kpr($vars);

}


texts: Get a contextual filter for a View in Drupal 8

texts:
I'm converting a module from D7 to D8 for a client. Some of the code is working programmatically with views - something I haven't done that much in D7, since I just write my own queries.

In the code is this line:

$contextual_filter = method_exists($view, 'get_items') ? $view->get_items('argument', $display->id) : 0;

I need to convert this to D8, but I'm not sure entirely what I'm working with here.

What I do know:

In D8, $view is an object of type Drupal\views\ViewExecutable
In D8, there is no get_items() method, nor a getItems() method on ViewExecutable
ViewExecutable has a property, args, and also a property argument

My questions:

How can I get the items from ViewExecutable
How can I get the contextual filter from ViewExecutable
Do I even need to do #1 to get #2?

Further down the code, I can see that $contextual filter is used as follows:

'contextual_filter' => !empty($contextual_filter) ? 1 : 0

So it would appear I'm just trying to get a boolean indicating whether or not a contextual filter exists.

Can anyone who has worked more with D7 Views more than I give me some insight as to what is happening with this code, and ideally how I can update it to D8? (Though insight as to what is happening in D7 may be enough for me to figure it out in D8).


texts: views slideshow: display multiple items but scroll only one item at the time

texts:
i'm using drupal 8 and slideshow module to create a block of slides (fields with images and descriptions to it) to put it on some pages.

I have managed to show slides horizontally and they scroll nicely but problem is how to show 4 slides and scroll only by one at the time.

In setting for slideshow there is an option "Items per slide" if i use it and put 4 - i will get 4 slides on an block but it will scroll 4 items at time.  If i put 1 - it will scroll one item at the time but will show only 1 slide and need 4.

plus to all that it should be responsive if only 3 slides can fit on the screen it should show 3 slides and scroll only one by one.


texts: How do I reset URL for Product Display when replacing the main product? (instead of having an increment added to the URL)

texts:
I am having trouble with URLs after replacing items by a delete/re-import. The site uses Pathauto module.

I am adding content to a Drupal Commerce site using Feeds. I had uploaded the Product Variations and then Product Display for one product type. I realized that there were several mistakes with the CSV file and decided to start from scratch.

I deleted the original products by going to Products > Manage Products. From the "List" tab, I selected all of the products and chose "Bulk Action" >> "Delete". The products were deleted from the website, but the URL was incremented by a "-0" and the original now returned a "404" error.

Desired: www.XYZ.com/product/widget

vs.

Less than desired: www.XYZ.com/product/widget-0

How do I return the Product Display to the "widget" URL without the "-0"?

If I try to override it by manually making the update on the Product Display, I get an error message that indicates that URL is already taken.

I would like to clean this up for SEO. Please advise.

Thanks,
keb


texts: Views not work in D6 after upgrading php version to 5.4

texts:
After upgrading php version to 5.4 in drupal version 6, views not work and show fields as Broken/missing handler:

you can see the screenshot of it .
where is problem?


texts: Block cache depending on current node and its last modification time

texts:
I am building a module with a block that outputs some informations from the current node.

When i return my render array i managed to get the cache as "node dependent" using (maybe not the best method ?) :

        '#cache' => [
            'contexts' => [
                'url',
            ],
        ],

The blocks are showing up the right contents on the right pages, but if i modify my node and it's fields, the block content remains pulled from the cache and is not updated with the latest values.

Is there anything to add in the #cache array or a way to invalidate this specific cache when node gets updated ?


texts:
I'm migrating a legacy blog from a home-grown CMS to Drupal 7 and I need to wrap my head around how I'm going to redirect URLS to a new aliased pattern.

The legacy site's URLs use query strings /?t=40&an=49187&anc=570&format=xml which then redirect to an aliased url like /blog/i-know-this-is-not-ideal. Most of the listing pages on the site use the query parameters to link to pages, though others use the aliased urls. The an parameter appears to refer to their version of a Node ID, which I'm able to parse and store in my migration.

The company who owns this platform was kind enough to sent me an Excel spreadsheet with aliases in one column and query strings in another — so I have something at least.

Maintaining SEO juice is critical for this client — and Google has parsed these query parameters in many cases.

Should I look towards writing a custom module for this, as the Redirect module appears not to provide support for query parameters? Or should I look into htaccess rewrite rules?


texts: Get non-standard user attributes in layout

texts:
I want to show the amount of credits the user has. I know the $user object has the following properties:

uid - name - pass - mail - theme - signature - signature_format - created - access - login - status - timezone - language - picture - init - data - sid - ssid - hostname - timestamp - cache - session - roles

But I have also extended user properties like address street, address city, user credits, ... . But how can I print those properties in my layout theme? They are also not in my users table in my database.


texts: When translating a node, can I avoid copying the default value from the original language

texts:
Just a little background:  I've got a set of paragraphs fields that I need to be able to translate, and given the limitations on translation with paragraphs, I've come up with the idea, that it may just be best to create a new node of a new content type (for holding the paragraphs fields) for each language of the main node.  I would then use Inline Entity Form to bring those fields into my main node.

The problem I run into is that translation copies the value from the original language when I create a translation.  Most of the time this is desirable, but in this case, it means that all languages get the same referenced node, when I specifically want them all to have their own new node.

Is there any way to suppress the value copy functionality for a specific field when translating?


texts: View to display 2 posts from 1 content type 1 and 2 posts from content type 2

texts: I want to display 4 featured posts on home page. 2 from the content type 1 and 2 from the content type 2. For this the straight forward way is to create two different views blocks. What I want to know if it is possible to display all 4 posts through a single view ??


texts:
I'm not sure what is causing this, but every page of my Drupal site is throwing a 403 error redirect loop.

I was just working on the project this morning, and left and came back to it and can't figure out what has gone wrong.

If anyone could event point me toward a resource for figuring out what has gone wrong it would be a huge help.


texts:
i am actualy trying to read a field value in my panelized node.

I want to recieve the data in the red marked field, as u can see in my screenshot.

I tried to following:

<?php print_r($display->context['panelizer']['data']['field_centerpage_layout'][0]['value']); ?>

But I recieve this Error:

Fatal error: Cannot use object of type ctools_context as array in C:\seu\xampp\htdocs\iptp\sites\all\themes\mytheme\plugins\layouts\he_two_70_30\he-two-70-30.tpl.php on line 29

I would be thankful for any kind of help :-)


texts: How to give confirmation for deletion through link?

texts:
I have tabular format data and each row I have an edit and delete links , on clicking on the delete link it should ask for a confirmation to delete and if press delete only I need to delete. Now its asking for confirmation but not deleting any. Instead its giving me a blank page. Is it because it's submitted to the same function? It's not going to the products_delete_confirm_submit() on submission by the way. Or is there any workaround for this?

Here is the try :

Menu call back:

 function mailusers_menu() {
     $items['mailusers/usergroup/delete'] = array(
        'title' => 'Delete User group',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('products_delete_confirm', 3),
        'type' => MENU_CALLBACK,
        'access callback' => TRUE,
        'access arguments' => array('access admin tab'),
      );
 return $items;
}

callback function

function products_delete_confirm($form,$product_code) {
$form['_product'] = array(
        '#type' => 'value',
        '#value' => $product_code,);
//$form['#action'] = url("mailusers/products_delete_confirm_submit");
//      //drupal_set_message($product_code);

return confirm_form($form,t('Are you sure you want to delete '.$product_code.' Product?'),
        isset($_GET['destination']) ? $_GET['destination'] : "mailusers",t('This action cannot be undone.'),t('Delete'),t('Cancel'));

}

Delete submit handler:

function products_delete_confirm_submit($form, &$form_state) {
  $form_values = $form_state['values'];
  if ($form_state['values']['confirm']) {
  $param = $form_state['values']['_product'];
    drupal_set_message(t('Product ' .$param.' will get deleted.'));
    db_query('DELETE FROM {content_type_usergroup} WHERE vid = %d', $param);
    drupal_set_message(t('usergroup has been deleted.'));
    drupal_goto('mailusers');
 }
}

And in the table I am calling the delete link href="mailusers/usergroup/delete/10"