texts: How to unit test custom console ContainerAwareCommand in Drupal 8

texts:
I have a custom console command that extends Drupal\Console\Command\ContainerAwareCommand. Inside the command I need to access the container to fetch a service. But now I'm struggling with figuring out how to mock the return value from the container->get command so that I can inject a stub of the actual service the command uses. So how do I set up the unit test?

The code inside the execute() method of my command that somehow needs to be stubbed:

...
$importer = $this
            ->getContainer()
            ->get('fmo.calendar.event.importer');
...

The unit test class so far looks like this:

namespace Drupal\my_module\Tests\Command\Calendar;

use Drupal\Console\Application;
use Drupal\my_module\Command\ImportCalendarEventsCommand;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\Console\Tester\CommandTester;

class ImportCalendarEventsCommandTest extends UnitTestCase
{

protected $command;
protected $application;

public function setUp()
{

    $helperSetStub = $this->getMock('Symfony\Component\Console\Helper\HelperSet');

    $this->command = new ImportCalendarEventsCommand($helperSetStub);

    $this->application = new Application(array('container' => $this->getContainerStub()));
    $this->application->add($this->command);
}

public function tearDown()
{
}

public function testItIsAContainerAwareCommand()
{
    $this->assertInstanceOf('Drupal\Console\Command\ContainerAwareCommand', $this->command);
    $this->assertEquals('fmo:calendar:import', $this->command->getName());
}

/**
 *
 * @param [string] arg [description]
 */
public function testCanImportCalendarEvents()
{

    $command = $this->application->find('fmo:calendar:import');
    $commandTester = new CommandTester($command);

    $code = $commandTester->execute(
        [],
        ['interactive' => false]
    );

    $this->assertEquals(0, $code);

}

private function getContainerStub()
{
    $stub = $this
        ->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')
        ->getMock();

    $stub->method('get')->willReturn('hello');

    return $stub;
}
}

But this does not work. There are new dependencies I need to mock. I tried looking through the test folder of the Drupal Console project itself, but could not find any tests for the ContainerAwareCommand in that project either...


texts: Feeds import: Country field not appearing in Target options

