texts:
I have a site where I set a cookie when the user is visiting a specific content-type:

function THEME_preprocess_node(&$variables) {
  if (isset($variables['node']) && $variables['node']->getType() == 'MYTYPE') {
    // Store cookie with id of active node.
    user_cookie_save(['THEME_location' => $variables['node']->get('nid')->getString()]);
  }
}

Then if the user again is going to the frontpage, I would like to redirect him to the node referenced from the above cookie:

function THEME_preprocess(&$variables, $hook) {
  $variables['is_front'] = \Drupal::service('path.matcher')->isFrontPage();

  // Redirect the user to the selected node.
  $cookies = \Drupal::request()->cookies->all();
  if ($variables['is_front'] && isset($cookies['Drupal_visitor_THEME_location'])) {
    $nid = $cookies['Drupal_visitor_THEME_location'];
    $response = new RedirectResponse(\Drupal::url('entity.node.canonical', ['node' => $nid]));
    $response->send();
  }
}

The above works fine most of the time, but sometimes when loggin out from the backend and visiting the frontpage I only get a white screen and the page is completly dead.
I know this is very vague but I cannot seem to reproduce this error by performing some specific steps. It just happens once in a while. If I then clear the cache everything seems to work as expected again? Can someone see what I am doing wrong here?


texts: How to change my homepage based on the time of day?

texts:
I have searched high and low for this. How do I change my homepage based on the time of day? To be absolutely explicit, I want:

Between 8am and 7pm - Homepage 1 (node/4)
Between 7pm and 8am - Homepage 2 (node/5)

So I want to design two completely different homepages and then they change based on time of day.

I tried some code but it doesn't seem to do the job:

$current_front = variable_get('site_frontpage');

if($current_front== 'node/4'){
    variable_set('site_frontpage','node/5');
}else{
    variable_set('site_frontpage','node/4');
}

Note:  I am not a code whizz so wouldn't know where to start with hooks and I'm a million years away from creating my own modules.


texts: Adding tables into the schema when they already have data stored in them

texts:
How do I add tables (with stored data) that already exist in the Drupal database to the schema, without destroying the saved data?

I'm taking over some work and finding that there's no use in the MY_MODULE.install file of schema definition and therefore no current use of hook_update_N() I've looked in the MY_DRUPAL_DB.system table and the module has system.schema_version of -1 which according to the table's description means:

  -1 if the module is not installed (its tables do not exist); 0 or the largest N Of the module's hook_update_N() function that has either been run or existed when the module was first installed.

The weird thing is that there is a .install file and it has a hook_install() which installs new role permissions. So there is something strange going on as I can't even use hook_update_N to add the schema (which I created by downloading the Schema API module and generating the schema defining code in localhost/admin/structure/schema/)


texts: How to send an email to a specific user on new account creation using Rules?

texts:
I have an alumni association portal. When a new user creates profile on the portal, that account stays blocked until a specific user from that batch/department approves it.

I am trying to make use of Rules, but not able to.


texts: How to display simple hierarchial select output as inline instead of UL

texts:
Im using Drupal 7 with SHS, and i have a Taxonomy vocabulary "Location"

The format for this vocab is like : State > City > Location.

I have created a Page View and added the field, but the output of the field is in a UL
like

Maharashtra
Mumbai
Location

However, i want it to be displayed in a single line as:

Maharashtra > Mumbai > Location

The current HTML Output of the field is: URL http://stage.adventureex.com/experience

Maharashtra

Pune

Junnar

I thought i could edit shs CSS file and find a solution, but it was not resolved. Here is the shs.formatter.css file

/**
* @file
* Styles for formatted output of shs module.
*/

.field-type-taxonomy-term-reference ul.shs-hierarchy {
  list-style: none;
  margin: 0;
  padding: 0;
}
.field-type-taxonomy-term-reference .links ul.shs-hierarchy li {
  padding: 0 5px 0 0;
}
.field-type-taxonomy-term-reference .links ul.shs-hierarchy li.last {
  padding: 0;
}
.shs-hierarchy li:after {
  content: '>';
  margin: 0 0 0 5px;
}
.shs-hierarchy li.last:after {
  content: '';
  margin: 0;
}

I asked the same question at #drupal-suppor IRC and @dc2 suggested that i add the following to the css:

.item-list .shs-hierarchy .shs-parent{display:inline !important;}
.item-list .shs-hierarchy .shs-parent{display:inline !important;}
.item-list .shs-hierarchy .shs-term-selected{display:inline !important;}

This gives me the intended result, but i wanted to know if this is the recommended way OR is there a better way to do it.

As the UL and LI tags still exist in the HTML output.


texts: Node View Permissions module prohibits list of nodes in Views module

texts:
I created a custom node type called 'Video' in D7, and in it are three fields, 'YouTube ID', 'Video Title', and 'Video Description'. Basically, I have a template for this node type that puts the YouTube ID into the YouTube iframe to show the video. Not a problem. It works. These videos are for authenticated users only, and I can paste the url of one of the video pages on my site, and if I am logged in, I can see it.

The problem isthat I cannot see my list of videos when logged in, unless I am logged in as admin. The View to see the list of videos (/user-area/video) is accessible, but there is no list displayed unless I am logged in as admin.

It is something with the view and permissions, because I can see the video list page (/user-area/video ~ created by Views module), but without the list on it ... and I can see the video content page (/user-area/video/[video-id] ~ drupal node, themed by .tpl.php).

Any suggestions?

UPDATE

I figured out that it has something to do with the Node View Permissions module that I am using for the 'Video' node type. Although the setting in that module for the 'Video' node type is 'View any', Views must have a difficult time with that. I can still access the video content page, but not the list of video generated by the Views module. I have to figure this out. I updated the title of this question.


texts: How to remove a taxonomy term with an empty required field without having to fill it?

texts:
I'm having a problem while trying to delete a taxonomy term that has an empty required field. To proceed and delete it, I have to fill the empty field to be able to delete it.

How can I remove the taxonomy term without having to fill the empty required field?

For me there is no problem by adding a letter to the field and then delete the taxonomy, but my client is getting crazy with this issue and he is getting me crazy.

Any solution?

Thank you in advance.


texts:
Is there any option available in Drupal views to sort views result using the arguments provided (contextual filters)

I am trying to integrate a search functionality using views. My problem is that contextual filter will list only matching results, I need all the results but it should sort according to the arguments passed using contextual filters. Is that possible?

I.E.   I pass the following string to a contextual NID argument:
1099+1100+1102+1098+1101+1097

I expect the order of the nodes in the view to be the same as the order as passed in through the argument.


texts:
I'm trying to figure out if path aliases are even capable of what I'm trying to do, or if I need some other sort of module.

I have a content type "project" and a content type "mockup". A "project" references a User. A "mockup" references a "project". I'd like the path pattern for a mockup to look something like (I'm making up the token names, but you get the idea)

[referenced_project's_reference_user]/[referenced_project's_title]/[node:title]

Now another thing is that the project path already looks like the first part of the mockup's path:

[project's_referenced_user]/[node:title]

So I'm wondering if there's a way for a token to get the url of the referenced node or something? I was hoping you could stack tokens something like: [[related_project]:url] but that doesn't work.

If you can't tell, I'm using the "references" module.


texts:
I'm inserting new users into tables users (using a webservice that insert), but how to make uid being automatically inserted and it would be always the next value of the current maximal value on table users (and auto-increment too) ?

Thank you


texts: What is the most common use case for the search_api "Index Hierarchy" processor given it is limited to indexing entity ids?

texts:
In search_api the "Index Hierarchy" processor is described as being for the filtering on parent use case:

Allows you to index hierarchical fields along with all their parents. Most importantly, this can be used to index taxonomy term references along with all parent terms. This way, when an item, e.g., has the term New York, it will also be matched when filtering for USA or North America.

However this is limited to indexing the ids of the reference field and the ids of the parents. Therefore it does not on its own provide the ability to search for a parent term and return all terms tagged with a child of that parent term as noted here and here. That is an open feature request.
Given these limitations what are its most common use cases? How have you used this processor to provide search options? Is it currently only useful in conjunction with facet_api/facets or custom code?


texts: Drupal 7: how to rewrite rules replacement patterns programmatically

texts:
i try to create different rule conditions or actions and need to rewrite different replacement patterns. for example:

defined replacement patterns:

 [loaded-points:value] [vote:value]

i want:

 if [loaded-points:value] >= 0

 [vote:value] = - abs([vote:value])

 else

 [vote:value] = abs([vote:value])

the following variables are available and may be used by PHP code:

 $loaded_points, $vote

my action as php code:

  if(isset($loaded_points, $vote['value'])) {
  $vote_value = (int)abs(round($vote['value']));
  if($loaded_points >= 0) {
   $vote['value'] = -$vote_value;
  } else {
   $vote['value'] = $vote_value;
  }
 }

in the next action i have the same values as before php action.


texts: In the views are not displayed in the widget attributes field Form add to cart

texts:
I need to display the attributes of the widgets in the representations in the Form add to cart, at the moment I have shown only a choice of the number and Add to Cart button

Now this (is not right):

How do I need to make it (what you need):

In the second image I have in the base table of contents it is possible to select the field of Content: Product variations and in it there are all the necessary attributes to me colors and sizes.

In the first image I have a base table Search API prime field Commerce item: Form add to cart in does not display attributes such as color or size selection, I can not achieve that result as the second image I have of the field Content: Product variations, as it were, I did not connect the relationship, the entity does not have the right, there is a field Indexed, Commerce item and some of the fields Content.

This capability is necessary for me to make a quick order from the catalog.


texts:
I am using drupal search api with facet api modules.

I am trying to add more than 3 related node in my search index, but I am limited to max 3 nodes.

I have articles, styles, brands, designers, themes content nodes.
I created a search index on articles on the fields page; after adding 3 nodes, the  fourth node doesn't show. The reason I am doing this is to have title of nodes as facets.

I was able to add 4 related nodes on another machine. Is there any limitation to the number of related nodes that can attached to the index?


texts: How to set language for user register page / form per subdomain

texts:
For a custom module, I need to change the language of the registration form based on the subdomain the user is currently active on.

I tried changing the global $language variable in hook_form_user_register_form_alter, but that does not work ($language variable is also not set at that point). I also tried setting the language in the $user object, but also no dice (probably because it is an anonymous user).

Finally I took a look at the language negotiation api, but setting up negotiation providers seems overkill for this (and haven't it studied enough to get a grasp on how to use it).

I just need to render the registration page in a different (but already available) language on /user/register, based on the subdomain. What would be the best way to achieve this.

I'm using Drupal 7.


texts: Is there some way to arbitrarily set the active trail?

texts:
I have a menu as such:

Home
Performances
News
Learning
...

I have a content type called 'Event' and when viewing a node of the event type I want to set the 'Performances' menu item as active. How would I go about doing this?

menu_set_active_trail() doesn't seem to work :s


texts: Contextual Filters On Block of News Items

texts:
Well I inherited a site, I have to make updates too. I have a list of news items, each news item has field I added called section, which lets people know what the section the news article blogs to. The url structure is http://example.com/tv or http://example.com/sports

On those pages, I have a list of news items (right now it's a global list) in a block. I need to adjust that list from a global list to reduce down to a list based on the section you are currently in. So the news list item should only show articles which belong to TV or Sports.

I have been working with the block, adding filters. I have attached an image of what I currently have. The field I have used in the view (sections) is called field_channel_section. In the auto preview I can put in TV and it will show me a list of the articles on that section, but on the actual page it shows nothing at all.

What am I doing wrong?


texts:
I have a vocabulary (lets name it as 'Brands') which is getting filled by adding terms while creating a nodes.

I have a view which shows me the list of those nodes. This view has an exposed filters including the one filters nodes by Brand. There are nodes which must relate to all 'Brands'.

It is not possible to assign manually all existing brands to node while creating it because the vocabulary is kinda dynamic. That means they should pass filter with any term checked. Not when 'All', but when any of existing. It seems to be obvious but I can't see any way I can do that.


texts: How to approach implementing a custom page header for each page

texts:
I am building a site that gives the content managers the ability to craft a masthead image, teaser text, and headline text for each individual page. This will appear in an area outside of node.tpl and -- anyway -- can also appear on taxonomy index pages, etc.

My current approach involves creating a Header content type and adding an EntityReference field to each entity I use in the site, then modifying page.tpl.php to look for and render that field. But is there a smarter approach?

Edited

The site is a multilingual site, so I'm looking for something that supports i18n. That lets Field Collection out, unfortunately.


texts: Get view result with sorting option programmattically

texts:
I've a view with sorting, that I need to call programmatically like,

$view_name = 'view_name';
$display_id = 'page';
$exposed_input = Array
(
    ['field_year_value'] =>
    ['shs_term_node_tid_depth'] => All
    ['field_federal_entity_value'] => All
    ['order'] => title
    ['sort'] => desc
);

$exposed_filters = Array
(
    ['field_year_value'] =>
    ['shs_term_node_tid_depth'] => All
    ['field_federal_entity_value'] => All
)

$view = views_get_view($view_name);
$view->exposed_input = $exposed_input;
$view->exposed_raw_input = $exposed_filters;
$view->set_display($display_id);
$view->pre_execute();
$view->execute();

But the result is not sorted.

Is there a way to accomplish this?


texts: Show content title in front page and full page when click

texts:
I want to add comments,post,follow to full node, it work with little sucees with view but i was unable to add comments, post, follow to full article post.

I have a content type called News it will only be showing article title in front page and article full node when clicked. The full node posted will have Add coment, Post, follow

The main problem now is how can i add comments, Post, follow likn to full node.


texts: Drupal Search Api reverse entity relations

texts:
I have a node which have entity reference to user,In search API,my need is to         take user as type,how can i get this relation in search fields as for now iam getting no relationship between them

Thanks


texts: Drupal Commerce - using rules to send different emails for Bank transfer and Cash on Delivery Payment

texts:
I have setup eshop (Commerce Kickstart) with two type of payments: Bank Transfer and Cash on Delivery.
I need to send different emails for selected payment method (Bank Transfer or Cash on Delivery).

I have decide to use rules for it.
For Cash on Delivery payment I have used default message "Commerce Order: order confirmation" - commerce_order_confirmation from Commerce Kickstart.

For Bank of Transfer payment (in admin/structure/messages) I have created cloned message of "Commerce Order: order confirmation" message - commerce_order_order_confirmation_bank_transfer)

Next I start to define new rule for Bank Transfer by cloning default rule for sending "Commerce order message: order notification e-mail - rules_commerce_order_message_order_notification" to rules_commerce_order_message_order_notification_e_mail_bank_tran.

In cloned rule I have changed only element "Create enitity" from commerce_order_confirmation message type to commerce_order_order_confirmation_bank_transfer message type.

But It makes error in "Set data value" element:
"Data selector entity-created:message-commerce-order for parameter data is invalid."
What is wrong? Thank you.

Here is cloned rule which make an error -

rules_commerce_order_message_order_notification_bank_tran:

    { "rules_commerce_order_message_order_notification_e_mail_bank_tran" : {
    "LABEL" : "Commerce order message: order notification e-mail (Bank Transfer)",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "4",
    "REQUIRES" : [ "rules", "message_notify", "commerce_checkout" ],
    "ON" : [ "commerce_checkout_complete" ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "message",
            "param_type" : "commerce_order_order_confirmation_bank_transfer",
            "param_user" : [ "commerce-order:owner" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:message-commerce-order" ],
          "value" : [ "commerce-order" ]
        }
      },
      { "entity_save" : { "data" : [ "entity-created" ], "immediate" : 1 } },
      { "message_notify_process" : {
          "message" : [ "entity-created" ],
          "save_on_fail" : 0,
          "save_on_success" : 0
        }
      }
    ]
  }
}

Here is rule used for cloning - rules_commerce_order_message_order_notification:

    { "rules_commerce_order_message_order_notification_e_mail_bank_tran" : {
    "LABEL" : "Commerce order message: order notification e-mail (Bank Transfer)",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "4",
    "REQUIRES" : [ "rules", "message_notify", "commerce_checkout" ],
    "ON" : [ "commerce_checkout_complete" ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "message",
            "param_type" : "commerce_order_order_confirmation_bank_transfer",
            "param_user" : [ "commerce-order:owner" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:message-commerce-order" ],
          "value" : [ "commerce-order" ]
        }
      },
      { "entity_save" : { "data" : [ "entity-created" ], "immediate" : 1 } },
      { "message_notify_process" : {
          "message" : [ "entity-created" ],
          "save_on_fail" : 0,
          "save_on_success" : 0
        }
      }
    ]
  }
}


texts: How to check if user has passed the quiz already before granting user points?

texts:
I'm awarding users points for passing a quiz successfully. However, there's nothing stopping the user taking the quiz again and again to score more points.

I have thought of these options, but I don't know how to implement them:

check if the user has achieved a certain score before awarding points
lock down the quiz for users who have already passed it, redirecting them to their results page
tagging the quiz with users ID when they complete it the first time and and denying points when they complete it again.

Any help?


texts: How to make a non-Drupal page and where to place it?

texts:
I need to create a page (it's receipt) which is not drupal-page. How it should work:

User clicks the link in "User Menu" or in "User Profile"
This link is made from link to custom page itself and user's $POST parameters (name and address fields, for example).
This page consists of HTML tags, CCS styles and PHP $POST-parameters and finally creates a PDF (to print).

I know how to make modules and use Hooks (I made custom registration), and I can use Drupal database (normal and fields entries). But how I should realize this task? And where I should place my custom page's file?


texts: How to run Drush commands on a schedule?

texts:
I'm deploying content to Drupal remotely (I'm in an Enterprise environment) and I need  something to run Drush commands based on a schedule. E.g on a cron task, read commands from the database table or file, execute the commands and record the result.

I've looked at the Rules and Job Schedule modules, but they don't really work because I need to enable Features.

I was thinking of creating a module which reads commands from a database and executes the commands in php. But is there a better way to do this?


texts: How can I override date field validation?

texts:
I'm overriding the date field to hide the "day" part with this code:

function MYMODULE_form_MYFORM_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['#after_build'][] = 'MYMODULE_date_remove_day_after_build';
}

function MYMODULE_date_remove_day_after_build($form, &$form_state) {
  $form['field_MYFIELD']['widget'][0]['value']['day']['#value'] = '15';
  $form['field_MYFIELD']['widget'][0]['value']['day']['#attributes']['class'][] = 'element-hidden';
  return $form;
}

This hides the day and allows the user to input the month and year.  If the field is required, everything is fine.

However, if the field is not required, and the user does not input any value on the form, then the form validation fails because the day of the date field has been set to 15, and the date module validation only accepts "every part (year + month + day) filled out" or "no part filled out."

So, on this specific field in my content type, I want to disable the date module's validation for the "day" alone-- or, I just want to disable validation for the entire date field.  How can I do that?


texts: Query parameters from $_GET vs. using the Drupal menu path

texts:
Page callbacks can receive wildcard arguments through the Drupal (6 and 7) menu system and using this results in quite nice and clean URLs. Core uses this for things like loading the nodes by their node id. The alternative is to use straight query parameters from $_GET as usual in PHP. Core seems to use this in  a few places, for form redirects, the pager etc.

When would it be appropriate to bypass the menu system and just use a query parameter? What are the pros and cons of the two options for parameter handling?


texts:
I need to create a custom form and in it there is an address but I can't figure how to use the address field form.

There is a way to use the address structure defined in the Address field module?


texts:
I wrote a block in Drupal 8 to render a menu based on the http headers of the request, which contains the users' information from the idp. This menu is supposed to be different from user to user, but currently it is cached once it is generated when the very first user login to the website.

I have tried setting the cache max-age to 0, but it didn't seem to work at all. Then I tried the session of the cache contexts, but still those pages visited by previous users are cached. Neither did header:custid.

Here is a sample code

class MyBlock extends BlockBase{
  public function build () {
    return array(
      '#cache'=>array('contexts'=>array('session')),
     '#markup' => ...,
    );
  }

 ...
}

Thanks in advance for any help!


texts: Change the display name of a default field in Contact Form

texts:
In Drupal 8, I LOVE that there are default fields in Contact Forms for Name, Email, Subject, and Message...but in several of our forms those labels don't make sense.

