Adding content type to the class of each views row

You can add that into the views fields template for the row or you can add a node type field to your view, and make sure it's first or before the field you want to add the class to, and disable its display.    Then, you can go to the field you want to add the type class to, select rewrite output, and use the contents of this first field as a replacement value in the class of the wrapper element.

Just rereading, the above just wraps a field in your row.  To put that class in the row's html, you could edit up views-view-fields.tpl.php for your specific view and add a div wrapper yourself with that information in it (grab it all out of the $row variable provided).  Keep the node type field in there but have it not displayed.

So, for example, if your view is named foo, you could create a views-view-fields--foo.tpl.php with this in it:

<div class="<?php print $row->node_type; ?>">
<?php foreach ($fields as $id => $field): ?>
  <?php if (!empty($field->separator)): ?>
    <?php print $field->separator; ?>
  <?php endif; ?>

  <?php print $field->wrapper_prefix; ?>
    <?php print $field->label_html; ?>
    <?php print $field->content; ?>
  <?php print $field->wrapper_suffix; ?>
<?php endforeach; ?>

where, if I am cutting and pasting right today, the only thing I've added is the opening div and closing div.  This then wraps your whole row in your own div with class of nodetype.

You can find all of these templates in the views style information area (make sure your views code matches mine).  Just save them in or under your theme directory.

ADDITION:

If you want to have the class in
 instead of adding another
 inside it, you can copy views-view-unformatted.tpl.php to one appropriately named for your view and grab the information needed for the node-type out of the $view variable there.  You could also use a views_preprocess() function to do it, although for stuff like this I like seeing it in the template, but that's just me.  The function should be mythemeormodulename_preprocess_views_view_unformatted(&$vars) and you can add or modify any of the vars you want, once again, since $view is present, all the information about the view is as well.  For ideas, check out the views code in sites/all/modules/views/theme/theme.inc, or where ever module code is stored on your machine.


you can use Twig Tweak Module, will gives you twig extension called drupal_blockand you can render your block like the following :

{{ drupal_block('shariff_block') }}

Take a look to the module Cheat sheet for more info.

Note : Shariff Module provide block with the id shariff_block not shariffsharebuttons.


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

drupal_process_states() takes the parameter $elements and contains the example:

array(
  'visible' => array(
    ':input[name="remote_checkbox"]' => array('checked' => TRUE),
  ),
)

Your example is very similar:

array(
  'disable'=>array(
    ':input[name="profile_main[field_cellphone][und][0][cellphone]"]'=>array('filled'=>TRUE),
   ),
 )

But I noticed that 'visible' is an adjective while 'disable' is a verb so I checked the list of available states on the drupal_process_states() documentation and found:

  The following states may be applied to an element:

  enabled
  disabled
  required
  optional
  visible
  invisible
  checked
  unchecked
  expanded
  collapsed

So it looks like your problem boils down to a missing letter 'd' on 'disabled'.


This will work:

RewriteRule ^todo/(.*)$ todo?month=$1 [L,QSA]

No need for the rewrite condition.

That will internally forward, e.g. http://example.com/todo/january to http://example.com/todo?month=january.

Make sure you add that code before Drupal's main index.php RewriteRule


Okay, the answers to your questions are both rather simple.

Your columns are uneven because you did not apply a width to the columns. To solve this I simply applied a percentage width to the td element as follows:

.view-view-services .view-content td{
   width: 33.33%;
}

When you make your browser's viewport smaller, your images become smaller. This is due to the auto properties applied to the img tag's height and width. To solve the issue I overrode the max-width property as follows:

.view-uc-products .views-field-uc-product-img img{
   max-width: none;
{

Let me know if you have any questions!


How do I grant edit access on workbench to specific users?

I solved my problem as follows:
1) Using hook_views_query_alter I fetched the desired rows. With that step I was able to see in the recent content list all the rows I want but with edit link only to the ones that the logged in user has created.
In order to see the edit to the rest of the rows whose author is somenone else I followed the step 2.

switch ($view->name) {
case "workbench_recent_content":
...
unset($query->where);
....
$where_expression = MY where statement where I filtered by content type and by a field_location field that exists on all of my content type.
 $query->add_where_expression(0, $where_expression);

2) I created a rule, on node save, grant edit access to the people that have a specific role and belong to a specific country. That way the edit link appeared even all the rows I wanted.


8 - How do I load a Term entity from an EntityReferenceItem?

$node->country->entity.

See http://wizzlern.nl/drupal/drupal-8-entity-cheat-sheet, where it lists the properties of common field types.

If you want to see the properties of a field type, one way to do that is by looking at the propertyDefinitions() method of the field type class, in this case EntityReferenceItem.


Does Aegir 3 allow multiple SSL sites on the same IP Address?

Indeed it does. From the release notes:

  Aegir 3 now supports SNI for SSL.


dissecting the og module - where is the content type form submit handler for function og_ui_form_node_type_form_alter?

This happens automatically.

Adding a variable to that form means that it is automatically saved with variable_set() with a _node_type suffix. Similar to admin forms.

Here is another example: userpoints_nc_visits_form_node_type_form_alter().

As you can see, the form element is for example named userpoints_nc_visits_points and the default value is fetched with userpoints_nc_visits_points_type (inside the get setting api function).


I got this working, and I didn't need Eva, Views Field, or Panels. I just needed good ol' fashioned Views.

I created a View with a Page and a Block.

Page displays images and takes contextual filters Term (of vocab Camp) and Date.
When the value is not in the URL, a summary is displayed.

Block displays Terms (of vocab Tags) and takes the same two contextual filters. When the filter value is not available, I choose Provide default value > Raw value from URL > and select relevant path component.

I set the block to display on all pages, but on pages that don't pass it recognized arguments it just doesn't appear because it's empty.

Voilá. So much simpler than I thought.


Take a look at this one: https://www.drupal.org/project/search_by_page

Hope this is what you require.


views_report_state_field.inc

class views_report_state_field extends views_handler_field {
  function query() {
    // Query
  }

  function render() {
    return "working!";
  }

}


Unwanted data show after add password-comfirm

Your browser autocomplete functionality is responsible for this.

If it's undesirable something like this should fix it:

$form['waiter_name'] = array(
  '#type' => 'textfield',
  '#title' => t('Waiter Name'),
  '#maxlength' => 70,
  '#description' => t("You Need To Add Waiter Name. "),
  '#required' => 'true',
  '#attributes' => array('autocomplete' => 'off'),
);

I would expect just adding it to the name field is enough, the browser shouldn't try to fill the password if it doesn't perceive a username.


Its not good idea to have one page or node with 2 different url, what i suggest to you is to override node view page with panel and create 2 variants.

Create the 2 different views panes and drop them each one in variant.

In the link to that node add GET variabile and switch the right variant based on that

Example
/my-url will show the first variat
/my-ulr?show=1
Will show the second variant

You control that with panel visibility rule and use php code to check the $_GET array


How to alter the uc_address:city form field?

If you are using Addressfield module you can easily do that extending the module itself.

Look into the sites/all/modules/addressfield/plugin/format & you will see address.inc, where you can extend the list of region or city.

You can look for the example in sites/all/modules/addressfield/example/plugin/format to better understanding of the the format which module will accept for extending it for your list values.


How to build and embed the output of a Message entity created by the Message module?

Got it.

$message = message_load($mid);
$build = $message->view();
$build += array(
  '#theme' => 'message',
  '#entity' => $message,
  '#view_mode' => 'full',
);
$output = drupal_render($build);


Cookies for anonymous users aren't read nor checked

Instead of making a custom cookie, try using Drupal's cookie system.

Set:

user_cookie_save(array('key' => 'value'));

Get:

var = $_COOKIE['Drupal_visitor_key'];

I just realised this is in php, not javascript as you have used so I will expand.  I made my overlay by creating a new page with hook_menu and am using hook_init to check for cookie values, redirecting to my new page if required.


Why are there .htaccess and php files in ./sites/default/php/twig

The PHP files are compiled Twig templates and the .htaccess file protects them from public access. You can switch off the caching of compiled twig templates by setting this service parameter to FALSE.

# Twig cache:
#
# By default, Twig templates will be compiled and stored in the filesystem
# to increase performance. Disabling the Twig cache will recompile the
# templates from source each time they are used. In most cases the
# auto_reload setting above should be enabled rather than disabling the
# Twig cache.
#
# Not recommended in production environments
# @default true
cache: true

You find this in sites/default/default.services.yml, which you have to rename to sites/default/services.yml to activate it.


How can I add a textbox in Site Information configuration

You need to add your own module if you're looking to alter this form. You'll need 2 things:

An alter form hook function to add the text field.
A submission handler to process the data.

Something like this...

function mymodule_form_system_site_information_settings_alter(&$form, $form_state, $form_id) {
  $form['site_information']['mymodule_site_organisation'] = array(
    '#type' => 'textfield',
    '#title' => t('Site Organization'),
    '#default_value' => variable_get('mymodule_site_organisation', ''),
  );
  $form['#submit'][] = 'mymodule_handler';
}
function mymodule_handler($form, &$form_state) {
  variable_set('mymodule_site_organisation', $form_state['values']['mymodule_site_organisation']);
}

Once implemented, you can reference your custom value by using variable_get('mymodule_site_organisation', '') anywhere you need it.


CKEditor displays entire site page when rich text is switched on

The issue was due to a php code used in the donate button of the same page which got rendered in all wysiwyg fields. There was error in the code which disallowed the search to function properly. I was able to identify the issue using elysia cron which displayed errors  when search cron was running. Checking the logs helped me resolve the issue.
Error in one page could cause the CKEditor to display the same page for all wysiwyg fields when switching on rich text is interesting. Thanks.


Combining two node forms: is that possible?

You can also use Flexifield to get 2 content types on the same form.

Like docs says:

  You define a field combination by creating a node type and adding
  fields to it. On a different node type, you can add a flexifield, and
  then on its configuration form, specify which node types to use as
  items within the field.


Regions missing on page templates defined in a controller

Are you rendering the regions in your twig template?

Like

{{ page.custom_region }}


Deleted content returns over and over again

Did you check the error log? is there any warning or error in there?

If not then you should manually delete it from database. just look for their ID and remove them from DB


Comment replies to be another comment type

You don't need to use two different comments you can use only one and hide the "special" fields if the comment is not a reply comment.


How do you display a pane in an organic group?

This is what you need to do on the view content pane:

Relationships: "Group membership: Node group membership"
Contextual Filters: "(group membership) OG membership: Group gid"
Pane settings: Argument input: From context > Og group ID

On the panel contexts:

Contexts: OG group > Og group from context

Then you should add the view content pane to the panel pane and the argument should automaticaly be set to "OG membership: Group gid" > "OG group".

These are required for it to work, and I'm currently using them.


You could dynamically add the the same tag to the referenced image nodes when the 'object' node is created (or updated). To do this, you'd implement hook_nodeapi() and check the $op parameter for either "insert" or "edit" (depending on when you want this operation to happen). Then you can pull out the node id's of the 'image' nodes being referenced and apply the terms. This way they have the same taxonomy based permissions at the 'object' node.

There may be other ways, but this seems like it should work for you. I actually do the same thing to set a CCK node reference value during creation. I don't have access to a coding environment right now, or I'd add code snippets.


Block visibility role section is missing

There is a bug in Rules 8.x-3.0-alpha6 that hides the core block visibility conditions. Please upgrade to Rules 8.x-3.x-dev. See https://www.drupal.org/project/rules/issues/3160347


Syntax for getting plain field value in computed field

I'd suggest you to start by understanding the structure of your entity. You could do something like
<?php print_r($entity); ?>
 to print on screen your entity object and understand how to reference each one of its fields.

You'll discover that you could get your title just by using $entity->title (in your example you are getting the first letter because you are treating it as an array).  You could also find that not all your fields might be have by the 'value' key.

Once you do that, you could get the fields values using field_get_items(). A basic example:

$items = field_get_items('node', $entity, 'field_keywords', $entity->language);
$item = array_shift($items);
$keywords = $item['value'];

And maybe you could take it one step further and wrap that in a reusable function:

/**
 * Get a node field's first value.
 */
function YOUR_MODULE_node_get_field_single_value($node, $field_name, $key) {
  $items = field_get_items('node', $node, $field_name, $node->language);

  if (!empty($items)) {
    $item = array_shift($items);
    return isset($item[$key]) ? $item[$key] : NULL;
  }
  else {
    return NULL;
  }
}

And call it like this (assuming that this field has a single value in it):

$keywords = YOUR_MODULE_node_get_field_single_value($entity, 'field_keywords', 'value');

Please note that the above function is just an example, your field might have multiple values in it. In that case, you'll need to iterate the array returned by field_get_items.


You can edit the form with function_form_alter(), and modify what to do on submit. Try this:

function MY-MODULE_form_alter(&$form, &$form_state, $form_id){
  if( $form_id == 'YOUR-FORM-NAME' ){
    $form['actions'][]= array(
      '#submit' => array('_CUSTOM_FUNCTION')
    );
  }
}
function _CUSTOM_FUNCTION(){
  //put what to do here
}


When you click on add / remove / edit a field / filter / sort / contextual filter etc.. at the very top, you need to change the For All displays to This page (override) so it does not affect all the other views. You only need to do this for the first time, it will remember your setting.

Note: field / filter / sort / contextual filter etc... each have individual settings.


Drupal does not restrict the usage of long strings in code. It is advisable to concatenate each line ($output .= '...';) for a readable code, but as you can see in Drupal code, long strings are not broken up, especially when used with t():

function field_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.field':
      $field_ui_url = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#';
      $output = '';
      $output .= '
' . t('About') . '
';
      $output .= '
' . t('The Field module allows custom data fields to be defined for entity types (see below). The Field module takes care of storing, loading, editing, and rendering field data. Most users will not interact with the Field module directly, but will instead use the Field UI module user interface. Module developers can use the Field API to make new entity types "fieldable" and thus allow fields to be attached to them. For more information, see the online documentation for the Field module.', array(':field-ui-help' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) :'#', ':field' => 'https://www.drupal.org/documentation/modules/field')). '
';
      $output .= '
' . t('Terminology') . '
';
      $output .= '
';
      $output .= '
' . t('Entities and entity types') . '
';
      $output .= '
' . t('The website\'s content and configuration is managed using entities, which are grouped into entity types. Content entity types are the entity types for site content (such as the main site content, comments, custom blocks, taxonomy terms, and user accounts). Configuration entity types are used to store configuration information for your site, such as individual views in the Views module, and settings for your main site content types.') . '
';
      $output .= '
