texts: How to sort view with rewritten field values

texts:
I have written code with using hook_views_pre_render, I only need to have a custom sort handler which can work with the rewritten field values.

Does any professional here has a sample code for a views custom sort handler which works with rewritten values?


texts: Is a custom module the best way to build out a Form with full custom AJAX?

texts:
I have a project (problem) I've been thinking about for about a week now. When it was first presented to me it seemed to be a very easy solution, and frankly there are easy ways to accomplish this, but I don't necessarily like them. Let me lay this out though.

The Simple Problem

At its simplest this project is creating a simple (name, email, and one other field) form that will be available from any page of our site.

Let's Get Complicated

I want this form to be available on each page, but possibly tucked away with a call to action befitting our user base. On top of that I am not looking to just have a link to a Webform page, but an AJAX powered form so that my users do not lose their place in the site if they choose to submit their information.

So what's the ultimate problem?

I've looked into modules like Webform AJAX, but they don't allow the kind of fine grain AJAX control I want. I've done research into the Form API (Which, btw, if you have a great resource for understanding this better, please feel free to pass it along.), and it would appear that to accomplish everything I want to do with this simple form would require me to create a custom module.

Questions I have.

Is that right?
Am I way off base?
How much have I over-thought this project?

Thanks in advance.


texts: How do I get the weight of a multiple value field collection in a computed field?

texts:
I have the following structure in a content type:

. field_collection_parent (multiple value = 7)

.. computed field (single value)

.. field_collection_child (unlimited multiple value)

field_collection_parent represents the days of the week and field_collection_child are some work reports of each day. The computed field returns the day (monday, tuesday, etc.)

The problem is that I can have data in the first and thrid items of the field_collection_parent (that is Monday and Wednesday), but when I save the node, I only have two rows, because the second was empty, and computed returns Monday and Tuesday.

So, is it possible to get the weight of each field collection item although they were empty, and code it in the computed field?

Thanks.

P.D. I tried

$wrapper = entity_metadata_wrapper('field_collection_item', $entity);
$entity_field[0]['value'] = print_r($wrapper->delta(), true);

as indicated in
"how to get weight or delta of current field collection item that is being computed" but it returns "Fatal error: Call to undefined method EntityDrupalWrapper::delta()"


texts:
I would like to override the buildForm() method of the Comment module in my custom module.

The method is defined in core/modules/comment/src/Form/CommentAdminOverview.php.

To achieve this, I've created myModuleName/src/Form/MyModuleNameCommentAdminOverview.php, whose first lines are the following.

namespace Drupal\myModuleName\Form;

use Drupal\comment\CommentInterface;
use Drupal\comment\Form\CommentAdminOverview;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\user\PrivateTempStoreFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;

class myModuleNameCommentAdminOverview  extends CommentAdminOverview {
  public function buildForm(array $form, FormStateInterface $form_state, $type = 'new') {
    // ...
  }
}

In myModuleName.info.yml I have these lines.

 dependencies:
  - comment:comment

My code is not working. What am I doing wrong?

I have read the following, but I don't understand what I'm doing wrong.

Need to override single Drupal 8 plugin function
Override or extend function of a contributed module
Overriding the function of a module in another module


texts: Ubercart how to provide expiry option for a product if its not in auction?

texts:
How to provide option for products to be automatically expired using ubercart.

I know one solution could be scheduler.

Is there any other solution which can be applicable only for add to cart  products alone instead of auction item which already has expiry dates.

Thanks in advance.


texts: Facebook Connect button in Overlay (Drupal 7)

texts:
I've been helping a friend with a site, and recently run into a road block.

I've installed FB connect, set up an app, and it's working well from the home page.  However, he has an overlay installed for most of the forms and the Connect button doesn't display on the forms.

I've tried almost every variation that I can think of/find and nothing seems to be working.

Any advice?

I'm not able to post an image, but the sanbox site is at central-mining.com, just click on either of the login/registration links on the top menu.


texts: How to restrict group node access to a user/member of an group?

texts:
I am using the Group module and I have created a group called "Group-Y" and group type "Group-type-Y". I also defined a group role name "Admin". Added an member with role "Admin".

I have checked this module, which provided the access based on page,

https://www.drupal.org/project/page_access

Page access module does work with global user admin, like here:

I tried to achieve it for group admin. In the edit node, page access settings are not displayed.

I need to achieve to restrict node based on user/role in a group. Can anyone help me out?


texts: How can I get the translated path to the current node?

texts:
How to get path to current node but of another language?

Available languages:

English (URL prefix: en)
Polish (default, no URL prefix)

Enabled detection methods:

URL (by prefix)
Session (parameter: language)
Browser
Default

I created translation of taxonomy and translations of some basic page nodes. However, none of the following codes work.

drupal_get_path_alias(null, 'en')
drupal_get_normal_path('', 'en')
drupal_get_path_alias('hardcoded-existing-path', 'en')
url(current_path(), array('language'=>'en'))

How to make it work? All internalization modules are enabled.


texts: Display image from Webform submission using views

texts:
I have created webform with title, description and upload file fields. And I have created views to display submission data in a grid view.

For images, it just giving me the image name with URL to image but it is not displaying as an image. I tried everything, but didn't find any solution. Please give me solution for displaying images in views.


texts: I have dloaded libraries 7.x-2.0 in my modules folder and installed colorbox 7.x-2.2 in modules and installed  1.3.26 plugin to sites/all/libraries folder and enabled colorbox in manage display for fields. ALL OF THIS WAS WORKING BEFORE UPGRADE. So started from scratch but when I click on an image it opens lightbox and the image never loads.


texts: Is there a way to consume external web services and show results in Views?

texts:
I have an external web service, which can be accessed using a HTTP call (with parameters passed as query string), and that returns the result in XML format.

I would like to use Drupal to access that web service (with the desired parameters), and display the result using Views.

These are a sample query and the result obtained from the web service I am using.

Query: http://localhost/query.php?cy=in&q=abcd&cat=22
Result:

<?xml version="1.0"?>
<results>
<Jobs>
    <Job ID="111">
        <Title>Test one</Title>
        Test one summary
        <DateUpdated Date="2011-04-04 18:03:00">4/4/2011</DateUpdated>
        <Location>
            <Country>India</Country>
            <City>Delhi</City>
        </Location>
        <CompanyName>Test Company</CompanyName>
    </Job>
    <Job ID="222">
        <Title>Test two</Title>
        Test two summary
        <DateUpdated Date="2011-04-04 18:03:00">4/4/2011</DateUpdated>
        <Location>
            <Country>India</Country>
            <City>Chennai</City>
        </Location>
        <CompanyName>Test company</CompanyName>
    </Job>
</Jobs>
</results>


texts: How to force pathauto to bypass common word removal based on content type?

texts:
If one set up a url pattern for nodes of certain type to node/[node:title] and then try to create a node with title this is my title the generated pattern is node/my-title. This is because pathauto removes common words by default.

I found that some of the value processing is happening at cleanString inside AliasCleaner.php class. This can be changed via pathauto configuration at admin/config/search/path/settings. However, changing the setting is global and I need don't intend on removing this default behavior globally.

Is it possible to hook into the cleanString process and alter it only for a specific content type?


texts:
I have a simple Drupal 6 website with a content type 'Software' this has various CCK fields regarding evaluation of the software. The software has been evaluated by a speech therapist and the website is used by people suffering from Aphasia to help them pick the software that is right for them.

One of the pages on the site has a comparison table built using views, selecting nodes with their CCK fields.
http://www.aphasiasoftwarefinder.org/comparison-table

I appologise for the amature look of this site, I knew very little about theming and am still learning.

I am now re building this site in Drupal 7 and it has become much more complex with regard to the various evaluation criterion and is also including Apps and other software that may be useful to people. I decided to use Taxonomy instead of CCK fields as there about about 7 areas or evaluation (Taxonomy volcabulary) each with its own list of terms.

Everything is working well except when I come to creating a comparison table.
I want to be able to use the Taxonomy terms that are the same as the CCK evaluation fields from the Drupal 6 site but I am strugling as to how I can achieve this.
So I have a Taxonomy Volcabulary 'Evaluation' with a list of 8 or so terms, I want to be able to separate those terms out as columns along the top of the view and list the nodes down the side, then populate the colunms with a tick if they have that taxonomy term.

If someone could point me in the direction of any tutorials that may help towards this goal or come up with any ideas on how this could be done???

Many thanks
Julie


texts: Pre-select Group Audience for Organic Groups

texts:
Here is my situation.

I am using the latest version of Organic Groups on Drupal 7. Every user on my site is part of one group and one group only. Is there a way to make it so that when users are creating group content, the group they belong to is automatically pre-selected? Again, every user is only in one group (but there are numerous groups), so it's superfluous to force them to make a group selection whenever they are creating group content.


texts: Change text in Commerce Kickstart "order total" dynamically

texts:
I want to change the label in the attached image, that is from Commerce Kickstart. I need to change that text depending on the role of the user.

If the user has role1 then the text will be "order total" & if user has role2 then the text should change to "Quote total". Any idea?

I tried to debug with Devel to see where to change the label but I could not find it.


texts:
For a new website I have a list of products with specs, but most of the time the specs are different for each product, because there are a lot of types of products.

Right now I just have a new field for every type of spec, but I want the client to be able to do this themselves.
Is there a module that enables me to customize the label for each field?

So let's say the client can add a field, fill in the label and value himself?


texts:
How to add a marker in different part of the image (please look at the attached photo),

There is a module Imagefield marker which is not working. is there any other similar module?

Thank for the help.


