texts:
Used omega theme and stumped at menu part.

Top right - Home
Top Left - Work
Bottom Left - Contact
Bottom Right - FAQ

Tried to set 2 menus: top and bottom in menu zone and then set id to each links so they can be positioned accordingly but it didn't work as expected. These menus sit next to the main menu in column 1, 3, 8

How do I put the menu links in menu block then set them at the corners of the screen?


texts: Simple AJAX callback fired on form submission button click

texts:
I am trying to fire an AJAX callback when the user presses the submit button. This is such a simple thing but trying to debug Drupal's Form AJAX API is driving me crazy. At this point I just need a fresh set of eyes to look over it. Currently, when I press the button the page just refreshes and the AJAX callback is never fired. I have a form being built with the following code:

class OnlineRevenueForm extends FormBase {
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['resetbutton'] = array(
        '#type' => 'submit',
        '#value' => $this->t('Submit'),
        '#prefix' => '
',
        '#suffix' => '
',
        '#ajax' => array(
            'callback' => 'Drupal\revenue_projection_model\Controller\RPMController::ResetFields',
            'event' => 'click',
            'progress' => array(
                'type' => 'throbber',
                'message' => NULL,
            ),
        )
    );
    return $form;
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    $form_state->setRebuild(FALSE);
  }
}

Inside of my controller I load this form using the following code:

class RPMController extends ControllerBase implements ContainerInjectionInterface {
 public function rpm() {
    // Load the module's template file
    $TemplateFilePath = drupal_get_path('module', 'revenue_projection_model') . "/templates/revenue_projection_model.html.twig";
    $template = $this->twig->loadTemplate($TemplateFilePath);
    //Load Forms
    $OnlineRevForm = \Drupal::formBuilder()->getForm('Drupal\revenue_projection_model\Form\OnlineRevenueForm');
        $markup = [
         '#type' => 'inline_template',
         '#template' => $template->render(
            ['online_rev_form' => $OnlineRevForm]
         )
        ];
   return $markup;
 }

This form is then displayed via the twig template file. The callback that I'm trying to call is also inside of the Controller:

public static function ResetFields(array &$form, FormStateInterface $form_state) {
     $ajax_response = new AjaxResponse();
     $ajax_response -> addCommand(new AlertCommand("Testing"));
     return $ajax_response;
}

Update 1:
I have updated how the form is being return in the controller. It is now being returned as a unrendered form in a render array.

public function rpm() {
  $OnlineRevForm = \Drupal::formBuilder()->getForm('Drupal\revenue_projection_model\Form\OnlineRevenueForm');
  return [
        '#theme' => 'rpm_page',
        '#online_rev_form' => $OnlineRevForm
  ];
}

I have also added this code to the .module file:

function revenue_projection_model_theme() {
  $theme['rpm_page'] = [
    'variables' => ['online_rev_form' => NULL],
    'template' => 'revenue_projection_model',
  ];

  return $theme;
}


texts: How to manage and delete orphaned node references?

texts:
I have a product node type and a review node type. The review node type has a node reference field that points to product. I can make one product and many users can add through using the node reference URL widget several reviews. I've been deleting the products while the reviews have been sitting orphaned in the database. This hasn't been a problem till I installed the Search API module. Perhaps the error being caused by the Entity module is a bug but those pesky node references have no business existing if the product has been erased or at least they shouldn't be published.

I can think of many solutions to this including never letting a product be deleted so that all content stays in the database till the end of time.

However, I would like to just delete all the reviews when a product is deleted. How do I do this.


texts: How to populate search form with search term in View / Panels / Page?

texts:
I've using Views and Page Manager to create a custom search results page. You can see it here:

http://quotefail.com/search/node/world

The page is being generated by Page Manager. I've got a Search Form in the top panel, but it starts empty. I'd like it to be pre-filled with the search term that was used to generate this page.

How can I prepopulate the search form with that search term?

Here is my page config:

Here is my Search View in the center panel:


texts: Page title getting hide when there is no data available in view

texts:
I have created a view for content and added no result behavior. But if there is no data available in view so title showing nothing(Page title block ). But I wanted to show title in all condition. For better understating please check attached images.

But when I was trying to override title in contextual filter Content:Document type so as per replacement pattern I am only getting Title's ID that is I think correct way to do but how can i achieve it's name instead of ID. Please check attached images.


texts: Best method to enable/disable modules depending on the environment

texts:
What would be the best solution to enable/disable modules depending on the site environment (dev, stage or production)?

Created a database dump containing the system table for each installation. Then when deploying I use mysql -uuser -ppass database < dump-<type>.sql where the type reflects the kind of environment.
Created a shell script for each environment, that uses drush to enable or disable needed modules and set specific site settings.
Wrote a small deploy script for each site that looks something like this:

// change working directory to drupal installation path
chdir('public_html');

// define root, include bootstrap.inc and start drupal
define('DRUPAL_ROOT', getcwd());
require_once(DRUPAL_ROOT . '/includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

// modules that should be disabled/enabled on stage site
$modules = array(
   'field_ui' => 1,
   'toolbar' => 1,
   'update' => 1,
   'overlay' => 0,
   'feeds_import' => 0,
   'feeds_ui' => 0,
   'feeds' => 0,
   'menu' => 1,
   'advanced_help' => 1,
   'job_scheduler' => 1,
   'wysiwyg' => 1,
   'views_ui' => 1,
   'dblog' => 1,
);

// enable/disable modules and set site specific variables
foreach ($modules as $module => $state):
  if ($state == 1):
    if (!module_exists($module)):
      module_enable(array($module), FALSE);
    endif;
  else:
    if (module_exists($module)):
      module_disable(array($module), FALSE);
    endif;
  endif;
endforeach;

variable_set('error_level', ERROR_REPORTING_DISPLAY_ALL);
variable_set('preprocess_css', 0);
variable_set('preprocess_js', 0);
variable_set('cache', 1);
variable_set('page_compression', 0);
variable_set('block_cache', 0);

Does anyone have a better solution?


texts: How to translate the URL alias (path) for an English version to an Arabic version?

texts:
I have a dual language site (English and Arabic). In the English version I added a URL alias: projects/commercial.

But I can't find a way to have that translated to the Arabic version. I need that because the path is used by a breadcrumb module.

Any suggestions?

Edit: I am using pathauto, but my problem is that the URL is for a view that lists certain projects based on contextual filters. So I added the alias projects/commercial instead of projects/7 the breadcrumb works fine in English but not in Arabic


texts:
Can anyone please guide me on how do I create a photobox that contains image and I wanted to display that image on landing page.

I have created content type as an Image. But, I don't know how to display that image in landing page.

I am new to Drupal. Any help will be appreciated.

Thanks!


texts: Why is my file upload widget returning an empty string?

texts:
I have built a form with the form API which contains this file upload widget:

$form['fid'] = array(
  '#type' => 'file',
  '#title' => t('Upload a file')
);

When I use it to select a file on my computer (a small .txt file) and click on Submit, the following validation function is executed:

function myForm_validate($form, &$form_state) {
  error_log("Empty string? : " . ($form_state['values']['fid'] === ""));
}

And it prints Empty string? : 1 in the error log. What am I doing wrong here? Why am I getting an empty string instead of a file path?


texts: Views-overriden taxonomy/term page returns not found

texts:
I am trying to override the default taxonomy/term/xxx page with a page created by views.

My view: I have followed the usual instructions with using url taxonomy/term/%, gave it a contextual filter that is validated to a term name. In the preview results box of this view, I can use a term as an argument, and get the results correctly.

But when use the url in the real site, I get a 404. Regardless what the url alias pattern is for the default taxonomy term pages, when this view is enabled no term will return a page.

Turning my view off->term page urls work
Turning my view on ->term pages stop working.

I have no other view with the same URL enabled.


texts: Updating comment date using services module

texts:
I am trying to update comment date using services Drupal module. I can see that every comment contains following two dates, but I can't update them using command below.

1451929300
1451929703

curl -H "Content-Type: application/json" -H "X-CSRF-Token: khujfk" -H "Cookie: fzuk-uzfk" -X PUT -d '{"nid":"10","created":"1451929400"}' http://url/rest/comment/355

I would expect that the creation date would be changed to 1451929400 after running above command, but nothing changes. Anyone knows what am I doing wrong?


texts: How do I theme the "The website encountered an unexpected error" page?

texts: How do I set the theme to use for the error page showing an unhandled exception like the one shown in this screenshot?


texts:
I have created my first webform in drupal 8. However, I found that some of the fields such as "Telephone", "Email" are showing the field name and the textfield on the same line. However, for the text field such as "Name" and "Subject" (Also a textfield), the field name and textfield are showing on different line.

I haven't done any setting on those 4 fields. I would like to ask if I could do some settings such that the textfield is always under the field name?

Thank you for your help.


texts: Is it possible to remove Route objects from a RouteCollection object?

texts:
When I look at the code used for the method handling a RoutingEvents::DYNAMIC event, which receives a RouteBuildEvent object, I notice the code is always similar to the following one.

$collection = $event->getRouteCollection();
$route = new Route("$path/display", array('_form' => '\Drupal\field_ui\DisplayOverview') + $defaults, array('_permission' => 'administer ' . $entity_type . ' display'));
$collection->add("field_ui.display_overview.$entity_type", $route);

Since the RouteCollection class defines the RouteCollection::remove() method, would not removing routes from the collection be possible? I was thinking of removing a route to redefine it.


texts: how to include searched term in results when using exposed filter

texts:
I have created simple view that can filter children terms of parent that is typed into exposed filter. Using taxonomy term:parent term relationship.

Question: Is there any way to include searched term inside results as well?


texts:
I've been using my 4 year old Mac Book Pro for a development environment for the past few years, and with memory (8 GB) and hard drive upgrades, speed was pretty decent.  I just got a new iMac with a 3.4 GHz quad core processor and 16 GB RAM, and navigating between admin pages is slower than an arthritic snail.  It literally takes up to 1 minute to just change pages in the admin section.  The same pages with the exact same codebase and db change on my MBP is a matter of seconds.  I'm using the same stack setup on both (Mac's Apache, MySQL and PHP via Homebrew).
I have both XHProf and Webgrind set up, but both are disabled (in Devel settings for XHProf and xdebug.ini for Webgrind), so I know that's not what's causing the problem.

To troubleshoot, I turned on the query log in Devel, and it looks like at least one problem is the cache_set function.  There are multiple calls to it, and every time it takes way more time than any of the other functions.  Also, in looking at webgrind, the top function I'm seeing called is php:sleep, which is being called from the lock_wait() function.  According to the comments in the function, sleep should only be called when a request failed to get a db lock.

So, with that info, it appears that I need to tweak my db settings.  Can anyone give me some suggestions on what to change?  I'm a noob to db tuning like this, so this is unfamiliar ground for me.  I'm still searching myself, but any tips would be welcomed.

As a side note, my PHP memory_limit is set to 256MB, so I don't think that's a problem.

Thanks.


texts: Drupal 7: notify user module recommendation

texts:
I'm trying to figure out what the best solution to a project requirement is. The basic premise is that a site needs to have a notify user feature - similar to how Facebook works.

A listing in the site will appear showing the number of notifications (similar to this site actually, on the top left).  A sample notification would be: another user commented on your node.

Another possible notification would be "a node was created in a subscribed taxonomy term".

I've been looking at the Notifications  module,  but I'm not convinced it can do what I need it to do.

Has anyone ever built a solution to this problem?  Or am I looking at a lot of custom work?


texts: How to update all hyperlinks which are in the content

texts:
Hello I am using book_copy module for creating a new version of the book so i have copied a book which is having more than 1000 pages with the book copy module.
Now the new book copy has all working links but for the new book i needed the new urls.
like for previous book it was content/2012 now i needed content/2013 which i have done with pathauto but problem is that while copying a book it takes url for pages as content/2013 but in the page there are hyperlinks which are not updated and pointing to old book pages.
 So let me know if any module for fixing this issue o/w i need to go on each link and update it which is really a difficult task.


texts: Can Rules be used to disable the logo variable on some pages?

texts:
I have a change in Drupal 6 that I would like to make quickly without doing another SVN roll (until I get a more permanent solution in place) and I would like to create a triggered rule that will null the $logo variable that is being sent to the theme before it gets there.

I know how to tell it to identify the page in question and control it based on role. However, I am having trouble figuring out what PHP code to use in the custom PHP code section. Partly because I just don't know what variables are available nor at what point in the code flow I am sitting in (which is important for this).

Does anyone have any ideas or suggestions?


texts:
How can I disable a region at with the context module at all pages but the  (home page).

I've been trying to disable a region on all pages, except the , without having to write all the paths.
I can't make the wildcards * ~ work on the <front> page.

In the condition field, I've tried to put alot of different combos i cant show here, because my post is deemed spam:

Imagine me using * ~ wildcards in front and in back of all the ways you can write the front page path: eks.  http//www.domain.com/
same goes for <front> with all the different combos.

Which one is supposed to work? Hope you get the idea.

Thanks!
Best Regards Elias


texts: Commerce - adding a class to the body element when there is an item in the cart

texts:
Is there a way to add a class to the body element if there are one or more items in a shopping cart?

I'm using Drupal 7.38 and Commerce 7.1. I have to admit that I haven't tried anything to achieve my goal, apart from searching the interwebs - I have no idea how to add a class when a certain event happens.


texts: Limit views exposed filter options to terms with associated nodes of content type X

texts:
I have a module which limits the options in a views exposed filter to terms which have associated nodes. The code is based on this answer: How can I limit the exposed filters to only display values for which content exists?
Code:
if (isset($form['area-of-law']['#options'])) {

  foreach ($form['area-of-law']['#options'] as $key => $value) {

    if (is_numeric($key)) {
      $query = \Drupal::database()->select('taxonomy_index', 'ti');
      $query->fields('ti', ['nid']);
      $query->condition('ti.tid', $key);
      $nodes = $query->execute()->fetchAssoc();

      if (!$nodes) {
        unset($form['area-of-law']['#options'][$key]);
      }
    }
  }
}

This works, but all node types are returned. I would like to limit the filter further to only show those of content type X.


texts:
I cannot get my imagecache custom actions to work at all?

When returning $image in any way, it gives me an error, which can be resolved by adding in the first line here:

if (!$image_context['entity']) { return 'No referring entity'; }
$image->ops[0] = "-resize 1600x1600";
return $image;

That should simply just resize my images now?

Essentially, my end goal is to check the value of a field submitted with the node which also submitted the original image, and then based on its value, apply a watermark. I am just toying about with custom PHP right now... but I can't seem to get any custom actions to work right now... Any help would be great, thanks! :D


texts:
I would like to know if anyone is experienced with ubercart with panels.
I am making a website with these two modules, the ubercart is for the online store, the panels is for the layout. And the site headers and footers are within the mini panels of the panels module.

I would like to make the mini panels also appear on the ubercart checkout, cart pages but i dont know if it is possible, since the checkout , cart pages are generated by the ubercart modules and they are not nodes, views, and seems it is not possible to assign them info mini panels in panel module.

Is there any way to make a page generated by module appear as mini panels, and so that i can create a new page by using the mini panels. Thanks!


texts: Very slow menu_tree_check_access query - how to debug

texts:
I have a Drupal System which is running fine in production and locally but the dev/cons Db seems to have a problem.
After looking a bit deeper into it I found that menu_tree_check_access takes 3.8 Sec to finish!

First I thougt there must be something wrong with the DB-Server but everything is fine there.

After I started a node permissions rebuild everything was suddenly quick again. But after the node permissions rebuild finished it was slow again.
So I guess there has been added some strange test content that creates some kind of infinite loop or something else.

Any ideas how to debug this? How can I run the slow query against another fresh DB from Prod e.g. with devel I only see the query with placeholders.


texts: How can I refresh a view block as soon as new content is added?

texts:
I want to refresh a views block whenever new content is added.
I am using views auto refresh module

  Quick HOWTO: Using a ping script

  Using a ping script is essential for production environments, to avoid
  a full Drupal bootstrap at each refresh.

  Create a new page view Copy the file ping.php.example to your Drupal
  root folder and rename it as ping.php Edit ping.php such that
  DRUPAL_ROOT points to your Drupal root, and adjust the query: $result
  = $db->query("SELECT count(nid) FROM node WHERE created > $timestamp");

  to reflect your view's generated SQL query. Make sure to keep the
  created condition in the query. Add a new header of type Global:
  Autorefresh with: Set the interval time to 5000ms Check Use a ping url
  In Path to the ping script, enter ping.php Save the view and open its
  page In a second browser tab, add a new content that fits the view's
  criteria See the new content in the view!

Is there any other way we can refresh a views when content is created


texts: How do I give the following responsive information in the .info file?

texts:
I have the below lines in the info file for a Drupal 7 theme.

stylesheets[all and (min-width: 980px)][] = css/960.css
stylesheets[all and (min-width: 760px) and (max-width: 980px)][] = css/720.css
stylesheets[all and (max-width: 760px)][] = css/mobile.css
stylesheets[all][] = style.css
stylesheets[all][] = color/colors.css

How do I map these in Drupal 8?


texts: Making one term in a vocabulary priority and print it separately

texts:
I have several terms in a vocabulary and my content type can be tagged with more than one of them.

When I print the term names tagged with the currently viewed node it seems that the term names are printed always in the same order (in the order of term id?)

However I somehow need to make one priority term per node and then print its term name first or separately from the rest.

Is there anyway to do this?


texts: How do I style a node page for a specific content type?

texts:
I have a content-type "foo". As you know, you can look at such a node by using it's nid and going to /node/nid. I'd like to create 100% custom markup and CSS for this page.

I want code and files and only code and files. So, what I'd expect is a MVC architecture, meaning, that there's a template file to which all the node related data is passed and I can easily change the markup. But since Drupal isn't MVC at all, it somehow gets very complex and I absolutely don't get the architecture here. I'm not sure  can use one template only; if so what's the naming pattern?

Can someone tell me the cleanest and easiest way to create the HTML for the node page?


texts: How to create a custom content-type with template for an "empty" page

texts:
I want to display a Unity webplayer in a modal/overlay. I figured out a way to show a drupal page with the webplayer in the overlay, so I'm almost there. But that page then displays everything, including menus etc. The Context module allows me to strip most of it, but not everything. So it seems having an empty page to start with will be easiest.

What would be the best way to create a Drupal page that only shows the content and is otherwise empty? I have already created a custom content-type for the webplayer, so maybe there is a way to associate that with a custom template file that only prints the content? I'm also writing a module for this, so the solution can require changes that need to be implemented in code.

I'm not very familiar with theming, so I'm also interested what template file needs to be created or changed (page.tpl.php, node.tpl.php or something else altogether).


texts: Programmatically add a taxonomy term as entity reference in a custom entity

texts:
I'm really struggling to add a taxonomy_term as an entity reference to a custom entity I've created programmatically.

Here is my configuration based on BaseFieldDefinition (the name of the vocabulary is "specialite":

$fields['speciality_field'] = BaseFieldDefinition::create('entity_reference')
  ->setLabel(t('speciality'))
  ->setRevisionable(TRUE)
  ->setSetting('target_type', 'taxonomy_term')
  >setSetting('handler_settings', ['target_bundles' => ['specialite' => 'specialite']])
  ->setSetting('handler', 'default')
  ->setTranslatable(TRUE)
  ->setDisplayOptions('view', array(
    'label' => 'hidden',
    'type' => 'author',
    'weight' => 0,
  ))
  ->setDisplayOptions('form', array(
    'type' => 'entity_reference_autocomplete',
    'weight' => 5,
    'settings' => array(
      'match_operator' => 'CONTAINS',
      'size' => '10',
      'autocomplete_type' => 'tags',
      'placeholder' => '',
    ),
  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

This piece of code doesn't work, would you please help to find what I am missing, or redirect me to a good documentation explaining different values for handler_settings

Thank you so much.


texts: Drupal 7/Zen - How do you move the header (field_image) image above the title on a page?

texts:
How do you move the header (field_image) image above the title on a page?

Drupal 7/Zen Theme

This seems like it would be a simple thing to do. I've been messing around with trying to accomplish this by doing a few things suggested on other websites but cannot seem to get it to work.

I've tried editing the page.tpl.php file but that messes up my homepage.

I'm trying to do this without using panels or any other module.

Thanks!


texts:
I have to make a new install for Drupal 7 and i need to request the database space on Oracle DB to the DB guy, who wants to know exactly which permissions should have the drupal account that will handle the database.

I have read a lot do documentation, and everywhere is just said that the account for the database should have full privileges. I have told this to the DB guy and he refused that statement, arguing for example that Drupal will not need the "drop database" privilege, as an example.

So my question is: where can I find the exact minimum list of database privileges that Drupal needs to work properly?


texts: Inserting submenu to main menu using jquery - good idea?

texts:
I have main menu showing only first level links (3 items).

**Home**
**Themes**
-green
-blue
-red
**Jokes**
-long
-short
-medium

I am using Menu block module (to show second level items) + Power menu (to make menu items active if current node has certain term).
So when a node with taxonomy "theme" is displayed, the items under "themes" shows up in block menu.

What I would like to do is to somehow inject the block menu items inside primary menu. The main reason is to be able to use responsive menu, that immediately shows user menu options based on node term. (It is more of a usability idea for mobile users - not having to click through full menu).

Question: Do you think it is a good idea to inject such menu using jquery? Or is there a better drupal way of doing this? Thank you


texts: Images not appearing into sites/default/files

texts:
I designed and set up a site for a client at Gregory Lamberson.com, and for some reason when he tries to create new content, the images are not uploading to the correct directory. The old images that I put on the site are showing up fine at /sites/default/files, but when he tries to add a new image, it writes the image into /?q=sites/default/files, and that directory doesn't exist, so the images are not showing up into the site.

Clean URLs are not enabled, so I was thinking that if I do enable them it might solve the problem. However, I am just starting out in front-end development and I could use a second (professional) opinion.

The nodes in question are in Storm Demon & AfterLife Project.

Thanks!


texts: Modifying views exposed filter query string

texts:
I'm looking for a way to modify views' resulting query string (URL) after applying a filter, but have been unsuccessful so far.

I have a view with exposed filters, taxonomy lists to be specific. Hitting apply generates something like:  www.mysite.com/myview?foo=123
My goal is to have it instead generate:  www.mysite.com/myview?foo=bar

I know views' exposed filters depends on tid for the filter to work when visiting a page (e.g. pasting a link and visiting the page), and I have some hook_views_pre_buildcode to handle that. My issue is going the other direction. What hook, function, or other approach can I use to modify that?

For reference I've tried replacing view object contents in hook_views_pre_build, hook_views_post_build, hook_views_pre_execute, hook_views_post_execute, and hook_views_query_alter, but nothing seems to have the desired effect. I do not want contextual filters due to the need for order independence.


texts: User registration times out/doesn't exit on live centos+nginx server

texts:
I have a bit of an edge case, but it's confusing me very much. I noticed that my services user/register.json POST calls would just endlessly freeze on my production server, but not on my local, however it would actually successfully create the user. Also, it would happily exit with a services_error() callback if the user couldn't be created (existing username, for example).

On further investigation, it seems that the user registration form itself on the drupal site does the same thing. No errors come up, nothing in the logs, just an endless timeout on successful save and drupal set message errors on unsuccessful save. Even when I go into the code and insert watchdog messages, they only actually get pushed through on the next successful request. It also only seems to be registration that is affected, and creating a new user from the admin interface is completely fine.

The production server is a CentOS 7 box running nginx with php-fpm, mariadb & memcached, seems to have enough memory, doesn't appear to have any weird low timeout values in the settings, etc.

Can always provide any conf files or anything if that helps, but I was wondering if anyone knew of any known issues where only user registration could be affected. Thanks in advance!


texts:
Actually I created user's request mail form as CCK.This CCK displayed page name as node/add/laptoprepair.I want to display this CCK page as Block for the purpose of calling multiple page.How to create this CCK as block?

In user's  page it is displayed as,


texts: How to code custom entity to access more than one database table?

texts:
I have an entity that uses two tables, when I describe it in hook_entity_info() as far as I know I can only tell it about the base table. The base table is subscriber, I also have a table disease_catagories which stores the results of a select list. (stores the subscriber id, and the taxonomy term id. It can store any number of items with the same subscriber id and different taxonomy term ids)

I need the entity to contain an array of those taxonomy term ids, but I don't know how to connect that database table with the base table. are there any good articles that discuss how to attach a second table to the entity (maybe as field data)?


texts: Replace taxonomy vocubulary administration page with a view

texts:
I would like to replace admin/structure/taxonomy/manage/my_vocabulary/overview with a custom view.
 Some of my vocabularies have custom fields that I would like to display and use as filter for the view.
For admin/people a view exists that can simply be modified.
Is it possible to create such a view also for admin/structure/taxonomy/manage/my_vocabulary/overview ?


texts:
My drush isn't working as expected. I think it's because the database information isn't being read properly. There is no DB info in the status command.

httpdocs]# drush st
 Drupal version         :  7.35
 Site URI               :  http://default
 PHP executable         :  /usr/bin/php
 PHP configuration      :  /etc/php.ini
 PHP OS                 :  Linux
 Drush script           :  /root/.composer/vendor/drush/drush/drush.php
 Drush version          :  7.0.0
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /var/www/vhosts/domain.com/httpdocs
 Site path              :  sites/default

System info:

Centos 6.6

PHP 5.3.3

MySQL 5.1.73


texts: How to auto redirect link with node/id to /name?

texts:
I'm using Pathauto to generates all node url. There are many pages and blocks containing links with "node/id" instead of the "urlpath". When user click one of those link, it actually direct to the "node/id", not "urlpath" generated by Pathauto. How can I fix this?

PS: I dont wanna use "Redirect" and add them one by one


texts: How to group li element via using Drupal.behaviors?

texts:
A newbie question here.

How can I select a range of li so I can moved them inside new element?

For example:

test

test

test

test

test

test

test

test

test

test

test

test

To be like this:

test

test

test

test

test

test

test

test

test

test

test

test

So far I tried using Jquery:

(function ($) {
  Drupal.behaviors.menu = {
    attach: function (context, settings) {

    $('#navigation ul li.expanded').hover(function() {
      $(this).find('ul').css('display', 'block');
    }, function() {
      $(this).find('ul').css('display', 'none');
    });

    var $lists = $('#navigation li.expanded ul.menu');

    // Loop through all target lists.
    $lists.each(function(i, e) {
      var $list = $(e);

      //These are temporary variables.
      var $new_list = $('
');
      var $list_item, $sub_list, $sub_set;

      // The number of items per column.
      var per_column = 6;

      // Calculate the amount of columns needed.
      var n = Math.ceil($list.find('li').length / per_column);

      // Loop through all columns.
      for (var i = 0; i < n; ++i) {
        // Creates the sub list for the current column.
        $sub_list = $('
');

        // Gets the first set of list items from the original list and adds them to the sub list created above.
        $sub_set = $list.find('li').slice(0, per_column).appendTo($sub_list);

        // Creates a new list item and adds the sub list to it.
        $list_item = $('
').append($sub_list);

        // Add the newly created list item to the new list.
        $new_list.append($list_item);

        // Create a div with the class 'columnX' and wrap the sub list with it.
        $sub_list.wrap('

');
      }

      // Replace the original list with the new one.
      $list.html($new_list.html());
    });

  };
})(jQuery);

The above approach generates "

But I'm having difficulty in manipulating elements via Jquery or JS. Any thoughts will be appreciated. Thanks


texts: How to import the node class into a title field of a view?

texts:
I installed the Node Class module. I have a view, where the node class should be imported into the title field of the view.

How can I achieve this?


texts: Is there way to display thumbnail gallery using external links to images?

texts:
Drupal 7, is there way to display thumbnail gallery using external links to images?(instead of uploading pictures)
Something like

https://wordpress.org/plugins/wp-gallery-custom-links/screenshots

I have Views, Imagecache External, Views Responsive Grid modules installed, but no one of them helps me to achieve this simple task. I want create responsive thumbnail gallery with external images.


texts: How do you iterate over and get results for every display in a view with only one call to views_get_view?

texts:
My code is as follows :-

$view = views_get_view('view_name');
$displays = array(
  'display_1',
  'display_2',
  'display_3',
  'display_4',
  'display_5'
);

foreach($displays as $display){
  $view->execute($display);
  $result = $view->result;
  if(count($result) > 0){
    //Do Something
  }
}

Sorry, to elaborate as it is not clear, this code seems to return the same result set no matter what display is excecuted. I have tried a few other methods such as :-

$view->set_display($display);
$view->pre_execute();
$view->execute();
$result = $view->result;

But again always recieving the same results. Looking at the $view->execute() method, it would appear that a check is done to see whether the $view has been built.

if (!empty($this->executed)) {
  return TRUE;
}

I will try to unset($view->executed) and see if this helps :)

Sorry should have included the issue originally Doh ! :)

Edit (6/1/15 - 11:42) :

That doesn't seem to help :( It seems like I need a way to "reset" the view object.

I've given up on trying to implement this in one call and have just re-instantiated $view = views_get_view('view_name') within the foreach loop. This may be the only viable option but if someone could confirm I will edit the question to reflect this.


texts: Menu Block: Expand all children of this tree - ignored?

texts:
Is anybody using Taxonomy Menu + Menu Block? I have a problem setting Expand all children of this tree, in that it seems to be completely ignored. My sidebar taxonomy menu lists all children expanded, regardless of the setting value.

Since I don't see the problem in issue queue for the project, I assume this could be only a local problem. It might be that I am overlooking some other module that could be causing that.

Open for your insights, please.


texts: "contact" SQL table: what is it for and where do I edit it?

texts:
We are running a site with the Hotel Diamond theme. Today we received a bounced email: apparently, someone had tried using the contact form in the site to send us a message, and the system had tried sending it to "test@localhost.com".

Now, the Hotel Diamond theme has an option to configure the email for the contact page, but it is correctly configured (i.e., it's NOT "test@localhost.com"). So I decided to look for that address in the raw SQL dump of my site, and I found this:

INSERT INTO `contact` (`cid`, `category`, `recipients`, `reply`, `weight`, `selected`) VALUES
(1, 'Website feedback', 'test@localhost.com', '', 0, 1);

My question is: where do I edit that in the admin pages? And why is Drupal using this entry to send contact email, instead of the address we had configured in the Hotel Diamond config page?


texts:
I am using Drupal 7, the Ubercart and Rules module; I plan to use the Views Rules) module. I want to use the Rules module to automatically publish nodes that contain data from a Ubercart order.

I'm attempting to automate a few processes on my Drupal 7 site after the completion of an order with Ubercart.  Upon completion of an order, I would like to automatically publish a content type that contains data from the order (price, customer/user, seller, product name, entity reference data, etc).  I can create the rule to publish the content type, but I'm struggling to figure out how to get the data from the order into the content type.

My approach so far has been to tag the order upon completion of an order, then fetch the order data. However, when I drill down into data selectors, the values I need are not available.  Furthermore, I'm not sure I would know how to get it loaded into the content type upon publish.

I've come across Views Rules module which, to my understanding, will allow me to define the values to fetch.  I've created views that I can load into Rules, but it appears that the View will return all results of the view instead of the result I need upon completion of the order (maybe I'm wrong about this?)

I just need a nod in the right direction on how to accomplish this.  I'm just not sure if my approach is right. I have the basics of Rules, and have only constructed very simple rules.  I imagine what I want to accomplish will require a more complex construct of Rules. Any suggestions are greatly appreciated, particularly on how to use Views to accomplish what I need.


texts: How to display an HTML table after the form submission on the same page as the form?

texts:
I am trying to build a form which takes the food item and the no. of servings and calculates the total calories for that particular food and displays it to the user.

User, can add another food by filling out the form again and the calculated calories for the second food is added to the first and the total calories are also displayed. He can add as many food items as he wants and the form shows the total calories of all those food items.

I want to display this information to user in a table. table will have the following columns.. food item, servings, calories and in the last row the total calories of all those food items. I also want to have a another column with a "delete" button to delete that particular food item from the table and refresh the table without that particular food item.

The main problem am facing is, How can I show this table on the same page as that of the form ?

I have been saving all the user submitted info in session variables and I am being able to create and show such table on another page (for example, when user adds many food items and clicks "Done" button, its redirected to another page and the table is shown there.) But I dont want the user to be redirected. I mean if he wants to add another food item to the table, he has to navigate to the form page again and that's not convenient to the user.

To learn how to write forms, I followed this guide, http://drupal.org/node/262422. So my form is in a file, say..myform.module. Now, I have all the data to create an HTML table (Am saving all the food details given by the user in session variables), but how can I make it displayed on the same page as that of the form ?

or in other words, path to my form is, http://localhost/d7/?q=calorie_consume , I also want the table to be showed on the same path or page. How can I do it?

Where should I put the code for creating the table inside myform.module file ?

So how can I achieve this ? Or is there some other approach to creating such calculators that am not aware of ?

Thanks in advance.


texts: database update warning but no updates - google tag module issue?

texts:
I'm on Drupal 8.8.2, and we've got a "database out of date" alert, requiring us to do database updates. When I attempt to do so at update.php, I get a message saying "no pending updates"

I re-ran cron to make sure the messages were up-to-date, and tried again. the message and issue remain.

When I look at logs I get three file permssions-type issues:

The file permissions could not be set on public://google_tag/primary/google_tag.data_layer.js.
The file permissions could not be set on public://google_tag/primary/google_tag.noscript.js.
The file permissions could not be set on public://google_tag/primary/google_tag.script.js.

Within the public folder, I checked the folder permissions.
google_tag folder and it's subfolder, 'primary', are both 775 (drwxrwxr-x)
The three error-triggering files inside 'primary' are 664 (-rw-rw-r--)

Do these permissions need to change?
Is there another issue? Maybe something within the Google Tags module, itself?


texts: How do I add field collection unlimited items from hook_form_alter()?

texts:
I am trying to implement what described in Add unlimited field collections in a from of drupal and Field collection with unlimited cardinality pre-populate fields, but the Add more and Remove buttons don't work. I have issues with drupal_rebuild_form().

The code in hook_form_alter() is the following.

$items_count = 3;
$field_name = 'field_story_technology';
$form_theme = $form[$field_name][LANGUAGE_NONE]['#theme'];
// Remove delete and add more buttons
//~ $form_state['field'][$field_name][LANGUAGE_NONE]['items_count'] = $items_count;
$items = &$form_state['field'][$field_name][LANGUAGE_NONE];
$form[$field_name]['und'][0]['remove_button']['#access'] = TRUE;
$form[$field_name]['und']['add_more']['#access'] = TRUE;
// Generate required number of fields collection
if ($items_count > 1 and $items['items_count'] != $items_count) {
  $items['items_count'] = $items_count;
  $items['field']['cardinality'] = FIELD_CARDINALITY_UNLIMITED;//$items_count;
  $form[$field_name][LANGUAGE_NONE] = field_multiple_value_form($items['field'], $items['instance'], LANGUAGE_NONE, array(), $form, $form_state);
  // Reset theme function, as field_multiple_value_form hijacks it
  $form[$field_name][LANGUAGE_NONE]['#theme'] = $form_theme;
  $rebuild_p = TRUE;
  //~ $form_state['rebuild'] = TRUE;
}
// Fill generated fields with data
for ($delta = 0; $delta < ($items_count-1); $delta++) {
  $form['field_story_technology'][LANGUAGE_NONE][$delta]['field_technology_photo_title'][LANGUAGE_NONE][0]['value']['#default_value'] = 'new value';
}
if ($rebuild_p) {
  $form['#after_build'][] = 'tttttt';
}

function tttttt($form, &$form_state) {
  return drupal_rebuild_form($form_state['build_info']['form_id'], $form_state, $form);
}

drupal_rebuild_form() will change my other functionality.


texts: How many libraries is too much before there is a performance issue?

texts:
We are using Paragraphs module to allow for selecting of up to 15 different Paragraph Types. As part of this, each one requires its own CSS and JS since they are vastly different. We already have a common set of CSS and JS that can be shared (25% overall), but there is a large percentage (75%) that is unique to each Paragraph Type.

We were able to combine lots of the CSS and JS, which resulted in the creation of 10 libraries and 1 general library to help with the management of these types. We are concerned that if we add more Paragraph Types the number of libraries could increase to anywhere between 20-30 as newer Paragraph Types are needed.

How many libraries is too much for a custom subtheme before it cause a performance issue (if any)?

Since there is no extra preprocessing needed per Paragraph Type, we simply add them using the {{ attach_library('mytheme/name') }} in twig templates. The only hook that is used is the one to add the general library.

mytheme is a subtheme and is set as default and enabled

Examples:

paragraph--carousel.html.twig

{# this is the paragraph type specific library #}
{{ attach_library('mytheme/carousel') }}

 {{ content.field_title }}

 {{ content.field_sub_title }}

 {{ content.field_description }}

 {{ content.field_image }}

paragraph--jump-menu.html.twig

{# this is the paragraph type specific library #}
{{ attach_library('mytheme/jump-menu') }}

 {{ content.field_title }}

mytheme.module

function mytheme_preprocess_paragraph(&$variables) {
  // Add general library for paragraphs.
  $variables['#attached']['library'][] = 'mytheme/global';
}


texts: How to manage placement of blog articles in omega regions

texts: I want to be able to control which omega region blog entries (individual blog articles) are placed. They appear to be in the content-zone, but I have not seen how to control which actual region they are contained within.


texts:
I'm screwing around with jQuery for the first time, and I'm unsure of where to add a call in Drupal to allow it to alter classes of elements within the body tag.

I'm looking at utilizing something like the following:

$('header').toggleClass('Scrolling', $(document).scrollTop() > 0);

Without any custom modules at this point, the only robust method I have available seems to be using my custom theme. I've included a script in my custom theme's .info file:

scripts[] = scripts/mine.js

Within that file I've added a test script:

(function($) {
  var e = document.getElementsByTagName("body");
  alert(e.length);
  for (var i = 0; i < e.length; i++) {
    alert(e[i]);
  }
})(jQuery);

The result is an empty array. When I change "body" to "html", "head" or "script", I get an array populated with HTML objects. This leads me to believe that because the script is included in the header of the HTML page, it doesn't have access to body elements, as they haven't been loaded yet.

What am I missing that would allow this type of script to interact with body elements, and therein let me add a class to an element via my first line of code?


texts: Is there any File Manager Module for drupal 7

texts: I need a module as like as File manager. We need to view, edit, modify and delete the files and also with permission option.


texts: Change order status string from "Completed" to "Shipped"

texts:
I'd like to change the order status string from "Completed" to "Shipped" to allow for better communication between us and the customer.

Commerce Custom Order Status would sidestep this problem by allowing me to create a new status, but that isn't the best way around it, because there might be triggers set for "completed".


texts: Google analytics module vs direct code insertion in tpl file

texts: Shall I install google analytics module or just put GA code in page.tpl file as there are too many modules and I dont want to add one more module. what do you suggest?


texts: Facet API and views contextual filters (facets block on non-search page)

texts:
I'm using Facets API with SOLR and it all works fine.

I also have a standard view set up using a facets block from the search-index view. This also works OK, but it shows the complete unfiltered facet list.

What I'd like to do is apply a contextual filter from the path to the facet block, but it doesn't seem to work - I get nothing.

I'm wondering whether this is possible and if so how (and if anyone even understands what I'm asking?!)

Thanks,
Chris


texts: How to reset a form element to its ordinary default value?

texts:
I do a form alter on a node form and make some callbacks which restrict value lists in a < select > element, which is a entity reference. When the triggering element is changed, I want to load the node forms default value just like it is in the beginning of the form process.
I remember there was an api function to do that. Someone nows it?


texts: Can't get the author's picture printed onto a node in Drupal 7

texts:
After reading the documentation, it seems that the correct way of doing that is like this:

php print $user_picture;

It won't work (it doesn't print anything at all).

Afetr asking around, I get this answer, which sadly won't work either:

global $user;
$image = theme('user_picture', $user);
print $image

That code was suggested as a "last resource", but when I try to use it, I get this error message:

  Fatal error: Cannot use object of type stdClass as array in /includes/theme.inc on line 1054

Line 1054 is the following one:

  // Line 1054
  if (isset($variables['#theme']) || isset($variables['#theme_wrappers'])) {
  //
    $element = $variables;
    $variables = array();
    if (isset($info['variables'])) {
      foreach (array_keys($info['variables']) as $name) {
        if (isset($element["#$name"])) {
          $variables[$name] = $element["#$name"];
        }
      }
    }

It´s pretty clear that it should work, but it doesn't.

Using contemplate module, I get this output as an alternative, but it doesn't work either.

<?php print $node->picture ?>

I've tried then with Devel module (using the /devel tab of the node):

I get this:

picture (String, 4 characters ) 2876
$...->picture

Wich won't work, because the output is just "2876", but is the only "picture" there.

So what can I do? How can I trace this problem?


texts: Simple newsletter send only This is a test version of the newsletter

texts:
I am using Newsletter module to send newsletter to all my registered users. I have created two lists

Blog

Project (Have created templates for them as well).

My questions are;
The test mail just sends the [node: title] like tokens. What should I add to mail the contents of the node?
Thanks


texts: Webform - Replace Form title with Node title

texts:
I'm working on a Job Portal where-in i created a content-type for job listing and a Job Application Webform. I need to provide a link on the job node which will be linked to the webform and upon submission,the title of job listing node will be sent as the webform title(Editable or uneditable). And in the Webform listing, the form should have the title as that of the Job node from which it is applied.

I like to know, what are the ways with which this can be achieved


texts: Is there a possible/safe way to do a sub-request

texts:
In Drupal 8 the Symfony HttpKernel Component offers a nice way to make an internal sub-request (forward a request to another page without changing the URL). I'm wondering if there is an ad hoc way to mimic some parts of this idea with existing Drupal 7 APIs.

I have a use case where I need to provide a central path that delivers XML, but for various reasons that XML must be fetched from embedded content on a separate path, that I don't control, but that's also delivered via the Drupal menu system. The specifics of the use case are probably beyond the scope of this specific question, so I won't elaborate too much there. Anyway, I've had some success creating a menu callback that simply calls menu_execute_active_handler() internally, and then renders the output. It gets the path to use for the sub-request via a query string. Something like:

// The XML we are looking for will be inside a sub-requested page at path
// xml-source-path and inside a <script id="xml-source-id"> block.
$query = drupal_get_query_parameters();
if (isset($query['xml-source-path']) && isset($query['xml-source-id'])) {
  $source = drupal_render_page(menu_execute_active_handler($query['xml-source-path'], FALSE));
  // Search for the XML within the raw sub-request markup.
  $matches = array();
  preg_match('/<script[^>]*id=\"' . $query['xml-source-id'] . '\"[^>]*>(.*)<\/script>/simU', $source, $matches);
  if (!empty($matches[1]) && strpos($matches[1], '<?xml') === 0) {
    $xml = $matches[1];
    // ----- Misc other processing to fetched $xml -----
    // Set headers and directly print result.
    drupal_add_http_header('Content-type', 'application/xml; charset=utf-8');
    print($xml);
  }
}

Though this works great for most of my own tests, I'm really not sure if I'm breaking any best practices here, or worse, introducing any security concerns. Since the callback itself is triggered from within a call to menu_execute_active_handler() (in index.php itself) is a recursive call like this potentially problematic? Also, would the fact that I'm accepting the path for sub-request via a query string provide any way for this menu callback to be used for malicious purposes? I really don't think so, but I'd feel much better if I could confirm, or identify a better way.


texts: How to change values views exposed filter based upon view results?

texts:
I have a view which, in addition to showing event nodes, also shows "fake" event nodes.  The "fake" event nodes are inserted in hook_views_pre_render().

The view also has an exposed filter to filter out content tagged with a certain term ID on the event_type field.  The exposed filter list has gotten too large so now it would make sense to only show the terms in the list that can filter out the view results (including the "fake" events).

Now I tried this with hook_form_alter(), but the problem is that the "fake" event nodes aren't available by using views_get_view_result() and I'm not sure what other function could be used to do that here.

I tried using dpm($view); in hook_views_pre_render(), hook_views_pre_build(), and hook_views_pre_view(), but I could not find how to change values in the exposed filter in any of those.

Where can I see the values of the view result at the same time as the value options in the exposed filter?


texts: Query with db_select() to select node by id and join field and terms

texts:
I am trying to write a query using db_select that selects a particular node by id, and then joins it's field_data_field_projectresources column and also selects the terms from taxonomy (because this is a term_reference field)

I have tried numerous attempts but I am finding myself stuck (I didn't even get to the part about joining the  dr_taxonomy_term_data table)

 $query = db_select('node','n')
  ->condition('n.nid','5')
  ->fields('n')
  ->fields('p');
 $query->Join('field_data_field_projectresources','p','p.entity_id = n.nid');
 $result = $query->execute();

 while($record = $result->fetchAssoc()) {
   print_r($record);
 }

Any help appreciated, Thanks


texts: AJAX in Form API element returned in another AJAX callback

texts:
I have a form like this:

$form['my_button'] = array(
  '#type' => 'button',
  '#ajax' => array(
    'callback' => 'my_callback_1',
    'wrapper' => 'some_wrapper',
  )
);

Which works fine (code is very simplified). Now, in the callback, I want to return another button, which also has ajax configured:

function my_callback_1() {
  return array(
    'my_other_button' => array(
      '#type' => 'button',
      '#ajax' => array(
        'callback' => 'my_callback_2',
        'wrapper' => 'some_other_wrapper',
      )
    ),
  );
}

function my_callback_2() {
  return array('#markup' => 'success!!');
}

Now, when I click on the first button, Drupal loads the second button just fine. The problem is, a click on the second button does nothing. Am I missing something?


texts: How to make a slideshow with collection field?

texts:
I have a content type called Building. These buildings have many planes with its own name.
In my content type, I have a collection Field (unlimited values) whose sub-fields:

Image
Title

I'm trying to make a slider with the sub-field image, making the titles of the images as a pager.
I created a Block-View which receives the nid as argument from the URL.

I have the Field Slideshow module for the Formatter Slideshow in views module.
My current configuration is:

Formatter: Slideshow
Image Field: Field Collection field:image
Multiple field setting - Display all values in the same row: YES
CONTEXTUAL FILTERS - Content: Nid - Content ID from URL

This configuration makes the images function as slider. But, I don't know how putting all titles of the images as a pager.


texts: Cannot add a domain to existing drupal 7 site

texts:
Sorry in advance if this is a dumb question, I can't seem to figure out how to add a domain name to a D7 site, (currently using an IP). The website is hosted on digitalocean, the new domain is from namescheap, and the site is Drupal v 7.41.

(The end goal is to apply a letsencrypt ssl certificate to the website, which is not possible without a domain name - so if anyone has better advice than bothering with the domain please let me know! SSL was implemented by following this step-by-step guide: https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-16-04)

The new domain has been added to digitaloceanl, and I've changed the $base_url variable in settings.php to the new domain. Trying to reach the site by the new domain returns the following Privacy Error warning:

"NET::ERR_CERT_COMMON_NAME_INVALID"

And running tests on the ssl certificate return "MISMATCH,"

Both of which seem to imply the new domain is not working properly.

Not sure what other information to supply, so if anyone has a suggestion please let me know!

Thanks,

Jill


texts: How to display the same field with various nodes in the same row using Views?

texts:
How do I do something similar in Views with the below SQL query?

select nid,
title AS title1,
type AS node_type,
(select title from node,
field_data_field_node_reference_id
where
node.nid = field_data_field_node_reference_id.field_node_reference_id_target_id
AND
field_data_field_node_reference_id.entity_id = 1)
AS title2,
(select nid from node,
field_data_field_node_reference_id
where
node.nid = field_data_field_node_reference_id.field_node_reference_id_target_id
AND
field_data_field_node_reference_id.entity_id = 1)
AS nid2
from node
where nid=1;

The output in MySQL would be:

nid | title1     | node_type |   title2        | nid2
1   | Some Title | MyNode    |   Another Title | 69

As you can see, they share a relationship by a field called 'field_node_reference_id_target_id'.  Both values, 'title1' and 'title2', are from the same table called 'node'.  I would like to avoid writing my own SQL queries, so is there a way to get views to display a similar output (e.g. node titles in the same row that share a relationship)?


texts: User click on log in when user already logged in so should throw message.

texts: I am write some code for user login. But i want when user click on log in button every ,that time checks user already logged in or not . if user logged then throw the informative message and if not throws error. How i do this.. Please help me..


texts: There doesn't seem to be a concise answer of how to hide the page view title on a rendered views page. Does anyone know how to hide this without having to install another module or write any code? Is it even possible?


texts: Change date format "Authored on" for views with replacement pattern

texts:
In Druapl 8, how can i change the date format used in a view (see screen shot)

The view uses a replacement pattern {{ created }} == Authored on

and i don’t find where to modify the format. I’ve checked :

  configuration / regional and language / date and time formats

But i don’t know how to use the custom format with {{ created }} in the view.

Could it be done in admin without modify template file ?


texts: I have a banner and some social media buttons added through a template edit. I was wondering if it would be better to put it in a block or leave it as is. My goal is better performance.


texts: Specify which theme to use when rendering a page with drupal_render_page()

texts:
I'm looking to send out a node as an HTML email. I have the code working except for one part.

I'm using drupal_render_page() to render the page's content so it's ready for an HTML email. I thought I'd use a custom theme for this (to take advantage of Drupal's theming layer).

However, I can't seem to figure out how I would specify a specific theme to use. Every time I run it it runs the current theme.

I'm not sure if this make a difference or not, but I'm using the Batch API to generate/send the emails.

I've tried changing the $theme and $theme_key globals in the batch callback, however that didn't seem to change anything.

I've also tried something like this in hook_custom_theme():

if (arg(0) == 'batch' && $_REQUEST['op'] == 'do') {
  return 'email';
}

However, this also doesn't seem to change anything and still renders the email using the "seven" theme.

I've also tried using hook_batch_alter(), however changing the theme changes it for the batch process, (I still want the batch to process in the seven theme, I just want the email to be rendered in a different theme).

Thanks!


texts: How to place a role-aware "Add new" link at the top of a Views listing of media

texts:
I've created a view that provides a listing of a particular media type on my site.  I'd like to place an "Add new" link at the top of this view and have it visible only to users who can actually add new media of that type.  Does anyone know a straightforward way of doing this?

What I've tried:

Adding a View header component of type "Text area":  Nope, can't restrict visibility
Using the menu's Menu block and trying to insert that as a Views header component: Nope, can't restrict visibility
Using the menu's Menu block and adding it to the Block layout with a specific "Show on this page" set to just the Views page I had created.  This worked, but with several of these links to create, I would be unacceptably cluttering up my Block layout with one-off menu blocks.
Creating a menu with one menu item and rendering it with the "Rendered entity: Custom menu item":  Nope, can't restrict visibility AND it renders in a useless way (unformatted data)

I find it strange that you can't create a Views header/footer element and specify its visibility based on roles/permissions.

Any ideas/solutions that won't be duplicative or hard to maintain?


texts: How to change the value of site_name to "My site name" in multilingual sites using Drush?

texts:
I'm trying to use this Drush command:

drush variable-set site_name "My site name"

I have no problem at all to use this command when the site has only 1 language. But it doesn't seem to work (have any effect) in a multilingual site when the "site name" is to be translated to additional languages.

Is there a way to use this Drush command to set the site-name in every of those additional languages? Either at once or in every language (in several steps)?


texts: I want to create a dynamic main menu according to user roles. For example if an anonymous user visits he can only see the 'Home' and 'About Us' links, while registered users can see additional links like 'Contact Us'. Is there a way to do that, through a module perhaps? I don't want to edit in source code.


texts: Right way to update a drupal distribution?

texts:
I have a site which is a Commerce Kickstart distribution.

My distribution version is 7.x-2.0-rc1 and now the 7.x-2.0-rc2 version is available.

How do I update a distribution? I tried these method (both failed...)

1) I follow the update standar process using the drupal ui. I get this error message:

>     Notice: Undefined index: version_major in update_calculate_project_update_status() (line 595 of
> /Applications/MAMP/htdocs/mySite.com/modules/update/update.compare.inc).
>     Downloading updates failed:
>
>     commerce_kickstart-7.x-2.0-rc2-core.tar.gz does not contain any .info files.
>     Notice: Undefined index: version_major in update_calculate_project_update_status() (line 595 of
> /Applications/MAMP/htdocs/mySite.com/modules/update/update.compare.inc).

2) I downloaded the distribution and replace the folder mysite.com/profiles/commerce_kickstart
This didn't work neither.

¿Which is the right way to to do this?


texts: How do I limit the number of Views results on specific pages?

texts:
I have a Views-generated block which lists news. I would like the number of items to depend on the page it is displayed on - for instance: on the front page there's a place for 3, on another one - even 10. Is there a way to do that via a View tpl or template.php code?

I would rather not have an almost-identical copy of the View just for a different purpose.


texts: Payment Information on hook_commerce_checkout_complete

texts: I am developing module which connects Drupal Commerce with 3rd party invoicing system. For this purpose I need to send payment information (has it been paid? how much? in what way?) after the order is complete. I guess the hook_commerce_checkout_complete() hook is the best place to do that but I can't figure out how to obtain this payment information from an $order object/entity.


texts: how to theme content type based on context

texts:
I have an article content type with categories (term1,term2 etc)
I want to be able to theme the node view with a different theme when specific category is picked on node edit

how can this be done ? any kind of solution is acceptable

NOTE: at this point https://www.drupal.org/project/page_theme, https://www.drupal.org/project/themekey have not been ported to D8 :-( They would really be great solutions


texts: I installed Charts with Google Charts in Drupal 7. Everything is ok, but when I have to use decimal numbers, with number 0.5 or 0.8, it appears to me .0 or .8 both on the vertical axis of my column chart and on the graph itself. Why?


texts:
When I register as a new user I get an error.

An illegal choice has been detected. Please contact the site administrator.

If I reenter my password fields, and press create new account then it lets me register. Ideas?


texts:
I have created a calendar with calendar module used in views.
Here I would like to make change from "Wednesday, October 1, 2014" to "October, 2014" (red color).


texts: Drupal 6 - create second contact form with redirect after submitting

texts:
I was asked to add to existing Drupal 6 page second contact form.
What I mean by second:
On the site there is site wide contact form that's available at www.site.com/contact but what I need to add is a second contact form but with some custom fields.

I only need 2 fields: name and suggestion.
Also I would like to have custom message after form submit.

So the user navigates to page www.site.com/contact/question. User enters name and suggestion, then clicks submit and user will redirected to page showing thank you message, this can be at the same address, not necessary a redirect.
On server site I just need to send form content to specific email address. No tables, reports, simple email.

It would be nice not to install any additional modules, but if they are really necessary then that's fine.

Site is bit old and I am afraid that installing new modules will create issue.

There is a module called webforms, but can I achieve my goal without additional modules?


texts: uploaded image exceeding the maximum file size of

texts:
I am using Drupal 8.3.5 and Lightning 8.x-2.16. When I upload an image in an image field that exceeds the max file size. I get the page warning: The file is 826.11 KB exceeding the maximum file size of 25 KB. I would like to remove the placeholder text
     To reproduce this I installed a fresh Drupal Lightning site. Added a plain image field to the Page content type and set Maximum upload size to 80 KB. Then try to upload an image that is over that file size.


texts: Why I don't get the encryption methods? Encrypt module

texts:
I'm working on a Drupal 8 project. I want to send a link to the user via email and passing as parameters some user details that I want to encrypt. When the user clicks the link, I will get those encrypted data from URL and I will decrypt them.

After some research, I decided to use the Encrypt module.

I installed it, I added my key in settings.php, I also created a key in admin/config/system/keys, and now I'm trying to create an encryption profile, but the encryption method list is empty.

Is this the correct way to implement data encryption/decryption? If so, how can I get the encryption method list?


texts: How do I programmatically export all webform submissions into a single csv? (multiple webforms)

texts: I have hundreds of webforms created from a single webform template. How do I programmatically export all webform submissions into a single csv? Note that this is not possible via views out of the box. One would have to create [webform_mysql_views.] (Combine Webforms to export multiple form results in a single CSV) This doesn't seem efficient.


texts: Why do I get an error about loading the htmlpurifier/library/HTMLPurifier.auto.php file?

texts:
I am creating files to be run in different situation using scheduled cron jobs. These are mainly for either cleaning nodes, updating or doing other calculations automatically. The drupal site is running in devdesktop.
I have a few of them and so far I have no problem making them do what they should. They all have the same structure and format, using the same basic db functions or node_delete_multiple.
This new file I created, is having me want to split my head open on a concrete wall. I basically doing the exact same thing as my other scripts, but when executing this one I get an error. I found where it was coming from (node_delete_multiple()) and reduced the code to this.
define('DRUPAL_ROOT', str_replace('cron_scripts', '', getcwd()));
require_once DRUPAL_ROOT . './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$regtodel = array(5366,5373,5375,5444);
node_delete_multiple($regtodel);

The DRUPAL_ROOT value is the same used from the other, working, scripts I have in that directory.
This should delete the nodes in the array. It doesn't and it gives this error.

Fatal error: require_once(): Failed opening required 'sites/all/modules/htmlpurifier/library/HTMLPurifier.auto.php' (include_path='.;C:\Program Files (x86)\DevDesktop\common\pear') in D:\AQUIADEV\site\devdesktop\OCRNATIONv2\sites\all\modules\htmlpurifier\htmlpurifier.module on line 320

Now, when looking at htmlpurifier in the website, it's normally loading its library using the library API, but from the external script, it's not using the API and try to load from the module folder. Plus it's probably loaded by the bootstrap, but I don't need it in those script. It should be related at all, but for some unknown reason, it prevents me from going any further.
What can be the reason behind that? Like I said, other scripts are working.


texts: Panels on the front page get invalid $user variable

texts:
I have a Drupal 7 wite where the front page is a Panel. In one of its tiles I have a custom PHP code that prints out the value of `$user->name'. Now the problem is that it usually prints out a different user's name.

Cacheing and memcache is now switched off. Do you have any idea what might cause this problem..?


texts: Filter articles by tag equal to the node title

texts:
I'm trying to create view which will show all Articles which tag is equal to title of currently being viewed node (which content type is not Article).

Adding filter Has taxonomy term = [title] does not see token.
My question is how to pass current page title to filter or this is done with contextual filters?

For example, I have the Author content type. On Author nodes, I want to add a view which shows the last three articles which have tags equal to the title of the node. (In my case, it's the author's name.)

Author is not a type of user, nor a role assigned to users.

I managed to get something (but not good enough to work):

View:  Unformatted list of fields
Filter criteria: Content type (=Article)
Contextual filter: Content:Tags
Provide default value: Taxonomy term ID from URL
Validator: Taxonomy term (Tags) + Transform dashes in URL to spaces in term name filter values

When I try to preview the results (Preview with contextual filters), with "chuck-norris" it returns the result as expected, but it doesn't work with "author/chuck-norris", so it doesn't show result on page for Chuck Norris.
I also tried with different options (e.g. default value Rawvalue from URL, path component 2, with checked Use path alias).


texts: Drupal module to generate compressed xml sitemap

texts:
Is there any Drupal module which can generate compressed xml sitemap like sitemap.xml.gz? The problem is I have a site with a lot of pages and the generated sitemap is very big (more than 1 MB). I have "404 not found" errors in google webmaster tools for the sitemap, but when I open the address mysite.com/sitemap.xml the sitemap is displayed after more than 5 seconds. When I test my sitemap with google PageSpeed Insights it tells me to activate compression and I will reduce the data transfer for this file with 92%.
I activated compression on Nginx and now it is compressing everything but the sitemap.  Now I am searching for a module generating compressed sitemap.
I am usung Drupal 7 with Nginx and xmlsitemap module for generating sitemap


texts: Second ajax select rebuilt by first does not fire

texts:
I have a form with 3 select fields. Selecting a value from the first should result in the second becoming populated, and this works. Similarly, when making a selection in the second, the third should be populated, however the second field never fires.

When the ajax callback from the first field returns the second field, the markup for the second field contains the ajax callback, which does not fire.

Here is the code:

   public function buildForm(array $form, FormStateInterface $form_state) {

      $config = $this->config('my.settings');

      $form = [];

      $options = _get_list();

      $form['instances'] = [
        '#type' => 'details',
        '#title' => $this->t('Instances'),
        '#open' => false,
      ];

        $form['instances']['first'] = [
          '#type' => 'select',
          '#title' => 'First',
          '#options' => $options,
          '#ajax' => [
            'callback' => '::populateSecond',
            'disable-refocus' => FALSE,
            'event' => 'change',
            'wrapper' => 'edit-second',
            'progress' => [
              'type' => 'throbber',
              'message' => $this->t('Loading...'),
            ],
          ]
        ];

        $form['instances']['second'] = [
          '#type' => 'select',
          '#title' => 'Second',
          '#options' => '',
          '#prefix' => '
',
          '#suffix' => '
',
          '#validated' => TRUE,
        ];

        $form['instances']['third'] = [
          '#type' => 'select',
          '#title' => 'Third',
          '#options' => '',
          '#prefix' => '
',
          '#suffix' => '
',
          '#validated' => TRUE,
        ];

    return parent::buildForm($form, $form_state);
  }

  public function populateSecond(array &$form, FormStateInterface $form_state) {
    $selectedValue = $form_state->getValue('first');
    if ($selectedValue) {
      $second = _get_second_list($selectedValue);

      $form['instances']['second'] = [
        '#type' => 'select',
        '#title' => 'Second',
        '#options' => $second,
        '#prefix' => '
',
        '#suffix' => '
',
        '#validated' => TRUE,
        '#ajax' => [
          'callback' => '::populateThird',
          'disable-refocus' => FALSE,
          'event' => 'change',
          'wrapper' => 'edit-third',
          'progress' => [
            'type' => 'throbber',
            'message' => $this->t('Loading...'),
          ],
        ]
      ];

      return $form['instances']['second'];
    }

  }

  public function populateThird(array &$form, FormStateInterface $form_state) {
    $selectedFirst = $form_state->getValue('first');
    $selectedSecond = $form_state->getValue('second');
    if ($selectedFirst && $selectedSecond) {
      $third = _get_third_list($selectedFirst, $selectedSecond);
      $form['instances']['third'] = [
        '#type' => 'select',
        '#title' => 'Third',
        '#options' => $third,
        '#prefix' => '
',
        '#suffix' => '
',
        '#validated' => TRUE,
      ];

      return $form['instances']['third'];
    }

  }

Here is an example of the 'if' statement that precedes each form field in buildForm in the final working version.

       if (!empty($form_state->getUserInput()['first'])) {
          $second = _get_second_list($form_state->getUserInput()['first']);
        }
        else {
          $second = NULL;
        }

and then, in field 'second', as an example:

    #options = $second;


texts:
I am using Drupal and I would like to index Arabic text that use Arabic diacritics extensively 'similar to accents in French or Umlauts in German".

The text is indexed but the search doesn't ignore the diacritics when searching. Does anybody know if the Arabic standard tokenizer handle Arabic diacritics?

I read somewhere that some people use AraMorph tokenizer. I am not sure if this can work with Solr 4.4.0.

I use Apache Solr integration module along with Search Api for Solr.

How can I make my search insensitive so that it ignores those diacritics?

Thanks,
Mohamed


texts: How to add a database index to a base field

texts:
Goal:

Add a database index to a 'created' field.

Given:

There is a custom entity with a base field created.
The field is stored the entity table.
Field source code of the created field:

$fields['created'] = BaseFieldDefinition::create('created')
  ->setLabel(t('Created'))
  ->setDescription(t('The time that the entity was created.'))
  ->setDisplayOptions('view', [
    'label' => 'hidden',
    'type' => 'timestamp',
    'weight' => 3,
    'settings' => [
      'date_format' => 'medium',
      'custom_date_format' => '',
      'timezone' => '',
    ],
  ])
  ->setDisplayConfigurable('view', TRUE);

What I researched:

I have not found a way to add index using the \Drupal\Core\Field\BaseFieldDefinition().

As I understand indexes are defined in a @FieldType plugin. The created field is implemented via the \Drupal\Core\Field\Plugin\Field\FieldType\TimestampItem() plugin and obviously does not have have indexes there.

P.S. I know, that I can write an updatescript to add an index to the table manually.


texts: Form input returns "1" instead of real value

texts:
On this page I have an select list with values from a file directory. This works. Only after submitting it doesn't get the value of it. It makes it "1". Normally with a "normal" select list this should work I guess.

Problem: $form_state['input']['edit']['ios_cert'] doesn't return selected value.

Code (in hook_form):

$files = array();
foreach(glob("C:/wamp/www/drupal2/sites/default/files/*.pem") as $filename) {
   array_push($files, substr(strrchr($filename, '/'), 1));
 }

$form['replace_textfield']['edit']['ios_cert'] = array(
    '#title' => t('Select right certificate file'),
    '#type' => 'select',
    '#options' => $files,
    '#default_value' => $ios_key,
    '#weight' => 45,
  );

Code (hook_submit):

$ios = $form_state['input']['edit']['ios_cert'];

$query = db_update('push_notifications_api')
->fields(array(
'app_id' => $app_id,
'GCM' => $gcm,
'ios' => $ios,
'ios_mode' => $ios_mode,
))
->condition('app_id', $oldid)
->execute();
drupal_set_message(t('@title has been updated succesfully.', array('@title' => $title)));
dsm($form_state);

Result:

And it should be something like "Filename-djfklasjklf.pem"

thanks in advance!


texts: Import external modules yaml config through own hook_update_N implementation

texts:
I am trying to update a module on an old project of mine. In the meantime the module's devs added new configuration and schema yaml files but did't write the update functions for already existing sites.

How would you import all schema and config changes automatically?
Do I need to import the yaml files though Yaml::parse and then use \Drupal::configFactory() and \Drupal::entityDefinitionUpdateManager() in my hook_update_N function? Or is there an easier way?


texts:
On my Drupal 7 website, I would like a uri like

folder/subfolder/preferences

to be an alias for the user edit page

user/<uid>/edit

for all users.  To be precise, when a user navigates to folder/subfolder/preferences, they should be at their own user/"uid"/edit page with the original folder/subfolder/preferences uri in the navigation bar.  If necessary, I wouldn't mind if the aliase contained the uid, so I'd be ok with folder/subfolder/preferences/"uid".

It seems like the pathauto won't do what I want, I'm experimenting with sub-path auto but so far no luck.  If there's a module that can help me do what I want that would be great, but wouldn't mind to do it through a hook if necessary (I haven't figured out how to do this by hooks either).  Thanks for any help.


texts: How can I get the render language for a views in views field plugin

texts:
I need to write a views field plugin, where I need to display a message depending on if the render language exists for an entity. (i.e. entity languages: en, hu, fr display language: de -> message needs to show up, i.e. entity language: en, hu, fr display language: en -> no message)
But for this, I can't get the language from the views. I can get the settings with $this->view->display_handler->getOption('rendering_language') but this can contain also dynamic values like ***LANGUAGE_entity_translation*** or ***LANGUAGE_entity_default***. I looking for a solution that can give me a specific language code that was made by the rendering language setting.


texts: How to add a link in a menu with query parameters in paths

texts:
I want to add this link : resources?field_resources_type_tid_i18n[0]=130 in the main menu
that point to a view with exposed filter.
But When I save my link I just find resources without query parameter


texts: Inserting html just before body of all pages (drupal 7)

texts: I want to add some html just before the start of body of all pages. I have managed to do so by adding the html before the body tags in html.tpl.php. It works fine. But it appears in all themes. I want it to appear only for my default theme (i.e. stark). How can I do that?


texts: Execute Drupal function in background, maybe with cron, for the duration of a user session

texts:
It was too complicated description of the task, so let me edit it and simplify: I need a Drupal 7 function (data collection function) to be periodically triggered in the background but only a while a logged in.

Use case is that we need bunch of data from the remote server to display to the user and it takes long time for all the data to be (1) copied from the remote server, (2) upload to local Drupal database and (3) finally to display to the user. So we don't want the user to wait, but to do some other staff and display the data little bit later when it is ready.

So scenario is like this:

User logs in to Drupal 7 website and start browsing pages without any delay.
At the moment when he/she log's in we need to trigger a Drupal function in a custom module that starts to perform steps (1) and (2) in the background. So user again doesn't feel any delays.
When the data is pulled and uploaded to the local Drupal 7 database, the system starts displaying it to the user.

Is it so difficult or impossible for Drupal to trigger a function in the background independently of whatever user is doing on the website only for the period of time while he/she is in the session?


texts: Getting the value of taxonomy field in a node.html.twig template (Drupal 8.x)

texts:
I'm currently trying to figure out how to get the value of a field of a node in node.html.twig template. The field (machine_name: news) is linked to a taxonomy and multiple values can be selected. I see a lot of threads here on Drupal StackExchange - tried all the solutions, but not a single one fixes my problem.

I'm currently trying:

  {{ node.field_news[0].value }}

But then nothing is printed. When I try:

  {{ node.hasField('news') }}

... the value '1' is printed. So the field is available.
I tried dumping the whole 'node' object using the Twig dump() method, but then I get a white-screen-of-dead due to memory restrictions.

Any idea's what is the correct way? I'm using Drupal 8.3.2


texts: Entity browser widget in custom config form

texts:
I am able to render the entity browser button in custom configuration form.
But, after selecting the image it does not get displayed in the
 form, has anyone integrated in custom form so far ?

$form['content_link'] = [
    '#type' => 'container',
    '#parents' => ['content_link_wrapper'],
    '#weight' => -3,
    'widget' => [
      '#title' => t('Content Link'),
      '#description' => t('The content to be linked in the menu.'),
      '#field_name' => 'content_link',
      '#field_parents' => [],
      '#required' => TRUE,
      '#parents' => ['content_link'],
      '#tree' => TRUE,
      '#id' => 'edit-content-link',
      '#type' => 'details',
      '#open' => TRUE,
      'target_id' => [
        '#type' => 'hidden',
        '#id' => 'edit-content-link-target-id',
        '#attributes' => [
          'id' => 'edit-content-link-target-id',
        ],
        '#default_value' => "",
        '#ajax' => [
          'callback' => [
            '\Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget',
            'updateWidgetCallback',
          ],
          'wrapper' => 'edit-content-link',
          'event' => 'entity_browser_value_updated',
        ],
      ],
      'entity_browser' => [
        '#type' => 'entity_browser',
        '#entity_browser' => 'image_browser_dropzonejs',
        '#cardinality' => 1,
        '#selection_mode' => 'selection_append',
        '#default_value' => [],
        '#custom_hidden_id' => 'edit-content-link-target-id',
        '#process' => [
          [
            '\Drupal\entity_browser\Element\EntityBrowserElement','processEntityBrowser'
          ],
        ],
      ],
      'current' => [
        '#theme_wrappers' => ['container'],
        '#attributes' => [
          'class' => 'entities-list',
        ],
        'items' => [],
      ],
      '#attached' => [
        'library' => [
          'entity_browser/entity_reference',
        ],
      ],
    ],
  ];


texts: Drupal 8 Migrate Plus - CSV Row Number as key

texts:
In the Drupal 7 migrate module, you can use 'csvrownum' as the mapping key when migrating content from a CSV (https://www.drupal.org/node/1152158). For the Drupal 8 version, I am not sure what the equivalent is. Here is my yml file configuration (migrate plus):

id: timesheet_data
label: Importing Timesheet
migration_group: csvimport
migration_tags:
  - node
  - csvimport
source:
  plugin: csv
  path: 'somepath/timesheet.csv'
  header_row_count: 1
  keys:
    - csvrownum
  column_names:
    0:
      name: Name of Contact
    1:
      address: Address
destination:
  plugin: 'entity:node'
  default_bundle: timesheets
process:
  title: name

I tried this approach thinking it might be similar to the drupal 7 migrate module. I also tried not specifying  a key, both resulted in an error.


texts:
I'm trying to remove the login link from the Drupal site.

However, despite the User login being set to none. It still shows on the site.

Is there a way to hide the link?

Thank you,
Kevin Davis


texts: Views display of every user's flagged nodes grouped by flag type

texts:
I am using views and the flags module to create a site where users can flag node items  with multiple flags/flag types. For my example, a user can flag nodes (content) items with one of three flags: fruits, veggies, or other.

User 1, name and profile picture

flag-fruits     flag-veggies     flag-other
------          ------           ------
apple           carrots          pork
orange          celery           ham
cherry                           soda

User 2, name and profile picture

flag-fruits     flag-veggies     flag-other
------          ------           ------
lime            artichoke        trout
banana          lettuce          barley
cherry          ginger           soda

User 3, name and profile picture

etc…

I have tried setting up the relationships in Views using content (node) item listings and Users' Flagged Content relationships. With Grouping Fields I can manage to relate a single flag type to each user, so…

User 1

flag-fruits
------
apple
orange
cherry

But I really need the view to show each flag under each user in a list. I have been attempting this with the [ViewField][1] module and also regular Views Attachments, but so far with no luck. Is this even possible? Panels maybe?

[1]: http://drupal.org/project/viewfield


texts: Correct usage of hook_user_login and hook_user_presave for saving data to user

texts:
I have a custom module that syncs LDAP-data to custom user fields (every 24 hours, depending on when the user logs in). Everything seems to be working, but I'm not an expert on PHP and Drupal hooks so I want to be sure I'm not doing anything silly.

My understanding is that when user account is saved in hook_user_login, hook_user_presave is run and the values are saved (values are located in the $edit variable). Am I saving the values correctly? Have I missed a critical check that could lead to errors?

Here's my code:

// runs everytime a user logs in, checks if ldap attributes need to be updated
function company_ldap_user_login(&$edit, $account) {

      // If the user is user 1 or guest, then do nothing
      if ($account->uid <= 1) {
        return;
      }

      // don't update data if it's less than 24 hours ago
      if (isset($account->data->ldap_sync) && $account->data->ldap_sync < time() - 3600 * 24) {
        return;
      } else {

        // load custom LDAP configuration
        require_once('custom_ldap.inc');

        $ldap = new ldap();

        // get LDAP data
        $data = $ldap->get_info();

        // do nothing, since user does not exist in LDAP
        if($data["count"] == 0)
        {
          return;
        }

        $data = $data[0];

        $first_name = trim($data["givenname"][0]);
        $last_name = trim($data["sn"][0]);
        $fullname = "$first_name $last_name";
        unset($data['mailaddresses']['count']);

        // load the user that has logged in
        $account = user_load($account->uid);

        // save LDAP data to an array
        $edits = array(
          'first_name' => $first_name,
          'last_name' => $last_name,
          'fullname' => $fullname,
          'emails' => $data['mailaddresses'],
          'ldap_sync' => time(),
        );

        // save the user with the data provided above
        user_save($account, $edits, 'company_ldap');

      }
}

// when user account is being saved or updated
function company_ldap_user_presave(&$edit, $account, $category) {

  // make sure to only update ldap-attributes when needed
  if ($category == 'company_ldap') {

    // if there is no data to save, don't save
    if (isset($edit['fullname'])) {

      // save ldap-data to custom user fields
      $edit['field_company_fullname'][LANGUAGE_NONE][0]['value'] = $edit['fullname'];
      $edit['field_company_first_name'][LANGUAGE_NONE][0]['value'] = $edit['first_name'];
      $edit['field_company_last_name'][LANGUAGE_NONE][0]['value'] = $edit['last_name'];

      // loop through all mail addresses and add them to the custom user field
      foreach ($edit['emails'] as $i => $email ) {
        $edit['field_company_emails'][LANGUAGE_NONE][$i]['value'] = $email;
      }

      // save serialized data of last ldap sync to users.data table
      $edit['data']['ldap_sync'] = $edit['ldap_sync'];
    }

  }

}


texts:
I am running Drupal 7.56

I have been using Views extensively for some months now. I want now to create custom pdf pages from some Views.

I have installed jQuery_update, then Views PDF Display Module, then copied fpdi and tcpdf libraries into the Libraries folder (via FTP).

Now, when I want to add a PDF Page to a View, I get the following error message :

  Fatal error: require_once(): Failed opening required 'sites/all/libraries/fpdi/fpdi2tcpdf_bridge.php' (include_path='/home/my_hostname/www/www/sites/paroisse/civi_extensions/nz.co.fuzion.cmcic-master/:/home/my_hostname/www/www/sites/paroisse/civi_extensions/nz.co.fuzion.extendedreport/:/home/my_hostname/www/www/sites/paroisse/civi_extensions/org.civicrm.sms.twilio/:/home/my_hostname/www/www/sites/paroisse/civi_extensions/com.drastikbydesign.stripe/packages/:/home/my_hostname/www/www/sites/paroisse/civi_extensions/com.drastikbydesign.stripe/:/home/my_hostname/www/www/sites/default/fpdf:.:/home/my_hostname/www/www/sites/all/modules/civicrm:/home/my_hostname/www/www/sites/all/modules/civicrm/packages:.:/home/my_hostname/www/www/sites/all/modules/civicrm:/home/my_hostname/www/www/sites/all/modules/civicrm/packages:/home/my_hostname/www/www/sites/all/modules/civicrm/vendor/tecnickcom:/home/my_hostname/www/www/sites/all/modules/civicrm/vendor/phpseclib/phpseclib/phpseclib:/home/my_hostname/www/www/sites/all/modules in /home/my_hostname/www/www/sites/all/modules/views_pdf/views_pdf_template.php on line 22

I suspect that this is due to a bad installation, but find no clear and up-to-date installation tutorial.

I must say that :
- I am not a programmer,
- I use civicrm, a big Drupal Module, which explains the big include path

Any help is welcome


texts:
I was running through some tests on my site with a client, and I was logged in as a normal authenticated user. I then logged out with the intention of logging back in as the superadmin (uid -> 1).

I navigated to a node page where there was a login form, and the site automatically logged me in as the authenticated user that I was logged in as previously.

Do you have any ideas of what could be causing this? The page that where this auto-login occurred reads off of a custom node.tpl file and I've got a few user_load() calls in that code.


texts:
Want to redirect $form_state to external URL after successful registration of the user. Like, need to redirect to facebook after user registration.

  $query = "http://facebook.com";
  $url = Url::fromRoute('user.register', [], ['query' => ['service' => $query]]);
  $form_state->setRedirectUrl($url);
  //$url = Url::fromUri($query);
  return RedirectResponse::create($url->toString(), 302);

  $form_state>setResponse(newTrustedRedirectResponse('https://google.com', 302));
  return new RedirectResponse($query);
  $form_state->setRedirect($query);
  $form_state->setRedirectUrl(Url::fromUri($query));
  $response = new RedirectResponse($query);
  $response->send();

tried above all methods, but nothing works.


texts: How To Set Node Path/Alias Programatically

texts:
I am creating some nodes in Drupal 6 programatically by creating an empty object, setting some properties and calling node_save() on the object.

When I print out the object again, I see new properties, since node_save() alters the node object by reference, but I don't see a path property, but from Drupal I can always view the node at 'node/NID'.

Is 'node/NID' the path?

Should I not set a 'user friendly' path property on the node itself, and just use path_set_alias() after node_save instead of mucking with the path property on the node itself?


texts: How to inject a fake class into container when running WebTestBase tests?

texts:
I've got a form class, and I'm injecting my custom functionality class into it via constructor. That class is added to the container via the services.yml file defined in my custom module.

I'd like to test that the form is functioning correctly, but for testing purposes I'd like to replace the class that's injected into the form with a fake one.

Both real and fake classes implement the same interface. The form is working with that interface.

My test file:

<?php
/**
 * @file
 * Contains \Drupal\my_module\Tests\FormTest.
 */

namespace Drupal\my_module\Tests;

use Drupal\my_module\Tests\Fake\FakeClass;
use Drupal\simpletest\WebTestBase;

class FormTest extends WebTestBase
{

    public static $modules = [
        'my_module',
    ];

    public function setUp()
    {
        parent::setUp();

        $fake = new FakeClass();

        $this->container->set('my_module.real_class', $fake);

        // $this->container->get('my_module.real_class') returns a FakeClass object.
    }

    public function testFormWorks()
    {
        $this->drupalGet('my-form');
        $this->drupalPostForm(NULL, [], 'Submit');
        $this->assertRaw('Form is working.');
    }

}

When I'm running the test, the real class is being used, which is not the desired test behaviour.

I can't figure out what I'm doing wrong here. Any help is appreciated.

Update: the issue is not specific to forms. Same thing happens in page controllers.


texts:
In admin/config/regional/translate/update I found the following message:

If there are available updates you can click on "Update
translation" for them to be downloaded and imported now or you can
edit the configuration for them to be updated automatically on the
Update settings page

The following screenshot reveals more:

I could not able to find Update translation anywhere. What is missing?


texts: Access denied for image urls created via image style although derivative token is appended?

texts:
I want to apply an image style to an image and use it via CSS:

if (isset($node->field_images_image['und'][0]['filename'])) $vars['blurred_background'] = image_style_url('background_blurred', 'assets/'.$node->field_images_image['und'][0]['filename']);

In my page.tpl.php:

<?php if (isset($blurred_background)): ?>
<style type="text/css">
body {
    background: url(<?php print $blurred_background; ?>) no-repeat center 0 #292929;
}
</style>
<?php endif; ?>

which actually prints a url like:

body {
    background: url(http://localhost:8888/projectname/assets/styles/background_blurred/public/assets/2222.jpg?itok=xqy5lL55) no-repeat center 0 #292929;
}

But the image is not visible (and not created in the file directory) and if I open the image url, I get an access denied, although there is a token appended?!

I guess this has to do with Drupal's 7.20 security update which I originally dont want to disable. Is there no correct way of doing this without disabling this security feature?