' . t('Entity sub-types') . '
';
      $output .= '
' . t('Some content entity types are further grouped into sub-types (for example, you could have article and page content types within the main site content entity type, and tag and category vocabularies within the taxonomy term entity type); other entity types, such as user accounts, do not have sub-types. Programmers use the term bundle for entity sub-types.') . '
';
      $output .= '
' . t('Fields and field types') . '
';
      $output .= '
' . t('Content entity types and sub-types store most of their text, file, and other information in fields. Fields are grouped by field type; field types define what type of data can be stored in that field, such as text, images, or taxonomy term references.') . '
';

I would stick with this drupal usage, this is the best compromise for usage and good readability. Your first examples looks good, but adds extra line feeds. The second example is not good to read and the third is often used in scripts, but not very common in php code.


How can I update multiple drupal 7 sites on my server, using drush

You can simply create a Bash script, and feed in all the folder names in the sites/dir into Drush.

See this script for updating a Drupal site; modify it according your needs-

Remember that testing is a very important part of every site upgrade. You should include a manual testing phase after the pm-update, and then push each tested site back to the live site as they are found to be working.


New Drush install instructions use Composer for install, even on Drupal 7?

Drush uses composer to install its dependencies, so please follow the composer instructions regardless of whether you plan to use drush with Drupal 7 or Drupal 8.


After much playing and breaking I wrote some code in a custom module to save the current order to load to the users profile in a un-editable field

    function create_new_quote_menu() {
  $items = array();
  $items['create_new_quote'] = array(
    'title' => 'Start New Quote',
    'type' => MENU_NORMAL_ITEM,
    'page callback' => 'custom_callback',
    'access arguments' => array('access content'),
  );
  $items['quotes/%/Load'] = array(   // assuming you want to make this dynamic
    'title' => 'Quotes',
    'page callback' => 'create_new_quote_LoadQuote',
    'page arguments' => array(1),   // references %, i'm assuming this is all dynamic
    'access arguments' => array('access content'),  // don't do this, whatever permission you want goes here
    'type' => MENU_CALLBACK
  );
  return $items;
}

function custom_callback () {
  global $user;
  $currentOID;
  $user_full = user_load($user->uid);
  $currentOID = commerce_cart_order_new($user->uid);

  $updateUserParams = (array) $user_full;
    $updateUserParams['field_currentcartorder'][LANGUAGE_NONE][0]['value'] = intval($currentOID->order_id);

    unset($fullUser->pass);
    unset($updateUserParams['pass']);

    user_save($user_full, $updateUserParams);
drupal_set_message(t('You have Created a New Quote #'). $currentOID->order_id,'status');
drupal_goto('moulding');
}

function create_new_quote_LoadQuote($quote_to_load) {
  global $user;
  $user_full = user_load($user->uid);

  $updateUserParams = (array) $user_full;
    $updateUserParams['field_currentcartorder'][LANGUAGE_NONE][0]['value'] = intval($quote_to_load);

    unset($fullUser->pass);
    unset($updateUserParams['pass']);

user_save($user_full, $updateUserParams);
drupal_set_message(t('You Loaded Quote #'). $quote_to_load,'status');
drupal_goto('quotes');
}

function create_new_quote_commerce_cart_order_id($uid) {
  global $user;
  $user_full = user_load($user->uid);
  $orderidentifier = $user_full->field_currentcartorder['und'][0]['value'];
  $orderidentifier = intval($orderidentifier);
  return $orderidentifier;
}

excuse my uncommented code and poor module name but I got it working this this code set so I can now create and change orders from my view by pasing Quotes/[orderid]/Load via a link


how to managed form '#type' => 'text_format' toolbar

You need to +Add new text format over at /admin/config/content/formats

Then Configure your new text format and remove those icons by grabing them and dragging them from the active toolbar to the available buttons section

Lastly, instead of full_html, use your custom format for your custom module.


hook_views_pre_render(&$view) seems to be called after the pager rendering

I couldn't find any hook to sort the views result after the results so I ended up using the module "Views PHP" and sort my view using the following:

<?php
    $deliveryTime1Arr = delivery_time_lookup($row1->nid);
    $deliveryTimeRow1=$deliveryTime1Arr[3];
    $deliveryTime2Arr = delivery_time_lookup($row2->nid);
    $deliveryTimeRow2=$deliveryTime2Arr[3];
    if($deliveryTimeRow1>$deliveryTimeRow2) return 1;
    else if($deliveryTimeRow1 == $deliveryTimeRow2) return 0;
    else if($deliveryTimeRow1 < $deliveryTimeRow2) return -1;
?>


Turns out this error message was being created when clicking on a link that had http selected as its protocol.


Multipage Registration form, Confirmation Page Security Issues?

After further investigation, it appears that one option is to make a confirmation page that is called after the form does it's final submission. Essentially, somewhere in the form alter or form functions near the end (after database operations), add a variable to PHP's $_SESSION array that contains the Drupal form ID (a long string of random characters), and add to this array another sub-array that contains all the information you want shown on the confirmation page.

Then, in the confirmation function (or page if you want to do the .tpl.php version), pass the form ID as a variable in the url. Then use this form ID to get the array from the $_SESSION array and retrieve the information.

As an example, see the drupal_set_message() function since it too uses the PHP $_SESSION variable to pass information back to the user on the next page load.