For example, one form's primary use is to request an appointment, but I would like to use the Message field to ask if they have any other questions. Saying "Message" at the top of the box doesn't make sense, and I would like to still use the field but change the label to "Questions".

Is that possible to do without making another field and hiding the default field?


texts: How do I get the user's email in the user profile template?

texts:
I am trying to customize the user-profile.tpl.php file.

I can access the all custom fields using $user_profile['field_fieldname'], and I can even access the user picture using $user_profile['user_picture'], but I don't know how to get the user email.


texts: Related nodes by taxonomy term in a view block of drupal7

texts:
I want to show related nodes to the current node in a block using taxonomy terms.
In my site say x is my taxonomy vocabulary and x1,x2,x3,x4,x5,x6 and x7 are the taxonomy terms under it. A node could be tagged with any of these taxonomy terms.
Say node T is tagged with x2 and x3.
node W tagged with x3, x1 and x5.
node c tagged with x2 and x6.
node R tagged with x2 and x7.
F tagged with x4,x6.
H tagged with X2,x5.
Now when the node T is displayed I want items having any of the taxonomy terms similar to the current node i.e. X2 or x3 but the priority should be x2 i.e. list all the related nodes with x2 as tag first and then only with x3. so in the above case i need related nodes in the order C R H W? How is it possible by using views in drupal 7?


texts: Create a simple date formatter to be used in views

texts:
I am using Views Data Export to create a custom RSS feed that looks like

   My Title
   2012-05-12 22:33:00

Start date is a Date field provided by the Date module.

In order to achieve the date formatting on the second field I have to use the Plain formatter from the Date module to avoid theming tags. Unfortunately plain formatting, gives the raw date as stored in the DB ignoring timezone settings.

I have created a custom field formatter module to tackle this:

/**
* Implements hook_field_formatter_info().
*/
function rss_date_formatter_field_formatter_info() {
    return array(
        'rss' => array(
          'label' => t('RSS'),
          'description' => t('Displays a date as rss.'),
          'field types' => array('date', 'datestamp', 'datetime'),
    ),  );
}

/**
 * Implements hook_field_formatter_view().
 */
function rss_date_formatter_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
    $element = array();
    $settings = $display['settings'];
    $formatter = $display['type'];
    foreach ($items as $delta => $item) {
        $element[$delta] = array('#markup' => $item['value']);
    }
    return $element;
}

Problem is that no matter what I cannot set $element to return the localtime. $item['value'] contains a string of the date representation as it is stored in the DB (thus UTC). Converting it to a date and then back seems to output nothing. Also if I hardcode a string there, it seems the string is altered but I cannot find from which function this happens (eg. entering 'test' in the #markup returns '1est', like converting the first letter to a valid month (1-12).

Any clues on this? I never thought outputting a date in localtime without theming would be so hard.


texts: How to import an SQL file and COMPLETELY erase the previous one

texts:
I'm having a hard time with buggy modules and need to do a lot of installs, uninstalls and so on.

But even if I uninstall, the modules leave data on the SQL file, and the only way to start from scratch is a new install every time...

How can I save SQL files that will delete ALL older data when imported?

An fresh SQL file that doesn't contain any data of newly installed and uninstalled modules.

I've tried add drop dables and other settings, but it seems that once you install a module...it's too late..it keeps creeping back into the database, sometimes form dependencies also?


texts: View: display first value in a single field in field collection

texts:
Drupal 7, view 3 and field collection.
I have a custom content type with a field collection called personal detail.
Personal detail have 2 fields: name and contact.
Personal detail is zero to unlimited.
In view, I am able to display the values of 'name' field. The problem is there are multiple values for 'name' field. This caused me to have duplicated records (i.e. same node id appears more than once, because the 'name' field)
I only want to display the very first one value of 'name' field which is stored the order of a node.

Solution:
In Go to field collection in view's relationship (right column)

There is a statement: The delta allows you to select which item in a multiple value field to key the relationship off of. Select "1" to use the first item, "2" for the second item, and so on. If you select "All", each item in the field will create a new row, which may appear to cause duplicates.

So select "1" will show the first fields.


texts:
I am planning to use Quick tabs, and it has one neat feature to use a menu as a callback and it prints the content returned from it. But How can I use the callback to pass NID so that I can return content related to that node.

Ex:

Basic Page : node/1
callback : tabs_content

Tab 1 | Tab 2 | Tab 3

function tabs_content(){
  $nid = arg(1);
  // Fetch some content related to this node
  return $content;
}

But obviously arg(1) will not have nid as this function is called from quick tabs arg(1) will be some ajax call back. So how can I get node id ? I dont want to use sessions, want to keep it clean and simple.


texts: Allow an author of a comment to see their comment listed in the comment section of a node with a notice that the comment is in moderation?

texts: I seem to be getting a lot of duplicate comments on my site and I think it has to do with the fact that users do not see their comment right after submitting it. I have it set so that an admin must approve it before it is published. Is there any way to make it so the user can only see his own comment on the node before it is published with a little notice that tells them it is in moderation?


texts: Views Contextual filter: php code for getting the value from url

texts:
Im trying to set up a Contextual filter in drupal views based on the URL.

The contextual filter is operating with a text field that sets the node alias.

I have it working with "RAW value from URL" based on the position (parentpage/childpage/grandchild-page), but the position could change (only parents and child for example), so do i need to use the "PHP code", or is there a better way?

What i want to happen:

"If last section of page url, (grandchild-page), matches field set in contextual filter, then true (show fields).


texts: I have implemented hook_user_login(&$edit, $account) and some of custom fields from $account should be updated. I am doing this with user_save(). These changes are not visible in Simpletest. I have tried user_load() in Simpletest before login and after, no changes. The Values are being saved to the db but are not visible in Simpletest. Any Idea?


texts: How to get number of results from MySQL query without getting all result data?

texts:
For a Google Maps application, I built an AJAX call that dynamically checks whether there are markers in a given viewport range. All marker information is stored in a node (note that I am using projective coordinates x, y instead of lat,lng) and the text in the body field also matches a condition. The MySQL query is as follows:

var $text = 'Test';
$query = db_select('field_data_body', 'b');
$query->join('field_data_field_x', 'x', 'b.entity_id = x.entity_id');
$query
  ->fields('b', array('entity_id'))
  ->fields('x', array('field_x_value'))
$query->where('b.body_value LIKE :text', array(':text' => $text));
$query->where('x.field_x_value >= :num1', array(':num2' => $xmin));
$query->where('x.field_x_value <= :num2', array(':num2' => $xmax));
$result = $query->execute();
if ($result->rowCount() < $maximum) {
 process_data($row->entity_id, $row->field_x_value);
}

Now, whenever the amount of markers exceeds a number $maximum, a clustering mechamism sets in. For this purpose, I really need to

1) check if there a less than $maximum results,

and only in this case

2) pull that data and process it.

Since quite many markers are stored in my database, my MySQL query should be as slim as possible, ideally it would first only give me the number of results (similar to a COUNT* query) and pull the result data only if needed.

Can anybody advice me on whether my $query->execute()->rowCount() code does that job? Or does $query->execute() automatically pull all results, and rowCount() is a PHP counting routine? The $result object does not seem to contain the explicit data, therefore it seems plausible to me that the data might not have been pulled yet at that stage...

Thanks for your help!


