Generate h1 et h2 inside link with theme function I am trying to modify a module.

I have two variables: let say $date = "mydate" and $title = "mytitle"

I have for the moment a theming function that creates a link by doing something like this:

$vars['row_dates'][$i] = l( $date, '', array('fragment' => $vars['timelinr_dates_id'] . '_' . $i, 'external' => TRUE));

which output a result like:
    mydate

I would like now to output something like:

mydate

mytitle

the problem is that if I do:

$date = "
mydate
";
$title = "
mytitle
"

then the markups are outputed like text
Is there a way to acheive it ?

You need to set the html-Option of l() to true:

l( $date, '', array(
  'fragment' => $vars['timelinr_dates_id'] . '_' . $i,
  'external' => TRUE,
  'html' => TRUE
));

Otherwise all html-tags get escaped by l().


Place a custom block inside admin area How is it possible to place a custom block inside the admin area? (e.g. in a node edit form)? I tried with page restriction but with no success. How can I see the block regions of the admin theme (seven)?

You can just go to "Structure > block layout" from the admin bar. This will default to your current default theme but along the top of that page it will list out all other active themes and "Seven" will be one of them

Click that and the block listing will now be for the Seven theme and you can add/remove blocks like you can normally except it will now be for the Seven theme

You wouldn't be able to place a block midway through the form but you could add a block above/below the form


Request to reset the password ask current password My problem with Drupal is that when I choose "Request new password" and submit, it sends me a email with a link

  example.com/?q=user/reset/69/1376903015/wiUMZxM27RkYYAAr6zHZfqz6BH4sVMHDAfGoaeZT-Cc

I can login to account by clicking over that link. When I do the same it logged in me and redirects me to user edit page

  example.com/?q=user/69/edit&pass-reset-token=-yS11phdH8HuId-5wpaKrdI6KyWOtfV098jZ5mXb_C0

Now I want to reset my password but when I click on password tab example.com/?q=user/69/password,  it ask me my account's current password. But I (may be a user) don't know current password . So How can I change password?

One point I noticed that when I put pass-reset-token on the password change URL like this

  example.com/?q=user/69/password&pass-reset-token=-yS11phdH8HuId-5wpaKrdI6KyWOtfV098jZ5mXb_C0

I can reset my password without putting current password.

It means that token does not apply on the password tab link. Do I need some module or change in core user module to rectify this problem?

WHAT I DID FOR TIME BEING / TEMPORARY SOLUTION

I edited file : modules/user/user.pages.inc
    //on line Number 142 updated

drupal_goto('user/' . $user->uid . '/edit', array('query' => array('pass-reset-token' => $token)));

to this

drupal_goto('user/' . $user->uid . '/password', array('query' => array('pass-reset-token' => $token)));

Changed "edit" to "password"

Now my goal is complete. I know it not a good solution.

Any suggestion or answer would be appreciated.

No Current Password module allows you to make this field optional.

Also, there's an issue in core about this.


Unable to load class \Drush\VersionControl\Backup I keep getting this error :
Unable to load class \Drush\VersionControl\Backup
 every time i attempt to update my Drupal install from 8.4.0 to 8.4.2.

I am running  the composer provided drush Drush Version   :  8.1.15

Now here is what i have tried:

drush up drupal --debug
Unable to load class \Drush\VersionControl\Backup
drush up drupal --debug  --version-control=svn
No valid version control or backup engine found
drush up drupal --debug  --version-control=git
No valid version control or backup engine found
drush up drupal --debug  --no-backup
No valid version control or backup engine found

if anyone could answer any of these question for me, i would really appreciate it:
How do i turn off version control?
How do i set the valid version control that this thing is complaining about?
How do i set the backup engine?

Note: some solutions out there mentioned that we have to remove the composer provided version and install drush to a different location. To be honest I do not want to use that solution.

Thanks.

I am running the composer provided drush Drush Version : 8.1.15

Drupal 8.4 requires Drush 9, so upgrade your Drush for starters.

composer global require drush/drush:master

  http://docs.drush.org/en/master/install/


How do I allow both kg and lbs units for a field I want the user to be able to submit weight as either kg or lbs and do any necessary conversion on the fly. I took a look at Unit Conversion Formatters but it seems that this is designed to convert for display only (not for storage).

Create two fields, one for number, second for unit. Optionally put them in a field  collection.

Then, add Computed field that will use both values for computation and store the result the way you need it. For best flexibility, you might want to create two of them, ie field_real_kg and field_real_lbs.

  computed fields are populated with values that you define via PHP code. You may draw on anything available to Drupal, including other fields


How to create a view to display poll results formatted as a chart? By using core module poll, every time somebody participates in it, the poll module creates data representing the selected option of the poll, called 'poll results'.

How can these poll results be transformed using the views module? By creating a view and using a relationship to poll results, I only get 0, no matter what.

After I succeed in showing some tabular format of these results, I want to further enhance this view to display these poll results using some 3rd party charting app. This by using some charting module with views integration, which uses a charting library as its rendering engine.

Thank you

About this phrase in the question:

  display poll results using 3rd party charting app

To create charts in Drupal, consider the comparison of charting modules as a possible place to start from, to find the module that best fits your needs. That comparison includes the following: "Poll Chart Block displays poll's results in a block, with a selectable chart type, and using the Chart module." So it looks like what you're trying to achieve already exists as a contributed module, no?

Be aware: I'm a new (co-) maintainer of Chart, and the author of the comparison of charting modules.


Forcing OpenID login instead of Drupal own authentication Is there a way to force the users to use OpenID (e.g. Google, Facebook, Twitter) and not use Drupal's internal authentication?

I simple solution would be to alter the login form to remove the username and password fields.

Here is some sample code to get you started:

/**
 * Alter the login form page
 */
function MYMODULE_form_user_login_alter(&$form, &$form_state, $form_id) {
  _MYMODULE_alter_login_form($form);
}

/**
 * Alter the login form block
 */
function MYMODULE_form_user_login_block_alter(&$form, &$form_state, $form_id) {
  _MYMODULE_alter_login_form($form);
}

/**
 * Function to change a bunch of things in the user_login form (both the block
 * and login screen).
 */
function _MYMODULE_alter_login_form(&$form) {
  unset($form['name']);
  unset($form['pass']);
}

Unfortunately I don't know of any contrib modules that will do this for you; the good news is that I have wrote 95% of the module for you. ;)


Checking for existence for a field on an an entity_metadata_wrapper I am iterating through a field collection, and wrapping the field collection items with an entity_metadata_wrapper. I would like to check for the existence of field before calling its value method (which results in an error on fields that do not have a value), but I cannot find a way to do so.

$field_collection_item = field_collection_item_load($id);
$item_wrapper = entity_metadata_wrapper('field_collection_item', $field_collection_item);

// this results in an error if the field_contrib_headshot field is empty
$headshot = $item_wrapper->field_contributor->field_contrib_headshot->value();

My current workaround is to use field_get_items to see if the field is empty, but i'd love to be able to do this through the metadata wrapper if possible.

Simply call the PHP function isset():

$headshot = array();
if (isset($item_wrapper->field_contributor->field_contrib_headshot)) {
  $headshot = $item_wrapper->field_contributor->field_contrib_headshot->value();
}

EntityStructureWrapper implements the __isset() function according the principe of Overloading.