To keep the user from using the browser-back button and resubmitting the same information again, check the $_SESSION variable for the same form-id before committing user changes to the database and stop the attempt if the form-id's match. In some cases (e.g., registering for a new user account), Drupal will complain anyway if one tries to submit duplicate information to the database (e.g., username exists already).


How to process different URL page via Drush?

As the article says, the uri parameter just populates the request information. Drush only uses this to find the site settings information.  At this point, just like in a web request, the context is the index.php page.

On a web server, the code inside the index.php takes the URI and causes the requested page to be rendered.

Drush does not do this step.  So, when you do your ev of the current_path(), you get the default page.

The article points out that you need to call the menu_execute_active_handler() in D7 to render the page.  This take the URI and converts it to the requested page.

If you want information about the page, you will need to embed your print statements in the code for that page.

NOTE: an alternative to trying to do this via Drush is to look at using the devel module (I recommend adding the kint addon as well). This allows you to place debug statements in the code that will print out on the web page, e.g. kint($node).  Very useful in determining the structure of data so you can grab the right bit.


Are the parameters of saved exposed Views filters saved in the database, and if so, how can I access it?

Use Saved Searches

  Saved Searches provides a simple workflow for saving search queries
  from Drupal core search. It will take advantage of Apache Solr facets,
  if the Apache Solr Search Integration module is installed.

  Saved Searches gives users with permission access to a "save this
  search" form in a block, which appears on search result pages, and
  lists the user's saved searches in another block. Depending on a
  user's permissions, Saved Searches will provide a simple "Save this
  search" button, a text field for entering a short URL slug, and/or a
  dropdown to "Re-use an existing saved search name". Clicking the "Save
  this search" button without entering a URL slug will generate a short
  URL for the search, like "http://example.com/s/cwmc". A link to the
  search will appear in the savedsearches_user block.

  Saved Searches is useful for sites with complex search options, or
  sites where users may want to revisit or share dynamic sets of search
  results.


Here's how you create a term reference field to a CONTENT_TYPE:

Create a taxonomy vocabulary called, say, "Color" at admin/structure/taxonomy/add.
On admin/structure/taxonomy, click "add term" next to your new vocabulary.
Add terms, such as, say, "blue", "red", etc.
Go to /admin/structure/types/manage/CONTENT_TYPE/fields
Add a new field called, say, "Color", and, set its "field type" to "term reference". Select an appropriate widget, such as "select list".
Go to /admin/structure/types/manage/CONTENT_TYPE/display and set the field's display to, say, "link". You can try different display options, such as "plain text" too.

Hope that helps.

Appendix:

To create a node and save this field programmatically, follow this example, which has instructions for saving term reference fields.


CKEditor crashes when switching text format for specific content types

I would "downgrade" to the stable WYSIWYG 7.x-2.2 version of the WYSIWYG module, and to the 3.6.x version of CKEditor (such as CKEditor version 3.6.6.1.7696), since the WYSIWYG module does not support the 4.x version yet ...).

Another option is to switch to the CKeditor module (which is in core in D8 now ...), and no longer use the WYSIWYG module in combination with the CKEditor library.


How can I pass $title a node variable to html.tpl.php?

// template.php
function THEMENAME_preprocess_html(&$vars) {
  $vars['title'] = 'my title';
}

// html.tpl.php
echo $title;

http://drupal.org/node/223430


IMCE file browser doesn't list the files in the Directory path that are uploaded by FTP

found it!
Instead of using Filefield_source module I should use the IMCE for FileField module, that's all. Details from project page:

IMCE for FileField allows users to select files from IMCE File Browser. It supports FTP uploaded files by automatically registering them as IMCE files thus making them usable in a FileField.
How to use

Go to your FileField settings page.
Check the box saying Allow users to select files from IMCE File Browser for this field


You can simply edit the view mode you're using, Default, Full or Teaser for example:

Download Display Suite and enable the "Display Suite" and "Display Suite UI" modules.
Go to admin/structure/types/manage/article/display/teaser where "article" is your content type and "teaser" is the view mode.
In the "Layout for article in teaser" fieldset, select the "One column" layout and click Save.

You will now see a lot more fields, provided by the Display Suite module. One of those fields is called Last modified.

Drag that field to the top, and you're done! No custom theming or coding required.

As a side-note: in views, the field you're looking for is called "Changed":


How do I create new content type with editable fields?

Based upon the mentioned requirement, to me it seems either of the following situations:

For Drupal 7:

Theming the node add page: page--node--add--[content type].tpl.php
Theming the node edit page: page--node--edit--[content type].tpl.php

For Drupal 6:

Theming the node add page: page-node-add-[content type].tpl.php
Theming the node edit page: page-node-edit-[content type].tpl.php

More info about the same you can get from here:
https://drupal.org/node/1092122
https://drupal.org/node/1089656
https://api.drupal.org/api/drupal/modules%21system%21page.tpl.php/7


Using Exposed Form to filter by referenced entity

It's not possible with views alone without custom code or another module.

See https://www.drupal.org/sandbox/el/2698765 or D8 entity reference exposed filter for ideas on how to proceed.


The problem is the query that is probably too complex, and pager_query() cannot alter it to obtain the total number of row matching the query passed as argument.
As reported in the documentation for pager_query():

  The pager uses LIMIT-based queries to fetch only the records required to render a certain page. However, it has to learn the total number of records returned by the query to compute the number of pages (the number of records / records per page). This is done by inserting COUNT(*) in the original query. For example, the query SELECT nid, type FROM node WHERE status = '1' ORDER BY sticky DESC, created DESC would be rewritten to read SELECT COUNT(*) FROM node WHERE status = '1' ORDER BY sticky DESC, created DESC. Rewriting the query is accomplished using a regular expression.

  Unfortunately, the rewrite rule does not always work as intended for queries that already have a COUNT(*) or a GROUP BY clause, and possibly for other complex queries. In those cases, you can optionally pass a query that will be used to count the records.

  For example, if you want to page the query SELECT COUNT(*), TYPE FROM node GROUP BY TYPE, pager_query() would invoke the incorrect query SELECT COUNT(*) FROM node GROUP BY TYPE. So instead, you should pass SELECT COUNT(DISTINCT(TYPE)) FROM node as the optional $count_query parameter.


Views: list all nodes based on relationship

You are correct in setting your relationship as "Entity Reference: Referenced Entity". To recap: you have a view of nodes filtered by Activity. Activity has the entity relationship field that references Course. The direction is from Activity to Course and you are building a bridge from activities to course.

Normally one would set the contextual filter up as node:nid. As you want to list all activities associated with a course, you therefore need to pass in a context that uniquely identifies the Course. Nid fits this perfectly. The nid coming in as the contextual filter needs to be of type Course. So how do you tell Views. You already have a bridge from activities to course (your relationship), and to indicate to views that the nid contextual filter is of type Course you set the relationship that you added on it. Using nid as contextual filter makes more sense in most cases, as it is the unique identifier. It could be taken from the url as a default, or could be sent in via a panel etc.

You can if you wish add another field as the contextual filter, as in the title (it may or may not be unique). But always you will need to add the relationship to the contextual filter to identify the context as belonging to Course.

Now to explain what you did with setting the contextual filter to 'Content Course'. You added the field that appears on the Activity type and which is your entity relationship field to Course, as the contextual filter. This field does not exist in the Course type, so you will never get a result from it. As you want to show a view of activities associated with a Course type, you have to add the relationship that links activities with courses (which you did), and then your contextual filter has to be of a field that appears in Course type. So you must first select a field that does indeed appear in Course type, and then you have to tell Views to use the relationship on that field (remember, your relationship takes you from an Activity type, which is the begin-point, to the Course type, which is an end-point, and your context needs to be on the end-type). Imagine using the nid or the title as the contextual filter. Both course and activity have both of these fields, so which type's should Views use?

The relationship is also considered when adding Fields, Filter Criteria, and Sort Criteria on your view. You have to decide whether the field, filter, or sort belongs to your base type, or to a type that you are bringing in with a relationship.

For a brilliant video tutorial series on Views, have a look at Johan Falk's Taming the Beast: Learn Views with NodeOne


Problem between Organic Groups and Articles/Pages?

I had this problem too. It turns out the current 'stable' version of Organic Groups is not so stable. This along with some other annoying bugs are fixed in the development version of OG. Give that a try :-)


Logo size should not reduce after uploading - Drupal 7

Don't use "Upload icon image", that's for favicon. Use "Logo image settings" -> "Upload logo image".

I tested this theme and both logo and favicon work perfectly. Logo is not altered in any way and favicon works, no matter what size.


How can I ensure a user field is hidden by default for the logged in user?

If you don't want to depend from a module implemented by others, you can implement hook_field_access() in your own module. It is quite easy to change the access permission for an entity field, knowing its name.

function mymodule_field_access($op, $field, $entity_type, $entity, $account) {
  if ($field['field_name'] == 'field_of_interest' && $op == 'edit') {
    return user_access('edit field of interest', $account);
  }
  return TRUE;
}

$op is 'edit', or view'; $entity contains the object for the entity to which the field is attached; $entity_type is the entity type.

With a module that aims the specific fields for which you want to control the access, it is easy to enable the access control: Just enable the module when you need it, and disable it when the access control is not necessary.


Why am I getting a 200 status header when the page is being served from cache?

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 change a grouping field in a view programmatically?

function MYMODULE_views_pre_build( &$view ) {
  $custom_field = 'field_MYFIELD_value';
  $view->display[$view->current_display]->handler->options["style_options"]["grouping"] = $custom_field;
}


Remove the language prefix from the file URL

I have fixed this issue now, since the site was on nginx, I have written the redirect rule which removes language prefix while fetching files.

Insert this line in your server configuration:

rewrite ^/fr(/.*)$ $1 last;

If your site is on Apache you can add redirect rule on your server configuration or on .htaccess file.

RewriteEngine on
RewriteRule ^fr/(.*)$ $1