texts:
What would it take to style tabs (of the MENU_LOCAL_TASK variety) differently for tabs that anonymous can't see.  I have various admin-only tabs that I'd like to automatically call out as admin-only tabs (so that my admins/mods can keep track of what normal visitors can and can't see).

Maybe something like a call to user_access() within the hook_menu's title_callback attribute and stuffing a css class in the menu title if anon fails?  This would mean adding this to every MENU_LOCAL_TASK though.  I was hoping for something a little more global/automated.

What about taking it one step further and having a css class on all links that would be hidden if anon were viewing the page?

Drupal 6.

My solution

Riffing on Andy's answer.

/*
 * Add css class to menu items that anonymous users don't have access to.
 */
function [themename]_menu_item_link($link)
{
    global $user;

    // Not necessary to do this for Anon
    if ($user->uid != 0) {
        // Temporarily impersonate Anon
        $original_user = $user;
        $old_state = session_save_session();
        session_save_session(false);
        $user = drupal_anonymous_user();

        // See if Anon has access to this menu item
        $map = explode('/', $link['href']);
        _menu_check_access($link, $map);

        if (! $link['access']) {
            $newStyle = array('attributes' => array('class' => 'non-admin'));
            $link['localized_options'] = array_merge($link['localized_options'],
                                                     $newStyle);
        }

        // Restore user
        $user = $original_user;
        session_save_session($old_state);
    }

    // Resume rendering of this link
    return theme_menu_item_link($link);
}


texts: Generating internal URL/redirect by path>

texts:
In the past I could set up redirects with drupal_goto using a simple path (i.e., node/1).

Is this not possible at all in Drupal 8? Everything I've seen relies on a route name but that requires either generating a page in a module or keeping a static note of a node id, which seems backwards.

If I use Url::fromUri(), I can't seem to use getRouteName() since it interprets that as an external URL (even though the domain is the Drupal install).

What is the best way to get the route name of an internal path?


texts:
In Drupal 8, you can use system blocks to show menus starting from different levels. For example:

Menu item 1 (level1)
--- Menu Item 2 (level2)
--- Menu Item 3 (level2)

Menu item 4 (level1)
--- Menu Item 5 (level2)
--- Menu Item 6 (level2)

When user is on a page linked by menu item 2 I want to have a block showing the following:

Menu item 1
    --- Menu Item 2
    --- Menu Item 3

What the main system block offers is the following result:

    --- Menu Item 2
    --- Menu Item 3

You see? I need the parent menu item of these menu items as well.

What I did so far is to define a custom block in my module:

class MainMenuBlockSecondLevel extends BlockBase {

  public function build() {
    $menu_name = 'main';
    $menu_tree = \Drupal::menuTree();
    $parameters = $menu_tree->getCurrentRouteMenuTreeParameters($menu_name);
    $parameters->setMinDepth(2);

    $tree = $menu_tree->load($menu_name, $parameters);
    $manipulators = array(
      array('callable' => 'menu.default_tree_manipulators:checkAccess'),
      array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
    );
    $tree = $menu_tree->transform($tree, $manipulators);

    $parents = $parameters->expandedParents;  // menu_link_content:dd7b39a6-c4c8-48dd-a1cf-92a755087c29

    $build['parent']['#markup'] = '
Parent
';
    $build['menu'] = $menu_tree->build($tree);
    return $build;
  }
}

With the $parents variable I get an array like that:

Array
(
    [0] =>
    [1] => menu_link_content:dd7b39a6-c4c8-48dd-a1cf-92a755087c29
)

Here it stops for me now. What is menu_link_content:dd7b39a6-c4c8-48dd-a1cf-92a755087c29 and how can I get the needed information like menu item title and path out of it?


texts:
Looking to do something along the lines of how kijiji.ca and redflagdeals.com manages their content based on the location chosen. I'm trying to use the getlocation module but I can't really figure out whether it's the right thing to try. I want the default location to be retrieved automatically through the ip address and then give the users the option to change the city which will corresponding with a change of content..

Just looking for someone to steer me in the right direction as I can't seem to figure this out..thanks!


texts: Programatically created node type does not display title field

texts:
I have created a new node type within a module (for Drupal 7). I have created fields for it programatically as well and they all display. The one problem I am experiencing is that the title field does not display. I am not sure how or where to look to fix this. The title field does display in the node type's manage fields display.

Here is the code for creating the node type in hook_install():

// define the node type
  $type = array(
    'type' => $machine_name,
    'name' => $t($parameters['name']),
    'base' => 'room_reservations',
    'module' => 'room_reservations',
    'description' => $t($parameters['description']),
    'has_title' => TRUE,
    'title_label' => $t($parameters['title_label']),
    'custom' => FALSE,
    'locked' => TRUE,
    'disabled' => FALSE,
  );

// set other node defaults not declared above
  $content_type = node_type_set_defaults($type);

// add the body field
  node_add_body_field($content_type, $t($parameters['body_label']));

// save the content type
  node_type_save($content_type);


texts: How to import a Text File from feeds CSV and map it to a File upload field with multiple values?

texts:
EDIT: This issue is directly related to how the Acquia hosting Platform handles private files, not webforms / feeds or feeds tamper.

I've got a site where I need to Migrate the users from a webform they were using, and convert those submissions into user accounts.

I am using Feeds (7.x-2.0-beta1+8-dev) and Webform (7.x-4.8) and feeds Tamper.

I've managed to map all the fields except the Attachment field which is of type File. The Attachment field has the ability to attach unlimited files. Here are the three options I have when using the Mapping section in Feeds importer:

When I export my CSV from webforms, my Attachment field becomes the parent of every field in my CSV, and won't run until I modify it by removing the Attachment key from the start of the CSV file. (This makes no sense to me.)

After removing the Attachments field I am left with:

  "Email","Name","Filesize (KB)"
  "testemail@example.com","http://dev.website.ca/system/files/webform/permits/genericfile.txt|http://dev.local488.evsite.ca/system/files/webform/permits/94ufos.txt","55"

In this CSV there is the Attachment field and the Email field. When the run the CSV import, the user is created but nothing is added to the file field. I've tried mapping the Name value to all the possible options and it doesn't seem to be outputting anything for me.

When there is multiple values in the Name field I am using the explode plugin, using | as a string separator.
 I'm just not sure if i'm suppose to pass in an array or values or am I missing a module or something? I've browsed several similar questions but they have to do with Image i'm just using text files.

I am just wondering how can I can use the Feeds User Importer to import a regular text file from a CSV file and have it uploaded to the File widget in the user's Account page?

Any tips in the right direction are highly appreciated.


texts:
When updating my module from Drupal 7 to 8 I bumped into the concept of cache tags and cache contexts. After reading both documentation pages, I have come to the following conclusions:

A cache tag is used to tell Drupal 'what is in the cache', so the cache can be invalidated once something in the cache is updated. This is mainly used for entities and configurations.

Cache contexts provide... context (duh), so the exact same set of tags (entities) can exist under multiple circumstances with a different cache. Examples for contexts are languages and themes, where the same set of entities need to be rendered differently.

Now I did find how to invalidate cache tags:

  Cache tags are invalidated using cache_tags.invalidator:invalidateTags() (or, when you cannot inject the cache_tags.invalidator service: Cache::invalidateTags()), which accepts a set of cache tags (string[]).

But I cannot find how to invalidate cache contexts...

The reason for asking this is because I am in the process of converting the white label module to Drupal 8. (This module allows the site name, logo and color scheme to be overridden initially based on a url token, but a session variable for subsequent pages.) So I thought such a whitelabel token would make up for an excellent cache context. However (probably on very low frequency) the parameters (name, logo, etc) could change. Thus I should invalidate the cache context.

Can I invalidate cache contexts? Or are there other options? I have thought of using a combination of both tags and contexts, but I am afraid the amount of combination will go through the roof...


texts: Set another page.tpl.php if a parameter is set

texts:
i want to use another page.tpl.php file, if die fb parameter is set.
The File is located in my theme folder and has the name "page-fb.tpl.php"

My Function in template.php

function THEMENAME_preprocess_page(&$vars) {
/** Facebook Output */
    if ( isset($_GET['fb']) && $_GET['fb'] == 1 ) {
        $vars['template_file'][] = 'page-fb';
    }
}

The function is called, but the new page-fb.tpl.php is not loaded.
I'm doing all of this on Drupal 7.

Any advices?


texts: Why is AJAX pager in Views not recording the history

texts: I have a listing of news, used with Views module in Drupal 7. I have activated Use Ajax in advanced section. So now the pager loads the content smoothly, without loading other page. That is nice, but the pager is not recording the history of the browser, so when I hit several pages of the same listing, it loads all the content perfectly but when I hit the Back button of the browser, instead of going to the last page clicked on the listing, goes to a previously visited site, even a different website, depending on my browser history. This happens, aparently, because there seems to be no built-in mechanism to record website history or at least change the toolbar address with "#" so it can have a behaviour similar to what be expected. Is there some way of circumventing this?


texts: I just switch from drupal 6 services 2 to drupal 7 services 3. I'm having  little trouble figuring out how to configure services, I'm used to being able to test different services using the services browser, but it seems like there is no services browser in services 3, does anyone have a good method for do these test?


texts:
I'm trying to create Paragraphs programatically, to store an Indesign File with the images linked to it, so I have my paragraph type with some fields

field_indesign_file : (limited to one value)
field_indesign_image : (illimited number of images)

Currently the creation is OK :

$paragraph = Paragraph::create([
  'type' => 'indesign',
  'field_indesign_file' => [
    'target_id' => $indesign->id(),
  ],
  'field_indesign_image' => [
    'target_id' => ${'image'.'3'}->id(),
  ],
]);

but I don't know in advance how many pictures I'll have attached to the indesign file, so Id' like to be able to add other values to the field_indesign_image.

I tried using

$paragraph->field_indesign_image[LANGUAGE_NONE][1]['value'] = [
        'target_id' => ${'image'.'1'}->id()
    ];

and

$paragraph->field_indesign_image->appendItem(
      [
        'target_id', ${'image'.'3'}->id()
      ]
    );

but none of this method worked, I didn't find a lot of documentation and sometimes answers to other topic are a bit too complicated for me to understand since I'm a beginner at drupal 8.


texts: Alternate solution to avoid handling a huge number of menu items

texts:
I am on Drupal 7 and I am facing a dilemma with a project I am building. It will be a content-rich website, which means lots, lots, tons of articles. When user enters an article page, I want him to see the website area (menu item) it is associated with selected on top of the page. Drupal will handle it if the content is associated with the correct menu during node creation.

My concern is that I will have a huge menu page. When I have 1,000 articles or so, the menu admin page will be a terribly long list of articles associated with the top menus. I would rather have only the top two levels in my menu structure but I still need the subpages (articles) to be shown as associated with a menu item.

The question is: is it possible to associate a content type with a menu item so that it isn't actually in the menu, but it can interfere with the menu rendering so as to add ACTIVE or ACTIVE-TRAIL classes to the desired menu items? Do I have to play with template.php in order to achieve that?

Also, if you think that associating these many articles with a regular menu item is the correct approach and that there is no problem to end up with a monstrous menu list, please, tell me.

I am sorry if the question isn't enough clear, I will try to clarify further if necessary.


texts: Is there a way to make a keyboard shortcut for Save on the node edit page?

texts:
It would save a lot of time not having to scroll to the bottom of the page to save edits to a node.

Are there modules which achieve this?


texts: How can an entity reference field be displayed as a select list that shows the selected entity?

texts:
The Problem

I have a couple of entity reference fields that references a hierarchy of nodes. For the sake of simplicity let's use just the top level example Video Game -> Video Game Release

So when I look at the video game "Assassin's Creed 2" I see two releases "Assassin's Creed 2" and "Assassin's Creed Ezio Trilogy".

Background info that isn't necessarily important to the question:

  ! The reason for the entity reference is on "Assassin's Creed Brotherhood" I would also have two releases "Assassin's Creed Brotherhood" and "Assassin's Creed Ezio Trilogy".

  Assassin's Creed 2 (Node: game, ID: 1)

  Assassin's Creed 2 (Node: release, ID: 2)
  Assassin's Creed Ezio Trilogy (Node: release, ID: 3)

  Assassin's Creed Brotherhood (Node: game, ID: 4)

  Assassin's Creed Brotherhood (node: release, ID: 5)
  Assassin's Creed Ezio Trilogy (Node: release, ID: 3)

When I view the node "Assasin's Creed 2" I'm currently seeing both releases one after the other. I styled these using display suite and they look fine. However I want to display only one of them at a time with a tab, select list, or something of the like to allow me to switch between them.

My thoughts

I was unable to find a module that could perform this but I feel one may exist.
I could use a simple jquery tab ajax but wasn't sure if their was already a drupal way to do this.
Perhaps I could use exposed views and a views embed field to show all the referenced nodes but then the performance would suffer significantly.

The question

How do I display an entity reference field as tabbed or select list content? Preferably without the performance drop of an embedded view.


texts: Drupal Commerce - Out of Stock, customer clicks to notify store owner to order more

texts:
When a product is out of stock, the store owner wants customers to have the ability to pre-order, without paying.
Similar to stock notify, but the store owner will manually email back customers once the stock arrives.
Something like'This product is out of stock, notify us, and we will order it in for you within 1 week.'

So it needs to collect: customer email and product SKU.
As many customers will be non-registered users, what would be the best way of capturing this data, and emailing it to the store owner?

I was thinking flags/rules module, or do you think a custom module would be simpler?

Thanks in advance.


texts: Can I truncate “field_revision_body” without breaking the site?

texts:
I am cleaning up a client's Drupal 7 site that has been badly hit by spam.  Both Drupal's Backup & Migrate module and the CLI tools such as mysqldump and mysql runs out of memory when trying to extract the single table field_revision_body.

My current understanding of things is that this table contains old versions of field_data_body. Provided I don't want to roll anything back, I believe I should be able truncate field_revision_body without breaking the site.

However, since I am unable to make a backup of the database in its present state, I want to check if I've understood this correctly before engaging in  something that cannot be reversed.


texts: How to restrict access to content based on roles (multiple levels) and show a public preview?

texts:
I'm looking for a reliable solution for the following situation:

a membership site with multiple levels of access for users (based on roles, say anonymous, and levels 1 through level 4)
need to restrict node view access by role on a per node basis, but allow anonymous access to the teaser (should be possible to show/restrict other fields as well)
take performance and flexibility into account

There are several modules that solve most of the problem, but not entirely. I'm looking for recommendations on the combination of modules to use, and whether I'd need to extend any of these with custom code or if just combining contrib modules is feasible.

Premium content offers the basic functionality, but it seems to only work for the regular body field. Is it still a good option if you want to publically show or restrict other fields? (e.g. restrict the body as well as another text or file field).
Taxonomy Access Control: I like how you can easily change the access level per node by just changing the assigned taxonomy term. But how would I allow anonymous access to the teaser or other fields?
Field permissions offers all the granularity on the field level I would need, but I need the option to restrict one field (e.g. node body) to different roles on a per-node basis.
Or maybe do something with Panels (cf. this answer)?

A solution that plays nice with other modules (e.g. Views) is preferred (I think TAC would qualify here - e.g. filter by taxonomy, maybe use VBO for changing terms...).

How would you do this?

Update: I've looked into using Panels; whle I like the flexibility that a Panels-based approach offers, I doubt it's feasible for my use case.

Using Panels, the selection rule would have to be based on a combination of current user's role and node being viewed's term id, so for each selection rule you'd need 2 criteria and the 'All criteria must pass' setting. So each access level (except 'Anonymous') needs two variants: one for the combination of tid + roles that get to view the teaser, and one for tid + roles that get the full node.

Since there are 5 roles to take into account (anonymous + roles A, B, C, D) I'd need 9 page variants. This doesn't feel quite elegant, or would 9 variants be acceptable? (thinking about performance, maintainability etc.).

Another problem is that the Term ID criterium in the selection rule is per Content type, so if I wanted to use this for multiple content types I'd need even more variants. Since I need the 'All criteria must pass' setting for the combination of role and term id, I cannot add term id of two content types in one selection rule.

Another option would be to use PHP for evaluating the selection rule, but that feels like it may be defeating the purpose of using Panels. And code in DB is not a good idea, etc.

So unless I am overlooking a simpler way with Panels, it doesn't seem such a good idea (except maybe with custom PHP for selection rules...)?


texts: Context module not triggering Delta snapshot

texts:
I am using the Omega theme, and have the Delta and Context modules enabled. I created a Delta snapshot, and then created a Context to load that snapshot on the front page.

I created the context Condition -> path -> <front> and Reaction -> Delta -> Select Custom theme settings template. However, when I load the front page, the new snapshot doesn't load - it reverts back to the 'standard' Omega layout that I created.

I've tried deleting and recreating both context and snapshot, and clearing cache. I can't figure out what I'm missing.

Thanks for the help


texts: Show links only to sub menus items, not to parent menu

texts: I added some links to Main menu and created sub links for it. Now the problem is that I've to give url to the parent menus of sub links. I want it to be disabled. Links should be for sub menus only. How can I do it. Please help. In the pic, I don't want link for 'Contact us


texts: Banned IP address is still able to access the site

texts:
I've blocked the IP address at admin/config/people/ip-blocking and I can see it also in the flood control logs as a blocked IP, but the IP is still accessing the site and I can see errors in the watchdog with their IP address after the block...

I'm at a complete loss as to how this could be... google and SE search has brought nothing. Why isn't Drupal blocking this IP?

Edit: I tested it with a firend's IP and it's not blocking him either, so I guess my IP blocking is not working at all...


texts:
According to Counter JsInclude

(I've defined the library in the theme.libraries.yml and attached the library in the theme.info.yml and it shows in the header)

statcounter:
 version: 8.x-1.0
js:
 scripts/jquery.counterup.min.js: { minified: true }
dependencies:
 - core/jquery

HTML

1,234,567.00
$1.99
12345

(Have added this in a block in the front page and the markup is displayed)

jQuery

$('.counter').counterUp(); **or with extra parameters**
$('.counter').counterUp({
delay: 10,
time: 1000
});

(Have placed the jquery in a separate custom js; and defined it in the theme, the js is loaded and no errors till now)

   custom:
    version: 8.x-1.0
   js:
    scripts/custom.js: {}

I want to attach the last bit of jquery to the theme and make the counter work...Any ideas how to get it to work? Thanks.


texts: Integrate Drupal with Extensis Portfolio?

texts: Our organization uses Drupal (6 and 7) for our websites, but Portfolio Server for our DAM and photo collections. It would be wonderful if there were a way to import images directly from Portfolio into Drupal without needing to export them and reupload. Is such a thing possible? I couldn't find any modules on drupal.org that would do this (unless there's a way to use services to access an api on portfolio...)


texts: Entity filed query for sorting by title and weight both?

texts:
"i need to display data in alphabetical oredr if weights are in same number(1,1,1)condition ,if weights like(1,2,3) condition need to display data weight based ASC order" i'm using below code alphabetical sorting working good in same weights condition, but weight based condition not working please help me

               $query = new EntityFieldQuery();

               $query->entityCondition('entity_type', 'node')

              ->entityCondition('bundle', 'closing_team')
              ->fieldCondition('field_homebranch', 'tid',   $node->field_closing_team_categories['und']['0']['tid'])
              ->fieldCondition('field_featured','value','No','=')
              ->propertyOrderBy('title', 'ASC');

              $result = $query->execute();
              $nids = array_keys($result['node']);
              $news_items2 = node_load_multiple($nids);
                /*echo "<pre>";
                print_r($news_items2);
                echo "</pre>";exit;*/

             function element_sort1($a, $b) {
             $a_weight = (is_array($a) && isset($a ['#weight'])) ? $a ['#weight'] : 0;
             $b_weight = (is_array($b) && isset($b ['#weight'])) ? $b ['#weight'] : 0;
             if ($a_weight == $b_weight) {
              return 0;
                }
            return ($a_weight > $b_weight);
                }

?>


texts:
I come across different type of image crop, but the only one seems to work on the profile image is Image Javascript Crop like says this answer.

The problem so far is that i need to crop the image on upload.
I can't find any way. Is there any way?


texts: Ajax HTTP error occured. HTTP Result code: 200

texts:
I get Ajax error when I click next button. You can test it here.

I have found out the problem. It is due to the custom module which I have made.

<!DOCTYPE html>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<?php

/**
 * Implements hook_block_info().
 *
 * This hook declares what blocks are provided by the module.
 */
function custom_module_block_info()
{
    $blocks['tag_cloud'] = array(
        // The name that will appear in the block list.
        'info' => t('Custom Moudle'),
        // Default setting.
        'cache' => DRUPAL_CACHE_PER_ROLE
    );
    return $blocks;
}

When I remove the first two line (Doctype and meta). It works fine. But If I remove first two lines. It doesn't work on IE. I had to insert these two statements to get it working on IE. Now If I keep these two lines, it causes Ajax error, and if not It doesn't work on IE.

Can anyone help?


texts: htaccess multisite config crashed after sites move to other host

texts:
I am on my long way to move my D6 site to other hosting company. It was hard but finally seems it's almost done but I am stacked on multisites configuration.
Situation is like this:

Drupal folder (from ftp/apache access point of view)

/webs/drupal/site  (main )
/webs/drupal/site/sites (multisites)

domains:

www.a.com
www.b.a.com

point to:

/webs/drupal/

/webs/drupal/.htaccess file

#redirect to */site
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?b.a.com$
RewriteRule ^(/)?$ site [L]
RewriteCond %{HTTP_HOST} ^(www.)?a.com$
RewriteRule ^(/)?$ site [L]

/webs/drupal/site/.htaccess

it's standard D6 .htaccess with "always add 'www' prefix" rule on

The problem is that I can:

access default site using all combinations like www.a.com, a.com, a.com/site
access subsite like www.b.a.com/site

but all calls like:

www.b.a.com
b.a.com

redirects to the main site www.a.com/site ...

Any ideas?


texts: How to let the user add a block based on a layout choosen with display suite?

texts:
I'm using DS with view_mode_page to display a page of this view mode. E.g. cType House with view_mode "bathroom" is displayed on url:

house/foohousetitle/bathroom.

For this display I choosed a layout 3 colums. Everything is working well.

I want to expand this so that the user can add blocks in the first and second column of this layout. How to do this? If I use the standard drupal blocks it is displayed outside the choosen layout.


texts: How to display all nodes by user on his profile page

texts:
I want to create a view of "users" /profiles/<RealName> which lists selected fields from user content type. I accomplished this. But now, I want the same view to display selected fieds from the nodes created by this user.

I tried to do it by myself, but I'm unable to add relation to desired content type.

PS: I'm a newbie so kindly throw some details in your answer.


texts: Is there a simple way to change colors of a site with bootstrap theme?

texts:
I'm migrating from drupal 7 to drupal 8.
I'm visually empaired, so, a friend helped me to set colors on drupal 7 with bartic theme and color module.
For my new drupal 8 web site, I want to use bootstrap theme, 'cause is more accessible.
I saved colors code in a .txt file and want to set for my bootstrap theme.
I know I have to use sass for colors, but my firend can't preview the result.
I'm wondering if there is a way to preview color before inserting them in bootstrap theme: a module, for example, similar to color module.
Can someone help me?


texts:
I am using latest version of Organic Groups module. And create a page with panel page to view this group (classroom) content type. After that I added group_group field to subscribe user in this node.

But when user is going to subscribe, this path look like:

siteURL/group/node/63/subscribe/og_user_node

But I want to customize this path which look like:

siteURL/classroom/subscribe/?classroomId=63

It's not necessary to make it (siteURL/classroom/subscribe/?classroomId=63)

But I want to remove "group/node" & "og_user_node" from url and replace with other word.

Thanks for your kind help.


texts: Parsing a multi-valued theme-setting into to two defaults results in theme-settings not saving

texts:
The intention here is to parse out the two integers on either side of the dash, and save them as separate defaults. The problem I'm running into is nothing will actually save when I submit the theme-settings form, it just keeps resetting to the defaults and not the new value selected prior to saving.

dpm'ing the output variables from the grid array returns the exact same results as dpm'ing the theme-get-setting return if I do it using the method at the bottom of the post.. so i am at a loss on why this doesn't save new values when the theme-settings form is submitted.

Here is an example of the setup:

.info values

settings[user_first_wp] = '6-1'

theme-settings.tpl.php:

$grid = array();
list($grid['user_first_width'], $grid['user_first_pos']) = explode('-', theme_get_setting('user_first_wp'));

// User group first position.
$form['gaia_settings']['layout']['user']['1'] = array(
  '#type'          => 'select',
  '#title'         => t('Position'),
  '#attributes'    => array('class' => array('col-position')),
  '#default_value' => $grid['user_first_pos'],
  '#options'       => $pos_options,
);

// User group first width.
$form['gaia_settings']['layout']['user']['1'] = array(
  '#type'          => 'select',
  '#title'         => t('User 1 Width'),
  '#attributes'    => array('class' => array('col-width')),
  '#default_value' => $grid['user_first_width'],
  '#options'       => $width_options,
);

Doing it this way (below), does actually work, but I'd much rather keep multiple values in the same theme-setting default.

.info

settings[user_first_width] = '6'
settings[user_first_pos] = '1'

theme-settings.tpl.php

// User first position.
$form['gaia_settings']['layout']['user']['1'] = array(
  '#type'          => 'select',
  '#title'         => t('Position'),
  '#attributes'    => array('class' => array('col-pos')),
  '#default_value' => theme_get_setting('user_first_pos'),
  '#options'       => $pos_options,
);

// User first width.
$form['gaia_settings']['layout']['user']['1'] = array(
  '#type'          => 'select',
  '#title'         => t('User 1 width'),
  '#attributes'    => array('class' => array('col-width')),
  '#default_value' => theme_get_setting('user_first_width'),
  '#options'       => $width_options,
);


texts: Edit user account how to check before update if the role check box is selected?

texts:
I have a module that when my user changes the user details hook_user onupdate, pushes these details to an external database. However I would like this to only work when role X is selected, else my module will not do anything. The role will not be in the users profile as this processing is happening before I update the users account.

Drupal 6
Thanks

Update

 function checkrole_user($op, &$edit, &$account, $category = NULL){
 switch($op){
 case 'submit':

  if ($edit['roles'] == 'Staff'){
  do xyz
    }

  }


texts: How can I add an operation to the node and user lists?

texts:
I am looking for a way to add entries in the "Operations" Column at:

/admin/people

and or

/admin/content

I considered hook_node_operations and hook_user_operations

But those are for adding commands to bulk operations.


texts: How can I set a custom CKEditor on only one field?

texts:
I'm using Drupal 8.

I have a field that can only allow for specific styles, so I created a custom CKEditor and set the field to use it.

Now when I go to the field on the content edit form, I see the custom editor as the default, as well as a select menu to specify which editor I want to use to enter content.

When editing this field, I do not want to show any other editor options and I only want the editor to be used for this field.

What is the best way to implement this functionality?


texts: how do you add a cookie policy to the site so it appears when a user arrives?

texts:
Possible Duplicate:
  eu cookie compliance

I think this is now a legal requirement in the uk so I want to add one but I have not been able to find a module to do it. Has anyone found one or achieved it by doing a workaround?


texts: How to periodically deduct user points for flagged nodes?

texts:
I have a node which is published. And I have a global flag, which users have to mark to make nodes visible in Views. This is easy to do.

But then I need to charge 40 user points for every day that node remains flagged. And when user doesn't have enough points anymore, then node must be unflagged.

Possible realization what I tried:

via CRON: I tried to make a rule for that, but when I add an Event (= On CRON Run), then I cannot add an action with user points. Some people say it should be an extra script for cron, but I don't know how to make it.

via Rules: I tried to make a rule on Event "When node is flagged" and make a Scheduled Rule with the same -40pts for user nextday. It works only once until the Scheduled Rule completed or until cron is running. So I cannot make a loop properly.

I've no more ideas to get it working. Maybe I just lost something while making Rules?


texts: Webforms: pages 1,2 of 4 not being displayed

texts:
I'm developing my first Drupal 8 Webforms application. It had three pages to start with and I had managed to get it to do what I wanted it to. I have also developed a WebformHandler to go with it.

I needed to add an extra page between the old 1st and 2nd page. I created this using the "build" tab and it was created in 4th position in the list of pages, so I dragged it up to 2nd position and did "Save Elements".

But then, when I used the "View" tab to try out the form, the dialogue started at the 3rd page (the old 2nd page). I have now deleted the new 2nd page and appear to have the same old configuration that worked, but using the "View" tab still ignores the first page.

I have flushed all the caches; I have looked in the database for anything obvious (but not found anything); I have looked at the YAML files in the module I created for the Webform; I have even rebooted the server.

I have tried to scan the entire Drupal file tree looking for files that have been modified in the last couple of hours (since the webform last started correctly), but I haven't managed to find anything, except the WebformHandler, but that isn't called before the initial page is shown.

Using a different browser (Safari instead of Chrome) produces the same result, so I guess the problem is on the server and not the client.

Somewhere, something is holding information about my webform: could anyone help me to locate it?


texts: REST request through Actions and Triggers

texts:
In Drupal, I can define a Advanced Action in Administration>Actions , but the available options do not have a Send REST request option, how do I achieve what I want?

In my case, I want my remote service to know about a new node is being created, so I need to send the nid to my service.

I've thought of one dirty hack though, which is to use Redirect to URL and send my request through URL:

My server will receive the data it needs(which is the nid), and redirect the user back to their content using [node:id].

But like I said, this is more of a hack, is there a proper way of doing this?


texts:
I'm using D7 and I have a custom content type (Client) and I have a custom select list field for the User entity displayed in a custom block.

I have a custom display layout for the Client content type, wherein all fields are displayed in different blocks using Display Suite. The user's name is displayed only when the user field is enabled in the node main content, else it remains blank.

How do I display the username in the block without the need to keep the field enabled in another part of the node view?


texts:
Sites such as StackExchange use URLs that contain a page code and some additional keywords, possibly for SEO. If you change anything in the additional keywords, you are still redirected to the correct long URL.

Example: the following links redirect to the same page:

drupal.stackexchange.com/questions/724/why-is-drupal-7-so-slow
drupal.stackexchange.com/questions/724/

As long as the page code (/questions/724) is in the link, it is valid. So, we can construct many links that still resolve to the same page, e.g.

drupal.stackexchange.com/questions/724/old-page-title

This is very interesting for future-proof URLs, as the title of a page could change, but the URLs would still redirect to the correct page.

Can this be accomplished by using existing Drupal modules?


texts: Why isn't the custom validation handler fired in hook_form_alter()?

texts:
I am adding a custom validation handler to the node edit form, using the following code.

function my_module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id != 'node_article_edit_form') {
    return;
  }

  // ...

  $form['#validate'][] = 'my_module_node_article_edit_form_validate';
}

