texts:
Sometimes I need to collaborate with a more frontend-centric developer to help implement a site. So typically they're only changing CSS and minor template changes.

The way we've handled this in the past is that I work locally. When I have everything in a good state, I clone my environment to a staging server. The frontend dev then uploads his changes via sftp.

We'd like to move toward a setup where we're both working locally. The problem of course is keeping the configuration changes all in sync. I have been using Features, but there is still a lot of global configuration that would need to be manually migrated between instances.

I'm not quite ready to make the jump to each of us having a local database. I have considered taking a "half step" by having a shared database that we both connect to over the network.

I've found a few blog posts here and there where people have suggested it, but I thought I'd ask here: have you tried this, and if not, is there's any reason this is a bad idea?


texts: Additional form validation only after passing default validation

texts:
In Drupal 6.25.

I am building a custom user registration form that needs to run some actions on an external service after properly passing default form validation but before creating a new user record in Drupal. So far I am doing the following:

function mbrusers_form_alter(&$form, &$form_state, $form_id){
   if($form_id == "user_register"){
       if($default_form_validation_passed){
           $form['#validate'][] = 'mbrusers_infusionConnect_validate';
       }
   }
}

function mbrusers_infusionConnect_validate($form, &$form_state){
    // Run actions on external service
    if($error){
        form_set_error("", "SET ERROR");
    }
}

I feel like I'm overlooking something, but I haven't been able to figure out what to do. Maybe using validate is the wrong idea? Any help that sets me in the right direction is appreciated.


texts: How to use entity reference field titles in Views exposed and combined filters

texts:
I have two content types: Institution and Contact.

Any number of Contacts are associated with any number of Institutions.

Contacts are associated with Institutions via an Entity Reference field.

I have a view defined as follows:

Format: Show: Fields
Content: Published (Yes)
Content: Type = (Institution)
Content: Title (exposed)
Content: Contact (exposed)
Combined: Titles and Contacts (exposed)

The current sticking point is the exposed filter for Contact (an Entity Reference) requires the integer value of field_data_field_contact.field_contact_target_id, which frontend users have no means of knowing. I need a way of translating a Contact node's Title to the target ID transparently, and this method must also be accessible to the combined field Titles and Contacts.

Result sets for contacts are in the thousands, so providing a dropdown to the view is not workable.

The view type is likely set in stone, because it has been in production for years and has a great many fields.


texts:
What is the best way to find right service for dependency injection? Googling is not efficient yet. For example I spent quite long time figuring out that if I need current request passed to constructor by DI I have too use: $container->get('request_stack')->getCurrentRequest()

Full code example:

/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
        $configuration,
        $plugin_id,
        $plugin_definition,
        $container->getParameter('serializer.formats'),
        $container->get('logger.factory')->get('job_market'),
        $container->get('current_user'),
        $container->get('request_stack')->getCurrentRequest()
    );
}

And I've found above example in drupal class Documentation

Before that I've just found this
services list
but there is no description, no examples, nothing. Just a list with possibility to search.

How do you search for right service provider?


texts:
i´m building a new nap view style. I get the map shown correctly, but only without the data of the view :-(.

class OpenlayersViews extends StylePluginBase {
  /**
   * Whether the display allows the use of a pager or not.
   *
   * @var bool
   */
  protected $usesPager = FALSE;

  /**
   * Whether the display allows the use of a 'more' link or not.
   *
   * @var bool
   */
  protected $usesMore = FALSE;

  /**
   * Whether the display allows area plugins.
   *
   * @var bool
   */
  protected $usesAreas = FALSE;

  /**
   * Does the style plugin support grouping of rows.
   */
  protected $usesGrouping = FALSE;

  /**
   * Does the style plugin for itself support to add fields to it's output.
   */
  protected $usesFields = TRUE;

  /**
   * {@inheritdoc}
   */
  public function evenEmpty() {
    // Render map even if there is no data.
    return TRUE;
  }

  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['openlayers_map'] = array('default' => 'none selected');
    return $options;
  }

   /**
   * {@inheritdoc}
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    $openlayers_map_options = [];
    foreach (openlayers_get_map() as $key => $map) {
      $openlayers_map_options[$key] = $this->t($map['label']);
    }

    $form['openlayers_map'] = [
      '#title' => $this->t('OpenLayers Map'),
      '#type' => 'select',
      '#options' => $openlayers_map_options,
      '#default_value' => $this->options['openlayers_map'],
      '#required' => TRUE,
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function render() {
    dsm("OpenlayersViews:render");
    $map = openlayers_get_map($this->options['openlayers_map']);
    $mapid = Html::getUniqueId('openlayers_map');
    $features = array();

    /*
     * Here i need a function to get the result of the view
     */

    $element = openlayers_render_map($mapid, $map, $features, FALSE);
    return $element;
  }
}

I do not know, if render is the right position for getting the data.
So maybe some of you can explain, what is the next step to do.

best regards


texts: How do I get masonry to run again once twitter widgets have rendered?

texts:
I am using the Masonry API and Masonry Views modules to get a view to render nicely, it works well.

I'm using oEmbed Core to render the URL provided by the user into an embedded tweet for a specific node type.  That also works fine.

When the tweet shows up in the view however, my blocks get overlapped because the twitter widget is rendering after masonry has run.  How do I rerun masonry once the tweet has fully rendered?


texts:
I have two content types.

Images
Question

The question content type is meant to allow users to ask questions about the photos in the images content type.

I added a node reference field with "reference from url" type selected to the question content type. I checked "create link on the full view" during the setup. This works correctly if I go to an "images" node.

However, I am displaying the "image" type in a view. So far I can not figure out how to get a link to the question content type to show on the view. I have tried this using a "references" display type of the view, but still nothing.


texts: How to filter admin/structure/block per role

texts:
I use block access to determine which block a role can edit. I enabled Access the block administration page and View all blocks permissions so that my blocks_editor role now  can access the admin/structure/block page.

But the page displays the complete and huge  list of blocks, with a configure link when allowed to do so, as in screen capture below :

How can I filter/restrict this output to the list of blocks the role has permission to edit ?

Or as an alternative, how can I programmatically generate in a block, the links to blocks a role has access to ?

Thank you.


texts: How to fallback to URL alias of language in Drupal 8?

texts:
I have a node type with translation enabled for all fields including URL alias.

mysql> select * from url_alias where source='/node/22';
+-----+----------+----------------------+----------+
| pid | source   | alias                | langcode |
+-----+----------+----------------------+----------+
|  21 | /node/22 | /foo/bar             | en       |
|  45 | /node/22 | /bar/baz             | fr       |
+-----+----------+----------------------+----------+

I have language prefix as negotiation method.

When I access this node in /en/foo/bar, can see english version. But when I change the URL to fr/foo/bar, I get page not found. I would like to redirect to fr/bar/baz this case.

Is there out of box solution to get this functionality?


texts: Drupal theme layout - recommendation based on example needed

texts:
I am going to create a website that will have a layout similar (almost identical) to this one:
http://www.statoilfuelretail.com
Meaning:

position of all the menus/elements
picture in the background two
columns in the middle

All the graphics will be made by graphic designer - all I need is the theme (template) with layout I could use. Would be great if it was a Drupal 7 theme.

My question is: Which themes can you recommend (free and paid) that could be easily configured to match the layout presented on the website above?


texts: How to add the "user role field" in View showing users

texts:
I created a view showing users. Then I have a list of users. I need to add a field to show the user role. I clicked add field but I don't see this field. Do I need to add a relationship to have this field available?

Update: I have Aggregation enabled.


texts: Commerce 2 | Quantity Dropdown with Default Values -> Error

texts:
I need to allow the costumers to choose specific quantities for specific type of products but I would like to avoid adding 2 extra modules to my website ( Commerce Extended Quantity & Extended Number Field). So I used a form alter function like here Set default "Quantity" dropdown select in product. Commerce Kickstart.

The issue is that the input is transformed to a dropdown but when the form is submitted, a blank page appears with the message "The website encountered an unexpected error" and the error in admin/reports/dblog is Cannot unset string offsets in Drupal\Core\Field\WidgetBase->extractFormValues()... Here is the code I use:

function mymodule_form_alter(&$form, $form_state, $form_id) {

  if (strpos($form_id, "commerce_order_item_add_to_cart_form") !== false) {

  // Change widget type of quantity to select list
 $form['quantity'] = array(
'#title' => t('Quantity'),
'#type' => 'select',
'#datatype' => 'integer', // <-- I added this one to fix Notice: Undefined index: #datatype in commerce_cart_add_to_cart_form_validate() when you click add to cart button
'#options' => array(
  1 => '1',
  2 => '2',
  3 => '3'
)
);

 }}

Does anybody know if there is a way to fix this error? Thanks!


texts:
I've created a custom route for each nodes, let's say /custom-page/{node}, which renders some specific stuff from a Controller.
On this custom page, I'd like to automatically display the same local tasks as displayed on nodes canonical pages (In my case : View, Edit, Delete, Devel)
I know I can set dynamic local tasks using a Deriver in links.task.yml but how can I load local tasks from another route ?
Or maybe there is a way to tell Drupal to display local tasks as if it was for the route "entity.node.canonical" ?
Thank you for your help !


texts:
There Drupal links, such as sitename.com/?q=user or sitename.com/?q=user/register that a user may use for direct login or registration to my site.

What I want to do is to disable those types of direct links.
I have placed my custom blocks for login and sign up in the first page, so if a user hits the URLs above, a strange view of mysite is displayed because it has 2 registration forms: One exists because of my custom block and another exists because Drupal's default registration form

Does anyone know how could I disable or remove all the links of type sitename.com/link and the only link that can direct to mysite to be sitename.com?
I know that seems hard because it maybe is not configured in Drupal's layer, but on HTTP protocol.
So if that is not possible, can you think of any solution to avoid the above mess?


texts: Does a twig template know in which region it is?

texts: Or: how do I output conditional classes depending on the region a twig template is being rendered?


texts:
I've created a view where it displays all created articles by the current login user. named as "my Articles".

Now, I need to add a node/add/articles (which let me add a new article) together with the "my Articles"(view). where the "node/add/articles" is above of "my articles".