Your function should be named according to your module's name. If your module is called "foo", then:

function foo_node_presave(Drupal\Core\Entity\EntityInterface $node) {

Note also the use of backslashes, not spaces, to separate namespaces.


The Managing JavaScript in Drupal 7 guide provides the information to add JavaScript to Drupal. The techniques presented there apply to both themes and (custom) modules:

Add a scripts[] = somescript.js to your module or theme's .info
file
Use drupal_add_js() in your module or theme's code
Use the #attached['js'] property in a Form API or renderable array.

Note that Drupal already include jQuery, jQuery UI and a bunch of other libraries so you don't, and shouldn't, add them yourself. Instead you should use drupal_add_library() or the #attached['library'] property.

The Working with CSS guide provides the information to add CSS to Drupal. Again, the techniques presented there apply to both themes and (custom) modules. With an exception: addition of style sheets from an .info files only works for a theme and not a module.

Add stylesheets[all][] = somestylesheet.css to a theme's .info file.
Use drupal_add_css() from module or theme's code.
Use #attached[css] property in a From API or renderable array.


This is similar in D8. Copy page.html.twig from core or base theme and put it into the template directory of your theme.

Rename it like this:

page--user--register.html.twig


Views: Suggest nodes based on user behaviour and history

What you're looking for is known as a Content Recommendation Engine (CRE). There are a few modules out there are provide elements of CRE functionality. See this g.d.o. post for a pretty comprehensive listing, but nothing is a popular, easy, & comprehensive CRE solution.

The most popular is Similar By Terms, but it's a pretty basic and doesn't take user viewing history into account. The most comprehensive are the various Recommender modules based on the Recommender API, one of which, Browsing History Recommender, is based off of viewing history, however this isn't an easy solution; it requires a few dependendencies.

Note that CRE's are complex; think of the man-hours and money NetFlix has spent for its proprietary CRE. You're probably not going to find an easy/comprehensive solution from a install-and-ready-to-go Drupal module. If none of the above can cover what you need, you're best going to a 3rd party that provides easy integration into any website (e.g. LinkWithin).


How to execute a script that takes a long time?

You can break up your work somehow. You shouldn't try to process thousands of things at a time and assume nothing will break or you'll run out of time.

I have recently wrote an in-house Drupal 7 project that allows me to query a webservice for XML data very quickly and process 100,000s of XML entries to an SQL DB pretty fast. A full fetch of all remote SOAP based data is ~100,000 SQL rows after import. This takes ~5 mins to complete. From CURL to DB insert.

The Drupal 7 site performs the following:

Allows me to fetch a .NET SOAP response for X departments from my university. X any number of department queries from 1 department to 90 departments per school quarter.

I used the Background Process module to fetch the CURL requests to local XML files in a Drupal private filesystem.
90 CURL requests with ~2Mb XML responses complete in ~1 minute. (I could request 1 huge xml file of all departments; I break it up for many threads below).
The XML files are added to a Drupal queue. Queue's can lease queue items as jobs for processing. A developer can set a lease time per job for any length of time.

I then use hook_cron_queue to define a worker function that parses the XML and inserts the data into a database. This happens to be a non-Drupal database that I connect to via a custom db entry in settings.php.

I use the Ultimate Cron and Ultimate Cron Queue Scaler modules to actually perform the processing. I set 9 threads in Ultimate Cron Queue to process queue items, and I have set my lease time to literally 2 hours (7600 seconds). Drupal cron runs/checks for work every minute, the lease time assures no thread tramples over work already in progress.

with no optimizations a script I'd written using PHP DomDocument with Xpath queries inserting SQL queries to a DB took minutes per XML file. After adding some SQL batch inserts with db_insert each file takes seconds, but I know from progressively optimizing my scripts a job can have a set lease time. Which is what you want here.

In short. Find a way to break-up your workload and dont be afraid to use watchdog log messages in your module code. A Queue is a nice way to store pieces of the whole task to complete in tiny parts. As you run your worker functions you'll be able to find a lease time that works best for your data size and processing times.

I realized your post is about Drupal 6; it doesn't really matter. The core pieces you want are the D6 queue project and hook_cron(). The Ultimate Cron, Ultimate Cron Queue Scaler, and the Background Process modules have D6 versions.

The project described is a private in-house project, and I cannot easily provide code examples. I've tried to outline how to glue this all together.


Couldn't display body field on a view with Search Api

There are 2 solutions to add body field:

Solution 1:

Browse to search api index field configuration at /admin/config/search/search_api/index/hone_and_strop/fields
Now add The main body text field from Add related fields list.
Now do reindexing and you would be able to add body field into view.

Solution 2:

Create view mode with body field in it.
Now in view, use Rendered entity instead of fields.

  Note: You always need to do reindexing whenever you add or remove
  field form search api index field configuration.


Ubercart 3.x catalog page (terms categories) theme?

I not sure if you are referring to a taxonomy term page. In case if you are then please follow below mentioned steps:

Go to: admin/structure/views
Find a view called: Taxonomy term
Edit this view and add the fields as you wish
Under 'FORMAT' change to table, etc will change the overview of the taxonomy term page.

By modifying this view you will be able to change the layout, and the add more fields to the page.

Note: changing this view will change all the taxonomy term pages.


Out of the box, Drupal supports MySQL (or an equivalent such as MariaDB), PostgreSQL and SQLite for its main database. With additional drivers it also supports Microsoft SQL server and Oracle Database.

The MongoDB module can be used to off-load storage of things like cached data, fields (ie. most data for content, user, taxonomy terms, etc.) and sessions data from the main database to MongoDB. But MongoDB alone can not be used, you still need a SQL database. See NoSQL vs Other SQL Drupal Setups and its accepted answer for more information.

I'm not an expert, but except for SQLite,  I'm not sure switching DB engine is a good way to get great performance gain. I guess each engine has its strengths and its own optimization tools. I guess great performance gains can be obtained in each of them, but you have to knows how to do it.

There are also others performance aspects to consider, such as caching layers (Varnish, Memcache, APC, etc.), clustering and Content Delivery Network for static files.


How to display language switcher block as buttons, instead of simple links?

First choice
If you wants some design related change you can easily achieve using CSS.

Second choice
Enable twig.config: debug: true

See some template file where you can made changes.

  FILE NAME SUGGESTIONS:
  links--language-block.html.twig
  links--language-block.html.twig
  links.html.twig

Changing markup of the language switcher

Trird choice
Alter _language_switch_links_alter.
How do I alter a language item link?


Is it possible to export/import content types from one site to another

A few options:

Features

The features module enables the capture and management of features in Drupal. A feature is a collection of Drupal entities which taken together satisfy a certain use-case.
Bundle Copy


You can achieve using below step:

Go to Administration -> Structure -> Menus
Click on 'Add links' in 'Management' menu row
Add 'Menu link title' and 'Path' for menu item.
Set 'Parent link' for the menu item, so it would display in correct position.
Save the form

Update:

By default, Management menu be only dispaly to administrator or the user which has permission to view it.

If you want to set any specific visibility permission, you can use Menu item visibility module.

  This module exposes configurable and extendable visibility settings
  for menu links. For example, if you want to create a 'My account' link
  that points to /user, both anonymous and registered users have access
  to the /user path, so both will see the link, even if anonymous users
  do not technically have an account. Using this module will allow you
  to only have your 'My account' link visible to registered users, and
  hide it from anonymous users.


Per Clive's comment above, it works with this:

        namespace Drupal\custom_validation\Plugin\Validation\Constraint;

        use Symfony\Component\Validator\Constraint;
        use Symfony\Component\Validator\ConstraintValidator;

        /**
         * Validates the Image constraint.
         */
        class MainImageConstraintValidator extends ConstraintValidator {

          /**
           * {@inheritdoc}
           */
          public function validate($items, Constraint $constraint) {
            foreach ($items as $item) {
              if (strpos($item->entity->filename->value, 'shutterstock') !== false) {
                $this->context->addViolation($constraint->wrongImageName, ['%value' => $item->value]);
              }

            }
          }

        }


Change module's weight - by module or manualy

Since it was explicitly asked, there is also a module, Modules weight, that performs this task as well.

  We always need to modify modules execution order, and some could write
  a code that execute a query to modify the weight of a module in system
  table, some might go straight to his favorite SQL client and modfiy
  the record directly, This module provide admin interface for
  users/people has the access to modules page to reorder the module
  weights as they want


Can´t create more than one content type group

It seems this solves your issue : EntityMetadataWrapperException

You probably need to add field_og_subscribe_settings field to your new content group type, and make it required.

You can take a look at

/admin/structure/types/manage/group/fields/field_og_subscribe_settings

to see how it's been configured for the default group content type.

Refer this link for detailed details about this issue: EntityMetadataWrapperException errors due to features not being reverted


How to remove a Required Field based on other field value

Try using the #states attribute: a structured array describing the different JavaScript states that can be applied to the element when certain conditions are met. Please read the extensive description of this feature at drupal_process_states()


You probably want to write this as an update hook, something like this should work:

function MY_MODULE_update_N() {
  foreach (\Drupal::entityTypeManager()->getDefinitions() as $entityType) {
    $entities = \Drupal::entityTypeManager()->getStorage($entityType)->loadMultiple();
    foreach ($entities as $entity) {
      if ($entity->langcode->value != 'en') {
        $entity->set('langcode', 'en');
        $entity->save();
      }
    }
  }
}

This loops through all entity types and loads all entities for the given entity type, then it updates the language if it is not set to english.

You might want to create a batch process if you have many entities to update.

For more info about how to do that, look here.


Your answer is quite flexible actually.

You select the one column template and disable drupal standard regions and then just add a php filter custom content for each row in your grid. You add the grid classes inside your php filter and then use block render or views_embed_view.

Another more clean solution would be to create your own layout plugins for panels. It is not as difficult as it sounds. Just download and fork panels_extra_layout and you have everything you need in order to create your own custom and reusable grids.

Have fun.


How to validate temporary files with form API

This isn't a particularly clever solution, but hopefully it's ok. As far as I could tell you can't validate temporary files, they have to be uploaded.

So I ended up uploading them to the private directory and then immediately deleting them. Because some of the data might be sensitive I don't want to store them and this form takes place on a secure page.

function mymodule_form($form, &$form_state) {

   $form['file1'] = array(
     '#type' => 'file',
     '#title' => t('File1'),
   );

   $form['file2'] = array(
     '#type' => 'file',
     '#title' => t('File2'),
   );

}

Now for the important bit.

function mymodule_form_submit ($form, &$form_state) {
    //check if any file was attached
    if($_FILES['files']['tmp_name']['file1'] != '') {
      //Save and validate the file to the private file area
      $file1_included = file_save_upload('file1_included',
                                     array(
                                        'file_validate_is_image' => array(), // Validates file is really an image.
                                        'file_validate_extensions' => array('png gif jpg jpeg'), // Validate extensions.
                                      ), 'private://');
      //This is set-up for the email. Mimemail stores attachments in $params.
      $params['4'] =  array('uri'    => $file1_included->uri,
                          'filename' => $file1_included->filename,);
      //The file has been uploaded. So we'll set a variable which will be called later to delete it.
      $del_files['file1'] = $file1_included;

    }

   if($_FILES['files']['tmp_name']['file2'] != '') {
   //.... same as file 1...
   }

  //this will send an email. Note $params. We've put all our attachment information in
  //there.
  $message = drupal_mail('mymodule', 'notify', $email, language_default(), $params);

  //This function will delete all the files we've just uploaded. We check if
  //the variable has been set. And if it has then we call it and delete the relevant
  //files.

  if (isset($del_files)){
    _tellafriend_filedelete($del_files);
  }

}

This is the function we call to delete the files

function _mymodule_filedelete(&$del_files){
   //we know the variable exists, but now we have to check which files were uploaded.
   if(array_key_exists('file1' , $del_files)) {
    //and if they were uploaded. We delete them.
    file_delete($del_files['file1']);
  }
   if(array_key_exists('file2' , $del_files)) {
    file_delete($del_files['file2']);
  }
}


How to creat a page display comments list of users

This is just a simple view: Set up a relationship with comment:node not author; then in your filter criteria add "User: Name exposed" and set your fields.


How to make persistent exposed filters in views

Take a look at Views Global Filters module. That will solve your problem.

The project page reads

  Use Views Global Filter on sites that feature multiple Views. You want
  the views to be driven by the same filter selection, for instance a
  country, a date range, a search term or even proximity to a post code.


Is it possible to pass a Field value Via URL when creating a Node?

For passing values to forms:

There is a Drupal Module called Prepopulate which allows you to prefill fields on node forms using $_REQUEST variables.

It is quite simple to use and merely requires you to rewrite the links to contain the field values you want to pass along. If you want to fill field_your_fieldon your ticket node, the link would need to look like this:

http://www.example.com/node/add/ticket?edit[field_your_field]=desired field value

That said, this wont hide any fields on the form, merely provide default values for them. If you want tickets with different fields, you could always use multiple node types.

If you want to actually hide fields based on the url, you could reuse the node form on custom pages and manipulate their fields there as you need.

You will  need menu entries for your different node displays to distinguish which node form you want to call.

function ticket_module_menu() {
  $items['ticket/add/tech-ticket'] = array(
    'page callback' => 'drupal_get_form',
    'page arguments' => array('ticket_module_tech_ticket'),
    'access callback' => 'create ticket content', //or put a custom permission
  );

  $items['ticket/add/support-ticket'] = array(
    'page callback' => 'drupal_get_form',
    'page arguments' => array('ticket_module_support_ticket'),
    'access callback' => 'create ticket content', //or put a custom permission
  );

  return $items;
}

And then create a form for each entry:

function ticket_module_tech_ticket() {
  module_load_include('inc', 'node', 'node.pages');

  //get node add form for node type ticket
  $form = node_add('ticket');

  //Hide fields you do not want to display
  $form['field_your_field1']['#access'] = 0;
  $form['field_your_field1']['und'][0]['value']['#disabled'] = TRUE;

  return $form;
}

function ticket_module_support_ticket() {
  module_load_include('inc', 'node', 'node.pages');

  //get node add form for node type ticket
  $form = node_add('ticket');

  //Hide fields you do not want to display
  $form['field_your_field2']['#access'] = 0;
  $form['field_your_field2']['und'][0]['value']['#disabled'] = TRUE;

  return $form;
}


How do I override the HTML output of a theme function?

You will need to override the whole theme function in your own module.
Because the override is done from a module level, not the theme, you will probably need hook_theme_registry_alter to change the theme function settings for that specific hook_theme component.


AJAX callback not added using form_alter

You need to do the AJAX callback on #process callback as #after_build callback is too late to inject AJAX.

Check out the this link and the example code:

/**
 * Implements hook_form_alter()
 */
function kf_link_form_alter(&$form, &$form_state, $form_id) {
  if ('example_node_form' == $form_id) {
    //$form['field_link'][$language]['#after_build'][] = '_kf_link_field_link_after_build';
    $form['field_link'][$language][0]['#process'] = array('link_field_process', '_kf_link_field_link_process');
  }
}

/**
 * Custom form api process function
 */
function _kf_link_field_link_process($element, &$form_state, $form) {
  $element['url']['#description'] = '

';
  $element['url']['#ajax'] = array(
    'callback' => 'kf_link_ajax_callback',
    'wrapper' => 'example-link',
  );
  return $element;
}

/**
 * Custom ajax callback function
 */
function kf_link_ajax_callback(&$form, $form_state) {
  $values = $form_state['values'];
  $field_link = $values['field_link'];
  $language = $values['language'];
  $url = $field_link[$language][0]['url'];
  $duplicate_nodes = _kf_link_get_url_nid($url);
  foreach ($duplicate_nodes as $duplicate_node) {
    if (isset($duplicate_node->nid) && ($duplicate_node->nid != $values['nid'])) {
      drupal_set_message(t('This URL already exists in !title', array('!title' => $duplicate_node->title, '!url' => "node/{$duplicate_node->nid}")), 'error');
    }
  }
  $commands = array();
  $commands[] = ajax_command_html(NULL, theme('status_messages'));
  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}


theme_menu_local_tasks() will never be invoked using those two methods, so it makes sense that your dpm() fails.

Both functions do eventually invoke hook_menu_local_tasks_alter(), though, and that's where you can make your changes:

function MYTHEME_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  if ($some_condition) {
    // Grab the first tab.
    $first_tab = &$data['tabs'][0]['output'][0];

    // Add a class to the link element.
    $first_tab['#link']['localized_options']['attributes']['class'][] = 'some-class';
  }
}