function my_module_node_article_edit_form_validate(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  // ...
}

The validation handler is not invoked, though. What is wrong with the code I am using?


texts:
I'm using Drupal 7.38 with the Disqus (version 7.x-1.12) module.

Disqus simply fails to load.  No trace of it in the console, elements or sources.

Disqus visibility is set to appear in  block as per /admin/config/services/disqus and block is configured. Its "permissions" are configured properly also.

Disqus was previously working.


texts:
I have a form function called mymodule_join_form in MyModule and differentmodule_form_mymodule_join_form_alter in DifferentModule. It's not being called, though (I put `echo 'hello';die;)

I can get to it using form_alter with if (form_id == 'mymodule_join_form'), but shouldn't the first way work?


texts: Default user relationships with the site admin

texts: I am using the User Relationships module for my Drupal7 site. I have created a one way relationship with reciprocal by the name "Follower". So if User A can be followed by User B. Also, User A can follow User B. Now i set out in the process of creating a default relationship. I did that but it works only one way. I want that by default all user follow and are followed by the ADMIN. the default relationship that i created through the CMS works fine but it works only one way. I see that Admin is following the users but not vice-versa. Also, this happens only for new users of the site. I do not see old users having that default relationships. How can i achieve that? Any suggestions.


texts: How do I add 2 blocks side-by-side in Bootstrap theme's "Content" region?

