texts: Can I store a computed field as a field of a Content Type?

texts:
In content type = Person, I have these fields:
- First Name  [node:field_person_first_name]
- Middle Name  [node:field_person_middle_name]
- Last Name  [node:field_person_last_name]
- Suffix  [node:field_person_suffix]

In views, I have successfully concatenated the full name by adding Global: Custom text and using Replacement Patterns to build the fields. However, this is time consuming.

These fields will always be put together in both of these two ways:
- full name, last first
- full name, first first

Is there a way that I can create two computed fields for these which I could store in the content type? If so, how do I do this? Note: I don't want to modify the original data.

Update:
I have Entity Token and Token already. I loaded Token Filter. I found, but have not yet loaded Token Field.

Token Field suggests that it might be nice if one could define a field "without needing to know any PHP" but the samples on this page indicate otherwise. My HTML knowledge is slight and PHP is non-existent.

I did follow a training video which gave me access to some tokens when creating a new field in Person, but these did not include tokens for fields within the Person content type.

Will this be possible (without PHP) if I install Token Field?

Update 2:
The site simplytest.me is excellent. Token Field loaded. Unfortunately in a real test, I'm getting "Cath [node:field_person_middle_name] Staincliffe [node:field_person_suffix]" because author Cath Staincliffe doesn't have a middle name or suffix. Do you know how to instruct the module to only use a name if one exists?


texts: How can I ensure that a user account on my local dev server has the same uid as an account on my production server?

texts:
I have a local dev server that I use for testing and a production server.  I have written several rules (with the rules module) that send private messages (using the private message module) to users.

I want these messages to be sent from a special administrative support user; the problem is that this user has a uid of 7 on my local site and 9 on the production site.

Since I am still early in the development process, it is simple enough for me to reset the databases and start over so that the uids are in sync.  However, since this may come up again at a point where it is not convenient to reset, is there a good way to ensure that accounts on different servers have the same UID?


texts: How to use Drupal.ajax() to update #content div on  click?

texts:
I'm trying to update the #content with AJAX. I've found the Drupal.ajax function and tried to use it with this code, copied from Views module but modified:

var base_element_settings = {
  'event': 'click',
  'progress': { 'type': 'throbber' }
};
jQuery('a').once('custom-ajax-processed').each(function () {
    var element_settings = base_element_settings;

    if (jQuery(this).attr('href')) {
      element_settings.url = jQuery(this).attr('href');
    }
    var base = "content";// $(this).attr('id');
    Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
});

But instead of replacing the #content it alerts the response contents with the title An AJAX HTTP error occurred.
HTTP Result Code: 200
What am I doing wrong? Is it possible to achieve with Drupal.ajax() ?


texts: Hide new topic link based on the forum topics

texts:
My goal is to create a second forum. I created a new content type called forum2 and added taxonomy_forums term reference to it.

Drupal automatically creates links for each content type.

I would like to display links based on the forum topics.
For example ,

namesite/forum/1 - only New topic link is visible
namesite/forum/4 - only link for forum2 is visible

and so on.

here is what I did

function theme_advanced_forum_node_type_create_list(&$variables) {
  $forum_id = $variables['forum_id'];

  // Get the list of node types to display links for.
  $type_list = advanced_forum_node_type_create_list($forum_id);

  $output = '';
  if ($forum_id == 1 || $forum_id == 2)  {

      $output .= '
';
      $output .= theme('advanced_forum_l', array(
        'text' => 'Add to forum',
        'path' => $type_list['forum']['href'],
        'options' => NULL,
        'button_class' => 'large',
        ));
      $output .= '
';

  }
  elseif ($forum_id == 3 || $forum_id == 4)  {
    $output .= '
';
      $output .= theme('advanced_forum_l', array(
        'text' => 'Add to forum2',
        'path' => $type_list['forum2']['href'],
        'options' => NULL,
        'button_class' => 'large',
        ));
      $output .= '
';
    }
  else {
    // User did not have access to create any node types in this fourm so
    // we just return the denial text / login prompt.
    $output = $type_list;
  }

  return $output;
}

Any help would be greatly appreciated


texts: Hide the "view exposed filter" form or reload the page after submit the form?

texts:
I am using view exposed filter on a view display as "block". The block is added to dashboard.

I added a second function to "Apply" button using hook_form_alter. I want to hide the expose form of view after submit it. I added the jquery to hide the element using drupal_add_js. But it didn't work.

Is there any way to hide the form or reload the page after submit of expose form so i can hide the form on page load?


texts: Saving user specific customization settings

texts:
My module prints entries from the database,
I use Pager and ->limit to choose the number of records to show per each page,
instead of hardcoding limit, I'd like user to decide, between e.g. 10,20,50,100 entries per page.

I've got form with select, and the question is - how I can save and pass user defined value to ->limit.

use database - it works, but I'd like to avoid creating extra entry to database concerning such a silly setting like number of records per page
variable_set - if I'll set variable e.g. number_of_rows, change in the limit made by one user will affect rest of the users - not acceptable

maybe there's some solution concerning cookies/sessions?


texts: Make the suggestions of an autocomplete exposed form clickable

texts:
I'm using Drupal 7 and Views.
I have an exposed form of type "autocomplete".
I would like the suggestions to be clickable, which avoids having to click on apply.
Do you know how to do it ?


texts: Changing the HTML of Webform Confirmation popup

texts:
I want to override the default HTML that loads on a webform confirmation popup but couldn't find a hook for that.

Can anyone help ?

Thanks,
Yaron


texts: Add an extra to the price of the product

texts:
Guests can add a meal plan to their cart. They can compose their own formula. Type of sandwich, drink and dessert.

For example the list of drinks is a list of 'taxonomy' terms.
However some drinks can give a supplement. For example the formula costs 1 € more if I take a coke.

I do not know how to do this possibility. I had imagined adding a field in the taxonomy of drinks where we can put the blow of the supplement. But I did not find with Rules how to add this extra to the cart.

Have an idea of how I could do it? Thank you for your help


texts: How may I simplify the registration process

texts:
I Try to use RNG to allow student user to registrer for company interviews (the events). I set up a View on my event to allow student to register for an interview.

It seems a bit complex because they had to click on a link (register) to a page where they have to click on a create button under a select Identity where there is only one mandatory "My account" radio ?

Is there a better way to do that with RNG, or maybe a more suitable module, I am indeed trying to create a n,n relationship between user and event.

I give a try to basicCart module, but I don't need the order part.


texts: drupal_http_request redirect is not a fully qualified uri. Throws missing schema error 1002

texts:
I am trying to authorise with an Viagogo API using oauth in my custom module (i have my credentials from Viagogo). I can construct the initial URL OK but the redirect response from the API is a relative reference with an absolute path i.e. /Public/SimpleOAuthAccessRequest/Authorize?oauth_token=Y%34hg5k34jhg5%3D

Which in turn is throwing a missing schema error using drupal_http_request.

  object(stdClass)#466 (4) { ["error"]=> string(14) "missing schema"
  ["code"]=> int(-1002) ["redirect_code"]=> string(3) "302"
  ["redirect_url"]=> string(87)
  "/Public/SimpleOAuthAccessRequest/Authorize?oauth_token=Y%2Fbm9asdfasdfdsfjJfdd3D"

How can i get around this?

Is there a simpler way my custom module can authorise with oauth and access this API instead of my having to write this connector? The PHP code sample provided by Viagogo is using CURL and works fine outside of Drupal but once I bring the functions inside my custom module it doesn't work hence me using drupal_http_request.


texts: What are the significant differences between the Sharethis, Addthis, and Service Links modules?

texts:
AddThis
Service Links
ShareThis

These three modules appear to be very similar in terms of functionality.  AddThis has about double the number of the installs compared to the other two, but Service Links and ShareThis each have over 10,000 installs, which is not too shabby.

What, if any, are the significant differences among these modules?


texts:
I see Documentation of entity_load but I didn't find anything about ordering of results,
How can I order the results entity_load by delta?

as example I fetch all product of one node by

$node = node_load(313);
$field = field_view_field('node', $node, 'field_product_select');
$pids = array();
foreach ($field['#items'] as $key => $value) {
  $pids[] = $value['product_id'];
}
$products = entity_load('commerce_product', $pids, array(), TRUE);

$return = array();
foreach ((array) $products as $key => $product) {
  $return[$key]['product_id'] = $key;
  $return[$key]['product_type'] = $product->type;
  if($product->field_is_selected_price['und'][0]['value'])
    $selected_price=$product->commerce_price['und'][0]['amount'];
  $return[$key]['price'] = $product->commerce_price['und'][0]['amount'];
  $images = field_view_field('commerce_product', $product, 'field_product_images');
  foreach ((array) $images['#items'] as $image) {
    $return[$key]['img'][] = $image['uri'];
  }
}

I want fetch products order by 'delta'(or other field ),(results are order by entity_id by default) , how can I achieve it?


texts: How to create options in installation profile/ distribution to enable custom content types?

texts:
I have created a custom installation profile/ distribution with exported config files of a site. I have 4 content types in this site from which two will be installed by default but for other two are optional.

I can see a couple of options:

Creating a custom module for each content type and putting related config files in it. (This does not allow any option at installation time although I can enable the module using info file of profile)
Custom form alter of installation form and add check boxes.(If I want to combine this with option 1 then how can I do that?)

Checkbox-> Content type 1 (This is disabled and checked)

Checkbox-> Content type 2 (This is disabled and checked)

Checkbox-> Content type 3 (Optional)

Checkbox-> Content type 4 (Optional)

All the related config files of checked content types should be enabled at installation.

I would like to go with option two and give user check boxes at the time of installation of profile but if there are any better ways to do it then please do suggest.

Thanks in advance.


texts: Contact Form with drop-down subject (bonus: auto-selected based on GET/POST)

texts:
I have a number of services on my site and I want them to all direct to the contact form. Now, this is where it gets tricky- I want the subject to be a dropdown selection of all services provided and, if possible [bonus], based on the link clicked (GET/POST).

Alternatively:
I would also be open to a contact-form jquery popup modal box that I could tailor for specific services.

Any help is greatly appreciated and I thank you in advance.


texts: How to create a view of duplicate entities based on title, showing the most recently created ones

texts:
I have investigated a number of solutions that came close to my requirements, but not one that actually solves this, I think very common, use case:

Often after using feeds, there are duplicate entities created with the same title. Apart from the methods to prevent this from happening, I want to find a solution to list the most recently created entities of which the title already is in use.

When the most recent duplicates are listed, I want to bulk-delete them using views bulk operations.

My approach is as follows:

Create a view that lists titles of all entities of a certain bundle.
Turn on aggregation
Add the entity ID as field, with aggregation 'Count'
Add a filter: entity ID with aggregation 'Count' is 'more than 1'

The result is a list of entity titles with a column of the count of entities having that title.

Question 1:

So far so good, but I need to see the latest entities listed with an already existing title. How to make that happen?

Question 2:

I need to bulk-delete these most recent duplicates, preferably using Views Bulk Operations. However, when I add VBO(for entities) to the view, this results in an empty output. Probably because the aggregated list shows titles and not entities. This is caused by question 1 not being resolved.

EDIT:
I came up with the idea to use this view of duplicate titles, as a filter for another view that should show the latest entities having those titles.
So my 3rd question would be:

QUESTION 3: How to create a view that uses the aggregated view mentioned above as its filter, to show the entities having those titles.


texts: Form added to content in hook_page_build lacks of AJAX

texts:
I'm adding a form to the footer using hook_page_build because a want to show it using a popup, so when user launches the popup the form appears inmediatly.

The problem is that the form is not AJAX processed: the submit button hasn't the ajax-processed class so AJAX is not working. But if I render the form using hook_menu and drupal_get_form the form has the ajax-processed class and AJAX is working.

Form code fragment:

  $form['message'] = array(
    '#type' => 'textarea',
    '#title' => t('Your Personal Message'),
    '#default_value' => '',
    '#cols' => 50,
    '#rows' => 5,
    '#description' => '',
    '#required' => TRUE,
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Send Message'),
    '#ajax' => array(
      'wrapper' => 'myform-wrp',
      'callback' => 'myform_ajax_callback',
    ),
  );

Implementation of hook page build:

function mymodule_page_build(&$page) {

  // Get the current $node
  [...]

  $form = drupal_get_form('mymodule_form', $node);

  $page['footer']['my_form'] = $form;

}

Hook menu that the retrieves a working AJAX form:

function mymodule_menu() {

  $items = array();

  $items['node/%node/mymodule-form'] = array(
    'title' => 'My form',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('mymodule_form', 1),
    'access callback' => TRUE,
  );

  return $items;
}

I've tested it with hook_page_alter too.

What can be needed to ajaxify this form? I suppose is something related to adding the form too late...


texts:
I have installed a few modules for the site; one of them is causing an error, and I can't access the modules page.

The error I see is the following one:

  Fatal error: Call to undefined function ctools_include() in
  /var/www/vhosts/haweraprezchurch.org.nz/httpdocs/sites/all/modules/features/includes/features.ctools.inc on line 226

How can I access the module page?

In my case I am using Drupal 7.


texts: disable administrator role in add user form

texts:
Some role in my site has permission to create users but not a administrator one.
How to disable create a new user of administrator role?
Is there a module for that?
thanks.


texts: Organize files attached to a node into folders

texts:
We need to organize files attached to a page into folders (with Drupal 7). They don't necessarily have to be physical folders, virtual folders are fine.

Do you know a module like this, or do we have to implement it our own?

Update:
To be more specific: we need the ability to display attached files on the page organized into folders, the underlying filesystem structure is indifferent.


texts: Login by phone or email along with Username

texts:
There is a requirement to provide login option with all the following: username, email and phone. I understand LoginToboggan provides the capability to login with email or username. I am looking to incorporate the phone number as well, is there a module which would let the user do this?

I did see some posts in Drupal answers too but all of them discuss only about email login.

Edit: The forum suggests me to edit my question with more details about the cross referenced stackExchange post. Registering the user's phone number is definitely something which has to be considered, however, the prerequisite for me is to check whether phone login is possible in first case which will work seamlessly with email login and username login. A multiple provision would not be bad especially for people like me with poor memory ;)


texts: How to find the number of clicks on a flash banner?

texts:
There is a flash banner in a Drupal website. I want to know number of clicks on that flash banner.

My Question: Is there such option in Drupal (in Joomla there is one).


texts:
I am trying to receive the values of the form on my email, but I just receive empty mails. What is wrong in my code?

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state) {
   $langcode = 'fr';
   $to = 'my_mail@gmail.com';

   $mailManager = \Drupal::service('plugin.manager.mail');
   $module = 'FrenchForm';
   $key = 'New contact';
   $params = array(
    'body' => 'test',
    'subject' => 'Website Information Request',
    );
   $send = true;
   $message['subject'] = t('New mail');
   $message['body'][] = t('test');

   $result = $mailManager->mail($module, $key, $to, $langcode, $params, NULL, $send);
}


texts:
I am making a drupal commerce site. For coupon functionality I am using commerce_coupon module .

My question is How can I restrict a coupon by user roles i.e. a particular coupon should be applicable only for authenticated users .

I have already installed Commerce Coupon - Per user redemption installed which gives me coupon per user functionality . But I want commerce coupon by user roles.

How can I achieve this ?


texts: Event registration for events with multiple dates/places

texts:
I'm making a event content type (representing academic conferences) for a Drupal 7 site, and I'm thinking of give visitors the posibility of registering in these events.  But in some cases, these conferences can occur several times, in different dates and places. When registering, the registrant must choose in which date/place he wants to go.

For now, the date/place pairs are being stored in the event via a Field Collection. I've also checked two common modules for registrations in D7: Node Registration and Entity Registration.

Right now I'm thinking in 2 alternatives to implement this:

Several registrations forms per event, one for each date/place:

Pros:

I could (in theory) manage each presentation separately, with different capacity/end of registration date.

Cons:

As now, I don't find a module that permits multiple registrations in a node. (custom code?)

One registration form per event, with a list field that permits to choose the date/place

Pros:

Implementable right now through Node Registration module + private fields per node

Cons:

I can't manage capacity/end of registration date separately, and when the end date of one presentation comes, I must update the list field manually (custom code?)
The list options are defined per field (not by field instance) so I have to create a new field on each event that has multiple dates/places (each one with different machine name. Consider this is going to be done not by site admins, but event organizators with its own user role)

Is there another way to implement this feature? An module I haven't found? A hidden feature or creative use of Node/Event Registrations? Custom code/module?


texts: How to set a flag at node when user view node?

texts:
I have a content type 'page'. When a user views this node, I want a flag to be set automatically not by flage module link.

Any help?


texts: Problem when using Feeds to import nodes which have a image field

texts:
I'm using feed to import nodes from a csv file. I'll try to reproduce.

Everything works fine if I do this:

1) I create the importer. For Mapping Settings I set:

ID -> Node ID
TITLE -> Title
BODY -> Body

This importer will import the csv data to the cuadros content type

2) I import this csv file with no problem at all:

ID;TITLE;BODY
83;without title;text
1084;White;text

But I get a message error if I include a image for the node

1) I create the importer. For Mapping Settings I set:

    ID -> Node ID
    TITLE -> Title
    BODY -> Body
    PHOTO -> Images

Images is a image field of the node.

2) I put the 2 images files in: localhost/mysite.com/sites/default/files/photos/

3) I import this csv file

ID;TITLE;BODY;PHOTO
83;without title;text;http://localhost/mysite.com/sites/default/files/photos/245c-w1000-h800.jpg
1084;White;text;http://localhost/mysite.com/sites/default/files/photos/261-w1000-h800.jpg

4)I get the error message you can see below.

Just in case it was a permission problem I set the files folder and all its content to 777, but problems stil persist

 The specified file temporary://filel1sCPA could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.
The specified file temporary://fileqPBtxM could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.

Invalid enclosure http://localhost/mysite.com/sites/default/files/photos/245c-w1000-h800.jpg
Invalid enclosure http://localhost/mysite.com/sites/default/files/photos/261-w1000-h800.jpg


texts: The provided host name is not valid for this server even after updating settings.php

texts:
I'm running in to the error message
The provided host name is not valid for this server.

I found the previous solution here however even once updating my settings.php file I'm continuing the hit this problem.

My two domains are almost identical however the second one includes an a at the beginning. Therefore my two trusted_host_patterns are exactly the same except that the second one includes an a after the ^. Is it possible that there is something else I'm missing? Looking in admin/reports/status I can see the two domains listed under trusted hosts.

Here's the line:

 $settings['trusted_host_patterns'] = array(
    '^domain\.com$',
    '^adomain\.com$',
 );


texts: 7.26 /admin, /user not found on Localhost

texts:
I am new to Drupal. I developed a site on a server and now migrating it on my personal computer (Windows 8.1). The site is working fine as it should.

My problem on localhost is that when I log in to my site (using this url: localhost/drupal_site/user/login) with an admin userid, it redirects me to the "404 Page(url: localhost/drupal_site/user)" on submission of correct username/password, And neither the admin menu bar occurs on the site.

I've tried modifying .htaccess, httpd.conf, cleaned cache tables in database and clean urls etc.

In .htaccess i've write:

'RewriteBase /drupal_site'

In httpd I've wrote:

<Directory "C:/xampp/htdocs/drupal_site">
    AllowOverride All
</Directory>
AccessFileName .htaccess

Its ironic that I've tried various solutions found with drupal community, but none of them really worked for me.

My Drupal Version is 7.26.

Xampp: Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3

Can anyone help me resolving this?


texts: How to update field values of a content type's nodes when when viewing a particular content type page

texts:
I'd essentially like to alter the values of a specific custom field of a few of nodes before they're displayed in a view on the 'page' of a specific content type.

The content type is that will be displayed is a park. When a park is viewed, one of the blocks shown is a view that fetches and shows several nodes that are also 'parks'.

This park content type has a field called proximity. I'd like to change the value of proximity (based on a mathematical formula) for all parks before the view is processed, so that I can use proximity in the view.

From what I understand so far, I should use a park_preprocess function, which calls some sort of hook to change the proximity values. Is this correct, and how would I do it?


texts: Change values of nested fields with entity_metadata_wrapper

texts:
The background of this question is that I'm trying to migrate data from Drupal 6 Imagefield Extended to Drupal 7 File Entity (with File Entity Inline). See also https://www.drupal.org/node/974888

First I tried to understand how entities work and how they can be extracted and manipulated using Entity Metadata Wrappers. That seems to work ok, for example, I can get the values of my imagefield like this:

$nid = 103025;
$node_wrapper = entity_metadata_wrapper('node', $nid);
$images = $node_wrapper->field_image->value();

And it seems that I could change the values of the images with something like this:

// Do something with $images
$node_wrapper->field_image->set($images);
$node_wrapper->revision->set(1);
$node_wrapper->save();

(For some reason it's not saving the values for the node in my case, but that's another question.)

My problem now is that I have nested fields, i.e. the imagefield has "subfields" for the source and license (that I had added in Drupal 6 using Imagefield Extended). I do get the values of those nested fields in $images - but only in the typical array with $images[und][0]['value'] and $images[und][0]['safe_value']. But there seems to be no way to get those values through the wrapper, for example like

$node_wrapper->field_image->field_source->value();
$node_wrapper->field_image->value()->field_source->value();

Now I have been trying for hours to figure out how I can change (or populate) those (sub) fields and then save the entire node, but to no avail.

I'm also wondering if it's necessary to do this on a node level as files are also entities, but it seems that there is nothing like entity_metadata_wrapper('file', $fid);.

I'd appreciate any hint that could point me in the right direction because the search has been kind of exhausting.


texts: How can I modify the arguments passed to a core hook?

texts:
Due to a recent update of Drupal core, I'm getting the following error:

  Notice: Undefined index: taxonomy_term in
  taxonomy_field_formatter_view() (line 1601 of taxonomy.module)

Now, this is caused because the core taxonomy hook taxonomy_field_formatter_view() has an argument called $items that expects an array of values that have two elements: tid, a numeric value, and taxonomy_term which is the taxonomy term object.

In the case of my code, each array in $items is missing the taxonomy_term element.

Now a simple fix would be to hack core and simply set $item['taxonomy_term'] = taxonomy_term_load($item['tid']) if it doesn't already exist. But of course, hacking core is a no-no so I'm trying to find a way to catch the $items argument for taxonomy_field_formatter_view() before it is passed to this hook.

What's the approach here? Would defining hook_field_formatter_view() in a custom module and fixing the $items argument work? Presumably not because the core hook is going to fall over first, so I'll need to modify it before it's passed into these hooks?


texts:
We are trying to host Drupal 8 at Azure web app, but developers is complaining on performance problems. As solution to mitigate it, they suggested to install xhprof. In order to install it, we've downgraded to PHP 5.5.9, but could not login to Drupal now; it just returns a 500 error. PHP error log is clean, IIS says that there is a CGI error (something wrong in PHP handler); since there is no access to Drupal, we could not check errors there.
Can you help us in setting Drupal 8 with XHProf on Azure web app and figure out what the problem is?


texts: Returning alternate HTTP codes for unpublished node

texts:
I'm trying to return the 404 page instead of 403 response for unpublished nodes in Drupal 8.

I tested  kernel response subscriber, but found the code I was using would only change the status code to 404 from 403, not actually display the 404 page.  So maybe someone can show me how to generate a 404 page Response object there?

This is the code I was using:

class ResponseSubscriber implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [KernelEvents::RESPONSE => [['alterResponse']]];
  }

  /**
   * Change status code to 404 from 403 if page is an unpublished node.
   *
   * @param FilterResponseEvent $event
   *   The route building event.
   */
  public function alterResponse(FilterResponseEvent $event) {
    if ($event->getResponse()->getStatusCode() == 403) {
      /** @var \Symfony\Component\HttpFoundation\Request $request */
      $request = $event->getRequest();
      $node = $request->attributes->get('node');
      if ($node instanceof Node && !$node->isPublished()) {
        $response = $event->getResponse();
        // This changes the code, but doesn't return a 404 page.
        $response->setStatusCode(404);

        $event->setResponse($response);
      }
    }
  }

}

I finally resorted to removing this response subscriber completely and used hook_node_access like this:

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Drupal\Core\Access\AccessResult;

function unpublished_404_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Session\AccountInterface $account) {

  if ($op == 'view' && !$node->isPublished()) {
    if (\Drupal::moduleHandler()->moduleExists('workbench_moderation') && $account->hasPermission('view any unpublished content')) {
      return AccessResult::neutral();
    }
    elseif (\Drupal::routeMatch()->getRouteName() == 'entity.node.canonical' && \Drupal::routeMatch()->getRawParameter('node') == $node->id()) {
      throw new NotFoundHttpException();
      return AccessResult::neutral();
    }
  }

  return AccessResult::neutral();
}

This seems to be in line with several answers on this site for Drupal 7.  But I wanted to see if anyone has a better way of doing this either with a KernelEvent subscriber, rather than hook_node_access.  It seems like what I want to do is test if a node is returning a 403 and then generate a new response with the 404 page and 404 status code.  I'm not sure how to do that.


texts: How do I apply a custom set of blocks to a custom content type

texts:
I have a custom content type I call a Listing. It contains a few hundred fields, and it has a custom template, which renders the node indie the main content area.

How do I configure the sidebar and other blocks to appear/not appear for only this content type and not all content?


texts:
I have a Webform that does some calculations (javascript) based on user selections, which i would like to send along with the user-selectable fields to a user's email.

Is it possible to append these div's to the HTML email along with the fields?


texts:
I'm writing a module and there is a text area where the users have to add paths; then, I explode these paths, and run some commands.

I would like to let users add something like "path/*" (as in context conditions).
Is it possible?


texts: Specify default sort header for a sortable table (tablesort) in D8?

texts:
I am trying the table sort example module and noticed that I am unable to specify the default sort col once the page load. Meaning, when the page load for the first time it's always sorting by the first column in the table. In this case the number column (see screenshot). I tried 'sort'=> 'DESC' and 'sort'=> 'ASC' on the second and third col but it did not pick any as a default sort col.
  Here is the code generating the tablesort:

<?php

namespace Drupal\tablesort_example\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Database\Connection;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Controller routines for tablesort example routes.
 */
class TableSortExampleController extends ControllerBase {

  /**
   * The Database Connection.
   *
   * @var \Drupal\Core\Database\Connection
   */
  protected $database;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('database')
    );
  }

  /**
   * TableSortExampleController constructor.
   *
   * @param \Drupal\Core\Database\Connection $database
   *   The database connection.
   */
  public function __construct(Connection $database) {
    $this->database = $database;
  }

  /**
   * A simple controller method to explain what the tablesort example is about.
   */
  public function description() {
    // We are going to output the results in a table with a nice header.
    $header = [
      // The header gives the table the information it needs in order to make
      // the query calls for ordering. TableSort uses the field information
      // to know what database column to sort by.
      ['data' => t('Numbers'), 'field' => 't.numbers'],
      ['data' => t('Letters'), 'field' => 't.alpha'],
      ['data' => t('Mixture'), 'field' => 't.random'],
    ];

    // Using the TableSort Extender is what tells  the query object that we
    // are sorting.
    $query = $this->database->select('tablesort_example', 't')
      ->extend('Drupal\Core\Database\Query\TableSortExtender');
    $query->fields('t');

    // Don't forget to tell the query object how to find the header information.
    $result = $query
      ->orderByHeader($header)
      ->execute();

    $rows = [];
    foreach ($result as $row) {
      // Normally we would add some nice formatting to our rows
      // but for our purpose we are simply going to add our row
      // to the array.
      $rows[] = ['data' => (array) $row];
    }

    // Build the table for the nice output.
    $build = [
      '#markup' => '<p>' . t('The layout here is a themed as a table
           that is sortable by clicking the header name.') . '</p>',
    ];
    $build['tablesort_table'] = [
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => $rows,
    ];

    return $build;
  }

}


texts: Why Each user can modify flag field of other users by VBO(Views Bulk Operation)?

texts:
I have many users, and I have a flag and also flag field. users can flag contents and add value in flag field when they are flagging a content. for modifying flag field I'm using VBO Module. But each user can modify flag field of other users. Consider Jack and John flagged a content, in this situation John can modify flag field of Jack and himself.

I want to users only can modify their flag fields. John can modify her flag field and Jack can modify her flag field too.

Update

When John logins to site, He could see below situation in site. I mean, John also can modify Jack's field value. This situation is possible for Jack and others.


texts: How to use [submission:values] in Email template in Webforms

texts:
I have the Webform 7.x-4.0-alpha6 version module enabled.

I have a Webform node with 20 form components. I added one email in Email Setting and I created the email template where I used the token: [submission:values].

Then I test the webform submitting a message. The problem is that [submission:values] print out the components values in a very plain way, no break line, no semicolon to make a difference between the title and the value for each component. Something like:

Name Jhon
Addresss Myaddress 12
CP 19932
....

Having 20 component make the email completely unreadable

My question is: Is there a way (a token) to print them in a better way, at least adding a semicolon between the title and value, and making the title bold ? or putting the output in a table?

    Name: Jhon
    Addresss: Myaddress 12
    CP: 19932

I know that I can print out the components in a separated way using the tokens:
[webform:{component}-title] for the title
and
[webform:{component}-value] for the value

And then I can style them. But this is time wasting since I need all components to be shown in the email template

Update: I found this module but doesn't help me: http://drupal.org/project/webform_tokens


texts: Best way to log clicks on a link of a custom content type

texts:
I have a custom content type (bundle, drupal 7) which has a link (rules link module) and I want to log the number of clicks on this link. At the moment I've an integer field in the bundle and I use rules to increment it and save the node every time the link is clicked.
I think this method is not efficient and has also security implications so I ask you suggestions on how to do it better.
I considered writing a small custom rule (module) which increment the value directly in the field table which probably would have less overhead but I think it would still not be very secure as I don't know how to handle a large number of clicks in a short time.
Thanks for any help.


texts:
I am working with Drupal 7.
How do I limit a taxonomy drop-down exposed filter to only display the terms used by nodes in view results?

I understand that the list is populated before the views takes place, but this means that I am often left with tags that display nothing ( since they are hidden with my view).


texts:
How to display the custom content type fiels in the custom template file. I have integrated custom content types in views.

How to assign custom template files to a view which is filtered to display certain content type only.


texts:
I create $_SESSION['loop'][$id].
When I unset $id = 0 then all of $_SESSION['loop'] are delete.
How can I do this?

$id = \Drupal::request()->query->get('id');