texts:
I'm attempting to send an email from a Drupal 8 module I'm developing, and it works except that special characters (' < >) seem to be getting escaped.

My module has a configuration to select whether the emails are plain text or HTML (using Swiftmailer). In plain text messages, apostrophes get replaced by &#039; while in the HTML messages, all HTML tags receive similar treatment, so the message arrives, but the HTML tags are all shown in the message, rather than formatting it.

Heres an extract from my hook_mail handler:

  $message['subject'] = $params['subject'];
  $body = $params['body'];
  if ($config->get('confirmation.format_html')) {
    // Set up HTML email.
    $message['headers']['Content-Type'] = 'text/html; charset=UTF-8';
    $message['body'][] = $body;  // HTML version of message body.
    $message['plain'] = \Drupal\Component\Utility\SafeMarkup::checkPlain($params['body']);  // Plain text version of body.
  } else {
    $message['body'][] = $params['body'];  // Plain text version of body.
  }

It seems there's some escapement of special HTML characters going on, but I can't see where?


texts:
I have HTML markup which is externally generated but I need to display in a form.

I've got the following code in a form controller:

public function buildForm(array $form, FormStateInterface $form_state){
    $form['phone_number'] = [
        '#type' => 'tel',
        '#title' => 'Example phone',
    ];

    $form['TEST-Cloze']   =   [
        '#markup'   =>  "
<select><option value='[Walter]'>[Walter]</option><option value=' Hank'> Hank</option><option value=' Gus'> Gus</option><option value=' Jessie'> Jessie</option><option value=' Mike'> Mike</option></select> was diagnosed with cancer in his 50th year. He began working with <select><option value='Badger'>Badger</option><option value=' Skinny Pete'> Skinny Pete</option><option value=' [Jessie]'> [Jessie]</option><option value=' Tortuga'> Tortuga</option><option value=' Bogdan'> Bogdan</option></select> to produce <select><option value='cocaine'>cocaine</option><option value=' heronie'> heronie</option><option value=' opiods'> opiods</option><option value=' [amphetamines]'> [amphetamines]</option><option valu\nhis death. He eventually became involved with hardened criminal <select><option value='[Tuco]'>[Tuco]</option><option value=' Gomie'> Gomie</option><option value=' Bogdan'> Bogdan\noption><option value=' Todd'> Todd</option><option value=' Gale'> Gale</option></select> to help with the distribution of his illegally manufactured product.
"
        // '#markup'   =>  $question->processed
    ];

    $form['submit'] = [
        '#type' => 'submit',
        '#value' => $this->t('Submit'),
    ];

    return $form;
}

However, the output is completely stripped of markup and displays as plain text, as shown below:

How can I get the markup printed?

UPDATE:

I am attempting to add my form element markup because of the complexity of having multiple drop-down lists in a single paragraph, such as displayed below:

I struggled to achieve this type form output using other form components which is why I began looking into the #markup component.


texts: Avoid drupal bootstrap for each image styles in private filesystem

texts:
Consider a scenario, where large number of images are attached to a node and they are displayed as thumbnail gallery when that node is displayed/rendered. The node has access control so it displayed accordingly. All images and corresponding image styles are stored on private file system.

Since every thumbnail is accessed from private filesystem it incurs a high latency due to permission check an every image.

Is it possible to avoid bootstrap/permission check for every image when they are displayed/rendered as a part of a specific node? So behave like public filesystem in this special case only. When any item is directly accessed via url, the permission checks kick in as they normally do for private filesystem.


texts: node:title token confused with Content Profile title

texts:
When I update a page, the yellow Drupal $messages variable reads,
"Page Lastname, Firstame Profile has been updated."

Also, I send emails (using Rules) each time certain content types are created. The same problem appears when I use [node:title]. It's like it's overwritten somewhere.

After hours of searching, I cannot find an answer.

Here "User Event" is a content type:

I am running the latest version of Drupal 6.


texts: How to let a user choose a role after their very first login?

texts:
I want to let users to select their role. There are 4 available roles (created by me as an admin) and the selection should be done after first login, so not on the registration form.

Can anyone help me to resolve this problem?

Note: the question let the user choose role upon registration is not exactly the same as my question here: that one contains "... with their chosen role ...", which is clearly something they entered on the registration form.


texts: create bilingual language site with drupal 6

texts:
i want to build a multi-language site (Chinese and English). From the documentation, I know I should install the Internationalization module, so i installed it, but there are some parts on my site that are not translated.

There are some parts as the following in every page (the Chinese version):

<a href="<?php print $base_path ?>" title="<?php print t('Home') ?>">测试公司

How do I translate 测试公司 when English is the set language?

On every page's top right part, there are some parts as the following:

  设为首页 |&nbsp;添加收藏  |&nbsp;简体中文&nbsp;English

How do I translate 设为首页, 添加收藏 and  简体中文 to English, when the user access http://example.com/en?

I know I can put that content in a block, then translate it, but it's too weird.

Is there a simple way to get that?

ps:  why this one that i can't translate(english-->chinese)? the code is used to alter the conntact form . $form['mail'] = array( '#title' => t('E-mail'), '#type' => 'textfield', . when i searched the E-mail in the translate interface, i can't find it,but  when i changed E-mail to test. then i can search it. why? thank you.


texts: Override "Display select options" to see them in reversed alphabetical order

texts: Can anyone advise me how to override the Hierarchical Select module to display select options in reverse alphabetical order?


texts: Cannot set form #default_value when altering Views Exposed Filter forms

texts:
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  drupal_set_message($form_id);

  if ($form_id == 'views_exposed_form') {
    $options = array(
      'All' => t('All'),
      '$' => '$',
      '€' => '€',
      'тг' => 'тг',
    );

    $form['field_price_second']['#type'] = 'select';
    $form['field_price_second']['#options'] = $options;
    $form['field_price_second']['#default_value'] = '$';
    $form['field_price_second']['#size'] = 1;
    $form['field_price_second']['#validated'] = TRUE;

    dpm($form);
  }
}

However, the default value isn't working, i see instead 'All' value as default in my views exposed form's select list. What's wrong?

DPM output:


texts: Where is the Drupal Syslog module log file in Cpanel?

texts:
I disable dblog module and want to enable syslog module instead of it.
After enabling that ,I can't see any drupal Log in error_log file in cpanel .

what is reason? where is Drupal log file for cpanel shared hostings?

My drupal version : 7

thank you


texts: Local drush stops working after changing files and folder permissions

texts:
So I changed the files and folder permissions with the following commands on Drupal 8 and after that, I can't run drush commands unless I change file permissions to 777

find . -type f -print0 | xargs -0 chmod 0644
find . -type d -print0 | xargs -0 chmod 0755

Here's the error I get after I run drush cr for example:

PHP Warning:  pcntl_exec(): Error has occurred: (errno 13) Permission denied in /usr/local/bin/drush-8/vendor/drush/drush/includes/startup.inc on line 415
Error has occurred executing the Drush script found at /data/websites/virtualmax.ca/public_html/vendor/drush/drush/drush
(errno 13) Permission denied

I wonder if there's a certain permission required to be able to run local drush installed with composer


texts: How to programmatically reference entities?

texts:
I am trying to reference an entity within my hook, so that every time a new entity is inserted, I create another entity referencing the first entity. I have not yet found a working way to reference an existing entity in my "field_content" when creating a new entity.
My code looks like the below excerpt:
function ost_notifications_entity_insert(EntityInterface $entity) {
  if ($entity->bundle() == 'deadline' || $entity->bundle() == 'message') {
    $new_entity = \Drupal::entityTypeManager()->getStorage('node')->create([
      'type' => 'notification',
      'title' => $entity->label(),
      'field_content' => "referenced entity goes here"
    ]);
    $new_entity->save();
  }
}


texts:
I'm trying to create a custom module which will display a message after my webform. I know that in order to display a message, I could use the following code:

$message = "Message here";
drupal_set_message(t($message));

But rather than having a specific message, I want to have a conditional message based on PHP if statements. E.g.,

    if($class == A) {
    print "Correct!";
}