texts:
I have block views on the first page in the "Content" region of the Bootstrap theme that I would like to display as follows:

 _________________
|                 |
| another block   |
|_________________|
|        |        |
| block1 | block2 |
|________|________|

Is there a way to do this easily, without using float left/right for block1/block2 (as Bootstrap using a grid layout using rows and columns)?

Normal Bootstrap syntax would make block1 go in the first
 element and block2 go in the second
 so that the two blocks appear as equal-sized columns.

I see that regions are laid out in themes/contrib/bootstrap/templates/system/page.html.twig.

If there is not an easy way to achieve the desired layout, do I need to somehow create a twig template, similar to page.html.twig, in my Bootstrap subtheme that defines say 2 side-by-side regions under the existing "Content" region (i.e. "Sub-Content Left" and "Sub-Content Right" regions)?  If so, how is this done and how to make the template apply to a specific page?

I looked into Bootstrap Layouts and Display Suite, but it wasn't clear how to integrate the two to accomplish the above.

Thank you very much in advance for your help.


texts: Wrong node type config used after switching databases with db_set_active()

texts:
I have a use case where I need to import selected nodes from one D6 site to another and since I have access to both databases, I figured I'd use a custom drush command to select the nodes I wanted from the exporting site and then import them into the receiving site, using db_set_active() to switch between databases depending on what I'm doing.  Here's the code I have so far:

function cnsnews_import_mrctv_videos() {
  // First, get defined mappings from the cnsnews_mrctv_import.
  //$mapping_result = db_query("SELECT * FROM {cnsnews_mrctv_import}");
  // Debugging line that only gets one category.
  $mapping_result = db_query("SELECT * FROM {cnsnews_mrctv_import} LIMIT 0, 3");
  while ($mappings = db_fetch_object($mapping_result)) {
    $mapping[$mappings->mrctv_channel] = $mappings->cnsnews_channel;
  }

  // Get variables that store the last nid imported.
  $last_imported_video = variable_get('mrctv_import_last_nid', 0);

  //Next, switch over to mrctv db to get a list of all of the video nodes.
  db_set_active('mrctv');

  foreach($mapping as $mrctv_channel => $cnsnews_channel) {
    // Get all nodes for the channel.
    $sql = "SELECT nid FROM {og_ancestry} WHERE group_nid = %d AND nid > %d";
    $result = db_query($sql, $mrctv_channel, $last_imported_video);
    $imported_nodes = array();
    while ($record = db_fetch_object($result)) {
      $video_node = node_load($record->nid);
      $import_nodes[$mrctv_channel][] = $video_node;
    }
  }
  // Switch back to cnsnews database to begin importing nodes.
  db_set_active('default');
  // Clear out the content_type_info cache entry.
  cache_clear_all('content_type_info:en', 'cache_content');

  foreach($import_nodes as $mrctv_channel_id => $video_nodes) {
    // Get the taxonomy term
    $cns_channel_tid = $mapping[$mrctv_channel_id];
    $cns_channel_term = taxonomy_get_term($cns_channel_tid);
    foreach($video_nodes as $video_node) {
      // Create new node object.
      $node = new stdClass();
      $node->title = $video_node->title;
      $node->type = 'video';
      $node->uid = $video_node->uid;
      $node->body = $video_node->body;
      $node->teaser = $video_node->teaser;
      $node->taxonomy[$cns_channel_tid] = $cns_channel_term;
      // Set video field values
      $node->field_video_upload = $video_node->field_video;
      // Modify some settings for CNS.
      unset ($node->field_video_upload[0]['filename']);
      unset ($node->field_video_upload[0]['fid']);
      $node->field_video_upload[0]['data']['dimensions'] = '800x600';
      $node->field_video_upload[0]['data']['player_dimensions'] = '640x480';

      node_save($node);
    }
  }
}

I have the default and mrctv databases defined in settings.php.

The issue I'm having is that when I've switched back to the default database and try to import, the field_video_upload field isn't being saved.  I stepped through the code from the content module starting at the node_save() call, and when it is loading the content type fields in _content_type_info() it is getting the info for the video node type in the mrctv database, not the default database.  This is happening even though I am clearing the content_type_info:en entry in the cache_content table.

Is there another cache entry I need to clear out to be able to do this?

Thanks.


texts: How do I create multiple nodes on the same page?

texts: Im on d7. I am trying to create node submission process where I can create multiple nodes on the same submit page and have them all reference a single separate node on the site. any suggestions?


texts: Avoid duplicate hits in two separate Views

texts:
I'm using Views to generate a number of lists, e.g. Newest articles and Popular articles.
Now, often newest articles will also be in the Popular articles list.

So when I'm using both views on frontage, I would like to prevent, that the same article is shown on both lists.

So basically skip articles in Popular list, if they also are available on Newest list.


texts: Problems installing drush 7.0 on Windows

texts:
I've been using drush 6 quite happily on a Windows machine (where I'm testing Drupal 7 sites) for some time, installed if I remember rightly using an MSI installer, under "Program Files". I'm working behind a proxy so had to alter the drush/gunwin32/etc/wgetrc file in order to enter the proxy settings.

Since downloading the service_container module drush 6 no longer works on that site, it keeps giving me "Can't inherit abstract function" errors. So I thought I would try upgrading to drush 7.0

But how to do this? I downloaded the zip file and can successfully execute drush commands from the Windows command line. However there appears to be no msi installer (so there is no "drush" command, you must run drush.bat), nor can I see a drush.sh command (for example) to run drush under Git Bash shell, and above all I cannot find anywhere to configure my proxy settings - so I'm a bit stuck!


texts: Caching interfering with jQuery and drupal behaviors?

texts:
I'm on the new side to coding so this is mysterious to me:

On several sites that I'm working on the jQuery library stops being added through drupal behaviors spontaneously as javascript and module files and page templates are altered.  Once the site cache is cleared through drush the behaviors properly call jQuery again.

I work with 3 others, and though our database is centralized our file trees are local. We use git for version control.

Any information as to why this caching incident keeps happening would be very helpful.  I'm trying to learn more about the caching process but so far I haven't found anything that clears this up.


texts: drupal template files in different folders for different content types

texts:
I'm trying to get Drupal to scan multiple directories to find template files for pages and nodes. I have a content type called "contest". I have a node with the path of "http://mysite.com/contest/test
I'd like to have a folder structure like:

templates
    page
        page.tpl.php
        page-front.tpl.php
    node
        node.tpl.php
    contest
        contest.tpl.php
        contest-test.tpl.php

Drupal is not finding contest tpl's.


texts: Programmatically pass parameters to Apache Solr integrated with Search API

texts:
I'm currently trying to enable spellcheck results with the search api. If I visit my apache solr server directly with http://myserver:8983/solr/d8/select?q=goood+worksd&spellcheck=true and provide the keywords and set spellcheck to true in the url parameters

I receive expected results

  {   "response":{"numFound":0,"start":0,"docs":[]   },   "spellcheck":{
      "suggestions":[
        "goood",{
          "numFound":1,
          "startOffset":0,
          "endOffset":5,
          "suggestion":["good"]},
        "worksd",{
          "numFound":1,
          "startOffset":6,
          "endOffset":12,
          "suggestion":["worked"]}]}}

In the response I can see the spellcheck information I need in the spellcheck section.

However when I set the options programmatically before doing the query with the search api I don't receive any of this information.

    $index_id = 'default_solr_index';
    $index = \Drupal\search_api\Entity\Index::load($index_id);
    $query = $index->query();
    $parse_mode = \Drupal::service('plugin.manager.search_api.parse_mode')
        ->createInstance('terms');
    $parse_mode->setConjunction('AND');
    $query->setParseMode($parse_mode);
    $query->keys($search_terms);
    $query->setFulltextFields(['title', 'body_field_parse', 'type','field_description','name','body','field_title','field_summary']);
    $query->addCondition('status', 1);
    $query->sort('search_api_relevance', 'DESC');
    $query->setOption('spellcheck','true');
    $executed_query = $query->execute();
    var_dump($executed_query->getAllExtraData());

When I var_dump($executed_query->getAllExtraData()) all I get is

  { ["search_api_solr_response"]=> array(1) { ["response"]=> array(4) {
  ["numFound"]=> int(0) ["start"]=> int(0) ["maxScore"]=> float(0)
  ["docs"]=> array(0) { } } } }

I've done all kinds of variations giving true instead of 'true' and adding other options like

$query->setOption('spellcheck','true');
$query->setOption('spellcheck.build','true');
$query->setOption('search_api_spellcheck','true');
$query->setOption('spellcheck.extendedResults','true');

But nothing seems to work. I saw a spellcheck search api module someone posted but I couldn't get it to work and it seemed to do things very similar to how I'm doing it now. Is there a way to pass these parameters to my query to my apache solr? Or is my method correct and getAllExtraData not the proper way to get this information back?


texts: Is there any way to set line item status in an order?

texts:
I want set line item status that if a line item is delivered. In an order, order status is for all the items but line item status is for each product.

Is there any module or something in UI?

I am using drupal commerce module.


texts: Properly override template_preprocess_book_navigation function in Drupal 8 Book module

texts:
I'm trying to find what is the proper way to override the template_preprocess_book_navigation function from the Drupal 8's core Book module. I want to add only two lines (bolded), but don't know how this should be done in "Drupal 8 way". Should I create a custom module or add something in the mytheme.theme file?
Thank you and be healthy!

function template_preprocess_book_navigation(&$variables) {
  $book_link = $variables['book_link'];

  // Provide extra variables for themers. Not needed by default.
  $variables['book_id'] = $book_link['bid'];
  $variables['book_title'] = $book_link['link_title'];
  $variables['book_url'] = Url::fromRoute('entity.node.canonical', ['node' => $book_link['bid']])->toString();
  $variables['current_depth'] = $book_link['depth'];
  $variables['tree'] = '';

  /** @var \Drupal\book\BookOutline $book_outline */
  $book_outline = \Drupal::service('book.outline');

  if ($book_link['nid']) {
    $variables['tree'] = $book_outline->childrenLinks($book_link);

    $build = [];

    if ($prev = $book_outline->prevLink($book_link)) {
      $prev_href = Url::fromRoute('entity.node.canonical', ['node' => $prev['nid']])->toString();
      $build['#attached']['html_head_link'][][] = [
        'rel' => 'prev',
        'href' => $prev_href,
      ];
      $variables['prev_url'] = $prev_href;
      $variables['prev_title'] = $prev['title'];
    }

    /** @var \Drupal\book\BookManagerInterface $book_manager */
    $book_manager = \Drupal::service('book.manager');
    if ($book_link['pid'] && $parent = $book_manager->loadBookLink($book_link['pid'])) {
      $parent_href = Url::fromRoute('entity.node.canonical', ['node' => $book_link['pid']])->toString();
      $build['#attached']['html_head_link'][][] = [
        'rel' => 'up',
        'href' => $parent_href,
      ];
      $variables['parent_url'] = $parent_href;
      $variables['parent_title'] = $parent['title'];
      $variables['prev_depth'] = $prev['depth'];
    }

    if ($next = $book_outline->nextLink($book_link)) {
      $next_href = Url::fromRoute('entity.node.canonical', ['node' => $next['nid']])->toString();
      $build['#attached']['html_head_link'][][] = [
        'rel' => 'next',
        'href' => $next_href,
      ];
      $variables['next_url'] = $next_href;
      $variables['next_title'] = $next['title'];
      $variables['next_depth'] = $next['depth'];
    }
  }

  if (!empty($build)) {
    \Drupal::service('renderer')->render($build);
  }

  $variables['has_links'] = FALSE;
  // Link variables to filter for values and set state of the flag variable.
  $links = ['prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title'];
  foreach ($links as $link) {
    if (isset($variables[$link])) {
      // Flag when there is a value.
      $variables['has_links'] = TRUE;
    }
    else {
      // Set empty to prevent notices.
      $variables[$link] = '';
    }
  }
}