If you want to add a class to the <li> element you'll need to go a step further, and override theme_menu_local_task().

The class attribute is hard-coded at the moment so that'll will need to be changed, based on a contextual variable you can pass into the theme function from the local tasks hook above.

That would look something like this in the alter hook

$first_tab['#extra_class'] = 'some-class';

And along these lines for the theme function

function MYTHEME_menu_local_task($vars) {
  // Copy the code from theme_menu_local_task() but change the HTML output
  // to include an extra class if $vars['extra_class'] is set
}

You might also need to implement hook_theme_registry_alter() to let it know about the new variable (can't remember if it matters but it can't hurt)

function MYTHEME_theme_registry_alter(&$theme_registry) {
  $theme_registry['menu_local_task']['variables']['extra_class'] = NULL;
}


How do I make the same variable available to all my theme files?

You would have to add a cache context:

$variables['#cache']['contexts'][] = 'url.path';

Now you cache for each relative path a different version of the template.

However, it is not a good idea to add this context to all templates. Only add it to those templates you intend to use the variable, otherwise you fill up your cache with a lot of useless variations:

function mytheme_preprocess(&$variables, $hook) {
  if (in_array($hook, ['foo', 'bar'])) {
    $variables['#cache']['contexts'][] = 'url.path';
    // add variables depending on the relative url
  }
}


Unable to show the Uploaded Image by the user in user submitted form for node

In Drupal 7 you can use system_retrieve_file()

  As system_retrieve_file function will download a file from a remote
  source, copy it from temp to a specified destination and optionally
  save it to the file_managed table if you want it to be managed.

Can you try this Save image from URL to a field from a custom module


It looks like it's already in the issue que at drupal.org (a better place to resolve module issues then here)

Although doesn't look the patch has been merged into the latest cut release (as of time of writing this), but you can see the changes that were made here:

http://drupal.org/node/1461732#comment-5727124


How do I change jquery_update version for a custom theme?

No need for a patch, jquery_update 7.x-3.0-alpha5 works great and it already includes functionality to specify jquery version per theme (as per this issue) on configuration page admin/config/development/jquery_update

For specifying a theme per role you can try any of the following modules role_theme_switcher Themes By Role (TBR)


The following may or may not meet your needs exactly, but they're ideas.  Since I am now aware of semantic search modules currently available, these would be my workarounds.

The default drupal search does not really provide you with a lot of configuration options to determine which of your nodes' fields/tags can be weighed more heavily when determining search result relevance, I would enable and use the Apache Solr Search Integration module to get at more accurate search results.

With this module, you can get several benefits:

It lets you configure different weights, in terms of search result relevance, for the title, body, text in bold, text in comments, as well as terms in all your vocabularies.  This way, you can weigh very heavily the terms from a certain vocabulary, while omitting text from comments and weighing very lightly text that is in terms from another vocabulary (for example) -- adjust weights to your needs.  What I'm suggesting here is that you can use tagging as a form of search metadata with this module...  (Author name, etc are also fields that can be weighed with this interface)

You can use facets with apachesolr search, which can allow your customers to actually narrow down and interact with search results themselves!  It also provides a 'sort by' block, which users can use to sort results by relevancy (the default), or date, author or type if they prefer.  These aren't exactly what you asked for, but are a way to interactively let users tailor results...  Screenshot below is directly from apachesolr's module demo site.