texts:
Working in Drupal8.
I have configured Feeds module in my build.
I have a content type with "Country" field ["Country" contributed module https://www.drupal.org/project/country].
Have mapped the "Country" field with the source and tried importing, but the values from csv file is not storing to the DB.
Below is my Country.php file which I placed inside feeds module:
<?php

namespace Drupal\feeds\Feeds\Target;

use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\feeds\FieldTargetDefinition;
use Drupal\feeds\Plugin\Type\Target\FieldTargetBase;
use Drupal\Core\Entity\EntityInterface;
use Drupal\feeds\FeedInterface;

/**
 * Defines a Country field mapper.
 *
 * @FeedsTarget(
 *   id = "country",
 *   field_types = {
 *     "country"
 *   }
 * )
 */

class Country extends StringTarget {
   /*
    * {@inheritdoc}
   */
   protected static function prepareTarget(FieldDefinitionInterface $field_definition) {
      //$type = $field_definition->getSetting('field_sac_admin_data');
      return FieldTargetDefinition::createFromFieldDefinition($field_definition)
         ->addProperty('country')
         ->markPropertyUnique('country');

   }

  /**
   * {@inheritdoc}
   */
  public function setTarget(FeedInterface $feed, EntityInterface $entity, $field_name, array $values) {
    /*if ($values = $this->prepareValues($values)) { //print_r($values);die;
      $entity_target = $this->getEntityTarget($feed, $entity);
      $item_list = $entity_target->get($field_name);

      // Append these values to the existing values.
      $values = array_merge($item_list->getValue()[0], $values[0]);
      //$values = array_merge(array("India"), array("IN"));

      $item_list->setValue($values);
    }*/

    if (!empty($values)) {
      $entity_target = $this->getEntityTarget($feed, $entity);
      if ($entity_target) {
        $item_list = $entity_target->get($field_name);

        // Append these values to the existing values.
        $values = array_merge($item_list->getValue(), $values);
        $item_list->setValue($values);
      }
    }
  }
  /**
   * {@inheritdoc}
  */
   protected function prepareValue($delta, array &$values) {
     if (isset($values['country']) && empty($values['country'])) {
       // If country is empty set it to null
       $values['country'] = NULL;
     }
     //$values['country'] = "IN";
   }
}

Have tried hard-coding $values['country'], but no luck.
Header is same as like in csv header.
Manually selected a Country and saved the node.
After that, when I import the csv file, its removing the country field value from DB for that node. Other field values are updating.
Can you please point out my mistake and help solving this issue to import the values from csv file?


texts: Allow user to request resend of activation email

texts:
I would like to code a way for a user to request the activation email be resent. Is there a function I can call from within a form-submit hook that will accomplish this?

(using Drupal 7)


texts: how to apply exposed filter without apply button in Drupal 8 views?

texts: I have textfield as exposed filter in table view. How I can apply that filter without pressing apply button. any contrib module or suggestion?


texts: I am running drupal 6.22 with MySQL. There is no drupal 6 API for using transactions. Since I am new to drupal, I do not know which is the best way to use transactions using the existing drupal APIs? Can anyone guide me on this?


texts: How can I change the number of items in a view only for the first page?

texts:
I'm trying to build a view with a different number of items for the first page (2 items) than the others (3 items). How can I build it to avoid skipping items ?
I made tests using hook_views_pre_build() but the result isn't conclusive as the second page will miss one item (item C):

Here is my current code:

function MYMODULE_views_pre_build(&$view) {
  if ($view->name == 'my_view' && empty($_GET['page']) {
    //The view normally has 3 items per page, put 2 for the first page.
    $view->items_per_page = 2;
  }
}

And here is the result I obtain:

  First page:

  item A
  item B

  Second page:

  item D
  item E
  item F

As you can see, item C is missing because setting the number of items per page to 3 imply that the first page also has 3 items.

Is there another way to get this working ?


texts: How do I add a node field widget to a custom form?

texts:
I added a number of fields to a node content type in Drupal 8. I want to create a custom form and add the field widget form (the one used during node creation) to this form.
How can I achieve this?


texts: Request passphrase at user registration and automatically assign role to user

texts:
Is there a module that would allow us to request an optional predefined pass-phrase/password at user registration?

So if the user fills in the pass-phrase he would be registered as a premium user or something, if not he would be set as a simple authenticated user.

By the way, I'm using Drupal 7.


texts: Is there a Self-Imposed Bulk Operations Limit?

texts:
My database has millions of nodes.  We've been approved to delete a very large amount of them given certain criteria so I set up a view with VBO to handle the batch deletions.  I've exposed the pager limit setting in Views so I can run batches of different sizes.  When I try to run anything higher than 1000 nodes per batch (10 per run to prevent timeouts), the batch sets its max value to some number around 1000, depending on the server.  This is limiting me to run either 1000 at a time or attempt to run the entire result set.

I'm looking for any ideas as to why there is this seemingly self imposed limit on the bulk operations.  My sandbox server sets the batch max at 1001 while my production server sets it to 995.

Drupal 7.27
Views 3.7
VBO 3.1


texts:
I'm working with Migrate. On my json source file I've the alias of the node to import. There are nodes that does not have an alias, so in the json I've things like "/node/1234". So I want to skip this alias (not the entire node).

Is there a way to do this?

I'm already using custom process but I don't know how to skip a single value.


texts: How to add CSS classes to a an image which belongs to a content type?

texts:
I have a content type with an image field; I would like to add CSS classes to those images.

I have looked at the values of the $content variable in node.tpl.php via the dpm(), but I couldn't see any properties/keys related to classes or attributes. Maybe I just couldn't see them, or I didn't know where to look.

I would like to print something like <img src="path-to-image" class="my-classes"> by using print render($content['myimage_field']) in node.tpl.php.

I do not want to use external modules to accomplish this. Is there any theme functions I can override? How do I override them?


texts: How do I divide taxonomy term pages by content type?

texts: Drupal out of the box lists all of the content tagged with a term in a single list on a terms page. I would like to split up that list into sub pages based on content types tagged with that term. See mockup below. Seattle is the term page and the "Attractions, Museums, Restaurants and Shopping" are content types tagged with "Seattle". To achieve this, i cannot use quicktabs as it requires an admin to create a new quicktab collection everytime a new city is created. Also, panels is not an option on this project either. I am thinking it they are just views pages, with a term id from URL contextual filter, but I am lost on how to add them as secondary tabs on the term page. Unless I am heading in the worng direction. I would love some advice.


texts: Change the output format used from a view export

texts:
I have a REST EXPORT view with particular fields in Drupal 8. I want to remove the main array which is printing by default.
The response is coming like this.
[
  {
    "title": "Product",
    "body": "
Here are the Product Details
"
  }
]

I expect the response to be like the following one.
{
  "title": "Product",
  "body": "
Here are the Product Details
"
}


texts: How to print the product variation separately from the submit/pay button in a Commerce add to cart form?

texts:
I want to put the calculated product price between the "product variation" select widget and the "pay" button.

In commerce-product.html.twig (my products display an add to cart form on the product itself), I have this code:

<article{{ attributes }}>
  <h2>{{ product.title }}</h2>
  {{ product|without('title', 'variation_price' }}
  {{ product.variation_price }}
</article>

variation_price is the calculated price.

What is the name of the variable that contains the product variation select widget?  Answer: product.variations
How can I place the submit/pay button separately from the variation type selection widget?  Answer: ??

I tried using kint to debug but it broke my site.  (And then people on this site kindly explained how to fix it.)  So I now understand that the variable containing the widget that shows the variations is named product.variations, and this is actually the "Add to cart" form (since that is what I set the display widget to in the UI).

So I guess I need to print the "Add to cart" form twice, and in one instance show the submit button, and in the other instance show the select widget... But how do I do that?

I looked at the twig debug theme suggestions but they don't give me a template for the "Add to cart" form:

<!-- FILE NAME SUGGESTIONS:
   * field--commerce-product--variations--contenttype.html.twig
   * field--commerce-product--variations.html.twig
   * field--commerce-product--contenttype.html.twig
   * field--variations.html.twig
   * field--entity-reference.html.twig
   x field.html.twig


texts: Can a custom module be used to assign permissions associated with a different module?

texts:
Drupal 7. I'm using a contrib module that has one user permission associated with it.  Enabling the module assigns that permission to only the "Administratror" role. I'd like to find a way of using a custom module to also assign the permission to a custom role I've created.

So far, I have within my custom module a function that runs when the contrib module is enabled.

function mycustommodule_modules_enabled($modules) {
  if (in_array('contribmodule', $modules)) {
    $roleid = array_search('custom role', user_roles());
    if (is_int($roleid)) {
      user_role_grant_permissions($roleid, array(
        'permission from contrib module' => TRUE,
      ));
    }
  }
}

But it results in an error like this (output from Drush):

  WD php: PDOException: SQLSTATE[23000]: Integrity constraint violation:
  19 role_permission.module may not be NULL: INSERT INTO
  {role_permission} (rid, permission,  [error] module) VALUES (?, ?, ?);
  Array (
      [0] => 5
      [1] => 1
      [2] => )  in user_role_grant_permissions() (line 3076 of /var/www/d7/modules/user/user.module). PDOException: SQLSTATE[23000]:
  Integrity constraint violation: 19 role_permission.module may not be
  NULL: INSERT INTO {role_permission} (rid, permission, module) VALUES
  (?, ?, ?); Array (
      [0] => 5
      [1] => 1
      [2] => )  in user_role_grant_permissions() (line 3076 of /var/www/d7/modules/user/user.module). Drush command terminated
  abnormally due to an unrecoverable error.
  [error]

Looking at the table structure that third value [2] that's blank is supposed to be the name of the contrib module associated with the permission.

I think the problem is something along the lines of either the permission doesn't exist yet at that point in the execution, or maybe it's a security safeguard that prevents custom code from assigning permissions associated with separate modules. Either way I'd appreciate someone pointing me in the right direction with this.


texts: How do I customize the flag/unflag links?

texts:
I'm fairly new to Drupal theming, and I am trying to customize the HTML output the Flag module for Drupal 8 produces for flag/unflag links; more specifically, I would like to make the links appear as buttons using Bootstrap classes. Does anyone know a good way to do this? I'm placing the flag link on the user profile page to enable users to follow other users. Here are some approaches which I have tried, so far without success:

Using the Twig replace filter to modify the output. This does not work, apparently because a "lazy builder" is used, delaying the production of the actual HTML output until a later stage after Twig's rendering is already complete.
Overriding the flag.tpl.php template with a customized version. This has no effect; maybe this functionality is no longer active in Drupal 8 (which did away with PHP templates in general)?
Using flag_create_link in a theme preprocess function. I got an error that this function does not exist; maybe it no longer exists in the Drupal 8 version of the module? (or else maybe I'm missing a necessary import).


texts:
Using advice from Drush: Update core from stable to dev I ran drush up drupal-7.x in order to switch from 7.7 to 7.x-dev.

However I'm now in the position whereby I want to move the project back to 7.8, however I don't seem to be able to figure out how to do this. I've tried:

drush up drupal-7.8

Which produces:

 Name         Installed version  Proposed version  Status
 Drupal core  7.x-dev            7.x-dev           Specified version available

So it appears to understand I'm asking for a new version, but following this through just updates the site to the latest 7.x-dev.


texts: Running a customized cron task very often

texts:
I have a custom cron task that needs to be run every ten minutes.
The task connects to remote servers to retrieve some data and update the drupal db.

In order to achieve that I have to execute drupal cron at least every 10 minutes (I do it via crontab on a GNU/Linux system), so my questions are :

Is it overkill to run drupal cron so frequently ?
What are the main tasks that drupal cron is executing ?
I understand that every task run within cron must check the last time it was executed so it is not run too frequently, is it generally understood this way ?


texts: How can I add entity base field with unique constraint if some entities already exist?

texts:
The issue is that adding a base field to a custom entity type in code would result in an issue of unique constraint violation as there does not seem to be a way to preset the value to the newly added field.

setInitialValue() would set the same value for all the existing entities triggering a constraint violation.

setInitialValueFromField() would not do any good as it would only allow fetching value from fields of same type. Otherwise it would be possible to utilise the value from an ID field and then replace those initial values with something more suitable.

Is there any meaningful way for doing that?


texts: How to filter by two fields using a single exposed filter in Views?

texts:
I have a view listing nodes. I added 2 exposed filters. One is Content: title and the other is Content:Body. Then I have 2 input fields to enter some keyword to do searchs.

I need to have just one field and do the search in both fields: title and body. Can I do this?


texts: How to show how many hits has got one page

texts:
I'm trying to get something like this "viewed: 123 times." on every single node a part from the static pages like about us or contact etc..

Is there a module for it or is better to create a flag for this?

Thanks in advance.


texts:
How do I resize image directly while uploading the image?

Select image from Computer > Upload > Resize directly to dimension that I want.


texts: 2 seperate feeds updating the same set of nodes (feeds module)

texts:
I'm using the feeds module to pull in a set of publications into a Drupal content type.  They are set to run at regular intervals using cron.  I have two separate feeds, which should work as follows:

Feed 1 (pure_feed) - pulls in the bulk of the fields
Feed 2 (harvard_format) - accesses a separate url source and updates one field on the content type.

The problem I have is that feed 2 always creates a new set of nodes rather than updating the existing nodes (that were created using feed 1).  I have used the debug options at /import and can see that the GUIDs for feed 2 match the GUIDs for feed 1, but it still creates 2 sets of nodes rather than updating the 1 set of nodes.

Here is an excerpt from the feeds_items database table:

As you can see they both have the same GUID but they are mapped to separate nodes.  Is there any way to have the second feed map to the same nodes as the first feed?


texts:
Hi Guys I am having a missing format: 1. alert on my web most of the time is when loging out of my web on when I access the front page, this is the log message

filter
Date    Saturday, August 1, 2015 - 11:16

User    raydelhgm

Location    http://localhost/gameswapuk/

Message Missing text format: 1.

Severity    alert

Hostname    127.0.0.1

how could i fix it, thanks


texts:
Fatal error: Call to undefined function omega_theme() in /home/itcom/public_html/sites/all/themes/libra/template.php on line 27

Whenever I browse my site, I get this message, and I am not able to login to the site. Clean URLs are not enabled in this site.

I would like to know how I can change the default current theme from code, and any other solution to rectify this problem.


texts:
I have images going mysteriously missing from my Drupal site, sometimes several all at once.  There are currently only two people who have access to edit these, myself and a manager in Corporate Communications.  She just alerted me to a half a dozen disappearing all at once, and claims she did not delete them.  I have no reason to doubt her word, and I know I did not delete them.  This started happening months ago, and I had thought I may have fixed it a couple of months ago by deselecting "Delete unused files" in the One-click Upload settings.  Apparently that did not fix the problem.

Why is Drupal eating my content?  How can I stop it?


texts: How to get a custom field label in a specific language?

texts:
In order to get the label of a field I just do :

$fii = field_info_instance('node', 'field_app_area', 'products');
$label = $fii['label'];

But it returns the label in the original language of the field, not the current user language.

I have seen some code here to get the translated label from the $content variable of a node template, but I don't have the template variables available.

So my question is either : how do I get the label translation or how do I get the $content (or similar) variable available without being on a template.


texts:
I've created a custom module for populating a database and now I need to apply form validation to this form.

I want a few different validation things to happen.

I want to limit specific entries on the client side IE: only allowing 6 characters being entered etc.
On submit I want to run through validation rules to make sure what was entered is correct. IE: only positive #s etc.

Are there any drupal 7 FAPI fields to validate specifics like this?

I found something like '#element_validate' => array('element_validate_integer_positive'),

Is there a list anywhere of element validations like this? I'm unable to find documentation anywhere :(


texts: Why can anonymous users see my block, whose visibility is set to hide it for anonymous users?

texts:
I have a block on one of my sites, in which all content is private.  Anonymous users don't see any of my content types, any of my views, blocks, etc.

The problem is one single block.  The problem block is the only one not created by a view or a module.  I created it simply by adding it via the block page interface.  I have set its visibility settings to be restricted to a certain role (not 'Anonymous', of course :-)).

However, this is the one piece of content that is still showing up on my site for anonymous users (before one logs in).  I've cleared cache multiple times, so that isn't the issue.

Has anyone else run into this issue?  Why would the block not respect the visibility settings?  I'm wondering if there are some modules that may be interfering with this or if there's another explanation I'm not seeing....


texts: Add custom styles for printing taxonomy terms

texts:
I'm using print module for generating a PDF file. Here, the node that I'm printing has a field that lists all the taxonomy terms for that specific node.

When the page is printed, the taxonomy terms are displayed in an unordered list with bullets, leaving an empty line between field name and taxonomy terms as:

Field name:

 - term1
 - term2

But, I wish to display the terms next to field name in the generated pdf. I tried using taxonomy menu module, but i anticipate it doesn't work with print module. Is there any way to get this done.


texts: Payments and user balances/virtual coins

texts:
I would like to implement some premium options within my website.  But most modules I have looked at, focus on providing payment-interactions (buying items, adding node etc.).

In contrast, I am looking for keeping a seperate account per user and their purchases.  My expected workflow would be that the user establishes a certain balance eg. 100 USD and then uses this balance to purchase many small items/subscriptions/etc. The payments should be handled via automated payment gateways (Paypal or some credit card processor) or through manual payments added by admin.

Can you suggest any modules - ideally for D6, but feel free to post D7 solutions too - that would faciliate managing a user-based account in Drupal?

Btw, I am aware that the complete solution is not availible out of the box and that custom modules will be necessary.  I am also open to suggestions relying on external services or alternative ideas like the userpoints module.


texts: view infinite scroll: how to exec a js function after loading items ?

texts: I have the module "views infinite scrolling" installed on my site and it works. Now I want to exec a function when all loaded (Via ajax) items are loaded and showed to the user. How can I do this ? Thanks.


texts: Create view display block for Organic Groups with specific criteria

texts:
I have created a OG view display block that shows the subgroups of a parent group. The issue I'm having is that when there is a private group that's a subgroup of the parent group being shown, it shows the message "-Private Group-". I would instead like the group to not appear in the list at all if the user is not subscribed to it, but show as a link to that subgroup if the user viewing is subscribed to the private group.

I have attached a screenshot of the current view configuration.


texts: How to pass argument in service with dependency injection

texts:
In a custom module, I have a custom service that uses GuzzleHttp\Client service.

mymodule.services.yml:

services:
  mymodule.mymodule_call:
    class: Drupal\mymodule\MyModuleCall
    arguments: ['@http_client']

The MyModuleCall is using dependency injection and start like:

namespace Drupal\mymodule;

use GuzzleHttp\Client;

class MyModuleCall {

  protected $client;

  public function __construct(Client $client) {
        $this->client  = $client;
  }

}

As explained in the GuzzleHttp documentation (http://docs.guzzlephp.org/en/latest/quickstart.html), we can pass an argument to the Client constructor to set the base_uri.

Like so:

use GuzzleHttp\Client;

$client = new Client([
    // Base URI is used with relative requests
    'base_uri' => 'http://httpbin.org'
]);

How do we set the 'base_uri' in the constructor when we use dependency injection to instantiate a class?


texts: Render custom block using block.html.twig template

texts:
I'm attempting to render a custom content block programmatically (created through the Custom Block Library UI) and I would like the block to render using block.html.twig as it would if I were to place it in a theme region. I have the block placed in a disabled region and I can get the block body field to render programmatically, but it is not wrapped in the usual block template and does not include the block title. I'm using the code to render a "content block" from the accepted answer here: How can I programmatically display a block?

$bid = ??? // Get the block id through config, SQL or some other means
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->
getViewBuilder('block_content')->view($block);
return $render;

As I understand it, I need to render the instance of the custom block that I have placed inside the disabled region, so I would expect that I have to use the machine name of that instance. I've done a lot of searching and come up with nothing. It's strange that nobody else seems to want to render the block with the title in the block.html.twig template.


texts: URL alias in view with subfolder of the Drupal installation

texts:
I've never seen this before:

This D7 installation runs in a subfolder of my dev server. The same way as all the other installations.

In a view I have a field with the node alias path. But this path I get with the subfolder.

Drupal runs in: myserver/subfolder/mydrupal
The path is: this-is-my-node

I should get: this-is-my-node

I get: /subfolder/this-is-my-node

When I overwrite the output of this field with [path] all works fine.

What could be happened?


texts:
I currently have a Drupal site with a content type of Training where a variety of different training courses are listed. We are looking to sell these courses with Drupal commerce.

How do we go about turning these courses to items visitors can buy?

EDIT:

OK. I think I may have it now. Sorry for the poor comment, it was late and I hadn't messed around with commence much - Now I have!

My query is how and where best to have the fields, which I believe is a common Commerce question

Each Training has the fields of:
- Title
- Body
- Who should attend this course
- Course Structure
- Dates

How is best to sort the content fields for a Training course:

1)
Product Variation type to have all the fields above - So each course will essential be a product variation?

OR

2)
Content type to have the fields with only reference to product for the price?

My reasoning for this question is I don't have the experience to know what is best for future development where I might be looking at managing available places (Which I fore see done with stock?)


texts: Add/List/Edit paragraphs while add/edit node

texts:
I have installed paragraph module.

I have paragraph called Address contains relevant info.

It is attached to node.

Per page/article I have more than 100 address. If I use default Paragraph Classic view mode then page is going to be too huge.

What will be alternate solution?

Should be there List and Add button. Add/Edit/List will open in Modal Widget?

Need to use Entity browser and Paragraph Views.


texts:
I have created a created a list in view of all members and so far it´s working fine.

I use both User profile and Profile 2.

The user profile for information the member are allowed to edit.
A Profile 2 type for information they are not allowed to edit but should be visible in the view list.

But I notice that if I create a profile type in Profile 2, View make doublets of the member. If I have two profile types, I get doublets, if I make 3 profile types, I get triplets of a member in the list.

Is there any way I can use more than one profile type without having the same member appearing in the list several times?


texts:
Hello this is my file views-view-field--sitemap--views-data-export--field-image.tpl.php :

<?php

$fields["field_image"]->content = '<image:loc>' . $field->original_value . '</image:loc>' . '<image:title>' . $row->field_field_image[0]['rendered']['#item']["alt"] . '</image:title>';

echo $fields["field_image"]->content;

When I check the box to hide empty if the image field, the empty fields are hidden in the preview of view but not out. How to hide empty fields when the view is displayed? I think there is a line to add in the template file.


texts:
I am new to Drupal and I'm looking for a slideshow of user uploaded images on a user uploaded project. Basically, I want the user uploaded images to be shown on the content page, in addition to text, ratings, comments, etc. I downloaded Views Slideshow and dependencies, then added a field on the content type the images go on, so users can add any number (actually it's capped at 10, but that shouldn't really matter) of images.

After that, I found myself stuck. Every single result on Google was somewhere along the lines of "Create a View and Use it" without enough detail on either.

How do I get a user created slideshow of images on content the user made?


texts: How can I make registered user take control (Edit/View/Delete) a piece of content type; a specific page for example. is that even possible?


texts:
I am keep getting this annoying response from PDO. The error is quite self-explanatory, however the solution (setting PDO::MYSQL_ATTR_USE_BUFFERED_QUERY) doesn't work for me.

PDO::MYSQL_ATTR_USE_BUFFERED_QUERY is already enabled in database.inc as suggested. Also Drupal get stuck on much early stage if I change the value to false, so I am assuming that this setting is effective most of the time but not always (which is weird).

The project is quite big and I am not the original developer, so it's not possible to inspect hundreds of files and fix every custom query or add $db->closeCursor() to them.

What would be your suggestion in this case?

The exact error message is:

  SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active.  Consider using PDOStatement::fetchAll().  Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.


texts: Restrict text format use to a particular node/edit URL

texts:
I have a custom text format that i use in the Wysiwyg profile with ckeditor. Using Drupal 7.
I want to restrict that text format use to a certain node/edit URL.

What would be the best option to achieve that either Programmatically or using custom modules?

Any advise is appreciated!


texts: View fields from the same database column

texts:
So, I have serialized data within the uc_orders table. This data has several parameters of interest each of which I want to create a unique field from.

Each one of these $data values work on their own. Obviously I am rewriting the value on the second declaration. How can I reference the same data location twice so that both of the fields can be used and I can explode all of my serialized data into separate fields?

  function uc_order_views_data() {
    $data['uc_orders']['data'] = array(
      'group' => t('Order') . ':data',
      'title' => t('Arrival Date'),
      'help' => t('Arrival date choosen by customer during checkout.'),
      'field' => array(
      'handler' =>'uc_order_handler_field_arrive_date',
        'click sortable' => TRUE,
      ),
      'sort' => array(
        'handler' => 'views_handler_sort',
      ),
      'filter' => array(
        'handler' => 'views_handler_filter_string',
      ),
    );

    $data['uc_orders']['data'] = array(
      'group' => t('Order') . ':data',
      'title' => t('Ship Date'),
      'help' => t('The date to ship the order by.'),
      'field' => array(
      'handler' =>'uc_order_handler_field_ship_date',
        'click sortable' => TRUE,
      ),
      'sort' => array(
        'handler' => 'views_handler_sort',
      ),
      'filter' => array(
        'handler' => 'views_handler_filter_string',
      ),
    );
  }


texts: CKEditor custom configuration (implemented using WYSIWYG module)

texts: How can I set some custom configurations for the CKeditor module? I want to set spell check SCAYT on by default, and a few other things like that. Ideally, I would like to create my own custom config file somewhere sensible that won't be overwritten.


texts: How do I create a view of content that contains a field collection field with multiple items?

texts:
I have a content type (meeting) that contains a field collection (presentation). I'm trying to create a view using views_datasource (XML format) that lists the presentations in each meeting like this:

  meeting1-field1
  meeting1-field2
  meeting1-presentations-field

  presentation1

  presentation1-field1
  presentation1-field2

  presentation2

  presentation2-field1
  presentation2-field2

  meeting1-field4 etc..

and so on for each meeting node in the view.

I have setup a relationship on the field collection field, but I am unable to get the grouping to work correctly.

Any advice would be appreciated.


texts: How can I specify language for Parent Item options on node create/update page?

texts:
The site in question is running Drupal 7 and has a sub-folder structure for the languages. E.g. http://site.tld/ for default language and http://site.tld/en/ for english.

The editors can choose if they want their admin interface in either language by logging in on the user page for any available language.

My problem now is that on the node create/update page, Drupal seems to use the global $language to determine what options to retrieve for the Parent item under Menu settings, rather then using the current node's language.

So if an editor is editing a node in the default language but on the english interface, only english menu items will be in the select list mentioned above. When saving the node, the Parent item will be reset to the base of the menu and the previous menu structure will be lost.

What I want is a way of altering the chosen language for when that option list is being built. I suppose one way would be to use hook_form_alter and rebuild the options for that field, but that doesn't feel like the right way of doing it.

Is there another way of solving this issue?

UPDATED

It doesn't necessarily need to work perfectly. I guess one way would be to have one language neutral menu and then localize the menu items instead. That would bloat the main menu though, especially when there are multiple languages.

Yet another hack would be to do as @reptilex suggested in his answer and then overwrite the admin translations with one language. I'd prefer not to though.


texts:
How to track the content fields changes in view, just like history review.

When we click on that particular field of content, my aim is some how to track the field of content type have gone through field track changes module. But its of no luck.


texts: How can I get the taxonomy term name from a term ID?

texts:
I'm trying to get a taxonomy term name by term ID. According to another post, I should load the term first:

$term = \Drupal::entityTypeManager()->getStorage('taxonomy')->load($tid);

But then I get this error :

  Notice: Undefined property: Drupal\Core\Entity\Plugin\DataType\EntityReference::$target

What am I doing wrong? How can I get the term name?


texts: Use default language domain when editing translated content

texts:
I have a multi-lingual site setup that uses two domains:

example.com (Primary/Default English domain)
example.mx (Spanish translation)

When editing translated content the user is forced to 'example.mx/node/[nid]/edit' which forces the user to login for both 'example.com' and 'example.mx'.

Is there a way to allow translated content to be edited on a path for the primary domain as opposed to the domain setup for that language?


texts: Show a required textfield when user select only ups shipping service on checkout form

texts:
I am using drupal commerce for my client ecommerce site. For shipping methods I am using commerce_shipping, commerce_ups, commerce_usps.

Everything is working but my client wants when a user select any ups shipping service a textbox should be shown and should be required.

What I have done till now :

I have created a pane which contains a textbox using order setting. And that taexbox is showing on checkout form . But when I make this textbox as a required field than it is not possible to submit the form when user select usps or flat rate shipping services.

So how I can show a textfield on checkout form which should be required only when user select any ups shippping service.

Thanks!


texts: Enable view sorting permission by organic group

texts: When using the draggableviews module for views sorting, permission for using draggable views is defined by role, any info on how this can be defined by OG.


texts: Is it possible to change the layout of the registration form using display suite?

texts:
My registration form contains the following fields
-Name
-City
-Mobile
-Email
-Password
-Confirm Password
-Terms and Conditions (using legal module)

Is there some way to change the layout? I want it to appear something like this

************** ***************
*   TERMS    * *   Name      *
*     &      * *   City      *
*   COND.    * *   Mobile    *
* ************ *   Email     *
*   Submit   * *   Password  *
************** ***************


texts: One node for every referenced node in views

texts:
I have a view that uses the table display mode. I want to show up the last created node for every referenced node; for example, I have two users, and I want to show the last post for both users.

  user number 1    |   last post title
     user number 2    |   last post title


texts: How do I retrieve un-submitted values from a form and pass to another module?

texts:
I have created a custom module called trim_users. What the module does is to alter the (menu) page callback of the user references module to execute a modified (by me) function of the user references module. The modification I've made is simple: I've altered a database query so that the users returned into my forms' autocomplete field is a trimmed down list of my users. I've joined on a 'user.team' field and I'm saying give me all the users where the team is 'x' and 'y'. So first the user enters the two teams into my form: team 'x' and 'y'. Then the user goes to enter a user. After the first character is input I want my trimmed list of users to drop-down in the autocomplete field.

I'm stuck on one bit: how do I send the values of team 'x' and 'y' sitting in my (as of yet unsubmitted) form so that the database query, in my trim_users module, can populate the condition clause with these two values?

Do I need to add an AJAX property to my form elements: 'enter team 1' and 'enter team 2' so that on change a function is called and the entered values made available to my trim_users module?

Thanks. Hope I explained that okay.


texts: Programmatically adding line items to Ubercart order

texts:
Can someone please suggest how do we add line items to an Ubercart order in Drupal 8? When I look at the references in Ubercart module, I get this:

// Load line items... has to be last after everything has been loaded.
$order->line_items = $order->getLineItems();

I am already setting product details to the order. However when I set line items by above line of code, system doesn't allow me to proceed ahead and doesn't even show any error.

Thanks in advance for any help or suggestions.


texts: Implementation of drupal behaviours in drupal garden sites

texts: If it possible to implement drupal behaviours in drupal garden site? if yes then what will be the syntax for it?


texts:
I have a
 containing a node (a Basic Page), which has a title, body and a header image. I do not want to display the header image inside that div, so I removed it from the block layout. I would like the header image to be in the html before the
, that is, outside of the div into which the given content type is outputted (so I cannot solve this via block layout, since the image field is to be outputted outside of the content block).

Can I somehow programmatically instruct my theme to display the header image of my Basic Page? Or is there a better way how to do it?

Example:
I need to change this:

Title

body

to this:

Title

body


texts:
How can I print a variable in the node template?

For example, if it's a variable of content, we can print it with the following code.

{{ content.field_name }}

If I have a {{ counter }} variable, how do I display it with Twig?


texts: apache solr combine terms from different content type

texts:
i want combine the taxonomy terms from different content type, i want combine those values and display in the apache solr search block.

I am trying using apache api, but no success


texts: I have created a views page ?q=node/% which overrides the default node display with Views. (very cool) My related taxonomy blocks stopped working though. Maybe there is something I do not know? Info below.


texts:
I've upgraded from  D6.31 to D7 . few problems with block.tpl.php in te deafult theme, but sorted easily.
Now when I install a theme i get a WSOD

select * FROM watchdog ORDER by wid DESC lIMIT 2;

gives an error of

The file %path was not deleted, because it does not exist. | a:1:{s:5:"%path";s:43:"temporary://marinelli-7.x-3.0-beta11.tar.gz";}

google hasnt thrown up any possible solutions. Anyone know ?


texts: How to theme or override forms when using Panels

texts:
I am using Panels in my website. there is a page user/$username/edit which enables the people to edit their profile.

I tried the following code to theme the user_profile_form form.

Template.php

function MyTHEME_theme($existing, $type, $theme, $path) {
    $items['user_profile_form'] = array(
        'render element' => 'form',
        'path' => drupal_get_path('theme', 'MyTHEME') . '/template',
        'template' => 'user-profile-form',
    );
    return $items;
}

and in /template directory added the file user-profile-form.tpl.php with this code

<?php
print "Hello";
?>

After clearing the cache, I expect to see Hello message when I visit the user profile edit page, But I still see the same form as before.

I wonder why it behaves like this, I thought it may be because of panels module that does some thing which overrides my template file.

I would like to know am I right? or I am doing some thing wrong in theming the form.

Thanks.


texts: Drupal doesn't invoke a hook function until I don't clean the cache

texts:
I created a module, and implemented hook_form_alter() using the following code.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'mymodule_form_id') {
    $form['#validate'] = array('mymodule_form_validate');
  }
}

