texts: Alter user_pass_reset for one time login D7

texts:
I don't like the one time login process; sending the users directly to their user edit page is not what I want. I want to force the users to insert a new password.

I have created a module that doesn't work; obviously I'm not affecting the submit action and is not taking the newly inserted username to the user object.

// Let's try to add a form in the user pass reset form for password requests.
function xxx_login_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_pass_reset') {
    $form['#account'] = $GLOBALS['user'];
    $form['loginsetup'] = array(
      '#title' => t('Login setup'),
      '#type' => 'fieldset',
      '#collapsible' => FALSE,
      '#collapsed' => FALSE
    );
    $form['loginsetup']['account']['name'] = array(
      '#type' => 'textfield',
      '#size' => 25,
      '#title' => t('Username'),
      '#required' => TRUE
    );

    $form['loginsetup']['account']['pass'] = array(
      '#type' => 'password_confirm',
      '#size' => 25,
      '#title' => 'Please enter your new password',
      '#required' => TRUE,
    );

    $form['message']['#markup'] = FALSE;
    $form['help']['#markup'] = FALSE;
    $form['actions']['submit']['#value'] = 'Enter';
    //  $form['#validate'][] = 'xxx_login_user_pass_validate';
    $form['#submit'][] = 'xxx_login_user_pass_submit';
  }

  return $form;
}

// We'll check if the user did not leave a username.

// function xxx_login_user_pass_validate($form, &$form_state) {
//   if (empty($form_state['values']['name'])) {
//     form_set_error('name', t('You must select a username.'));
//   }
// }

// We should send the new values to the user object.

 function xxx_login_user_pass_submit($form, &$form_state) {
   // Set up the edit array to pass to user_save().
   $edit = array(
     'pass' => $form_state['values']['pass'],
     'name' => $form_state['values']['name']
   );

   // Save the account with the new password and name
   user_save($form['#account'], $edit);

   // Inform the user.
   drupal_set_message(t('Your login details have been stored. Welcome to example.com!'));
}

The validate function is now commented, but it does not affect the module; with or without it, it still does not work.


texts: How to check if a form is being rebuild?

texts:
I want to perform a function if the form is being rebuild.

i.e.

If validation fails, or
Form is rebuild for any other purpose.

I do not want the function to run in any other case.

How can I do this?

I tried doing this in form_validation but it is executed even if form is not rebuild.


texts: Add a subquery in a WHERE condition, using hook_views_query_alter()

texts:
I tried to add a subquery like this:

function mymodule_views_query_alter(&$view) {
  $view->query->where[1]['conditions'][] = array(
    'field' => 'node.nid',
    'value' => 'SELECT SUBSTRING(source, 6) FROM {url_alias} WHERE alias LIKE "pros/%"',
    'operator' => 'in',
  );
}

I have a specific case where nodes are created with aliases starting with pros/ or not, and I want to get only them.

In a simple raw SQL query, I'd go with this:

SELECT *
FROM node node
WHERE node.nid IN (SELECT SUBSTRING(source, 6)
                   FROM {url_alias}
                   WHERE alias LIKE "pros/%")

But I can't find out how to do this using hook_views_query_alter().


texts: How to check if Drupal user is logged in via htaccess?

texts:
Is there a specific cookie Drupal uses to determine if a user is logged in or anonymous?

I need to check the cookie, and create a rewrite condition based on whether or not the user is logged in.

In the end, I would like something like this:

RewriteCond %{HTTP_COOKIE} !drupaluser=1 [NC]
RewriteRule ^(.*)$ /$1?no-cookies-for-you=%1 [R,QSA,L]

Thanks.


texts:
This is the first time I use a CMS, and I'm trying to install nivo slider module into Drupal. I used the following commands

drush dl nivo_slider
drush en nivo_slider -y

Then I added some pictures to the slider but they are displayed without animation

And in the status report I have the following error message

  Nivo Slider jQuery plugin Not installed
  The Nivo Slider library could not be found.


texts:
I'm trying to alter the password reset link (user/password) to my own language specific URL, but I can't find how I can do this.

How can I change it?


texts: Content added in article tags, doubling content, even without article content

texts:
I am displaying a content type through a view, using a contextual filter to limit results to one per page (nid). I believe this is a simple/standard way of displaying content, but being new to drupal I could be wrong.

My problem is that the content is duplicated. First within an 'article' tag, and then where I'd expect it to show up (inside the view tags).
I find it completely baffling because I don't even use the article content type. It's a problem I've had from the start, but I took the easy way out and simply hid the article content with display:none.
But now, for some equally baffling reason, drupal has placed a new view I created inside the article tags - which of course means it doesn't show either. :-(

Why would drupal decide to send along my content inside the article tags?

I'm not sure if this is enough to go on, but I would be more than happy to provide more information.

Thanks for your time,
Tobias


texts:
I just realized hook_node_presave($node) does not yet have a NODE#ID associated with the new node.

Can anyone tell me if there is a hook in the node creating process where I can access the new nodes' nid?


texts:
I'm building a module for basic e-mail sharing that will present a form on every node. So I hook into nodes and add a new variable called share_form which is supposed to contain the from from email_share_node_form after it has been fetched with drupal_get_form.

I have been checking out loads of examples and as far as I can see I'm doing everything right. But the page turns completely blank, with no errors either in the reports or on the page. The same occurs when I use other form_ids such as user_register_form that is supposed to work.

If I add any normal string to share_form the page renders with no issues at all. So the error is definitely occuring inside drupal_get_form.

Is there obvious error in my code? How can I debug this?

UPDATE: If I put the render(drupal_get_form('email_share_node_form')) in my node.tpl.php it renders just fine. Why not in the module?

/**
 * Hook into node_load to insert an e-mail share form.
 */
function email_share_node_load($nodes, $types) {
  foreach ( $nodes as $nid => $node ) {
    $nodes[$nid]->share_form = drupal_get_form('email_share_node_form');
  }
}

// --------------------------------------------------

/**
 * Create a share-form to display on a node.
 */
function email_share_node_form($form, &$form_state) {
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit')
  );

  return $form;
}

Thanks


texts: How to create a View with a contextual filter (fixed) value form a field value?

texts:
I'm creating a dynamic View with the following aspects:

1) A content-type of 'product'.

2) A content-type of 'company'.

3) A User who works for a company, linked to a compagny by a user_compagny_field.

A User can only sell the products linked to his/her company.
All products are linked by field 'products solds in this compagny'.

I've created a View that correctly shows all products. When I enter the NID from company X (3 in my case) i get the correct products: 10 and 7.

How do I get the value from the User-field compagny as an Contextual-filter inside my view. As far i can see I've three options:

1) Fixed Value: which works if I enter the Value of 3).

2) User ID from logged in User, doesn't work because i'm user 1. And I need the value of my compagny field.

3) Content ID from URL.

I find it rather complex and I'm always struggling with contextual Filters.
Thank you for your time and kind words, keep on Drupalling.


texts:
Novice question on Panels - I've inherited a D7 site with Panels 7.x-3.9.

I'm using a system page: node_view, with a variant for the content type I'm working on.

The layout has a number of regions - and just to be clear, by regions, I mean the $plugin['regions'] array in the template's .inc file.

What I can't figure out is how to add new regions.

(I want to add group some fields together so I can insert them using $content['foo'] in the template.)

Modifying the existing region names updates the descriptions used  /admin/structure/pages/nojs/operation/node_view/handlers/node_view__panel_context_[UUID]/content

But any extra regions I add don't appear (having done drush cc all) and they also don't appear when creating a brand new variant using the same template.