Drupal 7 hook_validate not called with custom form template I received a pretty strange problem trying to customize custom form's template. So while form's template stay untouched (drupal core's form template was used) validation works just fine, but when I add some specific templates to my theme, validation just not working at all. Submitting a form just doesn't gives anything - MYMODULEFORM_form_validate and MYMODULEFORM_form_submit hooks are not called after form been submitted.

function MYTHEME_theme ()
{
    $items['MYMODULEFORM_1_form'] = array(
        'render element' => 'form',
        'path' => drupal_get_path('theme', 'MYTHEME') . '/templates',
        'template' => 'template_1_filename',
    );
    $items['MYMODULEFORM_2_form'] = array(
        'render element' => 'form',
        'path' => drupal_get_path('theme', 'MYTHEME') . '/templates',
        'template' => 'template_2_filename',
    );
    $items['MYMODULEFORM_3_form'] = array(
        'render element' => 'form',
        'path' => drupal_get_path('theme', 'MYTHEME') . '/templates',
        'template' => 'template_3_filename',
    );

    return $items;
}

When I print out $form variable inside the template file #validate and #submit elements are present and correct. Do you have any ideas what can cause this problem I just stucked at this. Thank you!

SOLUTION: Was only needed to add print drupal_render_children($form); at the bottom of the template file.


D8: Replacing Contact Form Title With Label I've searched around for this answer but to no avail.

All I want to do is with any contact form I create I want to replace its default title (usually "contact") with the form's label.

So instead of {{ title }} something like {{page.label}}.

I need more descriptive titles for my forms.

{{ page['#title'] }} seems to work consistently and accesses the form's label.


How to show pages other than nodes with the default language prefix Content on our site exists in several languages. The default language is 'en'. Prefixes are shown in URLs, such as http://example.com/en/my/path or http://example.com/nl/my/path.

However, pages like the home page, and various views and custom pages, should not be localized -- they should show on the default language URLs, even if they list nodes in other languages.

The problem we face is that after somebody visits a page in non-default language, e.g. http://example.com/nl/my/path and they then go to the home page, the home page is on http://example.com/nl. This means that our the same non-node pages exist in several copies, each with only a different URL language prefix. Confusing for search engines, confusing for users, and heavy for the server (multiple page caching).

In other words, the home page and other non-nodes should always have the default language prefix, independently from the language of the previously visited page.
Can this be achieved elegantly (without having to write custom .htaccess redirects)?

Probably the easiest way that I know is to turn off "Determine the language from the URL (Path prefix or domain)." on the languages page at "admin/config/regional/language/configure".
This way there is only 1 url for all content.

I do not know (of an elegant way) to have language prefix for nodes but not other pages.


Can't declare uniquely named class.. because it's "in use" I'm trying to figure out how to make a processor for facets in Drupal 8.3. I've got this, but I have a couple issues. The first is a fatal error I get after activating the module, and navigating to a page with the facet on it:

Fatal error: Cannot declare class Drupal\facets_change_labels\Plugin\facets\processor\transform_labels, because the name is already in use in Drupal/modules/custom/facet_change_labels/src/Plugin/facets/processor/TransformLabels.php on line 22

It doesn't make sense, because this is the only place in the entire site that transform_labels or transformLabels is used. As an experiment, I changed the function to a completely random name, and the issue persisted.

What am I missing, or not understanding?

The code:

<?php

namespace Drupal\facets_change_labels\Plugin\facets\processor;

use Drupal\Core\Form\FormStateInterface;
use Drupal\facets\FacetInterface;
use Drupal\facets\Processor\BuildProcessorInterface;
use Drupal\facets\Processor\ProcessorPluginBase;

/**
 * Provides a processor for transforming labels.
 *
 * @FacetsProcessor(
 *   id = "transform_labels",
 *   label = @Translation("Transform labels"),
 *   description = @Translation("Transform labels"),
 *   stages = {
 *     "build" = 35
 *   }
 * )
 */
class transform_labels extends ProcessorPluginBase implements BuildProcessorInterface {

  /**
   * {@inheritdoc}
   */
  public function build(FacetInterface $facet, array $results) {
    $config = $this->getConfiguration();

    /** @var \Drupal\facets\Result\Result $result */
    foreach ($results as $result) {
      if ($result->getRawValue() == 'shape') {
        $result->setDisplayValue("leaf shape");
      }
      elseif ($result->getRawValue() == 'type') {
        $result->setDisplayValue("leaf type");
      }
      elseif ($result->getRawValue() == 'color') {
        $result->setDisplayValue("leaf color");
      }
    }

    return $results;
  }
}

For PS4 class autodiscovery to work, your file name needs to be the same as your class name. From reading the error message, it appears that your file name is TransformLabels.php, but you've named your class transform_labels. You need to change your class name to TransformLabels:

class TransformLabels extends ProcessorPluginBase implements BuildProcessorInterface {

One other question I have is, did you create the facets processor plugin type? Or was it a 3rd party?


Adding html subsites to Drupal 7 installation Newbie here, and would appreciate any insight.  I have a Drupal 7 site and am looking to create a few small HTML subsites (e.g., Drupal site www.mykittenmittons.com, html subsite cats.mykittenmittons.com).

After creating my Drupal site on BlueHost I used their "subsite" tool. The subsite folder is automatically generated in public_html. I gave it a whirl and added my html files to the subsite folder and it seems to work. Are there any reasons to not handle html subsites in this way, or problems I could encounter? Thanks.

I don't know anything about BlueHost or their tools, but the normal way to do that would be along the lines of:

Make a folder to house your HTML-only site
Put your site files in the folder
Set your webserver (Apache/Nginx/IIS) to direct requests for subsite.mysite.com to that new folder

Drupal is not involved in any way, shape or form.

So the answer is likely that there will be no problems, however I suggest asking this question of BlueHost as it really has nothing to do with Drupal.


How to exclude current node from a block view? I created a block view listing nodes of the content type: cars.

I added the block to the second sidebar.

After, I created 2 nodes of this type with the titles: car-1 and car-2.

Then the view block shows these 2 nodes. So far so good.

If I visit the page example.com/car-1 I see the block listing both the car 1 and car 2 nodes. I want to exclude the car-1 node from the block since I'm at: example.com/car1

This is what I did in the view:

1.  Click on add under "contextual filters".
2.  Choose Content:nid.
3.  Under "when the filter variable is not available, choose "provide default value".
4.  From the drop down menu select "content id from url".
5.  Scroll all the way down to the bottom of the window and click on the
6.  "More" link.
7.  Click "Exclude"

I works fines if I visit a node, but the block is not shown in any Views (i.e.: in the frontpage view )

I know that the reason is that the Content nid is not present in a view, but don't know how to workaround this.

One option is to clone the block, make it show everything (remove the contextual filter and the exclude setting) and in block configuration (via admin/structure/block) configure it to show on all pages except node/*.

Another option, if you want to have everything in one display and don't mind using php, is to use Provide default value > PHP code:

if (arg(0) == 'node' && is_numeric(arg(1))) {
  return arg(1);
} else {
  return 0;
}

The exclude checkbox must be on.

So this is giving the sql the node id to be excluded, normally the current node id, and when there is no node id, the node id to be excluded is 0, in other words don't exclude anything as there is no nid 0.

Without checking that the second argument is numeric, this wouldn't work on the default front page as it would have 'node' but not have nid.


Email-only subscription form with mailchimp module? I have a mailing list in MailChimp and I recently installed the mailchimp module in my Drupal 6.0 site.

The subscribe form for anonymous users has first name and last name input elements, as well as an (empty and ugly) interest groups div.

Is there a way, using the mailchimp module, to present simply an email+button subscription form block?

I haven't got a mailchimp enabled Drupal site in front of me, but from memory the simplest way to do it is to set the fields you don't want captured as optional in the Mailchimp interface (NOT the Drupal module) and then just hide the fields using CSS on your subscribe form.

If you don't need to capture anything other than email for your mailing list, you can remove those fields entirely from your list on Mailchimp's site, and (again from memory) they won't show up in your Drupal form.


Get organic group name in a rule? I want to create a rule that sends an email to all users of an organic group when content is posted to that group.  In the email I want the name of the group to appear in the subject.  I'm completely lost.  How can this be accomplished?

You can use the token [node:group-audience] to add the group name in your email notification.

Here is the export of the rule I am using:

{ "rules_og_group_content_notification" : {
    "LABEL" : "OG group content notification",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "og", "rules" ],
    "ON" : { "node_insert" : [] },
    "IF" : [ { "og_entity_is_group_content" : { "entity" : [ "node" ] } } ],
    "DO" : [
      { "og_get_members" : {
          "USING" : { "group_content" : [ "node" ] },
          "PROVIDE" : { "group_members" : { "group_members" : "List of group members" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "group-members" ] },
          "ITEM" : { "list_item" : "Current list item" },
          "DO" : [
            { "mail" : {
                "to" : [ "list-item:mail" ],
                "subject" : "New [node:content-type] in [node:group-audience]",
                "message" : "Hello [list-item:name],\r\n\r\nThere is a new [node:content-type] called [node:title] that belongs to [node:group-audience]: [node:url]\r\n\r\n\r\n--\r\n",
                "from" : [ "" ],
                "language" : [ "" ]
              }
            }
          ]
        }
      }
    ]
  }
}


Show comment module but have it disabled for anonymous users I have what I believe is a slightly unusual requirement for comments. I'm trying to figure out how to implement this:

Comment form should always appear at the bottom of the page (this helps
users understand they can submit a comment especially if there are no comments yet for a given article)
If the user is registered the comment form should be enabled.
If the user is anonymous the comment form should be disabled and provide a
link to registration

It seems like the comment module is generally built to be on or off. Any recommendations on exposing it as a disabled form?

I didn't know this until I just tried it but you can use a hook_form_alter() function in a custom module and simply set the whole $form to disabled...this disables all child elements as well. Combine it with the user_is_anonymous() function and you should be set:

function MYMODULE_form_comment_form_alter(&$form, &$form_state, $form_id) {
  if (user_is_anonymous()) {
    $form['#disabled'] = TRUE;
    // Add a link:
    $form['register_link'] = array(
      '#markup' => l('Click here to register...', 'user/register')
    );
  }
}


How can I have a taxonomy list that shows parent child relationship, but not allow the parent to be selected? Now and then I will come across a Drupal site that shows taxonomy terms to be selected in a drop down list. Example:

Fruit
    apple
    pear
Meat
    pork
    beef
..etc

And, while the child of each parent is selectable, the parent is not. How is this achieved, and how can I apply it to my taxonomy vocabulary who terms are 1 child deep?

Download and install this module http://drupal.org/project/term_reference_tree and
 check the Leaves only(Don't allow the user to select items that have children) option under manage fields-> click edit on taxonomy field.

It will select only the children not parent.


How to create a view to display a block of referenced nodes? I have a node type, called "policy", that has a bunch of CCK fields, including a Node Reference type.  This is configured to reference an unlimited number of nodes.

When the nodes are viewed, the list of referenced nodes appear at the bottom of the content.  Ideally, I'd like to put these in a block on the side of the content.

I've tried writing a view that accepts an NID as an argument and displays the CCK field.  This works in the Views configuration preview (displays expected results), but when I put this block on the side bar, and view a node, I do not see any results at all.

I do not have a relationship specified in the view - I'm not really clear on if I need to use it or not.

Thanks!

When configuring the argument for the block, set it to "Provide a default argument", and configure that to use the nid of the node being viewed.


How to disable shipping for ONLY virtual products and not if combined with physical In Drupal Commerce, I'm trying to come up with a rule the bypasses shipping if
virtual product types are put into the cart, but ONLY if all products are virtual; if physical products are put in, then the rule wouldn't fire because these products need to be shipped.

Below, for reference, is a solution for virtual products; it's close but it won't suffice if combined with both physical and virtual products.

Install Commerce Rules Extra

Create a rule for Event: Process checkout pane
Add Action: Change pane properties
Value: Shipping information
Page to move to: <do not change>
Enabled: uncheck
Add Condition: e.g. by Order contains products of particular product types, or based on Commerce order contains shippable products supplied by Commerce Physical Product.
You may have to clear caches before this takes effect.

Commerce Shipping has a couple of ways you can approach this. The simplest is to set the weight of your virtual products to zero, they won't be assessed shipping charges, and they won't affect any weight based calculations.

EDIT: Alternatively, you can use Commerce Rules Extra to add conditions that exclude your virtual products in the conditions for your Flat Rate.


Where should I add the unique identifier cookie code? I want to add a unique identifier in a cookie when the user (anonymous or logged) visits the website. Where should I call this code. I tried calling the code in hook_init but that doesn't work on cached pages. Any help would be greatly appreciated. Thanks.

I think hook_boot() would be the best place for your code:

This hook is run at the beginning of the page request. It is typically used to set up global parameters which are needed later in the request.
Only use this hook if your code must run even for cached page views.This hook is called before modules or most include files are loaded into memory. It happens while Drupal is still in bootstrap mode.

(emphasis mine)


CKEditor, Media, & Files — oh my We're relying on the Media module heavily for embedded video throughout our site.  When Media is used for a field, it is working beautifully for us.

We ran into problems, however, embedding Media rich text fields. We're using CKEditor, which strips Media tags when using filtered HTML. For security purposes, we want all non-admin users to continue using filtered HTML.  There were other complications, too: The UI was a little strange since you had to add the (non Media) image button to allow users to align images.  So they'd have two image-y buttons, one to upload and one to style. Finally we decided we could keep rich text pared down to text without images.

However we've also been using Media to upload files (documents/docx/pdf).  And we definitely want users to be able to link to files in the editor.  Should we use CK Finder?  Or is there a way we can expose the view at admin/content/file to non admin users so they could have an inventory of files and copy urls? Or rebuild a similar view, as described here?

I feel like I must be overlooking something obvious, as this seems like a very basic CMS feature... Have I managed to obscure functionality with my permissions and plugins?
Thanks!

You should try using the node reference (References) module and create a field on your content type. The node reference will ask you to specify a content type that allows users to select from a list of previously created content. You can also create a view which you can select as the source for the select list.

https://drupal.org/project/references


How do I automatically get the "Automatic alias" option checked for the content type? I have the Pathauto module, and I want to have the 'Automatic alias' checkbox selected by default for the new content types I create.

Is there a way to obtain this?

After you define the pattern of the content type path, it will be checked automatically when you add the node of that content type.

The path is admin/config/search/path/patterns.


Commerce order confirmation message with shipping service I'm sending confirmation message of a commerce order via Message Notify. I want to display the selected shipping service in the email.

Assuming that you are using Commerce Message module for this.

One way to do this is by adding your own token. In your custom module (MYMODULE) add this code (I have too many comments just for educational reasons):

// Set arguments for our custom token !order-shipping
function MYMODULE_message_presave($message) {
  if (!empty($message->mid)) {
    return;
  }
  $message->arguments['!order-shipping'] = array(
    'callback' => 'commerce_message_order_shipping',
    'pass message' => TRUE,
  );
}

/**
 * Message callback; Show Order Shipping Service label (!order-shipping).
 *
 * @param $message
 *   The Message entity.
 */
function commerce_message_order_shipping(Message $message) {
  $wrapper = entity_metadata_wrapper('message', $message);
  // Get order id from current commerce message
  $order_id = $wrapper->message_commerce_order->getIdentifier();
  // Get order from order_id
  $order_wrapper = commerce_order_load($order_id);
  // Get the line items. Shipping service is a line item (like product, discount etc)
  $line_items = $order_wrapper->commerce_line_items['und'];

  // Loop through the line items so you find the shipping service
  foreach ($line_items as $delta => $line_item_wrapper) {
    $line_item_id = $line_item_wrapper['line_item_id'];
    $line_item = commerce_line_item_load($line_item_id);
    //dpm($line_item);
    if(isset($line_item->commerce_shipping_service)) {
      // This is want we need, the shipping service label
      $shipping_service = $line_item->line_item_label;
    }
  }

  return $shipping_service;
}

Then in your message body add you new token !order-shipping.

Notice that this method works for other line items too... Also, it works for other modules that send emails (such as commerce_email) but with some difference in the hook function - currently hook_message_presave($message) -.

Credits to this issue: http://drupalcommerce.org/node/10096


node_mass_update will not update field Cannot get node_mass_update(); to update Votes field. $node_ids is an array of node ids and $votes is a number.

    $updates = array('field_votes' => $votes);

    node_mass_update($node_ids,$updates);

My module fires and it tells me that nodes are being updated and gives me a progress bar, but the fields in the nodes are not updated.

I've never used (or even seen) that function before, but following the trail down to _node_mass_update_helper(), I think you need to use a format like this:

$updates = array('field_votes' => array(0 => array('value' => $votes)));

That array format is the standard way to update CCK fields in Drupal 6, and since the helper function does this:

foreach ($updates as $name => $value) {
  $node->$name = $value;
}

immediately before calling node_save(), I think that's what the problem is.


Add 150 grams to each order for calculating shipping how can I add 150 grams to each order for calculating shipping costs (this weight corresponds to the packaging)?
I looked in the rules, but I do not see how to do this.

I guess you're using commerce_shipping module, if so, you can add a commerce_flat_rate service to every order.

Otherwise I would suggest you start using these modules ;)


Blank admin panel | Drupal 7 | XAMPP I am migrating a Drupal 7 project from one PC to another and I did the following steps

  1) Copy pasted the root folder into D:\XAMPP\htdocs    2)
  Imported the database of that project into phpmyadmin (had to increase
  max_file_uploads to 20 in php.ini)  3) reset admin password
  by referring https://drupal.org/node/1023428  4) updated the
  password in settings.php  5) cleared cache in the imported db
  (by deleting the content of cache and cache_* tables)