Drupal can call the function correctly, and run well for several days.

But one day Drupal did not call the function anymore, until I cleared the cache. Why?


texts:
Im trying to figure out what contextual filters to use but im getting no where, im trying to display content related to that user through an attachment on a page listing all users. So for example if I had user 1 it would display content from user 1 and if the user is user 2 and the attachment would display the content under user 2 and so on.

In the image below, I have the filters and relationships I am using on my attachment. on the page itself I have no contextual filters or relationships on it. I think that is fine since I am displaying just the users themselves, however I could be wrong.

as you can see I have no contextual filters added on to the attachment because I am not sure which one is the correct one, I have tried different combinations with User: Uid and Content: Author Uid but have had no luck.

Any help is appreciated.


texts:
Is the machine name of a Drupal 7 field limited to 32 characters (including field_)? When I'm creating a new field, the UI seems to cut me off there, but I wonder if this can be circumvented.

I'm using prefixes to map certain fields to others, and the fact that my prefixed fields are getting cut off is going to make my matching logic slightly more complex.


texts: How would you implement function rich forms to your module

texts:
I'm having a hard time deciding on how to develop the following functionality in my upcoming module:

I'm developing a module which should eventually be able to create "event" type nodes. Which extend the nodes functionality to have:

One or multiple plannings which consist out of...
... timespaces, which has the following properties, per timespace:

from (datetime)
to (datetime)
limit of subscribers (int)
And other stuff (not related to the question)

The website visitors should be able to subscribe to each timespace with a form, filling out their information. But if, and only if the limit of subscribers has not been reached yet for this timespace.
After subscription, the visitor should get an automatic mail with a PDF (ticket) attached to it.
Our customer should be able to export all the data, at any time to an Excel sheet...
... and (preferably) quick-review all the subscriptions at all time.

Well, the plannings and the timespaces won't be a problem, I'll manage that. But I would absolutely LOVE to incorporate Webforms into this. Since, point 3 through 6 all address functionality that already exists in Webforms... It'll save my butt a lot of time developing this thing.

My question is... Does anyone have any experience developing a module, incorporating Webforms? If so, how did you combine the two? I was thinking about something in the lines of:

Developing a new Field widget which would make it possible for the moderators to create the event's plannings and timespaces.
Somehow, (and this is the part where I'm not sure how to do this) creating a field for "webform" that would fetch the possibilities from the field.

I'm not sure.. I don't think this is the right way to go... I wonder what you guys think about this and if I simply should develop my own form + all the functionalities with it. Or maybe know a contrib module that does all of this...


texts:
I'm creating a menu item for my main navigation bar. It looks like this:

module/module.links.menu.yml:

top.link:
  title: 'Operations'
  description: 'Operations'
  parent: main
  menu_name: main
  url: 'route:<nolink>'
  expanded: TRUE
  weight: -49

mod.first_option:
  title: 'Functionality 1'
  description: 'Functionality 1'
  parent: 'top.link'
  menu_name: 'top.link'
  route_name: 'mod.route_name1'
  expanded: TRUE
  weight: -49

mod.secon_option:
  title: 'Functionality 2'
  description: 'Functionality 2'
  parent: 'top.link'
  menu_name: 'top.link'
  route_name: 'mod.route_name2'
  expanded: TRUE
  weight: -47

I'm trying to create an empty top level link, with nested elements beneath it for a menu. I've tried url: 'internal:##', url: 'route:<nolink>', and link: '<nolink>',  Anything else I could try?


texts:
I'm running OG 2.7.

I need to make it so ORG A can connect/ network with ORG B.

ORG A says "I'm affiliated with ORG B and want to show that connection." Currently, they would just select from an entity reference field containing a list of all ORGS, pick ORG B, and then ORG B would show up on ORG A's page as "in their network".

The problem is, ORG B may not agree that ORG A is affiliated and thus would want to approve or deny the affiliation. So I'm looking for a way to provide the same networking effect with approve/ deny functionality.

I've searched high and low for any glimpse of a way to achieve and have found nothing. Any help would be greatly appreciated, even if it's just pointing me in the right direction.

Thank you in advance


texts: Views REST Export and Multi-Value Fields

texts:
I'm having trouble getting the Views REST export to work nicely with multi-value fields.
I have an image field that can have multiple images. I have added the field to my REST export View, however all values are being output on the same line. Like this:

[
    {
        "nid": "11",
        "image": "http://example.com/sites/default/files/2016-02/mobile-1.jpg\n,   http://example.com/sites/default/files/2016-02/mobile-2.jpg\n"
    }
]

What I would like to achieve is something like this:

[
   {
      "nid":"11",
      "image":{
         "0":"http://example.com/sites/default/files/2016-02/mobile-1.jpg\n",
         "1":"http://example.com/sites/default/files/2016-02/mobile-2.jpg\n"
      }
   }
]

Is this possible?
Perhaps using HOOK_views_pre_render() to change the returned value?


texts: Creating a rule for changing user role when related profile is filed

texts:
I have created 2 profiles with using profile2 for users lets name them A and B. All users will have role authenticated when they subscribe and will have to fill profile A.
Then after completing subscription they can become "Pro" user by filling profile B fields. Now I want to change the user role when he fills this profile to "Pro".
I was thinking about doing this with rules but couldn't make it up until now.
What is the best way to do this?


texts: Form error messages are not displaying in colorbox

texts:
I have a custom form which is displaying in a colorbox.

But the problem is when I set an error in validate function using form_set_error, the red border appears against the field but the error message is not displaying.

Any idea?


texts: hook_menu implementation producing error page

texts:
I am trying to create a new module implementing hook_menu, to render a page on my company's web site, which I have taken over from the external firm who designed it. There are other modules that use the hook_menu mechanism successfully on the site.

However, when I create my module and try to access my new page, I get a message indicating "Error. The website encountered an unexpected error. Please try again later.", with no real indication of what the error is.

Here is my code:

<?php

function customer_stories_menu(){
    $items['test'] = array(
        'title' => 'Products Display',
        'title callback' => 'customer_stories_title',
        'page callback' => 'customer_stories_page',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
    );

    return $items;
}

function customer_stories_page() {
    return "Test 123";
}

function customer_stories_title() {
    return "Title";
}

I have made sure that I cleared the cache after putting the code in place. Could something in the site be preventing new hook_menu pages from working?

I should also mention that I first tried creating a new view page to get to the data I wanted to display, but I also got a non-descript error page when I tried to access the defined URL for the page. The two issues may be related. Thanks for any help you can provide.


texts: how to bypass video conversion for mp4 files?

texts:
I am using the Video module on my site, and would like a would like to bypass video conversion and a user uploads a file in MP4 format.

Is there any way that the bypass video conversion?

The reason for this is that due to the high volume of video submissions, and the fact that most often the video is already mp4.  The conversion takes a lot of hard drive space, and also required a lot of RAM and CPU resources.  I am hoping that bypassing some of the unnecessary conversions will help alleviate this problem.


texts: How to make Drupal 7 render taxonomy tags as RSS categories?

texts:
In Drupal 7, taxonomy tags do not show up in the RSS feed. How do I make them visible in the feed, so that RSS reader users can filter out stories based on these tags?

(I found it difficult to find an answer to this, so posting my findings in the hope this helps others)


texts: Where is $form_state stored between form build, and form submit functions?

texts:
I assume that $form_state data can normally be stored either in the database, or in the session.

In this code:

function _module_name_main_form($form, $form_state) {
  $form_state['random_extra_data'] = some_func();
}

function _module_name_main_form_submit($form, $form_state) {
  $important_data = $form_state['random_extra_data'];
}

I trust that there are limits to how the user can manipulate $form_state, which isn't true if $form_state['random_extra_data'] is stored in the session.

Is that safe to do?


texts: How to run auto feed with a auto link for every created node?

texts:
I'm stuck on changing the url of a feeds

what i want to do is after a person creates a content
that feeds runs his feeds to the target url depending on
the value he filled in.

example:
person fills in "hello world" saves the content
the feeds will go to www.domain.com/hello%20world and does his thing.

i already setup the rules that after creating content type event
and the action execute feeds importer (so he runs the feeds)
only problem is it will only go to the already filled in url
instead of the one depending on what the person filled in

can anyone help me with this. Thx


texts:
My site has a number of content types that have Field Collection fields. All of these field collection fields allow more than one value.

I've marked the content types as translatable, and the field collection fields as well. It does not work though; changes to translations are also visible in the original language.

Field collection is obviously an entity reference of sorts, and adding a new translation does not appear to link the field to a newly created entity, but the same one.

How do I fix this? Is this a configuration issue, or is this a bug?


texts: access callback admin permission is not working

texts:
This is a follow up to  drupal.stackexchange.com/q/228722/9921

I have an api that I creates that I would like to restrict access to users with administrator role. But for some reason the 'administrator permission'  is not working. And the api returns an error when I add this restriction.
To clearify the use of language here:

    User : admin
    Role : Administrator
if you go to people permissions, Administrator has a permission of type administer permissions

I am 100% certain the user is an administrator

function mymodule_menu() {
/**
 * Create api callback to return list of users in a give site
*/
  $items['api/v1/userslist'] = array(
    'type' => MENU_CALLBACK,
    'page callback' => 'mymodule_api_userslist',
    //'access callback' => array('administer permissions'), // tried both and they don't work
    'access arguments' => array('administer permissions'),
    'delivery callback' => 'mymodule_json',
  );
  return $items;
}

function mymodule_api_userslist() {
  // code not included since I know it works if the permission are just all permisions
  $data = Do an entityfieldquery to fetch users and return them
  return $data;
}

function mymodule_json($data) {
  if (is_int($data)) {
    drupal_add_http_header('Status', '400 Bad Request');
  }

  echo drupal_json_output($data);
}

The above code is being called via

  $users = drupal_http_request('http://'.$domain.'/api/v1/userslist');

Any ideas?

____EDIT

<?php

/**
 * Implements hook_menu().
 *
 * */
function data_export_menu() {
/**
 * Create api callback to return list of users in a give site
*/
  $items['api/v1/userslist'] = array(
    'type' => MENU_CALLBACK,
    'page callback' => 'data_export_api_userslist',
    'access arguments' => TRUE,
    'delivery callback' => 'data_export_json',
  );
  return $items;
}

function data_export_api_userslist() {

  $data = data_export_process_users();
  // Do an entityfieldquery (or some other query) to fetch users and return them
  // as an array, not HTML or json. Json encoding will happen in the delivery callback.
  return $data;
}

/**
 * Delivers JSON. Used as a deliver callback for api menu items.
 *
 * @param array $data
 *   An array to be encoded as json.
 */
function data_export_json($data) {
  if (is_int($data)) { //https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_deliver_html_page/7.x
    drupal_add_http_header('Status', '400 Bad Request');
  }

  echo drupal_json_output($data);
}

function data_export_process_users () {

  $results = array();

  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'user')
    ->addTag('role_filter');

  $results = $query->execute();

  $users_node_list = entity_load('user', array_keys($results['user']));

  $return_results = array();

  foreach ($users_node_list as $key => $value) {
    $output = array();
    $output['name'] = $value->name;
    $output['email'] = $value->mail;
    $output['init'] = $value->init;
    $output['role'] = array_slice($value->roles, 1, 1)[0];
    $output['status'] = ($value->status) ? 'active' : 'blocked';
    $output['last_access'] = format_date($value->access,'small');
    $return_results[] = $output;
  }

  return $return_results;
}