To use apachesolr search, however, you have to have to install and configure a solr server for drupal to use: http://drupal.org/node/1053074


How to redirect to edit page on node create?

When not in a Controller call the send() method on the RedirectResponse object.

$response = new RedirectResponse("/node/$id/edit");
$response->send();


Where is the 'Access Rules' in Drupal 7?

For anyone that might be asking the same question - email and username rules were moved to a separate module: User Restrictions.

http://drupal.org/node/1020672


Features in D8 is the way to sync features across multiple sites. And was the default in D7 to import and export database changes. Which in D8 is solved by Configuration management.

Please read the docs (thoroughly): Managing your site's configuration.

You routinely have to drush cex after you've made changes via the UI. This will export database values into multiple (hundreds/thousands) *.yml files. Then your colleagues will have to drush cim after they pulled the latest *.yml files to get the changes imported into their DB.

For a general overview please see Web development structure on multiple devices.


Disable default site and only use multisite

You can't have an index.html in the root of your default directory, Drupal doesn't treat these directories like normal web folders. If you want example.com to go to a folder with a plain index.html file in it, you're going to need to edit your vhosts configuration. Right now, your vhost file probably looks something like this:

<VirtualHost *:80>
  ServerName example.com
  ServerAlias www.site1.com, www.site2.com, www.site3.com
  DocumentRoot /var/www/YOURDOCROOT
...etc

What this is doing is redirecting all sites that match either the server name or server alias and sending them to the DocumentRoot folder specified. When it gets there, Drupal tries to map the http requests to the appropriate folder but finding none for example.com, it sends it to the default directory instead.

If you want it to go to a single-page index.html, you are going to have to remove example.com from your vhost above and setup a new one, pointing example.com to that new folder, ex.

<VirtualHost *:80>
  ServerName example.com
  DocumentRoot /var/www/EXAMPLECOMDOCROOT
...etc

and place your index file in there.

If instead you want Drupal to send all traffic to one of your subsites, you can try either of these two methods:

Remove the default directory (assuming there is nothing in there you want) and symlink it to the site directory you want it to be using instead, ex. if you want it to be pointing to site1

ln -s www.site1.com default
You could also point your primary domain there as well using symlinks, ex:

ln -s www.site1.com example


Custom Module: db_select title AND body?

If you want directly include the body within your result set, you can do a join on the field_data_body table.

$query = db_select('node', 'n');

$query->leftJoin('field_data_body', 'd', '(d.entity_id = n.nid AND d.entity_type = :node)', array(':node' => 'node'));

$query
    ->fields('n', array('type', 'title', 'nid'))
    ->fields('d', array('body_value', 'body_summary', 'body_format'))
    ->condition('type', 'fooBar')
    ->condition('status', 1)
    ->execute();


How can I programmatically enable clean URLs during a SimpleTest?

Did a few tests and here is what I found.

Enable Clean URLs in setUp() method:

function setUp() {
    variable_set('clean_url', 1);
}

.htaccess from live site is used during SimpleTest.  Modifications are not required.


Create and pre-populate a mutiple value field in field collection on new node with ajax call

Ok so I didn't manage to solve this directly, but I did accomplish my intent behind this quesion.

The intent behind this was to pre-populate a field collection from another node on a node create form with an ajax call.

I'm still not sure how you alter the fields in a field collection on a form and I'll leave this question open in case anyone knows, however if you're looking to pre-populate field collections onto a node, then this blog post has an answer:

http://drupal.cocomore.com/blog/field-collections-exposed

And I posted an example using ajax to do this in an answer to this question (where I think it's more relevant): How to create (& pre-populate) multiple “field collection” fields on an ajax call


Content profile fields on registration form by role

You can use hook_form_alter to alter the form. This is how the profile fields is added and they can be removed this way as well.

You have to make sure that your custom module is run after the profile module, which may require that you alter the weight of the module. This is merely a value in the system table.


What is the best way, programmatically, to iterate through a view's results?

Playing around with Views a bit I seem to have worked out an approach. However, I'd like to leave my question open to other answers and better solutions.

<?php
if ( arg(0) == 'node' && is_numeric(arg(1)) && ! arg(2) ) {
   $node = node_load(arg(1));
   $args = array($node->nid );
   unset($view);
   $view = views_get_view('Children');
   $view->set_display('default');
   $view->set_arguments($args);
   $view->set_items_per_page(20);
   $view->execute();
   $newarg = array();
   for ($i=0; $i<sizeof($view->result); $i++) {
      $newarg[$i] = $view->render_field('nid_1', $i);
   }
   for ($i=0; $i<sizeof($newarg); $i++) {
      unset($view);
      $view = views_get_view('Children');
      $view->set_display('default');
      $view->set_arguments($newarg[$i]);
      $view->set_items_per_page(20);
      $view->execute();
      ....
   }
}
?>

The key to executing the view multiple times was for me to unset($view) when I was done with the result set.


Is it possible for a view to have two outputs

You can use an attached View. An attached View is a View display that is attached to another View display, a compounded View.

In this question is explained its purpose:
What is the purpose of Views "Attachment", "Content pane" & "Context"?

  The Attachment option is to create yet another view that you can attach before and/or after any of the displays on your current view.


media entity browser base view is missing

No, the Media Entity Browser is still in contrib. If you are using core media then use the 2.x branch, see https://www.drupal.org/project/media_entity_browser. If this is only about the question in the title, see Revert views missing. Any workarounds? how to import a View from a module folder. If the View is missing you don't need to look for the UUID of the existing View.


you can use:

drush dl modulename --cache

From drush help dl:

Download Drupal core or projects from drupal.org (Drupal core, modules, themes or profiles) and other sources. It will automatically figure out which project version you want based on its recommended release,
or you may specify a particular version.

...

Examples:

 drush dl webform --cache                  Download webform. Fetch and populate the download cache as needed.

Options:
 --cache                                   Cache release XML and tarballs or git clones. Git clones use git's --reference option.
   --cache-duration-releasexml             Expire duration (in seconds) for release XML. Defaults to 86400 (24 hours).
...


Add attributes like id to block level elements in CKEditor?

If you just need to add ID to a link you can use the D8 Editor Advanced link module https://www.drupal.org/project/editor_advanced_link

It basically allows you to put attributes on anchor tags without touching the source code.


How to split up a View up amongst different Panels panes? Context display?

The module I needed to enable was Views content panes. I was looking for something like it in the Views and Panels section of the modules list - it was in neither, it's bundled with ctools and listed under Chaos Tools Suite.

Then, once enabled, you get two new Views display mode options:

Context is the one to allow a view to be loaded as a context behind a panel.
Content pane is like a smart block where you can allow settings to be set per panel pane (e.g. offset and pager, allowing the view to be sliced up), toggling fields on and off, changing titles, etc. A few gotchas:

All such options are disabled from being edited in Panels by default, you have to enable them each time using the "Allow settings" option in the middle in Views
Panels can be a bit fussy about showing newly added view panes. You might need to save/update the panel/page manager page before it'll register the new view displays, even though it seems to load everything new each time. If even that doesn't work, try clearing caches.


With Commerce Product taxonomy term view, is there a way to have page title set to the translated term title?

I had to workaround it in code by modifying an example posted by djg_tram:
/**
 * @file
 * Workaround for taxonomy term title not being i18zed.
 */
use Drupal\views\ViewExecutable;
use Drupal\taxonomy\Entity\Term;

/**
 * Implements hook_views_pre_render().
 */
function exposed_filter_workaround_views_pre_render(ViewExecutable $view) {
  $view_id = 'products';
  $view_display = 'page_category';

  if ($view->id() == $view_id && $view->current_display == $view_display) {
    $lang_id = \Drupal::languageManager()->getCurrentLanguage()->getId();

    $term_id = $view->args[0];
    $term = Term::load($term_id);

    $term_translated = $term->getTranslation($lang_id);
    $view->setTitle($term_translated->label());
  }
}


You can find the Simpletest interface at admin/config/development/testing

Be sure to clear your Drupal cache if you have enabled the Simpletest module and you cannot access admin/config/development/testing


Is there a way to send a newsletter to those users who share a taxonomy term in there profile

It sounds like you want something that simplenews doesnt do right out of the box. You can create newsletters (and a block for subscription links) -- but it doesnt appear to based off of Taxonomy terms directly.

Simplenews supports Rules, you could maybe define rules that achieve your goal.

I have not used simplenews, but I have a website for student surveys which has various email templates that remind students if they have additional surveys to complete, all running off of cron tasks -- you could code this type of newsletter functionality by hand without many helper modules if need be.

Sometimes manipulating a contributed module to suite your needs is harder than just doing it yourself for your project.


How to output from custom module without rest of theme

The controller does not have to return a render array, it can also provide a symphony response, for example:

use Symfony\Component\HttpFoundation\Response;

$response = new Response();
$response->setContent('
Hello world
');
//$response->headers->set('Content-Type', 'text/xml');
return $response;

This will bypass the Drupal rendering and theming.

Edit:

You can use two approaches to replace your Drupal 7 code:

1) Override page.html.twig and html.html.twig, remove anything out of this templates and put only that in what you want.

2) Render the HTML like you are doing it now in Drupal 7 and use a Symfony response.

Rendering in Drupal 8:

use Symfony\Component\HttpFoundation\Response;

$output = \Drupal::service('renderer')->renderRoot($build);

$response = new Response();
$response->setContent($output);

return $response;


How can I configure the search engine to search by dates? Drupal 7

You have not mentioned is it drupal 7 or 8
If it is drupal 7 i think it will help you.
First you install  date module. You can add a date field with a start and an end date. Other than that the rest is simple. Go to your view and add two filters.

First filter will be your start date where the field is "less than or equal to" -> "now" you can write that only if you select "enter a relative date"

Second filter as you may have guessed will be your expire date field where the field is "is greater than or equal to" -> "now"