Now I am able to login but the admin panel is blank, When I click Dashboard, Content, Structure, Appearance etc. nothing appears

No error is console.

PS: this is the first time I am using Drupal, so in-depth instructions is much appreciated

Edit

After @Randell's suggestion I had set display_errors to on and error_reporting to E_ALL. Still no error appears anywhere

Edit
From watchdog the last two rows;

Second-Last row

  uid : 1 Message : Session opened for %name. location :
  http://localhost:81/mysite/user referer :
  http://localhost:81/mysite/user

Last Row

  uid : 0 Message : Attempting to re-run cron while it is already
  running. location : http://localhost:81/mysite/users/admin
  referer : http://localhost:81/mysite/user

Most of the time it is the memory_limit setting in your php.ini. Drupal 7 needs a bit more memory and depending on how many modules you are using, it must be set to a higher value. 64M or 128M should be enough for moderate sites.


Is there a callback for the managed_file form element, called on succesful upload? Is there a Javascript/PHP callback for the managed_file form element that is invoked when the file is successfully uploaded? (I mean when the "Upload" button is clicked, not when the form is submitted.)

$form['video'] = array(
    '#title' => t('Video'),
    '#type' => 'managed_file',
    '#default_value' => variable_get('image_example_image_fid', ''),
    '#upload_location' => 'public://temp_managed/',
);

I have tried:

#file_value_callbacks, but this seems to be a preprocess
#process, but it also seems to happen during the page load

For the PHP side, use #upload_validators as described in Form API docs. They are fired after upload, just like you want them to be. In Drupal everything that's supposed to happen between user's input and actual form save, happens in validators. Pretty weird, but that's the way it is.

For an JavaScript part, element's description says:

  The #managed_file element is expanded into a set of FAPI elements including two '#submit' buttons one for Upload one for Remove, a '#file' element and a handful of '#hidden' and '#markup' elements to handle progress indication and displaying of already uploaded files.

Thus, while it does not have any '#ajax' property, you can try to access it's internals with your own custom code. Notably, successful file upload makes delete button visible. But internals can be refactored without notice, so be careful about that.


Anonymous users unable to download purchase I've set up a Drupal Commerce store (on localhost) for a book shop. One of the requirements is that people can buy ebooks without creating an account.

It all works fine if I buy a book as the administrator; at the end of the checkout process I can download the book. However, when I buy a book as an anonymous user I'm shown the 'Download now' link in plain text.

I'm using a content type named 'Books' with a field named 'Ebooks'. The latter uses the 'File' field type. The rest of my set-up is as follows:

Commerce File 7.x-2.0-beta2:

Product types: Books
Download limits: 5

Commerce License 7.x-1.2

Product types: Books
Line item types: Product

Permissions for anonymous users:

Checkout, Access checkout
Commerce licenses, View own licenses
Order, View own orders of any type

Rules:

Create a new account for an anonymous order: inactive
Assign an anonymous order to a pre-existing user: inactive
Activates licenses of an order: Completing the checkout process >
Activates all licenses of the provided order
Update the order status on checkout completion: Completing the
checkout process > Update the order state (to 'Pending')

At first I though the issue was that the order status is changed to 'Pending' once the checkout process has completed. However, changing this made no difference.

I then found that giving anonymous users permission to 'bypass license control' does instantly resolve the issue. However, that permission setting comes with a "give to trusted roles only; this permission has security implications".

So... something is not quite right in my set-up. It seems that anonymous users aren't given a license allowing them to download their purchase. I've run out of ideas though. What have I done wrong?

You have disabled the rules for creating an account for the anonymous user.
Therefore, the license never gets assigned to an actual user, stays assigned to user 0.

Commerce License and Commerce File were designed to license the file to an actual customer. I suggest either re-enabling the rules and creating the user accounts or developing a custom solution for the file downloads (you don't need most of commerce file if there's no actual user... just a temporary file link).