function data_export_query_role_filter_alter(QueryAlterableInterface $query) {
  $query->innerJoin('users_roles', 'ur', 'users.uid = ur.uid');
  $query->innerJoin('role', 'r', 'r.rid = ur.rid');
  $query->condition('r.name', ['administrator', 'contributor', 'publisher'], 'IN');
  $query->condition('users.init', '', '<>');
}


texts: Show or hide field data using java script in node

texts:
I create one cck content type and add one text field in them with name of:  My friend name: text field with add more buttonThen, i submit form with entering my 15 friends names
Like this:
1
2
3
.
.
.
15
this node display all of 15 names,

i am trying to do after submit form display only 10 name and after 10 name display more link after click more button show remaining 5 names. Like this:12345678910 more...Remaining 5 names1112131415 how can i do this ? i am using Drupal 6


texts:
This is so simple login request but cannot figure out why I am getting such error message when trying to login using Postman.

I use url http://localhost:8080/user/login?_format=json and input in the header Content-Type:application/json and I have in my body {"name":"user", "pass":"pass"} but I am getting this error message

  {     "message": "The \"user\" parameter was not converted for the path
  \"/user/{user}\" (route name: \"rest.entity.user.GET\")" }

Using curl works though:

curl --header "Content-type: application/json" --request POST --data '{"name":"admin", "pass":"pass"}' http://localhost:8080/user/login?_format=json

curl result:

  {"current_user":{"uid":"1","roles":["authenticated","administrator"],"name":"admin"},"csrf_token":"XXXXX","logout_token":"XXXXX"}


texts: I'm trying to theme a couple of different mails generated by notifications using the mimemail module. Is there a reliable method to find a mails mailkey for use in a template?


texts: How to create path for taxonomy term pages with parent terms if they exist

texts:
I have a taxonomy vocabulary which will only ever contain 2 level deep hierarchy.

I need the url to be just [vocabulary]/[term] for any parent term.

But for a child term I need it to be the following

[vocabulary]/[parent_term]/[term]

Is this possible with a pathauto token? If not, is there another solution to this?


texts: How should I deal with a vocabulary with many terms?

texts:
I'm trying to use Drupal 8, but if Drupal 7 is better for that, I'm ready to go back to Drupal 7.

I have a vocabulary that must contain at least 10,000 terms, but they can also become more than 100,000.  For the sake of simplicity, I chose to make only one vocabulary, without hierarchy.

I quickly reached the limits of my server, and I regularly get WSODs,  especially when I try to edit the vocabulary.