I don't have any idea how could I add an node/add/articles inside a view.

I need two solutions.

One is by not using a module and the other is using a module.


texts: How to update a record with drupal_write_record?

texts:
I do not understand how to update a record with drupal_write_record.

I want to update column "vid," in table "node," with the value $value, where "nid" equals $key.

This is what I have, and it doesn't look right, nor does it work. I can't find any examples.

$table = 'node';
$record = new stdClass();
$record->vid = $value;
drupal_write_record($table, $record, array('nid' => $key));

To be clear: I want to insert $value into column "vid" where the value $key exists in column "nid"; this is all happening in table node.


texts: Rewrite output of a field and include another one templated

texts:
As a newbie with Drupal 7, I'm wondering if it is possible to rewrite the output of a field, including another field templated.

Right now, my rewrite looks like :

[field_a] [field_b]

And it is displaying field_b as a raw value and not using its template.

Is it possible to display [field_b] using its template ?

Thanks !


texts: How to get a count of groups that user has joined?

texts:
I have used OG module to implement the Groups functionality. I want to get:

Count of all groups that are there on the website
Count of groups that a user has joined

How can I do this?

Note:
My preference would be to use an existing function (if there is any).


texts: Free tagging (term) not translated when creating a node

texts:
I have a bundle type "article", which is translatable in 2 languages (English (=default) and French). The user can select the language when creating the article. It also has a "free tagging field", which refers to a taxonomy (Which is also translatable).

When the user creates an article in the French language, and adds a new tag (which does not exists yet), the tag is created in the default language (=English).

How can i make sure that the new tag is created in the language the user selected on the node creation page?


texts: Possible to save plain text value when entity reference doesn't exist?

texts:
I have a user entity reference field. When I type in a name, but the entity/user doesn't exist I would like to save the name as a plain text value.
Is this possible?

Thanks.


texts: Blank row when adding field collection item

texts:
I have a Content Type with a Field Collection that can have multiple entries.
Whenever i click on "insert new element" i get instead a blank row with a "delete" button but no fields to fill. (site is in italian, Elimina means "Delete" and "Aggiungi un altro elemento" is the "add new item" button)

Things worth mentioning:
1) This happens when i'm in the frontend template (the node can be edited by anonymous users) but not when i'm in the administration pages, it works fine there
2) This field collection has some special fields: 1 Simple Hierarchical select, 2 computed fields and 1 Geofield. Apart from the SHS field the other fields are not editable by users (and even if they were, those fields are automatically generated so there won't be a widget)
I have tried to change the SHS widget with other widgets but it didn't work.
3) There are other field collections in this content type and adding a new item there works fine and shows me the form
4) I have checked through Firebug the json returned by the ajax call used to add a new item and it contains the HTML for the new form, but it looks like it's not appended to the page
5) Another thing that may be an issue is that on the frontend i'm using jquery 1.9 while in the administration pages i'm using jquery 1.7 (the site uses a bootstrap template) and i have noticed that in the ajax response it says jquery_version: 1.7, but this won't explain why other fields work.
6) i have tried changing the fields order putting the fields that work over this one  but that didn't work either. Those field collections that worked kept working and this one that doesn't work was still not working


texts: How can I override the search result page title dynamically?

texts:
In my Drupal 8 site, I am using the default search page. If I enter a keyword, for example article, the search result will be listed under Search result.
I want to change that to Search result for Article (keyword).
How can I achieve this?


texts: i'm using display suite and views in one of my teaser content type and i'm trying to add an EDIT button right in the teaser, but i can't find the function to do this. So i came here to ask for help. Can you help me? Thank you


texts:
I have built a content type named "Project" which will showcase some projects by the members of a group. I have used a user reference field in that content type, so that the contributors of a project can be enlisted.

Now I am trying to put in the user's profile page the links to the projects he contributed to. How can I achieve that?


texts: How do you properly use "Fetch entity by id" in Rules in order to access its fields?

texts:
I am trying to set up a RUle that loads and node (Fetch entity by id) and then, on another action, I want to access fields of the fetched entity. However, while I see the loaded node on the data selector of the next actions, I cannot seem to access its fields, only its "normal properties".

Any ideas?


texts:
I'm trying to detect when a form is submitted so I have written this code:

jQuery('#formid').submit(function(event){
        console.log('submit handler');
})

But nothing happens and the form is submitted normally. The form is rendered as usual and the submit button is generated with this code:

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Enviar'),
    '#attributes' => array('class' => array('btn','pull-right')),
    '#ajax' => array(
        'callback' => 'contact_form_ajax_submit',
        'wrapper' => $result_wrapper,
        'progress' => array(
          'type' => 'none',
          'message' => NULL,
        ),
    ),
  );

I don't know why my jquery script doesn't intercept the submit. I've checked the form id (obviously) so I ask for help because I have no idea about what could be the problem.

Thanks

Link: http://seminolaproducciones.com/contacto


texts: Site shows an empty page and a 500 internal error

texts:
My site doesn't show any page except an empty page. I changed the .htaccess file, but the sites shows a 500 server error.

What can I do?

The server log just shows the following line:

  [Tue Aug 27 12:07:52 2013] [error] [client 2.178.69.124] File does not exist: /home/pcctvir/public_html/favicon.ico


texts: How do I implement hook_finder_goto_alter()?

texts:
I'm having a bit of trouble with troubleshooting a module I am working. I am trying to modify a module to redirect traffic but even though its enabled it doesn't seem to do anything.  I've had problems in the past with using hooks and i'm not sure what I'm doing wrong.

I am basically using the finder module and here's the code to redirect:

function test_finder_goto_alter(&$result, $finder) {
  /* Redirect to a different page in the current directory that was requested */
    drupal_goto("testpage");
}

I see the module in modules and enabled it but it still doesn't redirect the way I want it to.  Do you have any suggestion on what I'm doing wrong? I don't think its specific to this module I think I might be doing something wrong in general.


texts: Additional fields for Ubercart uc_order_product