E_DEPRECATED and E_NOTICE errors showing in dblog / syslog despite disabling in php.ini I'm still getting a lot of PHP Deprecation and Notice messages in my logs despite having these values turned off in php.ini. According to admin/config/development/logging I should only be displaying errors and warning if that is relevant. Is there some other way that Drupal might override my php.ini settings?

In drupal_environment_initialize(), Drupal changes the report level with the following code.

// Enforce E_ALL, but allow users to set levels not part of E_ALL.
error_reporting(E_ALL | error_reporting());

The value of E_ALL changes basing on the PHP version, and it is:

--------------------------------------------------------------------------------
PHP   | Value expressed using the other constants                              |
-------------------------------------------------------------------------------|
Before| E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING         |
5.2.x | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING    |
      | E_USER_NOTICE                                                          |
-------------------------------------------------------------------------------|
5.2.x | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING         |
      | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING    |
      | E_USER_NOTICE | E_RECOVERABLE_ERROR                                    |
-------------------------------------------------------------------------------|
5.3.x | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING         |
      | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING    |
      | E_USER_NOTICE | E_RECOVERABLE_ERROR | E_DEPRECATED | E_USER_DEPRECATED |
-------------------------------------------------------------------------------|
5.4.x | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING         |
      | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING    |
      | E_USER_NOTICE | E_STRICT | E_RECOVERABLE_ERROR | E_DEPRECATED          |
      | E_USER_DEPRECATED                                                      |
--------------------------------------------------------------------------------

With all the PHP versions, error_reporting(E_ALL | error_reporting()) causes any warning to be raised; since PHP 5.3, it causes any deprecation message to be raised too.

drupal_environment_initialize() is the only place where Drupal sets the error level. A custom settings.php file could change it with ini_set('error_reporting'). Since settings.php is included after drupal_environment_initialize() is executed, that file could restrict the error level, or expand it; this means that with PHP 5.3, settings.php could cause E_STRICT errors to be raised too.

function _drupal_bootstrap_configuration() {
  // Set the Drupal custom error handler.
  set_error_handler('_drupal_error_handler');
  set_exception_handler('_drupal_exception_handler');

  drupal_environment_initialize();
  // Start a page timer:
  timer_start('page');
  // Initialize the configuration, including variables from settings.php.
  drupal_settings_initialize();
}

About the error levels, the PHP documentation has the following notes:

  In PHP 5 a new error level E_STRICT is available. Prior to PHP 5.4.0 E_STRICT was not included within E_ALL, so you would have to explicitly enable this kind of error level in PHP < 5.4.0. Enabling E_STRICT during development has some benefits. STRICT messages provide suggestions that can help ensure the best interoperability and forward compatibility of your code. These messages may include things such as calling non-static methods statically, defining properties in a compatible class definition while defined in a used trait, and prior to PHP 5.3 some deprecated features would issue E_STRICT errors such as assigning objects by reference upon instantiation.

If you are using PHP 5.4, that would explain why Drupal is recording E_STRICT errors, since Drupal adds E_ALL to the error level.


How to stopping spam when using Print_mail (submodule of Print)? I am using the Printer, email and PDF versions module to be able to email and print articles. This module allows you to send an email to anyone. The issue is, that this feature opens it up for spamming.

Is there a way to stop that or can you suggest another module?

About sending eMail using the print module
Even though this module can be used for printing, creating PDFs and sending an eMail, your question seems to only be about the sending eMails part of it.
Yes you're right: if you grant access to the eMail part of it to anonymous users, then that is a huge spam risk: any spammer can use it to enter any (repeat any ...) eMail ID ... to have "your site" send that eMail (and who knows what the content, from the spammer, might be) ... to the eMail Id "requested" by the spammer.
"The way to stop that" (spamming), as in your question, is to not grant that permission to use the eMail function of it to anonymous users.
If you do grant that permission to logged in (+ registered) users, then you have at least a trace which user used the eMail part of it.
Recommended alternative
Have a look at the Message Stack, these are the basic components and dependencies of it:

Some more details about the Message-related modules (=quotes are from the module's project page):

Message:

The Message module is the core of the message stack. It enables logging and displaying system events in a number of different use cases. Events that are recorded over time are sometimes call activity streams. Exportable messages subtypes can be created for different use cases with custom fields and display (view) modes.

Message Notify.

This module provides a method for sending a message via a notifier plugin. Message Notify comes with plugins for email and SMS and may be extended to other transport mechanisms as required.

Message Subscribe.

With this module, users who subscribe to content will be notified when events occur that involve that content. The module leverages the Flag module, which provides a subscribe functionality to users.

Quite a few popular Drupal distributions already adopted to this Message Stack, Open Atrium is one of them.
If you want to see it at work in an existing module (as an example), then checkout the 7.x-4.x version of the Answers module (disclosure: I'm a co-maintainer) and its Answers Notification sub-module. This sub-module allows logged in users (not anonymous users ...) to subscribe to selected nodes (such as "questions"), so that they receive notifications (using the Message Stack) when Questions receive Answers.


How to create a basic page This is a really dumb question, but I simply want to create a basic page with it's own path, (i.e. mysite.com/contact) so far I've only had to use Views to display node data. Views have the option of specifying a path, but I'm assuming I don't have to create a view to display a regular page?

The Drupal docs say the default installation comes with the "Basic page" content type, so I tried creating that content type, but I can't see an option to specify a path...

I feel very silly >.<

You don't set the path when creating a content type. Once you create a "basic page" content type (or use the one that comes with the "standard Install" of Drupal core), you can then create a basic page by going to node/add. Then in the vertical tabs at the bottom of the node creation page, you will find a tab called, "URL path settings". In there you can manually specify a path. If you wish to avoid having to manually adding a path for every node, use the Pathauto module.


Change a output value of a field in a view I've a view where one of the fields 'titleColor' has the option to return '#000000', '#FFFFFF' or '#FF0000'. I need to show instead of this values 'black', 'white', and 'red'. How can I do it? I've use in other cases Views Conditional  module, but I only can insert one else clause.

I hope you can help me,

Thank you very much.

A possible solution is to use the views feature "rewrite result", combined with Views PHP module.

Note: this module only has an alfa version as of today, but it's used in over 71K sites anyway.


Can nodes created using Feeds be updated automatically? The Feeds documentation mentions that it's possible to import a CSV feed and create nodes from it, assigning column values as CCK fields, but it doesn't mention if it's possible to update nodes when those values change in an updated feed. Is this possible to do using Feeds or an additional module?

For example, a feed is downloaded in week1, creating a node for a Red Widget. Its price is £10.

In week2, the feed is updated with a new price of £12 for the Red Widget.

Can the node initially created be updated with that new price without importing a new or duplicate node?

I believe as long as you have a primary/unique ID for each item in your CSV this should be very easy to do with the Feeds module.  When you do not have primary key to work with things get tough.


How we can get custom field type which will bring custom data from custom table to use as a drop down I need to use my custom table data as a drop down.

for eg. i have created one custom table which is getting list of cities and i want that list to be shown in my form as a drop down.

Thanks in advance

You might want to look at http://materializecss.com/badges.html#dropdown The have a pretty straight forward way of creating a dropdown menu, including code examples.

If it's for a certain Form ID you can use hook_form_FORM_ID_alter to specify which ID and alter it's HTML inside $form_state. If you don't know it's structure you can var_dump($form_state); first instead so you know what to alter.

P.S. also add the CSS of course: drupal_add_css(drupal_get_path('theme', 'custom') .'https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/css/materialize.css', 'theme', 'screen,projection', FALSE);


Display Jalali (Shamsi) Date in Archive View I have a Persian language website and I need to a archive block in my site.
but date of default archive view is Gregorian. I install Datex module and it convert all date of nodes to Jalali(Shamsi) Date but can't convert Gregorian date to Jalali Date in archive view.
I want to archive content in year+month format.
any one has another idea for convert date in archive view?

there are patch file in datex folder for patching datex to jalali support.

patching datex module for convert date to jalali.

path: modules\datex\drupal-jalali_support-0-0.patch


Trying to to display form in template I'm trying to display a form in a template (not my first choice, but I'm restricted in what I can do here) and I'm having some trouble figuring out how to do it.

I'm trying to tie into the Ubercart Addresses module to allow the user to select from one of the countries available to them.

I believe this information is located in uc_addresses_get_address_form

What I'm trying to do is as follows:

<?php  print render(drupal_get_form('uc_addresses_get_address_form'))?>

But this doesn't seem to add the form information I want.

How do I get this information into a template file?

Something like the following should work:

drupal_render(drupal_get_form('uc_addresses_get_address_form'))

Check Render form in template


Why am I getting a 200 status header when the page is being served from cache? Been running into a weird issue with all of our Drupal 8 websites, hosted on different servers.

The pages are caching correctly, x-drupal-cache header shows a HIT as well. The page however has it's headers set to 200, instead of 304. None of the sites are live yet, so i can't provide a link.

Request Headers:

HTTP/1.1 200 OK
Date: Fri, 18 Mar 2016 20:09:41 GMT
Server: Apache/2.4.7 (Ubuntu)
Cache-Control: max-age=900, public
Expires: Sun, 19 Nov 1978 05:00:00 GMT (Dries' birthdate? O.o)
Last-Modified: Fri, 18 Mar 2016 19:49:21 GMT
Vary: Cookie,Accept-Encoding
X-Drupal-Cache: HIT
Keep-Alive:timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html;
charset=UTF-8

Debugging the code Drupal uses to serve pages with 304 headers ( lines 165 to 170 of PageCache.php ) I have found that HTTP_IF_MODIFIED_SINCE and HTTP_IF_NONE_MATCH are not being set.

Thanks!

A Page cache hit just means that Drupal doesn't have to rebuild the HTML but can deliver it from the cache.

That doesn't make any difference at all for your browser. The browser requests the page and gets a HTML response. As far as he's concerned, there's no caching involved.

The built in Page cache has not support for returning 304 responses. Varnish does, but I don't know too much about when that works and when it doesn't. It depends on how you refresh/request the page for example, check if your browser really sends a If-Modified-Since header and if that's in the right form (see some of the answers in the linked stack exchange issue).


How to display field description right after field label? I'd like to display field descriptions in user profile2 page. Not below the form items but right after field labels. I tried to use hook_form_alter() in template.php of the theme but I could'nt figure out how to do that.

The module called Better field descriptions might be the one you are looking for. It describes as following:

Better field descriptions makes it possible to add themeable descriptions to fields in forms.

Would your customers like to write their own descriptions, but can't or won't, since they then need permission to manage the fields in the content type?
Would you like to show the description above the field or even between the title and the field?

The module Label help might also be helpful.


How to debug rules that are not being run? I have few rules bound to the Event: Completing the checkout process

After completing the checkout process these rules should run - but they do not work...

I am using Devel module to debug the Rules and in the dblog there is nothing about these rules - There are only rules that are actually being run upon other events.

How can I debug this ?

/config/workflow/rules/settings

Enable all debugging and it should show in the log if the event is correct. It will go through each condition and say which passed and which failed.


Extra collapsed fieldset on node form I have an extra collapsed input format fieldset on my node form. It above all other elements, appears unrelated to any fields, and I can't tell where it's coming from. Not sure how to investigate where the source is.

I'm guessing that the Multistep module is the cause, but I need to at least figure out what field the form is coming from.

Your first option is to simply inspect the html of the form, it should have identifying markup in the HTML which you can then use to grep all your modules for.

Your second option is to implement hook_form_alter and output $form to see which form is generating it and whether there are any identifying markers there. You can use kpr() to output the results of $form using the Devel module to get nicer looking output. You can also use hook_form_alter to remove the fieldset if you want.


Language/Region selection i18n drupal 7 I would like to implement a Region selector in a Drupal 7 website. Not the default i18n where you have 1 language for multiple countries but English content for the USA and different English content for the UK.

For configuration I would like to select the applicable regions on my node (maybe with taxonomy items?) so when the content is the same for multiple region's we don't need to duplicate it in all region's/languages.

Is there a solid solution for my needs?

THANKS!

To get a different content and/or interface for the USA and UK, go to admin/config/regional/language/add :

In predefined language, select English, british. This will add a new "english British" language with en-gb prefix, while default english has en prefix, and will import related .po files.

If you have only en-US and en-GB in your project, when the content is the same for both, simply set it as Language neutral  in the content node submission.

Maybe you already know the great article series Drupal 7's new multilingual systems compilation. It is a valuable source to get a complete overview of Drupal 7 multilingual setup.


How to set the file status of files uploaded through theme settings to permanent? I have been trying for a week to get image files uploaded to a Drupal server through the use of "managed_file" theme settings to remain on the site longer than the default 6 hours. I have visited the Stack Overflow/Exchange forums before
(https://stackoverflow.com/questions/8793518/set-file-status-permanent-for-appearance-settings-file-upload)
(Uploaded images in theme settings is going to be lost)
and have done my best to implement the provided solutions, but the uploaded files always disappear after 6 hours.

Here is one of the managed_file fields which I wish to make permanent:

$form['mentor_settings']['global_settings']['header_settings']['header_background_image'] = array(
      '#type' => 'managed_file',
      '#title' => t('Header Background Image'),
      '#default_value' => theme_get_setting('header_background_image'),
      '#description' => t('This image will match the full dimensions of the header in the back.'),
      '#upload_location' => 'public://themesettingspictures',
      '#upload_validators' => array(
        'file_validate_extensions' => array("png jpg jpeg gif"),
             ),
  );

The file is properly moved to the specified folder. I have attempted to set the file status to permanent using the code provided in the above links, but it has never worked.

I would like to know if anyone can show me what function will set the file status for me AND can show me how to write it for the setting above, with its very long array "path". The examples I have tried to imitate have always been for 1st level theme settings, but my theme has three different levels of settings, so I'm never sure if I'm referencing my individual settings properly when trying to change file status.

One more note: I have been a self-taught front end Wordpress and Drupal web designer for a year now, but my knowledge of PHP is weak and so I am usually unable to code and back-end functions on my own. If you simply tell me to "use" a certain PHP function, I will have no idea how to apply it within the context of Drupal. If you respond to my post with references to PHP functions, please explain if they must be in a certain file (theme-setting.php vs template.php) and provide any other Drupal contextual information.

You need set status FILE_STATUS_PERMANENT file when form submit

function mymodule_custom_form_submit($form, &$form_state) {
  if (isset($form_state['values']['images'])) {
    $file = file_load($form_state['values']['images']);

    $file->status = FILE_STATUS_PERMANENT;

    file_save($file);
  }
}


Ajax drop down list problem with callback I need a little help here.
In a custom module, I add a little form where you type your zip code, press a button and a drop down list populates (via ajax) with the stores that are close to that zip code so you can choose one of them. The problem is when you click on that button the callback is made but the zip code field remains empty, seems like I missing something that can bring the zipcode value to that part when the  refreshes.
some ideas?? thank you

    function mymodule_form($form, &$form_state) {

       $form['zip_code'] = array(
        '#type' => 'textfield',
        '#title' => 'zip code',
        '#size' => 5,
        '#maxlength' => 5,
        '#required' => TRUE
      );

      $form['button'] = array(
        '#type' => 'button',
        '#value' => 'find stores',
        "#limit_validation_errors" => array(),
        "#name" => 'mybutton',
        '#ajax' => array(
          'callback' => 'reload',
          'wrapper' => 'stores-div',
          'method' => 'replace',
          'effect' => 'fade'
        )
      );
      $form['select_str'] = array(
        '#prefix' => '
',
        '#suffix' => '
'
      );
      if(isset($form_state['values']['zip_code'])) {
        $arr = find_store($form_state['values']['zip_code']); //here is my main problem, $form_state['values']['zip_code']is always empty even after the callback
      } else {
        $arr[99999] = 'theres none';
      }
      $form['select_str']['stores'] = array(
        '#type' => 'select',
        '#title' => 'stores near you:',
        '#options' => $arr,
        '#required' => TRUE
      );
      $form['submit_button'] = array(
        '#type' => 'submit',
        '#value' => t('Send!'),
      );
      return $form;
    }
    function find_store($zc) {
        $fields = array(
                'zc'=>urlencode($zc),
            );
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,"http://somepage.php");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        $result=curl_exec ($ch);
        curl_close($ch);
        $arr = array();
        if($result!='none') {
            $explode=explode(',',$result);
            foreach($explode as $value) {
                $stores = explode('|',$value);
                $arr[$stores[0]] = $stores[1];

        }

    } else {
        $arr[99999] ='theres none';
    }
    return $arr;

}
function reload($form, &$form_state) {
  return $form['select_str'];
}

The values will be passed to the callback function reload instead of the original form function, therefore you should rebuild the form in your callback function - reload and pass back the element:

function reload($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
  $form = drupal_rebuild_form('mymodule_form', $form_state, $form);
  return $form['select_str'];
}


Rule condition to check which language is used by the visitor? I have a multilingual website (English, Spanish).

Is there any way to create a rule condition to compare the language used by the visitor against a fixed value?

The condition would something like: if language is English then go ahead with the actions.

Seemed like a useful thing to have.

I created a patch for Rules, adding this functionality. I posted it in the Rules issue queue. That seemed better than providing the code directly here, as this way you can still use it anyway that suits you, yet it may actually get into core Rules.

Also see this question, "How do I add a new condition in Rules 2?".


Programmatically import a feed I can successfully import remote content using the Feeds module by manually clicking on the Import button. I need to execute the import process from code, either from a module or executing PHP code from the Rules module.

I have tried the following code in a custom module.

function imports_cron_cron(){
  drupal_set_message('Import-CRON responding to cron execution! ...');
  $importer_id = 'publications_import';
  $url = "http://xml/url";
  $feeds_source = feeds_source($importer_id);
  $feeds_config = $feeds_source->getConfigFor($feeds_source->importer->fetcher);
  $feeds_config['source'] = $url;
  $feeds_source->setConfigFor($feeds_source->importer->fetcher, $feeds_config);
  $feeds_source->save();
  $feeds_source->startImport();

  drupal_set_message(' .... ENDING IMPORTS-CRON CALL!');
}

Both the drupal_set_message() calls are successfully executed, but no node is imported.

Can anyone help, please?

Your code seems to be OK. I use some similar code in one of my projects (this a csv importer, similar concept):

function custom_function($importer_id, $csvfile_path) {
  // Load the Feeds Source object.
  $source = feeds_source($importer_id);
  // Load the source fetcher config.
  $fetcher_config = $source->getConfigFor($source->importer->fetcher);
  $fetcher_config['source'] = $csvfile_path;
  $source->setConfigFor($source->importer->fetcher, $fetcher_config);
  $source->save();
  $source->startImport();
}

Make sure that you are using the foreground configuration, this way the batch process could be be executed "inside" drupal with showing the progress bar. Or you can force it:

// Tweak the importer configuration, to enable "Process in the background".
$config = array(
  'process_in_background' => TRUE,
);
$source->importer->addConfig($config);

// Execute the import.

Another approach could be to schedule it

// Schedule the import, and make sure importer is scheduled, too.
$source->schedule();
$source->importer->schedule();

This is a good article about feeds importer


Show virtual node in views How to show virtual node if there is no result in the views(date template) that use Contextual filters?

Inside your view under the advance tab

Click on "no result behavior"

Chose " Entity: Rendered entity "

Add a label

Entity type "node"

Entity id "enter the node id" for the node you want to show if no result was found.

chose appropriate view mode.

here an export of a view that returns node 1 if you have no articles in your system

$view = new view;
$view->name = 'retrun_homepage';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Retrun homepage';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* No results behavior: Entity: Rendered entity */
$handler->display->display_options['empty']['entity']['id'] = 'entity';
$handler->display->display_options['empty']['entity']['table'] = 'entity__global';
$handler->display->display_options['empty']['entity']['field'] = 'entity';
$handler->display->display_options['empty']['entity']['label'] = 'Show homepage';
$handler->display->display_options['empty']['entity']['empty'] = FALSE;
$handler->display->display_options['empty']['entity']['entity_id'] = '1';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'article' => 'article',
);


Problem in drush configuration with wamp server 64 bit I am trying to enable drush for wamp server 64 bit.

I have configured all things with youtube videos and it seems it must be ok but when I run drush via cmd console, I see this error message :

PHP Warning:  PHP Startup: Unable to load dynamic library './php_gd2.dll' - The
specified module could not be found.

My operating system is windows 7 64 bit. so I have installed Wamp server 64 bit version. PHP version is 5.5.12 and apache version is 2.4.9

I don't know what is the reason of this problem. I checked my php.ini
extension path is ok. also I can see "php_gd2.dll" file inside extension folder.

so why I see this error that says specified module could not be found?

PHP for Apache and CLI have different configuration files, so check if you're using the right one.

To identify which php.ini is used by drush, run drush status:

$ drush status
PHP executable         :  /path/to/bin/php
PHP configuration      :  /path/to/php.ini

then edit that file and check if you've the right extensions specified.

Alternatively check using php command, for example:

$ php -i | grep php.ini

Note: In case grep command is not found, replace with the with find.

If you still have a problem, possibly that your DLL library was compiled for the wrong version of PHP. So either use the one included with WAMP, or download the right one specifically for that version of PHP.

Also double check that your command-line php points to the right place (WAMP folder):

$ where php
$ which php

which should give you C:\WAMP\PHP\bin-like path, if it's not, update your system PATH variable in advaned system settings.

Finally to check if your GD2 library is loaded, check by:

php -r "phpinfo();" | grep gd2

Note: The grep can be replaced with find on Windows if you don't have Linux command utilities installed.


Unable to enable theme debugging I am trying to figure out which template file is used in a page and I stumbled upon this variable to enable in the setting.php

$conf['theme_debug'] = TRUE;

I did enable the variable in the settings.php and in default.settings.php (what is the difference actually?), but with no luck on seeing the generated output in the markup. And of course cleared the caches several times.

So am I really blind to the generated output? Where does it actually generates?

Permissions issue. That simple. And I wasn't noticing it.

setting.php file has read only permissions (444) by default. So I changed to 644 permissions and that's it.


Drupal 7 Weform 4 attach file message stays even though correct size file is updated I have set a file size limit of 4mb for the file type field.

Current behavior
When a file greater than 4mb is attached (10mb.jpg) and upload button is clicked, there is a message shown that mentions.
"The specified file 10mb.jpg could not be uploaded. The file is 10 MB exceeding the maximum file size of 4 MB..

Now when a file size of less than suggested limit and extensions ( 182kbs - 800px-pizigani_1367_chart_10mb.jpg) is attached and upload button hit, the message still stays and does not go away.

Expected Behavior:
On attaching and hitting the upload button for the file of correct size, the error message should not be displayed.

Let me know if this has been rectified in a later release or is still occurring for others.

Note: If the upload button is not hit and directly the webform is submitted, the functionality does work fine. Thus there seems to be an issue in client side validation.

Have you checked PHP's own maximum upload file size?

Default in php.ini is usually this:

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 2M

You can check your own site's setting at your sites /admin/reports/status/php


Multiple independent Views attachment pagers (load more) I have a view with two attachments. I want to have a load more button to load items for each attachment and the main view separately, I have the load more module, but it loads more items for all the views, not for each attachment separately. Any help will be appreciated.

Make sure you have unique pager id's for all your view displays.
You will find the option in Views under the paging section of your display.

EDIT

As noted below, attachments don't have the option to add a unique ID, this is a known limitation. See for example this discussion on Drupal.org.

It is currently not possible to solve this issue in Views only. If you want different paging options, you can not use attachments. A workaround is to use block displays and place them on the same page as the main view. (Do change the pager ID of the block views only if there are still problems).


Figuring out a conditional statement for a specific page I have a view which is modified by a views template page - this is in Drupal 6.

I'm trying to figure out a condition to affect the layout. Currently, the  element seems to be generated in page.tpl.php, which is fine, but I want to add a condition for this specific page, in order to add an id to this element.

For other pages, I've used the node id to do this, as such:

else if ($node->nid == '250' || $node->nid == '429' || $node->nid == '555' || $node->nid == '378') {print '<h1'. ($tabs ? ' class="with-tabs"' : '') .' id="medspecheader">'. $title .'</h1>';}

But I'm not sure how to do this with the view page. Is there a machine name that I can use, or something to affect the layout?

If you are asking how to modify the default page.tpl.php to do something different when a specific path is called, you could just copy page.tpl.php to page-PATH.tpl.php, eg, page-PATH-THAT-VIEWS-USES.tpl.php and then anything inside this new template would be used just for the page displayed at that path.

In your example code, as an example, you could copy page.tpl.php to page-node-250.tpl.php or page-node-429.tpl.php etc and then you wouldn't need any ifs in them with respect to the id="medspecheader" as these templates would only be used when looking at those nodes.

Just realize that the path used is the drupal system path, not any alias, but Views does create such a path for any Views that utilize a Page Display.

Lots more information about template suggestions for Drupal 6 can be found here.

If these don't work for your specific needs, you can also create more templates suggestions for Drupal to use via a hook_preprocess_page() call in your module or theme.

For example, if you wanted the page to display differently whenever a specific node type is being displayed, and you didn't want to hard code in all of the specific node nids, you could do something like this in your theme...

function YOURTHEME_preprocess_page(&$variables) {

  if (isset($variables['node']) && $variables['node']->type=='med_special') {
    $variables['template_files'][]='page-cck-' . str_replace('_','-', $variables['node']->type);
  }

  // any other page preprocessing goes here

}

Now, whenever page displaying a node of type med_special is called up, Drupal will look for a page-cck-med-special.tpl.php file in your theme to display it.


Do third party drupal modules pose a security risk? This may very well be a stupid question but there is no avoiding it now. Unfortunately myself and many others succumbed to the temptation of skipping learning ubercart in lieu of obtaining a seemingly quick and easy 3rd party module for commerce.

Today drupal alerted me to an update for this 3rd party module but deleting it is not picked up by the refreshed module list, it simply vanishes and then when you try installing new version it remains stuck in checked position so that no new version can be installed and no uninstall can ever take place.

Of course the creator of this module has disappeared off the planet leaving myself and many others with less money in our pockets and red faced and some very angry with no support.

All of us say it is the first paid drupal module we've ever acquired because it did seem such a very good idea and easy to implement and the young man who made it was extremely helpful and professional at first.

It is still working on my site albeit unable to be updated but strange companies like soso.com in China have infiltrated this creator's site and are being listed in user's list of domains including mine so is this not a most terrible security risk for anyone using it with rest of the well maintained open source drupal?

update: the owner of these modules has actually returned and is back to usual professional good self. :) all's well that ends well.