If "less than or equal to" and "greater than or equal to" don't appear as options, make sure you've enabled the Date Views module. (It is installed as part of the Date project.)


How to make "Announce on LinkedIn" on by default?

The issue here is the LinkedIn post functionality is tied to the node form; the form is altered to add the form component & submission hook. However, Feeds isn't using this form so it will never get a chance to process the submission handler.

If you look at the submission handler you can pull out the relevant function, linkedin_put_profile_field(),  to make this happen. Combine this with hook_feeds_after_import(), and you can come up with an implementation that will trigger a LinkedIn post upon a feed import:

function MYMODULE_feeds_after_import(FeedsSource $source) {
  if(function_exists('linkedin_put_profile_field') && isset($source->feed_nid) && $node = node_load($source->feed_nid) {
    $status = variable_get('linkedin_default_format_'. $node->type, '');
    linkedin_put_profile_field($node->uid, 'current-status', $status);
  }
}

Note: there will probably need to be more checks & altercations here based on your needs (e.g. setting the right UID to post as, throttling posting so your feed importing doesn't get marked as spam on LinkedIn).


How do I get Rules to see my custom entity?

Individual rules can have a type associated with them. Most rules work with Nodes but an Entity is 1 object up in the type hierarchy of Drupal. therefore rule(s) defined with the Rules module must be made aware that they are compatible with your custom entity type.

You would do this with an alter hook for Rules, or providing property information for your Entity:
I can't set a data value using rule on a custom entity


Inserting NULL value with db_query OR db_write_record

The NULL that you're passing is possibly/probably being interpreted as a string, ie. "NULL". When MySQL casts that to a float the result is 0.

If you have a default value for the column you can just leave it out of the query altogether, and you'll get the results you expect:

db_query("INSERT INTO {foo_bar} (name) VALUES ('%s')", $name_value);

or

$obj_foo_bar = new stdClass();
$obj_foo_bar->name = 'Dollar'
// Leave out $obj_foo_bar->amount

drupal_write_record($table, $obj_foo_bar);


Try replacing $ with jQuery. By default I don't believe Drupal allows the $ as a shortcut due to potential compatibility issues with other libraries.


Searching entity reference field value with Search API

I haven't tried this with Search API but if your "Author" is a separate content type and not the actual default Author field you need to add the Relationship for that Entity reference field (for the "Blog Author" content type).

Different Content types store data in different database tables. Relationships introduce that other table data into your Views.

You'll probably have to add the Title field using that Relationship (which is, I presume, your blog author name), and include that field in the Search API settings so it gets searched.

Entity reference fields only store the ID of the referenced entity, so using them alone won't let you search the actual Title field text of the referenced entity. You can only do that through the Relationship and the relevant Title field (or however you named that field).


How to inject code into node body after x paragraph

Well, one way to do this would be to modify the twig template that is outputting the paragraphs (on the node).

You could loop the paragraphs render array {{ content.field_foo }}:

{% for i in content.field_foo %}
  {{ content.field_foo[i] }}

  {% if i == 1 %}
    // print your output
  {% endif %}
{% endfor %}

1 will be your second item, as the count starts at 0. This is just some rough untested pseudocode. But the idea is to loop over and print each item in the render array one by one, and inject the code at certain counts.

edit: This answer is for if you are using the Paragraphs module, which at the time of this answer is not clear from your original question.


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

Ok, finally I got a workaround. I was focussed on entities and computed field, but it turned out to be a death end. So, I change the approach and found the rules_form module.

This modules allows apply a rule in the node form, so I created an integer field called delta in my field_collection_parent and populate it with rules when the form is created. In this way, I always keep a seven-rows field_collection_parent even though the field_collection_child is empty (because the field delta is filled).


The message states that views is missing a database column (human_name) it is expecting to exist. New fields in core or contributed modules are often added by an update process.

It looks as if you need to run update.php, because it was not run after upgrading core or the views module itself. Alternatively, if you have drush enabled, you can run 'drush updb' from a shell.


As I mentioned on this answer already: I guess one of your problems is to determine wether upvote insert rule or downvote insert rule was triggered - vote up/down is storing this in two separate voting sets. (I might be wrong here, when I am good for you).

Let's say it is just one vote set and there are minus votes. you would have to adjust the positive check in the condition to a negative points check. I had my rules still in the environment so I cloned them and did those changes:

(minus points will be probably just negative grants.)

Event: User votes on a Node

Condition: User has role(s)
Parameter: User: [vote:user], Roles: authenticated user

Condition: Check the value of the vote
Parameter: Vote: [vote], Operator: is lower than or equal to, Data value: 0

Action
Grant points to a user
Parameter: User: [vote:user], Points: -3, Points category: General, Operation: Insert, Moderate: Use the site default

Export:

{ "rules_substract_down_voter" : {
    "LABEL" : "substract down voter",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "voting_rules", "userpoints_rules" ],
    "ON" : [ "voting_rules_insert_node" ],
    "IF" : [
      { "user_has_role" : { "account" : [ "vote:user" ], "roles" : { "value" : { "2" : "2" } } } },
      { "voting_rules_condition_check_vote_value" : { "vote" : [ "vote" ], "operator" : "\u003C=", "value" : "0" } }
    ],
    "DO" : [
      { "userpoints_action_grant_points" : {
          "user" : [ "vote:user" ],
          "points" : "-3",
          "tid" : "0",
          "entity" : [ "" ],
          "operation" : "Insert",
          "display" : 1,
          "moderate" : "default"
        }
      }
    ]
  }
}

So there are still some things for you to check:

does vote/up down use one or two rule sets?
if it uses two, how to determine that in rules?
if it's only one with negative votes than you're done.


Insert data in table using drupal form alter submit

In your alter hook you can create custom submit handlers.
Ex.

function custommodule_form_deal_node_form_alter() {
    if (isset($form['actions']['submit'])) {
        $form['actions']['submit']['#submit'][] = 'custom_form_submit';
      }
    }

then you implement the custom submit handlers.

function custom_form_submit(&$form, &$form_state) {
 // $form_state will have the form value which you can insert into database.
}


installed drupal site locally but not working (XAMPP)

One reason for this can be 'the apache server's rewrite mod is not enabled'.

See if

  localhost/sitename/index.php?q=user/login

is working.

If that is working then try enabling Clean URL (sudo a2enmod rewrite for LAMP).

Few links that can be related to the problems.

http://drupal.org/node/1186762

http://drupal.org/node/333675


Context add assets seems to be a good solution for this https://www.drupal.org/project/context_addassets


How do I pass a string from a PHP field to the PHP filter?

You can copy the code from the php field and add some logic to it to return false or true depending on the result but no there is no current way to transfer it.

EDIT: This may seem a bit backwards, though if you made a $_SESSION variable as an Array() you could maybe do something with that. Maybe not very helpful. views_php has always been entirely buggy for me and it comes in handy sparingly.


Get the submitted values of a multistep webform

You will find the multi-page values stored in

$form_state['storage']['submitted']

Note that this array does not contain values from the current page and will be empty if the current page is 1.

And incidentally you can find out which page was just submitted by checking

$form_state['storage']['page_num']


How to Display children on the Taxonomy term page?

I finally found the solution. My Drupal is in french, I tried to translate, but my translation may not match the exact words :)

Go to View and edit the default Taxonomy term (content) page.
In Contextual filters :

select "possède l’identifiant de terme de taxonomie (avec profondeur)" and configure like this :

depth : choose the depth you want
check Allow multiples values
check Provide a default value and choose Taxonomy term (ID) from URL
select Filter by elements that share all terms
check Override title and write {{arguments.tid}} in the field
check Specify selection criterion and choose Taxonomy term (ID)

select "possède l’identifiant de terme de taxonomie avec modification de profondeur"

Now, if you have a complex taxonomies, go on a taxonomy term page may display the same result several times. To prevent this, in your View, go to Other section (under Contextual filters) and click on Query parameters. Then check Distinct.

Enjoy !


Permission Issue with created actions and VBO

The solution here was to set the permission I want in the access_callback of the custom entity itself.

so in my case the hook_entity_info

'access callback' => 'myentity_access_callback',

then added this in a function

function myentity_access_callback($roles = array()) {  // $op, $application = NULL, $account = NULL
 global $user;
 $roles = array(
   'administrator', 'anotheradminrole',
 );
  foreach ($roles as $role) {
    if (in_array($role, $user->roles)) {
      return TRUE;
    }
  }
  return FALSE;
}


TrustedResponseRedirect failing - how to prevent cache metadata?

You mentioned the URL generator, which is one of the two ways this happens.

In short, you need to do something like my patch in this issue: https://www.drupal.org/node/2630808

Pass TRUE to toString(), then you get a different object back that you need to add as a cacheable dependency. You can do that with such GeneratedUrl objects, entity and config objects and you should do that whenever your response depends on them.


How to set newest first in the view of content created

Under Sort Criteria section, add field Content: post date and set it's configuration as descending as shown in image below.


Create a view with mix of content and files

Thats tough to answer without a little more information.

It depends on whether or not they share anything in common. Views over on the right hand side of the UI has a menu for what are called relationships. You could for example setup a content type based view and then add a relationship to the user who created the content type node. After the relationship was created you'd then have access to information stored (fields) on the user as well as the fields from the content type itself. What these relationships are doing behind the scenes in views is setting up SQL joins between the various tables in your Drupal database.

Another thing you might want to look into is entity references and taxonomy tags. Both of those can be used to setup connecting points between pieces of content that can be rendered by a view much in the same way.


Submit handler in hook_form_alter not working in d8

What you are doing looks like it should work.

Doing an echo is undetecable in the submit handler, since Drupal will do a redirect after the POST request and thus clearing all of the output generated but Drupal in the actual submit handler.

A simple way to test if the submit handler is called or not is to insert a die()

Reasons for submit handler not being called could be:

You submit the form with a button you haven't added a submit handler on and that already have one or more attached to it.
Another alter hook removes your submit handler (unlikely)