texts:
I need to add fields to the Ubercart entity uc_order_product. I was looking into the function field_create_instance, but don`t know exactly where to use it. I believe I should attach the field I want to the uc_order_product entity using field_create_instance.

The 'uc_order_product' definition in uc_order.module doesn't have a fieldable => TRUE definition. May I add that definition from my custom module and tell uc_order_product is fieldable? This is uc_order_product entity definition in the uc_order.module.

'uc_order_product' => array(
  'label' => t('Order product'),
  'base table' => 'uc_order_products',
  'controller class' => 'UcOrderProductController',
  'metadata controller class' => 'UcOrderProductMetadataController',
  'entity keys' => array(
    'id' => 'order_product_id',
    'label' => t('Order product'),
  ),
  'bundles' => array(
    'uc_order_product' => array(
      'label' => t('Order product'),
    ),
  ),
  'view modes' => array(
    'full' => array(
      'label' => t('Normal view'),
    ),
    'cart' => array(
      'label' => t('Cart view'),
    ),
  ),
  // Entity API callbacks.
  'access callback'   => 'uc_order_order_product_access',
  'save callback'     => 'uc_order_product_entity_save',
  'deletion callback' => 'uc_order_product_delete',
)

Finally, I am trying to hook to this entity when it gets updated (hook_entity_update, hook_entity_presave) but they never get called on uc_order_product update. How can I hook to this entity when it is being saved, or when it has been saved? Thank you!


texts: What is best method to use for multiple databases on one server?

texts: Do you create an extra database for each site running on same drupal core or use replication, what is the best practice at the outset for setting up multisite databases on a vps centos server?


texts:
I have a custom drush command that does some pretty heavy node creation etc. I would like to disable certain modules only for the duration of the script to improve their performance.

I can not do a drush dis module_name before running my command because I need the modules to be active on the site while the script is running, but not active for the runtime environment of the current command.

I would rather not have to hack core, but from what I can see, I'm probably going to need to alter something in either module_list() or drupal_load() since neither of them have any hooks.

Is there any way to do what I'm after without hacking core?


texts: How can I indent parts of a Views field?

texts:
I have a content/node View listing several node fields in an unformated list. The fields are displayed inline since they combine to make a message to users; on their own the fields don't mean much.

As you can see there are 3 fields above; user picture, user name, and the comment body. I have marked the order and the areas of the 3 separate span classes. The problem of course is that when field 3 has more than one line of text the subsequent lines are not indented enough and overlap field 1. I have tried using margin-left and padding-left in combination with the text-indent property, but since field 3 is inline the CSS only ends up indenting the first line instead of the lines after the first as I need. I can display field 3 as a block and this does allow me to have better control, however it places the field on a separate row, and as mentioned previously I need the fields to be displayed inline so that they combine to make a message. In other words, if you see the red line below I would like the field 3 text to wrap and indent in a way that it stays to the right of the red line for lines 2 and after.

So it would end up looking something like below, but of course with the beginning of the lines not clipped.

The only thing I can think of is having 2 copies of field 3, both of which are trimmed. Therefore the first copy would be trimmed to only show 1 line and the second would be trimmed to show everything after the first line, however the problem is that I'm not sure how to trim the beginning of a field. So how can this be achieved?


texts: shadowbox + content page showing full content in other language when not logged in

texts:
I have a dual language site (English and Arabic). I am using shadowbox + content page modules to display node content (without header, footer,menu sidebars etc) in an overlay.
Everything works like a charm in both languages when im logged in but when im logged out and viewing the site in arabic I get the following strange behavior:
When I click a node to view it, the full page shows up in the overlay window which is not desired. The bigger other problem is that the content that is shown in the overlay is in English when it should be in Arabic.
Please let me know how to solve this problem or let me know if you have different approaches to achieve the same outcome.
Many thanks in advance


texts: Hook_add_to_cart_form_alter() actions works only if product is on stock

texts:
I modified a module Commerce Product Comparison by adding hook_form_alter(), so I am adding a new button before and actual "Add to cart" button. Everything works nicely except only when product is on stock. When product is not, Add to cart button is greyed out and also my newly added button does not work. I strongly feel this is something to do with my code for adding a new button. This is the code:

function commerce_product_comparison_form_alter(&$form, &$form_state, $form_id) {

    // checking if add_to_cart form is present, also we do not want a button displayed in product page, but only in views
    if (strstr($form_id, 'commerce_cart_add_to_cart_form') && !isset($form_state['context']['view_mode'])) {

        $entity = (object)$form_state["default_product"];
        $product_id = $form_state['default_product']->product_id;
        $nid = "";

// query for getting NID of product so it can be passed after
          foreach (commerce_info_fields('commerce_product_reference') as $field) {
            // Build query.
            $query = new EntityFieldQuery;
            $query->entityCondition('entity_type', 'node', '=')
              ->fieldCondition($field['field_name'], 'product_id', $product_id, '=')
              ->range(0, 1);

            if ($result = $query->execute()) {
              // Return node id.
              $nid = reset($result['node'])->nid;
            }
          }

        // those values works properly even when product is not on stock, I tested it
        $form['entity_type'] = array(
            '#type' => 'value',
            '#value' => 'commerce_product',
        );
        $form['entity'] = array(
            '#type' => 'value',
            '#value' => $entity,
        );
        $form['nid'] = array(
            '#type' => 'value',
            '#value' => $nid,
        );

        // Check if the current product already exists in compare list.
        $exists = commerce_product_comparison_list_exists('commerce_product', (object)$form_state["default_product"]);

        // Check if the compare list isn't already full (4 products max).
        $full = commerce_product_comparison_list_is_full();

        // I strongly feel there is something wrong with this piece of code, adding the button itself, maybe callback?
        $form['add_to_compare_list_form'] = array(
            '#type' => 'submit',
            '#disabled' => $exists || $full,
            '#value' => $exists ? t('In comparison') : ($full ? t('Comparison list full') : t('Add to compare list')),
            '#submit' => array('commerce_product_comparison_add_form_submit'),
             '#ajax' => array(
              'callback' => 'commerce_product_comparison_refresh_comparison_form',
              'wrapper' => 'cpc-wrapper' . $form_state['default_product']->product_id,
            ),
            '#prefix' => '
product_id . '">',
            '#suffix' => '
',
        );

    }

}


texts: Adding a second search for a specific content type

texts:
I am currently trying to build out a Video-oriented component on a longform article based site, and one of the requirements call for a Video segment/block that can be placed on any page, and it has a search bar that loads any videos with similar titles.

I know that Drupal includes search, and it can be granulated to a specific content type. But I was wondering if there was any way I could implement a separate search function that inherits the existing search logic, and search for content of this specific content type. Is it as simple as altering the logic inside the search form with hook_form_alter, or are there more intricacies involved?


texts: file upload using CCK not showing nid reference

texts: I have uploaded the image using CCk  the file path is stored in file table but where i can find the nid and fid for the uploaded file?


texts: How to delete children when main entity is deleted?

texts:
I am looking for the best way to delete children of my main entity when i delete it.
I have 2 entity type :

commandes_entity
commandes_ligne_entity ( entity reference to commandes_entity )

The only way i have found is to create a hook_entity_delete :

Edit :  This is how i delete children :

function boutique_commandes_entity_delete(Drupal\Core\Entity\EntityInterface $entity)
{
  $query = \Drupal::database()->delete('commandes_lignes_entity');
  $query->condition('commandes_id', $entity->get('id')->value);
  $query->execute();
}

Is there another way (maybe better) for delete children ?


texts: Remove output of author username and blog link of news snippets from search results

texts:
I currently have this in template.php to remove the 'username's blog' link from blog entries.

function phptemplate_links($links, $attributes = array()) {
    unset($links['blog_usernames_blog']);
    return theme_links($links, $attributes);
}

How would I go about using unset to remove the 'username's blog' link from the search results page?


texts: This form was missing from the server cache on Drupal 8

texts:
On my site I do this:

I got a form with this field:

'myfile' => [
  '#title' => $this->t('MyTitle'),
  '#type' => 'managed_file',
  '#upload_location' => 'public://myfolder',
],

And MyController:

$myform = \Drupal::formBuilder()->getForm('Drupal\[mymodule]\Form\[myclassform]');

This variable I pass to Twig template.

On my template:

{{ myform }}

Every is ok.

But when the page is cached I got this error when i upload a file:

An unrecoverable error occurred. Use of this form has expired. Try reloading the page and submitting again.

I dont use memcache or CacheRoute, only drupal cache for anonymous user.

How I fix that?
Is possible not cached the form?


texts: How to open the view and edit page inside the colorbox?

texts:
I am using an full calendar with event as a node.

I have disabled the overlay module.
In the full calendar settings->colorbox options, I have enabled 'open events in a colorbox'

Now when I click on any events in the full calendar it opens the node view page in colorbox which has two tabs view and edit .

When I click on edit tab , it opens into a new page instead of loading inside the colorbox.
How can I achieve loading of view and edit tab inside the colorbox and prevent the redirect which occurs when clicked on edit page? .


texts: Performance of site when loading 3000+ variables

texts:
I test all modules (custom + contrib) in one drupal base itself which has resulted in lot of variables.
I was just curious what happens if live site had 3k variables ?
Since all variables will be eventually global variables will it not require huge amount of PHP memory ? or is it not limited at all  ?
What is the alternate here ? cache_get with new cache table instead of variable_get every where


texts: How do I create content importing data from an Excel file?

texts:
I am using Drupal 6 and created a custom content type. I have an excel sheet that has more than 2 lacs entry. It is not easy to enter manually.

Is there is any way to this, either programmatically or from the UI?


texts: How can I skip field validation if the field is hidden?

texts:
I get a node form with node_form and then I render it with some modifications.

One of the modifications is that I duplicate the fields so I have the same fields twice. One field is disabled and the other same field is enabled, I also have a checkbox to show or hide the disabled/enabled field with #states. So I have only one field visible at time, for example, I have a disabled field visible, if I check the checkbox then disabled field is hidden and enabled field is shown.

The problem comes with the #requried = TRUE fields. When I submit the form it validates the two fields (enabled and disabled) but I only want to validate the visibile field. So, if it's visible the disabled field, I don't want to validate the enabled field.

What is a good way to achieve this?


texts: How to add the value of a drupal field to the class of a wrapper div

texts:
Working on a clients drupal 7 site, I have a content type that is promoted to the front page. The content type has a list field, I want to use the value of that field to add a class to the wrapper div on the node teasers populated to the front page. For example the html output would be something like this:

<div class="field_value">
content
</div>

I'd prefer not to have to use a view or nodequeue to do this as it's easier on the client administering their site to simply promote items to front page.

I've been trying to add the class in the node.tpl.php file but for some reason I just can't get it to work. I've tried creating a preprocess variable in the template.php file but all I get in the output is: div class="Array".

Does anyone have any ideas on why I'm just getting the word "Array" output? or any ideas on how to solve my problem?

Thanks


texts: Display Location of node Title different in Teaser vs Full

texts:
I created a custom template, node--article.tpl.php which renders my field_image field first, then shows the submission date, then displays the title and then renders the rest of the content.

This works very well in Teaser, but when I click on the node and view it in Full, the Title is rendered at the top. It is above the field_image instead of where it exists in the template. My template is just a slightly altered version of the Zen node.tpl.php. Why is the title being rendered up top instead of where it is in the template?

Here is my template:

<article class="node-<?php print $node->nid; ?> <?php print $classes; ?> clearfix"<?php print $attributes; ?>>

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

  <?php if ($display_submitted): ?>

      <?php print $pubdate; ?>

  <?php endif; ?>

  <?php if ($title_prefix || $title_suffix || $display_submitted || $unpublished || !$page && $title): ?>

      <?php print render($title_prefix); ?>
      <?php if (!$page && $title): ?>
        <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?>

      <?php endif; ?>
      <?php print render($title_suffix); ?>

      <?php if ($unpublished): ?>

<?php print t('Unpublished'); ?>

      <?php endif; ?>

  <?php endif; ?>

  <?php
    // We hide the comments and links now so that we can render them later.
    hide($content['comments']);
    hide($content['links']);
    print render($content);
  ?>

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

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


texts: Prevent comments containing html links from beeing validated

texts:
Seems very simple and I thought a module for that would be easy to find but no..
I've got a website that's beeing infested by spambots in node comments.

You're probably going to tell to disable full HTML input format, but this doesn't block comments, it just stops the links from linking; but the pollution is still there..

My normal users usually don't post any links. When I say links I mean html links:

Blah

So all I want to do is block all comments containing one or more of these html links.

I found blockanonymouslinks but this seems to only work for anonymous users. My spammers are logged-in users.

Any help would be much appreciated. Thanks!


texts:
I have imported a .pot file using the _locale_import_read_po function, like this:

$po_files = file_scan_directory('/', '/.*\.pot$/');
if (count($po_files)) {
  require_once DRUPAL_ROOT . '/includes/locale.inc';
  $po_file = reset($po_files);
  $translations = _locale_import_read_po('db-store', $po_file);
}

Now, what I want is to convert all the imported strings into a PHP array.

Is there any way to do that, and how?


texts: How to remove the title from a youtube video when using D7 + media module?

texts:
When I add an youtube video to a "blog post" content type I automatically get youtube's title/url placed above the video (see screenshot below).

I have Drupal 7.7 + Media 7.x-2.x-dev + Media Youtube 7x-1.x-dev installed.
I have added to the "blog post" content type a new "video" field with type "multimedia asset" and widget "media file selector".

I would really appreciate any advice on how to remove or change this title.


texts:
I have a an array like this from json.
[terms] => Array
  (
    [0] => Array
      (
        [id] => 1
        [Name] => term 1
      )
    [1] => Array
      (
        [id] => 2
        [Name] => term 2
      )
    [2] => Array
      (
       [id] => 3
       [Name] => term 3
      )
    [3] => Array
      (
       [id] => 4
       [Name] => term 4
      )
  )

I want to migrate them as taxonomy terms.
name:
    - plugin: sub_process
      source: terms
      process:
        value: Name

but this only migrate the firs term. term 1.
how will I migrate all?


texts:
I am using Views 3 in Drupal 7 to show parent taxonomy terms using nested relationships.

This involves setting up a parent relationship, then a parent relationship of that parent, and then a parent relationship of that parent - this goes five levels deep and appears to be working well.

I have set the view to output the term name associated with each relationship, and with Views set to not render anything if the result is empty, I am being left with exactly what i need - a list of all (well, five levels right now) hierarchical parent terms. I have also set views to link each of these term names to their respective pages - and this is what is causing me problems...

Thing is, I want to see these fields as an unordered list. Setting the format option in Views to HTML list obviously sees all of my fields as part of the same result, and thus makes them the same list item.

The first thing I tried was to hide each field from display and rewrite everything using a custom text field:

[Term_Name_Level_1]

[Term_Name_Level_2]

[Term_Name_Level_3]

[Term_Name_Level_4]

[Term_Name_Level_5]

This works, but when I'm not five levels deep in the hierarchy (which is most of the time), I end up with empty li tags, as so:

(I put periods in here to show the effect, as the blank list items don't show here otherwise)

.
.
.
Grandparent term name
Parent term name

The next thing I tried was to rewrite each individual term name field, adding li tags around each one

[Term_Name_Level_1]

then rewriting the output as follows

    [Term_Name_Level_1]
    [Term_Name_Level_2]
    [Term_Name_Level_3]
    [Term_Name_Level_4]
    [Term_Name_Level_5]

This almost worked, as if there is no result, the whole field is left out including the tags. The problem here is that the link to the term page is wrapping around the li tags, like so:

Grandparent term name

Parent term name

Thats obviously not what I need, so can anyone think of a way to get Views to output each field as a list item, but without printing empty tags when there is no result? I must say, I have a horrible feeling that I'm overlooking something!

Is there perhaps a way to get Views to output a raw link to each term page, so I can rewrite the lot? I see that there is a 'Taxonomy term: Term edit link' field available, but not a link to the actual term!

Thanks!


texts:
I'm setting up an audit log for a large network of Drupal 7 sites with dozens of editors and 5 developers.

These events are already covered:
Content Create, Content Update, Content Delete, User Login, User Logout, User Create, User Update (hook_user_update).

But I'm having a hard time logging:

Change in permissions
Change in settings

Any ideas how to go about logging that to watchdog?


texts:
In my page.tpl.php I'm doing this to display one of my view:

print views_embed_view('teaserview', 'default');

That gives me the following html output:

Edit view

But the only thing that I really need is

Is there a possibility to modify the views_embed_view call so that I get only the needed data?

There would be the possibility to modify all the views .tpl.php files but I hope there's an easier way to do this.

I also read about the semantic views module but I didn't understand how to configure my view with it so that i get only the needed markup as output. it didn't seem to have any effect.


texts: Displaying static text on a view that disappears after hitting 'Search'?

texts:
I have a view with a Search block exposed to users. What I would like to achieve is:

I would like to display a text in the View's body itself under the Search box. This text should disappear once a user enters a term and hit 'Search".

Is this doable? I hope someone can help me out.

Thanks


texts:
I inherited a site that has all images in directory stored in /sites/all/images/, rather than /sites/default/files/images/.

I installed the modules CKEditor - WYSIWYG HTML editor and IMCE image/file uploader and browser (configured correctly), then set a custom file path /sites/all/images/.

However, when I go to insert an image into the page, IMCE file browser loads and shows the directories on the left-hand side, but it lists the directory as being EMPTY when the directory is actually full of images.

I don't want to move the directory to /sites/default/files/images/ because I don't want to break all the image links currently in the site's content.

Can anyone tell me how to get IMCE to recognize the files in the directory and allow me to insert them into content?


texts: Node image instead of pointer icon in openlayers map

texts:
Does anyone know a way to change the pointer icons to node images?

Like the image below

I really like to have a little preview image from the node instead of hundreds of same looking pointers.

Any ideas?


texts: What's the equivalent of cache_clear_all()?

texts: What's the equivalent of cache_clear_all() in Drupal 8?


texts:
Drupal 7 has the field group module which contains a horizontal_tab.js file.

Inside this file i found this written

// If the current URL has a fragment and one of the tabs contains an
// element that matches the URL fragment, activate that tab.
if (window.location.hash && $(window.location.hash, this).length) {
   tab_focus = $(window.location.hash, this).closest('.horizontal-tabs-pane');
}

Can someone explain how this would work and what exact url i should call so that a particular tab is activated.


texts: Pathauto doesn't work anymore when i change the default language

texts:
I've got a big problem this morning.

I'm working with english as default language Administration » Configuration » Regional and language. It's much more easy to me to work with the interface in english.

But this morning i have to change the default language to french because my boss want the interface in French (and the website is almost finished)

But unfortunately, all my alias doesn't work anymore like before www.example.com/my-article is becoming www.example/node/5.
More precisely, it's only alias from content type who doesn't work fine because taxonomy term are ok.

Does someone has a idea why when i changed the default language in Administration » Configuration » Regional and language (english to french) my alias didn't worked anymore?


texts: Should dependent libraries list all dependencies?

texts:
If I have a library called foo and it depends on jquery I will list is a dependency.
But what if I have libraries bar and baz that depend on foo and also jquery. Do I only add foo as a dependency or should I also add jquery as well? What is the concensus on this?


texts: User referencing another user causes unexpected error

texts:
I have a Drupal 7 site with a bunch of users. Some are clients and others are sellers (role). I put an entity reference field field_seller on the user account form which filters users with the seller role.

Now, when applying a seller to a client and the client logs in, he gets an error

  "The website encountered an unexpected error. Please try again later."

The following error is shown in the log:

  Recoverable fatal error: Object of class stdClass could not be
  converted to string in _theme_table_cell() (row 2418 of
  /mysite.com/includes/theme.inc).

Any idea why this happens?


texts: Generating Ubercart orders programmatically

texts:
I am trying to generate ubercart orders programmatically in Drupal 8 and am doing it this way:

$order = Order::create(array(
  'uid' => $uid,
  'order_status' => uc_order_state_default('in_checkout'),
));
$order->save();
$product = Drupal::entityTypeManager()->getStorage('uc_order_product')->create(array(
  'qty' => 1,
  'order_id' => $order->id(),
  'nid' => $product_nid,
  'title' => $product_node->get('title')->value,
  'model' => '1001',
  'cost' => $product_node->get('display_price')->value,

));
$product->save();
uc_order_product_save($order->id(), $product);
$order->save();

Can someone please suggest what wrong I am doing here? Do I need to extend to some class in particular? This order is not generated.


texts: How to invert a contextual filter which is a taxonomy term ID?

texts:
I have a view that displays a number of nodes according to a taxonomy. I do this by adding a Contextual Filter -> Has Term ID and to get this value from the URL to filter out all nodes related to that taxonomy.

What I need to show in a view is precisely the opposite. I need to show all nodes except the nodes filtered out by the contextual filter of term ID. In a way, I need to show all content NOT tagged with the taxonomy term in the URL.

Does anyone know how this can be done?


texts: How to add a custom read more link in views?

texts: I have used views to create a page to look like the below screen shot. I have used trim to limit the description of the body to 200 texts. I have added "Link" and have termed it as "Read more". Is it possible to change the "Link" text in our webshop as "to shop"? I want this change to happen only for that specific item. For the rest it should be "Read more"


texts: How to customise order cart customer information pane

texts:
During checkout, I can add fields to billing or delivery information, but how can I add fields to customer information, or create another customized pane for them?

Example:

Student Information:

Name: Skill interest: Phone: Email: etc.....


texts: Quickly build a Drupal website from another Drupal website

texts: I have an existing website in Drupal, say abc.com, and it's in english. Now I want to quickly build this website for different domains. The layout remains same, but the language and images may change. How can I do this and how quickly can it be done? Should anything be done on the first site so that building the second site becomes easy like profiling or something?


texts: How do I get the current path of a block?

texts:
I need the current path, where my custom block is visible.
So, i have written this code

class MyBlock extends BlockBase {

  public function build() {
    $currentPath= \Drupal::service('path.current')->getPath();
    return array(
        '#markup' => $currentPath,
    );
  }
}

It is displaying the path where it was visible for first time; if I visit node/1, node/2, node/3 consecutively, it will print node/1 every time, because that was what I visited that first.
It might be happening due to block caching, but how do I get the path for the page showing the block?


texts: I need to create ubercart orders for a bunch of users. Can this be done with views and VBO or do I need to make a custom module for that?


texts:
I'm trying to display a quick summary of the number of different types of products on our site.

The summary contextual filter does this... but it adds hyperlinks to the items and I can't turn that off, and I can't customise the HTML tags or rewrite the output. Is there any
to do that?

Thanks


texts:
I am trying to make a multilevel menu using a Bootstrap theme on Drupal 8. I have created the menu and activated the "Show children" flag for all submenu containers but only first level submenus are showing.

I have tried http://knackforge.com/blog/pathirakaliappan/create-multi-level-bootstrap-menu-in-Drupal-8, but it doesn't seem to work: The submenus aren't being generated at all in the HTML.

I am using Drupal 8.1.2 and the 8.x-3.x-dev version of Drupal Bootstrap


texts: Responsive image gallery with unique URL per image?

texts:
I've been tasked to create a carousel that would have a unique URL per panel.

The panel would have to contain multiple pieces of info (each piece a link), and so would be views based.
the panels would have to be able to rotate.

Royal slider seems like it may be up to the task: http://dimsemenov.com/plugins/royal-slider/

My question is - are there any recommendations for other modules? module combos? custom script?

I'm using D7.23

Thanks!


texts: Why does loadMultiple load 1000 nodes 9.2 times faster than loading each node one by one?

texts:
I have always known that loading multiple nodes at the same time is faster than loading them one by one.

What I wasn't aware of, is the huge performance difference between the two ways of loading nodes.

I made an example to see the difference. Here's my result:

Load 1000 nodes one by one:

$start_time = microtime(TRUE);
foreach (range(1, 1000) as $nid) {
  $node = \Drupal::entityTypeManager()->getStorage('node')->load($nid);
  if ($node) {
    print_r($node->id());
  }
}
$end_time = microtime(TRUE);
print_r($end_time - $start_time);

Execution time: 10.7266 seconds.

Load 1000 nodes at the same time:

$start_time = microtime(TRUE);
$nids = [];
foreach (range(1, 1000) as $nid) {
  $nids[] = $nid;
}

$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);

foreach ($nodes as $node) {
  if ($node) {
    print_r($node->id());
  }
}
$end_time = microtime(TRUE);
print_r($end_time - $start_time);

Execution time: 1.1664 second.

How can loadMultiple be 9.2 times faster than loading the nodes one by one?

Is it the connection between Drupal and the database? What other factors are slowing down the process when loading the nodes one by one?

I have cleared the cache after every request to avoid the loaded nodes being cached.

I used the microtime function to calculate the exact execution times.


texts:
Is there a way to expose content from other databases to Drupal so Drupal sees them like nodes? Importantly, this should work without making actual node entries in the Drupal database.

This would mean writing a module which specifies how to translate my proprietary content into Drupal node format, so one could write theming functions for that content, or use the Views module on it, etc.

Currently my module just displays the content directly on its own, without bothering to provide seamless Drupal integration into Views.


texts: How to display the child menu items in a select list?

texts:
I want to display the menu items in a select list.
$items = \Drupal::service('menu.parent_form_selector')->getParentSelectOptions('main:', ['main' => 'Main']);

It gives the following select list options.
array:7 [▼
  "main:" => "<Main>"
  "main:menu_link_content:e92098f4-98c8-47d7-9697-a00da00ff6ce" => "-- Menu item 1"
  "main:menu_link_content:4552ac61-8b04-4785-913f-9deb6eae6a1f" => "---- Menu item 1 child"
  "main:menu_link_content:1eb2237a-eb55-4225-bdd1-078bb9db799b" => "------ child of child "
  "main:menu_link_content:2d105a33-9405-428f-81da-04ff2e8fb2da" => "-- Menu item 2"
  "main:menu_link_content:7619a127-3b25-4480-be88-7cfa1280180d" => "---- Menu item 2 child 1"
  "main:menu_link_content:2b1c8d61-bf3f-4245-8bee-ae404e5be528" => "---- Menu item 2 child 2"
]

Which is correct. Now I want to display the children of a specific menu item in another select list. Suppose Menu item 1. How will I do this?
I tried this code:
$menu_parent_selector = \Drupal::service('menu.parent_form_selector')->getParentSelectOptions('main:menu_link_content:e92098f4-98c8-47d7-9697-a00da00ff6ce', ['main' => 'Main']);

But it gives me the same results. All the menu items of the main menu.
Is there any way to get the children of the Menu item 1 only in the same format?
array:2 [▼
      "main:menu_link_content:4552ac61-8b04-4785-913f-9deb6eae6a1f" => "---- Menu item 1 child"
      "main:menu_link_content:1eb2237a-eb55-4225-bdd1-078bb9db799b" => "------ child of child "
    ]

Is there any hint to build it custom if nothing is available?


texts: How to overriding specific Omega_Kickstart CSS files in a subtheme?

texts:
I'm using Commerce Kickstart (Version 2).

I created a new theme, which is basically a copy of the commerce_kickstart_theme. So it's a subtheme of omega_kickstart which is, itself, a subtheme of omega v3.

Even though the child theme has various css files for global, narrow, normal, it -looks- as though the theme actually reads in the css from the parent theme... ie. the OMEGA and is ignoring same-named files in my subtheme.

Eg. if I have a file global.css in my subtheme, it is ignored and the omega_kickstart/global.css is used instead.

The same goes for the various alpha files. Eg. I copied alpha-mobile.css into my theme folder. But the file being @imported is the /omega/alpha/css/alpha-mobile.css.

My understanding is that if a same-named css file was in your theme directory it -replaced- the file from the parent. But that doesn't seem to be happening.

Any ideas?


texts: Redirect the anonymous users to the login page when they try to vote a node

texts:
I am using Vote Up/Down for voting on nodes. I would like that anonymous users could be see the voting widget, but they should be first redirected to the login page, before they vote. I tried setting the permissions as follows:

use vote up/down on nodes - checked for anonymous user
When I try to vote as an anonymous user I get the following error.

  An error occurred at /vote/node/1470/-1/vote/helpful/59a7d98542754cb9fd01758fbbe95a3a.

  Error Description: 403: Forbidden

use vote up/down on nodes - checked for anonymous user; view up/down count on nodes -  checked for anonymous user
I still get the same error.

Does anyone know what to do to redirect anonymous user to the login page when they try to vote?


texts: How to add flag on each field in a node in Drupal?

texts:
I have created a membership based website in Drupal 7. I want the user should create his portfolio and upload his work images. So i created a content type called portfolio having image field with unlimited upload option and gave access to that role. Also i want the user to like other user's images. So i created a View in which all portfolio images displays. For like button, i used Flag module.

Now problem is, there is only option Node Flag in views that shows flag only on 1st image in that node. I want flag on each image field in views like Facebook. So technically user should create multiple nodes if flag need to appear on each image. But its very much complex. Is there any way to add flag on each field in content in views?


texts:
I'm looking to switch my Site Name (admin/config/system/site-information) depending on what url I'm at.  So if I was at www.example.com/cat I could have the site name be Cats and if I was at www.example.com/dog I could have the site name be Dogs.

Doe anyone know of a module that has this functionality?

I know that this is similar to a multisite, but I just need to create a bunch of tiny blogs and a multisite seems like overkill.


texts:
I'm trying to change a label of Drupal 8's contact form ('Your email address'). The label is defined /core/modules/contact/src/MessageForm.php, but obviously I don't want to change this in core.

$form['mail'] = array(
'#type' => 'email',
'#title' => $this->t('Your email address'),
'#required' => TRUE,
);

In Drupal 7 I always used string overrides but the module isn't available for Drupal 8 yet. How can string be overridden in Drupal 8?


texts: How do I translate view's page path alias that has a dynamic path?

texts:
I have a view that has a dynamic path and I want to create a path alias for each language installed on my site. Following the answer on How do I translate view's page path alias? I'm able to create a path alias when no dynamic path is involved in the view, but when a contextual filter with dynamic path is in the view I can't find how to create the path alias.

The view is a simple view like this:

So, how do I translate view's page path alias that has a dynamic path like /jobs/% ?


texts:
I have been tasked with updating my code shop's long-abandoned Drupal 7 codebase to the most recent Drupal core, in order to bring in the latest security fixes (it's currently using v7.67). But all the knowledge I had about how to use drush seems to now be completely worthless.
What is this "composer" thing that it keeps complaining about? We never used anything like that back when we were still developing this Drupal 7 project (we abandoned PHP and switched to Python/Django a few years ago). I tried installing Drush through composer require drush/drush, which worked (and dumped a load of new code into my repo for some reason...). But even though I'm running it in the root of my repo, it says this:
! [NOTE] Drupal root not found. Pass --root or a @siteAlias in order to see Drupal-specific commands.

When I pass the root folder name via --root, it says the same thing. Thus, my old strategy of just running drush up drupal, which worked dozens of times in the past, no longer works.
Could someone who understands how Drush works these days explain to me how I can use it to update my codebase? Or maybe there's a way to install an old version of Drush that can actually understand my repo's layout? That'd be even better.


texts: Post request to create node in drupal 6 from external site does not create node but returns HTTP 200 ok status

texts:
I have been able to configure a rest Rest server from my Drupal 6 site using services 3.0 module.

I am able to make a get request successfully with an http response code 200 OK with the data related to the node id in json format. Following image shows this

But when I make a post request to create a new node using the same url and method as post, the response code is http 200 OK, but the new node is not actually created in Drupal 6. Following image shows this.

Can someone correct my methodology please. Is there something wrong with my post request? I am using services 3 on a Drupal 6 website. I need to make such a post call from an external site to drupal 6.

And below is the image showing response text for this post call:


texts: Flexslider view with pictures from nodes tagged with a taxonomy term

texts:
I need to group 10 images (random choice) of nodes belonging to a content type, and belonging to taxonomy foo with the term bar, in a Flexslider. How can I  setup that content pane view ?

Precision : each node can have one up to ten images.

I created a content view,

with that image field
Filtered by content type
Sort criteria : Global Random
Contextual filter : Content : taxonomy foo(provide default value : taxonomy term ID from URL)

If I use format unformatted list / display all items, it gives me a list of expected images. But if I use Flexslider format, it groups all the images of a single node in each slide ! I understand that the query result is grouped by nodes, when I just need its images ...

View preview


texts: Image field: mark an image as a "cover photo" with a radio button

texts:
In a given content type, I have three Image fields, each of them set to Unlimited cardinality. It's like a little gallery with 3 fixed albums: when using Display Suite, I have the ability to limit the number of values getting displayed, I limited it to 1:

and this way only the first image gets displayed. The fields link to a page created by Views, which shows the images separately as a gallery, etc...

Here's an example of the result:

What I would like to achieve is to provide a radio button near the images to the user when editing these fields to be able to select which image I would like to show as a "cover photo" without reordering the images. In the example above, I can only show the 1st one in the "album".

Do you have any ideas for that? Is there a module for this task, or do I have to code?
Can I solve this problem without converting my solution to other gallery solutions? I was thinking about Flag module, but I couldn't find out how I could use it for this task. I'm using File entity (fieldable files) module, which may help in solving this question.


texts: Synchronize drupal database with a traditional database

texts:
I have a installation of plain Drupal 6 with its own database. I have also another database,  different from the one used by Drupal.

I want to connect this database (with its own structure, tables and relations) with the database used by Drupal, and use the information in that database for creating views, for example.

I have a table "Persons" with 2 fields (Name, and Age) in the external database. I want to transfer (or connect, or synchronize) that information to my database in Drupal, or handle this information with some module. In my Drupal site, I have a "Persona" content type with two CCK fields: Name, and Age.

Is there any existing solution?


texts: How to change rest export views field alias programmatically

texts:
When using REST export view, and Fields format, under Settings I can change alias for each field.

How can I do the same with code?


texts: Permission to edit own unpublished content (only)?

texts:
I have a content type Poll with an unpublished option. When a user creates a poll the poll remains unpublished for 1 hour and after that it becomes published (done with rules).

What i want to achieve is: Give the Poll author the permission to edit his poll node only while it is unpublished. When it gets published this permission will expire.

How can i work this out?


texts: Add odd and even to field--item with twig template

texts:
I'm trying to add "odd" and "even" to an image field (which contain multiple images) theming each item :

{% for item in items %}
  {% set zebra = cycle(['odd', 'even'], loop.index0) %}
{% endfor %}

{% for item in items %}

{{ item.content }}

      {% endfor %}

For an unknow reason the result of this code is :

What am I doing wrong ?

[EDIT]

Proper working code is :

{% for item in items %}
        {% set zebra = cycle(['odd', 'even'], loop.index0) %}

{{ item.content }}

{% endfor %}


texts: Remove default › between breadcrumbs in panels breadcrumbs

texts:
Is it possible to remove the › between the breadcrumbs in the panels breadcrumbs module?  I tried modifying the part of the .module file shown below (which I know is bad practice, but I just  wanted to try it out) but that did not work.

// Finally, render the breadcrumb
foreach ($breadcrumbs_info as $crumb) {
if (isset($crumb['href']) && $crumb['href'] == '<none>') {
  $crumb['localized_options'] += array('attributes' => array(), 'html' => TRUE);
  $breadcrumbs[] = '<span ' . drupal_attributes($crumb['localized_options']['attributes']) . '>' . ($crumb['localized_options']['html'] ? $crumb['title'] : check_plain($crumb['title'])) . '</span>';
}
else {
  $breadcrumbs[] = l($crumb['title'], $crumb['href'], $crumb['localized_options']);
}

}


texts: BlockContent::load for addtoany_block returns null

texts:
I am trying to load the "AddToAny Buttons" block of AddToAny module inside a controller. My idea is to render the block content as a part of the page. I have verified the block id of "AddToAny Buttons" block in the Addtoany module's block plugin file which is 'addtoany_block'. But BlockContent::load('addtoany_block') returns null.
Could somebody help me identify where I'm going wrong?
Here is the code snippet

$block = \Drupal\block_content\Entity\BlockContent::load('addtoany_block');
$render = \Drupal::entityTypeManager()->
getViewBuilder('block_content')->view($block);


texts: related news and articles block on content page based on tags

texts:
I have to create a block that contain five article based on the tags which is get displayed on the content page.Below is the view i created.

The output of this view is

here in the sidebar the article having the same tag in the content page is shown,but the content is getting repeated twice.can anyone tell me why the content in the block is getting repeated


texts: Is there for modules the same as theme_get_setting() for themes?

texts:
I am using variable_get('name-of-setting', 'default-value') to retrieve module/theme settings in several locations in code.

The purpose is to keep default settings in one locations preferable in .info file. I am able to this for themes:

variable_get('name-of-setting', theme_get_setting('name-of-setting'));

Here the theme_get_setting() retrieves the settings from the theme-name.info file:

settings['name-of-setting'] = some_value

Can i do the same for modules? What is the API to retrieve settings from module .info file? If not, how do you handle module default settings to avoid it scatter around code?


texts: How to sign-in a user based on custom HTTP headers in Drupal 8?

texts:
I would like to sign-in a user based on some custom headers in the HTTP Request.
Let's say i have an administrator account in Drupal with the login "admin".
If i send a request to Drupal with a custom header (X-USER-NAME: admin), i would like to be logged in with this user.
I tried to develop a custom authentication module to deal with this use-case like so :
  public function applies(Request $request) {
    $name = $request->headers->get('X-USER-NAME');

    return isset($name);
  }

  /**
   * @inheritDoc
   */
  public function authenticate(Request $request) {
    $name = $request->headers->get('X-USER-NAME');
    $user = user_load_by_name($name);

    return $user;
  }

I then alter system routes so i can access them with my new authentication method with an event subscriber :
class AdminRouteSubscriber extends \Drupal\Core\Routing\RouteSubscriberBase {

  /**
   * @inheritDoc
   */
  protected function alterRoutes(RouteCollection $collection) {
    foreach ($collection->all() as $route) {
      $path = $route->getPath();
      if (
        ($path == '/admin' || strpos($path, '/admin/') === 0)
      || ($path == '/node' || strpos($path, '/node/') === 0)
      || ($path == '/user' || strpos($path, '/user/') === 0)
      ) {
        $route->setOption('_auth', ['headers_auth', 'cookie']);
      }
    }
  }

}

I can now access a route to add a new content (let's say a new article), but when i submit the form to create this new content, i get the following error : "The form has become outdated. Press the back button, copy any unsaved work in the form, and then reload the page.".
With my new authentication method, no cookie is set in the answer. I guess that there is some kind of CSRF token verification when submitting the form.
I am a newbie in the Drupal world, am I on the good way or should I use a different approach ?
Thank you for your help :)


texts: Set image as permanent in custom block plugin, temporary URI

texts:
I'm building a custom block plugin with an image upload which is working fine except for the fact that although the $file->status is set to permanent the URI still comes up as temporary.

This is the code I'm using:

namespace Drupal\eight\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\file\Entity\File;
use Drupal\image\Entity\ImageStyle;

class MyBlock extends BlockBase {
  public function defaultConfiguration() {
    return [
      'upload_image' => '',
    ] + parent::defaultConfiguration();
  }

  public function blockForm($form, FormStateInterface $form_state) {
    $form['upload_image'] = [
      '#type' => 'managed_file',
      '#title' => $this->t('Upload Image'),
      '#default_value' => $this->configuration['upload_image'],
    ];

    return $form;
  }

  public function saveImage($fid) {
    $file = File::load( $fid );
    if ($file) {
      $file->setPermanent();
      $file->save();
    }
  }

  public function blockSubmit($form, FormStateInterface $form_state) {
    $fid = $form_state->getValue('upload_image')[0];
    $this->saveImage($fid);

    $this->configuration['upload_image'] = [$fid];
  }

  public function build() {
    $config = $this->getConfiguration();
    $image = '';

    $file = File::load($config['upload_image'][0]);
    if ($file) {
      return [
        'logo' => $file->getFileUri(),
      ];
    } else {
      return [];
    }
  }
}

Inspecting the $file object before and after the saveImage method the status is actually changing from 0 to 1 but the URI I get is still pointing to the temporary file scheme.

URI: temporary://xxxxx.jpg

URL: xxxxx.xxx/system/temporary?file=xxxxx.JPG

What would be the way to correctly store the image as permanent?


texts: How can I package a module with a jquery-plugin in a sober way?

texts:
I'm almost getting crazy with this...

My Problem: I have a module with its own css and jquery-plugin. When i add it directly to the theme.info via scripts[] everything is fine. But when i try to integrate it with  drupal_add_js() from out of the mymodule.module I get a Reference Error

  jQuery.noConflict();

how do i load the jquery plugin from my module in my relative path mymodule/js/javascript.js?

I already checked out what others wrote. The plugin starts with
(function($).. and ends with })(jQuery)

What else can I do?


texts: How do I retrieve the field data  associated with an entity, using EntityFieldQuery?

texts:
I'm still confused about the entity concept in Drupal 7.
I have a node type audio with an MP3 field. I'm able to use EntityFieldQuery to find all the  audio nodes, but I need the URL of the MP3, which is stored in the "file_managed" table, and I don't find a way to retrieve it.

This is what I have:

// Query audio nodes
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'audio')
  ->propertyCondition('status', 1);
$result = $query->execute();

There is no URL in the $result array. At least I can't find it there; I only get the fid.


texts: Get values from unlimted field programmatically in node_presave hook

texts:
I have created class content type and set Allowed number of values to unlimited" to "Division" field
Now I want to get "Division" field values programmatically in node presave hook I'm using below code.

function example_node_presave(Drupal\Core\Entity\EntityInterface $node){
  if($node->bundle() == "class") {
     $getDivison = $node->get('field_class_division')->target_id;
   }
}

If i print $getDivison then I get 739 only.


texts: Maintain same node ID's when importing nodes

texts:
I am using Node Export with Features module, and then importing content while installing my profile. All works fine, but I want the node ID's to be retained while importing. I want it to be in same order as the source site.

Can I do this?


texts: Creating multiple blocks programmatically

texts: I am writing a custom module for Drupal 7. I need to create 5 different blocks with the module. Drupal has the hook_block_info and hook_block_view hooks which create blocks. How can I add multiple blocks since these hooks allow only one block per module?


texts: I'd like to allow HTML in my webform field descriptions. I don't need an editor of some sorts; just the basics like  and  tags and stuff. How can I edit my webform to allow these tags in the description field?


texts: Move title below image in Views grid format with CSS

texts:
I'm trying to customize a View that I've created showing all of one published content type. The grid is set to have 3 columns. I also have it set as a Rendered Entity with view mode "Teaser" so that it displays the image and content.

Using CSS I've been able to modify the header size, hide the words in the teaser while leaving the image, and modifying the size of the teaser image.

I'd like to be able to display the title underneath the image rather than on top, as is the default. There is no setting in the Views module to achieve this that I can find, so I'm doing some modifications using CSS. I'm having some trouble figuring out which divs to use to do so (there seem to be quite a lot that don't move around so easily). The divs are currently positioned like so:

I did find that assigning display: table-header-group and display: table-footer-group to the images (l-slat__media) and header text (l-slat__header) respectively worked, after assigning display: table to article. But they were tiny and about 25% of the original size. Not really sure why this is happening.

Any input as to what I might be able to do to put the header text below the teaser image would be appreciated.


texts:
My site is built on Drupal 7, and a number of my .js scripts are throwing this exception: Uncaught TypeError: Property '$' of object [object Window] is not a function. After some research, I think this is related to the new jQuery namespace update, but since we didn't write the scripts, I'd rather remove them than make changes.

I've traced the references to the $scripts variable in html.tpl.php, but haven't been able to trace back any farther. I've examined .info files for additions to scripts[], drupal_add_js(), drupal_add_library(), preprocess and process function calls, and found nothing.

Has anyone had similar issues with removing JS file references, and could you give me a rundown on Drupal's script inclusion process? I found the methods above digging through docs and help sites, but I'm still not clear on how it all comes together (i.e. if scripts[] variable additions are added before drupal_add_js() calls, etc.).


texts: What hook should I use to define a class?

texts:
If I want to define a class, like the one below, for a custom module, and make it available to all the functions in my module, which hook should I use?

class foo {
  public $bar;
  function display_bar() {
    return $this->bar;
  }
}


texts:
I am working to change the standard display when pressing the "People" button.
Instead of showing "Username" I want it to show a custom field. For example "Last name".

I almost made it work, but the pager is not working. When I click page 2, the same info shows as page 1. Sorting is working though.

Here's the slightly changed code, which originated from the core user module.

<?php
function user_custom_form_user_admin_account_alter(&$form, &$form_state, $form_id) {

  $header = array(
    'field_lastname_value' => array('data' => t('Username'), 'field' => 'dn.field_lastname_value', 'sort' => 'asc'),
    'status' => array('data' => t('Status'), 'field' => 'u.status'),
    'roles' => array('data' => t('Roles')),
    'member_for' => array('data' => t('Member for'), 'field' => 'u.created'),
    'access' => array('data' => t('Last access'), 'field' => 'u.access'),
    'operations' => array('data' => t('Operations')),
  );

  $query = db_select('users', 'u');
  $query->condition('u.uid', 0, '<>');
  $query->leftJoin('field_data_field_lastname', 'dn', 'u.uid = dn.entity_id');
  user_build_filter_query($query);

  $count_query = clone $query;
  $count_query->addExpression('COUNT(dn.entity_id)');    // or u.uid, does not make any diff.

  $query = $query->extend('PagerDefault')->extend('TableSort');
  $query
    ->fields('u', array('uid', 'name', 'status', 'created', 'access'))
    ->fields('dn', array('field_lastname_value'))
    ->limit(20)
    ->orderByHeader($header)
    ->setCountQuery($count_query);
  $result = $query->execute();

...

    $account->name = $account->field_lastname_value;
    $options[$account->uid] = array(
      'field_lastname_value' => theme('username', array('account' => $account)),
      'status' =>  $status[$account->status],
      'roles' => theme('item_list', array('items' => $users_roles)),
      'member_for' => format_interval(REQUEST_TIME - $account->created),
      'access' =>  $account->access ? t('@time ago', array('@time' => format_interval(REQUEST_TIME - $account->access))) : t('never'),
      'operations' => array('data' => array('#type' => 'link', '#title' => t('edit'), '#href' => "user/$account->uid/edit", '#options' => array('query' => $destination))),
    );

      ...
}
        ?>

Can anyone help? I have been struggling with this for hours. I did try changing the position of pagerDefault and TableSort to all kind of possible places like in the beginning before the join, after the join, tried with other joins then just left join, I'm stuck. Maybe I have to call SELECT FROM the custom field table and join the users table? But that's odd.
Any help is really appreciated.


texts: hook_feeds_processor_targets_alter - how to set a value not in the feeds source?

texts:
I need to import a csv that has only two fields (date and name) to a content type that has 3 fields:

date
name
file

The file field should be set as the name of the file being imported.

My code until now is this:

function MYMODULE_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
  $targets['my_feed'] = array(
    'name' => t('field_filename'),
    'description' => t('This field has the csv file name.'),
    'callback' => 'mymodule_import_filename',
  );
}

function MYMODULE_import_filename($source, $entity, $target, $value, $mapping) {
    $my_filename ='file.csv';
    $entity->{'field_'.$target}[$entity->language][]['target_id'] = $my_filename;
}

Where am I doing a mistake? Is this the way to import a value outside the file being imported?

Thanks.


texts: Create imagefield with maximum number of values programmatically

texts:
I've created an imagefield in my own module, like this:

$form['heading_img'] = array(
    '#type' => 'media',
    '#title' => t('Heading image'),
    '#default_value' => isset($content['settings']['heading_img']) ? $content['settings']['heading_img'] : '',
    '#theme' => 'media_widget',
    '#media_options' => array(
      'global' => array(
        'types' => array('image'),
        'schemes' => array(
          'public' => 'public',
        ),
        'file_extensions' => 'png gif jpg jpeg',
        'min_resolution' => '1920x550',
        'max_filesize' => '750 KB',
        'uri_scheme' => 'public',
      ),
    ),
);

Sometimes I need more heading images. Is it possible to make this field unlimited?

So you could click on a button: Add an other image. Something like this.


texts:
I have an old D6 site. I created a form with hook_form with very many fields (197 rows * 6 columns = 1182 fields). It works good and form submit works properly.

But when I add a new, 7th column to the form and the fields number becomes 1379 the form submit is not firing.

I do not see any errors or warnings, php memoty limit is set to 256M and post max size too. But submit handler simple does not fire.

What can be a cause?


texts: How to delete specific nodes from a custom module?

texts:
I have built a custom nodule that prints a button to a block on the user edit page using panels. Right now it just grabs the userid and spits it out to a drupal message.

My goal is to have the button delete some nodes of a specific content type, that don't have a custom field flagged, that are authored by the user being edited.

I'm kind of lost as to where I even start. I'm assuming I'll have to do a SQL statement

function custom_module_form_submit($form, &$form_state) {
  $uid = $form_state['values']['uid'];
    $sql = db_query("SELECT * FROM {node} n WHERE n.uid = $uid && n.type = 'custom_module'" );

while ($n = db_fetch_object($sql)) {

  $nid = $n->nid;
  $title = $n->title;
  node_delete($n->nid);
  print 'Deleted '. $i . ':' . $nid . ':' . $title . '<br />';
  $i++;
}
drupal_set_message('Deleted '. $i .' nodes.');
}

However I keep on getting an error saying 'Fatal error: Call to undefined function db_fetch_object()'


texts:
Does anyone know if there's a module out that would provide the functionality for displaying multiple nodes within a node i.e. similar to how a blog looks with its articles, simply a page that displays a number of teasers that link directly to other nodes.

The big thing would be the CMS part and the ability to add existing nodes within a node. By this I mean like the way you would with a field, except in this case it would be a list of existing nodes.

So far my attempt at such as set-up has been to use the field collections module to put a few fields together like title, image, long text, etc, then use this field collection as part of a basic page. This does exactly what I'm after except all we are doing here is giving the content manager the ability to supply a path to an existing node so there is not relationship here at all.

A content manager could delete the node and forget to delete the teaser on another page that was linking to it.

Please could I stress that 'Node embed' is not an option or anything similar because its just not practical for clients to use such methods. It needs to be very simple that almost requires them not to think.

Any suggestions please?


texts: Access Denied when I try to flush cache or change theme

texts: This is a very odd issue. Logged in as admin. All permissions given to admin. But Access Denied page when I try to flush cache or change theme. I can flush the cache with drush. I tried switching theme to garland and back again. I tried creating a new admin user, didn't work. I tried disabling recently enabled boost module, to no avail.


texts: Escaping special characters in custom submit handler redirect URL?

texts:
My submit handler contains a redirect to a URL formatted thus:

mysite.com/node/123/edit?step=step_2

and my problem is that it's appearing in the browser bar as:

mysite.com/node/123/edit%3Fstep%3Dstep=step_2

which messes up my redirect.

How do I escape the characters "=" and "?" for use in a URL for redirection from a custom submit handler?


texts: Open a Make Meeting field inside colorbox

texts:
I am using the Make Meeting Scheduler for my site, which is a Doodle-like scheduler module. This module makes it possible to insert a field (only field, not available as block) into a node. However, I need to open this field inside Colorbox.

I know a possible workaround would be to create separate nodes with only the Make Meeting field and then connect them to the original nodes where I need them, but this is definitely not an elegant solution.

I'm really not good with Drupal templates and that is why I haven't come up with a better solution. I suppose I should edit the template, print a link with the class "colorbox-load" and have that link point to the Make Meeting div. Problem is, I am currently clueless as to how to do that.


texts: Drupal commerce email order notification not sending properly

texts:
On the rule of sending email order notification I just changed the "FROM:" of the send mail, instead of the email of the website I want the email of the anonymous customer from a custom field of billing information I created then this will be sent to the admin.

This is my current rule:

{ "commerce_checkout_send_an_order_notification_e_mail_admin" : {
"LABEL" : "Send an order notification e-mail ADMIN",
"PLUGIN" : "reaction rule",
"WEIGHT" : "4",
"OWNER" : "rules",
"TAGS" : [ "Commerce Checkout" ],
"REQUIRES" : [ "rules", "commerce_checkout" ],
"ON" : { "commerce_checkout_complete" : [] },
"IF" : [
{ "entity_has_field" : { "entity" : [ "commerce-order" ], "field" : "commerce_customer_billing" } },
{ "entity_has_field" : { "entity" : [ "commerce-order" ], "field" : "commerce_line_items" } },
{ "entity_has_field" : {
"entity" : [ "commerce-order:commerce-customer-billing" ],
"field" : "field_email"
}
}
],
"DO" : [
{ "entity_fetch" : {
"USING" : {
"type" : "commerce_customer_profile",
"id" : [ "commerce-order:commerce-customer-billing:profile-id" ]
},
"PROVIDE" : { "entity_fetched" : { "customer_profile" : "customer_profile" } }
}
},
{ "mail" : {
"to" : "[site:mail]",
"subject" : "[customer-profile:field-full-name] - Event: [customer-profile:field-event-name]",
"message" : "Customer Name: [customer-profile:field-full-name]\r\nCustomer Email: [customer-profile:field-email]\r\nCustomer Contact Number: [customer-profile:field-contact-number]\r\nEvent Date: [customer-profile:field-event-date-no-end-date:event_date]\r\n\r\nPackages Selected:\r\n[commerce-order:commerce_line_items]\r\n\r\nOverall Total: [commerce-order:commerce_order_total]",
"from" : "[customer-profile:field-email]",
"language" : [ "commerce-order:state" ]
}
}
]
}
}

When I checked the log report of the website it says "Successfully sent email" but I never received the email. but whenever I change the "FROM:" to blank or [site:mail] I will receive the email notification. Why is that? The token I used for the "FROM:" is exactly the same as on the message and it's correct.


texts: Can we migrate basic Metatag data without customization?

texts:
I'm ought to Migrate-upgrade from D7 to D8 and deleted all modules besides Metatag (and its dependencies --> Ctools and Token).

You might have an idea how could I keep all the basic Metatag data for my nodes? By "basic" I mean only to the Page-title, Page-description and Meta keywords (And maybe also the Abstract tag); Nothing beyond that.

AFAIK, as for 2016 there is no migration-path for the Metatag module and people should generally copy their metadata manually; This situation kind of negates the whole migration experience since the all issue is to migrate nodes with their most common data.

Will cherish any advice.


texts: How to export (send) image from website to Instagram?

texts: I'm working on a social network website based on Drupal7, This social network is based on photos and users may upload photos and they are accessible in their profile. I need to equip the site to contact to the Instagram profile of users and they can send images from my website to their profile in Instagram. I checked the Instagram Block and Instagram Feeds and Drupalgram modules, but from I understand these modules only import images from Instagram, non of them export images to Instgram. How do I can send Images from my website to Instagram?


texts: How can I have Exposed filter of Flag type in views?

texts:
I want to add Exposed filters of flag types in Views.

I have many flag types and I want users to be able to select their favorite Flag type to show result.


texts: How to display popup ad only once in any session

texts:
I want to show popup ad once only no matter how many pages are visited by site visitor and the following code in page.tpl.php is causing to show ads more than once. How to correct it?:

<?php
  $showadzedo = false;
  if( !isset($_COOKIE['ad_zedo'])) { $showadzedo = true; setcookie('ad_zedo',1); }
 ?>
<?php
  if($showadzedo){
?>
        <script language="JavaScript">
        var zflag_nid="1185"; var zflag_cid="3307"; var zflag_sid="823"; var zflag_width="1"; var zflag_height="1"; var zflag_sz="15";
        </script>
        <script language="JavaScript" src="http://d8.zedo.com/jsc/d8/fo.js"></script>

<?php
  }
?>

I've tried placing cookie setting part to the very beginning of the page.tpl.php file and second part in the bottom before closure. But I still see ad popup more than once. How to make it work?

I've even tried _SESSION['ad_zedo'] instead of setting/getting cookied but does not seem to work.


texts: How to add warning message before module is uninstalled

texts: The module in question has a content entity, entity1, that has another content entity, entity2, that depends on entity1. I would like to add a warning before uninstall of the module if there are currently entity2's that exist and that depend on entity1. The warning will suggest to delete the entity2 and then entity1 before the module can be uninstalled. How could I do this?


texts: Contextual filters in taxonomy term ID (with depth)

texts:
I need to make a view that will show me the nodes of a content type inside a node of another content type filtered by a taxonomy term.

I have three content types. The first one is Projects, in which I've added some projects (title, body and images-shadowbox). The second one is Projects Categories, in which I have some categories like:

houses.
offices.
etc.

The third one is Services, in which I've added the following categories:

architecture.
engineering.

I have added a "Projects" vocabulary with two items:

Project 1.
Project 2.

In each node of the "Projects" content type, I assign term of the Projects vocabulary. Each node of the "Project Categories" & "Services" can have more than one terms of the Projects vocabulary.

What I need is to preview under each "Project Categories" & "Services" node the relevant node "Project", filtered by the taxonomy term of the "Projects" vocabulary.

How can I achieve this?


texts: Username converted to us-ascii (unix-style)

texts: I want to convert unicode characters in user names to us-ascii. I.e my first name is Søren and my last name is Sjøstrøm. It should be converted to soren.sjostrom (unix style) as the user name. How do I do that?


texts:
In form api, #prefix and suffix are not working for '#type' => 'managed_file'. Below is my code, is there any other way to wrap this?

    $form['cvFile'] = array(
    //'#title' => t('Upload your CV'),

    '#type' => 'managed_file',
    //'#description' => t('The uploaded file will be processed.'),
    '#default_value' => variable_get('cvFile', ''),

    '#upload_validators' => array(
        'file_validate_extensions' => array('pdf doc docx'),
    '#prefix' => '',
    '#suffix' => ''
    ),

    '#upload_location' => 'public://cv/',
    '#process' => array('gng_job_my_cv_element_process'),

    );


texts: I recently exprience one problem that requires a patch. I downloaded that file .patch, but have no idea how properly to install that to my hosted website.


texts: How to set MINIMUM number of required fields?

texts: I need to set the minimum number of required values for several file fields in Drupal 7. I can only find options to make the field required or set a maximum number of allowed values. Is there any way to set the MINIMUM number of required values?


texts: D8 | submitForm | Get the $_POST - vars via $form_state or via \Drupal::request()?

texts:
On an regular sumbmitForm function, should I fetch the user input via \Drupal::request()->request->get... or is $form_state->getValues(); the better (more saver) way?

thx


texts: Organic Group visible only by authenticated user

texts:
I want to make the list of OG visible only to authenticated user so they can request membership. I have created a view but it only display group the user is already member of.

When I change the group visibility from * Private - accessible only to group members* to Public - accessible to all site users this make the group visible to anonymous user too.


texts:
I am using Entity reference module.

In one of my content types I have added Entity references as Users of the website.  So is there any way or API function to load the entities with logged in user is associated.

For Ex: When User1 is creating an article node and will add other users such as user2 etc in one of my entity reference field. Now when user2 is logged in i would like to inform him that he was referenced by user1. Is there any API function to achieve it ?


texts: How do I go about migrating books using MIgrate_D2D?

texts:
I've had to rebuild my sites recently due to a hit on the Drupalgeddon bug I thought I closed. I've been trying to migrate everything in easily but it doesn't seem to want to for whatever reason.

Now, I use migrate D2d for the most part and except for groups, group posts, and books it works just fine, the issue is anything with entity references or hierarchies.


texts: Anyway to clone the shipping services at: admin/commerce/config/shipping

texts:
Is there any way to clone Flat Rates shipping services at: 'admin/commerce/config/shipping' ?

The Flat Rates are generated by these modules: commerce_shipping
and commerce_flat_rate

I need this because I need to create 50 shipping services (for the 50 Spain provinces/states).


texts:
I am attempting to create a validator on a birthday (date) field I added to the user. The validator is setup as such but it never fires when I test it by registering a new user on the front-end.

Anyone have any ideas why this validator isn't firing?


texts: Which folders/files in drupal 6 need not executive permission?

texts: In order to tighten security of D6 against malicious XSS file uploads, I am wondering what files and folders can have go-x permission where the group is webserver.


texts: use multi level/chain of entity reference fields to create a list of nodes using views

texts:
I have 3 content types: Outline, Chapter and notes.

Chapter and Notes have 2 entity reference fields chap_outline_reference and note_outline_reference respectively referring to outline.
On the chapter nodes i want to populate a jump menu of all the notes referring to the same outline as the chapter.
I'm using Views 7.x-3.13 and Drupal 7.41.

I created a block view using the following relationship:

Entity Reference: Referencing entity ( for chap_outline_reference)

Entity Reference: Referenced Entity ( for note_outline_reference) and i'm using the above relationship in this relationship.

I am unable to figure out the contextual filter.
I tried using Content:nid with either of the above relations, but that didn't work.

Any help would be highly appreciated. Thank You.


texts: How to generate a serial number based on a selected field value?

texts:
I have a content type in which there is an entity reference. All content of it is set to unpublished by default and upon creation a rule is run to assign an organic group based on the selected reference.

Now, upon publication of the content I want to have an incremental number assigned to a node based on the entity reference it contains.
For example:

  Node1     ref:abc    c:1
  Node2     ref:def    c:1
  Node3     ref:abc    c:2
  Node4     ref:abc    c:3
  Node5     ref:def    c:2

How can I achieve this?


texts:
I read through the Drupal 8 menu_api documentation in drupal.org. The example guide lists an option to create menu links and insert them into an existing menu. How does one create menu itself first and insert the menu links afterwords?

I used the entitytype manager based on the other answer in stackexchange, but going yml way is recommended. Any pointers?

use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\menu_link_content\Entity\MenuLinkContent;

\Drupal::entityTypeManager()
->getStorage('menu')
->create([
 'id' => 'test',
 'label' => 'test menu',
'description' => 'test test',
 ])
 ->save();

Using routes below to create the links:

 test.home:
 title: 'Home'
 url: 'test.url'
 menu_name: test
 weight: 1


texts:
I try to embed a view in a specific node. I found tutorials for doing this with Drupal 7 and PHP-Templates:

<?php print views_embed_view('view_name'); ?>

But I look for a way in Drupal 8 with twig-Templates. I tried to call the views_embed_view() function in the hook_node_view() and assign it to the node so that I can print it out in the twig-Template. But it seems that this hook never gets called.

Any hints/solutions how to do this in the Drupal 8 way?


texts:
I have a hierarchical dropdown menu created using Drupal Megamenu module. It works good for my needs, but there is a small issue: when the page loads the whole menu tree looks expanded, and covers the entire page for a while.
It gives a hard look. I would greatly appreciate if you have any suggestions or workarounds to fix this.


texts: Where is Content Type View Access stored in the Database?

texts:
I am looking for where Per Content Type - View Access is stored in the database.

Out of the box, I understand that Drupal can limit certain roles to be able to Edit/Delete All/Own Nodes but not access to View Nodes of certain types. I found those stored in the role_permissions table.

I use the ACL and the Content Access module and have found the "per-node" permissions in the ACL tables of the database.

I have limited View Access on specific Content Types to specific Roles, but cannot find where in the database this information is stored.

Where can I find that?

The reason I want to know is I want my custom module I am working on to work with the Content Access module to be able to grant/revoke access on certain Content Types to certain Roles.


texts:
I want to have make a node accessible via 2 different url. I want to apply a different theme on every one of theme.
They will be event/id and app/event/id. There will also be a third alias via pathauto but this will just be the same with event/id.

Any idea on a workaround?


texts: developing a site in drupal made a mess in modules .. is there better way?

texts:
When I develop a site in Drupal, I test a couple of modules to see what best suits my needs. The problem is that, if it is a large site, I find myself with a lot of modules and patches (disabled / uninstalled), which still exist in the modules folder. There are a lot of modules that don't have an uninstall feature; the result is that I get many unused tables in the database, and many used files to delete.

Is there a better solution, or way to proceed for testing modules?