Well, have you deleted that module without disabling & uninstalling it first? Some of your effects seems to be that way. Anyway, automatically updating a module from 3rd-party server is only as secure as his server. If you did it, and source server was compromised, you should consider yours compromised, too. Only safe way? Revert from backups to the last snapshot you are reasonably sure to be safe, and then do not update that module (possibly uninstalling it as soon as feasible).


CKEditor/TinyMCE does not apper or show up at text fields My CKeditor was working fine untill it suddenly stopped and does not show tabs on the body fields. I have uninstalled it and installed it again but the problem still persists.I have tried to use Wysiwyg Module and tried TinyMce but they all dont show up the tabs

drupal 7

tinyMCE 4.5.1

I have gone through all the similar questions and solutions and none seem to work. i am stuck for the last 3 days. please help me out

just a shot in the dark, but have you checked to make sure your text profiles are still correct? You may have to go in and reselect wysiwyg tools for your profiles.


View block with contextual filter on taxonomy term name in URL doesn't work Say, I have taxonomy vocabulary 'fruit' with terms like 'apple', 'pear' and 'grape'.
Through content type 'Healthy', 'Healthy' content is made using a entity reference field to choose a term from the 'fruit' vocabulary.

Now, on a page with path /food/good/apple, a views block is placed that should show content related to taxonomy term 'apple'.
I've tried to make a contextual filter in the views block like this:

When the filter value is NOT available > Provide default value > 'raw value from URL'
And for 'Path Component', I checked 3 (for the third position in the url, 'apple').
This however doesn't return any content.
When I remove the contextual filter, the block shows all Fruit content items.

Can this even be accomplished without using contrib modules?
Any help on how to get the right setup would be welcome!

Your contextual filter will be expecting the term ID rather than the term name. You'll need remove that contextual filter and then add a relationship to the taxonomy which will then allow you to add a contextual filter for the taxonomy term name rather than the term ID


AJAX: Form API Dependent Drop Down with more options Started with the example here:
https://api.drupal.org/api/examples/ajax_example!ajax_example.module/function/ajax_example_dependent_dropdown/7

However, I then wanted to add a third option that was depended on the first two (which is not in the example given)

The problem I first ran into was that when I updated the first dropdown it would update the second, but not the third.

So I changed the callbacks from

function ajax_example_dependent_dropdown_callback1($form, $form_state) {
  return $form['dropdown_second'];
}