I tried to increase the limits of memory (I am under MAMP), but I still have errors. Here is the error:

  Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in /core/lib/Drupal/Core/Entity/Sql/Sq

How can I avoid these problems?
Is it preferable to split the vocabulary?


texts: Permissions for seeing translated custom menu link items

texts:
I have a problem with custom menu link translations.

Only users with permissions to 'Translate custom menu link' (translate menu_link_content) are able to see the translated strings.

For example if I log in as admin, I can see the link texts changing when switching languages.
But when I switch languages as an anonymous user the link texts fall back to the default language. Translated routes are working correctly.

As a workaround I could just give all users the 'translate menu_link_content' -permission but that seems like a possible security flaw.

Is this a bug or am I doing something wrong here?


texts: Finding a node with a time closest to the current time without being past

texts: I am working on a site which has a Class (ECK) entity type. Each Class may have 0+ "Class Offerings," which are instances of a class at a specific date. I am trying to create a view listing a class and the next upcoming Offering for each class (if one exists). If there is no upcoming Offering, I would still like to list the Class. How could I accomplish this?


texts:
We can describe the configuration variables in the *.schema.yml files but there is a place to describe the State API variables?

I searched in the Core for some State variables and I don't find a description of them. And I searched in the State API docs without luck.

For the moment I add a comment explaining the variable where I set the value but maybe this is not the best approach for it.


texts: Views Load More for products listing page in ajax

texts:
For my ecommerce website i am using View Infinite Scroll module which is for Products listing page lazy loading,

Lazy loading works fine for my products listing view, but my requirement is when i click View More button then only it gets to load more products.

Is there options to call View More button or anyother modules supports for my requirement, please tell me if anyone have any idea means.


texts:
My login form generated by theme_form() contains a password field, which is generated by theme_password().

My goal is to add certain variable into $variables of theme_password(). But ONLY in case, when parent's form NID == 5.


texts:
I am writing a module which includes a form which collects timestamp data.  Part of the submit process is to test if there is already data recorded and if there is then I want then module to create a modal form to check of the user wants the data overwritten.

I have the user input form with various text fields and a submit button.  As part of the form I have included a link to allow me to trigger the modal from within the module code.  The code for the bottom of the form is:

  // submit buttons
  $form['progress_continuing_save'] = array(
    '#type' => 'submit',
    '#value' => 'Save then close',
    '#name' => 'progress_continuing_save',
    '#validate' => array('progress_continuing_save_validation'),
    '#submit' => array('progress_continuing_save_submit'),
  );

  // Hidden links for modal form used to query the user if about to overwrite pre-existing data
  $form['markup_cp_link'] = array(
    '#type' => 'markup',
    '#name' => 'markup_cp_link',
    '#markup' => '
' . l('cp_ajax_link', 'e80progress_cp/nojs', array('attributes' => array('class' => 'ctools-cp-modal'))) . '
',
  );

(I will use css to hide this link). The form works but the link does not create a modal popup, just redirects to another page.  A problem for later.)

The submit function looks like this:

function progress_continuing_save_submit($form, &$form_state) {
  ctools_include('modal');
  ctools_include('ajax');
  ctools_modal_add_js();

// some data manipulation follows to create the prospective field name and content, and recover the nids of the nodes to modified.  This works so I have omitted it.

  //load each node, update it and save it
  foreach ($nids as $key => $nid) {
    $node = node_load ($nid);

  // check if there is already a timestamp.  If there is, then query the user is this should be overwritten.
    if(isset($node->{$cp_field})) {
      jQuery('#markup_cp_link').trigger('click');
    }

When I test this by entering data that will trigger the if statement and clicking the submit button I get a php fatal error:
"Fatal error: Call to undefined function jQuery()"

Which surprises me, especially as I cannot find this specific error on the drupal web.

Any thoughts?


texts: I have a multi site setup with shared users on Drupal 7.22. Is there anyway to share user avatars amongst the sites?


texts:
I have a situation where I would like to add a field to a vocabulary itself.  In other words, I need an editable field on the form that normally appears at /admin/structure/taxonomy/my_vocabulary/edit and not a field that appears each term in the vocabulary.  Unfortunately, the description column in {taxonomy_vocabulary} is too limited for what I need.

What is the best way to go about this?  If possible I would like to avoid making a custom module with a custom table, form-alters for the vocabulary edit page, etc.

Thanks.


texts:
i have a strange issue with a field "date".
First i save it programatically this way :

$now = new \DateTime();
$node->set('field_paiement_date' => DrupalDateTime::createFromTimestamp($now->getTimestamp());
$node->save();

Then when i come on the content type in the back office i've got this value :

And finally when i dump the field in question i got this value :

My current timezone is 'Pacific/Noumea', so the correct value i want to show to the users is the one when i dump the field. What is the best way to do that ?

Regards,


texts: Reuse form from another module in multistep form

texts:
I have built a multistep form, and it works fine.

Now I have installed LoginToboggan module, It has the option of show a unified login/registration form.

I would like to set the last step of my multistep form to this LoginToboggan form. I don't mean redirect the user to the /user/login page, I mean show it in the same path.

Is that possible?

I am trying different variations of this code, but nothing is working:

function simpleexample_menu() {
  $items['simple-example-page'] = array(
    'title' => 'Simple Multi-Step Form',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('simpleexample_form_wrapper'),
    'access callback' => TRUE,
  );

  return $items;
}

function simpleexample_form_wrapper($form, &$form_state) {
  if (empty($form_state['page_num'])) {
// Build page 1
    return simpleexample_form_page_one($form, $form_state);
  }
  elseif ($form_state['page_num'] == 2) {
// Build page 2
    return simpleexample_form_page_two($form, $form_state);
  }
  elseif ($form_state['page_num'] == 3) {
// Build unified login/registration form
   return logintoboggan_unified_login_page();
  }
  return $form;
}


texts: Drupal change the number of items in view PHP

texts:
I have a view page that show 10 elements. The idea is to make three buttons for the user to select if he wants to display 10 elements, 20 elements or 30 elements in the view page. Is there any way to do in PHP? I have search in Google but I can't find anything.

I know I can change in the View config -> Pager:


texts: How to create a primary tab that links to the first accessible seconday tab?

texts:
In D8, for primary tabs that are local tasks an explicit route is defined. If the route is not accessible to the current user, the primary tab is hidden. Typically the same route is used again in a second local task that is defined seperately and has the primary local task as its parent.
In my use case, there are multiple secondary tabs but there is not one of them that will be accessible to all intended users of these secondary tabs. Therefore I don't have a route that I can use as the route for the primary tab, which will reliably open up the secondary tabs for all users who need them.
How do I create a primary local task tab that links to the first (highest weighted) accessible secondary (child) tab?
The only way I know is to create a bespoke route, a controller that loads then local tasks and finds the first accessible child, and an access check for the route that verifies there is an accessible child. This seems quite a lot of work for a relatively simple use case, and I'd have expected a contrib module for it.


texts: No search results display when using core search

texts:
I have added Drupal the search module block and it displays the search form.

When I type and click on search button, it displays nothing, just a refresh in page only.

What do I need to do to get search results to show up? I could use alternative search modules if that is recommended/necessary.

Note: I've already indexed the content. In configuration page, it's showing "your 100% content has been indexed".


texts: Can a published node have a later unpublished revision?

texts:
I haven't used Drupal for a while and I'm wondering whether this has been fixed recently or whether I'm mis-remembering.

I believe that if revision X of a node is published, it wasn't possible to create revision X+1 as unpublished, while still retaining revision X as published.


texts:
In Drupal 7, when theming the comments in my website (comment.tpl.php), I want to print the comment title without a permalink wrapped around as a link. I want the raw title. This should be simple, it seems, but it seems there is no variable for that. print $title will show the title wrapped with the permalink link.

Do I have to mess with template.php to fix that?

I also tried render($content['subject']), but nothing it is printed on the screen.


texts: How to boost search relevance based on certain values using Search API

texts:
I'm using the Search API with a database back-end.

I would like search results that are tagged Editorial to be favoured over results not tagged Editorial. So, for example, if two articles match a search query, and one is tagged Editorial, I'd like to see the Editorial one listed first.

Can this be done?

Thanks.


texts: Can I change the order in which hook implementation by different modules are called?

texts:
In D6, I use a contrib module, but I would like to override a small bit of its behavior. I have a custom module for that, but my implementation of the relevant hook is called before the implementation in the contrib module, and so the contrib module's version "wins".

Is there any way to change it, and force my own hook to be called last?

Here are the specific details:

I would like to remove the default "Anonymous" user name for unregistered users in the comment form.  I created a small custom module, tweak_comment_form, that implements form_alter hook and removes the default value from the name field (see the answers to my previous question about that).

However I also use a contrib module called RealName, which also implements form_alter. RealName does what I want for registered users (replaces user name with "real name"), but re-assigns default value to the name field.


texts: how to adjust installer path in JSON file to customize vendor dir

texts:
Before using 'composer install' I edit extra installers paths. Example: edit /web to /a-custom-docroot folder where is placed core, modules and all other folders.

When possible I would like to create a path for my vendor dir. To create a structure like this:

'- projectroot
--docroot/core
--customdir/vendor'


texts:
How do I get the human-readable label of a bundle from a loaded entity.

Lets say I want to get the label of a node of bundle my_article which is "My awesome article"

// Load a node
$node = Drupal::entityManager()->getStorage('node')->load(4);

print $node->bundle(); // prints the machine-readable name. e.g. 'my_article'.

print $node->getEntityType()->getBundleLabel(); // prints 'content type'.

I am only able to get the machine-readable name of the bundle or the Label of entity ("content type", "taxonomy term", etc), but how do I get the Label of the bundle?

P.S. I would prefer it to not use deprecated classes/functions


texts:
I'm using the CKEditor Module in combination with the Token insert (ckeditor) to show a user property in my body.

It looks like this:

But the results shows just the static text instead of the user property. What am I doing wrong?

UPDATE:

I've also tried to add the Token insert button to my editor like this:

But every time I save this and check again it is switched back.

These modules are enabled:

Entity Tokens
Token insert (ckeditor)
Token insert (text)
Token insert UI
Token

UPDATE:

The test gave me a result like this:

I tried to add a random number in my text field but the result just gave me the static text [random:number] instead of a random number...


texts: How do you display the 'Title' field on display/page for custom content type?

texts:
I created a content type called 'News' and when creating a 'News' entity, I am able to enter a value for the 'Title' field.

However, when I go to 'Manage display' for the content type, the 'Title' field is not listed as one of the fields that can be managed.

Looking at the page/node for a 'News' entity, the 'Title' field only appears in the breadcrumb.  However, I would like to display the 'Title' field elsewhere on the page (not only in the breadcrumb).

Is there a way to achieve this?


texts: How to solve the error while uploading image to nodes?

texts:
I have a content type and it has an image field. I'm using the File Field Paths module for the image field.

I uploaded images for some nodes via Drupal interface but then deleted them via FTP.

Then I'm trying to re-upload images to these nodes via Drupal but it gives this error and couldn't find anything to solve the problem.

How can I solve this problem via Drupal or via PHPMyAdmin etc.?


texts:
I've been tasked with migrating a Tridion based website to a Drupal installation. (It's more of a rebuild really)

I was wondering if any of you have any experience with migrating the data from Tridion in a such a form that I could use it in Drupal. I have never worked with Tridion and don't know the first thing about it (the documentation does not seem to be open?).

So my question to you is: What is the best/easiest/most reliable way to import the data from a Tridion driven application in to a Drupal application? (I would seriously prefer not to do it manually.)

Any general tips you might have are also much appreciated.


texts:
HI i have date field  in user profile,after user has been registered based upon current date for every one week i want trigger a mail to user.
example-you are one week old,two week old,like that i want to trigger a mail to user,thanks in advance.


texts: Commerce: Don't calculate extra shipping for 1st item

texts:
I have a flat rate of $2.50 for every order.
I have extra +$1 for every extra item added to cart.

So, if I order 1 item, total shipping is $2.50, but if I order 2 items total shipping is $3.50.

My problem is that in 2nd case, I get total shipping of $4.50 for 2 items instead of $3.50. It calculates the +$1 for both items.

I added the rule condition Total product quantity comparison to apply +$1 if quantity is > 1. So if I add only item, it doesn't calculate the extra shipping, but as soon as I add more items, it calculates the extra shipping for initial item.

Here's my calculation rule:

I followed this guide: https://vimeo.com/32813567


texts: How to change facebook og:image to post image link?

texts: For the facebook comments/share/etc I get the wrong thumbnail and as far as I've googled, it's due to the og:image meta tag. I'm using Drupal for Facebook module, is there a way to alter it? I found that I have to place 'rel="image_src"' somewhere, but where? At the image tag? And how can I do that using views?


texts: I have recently been looking for module that will allow you to preview the page you are creating, in real time as you are creating it (just like SE questions). I came across the live module, but I realized that it was only for drupal 5 and 6. Is there a similar module that allows you to preview your page live, for Drupal 7?


texts: How to add 'not equal' condition in form #states

texts:
In my form, there are 3 selection list  A, B and C.

I wanna show or hide C based on values of A and B selected.
C should be shown if A's value = 'all and B's value != 'all'

How to set the #state condition in this case?

 $form['C'] = array(
        '#type' => 'select',
        '#title' => t('C'),
        '#states' => array(
            'visible' => array(
                ':input[name="A"]' => array('value' => 'all'),
                ':input[name="B"]' => array('value' => 'all') //???how to set !='all' here?
            )
        )
)


texts: How to give anonymous users access to only certain nodes?

texts:
I am trying to implement the following:
Anonymous users are not allowed to view all nodes but only certain nodes.

I am using tac lite (https://www.drupal.org/project/tac_lite) to make this happen.

However, the only way I am currently able to control permissions to view nodes is the following:

not giving anonymous user the role 'View published content' and
   configuring tac_lite or other content access module to allow access
   to anonymous user to certain pages => doesn't work, access denied
   when testing nodes that user should has access to see

giving anonymous user the role 'View published content' => doesn't work, now anonymous users will see all the nodes regardless of settings of any other content access modules

Problem is not related to tac_lite. It also happens with for example node view permissions -module  https://www.drupal.org/project/node_view_permissions.

Also, when trying to solve the problem this page caught my eye:
https://www.drupal.org/node/270000
It says: "Only users who have 'access content'/'view published content' and not 'administer nodes'/'bypass node access' are eligible for the wild world of node access module control.."

I have understood that access control with Drupal is additive. Thus I should not give the anonynomous user the permission to 'view published content'. Yet, the text from https://www.drupal.org/node/270000 seems to contradict with this approach.

This is what devel node access shows when

I have set 'view published content' permission off for anonymous user
I have configured tac lite to show that page to anonymous user
I visit the page as anonymous user


texts: How to sort in View by last modified/change date - fields not visible in sort criteria

texts:
I'd like to sort content type by the last modified/changed/updated date of content but cannot choose the last modified/changed/updated date in the sort criteria. How can I do this, please? See screenshot:

I've done many things with Views so am surprised that I am puzzled by this one, it seems to be a simple problem - with, hopefully an obvious answer (and a quick win of rep points from a fellow drupal stackexchanger :) )


texts: I use inline images in my article content type. Currently my Teaser settings strip the HTML tags, leaving me with the text of the image tag, which runs into my article text. I'm reading about making a custom filter, but how can I apply the resulting text format only to the Teaser?


texts: Hide body on node edit if user can't access input format

texts: The default behaviour is that a user can't edit a node when they don't have access to its current input format, even if they do have the edit content type permission. I'd like to just hide the body field in those situations. Does anyone know of a contrib that does that? (I'm only interested in the body field, but a more general solution would be cool too.)


texts: views contextual filter by current year missing granularity

texts:
In a view I need a contextual filter: all nodes with creation date in the current year.

In D7 i was able to provide the current date as default value and set a granularity for the date, e.g. the year.

In D8 I don't have any options to granular configure the filter.

Is there any other solution to set this contextual filter?


texts: what is the best solution to create a black list of products?

texts: I'm implementing a site with drupal commerce and the customer needs to have a black list of some products. for example when a product get out of stock and they don't supply it anymore, they want to add that product to black list, only by entering the name of product in a text box. what is the best solution to implement such a thing since they don't want to handle it by a field (e.g a checkbox) in the time of creating a node.


texts:
I am using Drupal 7.40. I just found a redirect issue on my website.

When I enter "http://www.website.com/node/439432" in the browser, it will 301 redirect to "https://www.website.com/myalias.html" correct.

However, I enter "https://www.website.com/node/439432" in the browser, the webpage will not redirect to my URL alias page.
When I check the network, I got 200 status for the node page.


texts: Workflow issue that has been completely baffling

texts:
One of my developers, who has been working with Drupal since he started several months ago, recently ran into an issue with the composer install command that failed with the following error:

After several days of troubleshooting, we still haven't overcome this issue on the laptop machine.

The thing is that his computer is the only one that exhibits this issue. The same commit on other computers (including one with the same OS and one with another) work perfectly, as they have done for months.

The developer is one of several who have worked on the site in the past. As with all our new sites, we include composer.lock files in our repositories. Older Drupal 8 sites, which started development without Composer at all, have since been updated to work with Composer.

The issue seemed to be on the computer in general, since other projects now result in the same error. After days of debugging and eventually trying XAMMP and MAMP (running into other issues, but still coming full circle) - we still had the same issue on this machine (all the while, the same repository working fine on other PCs).

So we wiped the computer and started from scratch (Macos Mojave), installed fresh MySql, PHP, Apache versions and still the same issue.

Like many other developers who made the transition 'off-the-island', I had difficulties with composer at the start, but I have since learned much, and improved the workflow in my team to avoid these issues.

This issue seems not resolvable by any of the conventional means: We've tried updating composer, we've tried clearing the composer cache, we've tried fixing the AMP stack versions to ensure that issues aren't from there.

Googling gives many I don't get Composer, please help links. I haven't come across anything like this anywhere.

We need help to get beyond this. Bearing in mind that two of my team of three can work fine, ti's just one developer who has this issue, and recently at that (so the workflows we have in place has worked fine for months and months, I can't envision that we need to make drastic changes to that).

I also understand that installing docker or some other VM like solution is designed to avoid such issues, but we're not ready to make that transition now for various reasons.


texts: After adding new content type, drupal (7) returns to same window without any notification

texts:
As in the title, every time I add a new content type Drupal returns to the same page and provides no notifications.

Also, the overlay window is full screen width. Any ideas? No error logs.


texts: Missing Main Page Content Block in Blocks List

texts:
I have the region for Main page content in my theme.info file which is regions[content] = Content. But still, in Blocks list, there is no Main page content block. This is causing me problems.

Can i re-create a new block with the same name. What should i do?


texts: What's the proper (seo safe) way to blackout a site (e.g. for SOPA)?

texts:
I want to safely blackout my Drupal site to raise the awareness of SOPA. What's the SEO friendly way to do that?

I'm thinking of putting my site into maintenance mode and just changing the maintenance message.


texts:
I am trying to create a new filter for iframe reponsiveness purposes on admin/config/content/formats/manage/basic_html, but I cannot see the filter. It is listed as enabled filters on admin/config/content/formats/manage/basic_html.

What am I missing?

I took FilterAlign.php as example, and this is the content of the amu_dud_custom_filters/src/Plugin/Filter/AmuDudFilters.php file I am using for the input format filter:

namespace Drupal\amu_dud_custom_filters\Plugin\Filter;

use Drupal\Component\Utility\Html;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;

/**
 * Provides a filter to align elements.
 *
 * @Filter(
 *   id = "iframe",
 *   title = @Translation("iframe"),
 *   description = @Translation(("restrict iframe to 100% height for responsiveness")),
 *   type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_REVERSIBLE
 * )
 */
class AmuDudFilters extends FilterBase {

    /**
     * {@inheritdoc}
     */
    public function process($text, $langcode) {
        $result = new FilterProcessResult($text);

        if (stristr($text, 'data-align') !== FALSE) {
            $dom = Html::load($text);
            $result->setProcessedText(Html::serialize($dom));
        }

        return $result;
    }

Note: uninstalling and reinstalling the module make the enabled filters visible in the list, but a discoveryTrait exception occured.

For making custom filters, is it neccessary to create a plugin manager class?

https://www.drupal.org/node/1637730


texts: Edit a form retrieved using FormBuilder::getForm()

texts:
I found out how to get a node creation form, but I want to display and modify it (e.g. delete some fields I don't need).

This is my code.

public function buildForm(array $form, FormStateInterface $form_state) {
  $entity = \Drupal::entityManager()->getStorage('node')->create(array(
    'type' => node_type_load('friterie')->id(),
  ));
  // OPTIONAL - Set default values for node fields
  // $entity->set('field_machine_name', "value");
  $node_create_form = \Drupal::service('entity.form_builder')->getForm($entity);

  // I can display it with this method, but I don't know how to delete
  // some fields.
  $form['friterie'] = array(
    '#type' => 'markup',
    '#markup' => render($node_create_form),
    '#prefix' => '
',
    '#suffix' => '
'
  );
  return $form;
}


texts:
I have a problem.
I wish I achieve for my preloading fields Content Type (Type list). (pre loader like a webform).
Loading this list thereby synchronize on a table by the user.

I get to create my field and load the first time. But when you synchronize the table, it is necessary that the field starts to date.

How to allow reload value in cck field?

Thank


texts: How do you implement text color on taxonomy terms

texts: I want to implement different font colors on my taxonomy terms. I have installed and configured my color module version 7.x-1.0-rc1 but still I can't find any result.


texts: How to create bootstrap subtheme using sass?

texts: I am using latest bootstrap version(7.x-3.8) . I want create a subtheme by using SASS but i don't know how to proceed.


texts: Any way to override view_mode in twig directly?

texts:
For some reasons, I need to render a content twice, the first one in default view mode, the second one with thumbnail view mode.

In field--paragraph--field-slide--gallery.html.twig I tried to use the following code, however, got a fatal error.

{% for item in items %}
  {{ item.content }}
{% endfor %}

{% for item in items %}
  {% set item.content['#view_mode'] = 'thumbnail' %}
  {{ item.content }}
{% endfor %}

Any another idea to get the similar output?


texts: How can I programmatically remove the file from a managed_file form element?

texts:
I have a form where users upload images.  When an image is submitted it is validated against various criteria.  If the validation fails the user is returned to the form but the failed file is still showing in the file upload element with the remove button.

I have been trying to find a way (with no success so far) to automatically remove the file if it fails validation so the user does not have to do it.

It doesn't bother me but the client has requested it so I need to do it somehow.

Any ideas?


texts: including new field to views_nivo_slider

texts:
I created a slideshow using views_nivo_slider, with two fields, one content: image, and content: description. and I want the description field to be used as a description for the image in slide, but the problem is that description field doesnt work with nivo slider, it's not changing with the image, and I only have some static description fields.
thanks


texts: Is there a way to add new custom selection rules for panels?

texts:
I find the pre-supplied list of selection rules to create panel variants to be quite lacking.  For instance, if I am using panels to override taxonomy term pages, and I have some arbitrary boolean field on each term (say, "Is Blog?"), then I would like to create a panel variant based on this field being equal to TRUE.

However there is no such flexibility when using Selection Rules to create variants.  Am I alone in thinking that this missing functionality greatly diminishes the power of Panels and panel variants?

How would a site builder, or developer, go about creating new "custom" selection rules?


texts: Setting field values on a per-import basis when using Feeds

texts:
A student newspaper I work with is needing some way of importing XML files from InDesign. I'm thinking Feeds/Feeds XPath Parser is the best route for this.

However, one problem with this is that each week the Production Editor will need to import 4-8 XML files, one for each section. "Section" is a taxonomy field in the Drupal "Article" content type, and it's listed nowhere in the XML files they output.

To this end, is there any way to manually set the values of certain fields when importing, on a per-import basis?

I'm thinking this would look like a text box that shows up in Feeds UI when uploading the XML file. Feeds Tamper seems like an idea, but it looks like it's more designed to set default values, and less set specific values on a per-import basis.

Any thoughts?


texts: Migrate module: how to handle adding Redirects and rolling back?

texts:
I'm writing some migrations using the Migrate module. I need to set up redirects after I migrate in an item, but I'm not sure where to perform that action.

I can do it in the complete() function for the migration, which is called after each object has successfully been inserted. At that point, I'd have enough information to programmatically add a redirect.

However, if I needed to roll back the migration, I don't see where I can put in any clean up code to remove those redirects. There are pre and post rollback functions, but those are called before the entire migration is rolled back.

I suppose one alternative would be to, in a pre rollback, query the map table for all the objects and then lookup and destroy the redirects like that. Seems ugly.

I think the best solution here is to have a pre/post rollback function available on a per-object basis.

Anyone run into this previously or have suggestions?


texts: How to automatically unpublish / move to archive an article or node?

texts:
I need to have a functionality that allows users to create an article and choose for how long the  user wants it to be published (for example 7 days or 2 weeks). After this time the node will automatically move to archive.

How can I achieve this in Drupal 7? I know that there were some modules (Node expire?) in Drupal 6, but I am not sure about Drupal 7. Any advice?


texts: How to make a regular expression case insensitive?

texts:
I am working on a Drupal Commerce shipping rule and it needs a regular expression to compare postcodes with the buyers address as below;

/^AB37|^AB38|^AB41/

I am finding this code to be case sensitive and I need it to be more relaxed allowing lowercase or mixed.

I have read I need a 'i' flag, but I am unsure how to apply this.

Could somebody please provide me with an example?


texts: Creating redirects for files (images) on Pantheon

texts:
What is the best way to create 301 redirects on Pantheon for file?  I can create redirects for paths by placing rules in my settings.php:

switch ($_SERVER['REQUEST_URI']) {
  case '/my-path':
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: http://mydoamin/my-new-path');
   exit();
}

This is the redirect I want to create:

a/b/c/document.pdf and e/f/g/document2.pdfboth should be redirected to /new/folder/document3.pdf.

Unfortunately, this won't work with files.

Here is how I test:

Create file test.txt in sites/default/files
Access sites/default/files/test.txt and verify it works
Update settings.php and add die($_SERVER['REQUEST_URI']); and verify you the get uri.

Instead of getting URI I get 404.


texts: References lost when a content type is renamed

texts:
Actually I work in a project developed using drupal 7.
Drupal is totally new for me and sometimes something happens that leaves me stunned…
Today I have discovered something terrifying: when a content type is renamed (and his machine name change), you have to turn the whole project in the parts where the content type was used (in my specific case rules link) because when the machine name change it is possible that the references are lost!!!

You can help me to understand this comportament?


texts:
I have created a custom autocomplete function. The autocomplete field is populated with user name and last name from the content profile.

It is possible that there will be few users with the same name and last name. How I can pass content type ID to Drupal autocomplete, and add this ID to a hidden form field, so I can be more accurate?

I don't want to put the content type ID straight to autocomplete field, so I need some callback to current implementation.


texts: How to use Value Objects in Content Entities

texts:
I have a content entity that contains value objects. How would I go about storing the value objects? What is the best way to do this?

As I see it I have the following options.

Creating a custom TypeData (as described here) to serialize the value objects before persisting.
store the value object properties as map and add computed fields for the getting the hydrated value objects.


texts: Slideshow showing 3 slides (prev - active - next)

texts:
I am trying to accomplish the following:

I have a content type that contains title, img and body.

i want to show the nodes in a slideshow, like for example flexslider.

Nothing special so far.

i now want to show 3 slides at once, the 3 slides cover 100% width, where the 1st slide is the previous slide, the middle one is the active slide and the 3rd one is the next slide.
(The 1st and 3rd slide have some opacity on them to mark the active slide)

i have tried to do this with flexslider, jcarousel and jquery cycle but without aky success.

I managed to show 3 slides at once, but then i cannot navigate through the slides.

Any suggestions on how you guys would approach this would be very welcome!

Thanks in advance!

Edit:

After some more research i created 3 flexsliders (each in their own content pane) that i put into one page manager page.
I then floated them next to each other.

I configred each flex slider to skip 0,1 and 2 slides accordingly.

I now still have the remaining issue of controlling the 3 slideshows through one next and previous buttons.

Any suggestions for this would be very welcome!


texts: How to get all Fields of specific FieldType?

texts:
What I'm trying to do is ->

 $fields = [];
  $fields = $entity->getFieldDefinitions();
  foreach ($fields as $field) {
    if ($field->field_type == 'type') {
      $test = $field->field_type;
    }
  }

Unfortunately I couldn't find a neat method to select my fields by type, so I thought unless Drupal won't give me one I write my own.
But Drupal restrict me on that also with this ->
Fatal error: Cannot access protected property

  Fatal error: Cannot access protected property
  Drupal\field\Entity\FieldConfig::$field_type


texts: How to access parent site products in child site using drupal services ?

texts:
I want to create shopping cart in child sites but using PARENT site database.
I don't want to install UberCart for each child site as i have several child sites.

For example : when i add a product (LAPTOP) it must be available on all child sites with complete detail (Title,Model,Price,sku,etc.....)

Can someone guide me to right path.
Using drupal 6.


texts: How do I add venue location automatically when user selects a venue?

texts:
Does anyone know how I can allow a user to select a venue (such as a night club or restaurant) from a node reference autocomplete field and have the address of the venue also displayed.  This assumes that the venue is already in the system along with the venue's address.

The problem I am trying to solve is as follows:  my website allows users to post a comment about a venue which is already in the website's database.  I want the user to be able to enter the comment and type the name of the venue from an autocomplete box.  I don't want the user to have to enter the address of the venue rather have it auto populate.

Any help on this would be greatly appreciated.

Thanks,

Paul