Am I missing something in the UI (I'm logged in as user 1)?

(Thanks)


texts:
I build a module that implements hook_user_default_permissions to manage permissions for my site. It's been installed on the site, and its permissions took. But now, a while on, I am making some changes to the permissions, but they aren't taking.

I am trying to figure out how to re-trigger the hook being run. I've tried clearing cache, rebuilding the registry, disabling, uninstalling, and re-installing the module, and rebuilding user perms. None of these have worked. I've looked in the role_permission table to verify, and my changes have not been added.

How can I get the hook to run again?


texts: No successful migration from Drupal 7 to Drupal 8 yet

texts:
The upgrade reaches the following point:
Currently upgrading Node type configuration (40 of 70 total tasks)

then it fails with the following message:
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /drupal/batch?id=3&op=do_nojs&op=do
StatusText: OK
ResponseText:
Welcome to drupal8testlocale
...
Create new accountReset your password

Any help would be appreciated!


texts: Separate exposed sort form from exposed filter block

texts:
Is is possible in Drupal 8 Splitting exposed filters and exposed sort & pagination i.e. placing sort & pagination inside a separate block and filters in another block?

Right now there is no out of the box solution to this. In my opinion this would greatly improve user experience.


texts: How to know if i click any link in drupal and set a variable?

texts:
I need some help for the following case:

In my content-type i have a cck link that redirect to another page.
So, i need do this:

When, i click in the link.. In my content-type_form ([name_content_type]_node_form) i need to extract a variable of this form of my node:

form_state['values']['id'] = $id;
variable_set($id, 1);

Then, when i stay in the another page (that is a form) ; in this form do:

$form['id'] = array(
        '#type' => 'textfield',
        '#default_value' => variable_get($id, 1)
);

for view the corresponding id.

How to do this?


texts: views teaser read more loading to another node instead of slideshow

texts: I have created 5 news using teaser view and provided a read more link. when i click on read more it is pointing to another page instead of slideshow. I tried with views slideshow but ended up with nothing.


texts: Metatags not showing despite calling render in template

texts:
My custom page.tpl.php is not outputting metatags. I've tried all of these:

 render($page['content'])
 print render($page['content'])
 render($page['content']['metatags'])
 print render($page['content']['metatags'])

I know that the metatags module is passing in the metatag info, because doing this

watchdog('foo', print_r($page['content']['metatags'], true));

results in an array like this:

 Array (
  [node:feed] => Array (
    [abstract] => Array (
      [#attached] => Array (
        [drupal_add_html_head] => Array (
          [0] => Array (
            [0] => Array (
             [#theme] => metatag
             [#tag] => meta
             [#id] => metatag_abstract
             [#name] => abstract
             [#value] => This is an abstract
            )
            [1] => metatag_abstract
          )
        )
      )
    )
    [keywords] => Array (
    [#attached] => Array (
    [drupal_add_html_head] => Array (
    [0] => Array (
      [0] => Array (
        [#theme] => metatag
        [#tag] => meta
        [#id] => metatag_keywords
        [#name] => keywords
        [#value] => keyword1 keyword2
      )
      [1] => metatag_keywords
    )
  )
 )

 ... etc ...

What might be stopping it from rendering the metatags on the page?

I've also noticed that the metatags element in the default devel tab is an empty array, BUT in the tokens tab within devel, the node:metatag tokens are all present and correct.

Further investigation shows that drupal_add_html_head() is being called and the metatag information is being passed in.


texts: Caching $_SESSION data for anonymous users

texts:
I recently inherited a Drupal 6 website that is using $_SESSION to store a lot of anonymous user data. Currently none of this $_SESSION data can be accessed while caching is enabled.

I have considered using cookies to work around this limitation but would like a fallback for users without javascript enabled.

Is there a way to do this in D6, D7 or the upcoming D8?


texts: How to find which user permissions are necessary to access a page

texts:
I created a custom content type, which has a custom block on it.
When accessing that page, i get an "Access denied" error.

I have no idea which permissions is throwing this.

Does anyone have an idea of how to find the missing permission?

Thanks!


texts: Getting "Call to a member function getName() on null" in custom breadcrumb

texts:
I'm trying to customize the breadcrumb of drupal 8 to get something like this:

Home > category >article-title.

I wrote this and I wrote the code below.

namespace Drupal\module_demo\Breadcrumb;

use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Link;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\taxonomy\Entity\Term;

class ArticleBreadcrumbBuilder implements BreadcrumbBuilderInterface {

    public function applies(RouteMatchInterface $route_match) {
        $parameters = $route_match->getParameters()->all();
        if(isset($parameters['node'])) {
            return $parameters['node']->getType() === 'article';
        }

    }

    public function build(RouteMatchInterface $route_match) {

        $breadcrumb = new Breadcrumb();

        $term = $route_match->getParameter('taxonomy_term');

        $breadcrumb->addCacheContexts(["url"]);

        $breadcrumb->addLink(Link::createFromRoute(t('Home'), '<front>'));

        $breadcrumb->addLink(Link::createFromRoute(t('Articles'), '<none>'));

        $breadcrumb->addLink(Link::createFromRoute($term->getName(), 'entity.taxonomy_term.canonical', ['taxonomy_term' => $term->id()]));

        $request = \Drupal::request();
        $route_match = \Drupal::routeMatch();
        $page_title = \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject());
        if (!empty($page_title)) {
            $breadcrumb->addLink(Link::createFromRoute($page_title, '<none>'));
        }

        return $breadcrumb;
    }
}

but I have the error below.

  The website encountered an unexpected error. Please try again later.
  Error: Call to a member function getName() on null in Drupal\module_demo\Breadcrumb\ArticleBreadcrumbBuilder->build() (line 34 of modules/custom/module_demo/src/Breadcrumb/ArticleBreadcrumbBuilder.php).

Apparently the problem is with getName() and id().

Can someone tell me where the mistake is?


texts: Is there a way to include taxonomy terms and nodes in a search?

texts:
I'm trying to make the search for my site gather results based on nodes and taxonomy terms.

To give an example of what I'm trying to do, say that I have content nodes set up for my products and have taxonomy terms based on colors associated with the nodes. If I search for "computer", results seem to be all nodes with "computer" in the title, which is good. If I search for "black computer", no results are returned. I want to be able to search for "black computer" and have results return all nodes that have computer in the node title and are associated with the taxonomy term "black".

FYI, I currently have the search index set to index nodes and am using a view to override the search. I'm using Drupal 7.23.


texts: How to add a universal form submit handler to ALL forms?

texts:
Suppose i need to record all form submissions in a site, i mean all of them.
I would add a new submit handler to be executed after each forms submit handler, like $form['#submit'][] = 'log_submit' , right?

The problem is that some forms may not have the submit handler inside $form['#submit'] array but in $form['buttons'] or $form['#actions'] etc...

How would i add my own submit handler to ALL of these forms, in one hook_form_alter() and in a clean way?

Thanks


texts:
pathauto provides a hook called:[node:menu-link:parents:join-path]

    /**
 * Implements hook_tokens().
 */
function pathauto_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();

  if ($type == 'array' && !empty($data['array'])) {
    $array = $data['array'];
foreach ($tokens as $name => $original) {
  switch ($name) {
    case 'join-path':
      module_load_include('inc', 'pathauto');
      $values = array();
      foreach (element_children($array) as $key) {
        $value = is_array($array[$key]) ? render($array[$key]) : (string) $array[$key];
        $value = pathauto_cleanstring($value);
        $values[] = $value;
      }
      $replacements[$original] = implode('/', $values);
      break;
  }
}
  }

  return $replacements;
}

How can I implement a modification of this hook for my site? I would like to limit the depth of the parent trail to 2 levels. I think I could achieve this by modifying this line like this:

   $replacements[$original] = implode('/', array_slice($values, 0, 2));


texts: Speeding up the taxonomy term autocomplete

texts: I've noticed that the autocomplete on my taxonomy fields takes a long time to load existing terms when trying to tag a node. I have to type out the whole term name and wait a few seconds before autocomplete finds the existing term. Is this normal? If not, how can I speed this up? The ideal would be terms appearing as soon as I type a letter.


texts: How do I choose a default theme if the theme gives a white screen?

texts:
I tried to make a folder templates for all tpl files but after that now I can not load my theme anymore on Xamp? Now when I try to load theme in drupal there was only white screen.What can I do?
I am tired of that so if you just make one mistake in Drupal, you are need to install again and again.
I choose a different theme and I close the browser, but the theme is not working. How can I load a different theme if I don't have access anymore to Drupal?


texts: Drupal 7 Forum - Allow Users to 'hide' their online status

texts:
I am desperately trying to find a way for my users to 'hide' their online status from other users. Currently all users online are displayed in the drupal 'who's online' box.

Ideally I would look for a way to create a custom checkbox field (online_status) and then find a way for the who's online block to check that.

Any ideas, modules or approaches anyone can recommend.
My current thinking is to do it via Views and a custom block

thanks


texts: Private file system, The upload directory private://webform/XXXX/_sid_ for the file field could not be created or is not accessible

texts:
I am trying to set up the private file system for drupal 8. I have created a private folder /home/user/public_html/private_files with permissions set to 777

in settings.php i uncommented the $settings['file_private_path']= '/home/[USERNAME]/public_html/private_files';

the .htaccess file was created.

the status report page gives:
File system
Writable (private download method)

When i try to upload a file with either the webform file field or a drupal file field i get the error message: File could not be uploaded.

In the error log i get:
The upload directory private://webform/XXXX/sid for the file field could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled.

Can anyone help me with this


texts: views_datasource module problem with encoding

texts:
I installed views_datasource module to get json output of a view. There is a content type in my website called translations and English, Arabic and Persian texts are saved in there. This module works well but it has problem with encoding the Persian and Arabic texts. it outputs the json like this:

How do I can solve this problem.

UPDATE:

The views admin UI generates the true output as this picture shows

But when I visit the page path through browser I see the first picture


texts: I'm using the Insert module to allow users to insert images with a specific image style into a page. After upgrading to Drupal 7.20, the images are not stored in the files/styles folders, and the image url returns a 403 (access denied) error. I checked the folder permissions, and they are all set to 777.


texts:
I'm developing a site that it will use Services for the CRUD operations and ANGULARJS for the comunication frontend <-> backend.

Now when I want to insert a new content of content type FOO I will don't use the standard form (node/add/FOO), but one of my HTML form, this because, like I said, I will use Services to store the new content.

So, is there a way (or a module) that permit me to send this form to Drupal for only validating it and give back a ok/error code? In this last case I need to receive back errors and the wrong fields.

Thanks. M.


texts: How to add a tabbed menu on group main page (panel)?

texts:
I managed to get panels working with og 7.x-2.1 following:
- http://modulesunraveled.com/organic-groups/part-3-organic-groups-layout
- http://www.initsix.co.uk/organic-groups-panels-and-views-drupal-7

Now I'd like to add a tabbed menu on the "main og content", where I mainly divide by content-type (documents, agenda, forum, news..).

I tried to follow http://www.austinprogressivecalendar.com/blog/creating-drupal-panels-tabs in order to create tabs, where each tab is a panel.
However I don't know how to eventually add what would be my (sub) panel to the main content of the group page, and more in general I wander if there is a less cumber stone way to implement it.


texts: Webform: Remove UUID, Created, ID, etc fields from "HTML Table" Export

texts: I want to know how can i remove the fields from the module "Scheduled Tasks" for Webform, so the exported Excel file doesn't show the fields "Created" "UUID" "Serial Number" "Completed" etc. I can make it when i export manually but in scheduled tasks it sends all that information. I don't have a clue how to make it. I would appreciate if anybody could help me.


texts: How to get related nodes for node reference?

texts:
I have added related nodes using Node Reference module provided by the references module.
Now I want to retrieve all the related nodes. So I am looking for a function which takes a node id as input and returns all the related nodes.

Is there any function provided by Drupal API or reference module which helps me getting nodes related to a node?

I tried searching in the module functions but I found nothing.


texts: How to add filter 'fq' in drupal 8 search api solr?

texts:
I have 4 different content types, for those I have create 4 different search pages based on the page view I need to alter solr query.

In D7 we have addFilter('fq').

How can we do it in D8?


texts:
I've setup a Drupal site and had to turn off user registration because of the amount of bogus accounts being created. Now when I check the logs I see loads of access denied messages, usually for pages
node/add
user/register

Is this normal for a drupal (possibly any) site, and something to be expected?
It seems excessive to me, so I'd like to understand if this is a normal problem for websites, drupal or otherwise?


texts: How to upgrade module table scheme for entity

texts:
I've written a module that uses entities functionality. It has the following table scheme in .install file:

$schema['transaction'] = array(
    //fields
    'fields' => array(
        'id' => array(
            'type' => 'serial',
            'unsigned' => TRUE,
            'not null' => TRUE),
        'name' => array(
            'type' => 'varchar',
            'length' => 50,
            'not null' => TRUE,
            ),
        'random_id' => array(
            'type' => 'varchar',
            'length' => 11,
            'not null' => TRUE,
            ),
        ),
    //additional properties
    'primary key' => array('id'),
    'unique keys' => array(
        'random_id' => array('random_id'),
        ),
    );

Entity description:

function transaction_entity_info() {
  //song entity
  $entity_info['transaction'] = array(
    'label' => t('Transaction'),
    'label callback' => 'transaction_label_callback',
    'base table' => 'transaction',
    'fieldable' => TRUE,
    'entity keys' => array(
      'id' => 'id',
    ),
    'uri callback' => 'transaction_class_uri',
    'static cache' => TRUE,
    'admin ui' => array(
      'path' => 'admin/content/transaction',
      'controller class' => 'transactionUIController',
      'file' => 'includes/transaction.admin.inc',
    ),
    'module' => 'transaction',
    'access callback' => 'transaction_access_callback',
    'bundles' => array(
      'transaction' => array(
        'label' => 'Transaction',
        'admin' => array(
          'path' => 'admin/structure/transaction/manage',
          'access arguments' => array('administer transaction'),
        ),
      ),
    ),
    'entity class' => 'Transaction',
    'controller class' => 'transactionController',
    'views controller class' => 'EntityDefaultViewsController',
  );

  return $entity_info;
}

Now I need to add a new property into the table:

    'output' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0),

I can use fields, and add it through the admin panel, but I want to learn, how to upgrade the tables directly.

How can tell Drupal to reload the table scheme for this module, add attribute into the table and use it when loading the entity?


texts: How to maintain and update a Drupal installation and its modules?

texts:
I'm looking for a comprehensive tutorial on best practices for updating and maintaining a Drupal installation and it's modules where there are multiple instances of the site, that is having a development instance and a live instance, and methodologies for updating the live site with changes made on the development site, and avoiding database conflicts.

TL;DR

Best practices for updating Drupal and it's modules to newer, more secure versions.
Best practices for mirroring changes made in a development instance of a site to the live instance of the site.

Note: I am using Mercurial to track changes.


texts: Upgrading Drupal 8 to a newer version from the command line using Drush?

texts:
Currently I have stable Drupal 8.1 release and I would like to uprgrade my site to 8.2 dev. How can I do this via the command line with Drush if that is even possible?

If not using drush, can I just download 8.2 and extract it into 8.1 directory?


texts: PDOException: SQLSTATE[HY000] [2002] No such file or directory in lock_may_be_available() (line 167

texts: I have Drupal 7.2 application site and have upgraded from php 5.6 to php 7.2 since it reached its eol, also upgraded to rhel 8 from rhel 6.5, but while connecting to rds I am getting following error, however while trying to connect to db locally, was able to connect successfully. What does this mean and How can I solve this


texts:
I am working with the entity_metadata_wrapper, and I found online this function to display all of the wrapper's properties.

$billing_profile = commerce_customer_profile_load($order->commerce_customer_billing['und'][0]['profile_id']);
$billingWrapper = entity_metadata_wrapper('commerce_customer', $billing_profile);
dpm($billingWrapper->getPropertyInfo());

However, it gives me an error.

  PHP Fatal error:  Call to undefined method EntityValueWrapper::getPropertyInfo()

When I googled the function, it came up as EntityStructureWrapper::getPropertyInfo(),  where I see that its not a function of EntityValueWrapper, but rather EntityStructureWrapper.

How do I create that class instead of using the code I found?


texts: Override template file in a module (not in a theme)

texts:
I'm trying to write my first module on Drupal 8. It's a module that deal with paragraphs.

I need to add some template suggestion to paragraphs and declare them in my module /template folder.

So I defined a

function paragraphs_builder_theme_suggestions_paragraph_alter(array &$suggestions, array $variables) {
  $suggestions[] = 'paragraph__builder';
}

It works well when I define paragraph--builder.html.twig file in my theme, but I need to define that file in my module because I want my module to be theme independent.

When I define the paragraph--builder.html.twig file in the template folder of my module (removed the one in my theme first), the file is not red (I have some debug in that file that does not trigger). I tried to clean cache, everything... without success.

It seems that unlike Drupal 7, Drupal 8 only read the theme folder to find the template files that could overwrite default ones.

So my question is, how could I define my template file in a module ?

Thank you

Alex


texts: How to hide specific term/field value on the node?

texts:
Is there a way to hide a specific taxonomy terms (specific field values) on the node? (not hiding field/vocabulary altogether, just some values).

For instance, there is vocabulary "Location" with a stucture like:

Europe

England

London

France

Paris

On the node view I need to hide terms "Europe", "England" and "France" and display "London" and "Paris" only.


texts: Programmatically publishing and unpublishing nodes: anonymous access

texts:
We have several nodes that serve as open job postings which need to "open" and "close" on specific dates.
In order to accomplish this, we publish and unpublish them accordingly.

We have a query (based on publish unpublished node programmatically) that successfully updates both the node table and the node_revision table:

$result = db_query('update node n
JOIN field_data_field_jobs_date d ON d.entity_id = n.nid and d.revision_id = n.vid
JOIN node_revision r ON n.nid = r.nid and n.vid = r.vid
# Update the node_revision table
SET r.status = IF(
    (
    CURDATE() >= d.field_jobs_date_value
    AND
    CURDATE() <= d.field_jobs_date_value2
    ),1,0
),
# Update the node table
n.status = IF(
    (
    CURDATE() >= d.field_jobs_date_value
    AND
    CURDATE() <= d.field_jobs_date_value2
    ),1,0
)
# Only update our custom content type
WHERE n.type = \'job_posting\'');

This successfully updates the node status and node revision status in the database.

However, once a node has been published through this method, anonymous users still cannot see it (and are presented access denied if given a direct link to the node).

We have to manually edit each node and hit the save button for the published status to "take." This leads me to believe that we are omitting some sort of call to node access or something similar that updates the permissions on the node appropriately.

Any ideas besides the status field that may be preventing anonymous users from seeing programatically published nodes?


texts:
I have a content type called News. There are three taxonomy terms for this content type (In the News, Success Stories, Events)

I want a page that shows each taxonomy term, with the newest three nodes summary, respective of that term, underneath it.

For Instance:

IN THE NEWS:

january 5th, 2001
blah blah blah blah blah

february 5th, 2002
blah blah blah blah blah

SUCCESS STORIES:

March 1, 2011
blah blah blah

Jan 2, 2012
date blah blah blah

EVENTS:

march 1, 2010
blah blahb lah

may 3, 2011
blah blah blah

Is there a way to do this using Views alone or should I make a separate view for each section and use Panels to show the three views?

Any suggestions would be helpful.


texts: How to load terms in alphabetical order or in the same order they are in CMS?

texts:
I am loading terms programmatically but I am hoping to load them in the same order as they show in the CMS (weight). If not that, I just want them to load in alphabetical order.

This is what I am doing:

$vocabulary = taxonomy_vocabulary_machine_name_load($name);
$terms = entity_load('taxonomy_term', FALSE, array('vid' => $vocabulary->vid));

Any idea how to achieve that?


texts: Drupal 7 - views blocks not displaying page field content

texts:
I have a page where a view is creating a block which loads a field.

Other blocks loaded into the region are showing up just fine but that particular one will not show.  It is not because the field is empty or otherwise, I can creae labels and tables and empty conditions etc that do not get picked up at all

Is there something that has to be done to template files or otherwise to enable blocks created by views?


texts: Linking External Javascript with drupal_set_html_head

texts:
I want to add the below external javascript file to the head of my Drupal 6 site.

<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">
stLight.options({
    publisher: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
});
</script>

I want to know if it's OK to do somethng like this, as it's not working at the moment.

function template_preprocess_page(&$vars){
  drupal_set_html_head('<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>');
  drupal_set_html_head('<script type="text/javascript">stLight.options({publisher: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}); </script>');
}

Someone should kindly assist me feature the links of the external file in the header of every page of my site.

Thank You.


texts:
I've added an autocomplete function for my views_exposed_form (a text input) using this tutorial and it works (https://www.linkedin.com/pulse/implementing-autocomplete-drupal-8-custom-callbacks-waliullah-khan).

I'd like to add a "submit on click" behaviour, so when I click on a value of the autocomplete it changes the value of the input and then submit the form.

How should I do this?


texts: I have flagged contents in a block.But only admin can see the these flagged contents(contents are product variations).I want to show these contents to all authenticated users and anonymous users.Is it possible?Can you help me to solve this issue.


texts:
Something has happened on my site where I am unable to add taxonomy terms or edit existing ones.

If I go to add a taxonomy term or edit an existing one the form comes up, I made an changes (i.e. add some text in the description field) and then click save and it goes back to the Taxonomy list  but nothing changed. When I go back into edit the taxonomy term the previous change is gone.

The same thing happens when I try to add a term through /admin/structure/taxonomy/name_of_vocabulary/add form- it saves, but then the new term doesn't show up.

Any ideas?


texts: Redirect User: Delay + Intermediate page

texts:
I have been trying to get a quick easy way to redirect the user, no matter where they go to the site straight to the user login page. But before I do, I want to redirect them to another page saying some message like "Sorry, you need to be authenticated to view blah blah... you are being redirected to the login page".

I currently have:

function mytheme_preprocess_page(&$vars, $hook) {
  global $user;
  if ($user->uid == 0 && arg(0) != 'user'){
    drupal_goto('user/login');
  }
}


texts: how do i alter comments and comment form

texts:
I am trying to change the way comments are displayed in drupal 7 for a specific content type. I am using garland theme. Ideally I would like to modify comment display in my module as opposed to doing it in the theme.

I have successfully implemented hook_form_comment_form_alter to hide the author name this way:

function mymodule_form_comment_form_alter(&$form, &$form_state, $form_id) {
  //  krumo($form_id);
  switch($form_id) {
    case 'comment_node_mycontenttype_form':
      hide($form['author']);
      break;
  }
}

Now I would like to alter the comments to:

Hide the comment title link
Hide the "reply delete edit" links

I tried to implement hook_comment_view_alter() and hook_node_alter() but these seem not to get called. When I use the following code, nothing happens (no krumo outputs and no modifications).

function mymodule_comment_view_alter(&$build) {
  krumo($build);
}

function mymodule_node_alter(&$build) {
  krumo($build);
  hide($build['links']['comment']['#links']['comment-reply']);
}

The only way I found was to modify garland_preprocess_comment() in template.php in garland theme. But this applies to all content type and also I would like to have all my code in my module.

Is there a proper way to do this?

How come hook_comment_view_alter() and hook_node_alter() don't seem to get called?

Note I am using panels to add my content. So I have added the comments and the comment form using panels module. Therefore there is no field to toggle "allow comment title" as there is in structure->content type->comment settings. Even though the "allow comment title" field is unchecked, titles are still displayed. it seems like panels overrides this setting somehow.


texts: custom generate pdf with the header displaying only in the first page

texts:
I'm using print module to generate pdf files from the drupal content. Here I use tcpdf library. The pdf files are working fine. But I want to customize the pdf files, here I want to display header in only the first page of the pdf file and the rest of the pages should display no header, but the footer should be common.

How can I customize the pdf generation? Is there a way that I need to change some thing in template files or library files. I tried to look into the tcpdf's lib-handler files - print_pdf_tcpdf.pages.inc. But I could find nothing related to restricting header.

Help is appreciated.


texts: Having issues upgrading from Drush 6.3.0 to 8.0.5

texts:
We have been successfully using Drush, latest version 6.3.0. In order to obtain Drupal 8 support, I am trying to upgrade to Drush 8.0.5.

First I located the 8.0.5.tar.gz file and tried getting success that way. It complains:

./drupal-cron.php.sh

  20160407-204933 drush core-cron cron.php begin
      Unable to load autoload.php. Run composer install to fetch dependencies and write this file (http://docs.drush.org/en/master/install-alternative/). Or if you prefer, use the drush.phar which already has depdencies included (http://docs.drush.org/en/master/install).
      X-Powered-By: PHP/5.4.45
      Content-type: text/html

So next I tried pulling down drush.phar as that appeared to have the dependencies built-in. Trying that version also did not seem to successfully execute Drupal cron:

./drupal-cron.php.sh

  20160407-211633 drush core-cron cron.php begin
  X-Powered-By: PHP/5.4.45
  Content-type: text/html

We have been successfully running Drupal cron with Drush since our last update back in 2014 with this script:

#!/bin/bash
DATE=`/bin/date +%Y%m%d`
DATETIME=`/bin/date +%Y%m%d-%H%M%S`
LOGFILE=/kunden/homepages/35/d157794216/htdocs/reports/$DATE.${2}.drupal-cron.php.sh.log
export COLUMNS=132

echo $DATETIME drush core-cron cron.php begin | /usr/bin/tee -a $LOGFILE
/usr/bin/nice -n19 /usr/local/bin/php5.4 /kunden/homepages/35/d157794216/htdocs/drush/drush.php --root=$1 --uri=http://$2 --debug --nocolor core-cron 2>&1 | /usr/bin/tee -a $LOGFILE

And to try drush.phar I swapped out drush.phar for drush.php in the Bash script.

Suggestions how to get successfully upgrade to the latest version?


texts:
In view, when I set the settings to field field1 in Page, the same settings apply to field1 in Rest export. How do I get rid of it?

I see that everything is copied. I deleted the field from Rest export, and it disappears also in Page.


texts:
I'm having trouble with something incredibly simple:
When I select an element in a multiselect-form element, I want a textfield to become enabled. The problem I'm having is that Drupal never manages to get in the callback-function I specified.

Here I create my multiselect-element:

$form['foocat'] = array(
  '#type' => 'fieldset',
  '#title' => t('Manage subcategories'),
  '#prefix' => '
',
  '#suffix' => '
',
);
$form['foocat']['subcategories'] = array(
  '#type' => 'select',
  '#default_value' => '',
  '#title' => $foocategory,
  '#options' => $options,
  '#ajax' => array(
    'callback' => 'edit_displayname_callback',
    'wrapper' => 'displayname',
  ),
  '#attributes' => array('id' => 'foocats',),
  '#prefix' => '
',
  '#suffix' => '
',
  '#size' => 9,
);

A little bit further in the code I create my textfield:

$form['foocat']['subcat_displayname'] = array(
  '#type' => 'textfield',
  '#title' => t('Name'),
  '#default_value' => $entity->foocategory,
  '#size' => 25,
  '#maxlength' => 31,
  '#prefix' => '
',
  '#suffix' => '
',
  '#disabled' => TRUE,
);

if(!empty($form_state['subcategories'])) {
  $form['foocat']['subcat_displayname']['#disabled'] = FALSE;
  //Code for setting the textfield, dependent on what's been selected in the multiselect
}

And this is my callback function:

function edit_displayname_callback($form, &$form_state) {
  watchdog("Test", "Testing callback..", array(), WATCHDOG_ALERT);
  return $form['foocat']['subcat_displayname'];
}

The callback is never even called, and I have no idea why. I use AJAX in another part of the same form, and there it does work, so I'm guessing it's not a form problem.

Can anyone spot the problem?


texts: How to delete Duplicate Nodes based on title?

texts: Is there any easy way to remove duplicate nodes based on Node title?


texts: Enable users to edit user profile and nodes in same page

texts:
In my project I would like my users to be able to edit their profile from the same page they view their profile.

In order words when they click on the fields or an edit button beside the fields, they will be able to enter a new value.

What I want to achieve is pretty much how users edit their profile on LinkedIn.

Please is there a module that can help me achieve this?

(Please note that I am displaying the user profile with "views").


texts:
I am using Media 7.x-1.3 on Drupal 7.21.
I have created simple StreamWrapper to use with some other modules and it works great for them. It extends DrupalLocalStreamWrapper and overrides getDirectoryPath and getExternalUrl only.

When I set this StreamWrapper as my "Default download method" at admin/config/media/file-system and upload file using Media Browser, I do see this file created at the location it should but Media shows the "404 broken image" icon and when I add it to my node I see the 404 image also.

My StreamWrapper saves the files to a local path and serves it through CDN URL.

Do you have any suggestion about how I should work this out?


texts: How to make a webform block specific template?

texts:
i would to make a custom tpl for a webform in a block.I get is ID but actually i can't it to works.what the way to do this ? what si the folder / files structure to do this ?
i'm on drupal 6 and webform 3.x

thanks

EDIT: this my code for node-webform.tpl

<div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>">

     <?php if ($title): /*insertion du titre de la page et style differencié*/?>

<?php print $title; ?>

    <?php endif; ?>

    <?php  print $node->field_image_deco_lycee[0]['view'] /*Image deco page lycee*/ ?>

     <?php if ($submitted) { ?>
    <?php print $submitted?>
  <?php }; ?>

    <?php print $node->content['body']['#value']; ?>

    <?php print $node->content['webform']['#value']; ?>

    <?php if ($links): ?>

 <?php print $links; ?>

  <?php endif; ?>

     <?php if ($terms) { ?>
    <?php print $terms?>
  <?php }; ?>

     <?php print $picture; ?>

           <?php if ($node->field_vue_actus_lycee[0]['view']): ?>

           <?php  print $node->field_vue_actus_lycee[0]['view'] /*Vue actus du lycée*/ ?>

           <?php endif;?>

    <?php if ($terms): ?>

<?php //print $terms; ?>

    <?php endif;?>

  <?php if ($picture) { print $picture; }?>

  <?php if ($page == 0) { ?>
    <?php if ($title) { ?>

<a href="<?php print $node_url?>"><?php print $title?>

    <?php }; ?>
  <?php }; ?>


texts: Showing the description for the term identified by the argument in the Taxonomy Term view

texts:
I have a view that is a clone of the Taxonomy Terms default view, it has the depth modifier turned on.  I would like to provide the description field for the taxonomy that has been loaded in the header if it exists.  I'm using this with pathauto, so while the actual url may be something like /pub/by/geo-area/ethiopia, views gets the tid (lets say 3046) as the argument.

How can I then put the description field from that taxonomy term into the header of the view?  I tried creating a relationship for the taxonomy term content, but since I don't know at the time of creating the view what vocabulary the term will be from, and because it is possible that there will be multiple terms for that vocabulary attached to some of the nodes, that doesn't seem to be workable.

I considered an attachment, but I'm not sure how I could pull that off either.  Can I do this without an extra module?


texts: Conditionals with Combining Fields in Views

texts:
I'm having issues with rewriting the results of a field. I am trying to rewrite the field to be a combinations of 3 fields:

[field_products]
[field_downloadable_products]
[field_product]

When I preview my field I see this:

Is there a way to add a conditional statement to fix the issue where the other tokens are showing when there isn't a value there for those tokens?

Here is a view of my rewritten results:


texts: In Drupal 7 Commerce, is there a way to populate an anonymous user's profile billing/shipping address data during checkout?

texts:
This is for Commerce Core. Not Kickstart, but it can also apply.

Upon completing checkout with an anonymous user in Drupal Commerce. There is no billing / shipping data populated in the user's profile. What modules or rules are needed to have the user's billing / shipping address profile pre-filled upon successful checkout?

This is after the anonymous user completes a successful checkout and an account is automatically generated for them.


texts:
I want to use $view->set_exposed_input() to set my date filter values(date,month).
But my my knowledge about  php is weak;can you help me?
This is  php code that i using but it's not work

$view->set_exposed_input(array(
'f1' => $f1,
'f2' =>  array (
                 'year' => $year,
                 'month' => $month));


texts: How to override a view template in Bootstrap sub-theme

texts:
I'm using a Bootstrap sub-theme and am using the templates directory to override the templates for specific pages and is working ok.

I'm looking at this page in order to override the template file for a specific view, have added the file with my view name inside the template folder but its not working. Neither I can find the Bootstrap original views-view-unformatted.tpl.php in the bootstrap folder.

Can anyone point me in the right direction?


texts: Remove " edit Article " and [current-page:pager]

texts:
I'm working on a Drupal 7 site in which I'm using Meta tag module for SEO purpose. I have configured the meta-tags global and content settings.

When I try to edit a node for a content type, for example, edit an Article, inside the meta tag section in the page title field, it always displays <em> Edit title </em>, even I have removed all the tokens for this field but it still displays these tokens.

These are the global and content configurations.

This is how it displays the page title field inside the meta tags section in the content node edit page.

I want to remove <em> edit Article </em> and [current-page:pager].


texts: How do I display a specific field from an entity reference within a custom block template?

texts:
I have a custom block type that only has one field: an entity reference to my news content type. I am trying to display two specific fields from the news content type but can't figure it out.

This entity reference field has a machine name of field_featured_news

I have created a file with the filename block--block-content-testnews.html.twig

In this file, I can use {{ content }} and it will render the full entity (based on the settings in Manage Display.

However, I can't access the image field that is within the news content type. The field's machine name is called field_featured_news_image.

I have tried adding the following to no avail:

{{ content.field_featured_news_image }}
{{ content.field_featured_news_image.0 }}
{{ content.field_featured_news_image.entity.uri.value }}

and many others.

Only {{ content }} will display anything but it's the entire news node.


texts:
I have a view with some default (views) bulk operations. I needed some more (such as publish content, ...), so I added them (http://www.zyxware.com/articles/3633/drupal-7-how-to-add-your-own-custom-operation-in-views-bulk-operation-vbo), but now I need to reorder  them (so that the "publish content" is first, ... is second and so on) and can not find any way to do that (I tried to use form_alter function (with dsm on the form) on the page, where the view is shown, to debug information about the form in order to find the array containing all the bulk operations (and then rearrange it), but did not found such an array).

Do you have any ideas how to do that?


texts: Delete old columns from table using hook update

texts:
I need to delete some old columns of existing table. How to do it using hook_update or Is there some other way to delete old columns in .install file .

Thanks


texts: Problem with node revisions and taxonomy terms

texts:
I have a content type with a number of fields including a checkbox which allows you to select one or more taxonomy terms.  If I create a new version of a node, all the previous taxonomy terms are automatically included in the new node version.  I can see this in the database table "field_revision_field_catagories" (catagories is my checkbox field).

If I update the checkbox field with fewer terms checked, Drupal will not remove the existing ones.  For example:

Node Version 1 has taxonomy terms 1,3,5 7 checked and 4 corresponding records in the database table.

I use node_load() to get Version one from the database.
I update the node using a Form API form and change the checkbox to select 2 (uncheck    1,3,5,7)
save the node with node_save().

The database now has Version 2 with taxonomy records 2,3,5,7.  It updated the first record, changing it from 1 to 2.  The other 3 records are still there, however and need to be removed for my logic to work.

I guess I can use SQL to delete the records (or just delete them all after node_load()), but will that create other problems?  Is there a Drupal function I can use instead of SQL?

Thanks.


texts: Process a token from panel context in a ctools content type plugin

texts:
I have a ctools content type plugin. It has a simple text field settings form. In there I am putting a token from the panel content e.g. %vn_subject:vn-subject-facebook-link. I am then rendering this into a template. However, it is just rendering out the token as above without processing it. How can I process the token if possible to retrieve the required field value?
Thanks


texts: Is it possible to use the "Save & Edit" module with Rules?

texts:
I've created some rules to send notifications when changes some fields and  it works as I expected  when the user click on Save button.

After I enabled Save & Edit module but I receive notifications both if I click on Save and Save & Edit .

I want receive a notifications only when click on Save .

Is possible? Or is there another approach to achieve the same result?

Thank you in advance.


texts: How to stop twig debug from breaking HTML when inside tags?

texts:
Originally this was in a views field rewrite but i have since moved it to

views-view-fields--[view name]--[machine ID].html.twig

And behaviour seems to be the same:

 {{fields.title.content}}

This renders fine when twig debug is set to false in development.services.yml
When twig debug is turned on, the markup becomes badly broken.

I.e.

HTML does not support  inside tags, which seems to be the core issue.
Is there a workaround to this, or it's just a limitation of Twig debug?


texts: Display User Author Details in Block UserProfile

texts:
I am looking to display my own block on user profile page. The block will to display the username of the user whom profile we are viewing.

I went ahead and created a view, show users, block.

Added contextual filter for UIID, Raw value from URL.
Path component 2

User profile and a user sub-pages have this structure:
domain.com/u/username (user main profile page)
domain.com/user/845/posts (user posts, where 845 is uid)

How can I add a contextual filter that will work on both cases? The username is changed a little by path auto. Dashes, commas, uppercases and such are removed so that may be why raw value from URL is not working.

Btw, I am open to creating a custom user profile by creating user/% view for user profile.


texts:
I am having hard time displaying drupal message for anonymous users. My scenario is, I need to display message if there is certain query string and remove the query string with message. I am using following code but without success. I also tried with session variable without success.

 if(isset($_GET['action']) && $_GET['action'] === 'loggedoff'){
    drupal_set_message(t("We are sorry. While you have successfully authenticated, you are not yet entitled to access this site. Please ask the site administrator to provision access for you."));
    \Drupal::logger('vrpboostrap')->notice('query parameter has value loggedoff');
    $url = \Drupal::service('path.current')->getPath();
    $alias = \Drupal::service('path.alias_manager')->getAliasByPath($url);
    $alias = strtok($alias, '&');
    header('Location: '. base_path() . $alias);
    exit;
  }

With Session variable, I tried with:

if (isset($_GET['action']) && $_GET['action'] === 'loggedoff') {
    $_SESSION['vrp_action'] = 'loggedoff';
    $url = \Drupal::service('path.current')->getPath();
    $alias = \Drupal::service('path.alias_manager')->getAliasByPath($url);
    $alias = strtok($alias, '&');
    header('Location: ' . $url);
    exit;
  }
  if (isset($_SESSION['vrp_action']) && $_SESSION['vrp_action'] === 'loggedoff') {
    drupal_set_message(t("We are sorry. While you have successfully authenticated, you are not yet entitled to access this site. Please ask the site administrator to provision access for you."));
    session_unset('vrp_action');
  }

Can you guys advise me what am I doing wrong here and to display message for anonymous users?


texts: Add JavaScript to a page without access to core files?

texts:
I apologize in advance if this is a really simple question, but I'm pretty new to Drupal and still figuring out my way around things. So I was wondering if it is possible to add JS to a certain node or page of Drupal if I don't have access to the core library of files? I've searched around before and a lot of people have talked about somehow inserting a file into the directory, but I'm only granted access to the Drupal pages and the Appearance settings where I can add to/edit the CSS of a page.

Thanks!!


texts:
In Drupal 7 I put in settings.php this:

$base_url = 'http://mysite.local';

And when I run:

$ drush uli
http://mysite.local/user/reset/1/1460387746/mTqwCdJ7hi_pmrPRuFOScYwFtoHTmVAW07MV23O3UVk/login

The url generated will be fine.

In Drupal 8 I check and still there.

But in my Drupal 8 site, when I try run:
$ drush uli

I got:

mysite does not appear to be a resolvable hostname or IP, not starting browser. You may need to use the --uri option in your command or site alias to indicate the correct URL of this site.                          [warning]
http://mysite/user/reset/1/1460387905/ntObZiBxAnYdgGoc9jLqCIeQYpN_WjO04UlXcfSNZMo

I know I can do this:
$ drush uli --uri='mysite.local'

But much work.

Too I can do this with some drush config.

Then, how I do this like Drupal 7 in settings.php?


texts: Calling theme_hook_suggestions inside template.php

texts:
I am using template_preprocess_block() to introduce a theme function like this:

$variables['theme_hook_suggestions'][] = 'block_system_main_front';

but adding MY_THEME_block_system_main_front() to my template.php file does not change anything, MY_THEME_block_system_main_front() is not being called.

How can I introduce a custom theme function using theme_hook_suggestions and then use it like I use theme_image_formatter() ?


texts:
I encountered a conflict when I tried using logintoboggan and password tab modules together.

What I wanted to was to cancel the password requirement when users sign up and set their password when they confirm email addresses.

But the issue is, set your (initial) password form does not show up when I install the password tab module.

Anyone has solution for this?


texts: Passing argument parameter from Drupal Panel page into View in Drupal 7

texts:
I am having issues using View display in a Panel, on Drupal 7 (using Panopoly), from one of the Pages in our Drupal 7 site. We are having problems passing parameters from Panels into Views.

I would like to allow passing the Taxonomy Name (in lowercase), from a Page (using Panels), to one of the Views on that page.
At the same time, I would like to pass the Taxonomy ID (tid) in the same manner.
Then, with Contextual Filters (which are used in the View), I would like to filter those news articles.

For example, it should allow both:
news/3 and news/latest, showing same results.

Could someone help me or point me in the right direction?

Thank you in advance!


texts: User registration form: Give username "username n+1" value, if and when n is already used

texts:
I'm using the first & last name in the user registration form to generate the username for the new user:

$firstname = $form_state['values']['field_firstname'][LANGUAGE_NONE][0]['value'];
$lastname = $form_state['values']['field_lastname'][LANGUAGE_NONE][0]['value'];
$username = $firstname.''.$lastname;
$result = db_query("SELECT COUNT(*) FROM {users} WHERE name = :name", array(':name' => $username));
$results_number = $result->rowCount();
if ($results_number == 0) {
    $form_state['values']['name'] = $username;
}
else {
    $i = 1;
    $username = $firstname.''.$lastname.''.$i;
    while ($results_number > 0) {
        $result = db_query("SELECT COUNT(*) FROM {users} WHERE name = :name", array(':name' => $username));
        $results_number = $result->rowCount();
        $i++;
        $username = $firstname.''.$lastname.''.$i;
        $form_state['values']['name'] = $username;
    }
}

But I get an infinite loop. There is a problem with that while loop, any suggestions on the best way to fix that?


texts: How to replace the search submit button with a Font Awesome character?

texts:
I would like to replace the search submit button with a Font Awesome character like the Magnifier (Search Icon) character, and put Search the site inside the search box.

How can I achieve something like this?


texts: Ajax in a template file to show the value of session variable

texts:
I have a webform in my node.tpl which action points to hook_menu url of a module.

When the form submit happens, it compiles the form data in the custom module and stores the response value in a session variable; then, the page is reloaded and the session variable printed in the node template.

I want to show the same session variable without reloading the page.

Can anyone help me for this?


texts:
I am using Media and Wysiwyg with CKEditor to insert images in the post editing field, and for some reasons I keep getting this code instead of my images.

Does anyone know how to fix it?

[[
  {
   "type" : "media",
    "view_mode" : "media_large",
    "fid" : "412",
    "attributes" : {
      "alt" : "",
      "class" : "media-image",
      "typeof" : "foaf:Image"
    }
  }
]]

[[
  {
    "type" : "media",
    "view_mode" : "media_large",
    "fid" : "395",
    "attributes" : {
      "alt" : "",
      "class" : "media-image",
      "typeof" : "foaf:Image"
    }
  }
]]

I fixed it; you have to go into Administration » Configuration » Content authoring » Text formats and check the box Converts Media tags to Markup.


texts:
a try change the ajax callback button but i can't, i use *hook_form_alter*()

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

    $form['field_publicidad'][$language][0]['add_more']['#ajax']['callback'] = '_sample_add_more_callback'

}

someone can help me?


texts:
I've got a blog set up on my site, with a separate page holding all the blog posts.
I've created a custom content type for making the individual blog posts so when a new post is created a preview is displayed in a list under a 'view', like any normal blog.

I would like to know how can I also list the blog previews (or teasers) on the home page as well as the main blog page?


texts: connect apache solr to a custom search function

texts:
I am having some trouble with creating a search module (dictionary) that uses apache solr.
The current module is connected to a solr instance from a different source that has a indexation from a postgresql database with it's own schema.

Now I'm in the process migrating all the content to nodes in Drupal and so far so good.
The thing now is that I need to change the search request from the current solr to Drupal apachesolr with its standard schema. Problem is that I am relative new to how solr works, but I do understand the basic structure.

Anyone that might be able to give me a hand or point me to some kind of documentation to how to do this?

I tried to change the query search quartiles from what i could find in the schema . The only thing keep getting when i do a search is "Your search yielded no results"

Here is the cod in the callbacks.inc file unmodified

<?php

function ne_norstedts_page($types) {
  $ret = '';

  $form = drupal_get_form('ne_norstedts_search_form', $types);

  // Render search form.
  $ret .= '
';
  $ret .= render($form);
  $ret .= '
';

  // Get search results and output them
  isset($_GET) ? extract($_GET) : '';
  if (isset($q) && isset($from) && isset($to) && isset($type)) {
    $query = array(
      'q'  => $nq,
      'fq' => 'type:norstedts AND subtype:' . $from . '-' . $to . '-' . $type,
      'start' => isset($page) ? ($page) * 10 : 0,
    );

    $result = ne_api_get_api_fetch('/search', $query);

    $title = '';
    foreach ($types as $t => $name) {
      if ($t == $type) {
        $title = $name;
        break;
      }
    }

    $ret .= theme('ne_norstedts_results', array('result' => $result['result'], 'title' => $title));
  }

  return $ret;
}

/**
 * Gets text for a single word for ajax
 */
function ne_norstedts_ajax_load_word() {
  $url = isset($_GET['url']) ? $_GET['url'] : '';
  if ($url) {
    $result = ne_api_get_api_fetch($url);
    if (isset($result['text'])) {
      echo drupal_json_encode($result['text']);
    }
  }
  exit;
}

and here is my modified version of it

<?php

function ne_dictionary_page($types) {
  $ret = '';

  $form = drupal_get_form('ne_dictionary_search_form', $types);

  // Render search form.
  $ret .= '
';
  $ret .= render($form);
  $ret .= '
';

  // Get search results and output them
  isset($_GET) ? extract($_GET) : '';
  if (isset($q) && isset($from) && isset($to) && isset($type)) {
    $query = array(
      'q'  => $nq,
      'fq' => 'site:' . $from . '-' . $to,
      'start' => isset($page) ? ($page) * 10 : 0,
    );

    $result = apachesolr_search_search_page('/search', $query);

    $title = '';
    foreach ($types as $t => $name) {
      if ($t == $type) {
        $title = $name;
        break;
      }
    }

    $ret .= theme('ne_dictionary_results', array('result' => $result['result'], 'title' => $title));
  }

  return $ret;
}

/**
 * Gets text for a single word for ajax
 */
function ne_dictionary_ajax_load_word() {
  $url = isset($_GET['url']) ? $_GET['url'] : '';
  if ($url) {
    $result = apachesolr_search_search_page($url);
    if (isset($result['text'])) {
      echo drupal_json_encode($result['text']);
    }
  }
  exit;
}


texts:
I am using following code to render node comment form in a block:

$comment_form = drupal_get_form('comment_node_<node_type>_form', (object) array('nid' => $nid));
print drupal_render($comment_form);

It is working fine.

Now I need to check if a user has already commented on the node. If the user has not commented than I will show him/her this comment add form.

But in case, the user has already placed a comment for the node, I want to show him/her the edit form for his/her comment, where he/she can make changes and save thus updating the existing comment instead of saving new.

Any suggestions?


texts: Do you have an example of hook_menu() access callback?

texts:
I have downloaded the examples project, but in the menu_example module all the access callback are set to true.. hard to understand how it works.

In my example, my meno entry should be visible on nodes, but only for roles that have the permissions to edit his own nodes.

I cant find an example a bit more verbose of an access callback.

Do anyone have one?


texts:
got a problem with the EU Cookie Compliance module. I installed it and it only worked when you were logged in (my site uses SSL).  Then I realized I hadn't set the permissions so that the cookies message is displayed to Anonymous users.  Now the message doesn't appear to anyone, logged in or not.  I've made sure the cookie is deleted from the browser, but still no luck.  Any ideas please?

The site is http://idea.nottingham.ac.uk.

No message displayed for anyone since I added Display permissions for anonymous users. Before, it wasn't displaying message for 'guests', only logged in users.

Interestingly, it does work (for both guests and logged-in users) on my Bitnami development copy of the website where SSL is switched off.


texts: Inherit all styles from base theme expect a few

texts: I am doing a base theme and child theme. I want the child theme to inherit all the css from the base theme expect a few for which i will have the stylesheet in this child theme. How will i achieve this ?


texts: Content type which contains a content creation as a slip form

texts:
I'm quite new to Drupal and I've encountered a quite complicated problem.

I've created a role called "Event coordinator" authorized to create a content type entitle "Events" that has a title and and a description, and for which comments are disabled. Here is a sample of it:

Title: "Join Our Club".
Description: "It will be fun".

I've also created another role called "Audience" which will be used by the user who will attempt to join the event detailed in the content created by the "Event coordinator".

The "Audience" should create a "Slip" content which will have a request message. And it should be sent to the targetted "Events".

A "Slip" that gets created will be put (somehow) in another content which is the "Events". The "Event coordinator" then will choose whom will join an event based on the "Slips" that were created.

Only the "Event coordinator" and the owner of a slip (created by "audience") will be able to see a "Slip".

I've tried to use the "entity-registration" but it's not that flexible. I mean as an "Event coordinator" I'm not able to see all the "Slips" from all "Events" I created. It will just show the "Slips" when you view the content of a single "Event".

Any suggestions about which module(s) I could use to implement this?


texts: Can anyone advice me on how I can discover the active cookie details for a user logged into a Drupal website?


texts: I'm a long-time Drupal 7developer, and tried a Drupal 8 install yesterday for evaluation. I installed a bunch of contrib modules. All seems ok, but when I go to the home page, I'm presented with a login screen. I want anonymous users to be able to see the site, how can I allow this? I don't see any settings to force login, and am not using the shield module.


texts: Webform submissions to be seen on Drupalgap

texts:
I am making a DrupalGap application to view Webform submission.

I have made a view in Drupal as a table to list the submissions, now I want to see that table in DrupalGap.

How do I do that?


texts: Commerce doesn't handle Sagepay Form Integration return

texts:
So I'm using SagePay Form Integration on my site, but it has ceased to function correctly.

So on the Payment Stage of Checkout it says 'Use the button below to proceed to the payment server.'. Now I successfully complete a payment on the Sage Pay Testing Server and it comes back to the site URL checkout/order_id/payment/return attached with some GET vars.

The issue is that when it returns, checkout just displays 'Use the button below to proceed to the payment server.' again. The status of the order hasn't been updated and the user isn't ushered to the complete stage. Any idea why this is?

After further inspection it also seems that under Store > Orders it isn't logging the payment as it had previous. The order just remains at the payment stage in 'Shopping Carts'
tab of Admin > Store > Orders.

I'm having this exact same issue with all of the following versions:

7.x-1.0-beta2
7.x-1.0-beta1
7.x-1.x-dev

Your help would be greatly appreciated!


texts:
I'm trying to redirect some old urls to the new Drupal ones with .htaccess rules.

This works

Redirect 301 /oldurl http://mysite.com/new-url

But this gives me a Drupal error

Redirect /people/details.aspx?id=1234 http://mysite.com/name-surname

Is it possible to perform a redirect like this?

The errors I get are

Warning: array_flip() expects parameter 1 to be array, string given in DrupalDefaultEntityController->load() (line 178 of /var/www/includes/entity.inc).

Warning: Invalid argument supplied for foreach() in DatabaseCondition->compile() (line 1854 of /var/www/includes/database/query.inc).

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 2: SELECT revision.vid AS vid, base.uid AS uid, revision.title AS title, revision.log AS log, revision.status AS status, revision.comment AS comment, revision.promote AS promote, revision.sticky AS sticky, base.nid AS nid, base.type AS type, base.language AS language, base.created AS created, base.changed AS changed, base.tnid AS tnid, base.translate AS translate, revision.timestamp AS revision_timestamp, revision.uid AS revision_uid FROM {node} base INNER JOIN {node_revision} revision ON revision.vid = base.vid WHERE (base.nid IN ()) ; Array ( ) in DrupalDefaultEntityController->load() (line 196 of /var/www/includes/entity.inc).

My new rules begin before the Drupal rules of

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]

As suggested I have tried redirecting to non clean URLS. This works

Redirect 301 /oldurl http://mysite.com/?q=new-url

But the URL stays as that which isn't any good as there will then be duplicate URLs of http://mysite.com/?q=new-url http://mysite.com/new-url

I tried

Redirect 301 /people/details.aspx?id=1234 http://mysite.com/?q=name-surname

But I still get the same errors as before


texts: How to prevent multiple votes in polls of the rate module?

texts: I have installed the rate module, and set the emotion widget. I like this module but  after I vote successfully, I can click the vote button again. Instead I want to popup a window which says" you have voted. don't vote again", to prevent people from voting multiple times.


texts: How to implement custom access to node revisions?

texts:
I want to implement a custom access check in Drupal 8, where users assigned to the node field node-owner have view/edit and revisions view/edit permissions for this specific node.

I have implemented it for node view/edit using the node access system with hook_node_access_records() and hook_node_grants(). But I cannot find how to implement it for the node revisions, since the access check performed in NodeRevisionAccessCheck takes into account only the 'view revisions' and 'revert revisions' role permissions and I cannot see a relevant hook.

Should I do custom access checking on routes as described here?
https://www.drupal.org/docs/8/api/routing-system/access-checking-on-routes

And if yes, how do I implement the route check and fetch the current node?


texts: Can you display data dynamically from a textfield in the URL and Name of Views?

texts:
I have a content type of Product which includes a text field for the user to enter a Brand. This text field is open to the users to enter correctly, as there are hundreds of brands and I don't want them to have to learn how to enter taxonomy terms.

I am wondering if there is a way to dynamically create a View that will also dynamically generate the page name and page URL depending on the brand, and then display a table view of all of the Products with that Brand.

So for example if I have /category/brand/product-name as the parameters for the URL, for a specific product it would be /tshirt/busted/open-road, and with Busted being the Brand entered by they user, the view would automatically create the /busted url, and populate it only with Busted brand products in a table view.

Is this possible? I was thinking perhaps I needed to use tokens to grab the [node:field_brand], but I am unsure exactly how I would do this, or if it was even possible. Also, if there is a better way of handling this data instead of a textfield, I would like to know!


texts:
I've created a View that lists when a user has last logged in, using table format. I'm wanting to add a field that's a link to remind the user to login again (I've used a UID field and am rewriting the output to be a link, with UID as an argument at the end).

What's the most sensible way to trigger an email via Views?

Thanks!


texts: Module to do an action based on content type user sees

texts:
I would like to achieve, for my custom module, this behavior:

It triggers only when user sees the node of some content type
It does a calculation based on field present in that content type
(it checks the values of taxonomy term assigned to that node)
It prepares a variable based on calculation (it might be a complex query)
article.tpl.php is injected with the content of that variable


texts: Altering all urls to include extra information

texts:
What hooks are available for altering the urls? For example, there are language modules that, when enabled, provide urls such as /en/node/1 rather than leaving it as /node/1.

I want to have something similar in the url, that I can have access to without having other functionality compromised.

How is this accomplished?


texts: How to migrate fields attached to files?

texts:
I'm writing a file migration using migrate/migrate_d2d to migrate files from one Drupal 7 installation to another.

Images have custom fields attached to them, including a text field "field_boilerplate". This field exists in the destination site's image type. When I run the migration, the image itself migrates and creates an image entity, but field_boilerplate is not populated.

What am I doing wrong, and how can I migrate fields attached to files?

In mymodule.module:

/**
 * Implements hook_flush_caches().
 */
function mymodule_flush_caches() {
  mymodule_migrate_register_classes();
}
/**
 * Register dynamic migration classes
 */
function mymodule_migrate_register_classes() {
  // Arguments common to all migrations
  $common_args = array(
    'source_connection' => 'mysite_legacy',
    'source_version' => 7,
    'group_name' => 'mymodule_migration',
  );
  // Other migration arguments redacted for length
  // Image migration arguments
  $image_args = array(
    'machine_name' => 'images',
    'class_name' => 'MyModuleImageMigration',
    'description' => t('Migrate images'),
    'user_migration' => 'users',
    'default_uid' => 1,
    'source_dir' => 'http://example.com/sites/default/files',
    'destination_dir' => 'public://',
    'skip_pictures' => TRUE,
  );
  Migration::registerMigration('MyModuleImageMigration', 'images', $image_args + $common_args);
}
/**
 * Implements hook_migrate_api().
 */
function mymodule_migrate_api() {
  return array('api' => 2);
}

In an included file:

<?php
class MyModuleImageMigration extends DrupalFile7Migration {
  public function __construct($arguments) {
    parent::__construct($arguments);
    // Mappings
    $this->addFieldMapping('field_boilerplate', 'field_boilerplate');
  }
}


texts: Write a module to replace jquery with another js library

texts: jQuery is great. But sometimes it's not exactly what I want. What would it take to write a module that could enitrely replace jquery with something like mootools or closure? Would this even be possible without hacking core modules?


texts: Installing the Media Module + WYSIWYG Module on Acquia Cloud

texts:
I'm trying to get the Media module (and it's dependent WYSIWYG module) working on an Acquia Cloud environment. Normally, this isn't too bad locally but Acquia has a strange file structure that is giving me some headaches.

I have installed and activated both WYSIWYG along with Media but neither are working correctly. WYSIWYG needs CKEditor to work and wants it to be included in sites/all/libraries (outside of the normal modules folder). Acquia doesnt give you access to add in libraries like that.

Media isn't showing the library when a user accesses a content-type with an image field that use's Media's 'Media file selector' widget.

Im guessing a lot of this is due to path problems, but the only documentation Acquia has about their file structure is here (and this mostly pertains to the files folder - not core + contrib paths):
https://docs.acquia.com/cloud/files

So my question is two fold:

How do you get CKEditor into an Acquia Cloud instance with the WYSIWYG module?
Why wouldnt media show its library? Am I leaving another module out maybe? Path issue?


texts:
I want to import the fields "alt", "title" and the custom field "copyright_notice" via feeds using the following code:

function budg_eu_projects_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
  foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {

    $info = field_info_field($name);

    if ($info['type'] == 'file') {
      $targets[$name . ':alt'] = array(
        'name' => t('@label: Alt', array('@label' => $instance['label'])),
        'callback' => 'budg_eu_projects_set_target',
        'description' => t('The alt tag of the @label field.', array('@label' => $instance['label'])),
        'real_target' => $name,
      );
      $targets[$name . ':title'] = array(
        'name' => t('@label: Title', array('@label' => $instance['label'])),
        'callback' => 'budg_eu_projects_set_target',
        'description' => t('The title of the @label field.', array('@label' => $instance['label'])),
        'real_target' => $name,
      );
      $targets[$name . ':copyright_notice'] = array(
        'name' => t('@label: Copyright Notice', array('@label' => $instance['label'])),
        'callback' => 'budg_eu_projects_set_target',
        'description' => t('The title of the @label field.', array('@label' => $instance['label'])),
        'real_target' => $name,
      );
    }
  }

  return $targets;
}

As a callback function I use

/**
 * Callback for mapping file fields.
 */
function budg_eu_projects_set_target(FeedsSource $source, $entity, $target, array $values) {

  list($field_name, $sub_field) = explode(':', $target . ':uri');
  $info = field_info_field($field_name);

  // Populate entity.
  $field = isset($entity->$field_name) ? $entity->$field_name : array(LANGUAGE_NONE => array());
  $delta = 0;

  foreach ($values as $v) {
    if ($info['cardinality'] == $delta) {
      break;
    }

    if (!isset($field[LANGUAGE_NONE][$delta])) {
      $field[LANGUAGE_NONE][$delta] = array();
    }

    $field[LANGUAGE_NONE][$delta][$sub_field] = $v;

    $delta++;
  }

  $entity->$field_name = $field;
}

I managed to add the fields as a mapping target but the data of the fields are not saved. What is missing?

Thanks
Rainer


texts: How to display List price,Price,You Save in Commerce Module using commerce discount module using view

texts:
I have used drupal commerce discount module. then I give the discount for particular product (admin/commerce/store/discounts).
and
I have set the format of price (admin/commerce/products/types/product/display)
  Formated amount with saving(inline)
     Displaying a calculated price
     Showing: List price, Price, You save
     Labels shown
     Savings displayed as the percentage.

then I have check List price,price,You save in view price format but only price is display throught view.
but I want List Price,Price and You Save Display.


texts:
I'm attempting to add a lot of terms (~200) to a vocabulary, but I can't find any import modules that are updated for Drupal 8, and it seems the functions for doing this in Drupal 7 don't exist in Drupal 8. So, can anyone point me in the right direction for doing this?

I attempted to do it with entity_create, as suggested in the comments, with this code:

$term_create = entity_create('taxonomy_term', array('name' => 'test', 'vocabulary_name' => 'client'));

but I got this error:

Drupal\Core\Entity\EntityStorageException: Missing bundle for entity type taxonomy_term in Drupal\Core\Entity\FieldableEntityStorageControllerBase->create() (line 65 of core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php).

Any ideas?


texts:
I have a form that has 15 dates for training. I have handlers set for each session to be limited to 25 participants. Now I have been ask to turn off the registration for each of the 15 dates 24 hours prior to that date.
Is it possible to set source entities to hide the dates 24 hours prior to the date?


texts: I'm working on a scenario where users should not be able to access others' files. So, I wrote a custom module that creates a folder names user's name, then I went on to /admin/config/media/imce to set permissions and I typed php: return 'users/'.$user->name as instructed on the same page. However, that gives me Parse error: syntax error, unexpected end of file in DRUPAL_ROOT/sites/all/modules/imce/inc/imce.page.inc(789) : eval()'d code on line 1 and There is no valid directory specified for the file browser!. What to do? Any suggestions?


texts: Trouble adding markup in a node with hook_node_view()

texts:
I'm trying to add a piece of markup with a field in hook_node_view().  It's a little thumb icon for a music site, and I want to overlay this image over another field image (which I'll do with CSS).  However, it's not rendering, and I feel pretty confident that I'm going about it the right way. Here is my addition to the node array:

$node->content['like'] = array(
            '#theme' => 'image',
            '#path' => '/sites/default/files/likeimg.png',
            '#alt' => 'like',
            '#prefix' => '
',
            '#suffix' => '
',
            '#weight' => -1,
            '#attributes' => array(
                'class' => array('like-img')
            )
        );

What am I missing?  I am using Display Suite with fields in blocks, and Omega 3.


texts:
I have created a module named menu_bold and has dependency over menu_ui. Weight of menu_ui is 0 but menu_bold module has been changed to 1.

Now when the function hook_form_FORM_ID_alter is calling, it is firing first from menu_bold rather than menu_ui, indeed menu_ui has weight 0 and menu_bold has 1.

Why is this happing ?


texts: Placing user login and user menu at the bottom right when this is not supported by the theme

texts:
I'm new at Drupal and am building a site with the Bootstrap theme, and i would like to place the user login and user menu in the lower right corner. Unfortunately there is no region for that, there is just the footer region which covers the whole width of the screen

What is the best way for me to add the user login and user menu to this area?

This would have been a problem if i just wanted to place the user login and user menu below, because when setting contents of the blocks they are placed vertically on top of each other. But in my case this wouldn't look good, i would need the stacking to be done horizontally instead of vertically

I can think of two different approaches:

Modifying the bootstrap theme so that there is a region in the lower right
Modifying the code of the footer to include the content of the "user login" and "user menu" blocks (maybe using this as a guide)
Maybe using the panels module?
Somehow getting the stacking to be done horizontally rather than vertically

Which of these would you recommend? Are there other approaches that are better?

It's important that the site is easy to maintain long-term and that we can continue to use the auto-update for the bootstrap theme

Grateful for any suggestions!


texts: Is it possible to change the layout for a content type through CSS? How do I do it?


texts: How do I avoid the "too many connections" error message is shown?

texts:
How do I avoid the following error message is shown to normal users?

  PDOException: SQLSTATE[HY000] [1040] Too many connections in lock_may_be_available()


texts: Why does file_validate_extensions fail to validate?

texts:
I'm using the following code for validating and uploading a file from a form:

function request_form_submit($form, &$form_state) {
    $validators = array('file_validate_extensions' => array('png'));
    $file = file_save_upload('spectrum', $validators);
    if ($file) {
        //do stuff
    }

Uploading works, but I want to allow only png files to be uploaded. The validation part does not work at all, file uploading is always successful no matter which extension the uploaded file has.

I also tried giving a space separated list of extensions to file_validate_extensions as mentioned in the documentation, but that didn't change anything.

Any idea what I'm doing wrong here and why this doesn't work at all?


texts: drupal_render does not render concatenated elements

texts:
I am new to Drupal and wonder if users who have experience in this kind of questions can help me with my issue.

The problem is that the output of $complete0 through drupal_render() results in an empty space. Replacing $complete0 with either $title0 or $name0 works just fine, however trying to render a concatenated field does not get the job done. Please see the piece of code below:

    try{
        $title0 = field_view_field('profile2', $user['recommendation'], 'field_rec0_title');
        $name0 = field_view_field('profile2', $user['recommendation'], 'field_rec0_title');
        $complete0 = "{$title0} {$name0}";
    }
    catch (EntityMalformedException $e) {}
    if(empty($complete0)){
        $form['profile_evaluation']['field_field_eval_rec0']['und']['#title'] = 'Information missing';
    }
    else{
        $complete0['#title'] = 'Recommender 1';
        $form['profile_evaluation']['field_field_eval_rec0']['und']['#title'] = drupal_render($complete0);
    }


texts: Proper way to package translation files with a custom module?

texts:
I have a custom module. In this module all strings are in English. However, my website is in French and when installing the custom module, I'd like the French strings to be picked up and imported automatically.

What's the best way to generate and then package the .fr.po translation file with my custom module?

(With D7, I would use potx to generate the .po file for my module, then I'd put the file under sites/all/modules/custom/MYMODULE/translations. But potx no longer exists for D8 and the d.org documentation isn't very helpful.)


texts:
I'm running into an issue when updating to Drupal core 8.8.0. I've removed both the vendor folder and the composer.lock file, as per instructions on this link
https://www.drupal.org/node/2700999#s-special-considerations-for-upgrading-to-drupal-880-and-later

I run composer require drupal/core-recommended:^8.8 --update-with-dependencies
and I get the following:

  Problem 1
    - Conclusion: don't install drupal/core 8.8.5
    - Conclusion: don't install drupal/core 8.8.4
    - Conclusion: don't install drupal/core 8.8.3
    - Conclusion: don't install drupal/core 8.8.2
    - Conclusion: don't install drupal/core 8.8.1
    - Conclusion: don't install drupal/core 8.8.0
    - Conclusion: don't install drupal/core 8.8.0-rc1
    - Conclusion: don't install drupal/core 8.9.0-beta2
    - Conclusion: don't install drupal/core 8.9.0-beta1
    - Conclusion: don't install drupal/core 8.8.0-beta1
    - Installation request for acquia/lightning 4.0.4 -> satisfiable by acquia/lightning[4.0.4].
    - Conclusion: don't install drupal/core 8.8.0-alpha1
    - Conclusion: don't install drupal/core 8.9.x-dev
    - acquia/lightning 4.0.4 requires drupal/claro ^1.0 -> satisfiable by drupal/claro[1.x-dev, 1.0.0-beta1, 1.0.0-alpha5, 1.0.0-alpha4, 1.0.0-alpha3, 1.0.0-alpha2, 1.0.0-alpha1].
    - don't install drupal/core 8.8.x-dev|don't install drupal/claro 1.x-dev
    - don't install drupal/core 8.8.x-dev|don't install drupal/claro 1.0.0-beta1
    - don't install drupal/core 8.8.x-dev|don't install drupal/claro 1.0.0-alpha5
    - don't install drupal/core 8.8.x-dev|don't install drupal/claro 1.0.0-alpha4
    - don't install drupal/core 8.8.x-dev|don't install drupal/claro 1.0.0-alpha3
    - don't install drupal/core 8.8.x-dev|don't install drupal/claro 1.0.0-alpha2
    - don't install drupal/core 8.8.x-dev|don't install drupal/claro 1.0.0-alpha1
    - Installation request for drupal/core ^8.8.0 -> satisfiable by drupal/core[8.8.0, 8.8.0-alpha1, 8.8.0-beta1, 8.8.0-rc1, 8.8.1, 8.8.2, 8.8.3, 8.8.4, 8.8.5, 8.8.x-dev, 8.9.0-beta1, 8.9.0-beta2, 8.9.x-dev].

At this point, running composer prohibits drupal/core:8.8.0 won't work because I removed drupal/core as per instructions in the link above.

I can successfully update to 8.7.13, so maybe I can settle for that for now. But our team wants to be ready for Drupal 9 and upgrading to 8.8 will make that transition easier, I hear.

Should I update to 8.7.13 first, before attempting to upgrade to 8.8?

EDIT
I'm able to update to Drupal 8.8 by removing the vendor folder and composer.lock and removing acquia/lightning. I reinstalled acquia/lightning after Drupal core was added.
I am now running into issues when running drush dbupdate.


texts: How to create a custom paragraph block that preprocesses multiple Javascript Files?

texts:
I am trying to create a custom block that preprocesses inputted JS files in a node to load in the header of specific pages that have that block reference in a paragraph.

if ($vars['elements']['#id'] == 'myblock') {
    $vars['#attached']['library'][] = $vars['content'][''];
  }

What do I need to add to this to make it so it will read what is in the block and load that js if the block is referenced in a node?

I am a bit lost so any help would be great!


texts: how can I manipulate functionality or the structure of an existing form?

texts:
How can I manipulate functionality or the element's structure of an existing form in a different way and create my own template?

For example, I can use below code to display a user login form page, but this code doesn't have any flexibility and doesn't allow me to edit or customize each part of this form element separately and I can't change the look and order of this form straightforwardly.
Imagine that I want to add show password checkbox and other visual effect and style to that's form element.

Page--user.html.twig

{{ page.content }}


texts: How to set the node ID to start with 100,000?

texts:
I am running a new site with Drupal 7.

I want the node ID to start with 100,000.

How do I set it? I don't want the node start with node 1.


texts: After upgrade from OG6 to OG7 directly to ver. 2.x: Is there any possibility to use OG migrate (available only in OG 1.5)?

texts:
I´ve realised that OG Migrate is only in 7.x-1.5 but NOT in OG 2.x.

I´ve accidentally updated my site from D6 to D7 directely to OG 2.x.

Is there anything I could do to use OG migrate?


texts: Attach different CSS classes to first and second link

texts:
I have a Paragraph type 'Call to action' with one link field field_link.

I have another Paragraph type where I call the 'Call to action' paragraph as an Entity reference revisions field. With Allowed number of values set to 2.

So the editor is able to insert two Call to action links.

I want to attach 2 specific CSS classes to both links:

On the first link:

Button one

On the second link:

Button two

How do I loop through, so I am able to attach different classes?

Update:

In paragraph--call-to-action.html.twig I added:

{% block paragraph %}

{% for item in content.field_link %}
    {% if loop.index == 1 %}
      Button one
    {% elseif loop.index == 2 %}
      Button two
    {% endif %}
  {% endfor %}

{% endblock paragraph %}

But now it's rendering always the 2 buttons? What's wrong here?


texts:
We are considering to migrate an exiting website to Drupal: www.rkmission-shivanahalli.org The website has simple static content which I believe is not a big deal to migrate to Drupal.

However, there is one requirement which is pretty unconventional and not many websites have it. The archives feature. What we have been doing is, since currently the website is only collection of html files, we pick the whole web folder of current edition and place it into archives folder of the website and link the new website to the index.html page of that archived folder. We also have a link to get back to the current edition from the archives section.

Please see this link for more details, the archives page of current edition: http://www.rkmission-shivanahalli.org/archives.html

One of the edition from archives page will have a link like: http://www.rkmission-shivanahalli.org/Archives/AUG_2006/index.html.

Now I am not very sure how to achieve this using Drupal. Is there any direct way to do this? Or, any modules which does it on my behalf? Or, do I have to modify any source files etc.?

Thank you for any suggestions.

PS: This is a mirror of the question already asked in Drupal forums:
http://drupal.org/node/1884930


texts:
I tried the views_php but I have no luck. Any link to its documentation?

I want to add some custom field with PHP code inside it but the one I did return nothing. Please see the attached picture.


texts:
I've added a new field to a content type, using the Entity Reference module.

The new field is to allow entry of up to 4 related articles (curated content - chosen by the admin) per article.
I've set the field to allow up to 4 values - but using the 'Autocomplete (tags style)' widget it doesn't seem possible to enter more than one option.

Any suggestions/solutions?


texts: What are some design patterns found in prominent contributed modules?

texts: Besides Presentation-abstraction-control and other patterns that are used in Drupal core, are there any other design patterns prominently used in the more popular contributed modules such as Views, CCK, and Features?


texts:
I am new to drupal.
When user register into my website I need to get the users details and passed to a thirty for server .
I am trying the following hook,

function compass_preprocess_user_insert(&$edit, $account, $category) {
  db_insert('test')
    ->fields(array(
      'accountid' => $account->uid,
    ))
    ->execute();
}

here compass-my theme name
Please help me...


texts:
I'm using data from JSON to create new nodes or update fields on existing if node exist on my Drupal 8 website. So, when I use method to update nodes, I need to save in array node id of updated nodes and keys of fields with changed values in this node.

After update is finished I need to print table with all nodes of this content type where fields of updated nodes need to have different style (color, background, etc).

So if my old node have
body = "body1" and description  = "description 1" and new node have body = "body2"and description  = "description 1" after update is finished i need to get output like this:

Here is an example:

$node = \Drupal\node\Entity\Node::load($nid);
$node->set("body", 'New body text');
$node->set("description", 'New value');
$node->save();

Any suggestion?

Note: when I use $node->save(); if all updated values is same nothing is changed (date of node in content from admin panel is same as before update), but if values is different I need to store node id, keys and values only of changed fields in array.


texts:
I am using Drupal Commerce. For the Variations, I am using multiple add /remove via AJAX.

I need to make field readonly.

0 -> <input type="number" name="variations[form][inline_entity_form][entities][0][form][field_stock][0][value]" value="0" step="1" placeholder="" class="form-number" />

1 -> <input type="number" name="variations[form][inline_entity_form][entities][1][form][field_stock][0][value]" value="0" step="1" placeholder="" class="form-number" />

I have given example with 2 variations. How can I achieve it via form_alter ?

On Add of variation I need to unset that field and at the edit time need to make readonly.

Already checked with hook_inline_entity_form_entity_form_alter() but it is not going there.


texts: How do I find and alter the Views field markup in Drupal 8?

texts:
Below is a twig template: core/modules/views/templates/views-view-unformatted.html.twig:

{#
/**
 * @file
 * Default theme implementation to display a view of unformatted rows.
 *
 * Available variables:
 * - title: The title of this group of rows. May be empty.
 * - rows: A list of the view's row items.
 *   - attributes: The row's HTML attributes.
 *   - content: The row's content.
 *
 * @see template_preprocess_views_view_unformatted()
 *
 * @ingroup themeable
 */
#}
{% if title %}

{{ title }}

{% endif %}
{% for row in rows %}

    {{ row.content }}

{% endfor %}

How do I alter the markup (and add some php logic) in row.content? - which outputs markup such as:

Hello world!

Presumably, there is another twig template for this markup? I cannot find it. I have the twig debugger turned on, but there are no notes above the markup that renders each content field.

I've looked at the template preprocess functions in views.theme.inc too - can't see any markup being generated in those things.

Thanks