texts: A ton of errors in panels content editor

texts:
There's a whole slew of errors at the top of my panels varient content editor page and I have no clue where to start in even fixing them.  Most of these errors have been here since I started working and I have no clue how they got there or how to fix them.  I've had this exact problem on more than one site.

Also, my content got messed up and it won't let me change settings or anything. It stopped letting me change things after I added the Responsive Navigation modules block.

The theme I'm using is aurora and all it's suggested modules:

Magic
HTML5 Tools
jquery update
modernizr
blockify
borealis suite
fences
panels

The site is built on top of the Bear Distro.

Attached is a picture of what I'm looking at.


texts:
I'm using Radix and trying to create a Botstrap carousel component with no luck.
This is the code so far. Kint shows me that media object is there with its multiple fields but nothing is rendered.

themes\custom\newtheme\templates\content\node--article--teaser.html.twig

{% embed '@newtheme/carousel/carousel.html.twig' with {'media': content.field_media } %}{% endembed %}

themes\custom\newtheme\src\components\carousel\carousel.html.twig

    {% for item in media.items %}

{{ item.content }}

    {% endfor %}

    Previous

    Next


texts:
On the homepage of my website, I would like to have a block which displays 3 links to inner pages like so:

Each would have the Title of The page, a teaser image that I would like to select to represent each of these links (Since none of the inner pages have images used on them), a small summary and a link to the page.
What's the best course of action for me to take in creating this?
Would I create a custom view block to display this? If so, are any special settings needed and is there a way for me to select which picture is used through the views settings (overrides?)?

I feel as if this is quite the simple thing to achieve, yet I seem to be overthinking it as I can't come up with a proper solution which would make sense to me.


texts: Classify content in Views based on distinct values

texts:
Is there any elegant way to classify content in view, so that content with same value of some field gets the same value from some predefined list?

For example: I have nodes with entity reference field and would like to get different colors (from pre-defined palette) for different entities referenced through this field.

I know, that this might be solved by using Views PHP field, but this seems to be quite "hacky" to me. Also, classification lists can't be defined in user-friendly way.

Also, it's possible to add another field to referenced entity, which allows us to use this value for classification through views relationship. But this seems to overkill - and even then I would need to use something like Computed field to get randomly generated colors, which are compatible with each other (or use computed field in combination with list field - but that seems to be completely insane).

Do you know about any better solution?


texts: How to select multiple values for Drupal Facets (Facet API + Search API)

texts:
I am using Facet API + Search API to develop Filtering for the data within my site. I am also using Ajax Facet Filters to process the selection as soon as it's clicked.

It all came out great but there's one slight problem. I can only select one option per category. As soon as I select an option, all the inactive options hide and only the active (clicked one) shows.

I want the option to select multiple option but with my settings of Facet API & Search API, there seems to be no option.

Here's the picture to explain.

I'll be very thankful for any assistance.

Best.

picture taken from :- https://drupal.org/node/1669600#comment-6190924


texts:
I'm building a website related to videogames. There's a view that shows all videogames catalogued in the website, using taxonomy terms as arguments, that is:

mysite.com/games/genre/platform

The problem is that the "games" part in the URL is unnecesary: everything is games. For SEO reasons we want to remove this part, so, for example, this...

mysite.com/games/strategy/android

becomes this...

mysite.com/strategy/android

That is, a view with no fixed part in the path, just the parameters. How can I get this working?


texts: Creating commerce product display in rules with PHP results in error

texts:
This problem is to do with the following modules:

Drupal Commerce
Rules
Entity

I have the following code in an "Execute custom PHP code" Rules action. It creates a product display to go with a product (also created by Rules).

The problem is, it does not populate the product reference field (field_product_reference) and gives an error.

Code:

$product = $contact_details_product;
$display = new stdClass();
$display->type = 'product_display_regular';
node_object_prepare($display);

$display->title  = "Product display";
$display->language = LANGUAGE_NONE;

$display->field_product_reference['und'][0]['product_id'] = $product->product_id;
echo "TYPE: " . gettype($product->product_id);
node_save($display);

Where:

$contact_details_product is a variable available in Rules due to the previously created 'product' (as opposed to the display). This product was created in the same rule by a previous action.
product_display_regular is the product display content type.
field_product_reference is the machine name of the product reference field.

Error:

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /home/test/public_html/includes/entity.inc).

Hacking entity.inc to display some values showed that at some point the variable on line 178 gets a null value, so I'm guessing there's a problem with the php code in the rule.
Output of gettype and print_r in entity.inc:

TYPE: string
Array ( [0] => 170 )
TYPE: string
Array ( [0] => 170 )
TYPE: NULL
Array ( [0] => )
...

That's about all I have right now. Can give more info if needed.
Cheers!


texts: Alter dynamically line item price on cart (drupal commerce)

texts:
I want to alter a product price (for example saved at 0.70€ in store). I pulled the hair several hours to find how to change the unit price (and the impact on the total price by changing the quantity) when putting the cart and / or from the time we are on the cart .

In fact, I need a base price, and according to certain client I modified by an external data (webservice). This modified price should not be saved but just used to that moment until the checkout process is complete.

In everything I tried, including the hook_commerce_cart_line_item_refresh() the price is never changed.

An idea to save me?


texts:
I am using term reference in "select list" configuration. I do not know how to translate them, I have Taxonomy translation and Entity translation activated, but none of them worked.

Even I have already done the Field display translation settings and also the taxonomy translation settings!

Can you please give a guide? thank you


texts: Knowing if the currently logged-in user has seen the list of nodes shown in a view

texts: I use the Views module to show a list of specific nodes. Is there a way to know if the currently logged-in user has seen the list of nodes?


texts: Code working normally in a fresh HTML file but not in a Drupal block

texts:
Just wondering if someone would be kind enough to help me with a problem i am having.

This is the code that i am currently using for my E-junkie View Cart button on my Drupal site:

When i use this code on a normal HTML page the pop up is very nice and clean. However, when i try to use this code in a block on drupal the pop-up still works but there is no banner and the tables for the shopping cart all messy and etc.

Another thing that I am wondering about is my twitter feed doesn't work.

I have tried enabling the PHP module and set the input filter to PHP code and the twitter feed now shows but i am unsure if this is an efficient way to fix the problem. When i did this for the code above the banner of my cart started showing but the tables and etc. were still messed up.

I've been reading some FAQs and some people are suggesting that I should make exceptions in my theme's CSS files so that it does not affect the pop-up cart on my site but I do not know how to do this.

Apologies for the chunks of text, thank you in advance for any help.


texts: Is there a way to search Drupal's and contrib modules configuration settings?

texts:
With so many different modules in use with configuring Drupal it is hard to keep track of which settings are configured where, such as whether some CSS is set by the Code per Node or CSS Injector.

It would be nice to have search pinpoint what configuration settings contain some keyword. Does search have such a facility? I understand that the search module is mainly used by content such as nodes and entities.

But is there some way something like this can be accomplished, even by some module, or do module developers need to configure their modules settings to be indexable by search?


texts: what are the css files with question marks - like modules/system/system.theme.css?pywps6u?

texts:
I am new here, starting to find my way around a Drupal site I inherited. I am trying to work out if I can safely ignore all the @import css files with question marks like system.theme.css?pywps6u . I notice that the appended string of letters changes every so often, and I assume this is resulting from the caching.

What's going on here and can I safely ignore these files and just edit the normal files with standard filenames like MyStyleSheet.css?


texts: Removing div wrapper container of paragraph field and get only the plain text in twig

texts:
I have a paragraph template in my custom theme as paragraph--home-page-carousel.html and when I write like this

{{ content.field_home_slide_snippet[0]|raw }}

I get in HTML source code this

    FIELD CONTENT

what should I do to remove the div wrapper?


texts:
Having an issue with HOOK_views_pre_render and HOOK_views_post_render, trying to alter the rendered output of the view. There are similar questions like: Hide view results with hook but I am not seeing the results as I am expecting under $view['result']

There is what looks like a full entity and not the markup that I'm expecting.


texts: How do you deal with multiple locations?

texts:
I'm sure this applies to offices with multiple locations, but I am trying to create a site for a charity that runs summer camps. I was wondering how would you suggest I present the different locations?

I looked at gmaps and open layers (they may do what I want but I couldn't figure out how so easily, I don't want to have to enter coordinates because locations are changing often and I want to make it easy for new staff to add/remove locations).  Ideally it would be good to either have a map with markers that users can click on to see details of the location or to list the locations and once they click on it it shows it in a map.

So I guess there's two questions: 1) What tool can help me present this data in drupal 7?; and: 2) What tool can be used to manage the data?


texts: Exposed filter only allowing content types in list

texts:
I have a view called (Resources) that displays content filtering by content type. These are the selected options:

Expose this filter to visitors, to allow them to change it: ✅
Filter type to expose: Single filter
Operator: Is one of
Content types: Article, Post, Story (NOTE: I have other content types, such as Basic Page that shouldn't be included in this view at all)
Allow multiple selections: ✅

However, when none of the options are selected, it also brings in other content types, such as Basic Page, which shouldn't be.

How can I make it so that when none of the content types in the exposed filter are selected, the results are still filtered such that the nodes must be of one of the chosen content types (Article, Post, Story)?

In other words, I would like the view to behave such that, when none of the content types are selected, it acts as though all of them are checked.


texts: node_object_prepare causes profile page for non-admin users

texts:
When I'm calling node_object_prepare in a module to create a user profile type node Drupal 6 kicks the user out unless they have admin permissions.

How can I make node_object_prepare run regardless of the users role?

thank you,
George


texts: View with last post of each organic group

texts: I have a view with all posts of all organic groups, is there any way of show only last post of each organic group?