if (isset($_SESSION['loop']) & (isset($id)) & ( $_SESSION['loop'] > 0)) {
  $_SESSION['loop'] = $_SESSION['loop'] - 1;
  unset($_SESSION['label'][$id]);
  unset($_SESSION['code'][$id]);
  unset($_SESSION['price'][$id]);
  unset($_SESSION['sellercode'][$id]);
}

return header('Location: /basket');


texts: I am using Drupal 7. I do not want comments to index in search module. How can I achieve this?


texts: How to show fivestar votes in views as number instead of percentage?

texts:
I have a view which show a content with a Fivestar field (votes).
The problem is that the field is shown as the percentage of votes, not like the stars, or the number (in fact I need to show the number instead of percentage).

I mean, my Fivestar field has 10 stars. Well then if, for example, a node has 7 stars, rather than see the 7 stars or the number of stars (7) is shown the percentage, 70.

What I have to do to show the number (in my example "7")?


texts: All page access only to administrator in

texts:
I want to restrict my page access. Only an administrator should be able to see the page.

I followed this tutorial

function example_menu() {
  $items['example'] = array(
    'title' => 'My Page',
    'page callback' => 'example_custom_page',
    'access callback' => 'example_user_has_role',
    'access arguments' => array(1, array('adminstrator')), // Argument 1 loads the user, argument 2 is the role name.
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

function check_user_has_role($user, $roles = array()) {
    foreach ($roles as $role) {
        if (in_array($role, $user->roles)) {
            return TRUE;
        }
    }
    return FALSE;
}

But I was able to access the URL even after I logged out. What is my mistake or is there a better way to achieve this?


texts: How to join the `field_data_field_*` tables with `node` table using SQL?

texts:
I apologize if I ask for something obvious, but I am asking because I could not find a simple answer anywhere.

I know how to work with these tables in the PHP Drupal code, which built-in functions to use, etc., but for some reasons, I have to write a literal SQL query to the Drupal database.

That's why I'm asking what condition I need to use in the SQL query to connect the field_data_field_abc table with the node table?

If the data in the field_data_field_abc table contains the entity_type column with the value "node", can I do something like this:

SELECT *
FROM node n
LEFT JOIN field_data_field_abc abc ON n.nid = abc.entity_id
WHERE abc.entity_type = 'node'


texts: View groups by vocabulary in wrong order when being filtered by a second vocabulary

texts:
I am having a problem with my 'Grouped By' groups (term reference) being re-ordered when there is a filter for a second term reference.
Details:

My People content type has a People Category.
People are 'Grouped By' People Category vocabulary in order by term weight. This order is important.
People can also be placed in a Department vocabulary.
Not all People have a Department.
The View filters by Department. The filter is exposed.
The Sort Criteria is only People Category (asc)

Here is how they are displayed:
People Category 2
Person 1 (Department 1)
People Category 1
Person 2 (No department)
To summarize: If a Person has no Department, its Category grouping is pushed down out of order.
Here is what I have tried:

Added People Category as a sort criteria.
Added People Category and Department as sort criteria
Changed Department filter from “Is not empty” to “is one of”
People Category is already before Department in the Filter Criteria
Moved the Department filter to a second filter group.
Moved the People Category filter to a second filter group.


texts: List related nodes through the same referenced node?

texts:
I have two node types: book, author.

There is a node reference field in book which references a single author.

On a book node, I would like to display a list of the same author's books, which I don't know how.

It seems to me the solution will involve EVA, contextual filter and relationships.

I can list all the author's books in an author node using EVA and contextual filter. But it uses author's node ID, which is in the url. I don't think I can pass the referenced author's Nid in a book's url. Or can I?

I'm only 5 days into drupal, and don't know a thing about relationships, can someone help me get my head around this? thanks in advance!

[D7]


texts: Creating a menu structure based on Content Types Alias

texts:
I have imported in a bulk of content via a CSV Feed Importer (see Migrating content from older custom CMS). It worked splendidly. I was even able to take in each of the pages old URL and create an path alias for each page. Now I would like to rebuild the menu structure and it would be a certain help if I could create a menu structure based on all of the path aliases.

Is there a module to accomplish this?


texts: Webforms - Getting Select Options From External Database - Not Working

texts:
I am trying to populate the webforms pre-built option list using a custom module. It works when manually including the values in the module, but when I try to query an external database to get the options it fails. Below is my code. I know that the database works, because views is currently able to get data using that connection and the query works when implemented directly in MySQL.

<?php

function mymodule_webform_select_options_info() {
    $items = array();
    $items['user_name'] = array(
        'title' => t('User Name'),
        'options callback' => '_webform_get_user_names'
    );
    return $items;
}

function _webform_get_user_names()
{
     $user_names = array();
     db_set_active('externaldatabase');
     $query = 'SELECT userID,userName FROM user_name';
     $select = db_query($query);
     while ($row = db_fetch_object($select)) {
         $id = $row->userID;
         $user_names[$id] = $row->userName;
     }
     db_set_active('default');
     return $user_names;
 }


texts: Full HTML Block displaying incorrectly to Anonymous

texts:
I have been looking for help on this issue for awhile, but I can't seem to crack it.
For some reason, I need to have "Bypass content access control"  enabled to get this to look correctly.

I may be doing it wrong, so I'll let you know about what I'm trying to do as well. I want to make a Bootstrap Carousel that shows the images,  exactly as you see in the preview image.

What I've done is made a full-HTML block and pasted the code directly in to that. It works perfectly as the administrator, but it isn't working correctly with the DOM, obviously, as anonymous.

I've found things in the past where people had problems with this same permission, but nothing from 2013 to now. And as far as I can tell, nothing with the way blocks were rendered.

The site where you can see how it is actually working is: dev.americasconference.org

The way this should be working is that they previous/next flaps should be overlays on the photos, and not over the left and right margins of the web page.

Many thanks!!


texts: Gmap - Dynamically load markers on map pan

texts:
How can I add new markers when the user pans the map? For example, my database contains 100,000 markers and loading them all would be unfeasible. When the user moves the map, I would want the script to issue a new call to the database to retrieve the new markers. Here is the code that I have so far:

$url = "http://example.com/products?limit=200&offset=0&lat=40.756623&lng=-73.98487";
        $data = file_get_contents($url);
        $results = json_decode($data,true);
        $markers = array();
        $test = array();
        foreach($results as $result)
        {
            if(!empty($result['lat']) && !empty($result['lon']) && !empty($result['dealTitle']))
            {
                $key = $result['lat']."_".$result['lon'];
                if(!in_array($key,$test))
                {
                    array_push($test,$key);
                }
                $temp = array("text"=>$result['dealTitle'],
                                "latitude"=>$result['lat'],
                                "longitude"=>$result['lon']);
                array_push($markers,$temp);
            }
        }

    // a simple GMap array
      $map_array1 = array(
        'id' => "my-map",         // id attribute for the map
        'width' => "100%",        // map width in pixels or %
        'height' => "400px",      // map height in pixels
        'latitude' => 40.735812,    // map center latitude
        'longitude' => -74.010987,  // map center longitude
        'maptype' => "Map",       // baselayer type
        'markers' => $markers,
      );
      $element1 = array(
        '#type' => 'gmap',
        '#gmap_settings' => $map_array1,
      );
      $html = drupal_render($element1);


texts:
I have nearly 150 Panel pages and different template files. I generated lot of blocks using Node Block module to be used in the Panel pages.

I guess this is causing memory issues in both MySQL and Apache configuration. Any solution for this memory issues?

My global memory_limit is 128M. Only after setting 512M in settings.php, my custom Drupal View is generating the output (otherwise, it generated a 502 error).

Is there a way so that I can set memory_limit only for my custom View?


texts: How can I trace module dependencies in Features?

texts:
I have a site with several module created with the Features module. I've just noticed that one of the modules created with Features (we'll call it module B), has a dependency on another module created with Features (module A). As far as I know, there should be no connection or dependency between the two modules at all.

Is there a way to track down which aspect of feature B is creating the dependency on feature A since I'm almost positive it is doing so in error?


texts: Image captcha module not showing in admin after updating Drupal to 7.35

texts:
I have a site with Captcha module installed and Image captcha submodule working perfectly before upgrading.

I followed the recommended steps, and even did it in a nearly identical test site. Everything worked perfectly in the test site. But when I applied the changes (updating from previous core version) in production, I realized that Image captcha is not only not working anymore: it even doesn't appear as submodule in Admin.

The folder is there but is no longer detected. I am thinking of reinstalling the complete Captcha module, but I am very worried about the rest of modules.

Going back to my backup of my database is not an option as I realized the problem after 2 days and that means losing a lot of data (if I would restore my backup).

Any tip on what could be causing this?


texts:
I am trying to play around with Drupal 8 menu. How I understand now menu is a service, so how to alter menu output in Drupal 8? Is there any documentation? Because googling show no useful results.

What I am trying to achieve is move active class from <a> element to parent <li> element, this should be possible to do in .twig template (I wouldn't like that) so how to get menu in Drupal 8 and alter it's attributes?


texts:
How can I create menus like Apycom Menus ?

Do I need to create custom module and then use it which will be available to whole site or I can just use css and js from the apycom menus?


texts: Views adds "nid" to SELECT and GROUP BY when trying to aggregate by title

texts:
I tried to create a simple aggregated View, but Views added nid, even though I did not select it as a field, and also ruined my GROUP BY making the view unusable.

Any tips how to avoid this nid addition?

SELECT node.title AS node_title_1, node.nid AS nid, COUNT(node.title) AS node_title
FROM
{node} node
WHERE (( (node.type IN  ('my type')) ))
GROUP BY node_title_1, nid
LIMIT 10 OFFSET 0


texts: Entityreference not saved correctly inside ContentEntityForm

texts:
I was having a weird bug with my views. Some entity-references from my main-entity didn't show up in my view.

I investigated further with entityQuery and came across some weird action.
I can get the missing referenced entities by querying for nulls in main_entity and loading the referenced entities manually using the magic entity getter:

// Returns 90 main-entities. These correspond to the entities with missing data in my view.
$main_entity_ids = \Drupal::entityQuery('main_entity')
  ->notExists('field_referenced_entity')
  ->sort('created')
  ->execute();
$main_entities = \Drupal\my_module\Entity\MainEntity::loadMultiple($main_entity_ids);

// Load referenced entities for each main entity using the magic entity getter
$referenced_entities = [];
foreach($main_entities as $main_id => $main_entity){
  // Skip nulls
  if($referenced_entity = $main_entity->get('field_referenced_entity')->entity){
    $referenced_entities[$referenced_entity->id()] = $referenced_entity;

    // // Re-saving the entity here doesn't help
    // $main_entity->set('field_referenced_entity', $referenced_entity->id())
    // $main_entity->save();
  }
}

// At this point $referenced_entities -array contains 90 fully loaded refenced entities.

Also, the table main_entity__field_referenced_entity is missing rows for the missing references. I wonder how am I able to get the reference with the magic getter.

I tried to re-save all the entities in my loop but with no success.

The main-entity is first created and saved without the reference which is added afterwards inside ContentEntityForm::save()-method.

...
// Entity is saved and re-loaded
$main_entity->save();
$main_entity = \Drupal\my_module\Entity\MainEntity::load($id);
...
// Set the reference and save
$main_entity->set('field_referenced_entity', 123);
$main_entity->save();
...

Creating the MainEntity programmatically seems to work, inserting the required rows to the main_entity__field_referenced_entity -table:

$main_entity = \Drupal\my_module\Entity\MainEntity::create([
  'type' => 'main_entity',
  'status' => 1,
  'name' => 'Programmatically created MainEntity',
]);
$main_entity->save(); // No rows
$main_entity = \Drupal\my_module\Entity\MainEntity::load($main_entity->id());
$main_entity->set('field_referenced_entity', 123);
$main_entity->save(); // Row added

The problem seems to have started after updating to Drupal 8.5 from 8.4.4. I was running Drupal 8.5.3 when I noticed the problem. Updating to Drupal 8.5.5 doesn't help.

Does anyone have any idea what could be going on?


texts: hook_menu_links_discovered_alter() not being called

texts:
I'm working on a theme for a Drupal 8.8 project. I've implemented hook_menu_links_discovered_alter() in my .theme file – but Drupal doesn't seem to be invoking it, and I don't understand why.

(For context: my goal is to make some modifications to the "Log in" and "Log out" links on the user account menu. I've found numerous examples online which say that this is the right hook to use for this purpose.)

Here's what I've tried:

I've checked (a dozen times) that I'm using the correct function name, with the correct signature: mythemename_menu_links_discovered_alter(&$links)
I've added die('in hook') in my hook function to determine whether it's even being called. (It's not.)
I've cleared cache many times, from both the Drupal web dashboard and via drush cr. No luck.
I've noticed that Drupal sometimes takes a while to notice changes to .theme files, even after you've cleared cache. So, to be absolutely sure that Drupal is using the latest version of the file, I've added echo statements to other (already-working) hooks. This has confirmed that Drupal is using the latest version of the file – but mythemename_menu_links_discovered_alter() still isn't being called.

Any ideas?


texts: How to disable redirection to the node after node form submission

texts:
I have a node form exposed in the front-end to allow visitors to add their organisation to the list of partners. Below the form, I have exposed view block with the list of existing partners.

When a visitor enters a new organisation to the list I want the form just to add a new node type "partner" and reload the page/block without redirecting to the node content (node/[node ID]).

At the beginning I ed taxonomy terms instead and it worked as it should, now I want to achieve the same with node entity.

I have tried various solutions but none of it works correctly and I didn't find much by googling it.

For example, this is not functioning:

function THEME_form_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id) {
  if ($form_id == 'node_partners_form') {
    $form_state->disableRedirect(); // This is not functioning
  }
}

This does not work either:

function THEME_form_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id) {
  if ($form_id == 'node_partners_form') {
    foreach (array_keys($form['actions']) as $action) {
      if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
        $form['actions'][$action]['#submit'][] = 'THEME_node_form_submit';
      }
    }
  }
}

function THEME_node_form_submit($form, &$form_state) {
  $form_state->setRedirect(Url::fromUri('internal:/node/1')->toString());
}

=> Error: Route /partners does not exist.

Value of attribute action in the exposed node form is correct and therefore I think the proper solution should be elsewhere then altering form properties - probably it has more with the Drupal behaviour after adding a new node.

<form action="/en/partners">...</form>


texts: Entity Metadata Wrapper ->set saving data in incorrect language

texts:
I'm using entity_metadata_wrapper to programatically create some nodes. I noticed that some of the fields weren't showing in the node/edit form after doing this, even though they are shown on the frontend. After lots of digging I found in the database that the field data is being saved with 'und' instead of my chosen language ('en'). What is the way to fix this?

The field 'introduction' is definitely translatable before anyone asks (otherwise it would show in the backend just fine).

$entity = entity_create('node', array(
    'type' => 'my_bundle',
    'uid' => $user->uid,
    'status' => 1,
    'comment' => 0,
    'promote' => 0,
    'language' => 'en'
  ));

$ewrapper = entity_metadata_wrapper('node', $entity);
$ewrapper->language('en'); // Thought this would do it, but no dice
$ewrapper->title->set('This works fine');
$ewrapper->field_introduction->set('This doesnt');
$ewrapper->save();


texts: Move existing Webform textfield elements into a dropdown

texts: I have created a Webform using Drupal 8.9.13 and Webform version 6.0.2 and I have existing textfield elements and hidden elements which I am using in a computed twig element to calculate their values. This is working as expected but I now need to display these text fields into a dropdown options box. Is this possible?


texts: Redirect Search API view result (Leaflet map) to display in a pane

texts:
The particular Search function starts as Full Panel Page in a style to a Google Maps Location Search page; Search Input (Block) to the top left overlaid on a current Leaflet map based on the logged-in users Postcode. (It is overlaid with CSS using z-Index).
I'm confused over what is required to make the required Search Result Data View (Leaflet map) show in the same Panel Pane Window.
The user can after the above viewpoint window, again Search via the Search Block with the following next results this time to display in the same Panels Page or a Variant (As it will show the Views Context Pane) again full page Leaflet display with the said results and again with the Search Input Block again the the top left. (I'm not bothered if is the same window or a second Variant)
For example, an initial Panel Page is named: <dealers/local/mapping> which is a a two pane layout (left/Right). The Search input block is to the left whilst the initial map is to the right (set at 12 columns).
The additional search results (as a View (Indexed) would show again in the right Column Pane as a 12-column full page display. So the path would result asL <dealers/local/mapping/search-api-results/cheshire*> *cheshire being the locality the user entered to search for and displays the relevant mapping which I can add Facets/Proximity etc to it.
Currently, the search results only show the Results Page View by itself and not in any panel pane, which I require.
For hours (and I'm mean over some 8 hours over 2 days!) I have tried to get my head around what needs to be 'plugged in to what' to get the second stage Search API results to display in a second Panel Page so I can also include Search API Facets.
I've looked for hints, tips across Stack and Drupal.Stack, old 'tutorials' online (harking back to 2010!) and simply cannot find any hint, tip, or workout.
Somebody please help!


texts: moving D8 from one sub-folder to another

texts:
If you move your Drupal 8 website from one sub-folder (example.com/oldsite) of your domain to another sub-folder (example.com/newsite), you will find that internal links to pages and references to images are not updated. Instead, these links and references will point to your old domain name. How to fix this issue?

For example, this is one of the pages after the move the site from one subfolder to another. If I click on any of this links it's taking me back to the old website.

Thanks


texts: Related nodes view block based only on child Taxonomy Terms

texts:
I have a 2-levels Taxonomy Hierarchy structured like this:

Parent Term
    - Child Term 1
    - Child Term 2
    - ...

My goal is to create a view block, where related nodes based only on child taxonomy terms are displayed.

How can I do that?

Thanks

EDIT
The created views block will be displayed in the node's page.
So when in a node's page the views block should display other nodes that are related to the current viewed node based only on the child terms and not the parent.


texts:
I have created my contact us module using form api, email is successfully generated and send to my specified email address, but I need body of the email to b html formatted, for this I have created another file mymodule.install in my module folder and add the below code:

function mymoduleenable() {
 $current = variable_get('mail_system', array('default-system' =>    'DefaultMailSystem'));
 $addition = array('mymodule' => 'mymoduleMailSystem');
 variable_set('mail_system', array_merge($current, $addition));
}

function mymoduledisable() {
 $mail_system = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
 unset($mail_system['mymodule']);
 variable_set('mail_system', $mail_system);
}

and in my mymodule.module

 class mymoduleMailSystem extends DefaultMailSystem {
 public function format(array $message) {
 $message['body'] = implode("\n\n", $message['body']);
 $message['body'] = drupal_wrap_mail($message['body']);
 return $message;
 }
}

but due to above all piece of code I am unable to receive email, kindly suggest any solution.


texts: Cannot update core with composer after switching to core-recommended

texts:
I tried to update core from 8.9.0 to 8.9.1 with composer require drupal/core-recommended:8.9.1 but I get the following error:
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Can only install one of: drupal/core[8.9.1, 8.9.0].
- Can only install one of: drupal/core[8.9.1, 8.9.0].
- Can only install one of: drupal/core[8.9.1, 8.9.0].
- drupal/core-recommended 8.9.1 requires drupal/core 8.9.1 -> satisfiable by drupal/core[8.9.1].
- Installation request for drupal/core-recommended 8.9.1 -> satisfiable by drupal/core-recommended[8.9.1].
- Installation request for drupal/core (locked at 8.9.0) -> satisfiable by drupal/core[8.9.0].

This is pretty confusing, I thought drupal/core was replaced by drupal/recommended?


texts: Google Store Locator error while loading js assets

texts:
I've installed Google store locator set of modules on Drupal and for a while all worked fine, however now, seemingly our of the blue it stopped working. When looking at Chrome's console I can see it can't load sites/all/libraries/markerclusterer/src/markerclusterer_compiled.js nor sites/all/libraries/storelocator/js/store-locator.compiled.js even though both files are there. I've changed the files permissions to 644 then 777 to see if it was a permission issue, but that didn't resolve the problem.

Any suggestions?

EDIT

The error is: Uncaught ReferenceError: storeLocator is not defined and I also get a red GET while trying to load these libraries.


texts: String passed to the T function in inline_template not accessible for translation

texts:
For a custom field I have a formatter:

  public function viewElements(FieldItemListInterface $items, $langcode) {
    $elements = [];
    foreach ($items as $delta => $item) {
      $value = unserialize($item->value);
      $elements[$delta] = [
        '#type' => 'inline_template',
        '#template' => "{{ 'translate_me'|t }} {% for key,value in info %}  {{ key|t }}  : {{ value }} <br/> {% endfor %}",
        '#context' => ['info' => $value],
      ];
    }
    return $elements;
  }

I tried to search for the string "translate_me" on admin/config/regional/translate to translate it but cannot find it. I did clear the cache, run the cron, ensure the module the define the string has a version, and viewed the node in the target language. but to no avail. What am I missing?

Thank


texts:
I have a term reference field on one of my content types that allows for multiple terms to selected (list of checkboxes).  Is there a way to identify one of the terms as the "primary term"?

I know that I could add a second term reference field, but I'm thinking something along the lines of a radio button next to each term's checkbox, that could be checked, indicating the primary term.

We're going to using this to help categorize a set of digital files, and the terms relate to specific sections the digital file could relate to.  Each file can have several terms associated with it.  However some of the files have a physical copy in our library and the physical copy can only sit in one specific section on the shelf.  We'd like a way to indicate where the physical copy is located, so being able to mark one of the selected terms as the primary term would allow us to change how it displays.

So it could look something like this:

With 'foo' being the primary term.


texts: Missing values in $form_state['values'] when addding field through _form_alter after AJAX callback

texts:
I want to add a couple of fields to a content type form using AJAX and, upon validation, run a custom _submit callback to do something with those fields.

My approach:

1. Alter the form adding a select that triggers the ajax, evaluates the value of $form_state['values'][and produces two textfield fields:

function hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
  $form['select'] = array(
    '#type' => 'select',
    '#title' => t('Options'),
    '#options' => array(0 => 'Do nothing', 1 => 'AJAX'),
    '#ajax' => array(
      'callback' => 'my_ajax_callback',
      'wrapper' => 'ajax-info',
      'effect' => 'fade',
    ),
  );

  $form['info'] = array(
    '#type' => 'fieldset',
    '#title' => t('Information'),
    '#prefix' => '
',
    '#suffix' => '
',
  );

  if ($form_state['values']['some_value'] == 'some_other_value') {
    $form['info']['input_1'] = array(
      '#type' => 'textfield',
      '#title' => t('Input 1'),
    );

    $form['info']['input_2'] = array(
      '#type' => 'textfield',
      '#title' => t('Input 2'),
    );
  }

  // some validation
  $form['#validate'][] = 'my_module_FORM_ID_form_validate';

  // append it to the bottom because it's important that it is executed after the default submit callback
  $form['actions']['submit']['#submit'][] ='my_module_FORM_ID_form_submit';
}

2. Return the relevant part of code in the ajax callback:

function my_ajax_callback($form, $form_state){
  return $form['info'];
}

My problem comes when implementing my_module_FORM_ID_form_submit, as it seems that $form_state['input_1'] and $form_state['input_2'] are not set.

Sometimes, after clearing cash, input_1 and input_2 may be read in the callback and everything may work. But eventually, errors occur after a few attempts.

I also tried setting $form_state['rebuild'] = TRUE in the _validation without success.

Can it be a problem with the way I'm adding the submit callback? I cannot add it to $form['#submit][] because the default form callback is not defined there and it's important that my custom callback gets executed last.

EDIT
I think that what is causing the problem is that one of the fields that I am adding is actually an addressfield widget, that I attach to my form by calling addressfield_generate().


texts:
By default the label() method of the user entity returns the username. So everywhere on the website where user references are used, the username is displayed.

I need to alter this method so everywhere the user name is displayed it will use my custom function. So instead of "custom_user_name" will display "Firstname Lastname" for example.

Any idea on how to achieve this? Thanks.


texts: File paths aren't pulling in images or stylesheets

texts:
I'm sure I'm not the first person to run into this but I can't find another post about it.

I'm pretty new to drupal and I'm taking a swing at theming. I'm running into problems right out of the gate. I have my .info file set up and it is calling in two stylesheets and two javascript files. The stylesheets are not showing up on my site but the javascript files are...

also I have some place holder images within the template and no matter what I do with the file paths I can't get them to be pulled in either. I only bring this up because I feel like this is connected to my issue with the style sheets.

here is my .info file:

name = jonathansumner
description = A custom theme for jonathansumner.com
version = 1.0
core = 7.x
screenshot = screenshot.png

Stylesheet[all][] = ../css/bootstrap.css
Stylesheet[all][] = ../css/jbs.css

scripts[] = js/bootstrap.js
scripts[] = js/main.js

regions[header] = Header
regions[highlighted] = Highlighted
regions[help] = Help
regions[content] = Content
regions[sidebar_first] = Left sidebar
regions[sidebar_second] = Right sidebar
regions[footer] = Footer

features[] = logo
features[] = name
features[] = slogan
features[] = node_user_picture
features[] = comment_user_picture
features[] = comment_user_verification
features[] = favicon
features[] = main_menu
features[] = secondary_menu

My file stucture:

css [
  bootstrap.css
  jbs.css
  ]
js [
  bootstrap.js
  main.js
  ]
images [
  *images*
 ]
templates [
  page.tpl.php
 ]
jonathansumner.info

I've tried:

Stylesheet[all][] = ../css/bootstrap.css
Stylesheet[all][] = ../css/jbs.css

and:

Stylesheet[all][] = css/bootstrap.css
Stylesheet[all][] = css/jbs.css

and I have done the same with the images file paths within my html inside of page.tpl.php. I've been moving folders and files around for hours trying to get it to work and I haven't found an answer anywhere that solves this issue. I'm thinking I left something out of my .info file or maybe drupal can't handle directories or something. It's seams like this same set up works for other people though so I don't understand.

I have installed themes that work just fine so I don't think it is my installation causing it so it has to be user error of some type. Any suggestions?


texts: What reasons are there for views not rendering a link?

texts:
The link passes the nid and date to another view. List of classes presenting a link to a list of bookings.

In the following example John's class has a link but Jake's class does not.

The 'Add booking' and 'Claim' links work for all classes and pass the url as nid/time where time is in seconds rather than formatted to be passed to views.

The date field is setup with the date formatted as follows

The link is created through rewriting

More things that don't work.

Turn off Style settings > "add default classes"
Just rewrite the text instead of "Output this field as a link". I get the half closed span. This is true if I rewrite the source field.

2017-09-26AEST14:35">View Bookings
Creating a plain text field and rewriting there. Same result as for rewriting inline.

I can see why taking the default classes away might work, as it might stop the date formatter wrapping the text.
The link formatter looks like it is removing the span, so any other rewriting doesn't work.


texts: When programmatically adding views, what is a more efficient way to add them other than include them in mymodule.views_default.inc?

texts:
I have written a module that writes views programmatically, and my mymodule.views_default.inc file is enormous. Currently there are 150 individual views, and 780 will be the target.

But, even with the test group of 150 several things are happening.

1) when enabling the module via drush, php memory usage goes through the roof. It climbs into the gigs (TOP command), but it finally loads.

2) but, when I then try to view the site I get WSOD, and the top command shows apache2 climbs into the gigs for memory usage until the Apache process actually crashes.  Of course there is not enough memory to load it, and it's of course unrealistic to put php memory limit in the gigs.

What's going on here? How is the code in mymodule.views_default.inc actually handled once it's loaded? Where is it being loaded to? Is it loaded into memory for each Apache process? If I can actually get it loaded will my Apache process footprints actually shrink back down to something normal?

Can this file be divided up into individual files, and would this even help? Is it better to someway put them into the database instead of using the file at all?

In other words, how can I get almost 1000 views loaded and continue doing business as usual?

note, if you are curious, this is a census data project. I don't want to use filters or arguments as each set of data needs to to have its own individual page URL and other criteria unique to that data set.


texts: How to clean the html output of textfield using CKeditor?

texts:
I have a textfield using the wysiwyg http://drupal.org/project/ckeditor text editor module.

If I insert a table in the text then the table is wrapped with the following tags

    &nbsp;

I thought that the http://drupal.org/project/htmlpurifier module would remove this tags but it doesn't.

How can I remove these lines?


texts: 403 Ajax error when trying to place a block

texts:
I am unable to place a block. When I click on 'Place Block' nothing happens. When I check the Chrome console, there is an Ajax Forbidden Error 403. Message below. I have both checked Drupal log messages and the server error log and nothing appears there.
I have a local site and a dev site with the exact same code. It works fine on my local site, but not my dev site. All my file permissions are set at 644 and 755. I'm not sure what file I would need to update file permissions for, and if it's a restriction on my host, do I need to add something (and what) to my .htaccess file?
-----------FROM CHROME CONSOLE---------------
Drupal.AjaxError
message: "↵An AJAX HTTP error occurred.↵HTTP Result Code: 403↵Debugging information follows.403 - Forbidden Error↵403 - Forbidden Error↵
You are not allowed to access this address. If the error persists, please contact the website webmaster. If you are the webmaster of this site please log in to Cpanel and check the Error Logs. You will find the exact reason for this error there.
Common reasons for this error are: Incorrect file/directory permissions: Below 644. In order files to be read by the webserver, their permissions have to be equal or above 644. You can update file permissions with a FTP client or through cPanel's File Manager. Restrictive Apache directives inside .htaccess file.  There are two Apache directives which can cause this error - 'Deny from' and 'Options -Indexes'.
--UPDATED: FURTHER INFO FROM CONSOLE--
POST https://........../admin/structure/block/add/block_content%3A9d037523-3c9f-4267-8c94-d41db339b994/uswds_base_subtheme?region=header_top&_wrapper_format=drupal_modal 403
(anonymous) @ VM959:1
send @ jquery.min.js?v=3.5.1:2
ajax @ jquery.min.js?v=3.5.1:2
Drupal.Ajax.eventResponse @ ajax.js?v=9.0.8:337
(anonymous) @ ajax.js?v=9.0.8:277
dispatch @ jquery.min.js?v=3.5.1:2
v.handle @ jquery.min.js?v=3.5.1:2
ajax.js?v=9.0.8:511
Uncaught Drupal.AjaxError {message: "↵An AJAX HTTP error occurred.↵HTTP Result Code: 40…his error - 'Deny from' and 'Options -Indexes'. ↵", name: "AjaxError"}
Drupal.Ajax.error @ ajax.js?v=9.0.8:511
complete @ ajax.js?v=9.0.8:245
c @ jquery.min.js?v=3.5.1:2
fireWith @ jquery.min.js?v=3.5.1:2
l @ jquery.min.js?v=3.5.1:2
(anonymous) @ jquery.min.js?v=3.5.1:2
load (async)
send @ jquery.min.js?v=3.5.1:2
ajax @ jquery.min.js?v=3.5.1:2
Drupal.Ajax.eventResponse @ ajax.js?v=9.0.8:337
(anonymous) @ ajax.js?v=9.0.8:277
dispatch @ jquery.min.js?v=3.5.1:2
v.handle @ jquery.min.js?v=3.5.1:2


texts: Why does Apache show such drastic differences in memory usage when using mod_php?

texts:
I've taken steps to reduce as much as possible the memory footprint of my Apache mod_php processes by disabling Apache modules as well as Drupal modules.

When the server is under light load, I see memory usage between 40MB and 80MB.  However, when the server is under heavy load and there are about 100 processes active, 90 of those 100 will be 12MB.

I'm assuming this is a good thing of course. I know that the PHP is embedded into each process so then why would there be such a drastic difference in the memory footprints, 12MB and 80MB, and why can those first 10 be in the area of the 12MB range?


texts:
50 terms and each term needs to have radiobuttons or "other".

Food - o in price - o extra price

Drinks - o in price - o extra price

WiFi - o in price - o extra price

So "in price" and "extra price" are radiobuttons. User clicks "extra price" and he gets conditional text field (integer) where he can write the extra price. Result after choosing "extra price" should look like this:

Food - o in price - o extra price - _________ €.

There are 2 things that come to my mind. Making separate vocabulary out of each term, each containing terms "in price" and "extra price", make separate integer field in content type and use conditional field module.

But that would mean i would have to create 50 vocabularies and 50 integer fields for 1 content type and its possible that there will be more terms in the future.

2nd option would be creating 50 fields instead of using taxonomy and use Select or other module but that also seems to be overdoing it to have 1 content type with over 50 fields just becouse of this option


texts: Only one video is visible from a multiple-value field

texts:
I have a field named hudl_videos for embedding videos and I have added multiple values to the field.  I use the Embed and the Video modules where I can embed Youtube and Vimeo videos, but videos from HUDL aren't visible.

Why does this happen?


texts: How can I use a content type field on the body of the e-mail message template on the Webform module?

texts:
For usability matters, I would like to let the editor create his own confirmation message on my Event content type. So I create a field for that. I also have another field to select which webform is going to be used as a reference (I am doing that the same way that was done on the Event Demo that comes on the module).

Is there a way to use this content type field on the e-mail handler on the webform as a token or something like that?


texts:
I'm getting a strange error when uploading an image to my site. On upload, I use the Custom EXIF Mappings module to insert various metadata values into fields. This has worked really well for all but just a few images where I receive the following error:

  PDOException: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: 'ÿî' for column 'field_file_image_date_value' at row 1: INSERT INTO {field_data_field_file_image_date}

I'm really confused by this error, especially by the value ÿî. I checked/compared the metadata with other images in Bridge and can't seem to find any differences. Any thoughts on what might be causing this?


texts:
For some reason my theme function is not being found by Drupal.  I swear I have followed everything and spent hours of time trying to make this work to no avail.  Plus with not a single answer in the past 48 hours, Drupal's online support forum is about as much help as a bike with no wheels.  Maybe some of you can figure out what is going wrong with this code.

    function opti_format_results($response) {

    $results = array(

    '#theme' => 'opti_design'

    );

    if ($response) {

    foreach ($response as $key => $value) {

    $results['result '.$key] = array(

    '#markup' => $response[$key]['title'],

    // '#link' => $response[$key]['link'],

    );

    }

    } else {

    $results[] = opti_nothing_found();

    }

    return $results;

    }

    function Opti_Search_theme() {

      return array(

    'opti_design' => array(

    'render element' => 'optisearch'

    )

      );

    }

    function theme_opti_design($variables) {

    $content = $variables['optisearch'];

    var_dump($variables);

    $content = "What is going on??";

    echo "IT HAS THEMED! :D";

    return $content;

    }

The error is quite simple.  "Theme hook opti_design not found."  Can someone please tell me what is wrong.  Everything looks fine.  The hook_theme() function was set properly, and worked in an entirely other module just fine but for whatever reason will not do it's job here.  I feel like it is something simple but I am not seeing it.  Thanks for any and all help.


texts:
I have configured website with Drupal 7. Site is using Domain Access module. We use this module to make something like multi-site. We have one launch page on which you can choose desired subsite. All subsites have the same theme but with different colors, images, content. Additionaly site is multi-language. Right now structure is as follows:

  intro.example.com/de - launch page in German intro.example.com/en
  - launch page in English site1.example.com/de - main page for first subdivision in German site2.example.com/en - main page for
  first subdivision in English site2.example.com/de - main page for
  second subdivision in German site2.example.com/en - main page for
  second subdivision in English

I would like to change URL structure to following:

  example.com/de - launch page in German example.com/en - launch
  page in English example.com/de/german_name_of_site_1
  example.com/en/english_name_of_site_1
  example.com/de/german_name_of_site_2
  example.com/en/english_name_of_site_2

How can I change this link structure without turning whole site upside-down?
I would appreciate any help and ideas.

Franz


texts: Deployment using Composer replacing old style install but issues with legacy Drush

texts:
I took a Drupal project that was created awhile back via downloading a tar file and recreated it on a local via composer with drupal-project.

The recommended files were committed to git (i.e. no contributed modules, etc.) and cloned on the server. The composer install was clean.

At the point of doing a $ drush sqlc to load the database, it became evident that there was an issue - Drush error message below. I believe the issue is that Drush was already installed.

$ which drush outputs /home/me/.composer/vendor/bin/drush.

The error message when I attempt to run drush sqlc or drush status from the project, even with --root, is the following.

  PHP Warning:  require(/var/www/html/drupal/d8/vendor/composer/../../load.environment.php): failed to open stream: No such file or directory in /var/www/html/drupal/d8/vendor/composer/autoload_real.php on line 70
      PHP Stack trace:
      PHP   1. {main}() /var/www/html/drupal/d8/vendor/drush/drush/drush:0
      PHP   2. require() /var/www/html/drupal/d8/vendor/drush/drush/drush:4
      PHP   3. include_once() /var/www/html/drupal/d8/vendor/drush/drush/drush.php:56
      PHP   4. ComposerAutoloaderInit6220513682b217c143f76d07878222a3::getLoader() /var/www/html/drupal/d8/vendor/autoload.php:7
      PHP   5. composerRequire6220513682b217c143f76d07878222a3() /var/www/html/drupal/d8/vendor/composer/autoload_real.php:60
      PHP Fatal error:  require(): Failed opening required '/var/www/html/drupal/d8/vendor/composer/../../load.environment.php' (include_path='/var/www/html/drupal/d8/vendor/pear/pear_exception:/var/www/html/drupal/d8/vendor/pear/console_getopt:/var/www/html/drupal/d8/vendor/pear/pear-core-minimal/src:/var/www/html/drupal/d8/vendor/pear/archive_tar:.:/usr/share/php') in /var/www/html/drupal/d8/vendor/composer/autoload_real.php on line 70
      PHP Stack trace:
      PHP   1. {main}() /var/www/html/drupal/d8/vendor/drush/drush/drush:0
      PHP   2. require() /var/www/html/drupal/d8/vendor/drush/drush/drush:4
      PHP   3. include_once() /var/www/html/drupal/d8/vendor/drush/drush/drush.php:56
      PHP   4. ComposerAutoloaderInit6220513682b217c143f76d07878222a3::getLoader() /var/www/html/drupal/d8/vendor/autoload.php:7
      PHP   5. composerRequire6220513682b217c143f76d07878222a3() /var/www/html/drupal/d8/vendor/composer/autoload_real.php:60

In addition to Drush being in both ~/.composer/vendor and <root>/vendor, I note that ~/.composer contains

autoload.php
composer
phpdocumentor
phpunit
symfony
bin
doctrine
phpspec
sebastian

How do I go about cleaning this up so that the project root is the sole repository of these files and Drush can find what it's looking for?


texts: How can I hide/disable a specific menu item and a specific page (node) from all non-default languages?

texts:
Drupal 8 / Muli-Language Site:

There is a specific page that we need to hide/disable along with its menu link if the current site language is not the default (English).

How can this be done?


texts: Created a development/test server from an existing site, struggling with permissions errors on Cent OS 6 server

texts:
I am hoping a I can get a little help on a problem that I continually struggle with and that seems to impact a number of places on a site that I have copied over from a production version.

So I have a site for which I created a development environment for on an Amazon EC2 instance (original site is not on Amazon EC2). So far everything is loading up and showing for the most part. But it is becoming clear that in handling administrative tasks I am running into file permission problems.

For instance, If I go to *Administrator > Site Building > Themes > My Custom Theme* to configure the favicon, I get the error:

  The directory sites/default/files is not writable

I have tried chmod 775 and that does not work. If I do chmod 777 the css files don't load and the site is without styles. I have tried chown 6226 (which seems to be the default user from when I did a fresh install of drupal 6.20 on the new server). And have tried chown ec2-user (the default ec2 instance user) as well as chown the user from the production server (for which there is a user with the same name on the new server).

So far nothing works and the directory is still not writeable. Where can I go just to see what the new server expects for write permissions to the files it needs permissions to access? These are not problems on the production server.


texts: How to redirect users after password reset from first time user

texts:
I am using hook function in my module to redirect users accordingly as below.

function mymodule_user_login($account) {
 if (!$account->getLastAccessedTime()) {
  // The user has never logged in before.
   return;
 }
 $response = new RedirectResponse('MyModuleFormUrl');
 $response->send();
}

First time users coming from their corresponding emails are getting redirected to change password page able to set new password and existing users are redirected to form page after successful login. But the problem is how to redirect users after successfully setting their password to my module form. From the code above I thought it should happen automatically but it isn't. Can anyone suggest some ideas.

Edit to the Question:
So as suggested below I tried both the ways but still after the new user clicks save button on password reset page(setting his new password), he is not getting redirected to mymodule form page. Below are the codes I tried.

Method 1:

    function MyModule_form_alter(&$form, &$form_state, $form_id){
    if($_SESSION['first_time_login']==TRUE)
    {
       $_SESSION['first_time_login']==FALSE;
       $form_state->setRedirect('url');
    }

Method 2:

    function mymodule_user_form_alter(&$form,
    \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
    {
       foreach (array_keys($form['actions']) as $action) {
        if (isset($form['actions'][$action]['#type']) && $form['actions']
        [$action]['#type'] === 'submit') {
        $form['actions'][$action]['#submit'][] = 'mymodule_form_submit';
         }
       }
    }

    function mymodule_form_submit(array $form, FormStateInterface
     $form_state){
         $form_state['redirect'] = 'url';
     }

Final function which worked for me:

    function MyModule_form_alter(&$form, &$form_state, $form_id){
      if($form_id == 'user_form')
      {
        foreach (array_keys($form['actions']) as $action) {
           if (isset($form['actions'][$action]['#type']) && $form['actions']
           [$action]['#type'] === 'submit')
           {
            $form['actions'][$action]['#submit'][] =
               '_MyModule_user_profile_submit';
           }
       }
     }

      function _MyModule_user_profile_submit($form, &$form_state)
      {
           $response = new RedirectResponse('url');
           $response->send();
      }


texts:
I'm new to commerce, but I can't find a way to generate an order for a already existing customer via Admin Panel. Do I have to code that by myself or am I missing something?

I've tried to use Commerce Admin Advanced Order Module but this only seems to work with drupal users, not commerce customers.


texts: how to verify if a field is empty in views field template?

texts:
I have a views row template (views-view-fields--mymodule.tpl.php)

I wanted to verify if a specific field is empty.

Is there any way to perform this ?.

Here is what I already tried.

Every try failed.

1 try

  if($field["field_fax"]){

2 try

  if(isset($fields["field_fax"]->raw)) {

3 try

  if (!is_null($fields['field_fax']->content['fid']) ) {

Thanks a lot


texts:
How do I get a confirmation message to show as a modal dialog?

$form['mytable'][$id]['operations']['delete'] = array(
  '#type' => 'submit',
  '#value' => t('Delete'),
  '#name' => 'd' . $entity->ref,
  '#attributes' => array('onclick' => 'if(!confirm("Really Delete?")){return false;}'),
);

I've looked at the Colourbox module and OpenModalDialogCommand but I don't know how to integrate this into #attributes.


texts: how to hide text format tips for text field in a module, not theme?

texts:
I need to hide the text format tips for body field, depending on user role, in a module. After some research, I found this kind of code:

function mymodule_form_node_form_alter(&$form, &$form_state) {
  if (isset($form['body'][LANGUAGE_NONE][0]['#after_build'])) {
    $form['body'][LANGUAGE_NONE][0]['#after_build'][] = 'mymodule_node_after_build';
  } else {
     $form['body'][LANGUAGE_NONE][0]['#after_build'] = array('mymodule_node_after_build');
  }
}
function mymodule_node_after_build(&$form, &$form_state) {
  /*if (!user_access('administer filters')) {
    $form['LANGUAGE_NONE']['0']['format']['#attributes']['class'][] = 'invisible';
  }*/
}

*I know the mymodule_node_after_build function is all commented, so
it's doing nothing, but it's here only for illustration. Just adding
#after_build to the form or field makes it all invisible - and this is the issue here.*

The above code results in field body not displayed at all, instead of just hiding text format info. More precisely, the html contains this code in place of the body field (just an empty div):

I tried setting this also for:

$form['body'][LANGUAGE_NONE]['#after_build']
$form['body']['#after_build']
$form['#after_build']

(the last one displays white space instead of the whole form)

Unless there is another much simpler solution to this problem, I'd like to use the above approach or something similar in a module, but it's not working!! So what's wrong with it?


texts: Track step by step performance / execution time

texts:
Drupal 6 site is slow.

Want to track performance / page execution time.
- check each step, PHP code, execution time
- check JavaScript execution time
- check CSS execution time

Krumo prints out the function stack, each step/function from bootstrap to the page up.
Could Krumo give information about the execution time of each step?

There are also other tools, such as the following listing:

drupa.org project performance
Performance Logging and Monitoring

drupal.org project xhprof
XHProf

drupal.org project profiling
Profiling

What are the tools / methods to track the step by step performance (execution time)?


texts: What are the URL Alias pattern replacements for taxonomy parent terms when building up Node paths?

texts:
SCENARIO:

I created taxonomy terms with 3 depth levels. Example:

Term 1 ( Root )
   Term 2 ( Child of Root )
      Term 3 ( Child of Term 2 )

In the URL Alias for my vocabulary I set:

[term:parent:parent]/[term:parent]/[term:name]

That successfully creates a path that looks like this:

"http://mydomain.com/term-1" for the root term
"http://mydomain.com/term-1/term-2" for the root's child term
"http://mydomain.com/term-1/term-2/term-3" for the child's child term

In my Content Type, I created a Term Reference field that forces the user to select the deepest term ( 3rd term down ) with the help of Simple hierarchical select module.

ISSUE:

When creating nodes, I would like to set the node's URL Alias to term-1/term-2/term-3/node-tile. I am having trouble finding the Replacement Pattern for doing just that.

Does path auto allow me to do that out of the box? If so, what pattern should I use?


texts: I'm using Webform. How can I use JavaScript in it?

texts: I am using webform. I'm going to create to fields. First one should be taxonomy term name, and second one should be taxonomy term values. In this case I'm trying to use javascript. When you choose a category in first field, it should be seen categories acording first one. For example: when you choose "animals" category in first field, it should be seen "bear", "lion", "sparrow" and other categories in second. When you choose "fruits" category in first field it should be seen "apple", "bananas", "ananas" and other categories in second. How to solve this problem?


texts: How do I limit the maximum height of an image in signatures?

texts: Is there a way to automatically set the maximum allowed height of images in the Signatures for Forums module for Drupal 6? This will greatly help to have a tidy forum.


texts: Customize theming for field collection in node add form

texts:
I have a field type Field Collection in a content type (I set it to have multi value). In field collection including some fields and I want to show the fields in the field collection in table format in the node add form. Here I want it drupal_render in the table structure that i want. Do not ask me to use field collection table module because it does not meet it.

Looking forward for the help from everyone.

Thank you very much.


texts: After node creation how do i add simple buttons to edit the field values

texts:
``I'm new to drupal,I'm trying a create a content type with some field values which the user can use to create the content for the content type.In the node_view i have added some markup html to create additional generated fields to the content type.Now i want to add few buttons for the user to change the values in my content.

I created a form in node_view hook with a submit button so when user clicks the button i get to modify the node's properties,but i dont understand how to pass the node_id to callback form handler.

Or In general what's the standard process to let users create content for content type with server generating the additional info for the content.

function mymod_node_view($node, $view_mode, $langcode) {
if ($node->type == 'app')

$node->content['apikey'] = array(
        '#markup' => "Client Key
 ".$key['client_key'] ."
 Client Secret
".$key['client_secret']."
 Node id". $node->nid.",",
        '#weight' => 10
    );

    $form = drupal_get_form('redirect_button_form');
    $node->content['redirect_button'] = $form;

function redirect_button_form($form, &$form_submit) {
    $form['submit'] = array(
        '#type' => 'button',
        '#value' => t('Reset Key'),
       // '#callback' => 'my_special_btn_function',
    );

  $form['nid'] = array(
    '#value' => arg(1),
    '#type' => 'hidden'
);
}

function redirect_button_form_submit($form, &$form_state) {

$nid=$form_state['input']['nid'];

drupal_set_message('The form has been created nodeid,'. $node->nid .',key reset');


texts: Is there a way to hook rebuild permissions?

texts:
I'm working on a module that works with nodeaccess_userreference, I have to add some actions to the rebuild permissions function of the core.
Is it possibile?


texts: how to update cart without refresh page in drupal 7?

texts:
I am using Ubercart module for products in Drupal 7. When I click on 'add to cart' button my cart is not updating. After page refresh cart showing product means update. I am using this code :

<?php
$number_of_items = count(uc_cart_get_contents());
if ($number_of_items == 0) { ?>
  Your cart is empty.
<? } else if ($number_of_items == 1) { ?>
  <? echo $number_of_items; ?> item in cart.
<? } else {?>
  <? echo $number_of_items; ?> items in cart.
<? } ?>


texts: Reading a file uploade in my module without saving it

texts:
I'm creating an module and there I want to read a text file.

I don't want to save the file.

In my my_module.module file I have

function my_module_upload_form($form, &$form_state) {
    $form['upload'] = array(
        '#type' => 'file',
    );

    $form['submit_button'] = array(
        '#type' => 'submit',
        '#value' => t('Upload'),
    );

    return $form;
}
function my_module_upload_form_submit($form, &$form_state) {
    $file = file_load($form_state['values']['upload']);
    $url = file_create_url($file->uri);
}

I get the error "Trying to get property of non-object" at

$url = file_create_url($file->uri);

Can someone point me how to read the file correctly (without saving it)?


texts: Remove default tab from login page ( Simple Fb Connect)

texts: I am using Simple FB Connect module for Facebook login in my site. It adds a tab for facebook login, by default in my Login page. I want this tab to be removed and add a button instead. How can I remove this?


texts: Error when updating Bootstrap 7.30 to 7.35

texts:
Im getting the following error when visting the root of my Drupal 7 project after updating the sites bootstrap theme from 7.30 to 7.35.

Notice: Undefined index: element in bootstrap_menu_link() (line 22 of /Users/Chris/Sites/iss-mw/sites/all/themes/bootstrap/templates/menu/menu-link.func.php).
Recoverable fatal error: Argument 3 passed to l() must be of the type array, null given, called in /Users/Chris/Sites/iss-mw/sites/all/themes/bootstrap/templates/menu/menu-link.func.php on line 52 and defined in l() (line 2481 of /Users/Chris/Sites/iss-mw/includes/common.inc).

Seems to be some issue with the menu-link.func. Anyone know what this could be?

Cheers!


texts:
I cant seem to find any solid info on how to do this in the Webform module, is there a function or a module that goes with webforms to do this?

Thanks


texts: I'm using Drupal's Image module to generate a basic image gallery, it works fine for my client's needs but for some reason, it assigns a height value to each <li> in the image gallery as an inline style. It is not clear to me how it is coming up with this value, or how I can alter this. Any help would be appreciated.