So, my question is how can I get the results of this PHP code to display on my webform? I'm not familiar with PHP code, so I don't know if I can combine the $message code with the if statement somehow. (I've tried variations of this with no success.)

Thanks for your help.


texts: Ignore Special Characters from Expose Filter

texts:
How I can ignore special characters from expose filter.for example: I have a view with expose filter ( Title ) but if I write the text without special characters it returns ( No Result ) & if write the text with those special characters I have resulted.

Note: When I created the node I wrote the Title with special characters

Example: I created a node with Title (i'ts)
if I searched in expose filter by using (its) it returns(No Result) but if I wrote (i'ts) it works fine


texts: Programmatically create field instance of field and content type created in module code

texts:
In my module, I define a custom content type, and custom fields by using hook_node_info() hook_field_info(), and so on. I'd like to programmatically add field instances of my field to the created content type when my module is enabled/installed.

I know there is the possibility of creating the content type, and the field in the database by using node_type_save() and field_create_instance(), but this is not what I want, since during the development the field definitions will change, and in the latter scenario I would have to uninstall and reinstall the module every time I change a field/content type.

I tried using field_create_instance() in my module's hook_install() and hook_enable(), but Drupal says that the field I try to add does not exist or is inactive.

Is there an elegant way to let the module define fields, and attach them to content types when enabled (and of course detach them on uninstall or disabling it)?


texts: Install drupal-project w/ composer failing

texts: I am trying to install Drupal 8 on Windows using composer and drupal-project.  It is failing on the first package install; cweagans.  I have rebooted the box and checked all the permissions.  Composer is creating the drupal-project folder and I see D:\Websites\drupal-project\vendor\cweagans\ is there.  I have attached a screen shot of the command window with the command and error messages. Does anyone know of a work-around or another method to install drupal with composer?


texts: Ranking items (groups, nodes) by the number of Facebook likes

texts:
I am on Drupal 7.

I need to add a Facebook like button that will be associated with organic groups pages. Each group will have a different like button so that each group has an independent "Likes" count. I can do this by simply configuring and adding a Facebook iframe or XFBML interface. More about this here: http://developers.facebook.com/docs/reference/plugins/like/.

What I cannot figure out is how to retrieve this information from Drupal and use it in a Views. I would like to rank the organic groups according to the number of Likes clicked for each... I figure out I would need some kind of integration with Facebook... Is there any kind of module that will allow an intregration between Drupal and Facebook for this specific functionality? I have been using Janrain for logging users, but as far as I know, it won't provide this kind of integration I am talking about... Or maybe some Views-Facebook, or even Flags-Facebook integration where I could associate Likes with flags for a certain item...

Thank you.


texts: Is there a CKeditor / Drupal module that allows for a one-button image upload (without requiring Flash)?

texts:
Background:
I'm looking to add an image upload button to CKeditor. Ideally, I'd like to automated the click responses to start IMCE and jump right to the IMCE Upload button. In fact, I'd like to put the IMCE upload button on CKeditor's tool bar.

My Question:
Is there a way to put the IMCE Upload button directly onto the CKEditor tool bar just like we have here in side of StackExchange?

What I've seen/tried:
I've seen other methods recommending One Click Upload but this uses SWFloader. The Media module is great but people want a direct upload from inside the editor. They don't want to jump to another screen.


texts: How to create Drupal 7 clean pager links?

texts:
In my last project my client aksed me to do clean pagers in his website. However drupal 7 handles pagination using ?page=1 but I need page/1 insted of that. Do someone have experience of creating clean pager links using pager alter and .htaccess. I see lot's of modules but they are not working properly. I tried with clean pagination, smart paging modules but they did not work properly, Then I tried to do it by custom way through htaccess file and altering pager link, but can't get success.

http://someexample.com/hello-node/?page=1 to
http://someexample.com/hello-node/page/1

Any help will be appreciated.


texts: Get image's URL as a token for use in Views' replacement pattern

texts:
I need to get an image's full URL path as a token that I can use as a replacement pattern in Views.

I'm trying to have one thumbnail image link to a larger image.  I have the larger image excluded from view so I can use it as a token.  When I try to export the thumbnail image as a link using the larger image's token, the token is apparently the <img> tag instead of the path.

I think I can do this if I change the field type of the larger image to a File, but I want the benefits that come with the Image type (cropping, scaling, etc).


texts: How to assign a user a role during registration using Rules and Profile 2?

texts:
I am using the Profile 2 module to select roles during the registration process. So a user selects a role (using a radio button) and then a rule fires to give the user the role that was selected.

Here is the rule I'm using:

    { "rules_give_user_a_role_after_registration" : {
    "LABEL" : "Give user a role after registration",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "user_insert" : [] },
    "IF" : [
      { "data_is" : {
          "data" : [ "account:profile-main:field-user-role" ],
          "value" : "Emporos"
        }
      }
    ],
    "DO" : [
      { "user_add_role" : { "account" : [ "account" ], "roles" : { "value" : { "5" : "5" } } } }
    ]
  }
}

The issue is that the role is not assigned to the user. Any idea why not?


texts: I want to show the Preview Image from Media Youtube videos in Views. But I can't figure out how to display them in views. Is it supported? How?


texts:
In Drupal 7, I use drush qd -y and php -S localhost:8000 almost weekly to get a fresh development copy of Drupal 7 to build modules or test modules before I put them into our actual development boxes.

I'm looking at Drupal 8 without much prior knowledge. Can I still use drush qd as I do with in Drupal 7?


texts: Webform with File upload field throwing "... field is required" error

texts:
I have created a Webform, which has two file fields (i.e. Attach document 1 and Attach document 2). Both of them are mandatory and files are to be uploaded in the "Private" folder.

Now when someone attaches the files and submits the form, it throws error messages "Attach document 1 field is required" and "Attach document 2 field is required". If I invoke the validation, then it works. I have checked in the server and the files are uploaded properly. So I think it is "Webform" or "Form" issue.


texts:
I have a content type with datetime field. When I save node, in database I have 2014-04-28 11:00:00 for instance. But when I edit the node i have 2014-04-28 13:00:00. I guess that it has something to do with timezones.

Now the problem is that i have lot of nodes and i have to get the time from database. I don't want to node_load or anything like that.

The question is - is it possible to extract 2014-04-28 13:00:00 datetime from database with MySQL query? Or any work around where I don't have to use node_load?

Any input will be appreciated :)


texts:
Possible Duplicate:
  How to delete all unpublished comments?

I have been hit by spammers and now have like over 10k comments sitting in the approval queue. Is there a way to delete all of the comments in approval queue in Drupal 6?


texts: Please help with this query! Need to get taxonomy terms of related nodes

texts:
I've inherited this code that runs on our home page. It's used to do a custom display of specific pieces of related info. Here's how things are set up:

We have an article. It has a series of node reference fields that allow us to link related images (actually nodes themselves, which contain a headshot and some text; it's not an actual attached image.) Each of those headshots has a thumbnail created via ImageCache so that we can display a small version in search results and on list-type pages.

We have a new requirement that if the related image node for a specific article has a certain taxonomy term (tid) associated with it, it should display differently than other images.

The existing query (which I did not write) looks like this:

SELECT DISTINCT n.title, nr.teaser, n.nid, DATE_FORMAT(FROM_UNIXTIME(n.created), '%M %e, %Y') AS date, f.filepath AS image, cfri.field_related_images_nid as image_id

FROM node n JOIN node_revisions nr ON n.nid = nr.nid
LEFT JOIN content_field_related_images cfri ON (n.nid = cfri.nid AND cfri.delta = 0)
LEFT JOIN content_field_att_file cfaf ON cfri.field_related_images_nid = cfaf.nid
LEFT JOIN files f ON cfaf.field_att_file_fid = f.fid
JOIN term_node tn2 ON n.nid = tn2.nid

WHERE n.status = 1 AND n.type = 'article'   AND nr.body LIKE '%kimberly-clark%' AND tn2.tid = 143 ORDER BY n.created DESC LIMIT 3

This returns a recordset that looks like this:

TITLE         |  TEASER           |  NID |  DATE            |  IMAGE                            | IMAGE_ID
==========================================================================================================
Exec Profile  |  Could you please | 67491 | April 29, 2011  | sites/default/files/kcjones.jpg   | 67572
Unilver Ads   |  Unilever topped  | 67421 | April 20, 2011  | sites/default/files/unilever.jpg  | 66889

This is all well and good. But what I need to do is (in the same query, somehow) also return the tid that goes with the image_id from the term_node table. On its own for a single image node that query is simple:

SELECT tid FROM term_node WHERE nid = 67572

But how do I modify the existing query to bring in the tid based on the image_id found in the main part of the query? I'm guessing I need some kind of subquery, but this is stretching the limits of my sql chops...


texts: How to prevent the user profile page of a blocked user to show up?

texts:
When a user is blocked the (core) user profile is still accessible. I would rather show a message "this user profile has been removed".

I could write an exception into the user-profile.tpl.php. Is there a better way?


texts: Which variable to set for programmatically making a field required?

texts:
I am trying to do something like :

/**
 * Implements hook_update_N().
 */
function module_name_update_7002() {
 // Change field to required
}

To alter a field to make it required in production (where i can't access the backoffice).

Which variable do I have to set for doing so?


texts: How to fix "ID longer than 32 characters" error when upgrading?

texts:
Why am I getting the following error when I try to upgrade my site from Drupal 7 to 8 using the Migrate Upgrade module? After a progress of 11% my site's throwing an Ajax error:

  An AJAX HTTP request terminated abnormally.

  Debugging information follows.

  Path:
  /mysite/?q=en/file/ajax/field_slideshow_image/und/form-ESe-qn-oh9D4OVpLClBz2wTv1mHUxaTWHmj2hi5V3aw

  StatusText: n/a

  ResponseText: The page cannot be displayed because an internal server
  error has occurred.

  ReadyState: undefined

The actual error message is the following:

  Source ID comment_node_industry_recognition: Attempt to create a
  bundle with an ID longer than 32 characters:
  comment_node_industry_recognition().
  (/media/public_html/public_html/drupal/drupalmigrationfinal/core/lib/Drupal/Core/Entity/Entity.php:408)


texts: views_get_view() not accepting arguments?

texts:
Code without arguments works, but with arguments I run into an error of EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. Value at commerce_line_item()->commerce_product: . in EntityDrupalWrapper->set()

This does not work:

    $array = array('228');
    $view = views_get_view('commerce_wishlist_page');
    $view->set_display("default");
    $view->pre_execute($array);
    $view->execute();
    print $view->render();

This works:

    $view = views_get_view('commerce_wishlist_page');
    $view->set_display("default");
    $view->execute();
    print $view->render();

Did they changed something? Because according to documentation this should work. I can confirm view work in views UI, also with handwritten contexual filters in UI. How can I solve this?


texts:
I have a content type which has an entity reference pointing to users. I need to have a permission policy that says: only users who are defined in the content (as entity reference) can view it or download the file attached to it. anybody else should be faced with a message which saying: It's not your business!!

help please


texts: How to force absolute links on a menu tree in Drupal 7

texts:
What I have

I currently have a menu with subitems printed out in my page.tpl like this:

in template.php

   function THEMENAME_preprocess_page(&$vars, $hook) {

       $sitemap_tree = menu_tree_all_data('menu-sitemap');
       $vars['sitemap_expanded'] = menu_tree_output(i18n_menu_localize_tree($sitemap_tree));

}

then in page.tpl.php I have

     print render($sitemap_expanded);

What I want

While this prints out the entire menu tree perfectly I need the links to be absolute in stead of relative (what they are now).
Any way of doing this in a Drupal fashion without too much extra lines ?

Thanx all.


texts: How to insert any view inside of another view?

texts:
I wonder how to insert any view inside of another view in Drupal 8?

Simply, we have products pages, which contains product details pages in views. When I click on any product detail page from view, it should open window with text which is set up in one view and display another second view with related receipts.

Both views should be filtered according to Taxonomy reference.

How can I achieve this?


texts: Add default image to image file programmatically

texts:
I am trying to add a default image to an image field in Drupal 8 using the configuration management interface (CMI).  Normally once I have a field configured through the admin UI, I would then export the config YAML file for that field so I can add it to my custom module. The issue is that the default image for an image field is content and cannot be directly exported.

If I do export such a file, it would look like this:

langcode: en
status: true
dependencies:
  config:
    - field.storage.node.field_bluescope_header_bg_image
    - node.type.bluescope_page
  module:
    - image
id: node.bluescope_page.field_bluescope_header_bg_image
field_name: field_bluescope_header_bg_image
entity_type: node
bundle: bluescope_page
label: 'Header background image'
description: 'Image used as the page''s header background'
required: false
translatable: false
default_value: {  }
default_value_callback: ''
settings:
  file_directory: images/header-bg
  file_extensions: 'png gif jpg jpeg'
  max_filesize: ''
  max_resolution: ''
  min_resolution: ''
  alt_field: true
  alt_field_required: true
  title_field: false
  title_field_required: false
  default_image:
    uuid: 8288b3b1-4b0e-4efc-9137-55cb68382f0a
    alt: 'Header background image'
    title: ''
    width: 1920
    height: 1080
  handler: 'default:file'
  handler_settings: {  }
field_type: image

I noted that the default image is referred to using a uuid.  I was thinking that I could address this by programmatically adding the default file to this field's configuration during the module install process. What I tried was to create the image in drupal's file system and then get the uuid of that file and add it to the fields configuration using configFactory:

function colorbond_data_install() {
  $config_factory = \Drupal::configFactory();
  $field_bluescope_header_bg_image_config = $config_factory->getEditable('field.field.node.bluescope_page.field_bluescope_header_bg_image');
  $default_image = $field_bluescope_header_bg_image_config->get('settings.default_image');

  // Create default image file.
  $file_info = colorbond_data_add_file('public://images/header-bg/', 'starwars.jpg', 'Header background image');
  $file = File::load($file_info['target_id']);

  $default_image['uuid'] = $file->uuid();
  $default_image['alt'] = 'Header background image';
  $default_image['title'] = 'Header background image';
  $default_image['height'] = 1080;
  $default_image['width'] = 1920;

  $field_bluescope_header_bg_image_config->set('settings.default_image', $default_image);
  drupal_flush_all_caches();
}

The problem is that when I reinstall the module, the default image configuration does not appear:

Not sure what I am doing wrong.


texts: How to create a node out of a webform submission?

texts:
I'd like to be able to create a node out of a webform submission in Drupal 8. It can happen either on successful submission or as an additional task after the webform has been submitted. I've seen some info on creating content entities via REST/GET (https://www.drupal.org/docs/8/core/modules/rest/3-post-for-creating-content-entities) and I know that you can post a webform submission to a URL with Webform (yamlform) using either x-www-form-urlencoded or JSON, but I'm not sure if this is even the right thing to be looking at.

The webform, submissions, and content type I'd like to use are all on the same site.

I know this question came up for Drupal 7 and the direction was to have them use a content type, but we're not able to allow the submitters to use content types at this time because of the way the site is setup.


texts: drupal 7: How to create a pop-up window with close button, that shows automatically while loading front page

texts:
I am struggling to create a pop-up window (webform, node or something else) with close button.

Modal forms can achieve this by click link. But anyone know how to make it shows without link?


texts: Combining Feeds (with teasers) on the homepage?

texts:
I want to combine several feeds (several internal blogs from my site and several external feeds) and post them on the homepage.  I want to use teasers to only show part of each post.

How should I do this?

I have been trying to use the aggregator module and the feeds_block that it creates out of all the feeds, however it shows the entire posts. I want teasers.


texts: How do I add a synonym for a word in the search index?

texts:
I am looking for a way to add a synonym for a word in the search index.
My function will provide a dictionary for each word that the tool will index, the function will add the synonym if it finds one.

I think use hook_node_update_index but this hook catch each node before being analyzed by the indexing engine.

Is it rather a way to use a hook at a lower level that catch each indexed word
just before being stored in the index ?

By the way...
I use the core module search not the search Search API module.

Thank you for your help.


texts: When using drupal_get_query_parameters(), should I still run values through filter_var() or check_plain()?

texts:
When absolutely needing to take in query string values, I'm using drupal_get_query_parameters(). However, is it still a good idea to run values through check_plain() or filter_var(). Or does this drupal function automatically take care of data sanitization for me?

For example, is the filter_var with FILTER_SANITIZE_NUMBER_INT a good idea, necessary, or redundant?

<?php
$params = drupal_get_query_parameters();

// get dept name if exists in query string
if (array_key_exists('exposed_filter_a', $params['field_department_tid'] = filter_var($params['exposed_filter_a'], FILTER_SANITIZE_NUMBER_INT);
    $expfilter_value = taxonomy_term_load($params['exposed_filter_a'] )
}


texts: Exposed view filtering on a related node's value

texts:
I have a view with a list of nodes. Each node has a number of related nodes which I want to display below the parent node. This works fine.

However, when I go to filter the listing on values in one of the related nodes, then an empty set is returned.

I'm guessing it's trying to filter the parent nodes on this value, and not the related nodes. How can I remedy this?


texts:
I have a site with about 800 pages in the main menu.
When creating or editing a node, managing the menu item parent can be challenging with a select list containing so many options!
I am using Big Menu [https://www.drupal.org/project/bigmenu] to manage the menu within the menu edit areas. Is there something similar I can do with the node edit page?
Or some other option to make selecting a node's menu parent a little easier?


texts:
I ran into an issue recently where my hook_cron function was failing when triggered by cron. The problem was that I was calling EntityFieldQuery, which  does access checks and since cron runs as an anonymous user, the query would to process correctly. Specifically, I was having this issue: EntityFieldQuery doesn't work correctly in hook_cron

I am trying to understand why cron runs as an anonymous user. Cron clears the cache and so has at least some database access. When writing hook_cron functions now, I have to bypass access checks so that they return results as expected. Does anyone understand why this is the intended behaviour?

Drupal 7


texts: How do I customize the location of a field?

texts:
I have following block made with the Views module.

I need somehow, with the help of template I think, to place text and image in one line so it will be in one row.

How can I do that?

I tried creating a custom view template, but I do not have possibility to place those fields in that template as there isn't any variable. kint() shows me only content variables.


texts: How do i add an attribute to a certain script tag (my mobile navigation)

texts:
my problem is, that i have to add the attribute "data-pagespeed-no-defer" to the script tag of my mobile menu. i use responsive menus which produces the following tags (if advagg is disabled):
<script src=/sites/all/modules/responsive_menus/styles/meanMenu/jquery.meanmenu.min.js?qff4cj></script><script src=/sites/all/modules/responsive_menus/styles/meanMenu/responsive_menus_mean_menu.js?qff4cj></script>
Maybe I've found a way - but i don't understand all of the code. It searches for a script tag and for a string position ... But i don't understand how the code should adress exactly a certain script tag?
  if ($variables['element']['#tag'] == 'script' && strpos($variables['element']['#value'], 'jQuery.extend(Drupal.settings') === 0) {
    $variables['element']['#attributes']['data-pagespeed-no-defer'] = 'true';
  }
}

Can anybody help me or push me to the right direction?


texts: Show user email from the user entity to anonymous users

texts:
Through views I am trying to show the account email address of any user to any user.

I have checked "Disable SQL rewriting", made sure the view didn't have any permissions, allowed anonymous user to view profiles. After all this it still won't show.

Note: I really don't want to create an additional field that is just syncs up this info just to show it. I want to show the actual field.


texts:
I have several D7 sites that I inherited that should have been one site.  We are now trying to migrate to D8 (not all needed modules are available yet on D9).  We would like to migrate them to one site.
When I migrate site 1 nodes and/or webforms/submissions, all goes well.  When I migrate site 2, some of site one items are overwritten because they have the same ids.  How do I configure a migration so it does not overwrite a previous migration?


texts: How to make a MENU_LOCAL_TASK on a user's profile only appear on their profile?

texts:
I use logic like this to place a tab on each user's profile page so users can view analytics from the usage of a WebApp:

  // maps a url to a sub-page of user's profile, url to user's Analytics-Management form
  $items['user/%user/ClientCompanyName'] = array(
    'title'            => 'ClientCompanyName',
    'description'      => 'Manage your ClientCompanyName services.',
    'page callback'    => 'drupal_get_form',
    'page arguments'   => array('_ClientCompanyName_mgmt_form'),
    'access callback'  => 'user_access',
    'access arguments' => array( 'access ClientCompanyName services' ),
    'type' => MENU_LOCAL_TASK,
  );

This works great for each user, but I do not want one user to be able to go to another user's profile and hit their link to get to that other user's private analytics data.

Currently, if a user tries to visit another user's analytics management page, they see an access denied page.

But I would like them never to even be given the link to that page. I tried writing my own 'access callback', but I can't figure out how to pass in the '%user' portion of the intended url so I can test that against the logged in user...

I like how one can use '%' symbols in the url, and then 'page arguments' can be used to reference those arguments in the url. Is it possible to do something similar with the 'access arguments'?

Essentially, I'm trying to achieve the same thing as the behavior of the 'edit' tab on a user's profile: only if the user is on their own profile page will that 'edit' tab appear on the profile. How do I get the same effect for my WebApp analytics page?

(I guess I could make my analytics page a MENU_LOCAL_TASK of the profile edit form... but I'd still like to know how to create a conditional MENU_LOCAL_TASK whose conditional is more then simply an user_access() permissions test.)


texts:
What I am doing wrong? The error says:

  Fatal error: Call to a member function advanced_render() on a
  non-object in
  /var/www/mydrupalsite/themes/myTheme/template.php
  on line XXXX

/**
 * Overrides theme_views_view_field for a view
 *
 */
function myTheme_views_view_field($view, $field, $row) {
  //Work only for mobile view and section field
  if($view->name == 'mobile' && $field->options['label'] == 'Section') {
    $new_items = array();

    foreach($field->items as $skey => $subitem) {
      $new_items[$skey] = array();

      foreach($subitem as $key => $item) {
        $parent = taxonomy_get_parents($key);
        if(count($parent) == 0){
      //do not set item in items, if taxonomy does not have parent
        }
       else {
         $new_items[$skey][$key] = $item;
       }
      }
    }
  //Assign new items list to field items
    $field->items = $new_items;

    return $field->advanced_render($row);
  } else {
    return $field->advanced_render($row);
  }
}


texts: how to add #states property to an $element of the custom field?

texts:
i develop a custom field and have some errors on property #states.

The method of using #states in $element is quiet different with the $form.

The code i write is below.

 function cellphonefield_field_widget_form(&$form,&$form_state,$field,$instance,$langcode,$items,$delta,$element)
    {
        $base=$element;

        $element['cellphone']=array(
         '#type' => 'textfield',
         '#title'=>t('Enter your Cell phone Number!'),
         '#description'=>t('System will send you a message '),
         '#default_value'=>isset($items[$delta]['cellphone'])?$items[$delta]['cellphone']:'test for this field',
         '#weight'=>0,
        )+$base;

      $element['send_sms']=array(
         '#type' => 'button',
         '#name'=>'send_sms',
         '#title' => t('validate your cellphone number'),
         '#weight'=>1,
         '#value'=>t('Send the validation code!'),
         '#ajax'=>array(
            'callback'=>'ajax_send_sms_callback_function',
            'wrapper'=>'replace_markup_to_textfield',
            'effect'=>'fade',
            'speed'=>'fast',
            'method'=>'replace',
         ),
         '#states'=>array(
            'disable'=>array(
              ':input[name="profile_main[field_cellphone][und][0][cellphone]"]'=>array('filled'=>TRUE),
            ),
         ),
        );

    $element['validation_fieldset']=array(
    '#type'=>'markup',
    '#weight'=>2,
    '#prefix'=>'
',
    '#suffix'=>'
',
  );

   return $element;
}

No matter what i replace the input name of the #states, it's still not working.

i checked the html form and the code blow

<input type="text" id="edit-profile-main-field-cellphone-und-0-cellphone" name="profile_main[field_cellphone][und][0][cellphone]" value="" size="60" maxlength="128" class="form-text" />

what could the problem be?


texts: Attempt to charge recurring fee 2 failed.I am getting this error when i want to charge via developer a/c authorize.net. Normal payments going well but recurring is the porblem..Any idea to fix this error..D7 i am trying.....


texts: Can't log onto drupal with any email address

texts: I am receiving "Account Approval" spam at one of my email addresses. I can't log onto to Drupal using that or any other email address I am using. When requesting new password using various email addresses, all are rejected as unknown. Will creating a new account allow me to install module(s) to kill spam?


texts: Multi language with different layout drupal 6

texts: I have a multilingual site with English and Spanish. I need to change the Layout(theme) of my English pages but no chnage in spanish pages. Can we have separate tpl file based on Language? Any help will be appreciatable


texts:
I have a page that loads the comments section via Ajax once the user scrolls down to the comment section via a custom Drupal ajax callback I defined:

Comments are loaded fine, and using a custom module I'm able to delete, edit, reply and preview comments via Ajax successfully.

The Comment form is loaded via Ajax as well, using this function:

http://paste2.org/p/2757034

Now, here's the problem.

When the comment form isn't a reply to another comment, if I preview the comment and then save, I get this error:

  The form has become outdated. Copy any unsaved work in the form below and then reload this page.

Now, here is the code that's generating the form after it's previewed:

http://paste2.org/p/2757036

I tried drupal_rebuild_form() instead of drupal_build_form, but I had no success.
I searched a lot for a workaround but couldn't find one.

EDIT:
It appears that Fivestar is causing the problem. After disabling Fivestar, the form is submitted successfully. However I can't remove fivestar from this page.

Here's what's in $form_state when I click in the preview button:


texts:
I am having hard time with getting the value of YouTube video thumbnail URL, in order to use it as background image in a template file.
I created a video content type and added a remote video field (field_url_vid2). The output format is thumbnail.
{{content.field_url_vid2}} gives the full HTML markup, but I just want the value of the src attribute.


texts: Taxonomy vocabulary not showing up as existing field in new content type

texts:
I have 2 taxonomy vocabularies which I want to reference in new content types but I cannot see them under "add existing fields" when creating a new content type. Also tried referencing one taxonomy vocabulary from another and couldn't.

Saw this post on drupal forum and followed the suggestion of changing admin theme but it didn't work for me.

BTW, I'm using Marinelli theme.

Kind regards,

Jio


texts: Can't log in to Drupal websites after upgrading to OSX Yosemite

texts:
I have just upgraded my local machine to OSX Yosemite which has changed my Apache version from 2.2 to 2.4 and my PHP version from 5.4 to 5.5.

When I visit both example.dev/user and example.dev/user/login and enter my username and password, the login form appears to post the data and then 'loops' back to it's original state i.e. blank fields.

This is the same across all websites and all browsers and is the same for all users.

There is nothing in any of the error logs but…

"POST /user HTTP/1.1" 404 16744

… in the access logs

Has anyone encountered a similar problem?

Thanks,

S


texts: How to add a check box in views exposed filter

texts: I need to add a checkbox in an exposed filter to strip left and right space of a value entered by user, i.e: I have email field on the basis of email filtering the user some time user add left or right extra space. I need a handler or plugins globally which is applied for all text field. If the somehow global implementation is critical so, on the specific field is also ok.


texts:
Clean installation of Drupal 7.41, only installed modules needed for mediafront. When I create a preset and hit save the player preview is blank and cannot click Preset information, Player setting or player to player.

But no error in logs.


texts: Can't migrate alias with Wordpress Migration

texts:
I am using the Wordpress Module to migrate from Wordpress to Drupal 8. I am trying to have the alias be set to the link value (<link>https://myurl.com/wordpress-path</link>). I added the following to the source:

    -
      name: link
      label: 'The link value'
      selector: 'link'

and the following to process:

  path/pathauto:
    plugin: default_value
    default_value: 0
  alias:
    -
      plugin: get
      source: link
    -
      plugin: str_replace
      source: link
      search: 'https://myurl.com/'
      replace: '/'

I have also tried path/alias and path instead of alias but no luck.  I verified that the str_replace plugin does return the correct value but somehow it does not save in the node.

Here is my full migrate_plus.migration.my_wordpress_wordpress_content_post.yml:

uuid: 5b3b3b84-8d41-4a80-b1ca-c9046c269297
langcode: en
status: true
dependencies: {  }
id: wp_wordpress_wordpress_content_page
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags:
  - WordPress
migration_group: wp_wordpress
label: 'Import content from WordPress XML'
source:
  plugin: url
  data_fetcher_plugin: http
  data_parser_plugin: xml
  item_selector: '/rss/channel/item[wp:post_type="page"]'
  fields:
    -
      name: title
      label: 'Content title'
      selector: title
    -
      name: post_id
      label: 'Unique content ID'
      selector: 'wp:post_id'
    -
      name: content
      label: 'Body of the content'
      selector: 'content:encoded'
    -
      name: excerpt
      label: 'Excerpt of the content'
      selector: 'excerpt:encoded'
    -
      name: pubDate
      label: 'Publish date of the content'
      selector: pubDate
    -
      name: post_date
      label: 'Post date of the content'
      selector: 'wp:post_date'
    -
      name: status
      label: 'Published status of the content'
      selector: 'wp:status'
    -
      name: creator
      label: 'Username of the content creator'
      selector: 'dc:creator'
    -
      name: post_tag
      label: 'Tags assigned to the content item'
      selector: 'category[@domain="post_tag"]/@nicename'
    -
      name: category
      label: 'Categories assigned to the content item'
      selector: 'category[@domain="category"]/@nicename'
    -
      name: link
      label: 'The link value'
      selector: 'link'
  ids:
    post_id:
      type: integer
process:
  title:
    -
      plugin: get
      source: title
  body/value:
    -
      plugin: get
      source: content
  body/summary:
    -
      plugin: get
      source: excerpt
  created:
    -
      plugin: callback
      source: post_date
      callable: strtotime
  changed:
    -
      plugin: get
      source: '@created'
  status:
    -
      plugin: static_map
      source: status
      default_value: 0
      map:
        publish: 1
  uid:
    plugin: migration
    migration: wp_wordpress_wordpress_authors
    source: creator
  body/format:
    plugin: default_value
    default_value: basic_html
  type:
    plugin: default_value
    default_value: page
  path/pathauto:
    plugin: default_value
    default_value: 0
  alias:
    -
      plugin: get
      source: link
    -
      plugin: str_replace
      source: link
      search: 'https://myurl.com/'
      replace: '/'
destination:
  plugin: 'entity:node'
migration_dependencies:
  required:
    - wp_wordpress_wordpress_authors


texts: How to prevent contextual-links from being styled?

texts:
Possible Duplicate:
  How to override contextual styles?

The contextual-links seem to be picking up the styles from the block they belong to. How do I prevent this from happening?


texts:
I have recreated a feature with all field instances checked. but when I enable it in new site, only entities and content types are created not their fields.

In the feature's .info file there is lot of lines like this:

features_exclude[field][profile2-personel_information-field_myfield] = profile2-personel_information-field_myfield

I also removed these lines, but it still doesn't work.

Do you have any suggestion?


texts: trouble with a checkbox on the user registration pages

texts:
I created an extra checkbox field for the user registration form

This is the field setting page. (Standaardwaarde means "Default value.")

In the setting page, the field is unchecked, but it's checked in the registration page. I looked at some older questions regarding this subject, but it still a big questions mark for me.

How can I get the checkbox to be unchecked by default?


texts: I'm fairly new to Drupal, but when trying to install a new module, I was instructed to clear the cache. Now, all of the styling on my website is missing and I don't know what to do.


texts: How to set up a Drupal site to communicate with an external Landing Page

texts:
I have a client who runs several landing pages (non-Drupal) on remote servers. I don't have access to them. These pages collect the usual data – email/address/name etc.

Now the Drupal 7 site I'm working on (with Commerce shop) shall

receive an email-address from a landing page to check whether
someone is already known or not
in case of recognizing the email-address send name/address/etc-data
back to the landing page for further processing over there
finally receive a new or an updated set of data to be processed (in
the Commerce shop), resulting in an email with a link to a page
where a file can be downloaded (plus an email with Account-data for
new customers)

In the best case the customer never sees the Drupal site.

I have already set up the shop, everything is working as expected if a customer would buy directly on site.

Now since the files to be exclusively "sold" via landing pages are free testversions of the software sold in the shop I'm not sure whether I need the shop for this procedure at all. Here I need some input on how to set up the whole process.

A few ideas:

set up a secret form to be filled in by a landing page script/bot:
how could the landing page collect possible data?
use the services.module for data exchange: will this work in both
directions? What would be the best way to accomplish the task using
Services, both on the Landing pages and the Drupal site?
use customized Rules derived from the shop to accomplish sending the
desired mails?
redirect the customer to the shop, prefill the cart, skip payment in
checkout: this would not be the preferred solution?

I thought this should be a task not too bizarre, unfortunately it obviously is (to me at least). Any qualified pointing in the right direction?


texts:
So, I know how to use the tokens from the webforms to add them to the subject of the email confirmation that is sent out, but I am wondering if it is possible to automatically include the user's actual username in the subject line?

The customer I'm working with doesn't need the contact name in the very long webform they have setup because they are already set so that when someone creates their own user account, it includes all of those fields, which will save to their account, which we have configured to automatically assign them a specific role once they have completed the first step.

It's kind of repetitive to request that information again and the second webform, so that's why I'm wondering if it's possible to either include the username OR include the first and last name from their user account in the custom email subject when webforms are sent.

I've looked through quite a bit of possible answers, but they just don't seem to really cover anything other than including any of the fields/components that are actually included in the webform itself.

Any assistance would be greatly appreciated!

If you need further information, just let me know. :)

Thank You!
Nicole


texts: When to share fields between content types?

texts: I have a content type with a geolocation field on it, and I also want to add this as an extra field to users. Is it okay to share the field between these? Or should I create two different fields?


texts: Buy 3 Pay for 2 Campaign or Get 3 for the Price of 2

texts: a block named "Buy 3 Pay for 2" shows random products from a campaign. when clicked read more... leads to a page with products in that campaign are shown. how do I make such a campaign? I'm using drupal 7 with commerce.


texts: How to allow a client to do specialized styling for a single node?

texts:
I'm working on converting an existing website to Drupal, and I'm looking for best practices for creating specialized styling on specific nodes. I have a page that looks like this (baconized for your viewing pleasure):

Can someone advise me as to the best way to accomplish styling a node this way - specifically in a way where the content can be managed by the client?

I've had a few different ideas as to how to accomplish it, but I'm not sure which is best.

Write raw HTML as the content and add CSS in the template?
 - The downside with this is that I'd prefer my client not have to mess with raw HTML when managing the content, if at all possible.

Create a custom content type that has fields for each snippet which I can style within the theme?
 - This seems like a reasonable course of action, except that I'll be creating a one-off content type for a single node, and that seems less than optimal.

Do something with Views?
 - Views is always an option, but I don't know if it's the right one here. Would I create a separate node for the intro snippet, the 3 blockquotes, and the rest of the page, or something else? I'm not sure.

Do something with Panels?
 - I'm still figuring out how to use Panels, and it seems like a possibility here, but an overly complicated one. Additionally, how will the client manage it?

Any insight or advice here would be immensely helpful. Thank you!


texts: How to update/change anonymous author to authenticated current user upon logging in?

texts:
This is the case:

Anonymous user can create nodes
Anonymous user will leave their email address
Anonymous user must register with the same email to "claim" the contents they created
When that user logs in, the contents with anonymous author but same email address will update then the author will change from "anonymous" to current user.

I created a rule:

I've read some posts that I just need to add events on rules, there are no "AND" "OR" to events then rules will trigger that event but I noticed that it doesn't trigger the event "user logged in".

I tried testing this rule. changing Action, setting the value of author to ="1" ("admin") and removing condition of data comparison.

It does change the author to "admin" when saving new content either logged in or not.

When I saw that was working I returned the data comparison for the email.

Then If a user with the same email address logged in it does not change/update the author.

I tried placing the when user logged in first before the event after saving new content, as a result  I wasn't able to use the [node:etc] on comparison and action. I also tried creating a rule with just one event = "User logged in". same result, I can't find the necessary token/arg I need.

Is there something wrong with my settings? Anyone here could point me to the right direction and steps?

Thank you very much!


texts: How to rebuild derived plugins after new entities are installed?

texts:
I have a problem with a stale plugin-derivatives cache in a kernel test:

  protected function setUp() {
    parent::setUp();
    $this->installConfig(['my_module', 'my_module_test']);
  }

The my_module_test module installs new entities that should produce derived plugins, but when my test class tries to instantiate these plugins, they are not found.

It works if I explicitly call $this->container->get('{my_plugin_manager}')->clearCachedDefinitions() after installConfig(), so it's definitely a stale plugin cache. But I'm worried this problem might happen elsewhere. Is there some way to tag the plugin cache with {my_entity_type}_list so it gets invalidated by new entities? Or do I simply need to invalidate it explicitly whenever I do something that creates new entities?


texts: Drupal 7 defines the "use contextual links" permission. Which links are defined as contextual links?


texts: Render an image that is located inside a Paragraph that is inside an Entity Reference

texts:
I'm working with Drupal 8.

I have a content type called Lawyer.

This content type has an Entity reference called Firm.

In Firm (which is another content type) I have a Paragraph with an image field in it.

I need to render this image inside node--lawyer.html.twig

I have tried several ways to do it but I can't make it work. Any help?


texts:
I try to filter a node by the criteria of NID. Naturally I can filter by a single NID, but in this case I need to to filter by multiple NIDs.

I tried to wrote the following number values and non worked:

1, 20, 31

1+20+31

How should I write the number values so that it would work?

Thanks.


texts: Average value of integer field using views

texts:
I set up a multi value cck integer field for rating purposes. It has values

 1|good
 2|bad
 3|dont know

Users voted like so:

3 votes for good
2 votes for bad
4 votes for dont know

I want to make an average from all values. In views 3 I checked grouping and set group type average on cck field inside views. Unfortunately, Instead of 1 result I get 3 results - for every value set in cck field. Results are 1, 2 and 3 which is useless. How it is possible to get only one average number? Thank you

EDIT: the average value works the same way using simple text fields. Views group by in views 3 counts only values that are the same.
And it looks like it is known issue http://drupal.org/node/903768


texts: How to display jQuery UI dialog in submit button's onclick and prevent form submission?

texts:
I'm using Drupal 7 and jQuery Update module set to jQuery version 1.8. I have a form. In it's definition I have:

$form['#attached']['library'] = array(
  array('system', 'ui.dialog'),
  array('aat_pc_product', 'product_form'),
);

In the behavior, I use:

if(!isFormValid) {
  $('<div>' + Drupal.t('Some fields was left blank even when not disabled. Either check "skip line" or fill missing data.') + '</div>').dialog({ modal: true });
}

return isFormValid;

Now, with good old alert it worked great. But when I try do use dialog, in chrome in my console I get:

  Uncaught TypeError: Object function (a,b){return new p.fn.init(a,b,c)} has no method 'curCSS' jquery.ui.position.min.js?v=1.8.7:13

In FireFox it fails in similar way:

  TypeError: c.curCSS is not a function
  ...his,"marginTop",true))||0,v=l+p+parseInt(c.curCSS(this,"marginRight",true))||0,w...
  jquery...v=1.8.7 (row 13)

Updating to dev version of jQuery Update and seelcting jQuery 1.9 or 1.10 does not help - it does not complain about curCSS, but about lack of $.browser() that was removed in jQuery 1.9, and deprecated long ago.

My question is: Am I doing something wrong, or it's a bug between jQuery Update and Drupal? And if it's a bug, is there any version of jQuery update without it?

Is there a way to update jQuery UI to make it match jQuery, without hacking jQuery Update module or updating directly in D:\UniServer\www\misc\ui ?


texts: When does Drupal 5 change the filename field in the system table?

texts:
I tried to uninstall a module from my Drupal 5 website and now it has stopped working. It displays the .info files instead of the pages.

I can fix this temporarily by changing the "filename" fields in the system table from "module_name.info" to "module_name.module".  However this is a temporary fix.  It breaks when someone visits the website one or more hours later.

So I'm wondering what is causing Drupal 5 to change these system.filename fields?


texts: Tooltip issue with tipsy and views tooltips

texts:
I have a table of images, which link to their content, and because some of the content titles vary in length, it's difficult to align each image neatly if the titles are displayed above them, as long titles push their image to the side.
So rather than restrict title length, I'd like to remove the titles, and have them display inside a tooltip when hovering over each image in the table/gallery. Similar to imgur.com, which even shows the number of views for each node. I wouldn't mind showing creation dates too, if possible. But I'll be happy if I can just get the titles to show.

I've installed Tipsy and Views Tooltips, which for the most part seem great, but they aren't quite behaving as I'd like.

Views Tooltip provides the correct content title in the html, but it's div is outside of the Selector used to trigger Tipsy, so Tipsy isn't picking up the correct tip content. It just shows, 'null'.

The html looks something like(inspecting in chrome):

and the list goes on..

So if I set the Tipsy selector to, '.field-content a', it triggers on hover over the images, but doesn't have anything to return. And if I set it to, '.views-tooltip' and 'tooltip content', the tooltip won't trigger when hovering over the images.

So the way I see it, is that I need to somehow set the 'a' selector's original-title to the same as tooltip-content. Does anyone know how I might go about doing that, or perhaps have another solution?
Any help would be appreciated, as I've been stuck on this for almost 3 days now.

Cheers,

Matt


texts: theme_preprocess_node function not getting executed from template file

texts:
I am trying to print action "tabs" in my node.tpl.php file. I added the preprocess function as below-

function MYTHEME_preprocess_node(&$variables, $hook) {

 $variables['page_tabs'] = menu_local_tabs();

}

Then trying to print in my tpl like below.

print $page_tabs;

But it is not getting executed at all. Infect the control is not going inside preprocess function when I am trying to exit like below-

function MYTHEME_preprocess_node(&$variables, $hook) {

 echo "good bye";
 exit;

}

Any help is greatly appreciated. Thanks


texts: How to build a multicriteria search form leading to faceted search

texts:
I have seen a Drupal site that looks like this and it has an interesting search form that has several options for each field to search. This form is filled out (and can be expanded or contracted) and then goes to a faceted search. Unfortunately there is very little information on building advanced search forms like these and connecting them. I'm wondering what may have been used to create this search form but it looks like a couple of modules and not a standard view. But it is possible that one of the experienced Drupal wizards here probably has a better idea than me of what was used and how it was tied together to the faceted search, which you can build in views. Thanks for any help and insight.

At the moment I am using just the built in search for faceted search with a module and it works nicely.


texts: Store cache's datas in files instead of database

texts:
In a huge website, database's tables storing cache may become very large : is there a way to store cache in file system instead of DB ?

I'm talking about a solution that doesn't use external systems like varnish, simply an option provided by Drupal (a config for example). This doesn't seem documented and I'm not sure it exists !

Thanks !


texts: "The requested URL /drupal/ was not found on this server"

texts:
I know this error has been discussed in other topics, but I think every case is quite specific to what happened before.

I'm new to Wamp and Drupal, and I wanted to install Drupal on my wampserver. I followed this tutorial first - https://www.drupal.org/node/114493
It told me to go to localhost/drupal and perform the installation.
Drupal was installed, and I came to step 7: site configuration.
Because it wouldn't work with a random site name, I realized this tutorial had some steps missing, so I didn't fill in the site configuration.

So I started following this tutorial - https://www.drupal.org/node/1995312. This told me to  create a folder for my site in the www folder: I choose Kristientestdrupal.com.
The database and the settingsfile were already created in a different way, by the previous tutorial.
Now Kristientestdrupal.com was visible on localhost. The tutorial told me that if i clicked it I would go to the drupal installation (which I allready performed, but okay, I thought I could go to Drupal site configuration). I clicked it and I got the message that the site was not reachable.

So I retried the link localhost/drupal. This gave me a blank page (404 Not Found) with the message:

  Not Found
  The requested URL /drupal/ was not found on this server.
  Apache/2.4.23 (Win64) PHP/5.6.25 Server at localhost Port 80

It's clearly not working because I did not configure the site yet? But how can I get back to the page for site configuration?


texts:
Currently I am making a website for restaurants. In the site, each restaurant is a node type and a menu item is another node type. The relationship between restaurant and menu items is one to many.

What I am doing is that after user creates and saves a restaurant node, the user session will keep the newly-created restaurant node id, based on that id, user can create multiple menu items for this restaurant.

What I want to make is that only when there is a restaurant id in user's session can user go to menu item add page, otherwise they cannot do that.

So how can I add this menu-item-add-page access control based on user's session?

Cheers!


texts: Commerce billy mail: how to attach multiple files to an email

texts:
I have module commerce billy mail working. Additionally to the invoice PDF that is attached to the mail, I would like to send two more files (terms & conditions and a price list).

Here's the function _commerce_billy_mail_get_attachments from the file commerce_billy_mail.module, it seems to be the appropriate function (?), but I don't know how to add the additional files:

function _commerce_billy_mail_get_attachments($order) {
  $attachments = array();

  list($html, $filename) = commerce_billy_mail_pdf_prepare($order);
  $pdf_filecontent = commerce_billy_mail_pdf_create($html, $filename);
  $filemime = 'application/pdf';
  $attachments[] = array(
    'filecontent' => $pdf_filecontent, // we use a dynamically created file.
    'filename' => $filename, // can use any alias name here
    'name' => $filename, // required for mandril and other libraries.
    'filemime' => $filemime, // mime file type
    'type' => $filemime, // required for mandril and other libraries
    'list' => TRUE,
  );

  return $attachments;
}

Hope someone can help out!


texts: How to allow users to cancel their own account?

texts:
I gave the permission cancel own user account to authenticated users.

Now they can see a Cancel account button on their profile edit.

But when they click on that button, a confirmation form opens. That is fine.

On the confirmation form, when they click on the Cancel account, they are redirected to their profile page with a message

A confirmation request to cancel your account has been sent to your email address.

I want to change this functionality. When they click on cancel account, they should not receive a confirmation cancellation email. Their account should be deleted immediately and they should be gets logged out.

I tried with this code but it is not working.

$form['user_cancel_confirm']['#default_value'] = FALSE;

Is this possible? How can I do this?


texts: 'Add new comment' link/button does not display on custom entity

texts:
A new comment type is created and added as a field (say x_comments) to a custom entity. The comments show up and work as expected. However when the x_comments field is configured to disable 'Show reply form on the same page as comments' the 'Add new comment' link/button does not get rendered on custom entity pages. When this setting is enabled the comment form is displayed as expected.
Inspecting Drupal core's Article content type has custom Links pseudo field where 'Add new comment' link/button is displayed. However my custom entity does not have such a pseudo field, even if it did comment module would not know about it.
Please share clues on how to make the 'Add new comment' link/button be displayed?
The buildCommentedEntityLinks method is not being called on custom entity which creates the 'Add new comment' link. Hmm


texts: Drush command to switch to a multi-site child directory?

texts:
Is there a Drush command that would cd into the directory of a particular multi-site instance, I mean to go to a directory like this one:

/srv/www/drupal/sites/alpha

where the parent Drupal resides in:

/srv/www/drupal

Thanks.


texts: Get a list of all users and into an array

texts: I was wondering what how to get all the user and put all their UIDs into an array? I have seen similar questions but none really answer my question.


texts: Allowed memory size exhausted after importing PO file

texts:
I have a problem after importing the PO of the Drupal core 7.28 (I tried with French and Arabic), whenever I try to create a new feature or open the modules page, I will get an error:

  Allowed memory size of 268435456 bytes exhausted (tried to allocate
  5126472 bytes) in .../includes/form.inc on line 3906

After the import, it is consuming a lot of memory and time I tried debugging, this is the path I could trace:

menu_execute_active_handler -> drupal_get_form -> drupal_build_form -> features_export_form -> _features_export_form_components -> _features_export_build

This is as far as I could get while debugging. The last function _features_export_build takes a lot of time but I couldn’t know what is wrong inside.


texts: Why is the old version of the module being used?

texts:
I am creating a module, and I tried to update its files. I disabled the module, uninstalled it, deleted its files and then I put the new files in the sites/all/modules/mymodule. Then, I enabled my module.

The problem is that Drupal somehow is using the old version of my module rather than the new files I added. I cleared all the caches, from Drupal and manual from MySQL, but nothing changed.

Anyone ever had the same issue? Any ideas?


texts:
I have the following query:

$query = \Drupal::entityQuery('node')
            ->condition('type', 'case_study')
            ->condition('status', '1')
            ->sort('changed', 'DESC')
            ->pager(4);

$query->condition('title', "%QUERY%", "LIKE");

$nids = $query->execute();

This works fine, however it obviously only searches on the title of the node. My case study nodes' fields are structured like this

- Case Study
    - title
    - field_page_banner
    - ...
    - field_rows <-- this is my paragraphs field

The paragraphs can contain multiple types and are chosen by the user when creating the content.

I want to be able to alter my query so that it searches the content of the paragraphs. For example, if the user adds a 'Rich Text' paragraph type, it will search the text.

This works fine for the built in search functionality, I just want to create a page of case studies with search functionality.

I am using Drupal 8.2.4 and Paragraphs 8.x-1.0.


texts: How to create a block of links shared by a user?

texts:
I am using oembed to convert url to embedded content. I have enabled the oembed input filter in a text format. Now I want to create a block using views to only show the posts which have these links. How to do that?

Note: I want to use it on a custom form. Is there something which can detect embedded content in a view. By this I will be able to create a separate view/block containing the embedded content.


texts: syncronize drupal 7 users with magento 1.7 customers

texts:
The Module that is available in drupal is supporting the previous versions of Drupal (D6) and Magento(1.6). You can find it here

http://drupal.org/project/magento

I am using D7 with Magento 1.7, Is anybody out here can suggest me a flow how to add records in customer table while users are registering in drupal, Since i am very new to drupal as well as magento i am finding it a bit difficult to hack into D7 functions

Can this method be followed?

http://mysillypointofview.richardferaro.com/2010/09/07/how-to-pull-the-list-of-customers-from-magento-to-an-external-site/

Does this method have any security vulnerabilities associated with it?

I only need to add a few fields like

First Name
Last Name
Email
Password
Entity_type_id

Rest of the customer details can be updated using the magento engine itself once the user is logged in

Thanks


texts:
I have a custom table, from which I create a paged table using views and data module.
When I get somewhere over 15000 rows, PHP runs out of memory. Is there any way to avoid this?
Thanks


texts:
I am using migrate to import Commerce Products from a CSV file. The CSV file doesn't have its own serial so I am using csvrownum but that obviously won't work if there are already products -- I will be migrating constantly from the CSV files and so I need a real serial. So the big question is, how do I tell Migrate to generate its own serial? prepareRow feels too late because it seems I need to supply MigrateSQLMap a key field.

Here's a rough version of the constructor of the class:

public function __construct() {
  parent::__construct();
  $this->description = t('Test CSV');

  $columns = array(
    array('product_name', 'title'),
    array('url', 'url'),
    array('price', 'price'),
  );

  $this->source = new MigrateSourceCSV('/tmp/test.csv', $columns, array('header_rows' => 1));

  $this->destination = new MigrateDestinationCommerceProduct('commerce_product', 'product');

  $this->map = new MigrateSQLMap($this->machineName,
    array(
      'csvrownum' => array(
        'type' => 'int',
        'not null' => true,
      ),
    ),
    MigrateDestinationCommerceProduct::getKeySchema('commerce_product')
  );

  $this->addFieldMapping('product_id', 'csvrownum');
  $this->addFieldMapping('title', 'title');
  $this->addFieldMapping('field_url', 'url');
  $this->addFieldMapping('commerce_price', 'price');
}


texts: Mass image upload with Storage API and Services API

texts:
I am trying to set up a site that will be storing a large amount of images (roughly 50,000 to start with). The strategy for this was to use Storage API and S3 storage to deal with the costs of hosting, and Services API to provide an interface for a offline converter/uploader to get the images to the site.

This is working pretty good. If I upload an image manually by creating a node and filling in the image field, it gets sent to Storage API and good things happen. I can also upload files and create nodes from the offline uploader via the XMLRPC Services API.

The problem is that the files uploaded with the offline uploader don't get handled by Storage API. Currently the script uses the Services API method 'file.create' to create and object, then the details returned are used to fill in the image field on the node that is created next. I expect there is a better way to do this, but I am not sure.


texts:
I have a very weird problem with flexslider.

Everything was working ok, but suddenly flexslider stopped to show the images im adding.

My observations are:

Flexslider rewrites urls to the path, where there is NO images
there is a access denied warning in drupal logs but my permissions are set to 775/755

Whole flexslider mechanism is working correct, its cycling and stuff, but there is no content inside.

I will appreciate any help, and thanks a lot in advance.


texts: How to render a user register form for a Profile2 type

texts:
Since all of the Profile2 registration forms have the same id 'user_register_form' (even when using Profile2_RegPath module) how can I specify a Profile2 type when calling:

print(drupal_render(drupal_get_form('user_register_form')));

I need to be able to let the user create an account without having him leave the page. I'm able to print the Register and The Profile Fields to be edited, but they each have their own Action button which is what I do not want.


texts:
I was wondering how would you guys approach a situation where your Drupal7 site required a couple of custom content type, yet most of the fields would be shared across them. What I mean resembles a typical object-oriented case of a super class and its subclasses.

I want it so that I can make the admin-side content filling easier for the owner of the site. I also assume that for me, as the author of the form it would be a great time-saver if I could base one on another.

Is it possible? Does it make sense? Or would you rather make one type with all possible fields merged onto one form, then tweak the suggestion template so that irrelevant parts are /shown/hidden upon changing a dropdown menu that specifies the subclass?

Anyone been through a similar problem?


texts:
I'm customizing user profile page in my Drupal 7 site. I decided to remove menu tabs on the page by modifing template.php file with following code
    function my_theme_preprocess_page(&$variables){
    unset($variables['tabs']);
    }
Insted of tabs I created block in user-profile.tpl.php and moved links from tabs there
    `

        <?php print l(t('Edit profile'), "user/{$GLOBALS['user']->uid}/edit"); ?>
    </div>
    <div class="user-profile-subscriptions">
        <?php print l(t('Subscriptions'), "user/{$GLOBALS['user']->uid}/subscriptions");?>
    </div>
</div>`

How can I configure permissions to display this block only whe user is viewing own profile and hide whe viewing profile of other user?

UPD: I assume this may be possible through comparing current user name user->name and user name from URL but I do not know how to extract user name from URL.


texts: Restrict user profiles access with hook_menu_alter

texts:
Following this tutorial I'm trying to restrict viewable user pages (and other tabs created in views).
In particular, users belonging to role coordinator need to view and edit only pages of users associated with them via en entity reference field in core profile, and see an access denied page for others.
I've already queried the db to get all the users id associated with current user and put it in a session var $_SESSION["arUidCoordinated"] that I use in other hooks, but I can't make it work with hook_menu_alter.
Here's the code:

function mymodule_perm() {
  return array('my permission');
}

function mymodule_menu_alter(&$items) {

    $items['user/%user_category'] = array(
        'title' => 'Edit',
        'page callback' => 'user_edit',
        'page arguments' => array(1),
        'access callback' => 'my_module_validate',
        'access arguments' => array(1),
        'type' => MENU_LOCAL_TASK,
        'load arguments' => array('%map', '%index'),
        'file' => 'user.pages.inc',
      );

}

function mymodule_validate($account){

    global $user;

    $uid=arg(1);
    if (in_array("coordinator", $user->roles) AND in_array($uid, $_SESSION["arUidCoordinated"])){

        return true;

    } else {

     return false;

    }

}

I followed this post toot, but I can't make it work, I get "access denied" on every  user/% page, or failed opening required user.pages.inc and I don't understand where I go wrong...


texts: Is it possible to approve an Enitity Form?

texts:
Is it possible to approve a submitted Entity Form by a specific user/role ?

For example, I have a Leave Request Entity form to be submitted by the employee(role). The manager(role) will approve or disapprove the leave request.

Thanks for those who can give me some ideas.
(Im a beginner and learning drupal)


texts: How do I add static html files to my Aegir install

texts:
I have Aegir install running on a rack space server. In addition to the Drupal sites I am running, I would also like to be able to create static websites and server them from the same server. What steps do I need to do to get this to work with Aegir.

I tried the following

1.create a new file within vhostd containing

<VirtualHost *:80>
DocumentRoot /var/www/vhosts/mysite
ServerName mysite.mydomain.com

# Other directives here

</VirtualHost>

add html file to var/www/vhosts/mysite
3 restart apache ? (actually i'm not sure how to do this form aegir)


texts:
I have a semi-new Drupal 7 site in which admins approve the accounts of managers, and managers approve accounts of their employees. That's all working great. I've been asked to make it so that managers can delete the employee accounts that are no longer needed.

Using our old CMS, when all of our SQL was hand written I could build a "where" statement like :

$cWhere = "WHERE e.department = 'HR' and e.manager = 12345"

These items are not user entered, but based on the logged in person. To show a list of employees I could run :

"SELECT * FROM users " . $cWhere

Then to delete I could run :

"DELETE FROM users " . $cWhere . " AND uid = " . $deleteUser

This would ensure that the person who is logged in and trying to delete a user had the permission to do it, because the additional conditions of manager and department were checked. Furthermore, if the conditions for the employee list are changed, the delete code is automatically updated to take the new conditions in to account with no additional work needed. For the record, the query is considerably more complex than that, but no reason to make the question harder than it needs to be.

Now I'm doing everything with db_select. So I build the query to show the list of users. I need an additional query to check that the logged in user has permission to delete the target user. Then I would call the user_delete() function. Is there any way to do this, or do I have to rebuild the query completely a second time?

Non-working code, but something like this :

if (isset($deleteUser))
{
   $chkUser = $query; //$query is an existing db_select that hasn't been ran yet
   $chkUser->condition('u.uid', $deleteUser, '=');
   $rowsUser = $chkUser->execute();
   if ($rowsUser->rowCount() == 1)
   {
       user_delete($deleteUser); //user has permission
   }
}

$result = $query->extend('PagerDefault')->limit(20)->execute();

//... loop results, output list ...

Note, I have tried the above with the user_delete() commented out... but $chkUser is obviously a pointer to $query, as the list printed ends up being just the user in question. So everything works the way I need, except I've mangled my user listing query doing it this way.


texts:
I have a form which has an input field for which i want to add a suffix.
function myapp_preprocess_form_element(&$variables) {
  if ($variables["element"]["#attributes"]["id"] == 'edit-keys') {
    $variables['#suffix'] = '
Some text
';
  }
}

I've looked into the form-element.html.twig file and it does have a suffix varaible, but it's not rendering.
Any ideas?


texts: Execute a custom function on 'user register' or 'login'

texts: I am new to Drupal. I want to execute my custom function every time when user registers or logins to my site. How can I do this?


texts: How to handle ajax wrapper id for list of similar ajax forms?

texts:
Consider a Drupal 7 page with a list of same-type entity forms: formA, formB, formC. The entity form uses ajax to replace part of itself.

Is there an established way to manage the wrapper id's so that an ajax call for formA knows to replace the wrapper div in formA? If I don't change the wrapper id's, I would have three divs on the page with the same ID.


texts: Print Preprocessed username Field Value in User Template

texts:
$account->getDisplayName() Bypasses "username" Field Preprocessing in User Template?

I am trying to print the value of the username field of the user account in a user--custom.html.twig file.

MYMODULE.module:

function hook_preprocess_user(&$variables) {
  $account = $variables['elements']['#user'];
  $variables['userName'] = $account->getDisplayName();
}

user--custom.html.twig:

{{ user.name.0.value }}

Both the above examples access the username, but seem to access the value directly and circumvent any preprocessing of the username field (e.g. hook_preprocess_username()), so it looks like I need a different approach.

I have a view that shows the "User" entity so does not use fields and relies on the user template. What am I missing when trying to get the processed value of the username field, instead of the user name DB value for the account?

Related: Get username in custom user twig template but different.

In my template, I am rendering content.user_picture and trying to render username. So maybe I need to load the user instead of both fields? Looking for the processed username field value.


texts:
I have recently downloaded and installed Omega 7.X-3.1 theme on my Drupal site.
I followed the handbooks instructions to create my first simple HTML5 Omega sub-theme. With the sub-theme enabled I try to navigate to /admin/appearance/settings/themename however I only receive a blank HTML page and a 500 error.
Does anyone know how to fix this problem?


texts: How 2 set up a bunch of modules for sell per node access?

texts:
I need to sell some nodes on my site, not type of content (subscription alredy exist) - only per node acess.
I think, that it is not cost-effective to create type of content for every good, cause number of goods can reach 100 units per day.
I know, that https://www.drupal.org/project/uc_node_access can resolve my trouble, but I develop my site under 7 version of Drupal, and uc_node_access for 7 has only sanbox now.
Dear experts, help me if u can, I'm not a professional developer.
P.S. - sorry if my post has grammar mistakes, I'm Russian.


texts: How to filter only first level menu links using views?

texts:
I have created the menu with the below structure,

A

Link A1
List A2

Link A21
List A22

B

Link B1

Link B11
List B12

List B2

Now my requirement is to get only first level menu links i.e A and B only using views module.


texts: Pathauto is converting special characters (accented) by interrogation points

texts:
I created a Drupal website some years ago and everything was working well until now.

But since yesterday (when the client came back to me), the Pathauto module is now replacing all accented characters by quoting marks in URL aliases.

For example for this node, the URL alias was correct and it was updated.

But now, if I check the option "Generate automatic URL alias", then the "é" character is replaced by ??, as you can see there.

Any idea why this is occurring? How can I fix that?


texts: How to display products without selling them (or using the typical ecommerce modules)?

texts:
I am working on a project with drupal 7. My drupal experience is limited and Im a bit stuck on how to achieve a good structure.

The site will have products like wine, sherries and spirits. Each of these product types will have subcategories. (example: like red / white wine) Within these subcategories there will be certain brands of wines.

Since the website is focussing only on displaying the products and not selling them, I really do not want to use any ecommerce software, or modules.

Preferably I would like the products to be a content type. There is a little catch to it. All categories, so in the examples above; wines, sherries, spirits BUT ALSO red / white wines should have a description and a image.

Can anyone shed some light on how to create this in drupal 7. I have searched a lot but I'm not sure what the right approach would be. Thanks!