and

function ajax_example_dependent_dropdown_callback2($form, $form_state) {
  return $form['dropdown_third'];
}

to

function _ajax_example_dependent_dropdown_callback1($form, $form_state) {
  $commands[] = ajax_command_insert('#dropdown-second-replace', drupal_render($form['dropdown_second']));
  $commands[] = ajax_command_insert('#dropdown-third-replace', drupal_render($form['dropdown_third']));
  return array('#type' => 'ajax', '#commands' => $commands);
}

function ajax_example_dependent_dropdown_callback2($form, $form_state) {
  $commands[] = ajax_command_insert('#dropdown-second-replace', drupal_render($form['dropdown_second']));
  $commands[] = ajax_command_insert('#dropdown-third-replace', drupal_render($form['dropdown_third']));
  return array('#type' => 'ajax', '#commands' => $commands);
}

Which got me most of the way, but I still have one problem left.  It seems that when I update the first dropdown, it updates the options in the second box but doesn't send the updated value into my options function to get the new options for the third box.

Here is my code:

function cquiz_create_exam($form, &$form_state) {
  $subjects = _cquiz_get_subjects();
  $selected = isset($form_state['values']['dropdown_first']) ? $form_state['values']['dropdown_first'] : $subjects[key($subjects)];

  $form['dropdown_first'] = array(
    '#type' => 'select',
    '#title' => 'Select Subject',
    '#options' => array_unique($subjects),
    '#default_value' => $selected,
    '#ajax' => array(
      'callback' => '_cquiz_create_exam_callback_first',
      'wrapper' => 'dropdown-second-replace',
    ),
  );

  $type = _cquiz_get_type($selected);
  $selected2 = isset($form_state['values']['dropdown_second']) ? $form_state['values']['dropdown_second'] : $type[key($type)];

  $form['dropdown_second'] = array(
    '#type' => 'select',
    '#title' => t('Exam Type'),
    '#prefix' => '
',
    '#suffix' => '
',
    '#options' => _cquiz_get_type($selected),
    '#default_value' => isset($form_state['values']['dropdown_second']) ? $form_state['values']['dropdown_second'] : '',
    '#ajax' => array(
      'callback' => '_cquiz_create_exam_callback_second',
      'wrapper' => 'dropdown-third-replace',
    ),
  );

  $form['dropdown_third'] = array(
    '#type' => 'select',
    '#title' => t('Number of Questions'),
    '#prefix' => '
',
    '#suffix' => '
',
    '#options' => _cquiz_get_number($selected, $selected2),
    '#default_value' => isset($form_state['values']['dropdown_third']) ? $form_state['values']['dropdown_third'] : '',
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}

In the $form['dropdown_third'] section you can see that the options are defined by another function.  That function doesn't get redone after changing the first drop down box.  How do I get it to reload those options using the new select values?

Not totally sure, but setting $form_state['rebuild'] = TRUE in your submit or validation handler may help here.

  This is the key function for making multi-step forms advance from step
  to step. It is called by drupal_process_form() when all user input
  processing, including calling validation and submission handlers, for
  the request is finished. If a validate or submit handler set
  $form_state['rebuild'] to TRUE, and if other conditions don't preempt
  a rebuild from happening, then this function is called to generate a
  new $form, the next step in the form workflow, to be returned for
  rendering.

https://api.drupal.org/api/drupal/includes!form.inc/function/drupal_rebuild_form/7

Another option would be to replace the entire form on in your AJAX callback. So essentially you'll specify a #prefix and #suffix for the entire form and then use that prefix element id in your $form['dropdown_first/second']['#ajax']['wrapper']. Your callback will look something like this:

function ajax_example_dependent_dropdown_callback($form, $form_state) {
  ...
  return $form;
}


Drupal View Show Webforms NOT Submitted By Logged In User I'm hoping someone can help me out with this because I have been stuck on this for days...

I have a bunch of webforms that each user needs to submit. I figured out how to show a view of the webforms the logged in user has submitted, but what I am stuck on is showing the webforms the user has NOT submitted in a view. So it would be a list of the webforms the user still needs to fill out.

There must be something small I am overlooking. I appreciate any ideas or help, thanks!

Im not sure about this question: but here you go. Go to View and to ADVANCED>RELATIONSHIP> SElect USer. After that FILTER CRITERIA and add USER as well. NEXT, create roles and work around roles and users.


Diferences between: migrate_d2d and migrate I need to migrate a d7 site to a d7 distribution. This is to migrate from d7 to d7.

I found this modules which I undertand will help me with this task.I've read the documentation but I don't fully understand the diferences between them.

Which one is the right module for my situation?

From Drupal-toDrupal data migration (migrate_d2d) module page:

  migrate_d2d provides a framework based on the Migrate API

So the diference is - migrate is an API module for migrations, and migrate_d2d uses it to perform task like yours. Either way you will use migrate, only difference is - do you feel you need to write what authors of migrate_d2d already wrote? Or maybe you want to use or modify their work to save some time?


How to get node's view mode in hook_page_attachments? I need to get the node's view mode so that in the mymodule_page_attachments, I can add libraries conditionally if the node's view mode is set to full or default. I tried the following but not able to get the nodes view mode once I retrieve the$node` object.

How to get node's view mode in hook_page_attachments?

Here is what we tried:

function mymodule_page_attachments(array &$attachments) {
  $node = \Drupal::routeMatch()->getParameter('node');
  if(is_object($node)) {
     // we tried printing but that didn't result any view_mode field.
     ksm($node);

    // Goal
    if($node['view_mode'] == 'full' or $node['view_mode'] == 'default') {
       // proceed with my logic.
    }
  }
}

To attach a library only when a node in a certain view mode is displayed you can use hook_entity_view/hook_ENTITY_TYPE_view like following.

/**
 * Implements hook_ENTITY_TYPE_view().
 */
function MYMODULE_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {

  $node = $entity;
  if ($node->bundle() === 'page') {
    if ($view_mode === 'full') {
      $build['#attached']['library'][] = 'MYMODULE/foo';
    }
    elseif ($view_mode === 'default') {
      $build['#attached']['library'][] = 'MYMODULE/bar';
    }
  }
}


Use Ajax to load full node including comments and comment form I tried to use Ajax links API Module, nice module it even replace url when loading page but it works so slowly... I can wait page loading even for few minutes. I found another solution seanbuscay.com it works better but it doesn't load comments and comment form. I would like to load full node including comments (create view reference field with related comments didn't help).

I found some similar topics

Ajax via Jquery and attach behaviors

Load and interact with a node comments from their related node

Is it the best solution for Drupal 7 t use drupal.attach.behaviours?

Have anybody experience with loading full nodes with comments via ajax?

This modules contains a lot of extra code for your case and probably make too much unnecessary actions. You should to make a little script to make jQuery.ajax that make request, insert your node with comments in  and connect it to your theme. This modules made request by Query.ajax too.

Less code - faster action and may the force be with you.


Cannot get form_state storage or protected form values to work I am building a form using formBuilder. I have tried two methods to store values across form submit/validate for usage in ajax callbacks, but have been unsuccessful in either.
The first method, was to store a value in $form_state->set('name','value'); and retreiving it in the form submit/validate handler. That returned an empty result.
The second method was to store a variable on the class itself protected $image_deltas = 0; and then when the ajax form submit/validation is triggered, $this->image_deltas++; However, when I do this, it still does not work.
The following is the code I am using.
$form['images'] = [
  '#type' => 'container',
  '#id' => 'images',
];

dpm($this->image_deltas);

for ($i=0;$i<=$this->image_deltas;$i++) {
  $form['images'][$i]['image'] = [
    '#type' => 'textfield',
    '#title' => t('Image Path:'),
  ];
}

$form['add_another'] = [
  '#type' => 'button',
  '#value' => t('Add Another Image'),
  '#ajax' => [
    'callback' => [$this, 'addAnotherImage'],
    'wrapper' => 'images',
  ],
  '#submit' => [$this, 'addAnotherImageSubmit'],
  '#limit_validation_errors' => [],
];

The form submission handler is the following.
public function addAnotherImageSubmit(&$form, FormStateInterface $form_state) {
  $this->image_deltas++;
  $form_state->setRebuild();
}

The AJAX callback is the following one.
public function addAnotherImage(&$form, FormStateInterface $form_state) {
  return $form['images'];
}

When I submit the form, dpm() prints 0 every time. The same thing happens if I use $form_state->set('image_deltas') and $form_state->get('image_deltas').

This:
'#submit' => [$this, 'addAnotherImageSubmit'],

Should be this:
'#submit' => [[$this, 'addAnotherImageSubmit']],

Submit handlers are only called for #type submit and not #type button, so you'll need to change the type.
You will also need to use $form_state->set(), rather than a property on the class. This is because the form class is re-instantiated for each iteration (build, validate, submit), and therefore values stored in the properties of the form class will not persist. $form_state->set() persists values, as these are stored in the database, and are repopulated for each instance of the form class (as long as you call $form_state->setRebuild() as you have done).