sudo nano /etc/apache2/sites-enabled/000-default.conf

Make sure it looks like this:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

ServerAdmin webmaster@localhost
        ServerName mydomainname.com
        ServerAlias www.mydomainname.com
        DocumentRoot /var/www/html/drupal

<Directory /var/www/html/drupal/>
        Options +FollowSymLinks
        AllowOverride All
        order allow,deny
        allow from all
</Directory>

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


how to use css sprite in all my pages ( menu+ views)

You can use same image in different classes already; i am not sure that i understood your problem(I was going to ask for details but my reputation is not enough to add comments yet; so i am adding answer.).

.class-one {
  background: url("/your/path/to/images/your-sprite-image.png") no-repeat 0 0;
  ...
}

.class-two {
  background: url("/your/path/to/images/your-sprite-image.png") no-repeat 0 0;
  ...
}

If you need to change image's position, you can change first 0 for left, second 0 for top position.

If they are the same; you can merge them:

.class-one, .class-two {
  background: url("/your/path/to/images/your-sprite-image.png") no-repeat 0 0;
  ...
}


It sounds like you should handle this in your computed field's PHP since you're already parsing out the image there.

//Assuming $entity is the parsed node in question
preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $entity->body[LANGUAGE_NONE][0]['value'], $matches);

//If an image match has been found, build a URI relative to public file base
//Assume image URLs are something like:
// "/sites/default/my_files/some_dir/whatever.jpg"
if(isset($matches[1][0])) {
  $public_dir = variable_get('file_public_path','sites/default/files');
  $uri = file_build_uri(str_replace("/$public_dir/","",urldecode($matches[1][0])));
  $entity_field[0]['value'] = image_style_url('thumbnail',$uri);
}


How do I install sandbox module 'Filedepot multiupload'?

The link you provided for the sandbox module 'Filedepot Multiupload' is actually an issue (request) for Drupal.org Project Applications.
The actual sandbox project is located at https://www.drupal.org/sandbox/e.ruiter/2290395 . On that page, wihin resources, there isn't any link mentioned (yet) with title "Read documentation", which typically points to either available "Community documentation", or to the "Readme.txt" that comes with the module.
The module's Readme.txt appears to be the best documentation currently available. To review/browse it, you have 2 options:

Browse the module's source code that you downloaded, which should contain that readme.txt.

Follow the "Browse code repository" on the project page of the sandbox project. Next visit the "Tree" tab and click on the Readme.txt link there.

Here is the content of that readme.txt:

Introduction: This module extends the filedepot module with multiple upload support. Files can be uploaded with the plupload module which supports drag and drop.

Installation: Just install the module by copying the module to site/all/modules directory or install with drush. If you get some errors about files missing and plupload is not loading, you are probably missing the plupload library. Find the README file of the plupload module and follow the instructions.

Note: while you're reviewing the Readme.txt and experimenting / testing that module, consider either (or both) of these approaches:

enhance the readme.txt with anything you learn/discover about it, and then contribute an updated version of readme.txt back to this sandbox project. E.g. by creating a documentation issue, and attaching a copy of the updated readme.txt.

create a community page containing such documentation, and then create a documentation issue for this sandbox project, requesting the module owner to update the project page to point to this new community documentation.


How do I add a  over a paragraph's field, depending on another field of this paragraph?

Don't use the field template -- you'll find it difficult to change the formatting of one field based on the value of another field at that level. You'll want to use the paragraph template (or sometimes even the node template containing the paragraphs entity reference revisions field) so that the values of both fields are in scope at the same time.
Something like this might work in the paragraph template:
{% if content.field_title_level.value == "h2" %}

{{ content.field_title }}

{% endif %}
{% if content.field_title_level.value == "h3" %}

{{ content.field_title }}

{% endif %}
{% if content.field_title_level.value == "h4" %}

{{ content.field_title }}

{% endif %}

You could use {% if %}{% elseif %}{% else %}{% endif %} instead of consecutive ifs to provide a default ... I don't know what your data structure looks like.
You did mention that you want to use
 elements, so maybe you want something more like this instead:
{% if content.field_title_level.value == "h2" %}

{{ content.field_title }}

{% endif %}
{% if content.field_title_level.value == "h3" %}

{{ content.field_title }}

{% endif %}
{% if content.field_title_level.value == "h4" %}

{{ content.field_title }}

{% endif %}

Be aware, though, that
 elements are not semantic HTML like the header tags. (Even though they may be visually styled to appear like HTML headers, they will not be treated the same way by assistive technologies, like screen readers for the blind.)
Finally, note that you can do some very cool tricks by rendering Paragraphs content in the node template, by iterating through the items in the Paragraphs entity reference revisions field like so:
{% if node.field_paragraphs_items %}
  {% for item in node.field_paragraphs_items %}
    {% if item.entity.field_title %}
      {% if item.entity.field_title_level_value == "h2" %}

{{ item.entity.field_title }}

      {% endif %}
      {% if item.entity.field_title_level_value == "h3" %}

{{ item.entity.field_title }}

      {% endif %}
      {% if item.entity.field_title_level_value == "h4" %}

{{ item.entity.field_title }}

      {% endif %}
    {% endif %}
  {% endfor %}
{% endif %}

(Markdown syntax highlighting does not like my Twig, so there may be some errors in this example but hopefully you get the idea.)
Note the use of item.entity (in the node template) instead of content (in the paragraph template.) Just as pulling back from the field template to the paragraph template brought more field values into scope, rendering paragraphs entity references in the node template in this way will give you access to field values from the node as well as those in the paragraph.
There are pros and cons to both approaches. Keeping paragraph markup in the paragraph templates will keep your Twig tidier, so I generally recommend it unless your business logic requires you to render Paragraphs conditionally based on values in the parent node.


You have different ways/options to solve your issue.

Option 1:
Create a page node and then set node URL as default front page in admin/config/system/site-information

Option 2:
Create a view page using Views module and set the page url as default front page (same as previous option).

Option 3:
Download and Enable Empty Front Page module and then locate any block you want in the content region.


Adding “Unblock the user” option in Views Bulk Operations field

In drupal 7-

We need a Rules module, after enable Rules module and Rules UI go to

1- Configuration -> Workflow-> Rules-> Component-> Add Component

In Component plugin dropdown-> select Action Set
then add next page
Fill the mandatory field Name as (Ex: Unblock user)

2- Select Data type from list User ---Label Unblock user ---machine name unblock_user -- usage parameter

3- In setting option you can set Permission roles wise.

then click on continue button
then click on Add Action Link

4- then Select the action to add User ->Unblock User

5- Select Data Selector -> unblock-user and Save

6- Now go to- Views Page add field Bulk operations there will be present Unblock user option

for reference - Add Unblock user option by rules in views and set permission


Hide contextual filter parameter from view url

I don't think this is possible if you show the view as a page, but you might be able to solve the problem by creating a custom route and rendering the view on that page, where you fetch the uid programatically.

You must do something like this in your Controller:

$user_id = 1;
$args = [$user_id];
$view = Drupal\views\Views::getView('my_view_id');
if (is_object($view)) {
  $view->setArguments($args);
  $view->setDisplay('page');
  $view->preExecute();
  $view->execute();
  return $view->buildRenderable('page', $args);
}


Cron run exceeded the time limit and was aborted + How to change max_exec_time if not access on php.ini

Seeing as you don't have access to anything that allows you to change the max execution time (and I would imagine if you find a workaround that it won't work if your server is this locked down) I see a couple of options.

1:  Utilise the Batch API as I mentioned in my comment (Batch API docs are here)

2: Check out Elysia Cron to split your cron tasks up into smaller, more manageable chunks.

  Elysia Cron extends Drupal standard cron, allowing a fine grain
  control over each task and several ways to add custom cron jobs to
  your site.


Easiest way to test email notifications locally?

You can log the emails, which also brings some sanity to your inbox. Of cause there is a module for that (or two):

Maillogger
Maillog / Mail Developer


How to remove chosen comma between taxonomy

You need to go to the content type's display settings and change the display format.

/admin/structure/types/manage/article/display

is an example url you might go to to edit the article content type display settings.


I hope the said page is a view page in itself and you are passing a argument to that page.

If that is the case then you should check "Provide Default" value when you add the view and then select the required property from the dropdown. You would have something like get term id from url or what ever your argument is. Select that and it showup as you want.

If you need more clarification it would be good if you can export the view you have created or explain how you have created the view.


How to create a simple shopping cart without Drupal Commerce or Ubercart?

Maybe you should just use webform or entityform. With the flag module you can achieve that multiple items can be ordered. If there is no need for payment or checkout like in a 'normal' webshop, do not make it more complicatet than it is: actually you want your visitors to be in contact about one or more items on you website and get their details.


How can I change a menu link dynamically? (D7)

You want to implement hook_translated_menu_link_alter().

This hook is not called for all menu items. According to the API documentation:

  It is only invoked if $item['options']['alter'] has been set to a
  non-empty value (e.g., TRUE). This flag should be set using
  hook_menu_link_alter().

Here's an example:

function MODULE_menu_link_alter(&$link) {
  if ($link['link_title'] == 'foo') {
    $link['options']['alter'] = TRUE;
  }
}

function MODULE_translated_menu_link_alter(&$link) {
  if ($link['link_title'] == 'foo') {
    $link['href'] = 'node/5';
  }
}

Some notes:

you may want to filter additionally by $link['menu_name']
MODULE_menu_link_alter() is invoked on cache clear for all menus items declared via hook_menu().
For menu items created via web it is only invoked on save, that is, for this code to take effect you need to edit-and-save menu links you want to alter.

For reference, this technique is implemented by core in user.module (see user_menu_link_alter and user_translated_menu_link_alter) and by menu_token module.


core-quick-drupal doesn't require mysql, it would use something like sqlite. drush site-install allows you to specify config options like the mysql connection.  For example:

drush site-install mysite --db-url=mysql://user:pass@server/dbname