How can I place content in page_top in D7 since it is hidden in regions? I need to place a small menu in the page_top region using D7. I know the region is hidden, so my thought is to create a completely new region in the place that page_top would be showing up (I'm not sure how this is done). I have been creating a subtheme using Zen. Does anyone have an idea about how I can do this? Help is sincerely appreciated.

In the .info file of your theme you can add regions.

The template files that control your page layout are going to display that region.
Usually page.tpl.php will have the regions called upon for display.  So if you add a region to the .info file you will need to add the region in the page.tpl.php file as well.

Great article here... a little dated.. but still works.
http://yuriybabenko.com/blog/creating-new-drupal-regions


How to break up long words in a views display? I have a "related discussion" block view. Long words like links are breaking my layout.

Is there a way to force line breaks on those long words?

I could limit the length of links that then they wouldn't be as useful.

Update:
Turns out that the CSS doesn't work across all browsers and also wraps regular words in funny ways sometimes.

Is there a way to do this in Drupal?

There are no universal solutions to this issue. But the currently acceptable ones are to use the wbr HTML tag (perhaps with some JS), or to, as you have seen, use break-word (as opposed to Chrome's break-all) along with some fallbacks. Both of these solutions are proposed here. Drupal.org uses or used to use the word-wrap: break-word; solution.


Path aliases don't work We are running Drupal 7 on NGINX. The config has worked fine except that path aliases are ignored. When we navigate there, we get a "file not found" page instead of a redirection to the node.

Clean URLs work fine -- the site navigation using clean URLs works perfectly. It's just the aliases that are not working. We used this config example as the basis for the setup: https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/

Any ideas on what we're missing?

If you just add the following snippet under -> location ~ '.php$|^/update.php' {

#Redirect urls with php extension
if ($request_uri ~ .*.php.*) {
        error_page 404 =  @rewrite;
}

that should get it to work! It's basically telling nginx how to handle urls with .php extension.

And then restart nginx

sudo service nginx restart


Adding core Javascript libraries in my_module.libraries.yml I've read Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 module and I can see where you can add assets that are part of your module or from a CDN or external source. What about if that library you want to add is already a core asset?

I'm trying to add jquery.ui.accordion to my modules so in my *.libraries.yml I have:

my_module:
  js:
    /core/assets/vendor/jquery.ui/ui/widgets/accordion-min.js: { minified: true }
  dependencies:
    - core/jquery.ui
    - core/jquery.ui.widget

That library is never loaded. What am I missing? Is there a better way to add core assets to my module?

EDIT: I've also tried different paths like:

core/assets/vendor/jquery.ui/ui/widgets/accordion-min.js: { minified: true }
../../../core/assets/vendor/jquery.ui/ui/widgets/accordion-min.js: { minified: true }

I just scraped the MY_MODULE.libraries.yml and utilized one of the other methods of adding assets, by:

function MY_MODULE_page_attachments(array &$attachments) {
  $attachments['#attached']['library'][] = "core/jquery.ui.accordion";
  //new addition below
  $attachments['#attached']['library'][] = "MY_MODULE/MY_MODULE.accordion";
}

This works for me. Perhaps you don't need a MY_MODULE.libraries.yml if you are trying to add libraries that already exist in core.

Edit: So I still have a MY_MODULE.libraries.yml file however it now just adds my module's javascript (with a dependency to jQuery). It's just some Javascript that initializes jQuery UI accordions. I still use the code above to add jQuery
s UI accordion javascript and my own.


Is there a CCK fieldtype that would display a static field? I'm looking for something like the 'textfield' CCK fieldtype, except instead of displaying a label and an edit box with a value - it would just display a label and a value as text during both edit and view operations.

So for example, as a textfield it might display like this:
label: [value]

as a 'static' CCK fieldtype it would display like this:
label: value

I've tried disabling a textfield, but our User Experince folks don't like the fact that the field has a box, but yet really never becomes editable.

Thanks for all your help,
Greg

If I understand correctly, you don't need an input element at all. In this scenario, you can use hook_form_alter() or hook_form_FORM_ID_alter() in a custom module of site specific customizations to add a form element of type 'item':

$form['my_form_component'] = array(
  '#type' => 'item',
  '#title' => t('My Label'),
  '#markup' => t('This text follows the label'),
  '#description' => t('An optional description appearing below the markup'),
);

See the Forms API Reference for more details.

Edit: If you're not interested in custom modifications, the Markup module seems to provide this kind of utility in a contributed module for D6


How to load a apache solr document and send it for reindex after editing is done in drupal 7 As title says,

I want to load a particular node's document and When the editing is done, I need to send the modified document to Solr for re-index programtically.

How it can be done?

When using the apachesolr module, nodes are automatically marked for reindexing after an edit.  So there is nothing you need to do.

If for some reason you need to manually mark a node, the code is

apachesolr_mark_entity('node', $nid);


Create a Node with Fields and turn them into tabs in a display? I am a Drupal 7 newbie, I am only proficient in CSS and HTML and I am looking for someone to point me in the right direction(to documentation/modules/advice) on how to execute what I am trying to do or even telling me if it is possible or not.

I tried making tabs already, I was using quick tabs and multiple blocks but I found that would be inefficient because I need 12 pages with tabs and each has at least 2-3 tabs with content each that need to be eventually edited by heads of departments.

What I am trying to do:

Create a page with multiple tabs and content inside of it.
When editing the node there should be multiple tabs at the top corresponding with the tabs on the page and an option to add more tabs up to a limit
Tabs should have a title and body field.

Some examples of the content of the tabs: welcome, about, programme. They would just have 1 or two paragraphs of content.

How I was thinking it could be done:

Creating a New Field type called Tab, that groups a title & body
Creating a New Structure type that has max of 6 Tabs
Create a new display to have the fields organized into tabs.
Download Module for displaying tabs in editing mode?

I just don't know how to make that possible or if it is. Can someone point me in the right direction or help me to come up with a better alternative?

The easiest approach to create tabs to nest your content for visitors to see on your pages without much hassle is to try to use the Field Group module in D7.

Another solution is to use the Paragraphs module with 2 fields: title and body. And try to setup Field Groups possibly to treat each paragraph entry as a Tab on the page ...


How to do "has term (with depth)" filter on field of a related field i have a content type 'product', and two taxonomy lists 'company' and 'country'.
Country list has one level of depth like:

........
state1
-city1
-city2
........

Each product has a 'company' field. Each 'company' term has a 'country' field.
I'm trying to create a view for 'product', filtering by 'country'.
By adding the relationship "content: Company" i have only "taxonomy term: field_country" filter without depth.
There is a way to filter with depth like "Has taxonomy term (with depth)" ?

I'm on drupal 7

You would not require a Relationship, just two Contextual Filters.

Based on your requirements Company would be one Contextual Filter - Content: Has taxonomy term ID and Country would be a second Contextual Filter - Content: Has taxonomy term ID (with depth).


How to ensure that features dont get overidden I tried many times with many setting in features but when i add it and enable it always its overridden and i have to go and revert it. Basically block settings and strongarm have to reverted. So is there anything that i ensure while creating features such that it does not get overridden.

There are a number of reasons why Features may automatically show as overridden after being installed and not manually changing any Drupal configurations related to the Feature. There is a documentation page about this issue: Troubleshooting: Reasons Features May Be Stuck as Overridden. That documentation page is not complete, but it links to a Features issue queue thread where a lot more of the possible problems are outlined.


How to show a field in a view taken as input in a different content type? I made a form Company Information, which contains standard fields like Name, Address, Rating etc.

Now I am taking Rating from a different content type "Company Reviews", under Rating Field.

What I want to display various fields from Company Information and Company Reviews in a single view. I tried using the machine name in twig but somehow the view is showing values from Company Information but not from Company Reviews.

Does this sound familiar? I am sure it can be done but I am missing out something. Any help or even a direction is much appreciated, thanks.

[ UPDATE 1]

So, I was researching this for a while and just after posting the question I stumbled upon "Entity Reference", but it seems that this is not available for drupal 8
can we do this in drupal 8 somehow
https://www.ostraining.com/blog/drupal/entity-reference-views/

[ UPDATE 2]
The entity reference was suppose to show up in Add Relation under Advance Tab

And I am getting a few fields,  but not the ones I want.
neither the view is showing following entity relation

instead, I am having this on my dashboard,

so I went ahead and added Review content filter anyway, as a result, the Listing View started showing the reviews as companies, which was not the desired result, using review title as company title.

Do I require a module or should something have be-be done at content types Company Profile and Review?

[ UPDATE 3 ] The Answer is correct, Here is how did it, if anyone is interested.

It was rather simple,

Suppose you have Content-Type A, and Content-Type B, and a result View C

In Content Type A, you add a field, that is actually a Reference to Content-Type B, let's call it ref-AB. Similarly, Add add a field, that is actually a Reference to Content-Type A, say ref_BA.
Now fields of A & B Content-Type are related, and you can show them in the view.

To Show them in a view, you need to add "reference to the content" as a relation in view ( Go to view> your-view > advance > add relation). Suppose, you added ref_BA to your view, then all fields of content type B, will be available in your view.

In your view, add the field you want to show, making relation to ref_BA.

Entity Reference is now included in Drupal 8 core.
To use it, simply add a field "Reference-Content" and you may use your Company Reviews content type. Then, following the tutorial from your link, you should be able to add any field from Company Reviews in a view showing content of type Company Information.


Drupal 7 Views 3 exposed filter preselected I'm having a bit of a hard time configuring a preselected exposed filter on views.

I have a View (mysite.com/view-path) with an exposed filter as a select list with options:

Option 1
Option 2
Option 3

I want to be able to access the view with a preselected option in the exposed filter from another page (mysite.com/page) with a link like so (mysite.com/view-path?option=1)

Right now i've made a form alter on the exposed view filter with this:

if (!empty($_GET['option'])) {
   $form_state['input']['field_option_tid'] = $_GET['option'];
}

The problem is that this works, but when i try to click the select list and change the value to Option 2 for example, it will revert back to Option 1.

Use a custom module for this

function MYMODULE_form_views_exposed_form_alter(&$form, &$form_state) {
  if (!isset($form_state['view']->exposed_input['<filter_field>'])) {
    // OK to set the default value
    $form_state['input']['<filter_field>'] = '<new_default_value>';
  }
}

Where filter_field is the name of the exposed filter and new_default_value is the key of the value you want as the default.

Got the idea from this article