texts: Internal URL or menu callback to use node/entity content without html/page wrapping

texts:
Does anyone know, if there is any work-around or regular setup for panels or custom code known, to be able to use a url/node/%id or node menu-callback to render node/entity content delivered without the rendered page wrapping (<html> <header>,etc)?

I am not asking for Panels_everywhere behavior nor for Drupal modules like Colorbox, Lightbox, and all the others, nor Colorbox_node popup and such. I only try to have the node/entity callback url at hand to render entity or node content without any page.tpl.php or html.tpl.php involved, to use it somewhere else like for bootstrap modal, node_panels rendered into modals, or for custom scenarios to get most flexibility.

I took a look into Ctools module suite's modal callback and Entity_popup but the lack of documentation (no offense) and the confusion in my mind lead me to here asking for some breadcrumbs and ideas.

Thanks for any help on this.


texts: Drupal Commerce "product type" vs kickstart "variation type"

texts:
I am new to online shops creation, and I am looking at Drupal Commerce and its popular distribution package, Drupal Kickstart.

I understand more or less the concept behind "product type" in Drupal Commerce, but Kickstart uses different terminology - "product variation type". Is it the same thing? Is there difference?


texts: Best practice for building modules using classes

texts:
I'm looking to start building my modules as classes now that lazy/auto-load are in Drupal 7, and I'd love to look at some modules (contrib or core) that are doing a great job of it.

Is there a creative way for integrating a class as hooks? Do I implement each feature as a ctools plugin?

Any passers-by should note that D7 has new files[] declarations in module .info files for auto/lazy-loading classes/interfaces: Writing .info files (Drupal 7.x).

The following is a good read to get the motivations and the constitution (as it were) from the Drupal community Drupal programming from an object-oriented perspective.


texts:
I have a $user and what to get the style image as a URL

originally found this answer How do I access a user image?

but it was not what I was looking for


texts:
I am having a pretty base navigation menu in d8 .But compared to d6 its style is pretty basic . How can i have a decent navigation menu ?

navigation menu in d8

navigation menu in d6

How can i have a styled navigation menu in d8 ?? I blurred it because content not to be exposed ;) .


texts: Drupal 7, generalizing a view to use as a link in a menu

texts:
I have 2 content types "Project" and "Document" and 2 Taxonomy vocabularies of
"Document-types" (ex: calculations, reports, etc.), and "Projects" (the project names "alpha", "beta", etc).

All documents have a term reference to a project name and a document type, and
all projects have a reference type to a project name.

What I want is a menu that can be placed in the First side-bar of each Project that will have links like
"reports", "calculations", etc that will show all documents of type "report" or "calculations" etc.
(all projects have the same menu structure)

The problem is I now have an alpha-menu for the alpha project, a beta-menu for the beta projects, etc.

I can make a menu for each project where each link in the menu goes to a page view.
For the "reports" link in the alpha-menu the Views Filter is:

Content Published (Yes)

Content Type (= Document)

Content Document Type (= report)

Content Project (= alpha)

I want to make a generalized menu that when placed in the first side-bar of a project is will display the
correct documents for the project the menu is in.

The "reports" link for the generalized menu should look like"

Content Published (Yes)

Content Type (= Document)

Content Document Type (= report)

Content Project (= THE PROJECT YOU ARE DISPLAYED IN NOW)

How do I do this?????


texts: How to alter standard.front_page in module links YML file?

texts:
I have a menu with a "Home" link which was "provided by the Standard module. The title and path cannot be edited."

I am trying to alter the text/link using my module's links.yml file like so:

standard.front_page:
  title: 'Home Test'
  route_name: '<front>'
  menu_name: main

However this has no affect on the menu link. Other entries in this file work just fine.

Is it possible to alter the link in this way, or is the only option to use one of the menu hooks such as hook_menu_links_discovered_alter


texts: Theming a file link by adding custom file name suggestions

texts:
I want to display a bunch of data inside a view table, where each dataset has up to three different files. The user should be able to download these files by clicking a custom button or image in this table. I already learned that it's really hard or impossible to create different templates for fields of type file (file_link), at least without creating custom modules. For example, one file is from type PDF, and by default, Drupal shows a small PDF icon in front of the file name, and the file size behind. I can completely customize this behavior by editing file-link.html.twig, but this customizes ALL file links in the table, well, on the entire page.
I want to create a custom template for each file, based on their field name, like this: file-link--field--node--field-xyz-pdf.html.twig. I tried to alter theme suggestiongs by hooking into MYMODULE_theme_suggestions_file_link_alter(&$suggestions, $variables) through a custom module, but $variables doesn't contain the original field name or something else unique related to the field.
My next step was trying to hook into MYMODULE_preprocess_file_link(&$variables) and further into MYMODULE_preprocess_views_view_field(&$variables, $hook), finally finding the field name: $variables['field']->field.
But how do I pass this field name back to the theme suggestions hook? Honestly, I'm at my wits' end.


texts: Bootstrap site, not mobile friendly anymore

texts: I made a website with Ubercart and Bootstrap. It was all running fine until a while ago. For some reason the website stopped being mobile friendly. When on mobiles it would show the desktop version and the navigation bar would not become the three bars button for example. Weird thing is when resizing the browser window on the computer it works as expected, but when trying it in developer tools it just doesn't care and remains as desktop version, on mobiles as well. I'm pulling my hair at this point. I have tried disabling a ton of modules but nothing changed. If you can look at the website and go into developer tools and check if there is some sort of an error or something that could help.


texts: How to render the field from custom block in node.twig

texts:
I want to render the custom field from my block in node.twig. As I understand I have to expose the fields from Block to Node variables.

How to realize that?


texts: How to stop Watchdog from logging "DEBUG" errors?

texts:
I get this error in my logs a lot:

Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; views_many_to_one_helper has a deprecated constructor in require_once() (line 127 of C:\...\sites\all\modules\contrib\ctools\ctools.module).

This is really not important to me and I don't want it filling up watchdog. Is there any easy way to tell Watchdog to not log these errors? Where can I change which errors get logged by watchdog?


texts:
I want to use Apache Solr in my site build with Drupal7.
The server is UP, simples searches are working but I can't boost a field with bias.

For example, I boosted the title (or label in the administration page), giving him a 5 in the select field.

After re-index the node, I searched and the order of the result still the same.

I tried to create a little module with apachesolr's hook to watch the document it send to solr server.

hook_apachesolr_index_documents_alter():

[_fieldBoosts:protected] => Array
(
[id] =>
[site] =>
[hash] =>
[entity_id] =>
[entity_type] =>
[bundle] =>
[bundle_name] =>
[path] =>
[url] =>
[language] =>
[path_alias] =>
[label] =>
[content] =>
[teaser] =>
[ss_name] =>
[tos_name] =>
[ss_name_formatted] =>
[tos_name_formatted] =>
[is_uid] =>
[bs_status] =>
[bs_sticky] =>
[bs_promote] =>
[is_tnid] =>
[bs_translate] =>
[ss_language] =>
[ds_created] =>
[ds_changed] =>
[ds_last_comment_or_change] =>
[is_comment_count] =>
[type_name] =>
[created] =>
[changed] =>
[last_comment_or_change] =>
[comment_count] =>
[name] =>
[tos_content_extra] =>
[access__all] =>
)

All the data are empty.

This is a screenshot of my module setting page.

screenshot http://img338.imageshack.us/img338/7984/drupalsolrconf.png


texts:
I am adding content to my page using file_get_contents (I'm rendering the content to strip all template html as in this example: https://stackoverflow.com/questions/247991/displaying-a-drupal-view-without-a-page-template-around-it).

Some of the pages have forms which should be submitted normally, as in the page should be validated and redirected after submission. However submission is not working. For example, if the page is at http://mysite.com/myform and pressing the cancel button should call myform_cancel() and redirect me to http://mysite.com/, I instead get redirected to http://mysite.com/myform?response_type=embed and no submit methods are called.

What do I need to so to make my form submit as expected?

Edit:
A similar thing happens when I instead render the form using menu_get_item to get the callback and arguments, then render the html using: drupal_render(call_user_func_array($menu_item['page_callback'], $menu_item['page_arguments'])). This time I am redirected to my 'http://mysite.com/ajax-form' which is my menu url to the ajax call used to return the html.


texts:
In Drupal 5 there was a possibility to filter our content type's NIDs using "is one of" operator. So I have a view where I only used one filter like

Node: Node ID -> Is One Of -> <?php return callback_function() ?>

This callback_function() returns an array of NIDs and my view works just perfect. While moving project to Drupal 7 I discovered that there is no more such operator. Does anybody knows any possibility to use this good old "Is One Of" operator? Thank you!


texts: What is the best way to submit form values and output on an unthemed page?

texts:
I am writing a custom module that will be used to print consignment labels for a shipping provider.

The labels print 4 to a page. The module provides a form that allows the user to specify the number of packages, the dimensions etc then prints a label for each package. I will want to format them with CSS so that they print correctly to the label peel off sections etc

One way I had worked out to do this was to have a second form on the page which submits to a PHP file in my module directory. I place the code in this PHP page to process the labels and output which I can then print from.

This solution works, however it is outside of Drupal in that the form posts to a standalone PHP script. Is there a way to do this within Drupal? I have looked at the Print, PDF module but I dont know if I can configure it in this way.


texts: How to show a link only if a node author has a certain role

texts:
I have a block with which I'm creating a menu for users

<?php global $user;?>
  <a href="/user/<?php print $user->uid; ?>/ideabooks">MENU1
  <a href="/user/<?php print $user->uid; ?>">MENU2
  <a href="/user/<?php print $user->uid; ?>/ideas">MENU3

This block will only be visible on user profiles. Now I want to add another link only if the profile owner has a certain role.
So I guess I have to be able to get the node author(profile owner) and then check it's role.

How may I do this?


texts: How to render an entire page from external php page?

texts:
I'm creating a custom .php page that is outside my drupal installation and it should render a custom page of the installation. The "entire" page, also with theme and everything else.

I'm using this code, works but is not loading the theme:

    <?php

    /**
     * Root directory of Drupal installation.
     */
    define('DRUPAL_ROOT', '/home/quickstart/websites/custom.dev');

    include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

    drupal_deliver_html_page('user');
    ?>

Where am I wrong?


texts: How to sort field_info_instances return value by field weight?

texts:
I'm using field_info_instances() to retrieve the information for all the fields used by a content type, for example calling it as field_info_instances('node','bundle_name').
In the returned array, the fields aren't ordered as I expected. I need to get the fields ordered per weight.
For example, a field weight is 8, in the Manage fields list.

Despite this, it's shown on the top, in the output from field_info_instances().

Is there any possibility to get the fields ordered?


texts:
I've implemented a RSS feed with aggregator on my website.
It works well but i'd like to know if it is possible to force Aggregator to update the items with a function.
I need to use it in a custom module but i don't find anything in the Aggregator API.

Thank you !

Edit : problem solved (aggregator_refresh function)


texts: forcefully / manually remove content type

texts:
Is it possible to manually remove a content type?

I've packaged it in a feature and now the content type is no longer needed; it's been deprecated. I'm unable to delete the content type after disabling the feature in the features panel and in the modules page.


texts:
I have tried PDF using mPDF and Printer-friendly pages (Drupal 7.x). They both need own styling of an output. I have got a CSS that formats my pages for printing. I would like to generate PDFs by just "printing" to them. I do not want to maintain separate styles.

Is there a module that generate a PDF file with an output that would be sent to a printer?


texts:
I am new to panels, and am attempting to design a panel page. Is there any simple way to center content in panels? I can mess around in css, but I feel like I must be missing some simple solution.

How do you center content in panels 3?


texts:
I need a custom field whose default value will be a "next free" value calculated using a user-defined scope (selection of content types). But before I even try to bother coding, maybe someone knows of such a contributed module? My searches returned nothing.

I'd be reluctant to using Computed Field as I feel somewhat uncomfortable storing PHP code in database.


texts: Drupal db_or() only returning one result

texts:
Can someone please tell me why this code always returns only the last value of the query? I have tried many ways to dynamically build the condition statement for the querying of the database. I have looked at a couple examples and from everything i have seen, this is the way to do it. Any help would be greatly appreciated. Thanks!

function get_drupal_school_info($schoolIds) {
$or = db_or();
foreach ($schoolIds as $index => $data){
$or->condition(db_and()
    ->condition('f.field_external_id_value', $data['entity_id'],'=')
    ->condition('f.bundle', 'school')
    );
}

$query = db_select('field_data_field_external_id', 'f');
$query->leftJoin('field_data_body', 'b', 'f.entity_id = b.entity_id');
$query->leftJoin('field_data_field_partner_code', 'pc', 'b.entity_id = pc.entity_id');
$query
    ->fields('f', array('entity_id'))
    ->fields('b',array('body_value'))
    ->fields('pc',array('field_partner_code_value'))
    ->condition($or);

return $query->execute()->fetch();
}


texts: Execute a rule after a countdown finishes

texts:
I checked Countdown Timer Field module and some others but it seems they can't help in this issue.

I have a content type (organic group content type) I want this content type have a field for example "open until" and let the users indicate the date, once the countdown ends I want that organic group to be closed.

I want to have an event in rules like for example "countdown ends"

How to do this? thank you


texts: I am creating a multilingual site using the Internationalize module for Drupal 7. A lot of the CSS on my site is dependent on the body class section-... I have a page called Solutions which has a body class of section-solutions, I have multiple styles that use that selector.  When I switch to Protugues that selector changes to section-soluções and all my styles are gone.  Is there any way to keep all the HTML on the page in English?


texts: Add css file to the Admin Theme of the Commerce Kickstart distribution?

texts:
I'm trying to add a css file to the Admin Theme (for Backend) of the Commerce Kickstart distribution.

I tried this in a custom module, but not working, the css file is not loaded at all.

drupal_add_css(drupal_get_path('theme', 'commerce_kickstart_admin') . 'css/overrides.css', array('group' => CSS_THEME, 'type' => 'file'));

I created the css file at:

profiles/commerce_kickstart/themes/commerce_kickstart_admin/css/overrides.css

Also, is there any way to put the css file in other location? like:

  site/all/themes/mytheme/css/overrides.css


texts: Page title tag translated based on view title

texts:
I've been working on a multilingual site using i18n modules, with the 'translate view' ('Internationalization Views') module, provided by i18n, active too.

I can translate the view's title and the content, but what I need to translate now it's the content of the tag <title>. I've searched the web, but didn't found any answers to this problem, can anyone help me?

EDIT:

I didn't see that the problem actually apply on just one view.
The text in italian is "cinematismi" and it should be translated into "Wiper mechanisms".

In the "translate interface" section I see the following strings:
(the first one doesn't matter because it was an old view)

The problem is that all strings are actually translated.
Can someone tell me what string should it be?


texts: Drupal commons running very slow, what are the key modules to disable?

texts:
I'm running Drupal commons latest version 6.x-2.9 on MAMP 2.1.1 (clean install).

Drupal commons running very slow when I'm in the administer section. There's tons of modules and I'm not sure which are the key ones causing the slowness.

Need advice on that.


texts:
Is it possible to change the default tab for Media browser (Media module) in Drupal 7?
Currently I have:
Upload, Web, Library and My Files.

I would like to open Library by default, instead of Upload.


texts:
I'm relatively new drupal user, that always get nervous when taking a site live.

I need to redesign our current website as well as add some modules and node types etc.

What i plan to do is just grab the drupal files and the database, change them up locally and then replace the files and database on the live site.

Is this the best method for doing this?

Looks like a relatively simple task, but i just don't wanna be spending 3 days of headache again working out how to take a site live.


texts: How do I migrate a CCK node reference from drupal 6 to entity reference drupal 8?

texts:
I try to migrate cck field node reference drupal 6 to drupal 8 reference field?. After migrate I don't see cck field_node in drupal 8.

field_node:
-
  plugin: iterator
  source: field_node
  process:
    target_id:
      plugin: migration_lookup
      migration: upgrade_d6_node_page
      source: nid
destination:
  plugin: 'entity:node'
  default_bundle: cck
  overwrite_properties:
    - field_node


texts:
Currently I'm on example.com/node/add page. Now I wish to add content in content type = article. What I want is, when accessing path /node/add/article, add content url should look like node/add/article?keyword='hello'

And this page still opens add node article page.

I tried changing alias at /admin/config/search/path/add

/node/add/article

to

node/add/article?keyword='hello'
But it didn't worked?


texts: Batch API on a Dreamhost dedicated server

texts:
I am on a Dreamhost dedicated server. I use it to host Drupal sites that our company creates. We recently moved on to this server from another hosting company and have noticed that Batch API features do not work for Drupal 6 or 7. (This same dataset that's failing worked on our last server)

What is the difference? I have upped max_allowed_packet to 100mb, I have increased the Apache timeout to 900 seconds, and have changed the following PHP vars to some pretty high amounts:

max_execution_time = 1600
max_input_time = 1600
memory_limit = 2048M
post_max_size = 2048M

It still won't seem to work. It hangs on initialize and gives me the following message:

  An AJAX HTTP error occurred. HTTP Result Code: 403 Debugging
  information follows. Path: /batch?render=overlay&id=3329&op=do
  StatusText: Forbidden ResponseText: Access denied

I can run them in the background with Drush, however I have to run core-cron several times over and over to make the import work. This works for some items, but is not ideal as some clients like to use Views Bulk Operations on their sites for managing content.

My server is the top of the line server with 16GB of memory.


texts: height of block with view containing exposed filter

texts:
I have created a block with a view containing an exposed filter (drop downbox, auto submit).
Based on the selection in the dropdown, the visitor will see a short or long list of results. This block is located in the content region of one particular node.

The height of the block does adapt to this result, but unfortunately all elements below this block (i.e. the footer region) do not go below this block. They just remain on the initial height as when the page loaded.

How can I tell the footer to go below the block with the view automatically each time the filter is changed?

Your step-by-step help is highly appreciated!

Regards,
Hans


texts: How to make several instances of nivo slider in Drupal 7?

texts:
I develop a web site using the Drupal 7 cms. I use Nivo Slider and it works perfectly for me. I used nivo slider for the front page of the site. When I configured the nivo slider it's settings are displayed under structure in the Drupal CMS menu. Basically, I have to update images and set transitions and etc.

Now the problem is I have another page where I need to add a new slideshow. But I don't know how to make another instance of nivo slider and use it. Since this is a CMS I guess there should be a easy way to handle this.

I think my problem is clear. If not, please ask in comments where I have to clarify my problem.


texts:
I have a View of taxonomies. I want to rewrite the output of each field (name) as this:

[name]

so when I click on the taxonomy, it will prompt an alert with the term name.

I try to rewrite through the Views GUI to no avail.
I even tried with views_pre_renderbut because there is no #markup property, the rewriting is not HTML but plain text.
I did the trick with views_pre_render and other kind of content, but not in taxonomy. And is it really impossible to achieve that in the GUI ? Surely I am missing something very very basic here.


texts:
While a real subdirectory subsite has a URL of example.com/site1, and shares codebase with example.com, I was wondering if it's possible to create a separate Drupal installation (in a separate docroot) for site1 and still use the URL example.com/site1. In my case, they are two completely different Drupal installations with nothing to share, well, except the somehow 'related' URL part.

I know I can just use a sub domain and make the whole thing a lot easier but am wondering if the pseudo 'subdirectory subsite' is an option.


texts: Render view in code with the proper view mode

texts:
I have a view that calls for Show: Content, using a very specific view mode (neither Full content nor Teaser, it's created on purpose and themed according to my needs, basically an e-mail oriented output with very different HTML classes than the usual views displays in Drupal). When used in a page, it renders perfectly. However, when I render it from code to be able to use the resulting HTML directly:

$view = Views::getView('view_id');
$view->setDisplay('default');
$view->setArguments($args);
$view->preExecute();
$view->execute();
$render = $view->render();
$html = render($render);

I get an otherwise perfect render but not with that view mode, just the usual stuff. Alternative calls do the same:

$render = $view->buildRenderable('default', $args);
$html = render($render);

How could I force it to render the way I want it?


texts: Redirect users to different page after a login failure in d7

texts:
I want to redirect the users to different page if they enter the wrong login details, for that I am using following code but it is not working.

function bartik_form_alter(&$form, &$form_state, $form_id)
{
    if ($form_id == "user-login")
    {
        $form["#validate"][] = "bartik_validate_login";
    }
}

function bartik_validate_login($form, &$form_state)
{
    // on successful login, the uid is set in form_state.
    if (empty($form_state["uid"]))
    {
        $_GET["destination"] = "some url goes here";
        drupal_goto("some url goes here");
    }
}


texts:
I have a subscription product which will offer 1month , 1 year , 3 years packages. So i created all the product variations needed and i build a custom block to select all these packages.
When a user selects one package and went to cart page. Again if browser back is clicked then user will redirect to custom package selection page, If user selects another package then drupal commerce treats them as two different cart items.
I want to update the existing cart item with new package they selected. I tried below code but not worked.
 public function addPackages($param) {
    if (empty($param)) {
      return FALSE;
    }
    if (empty($param['id'])) {
      return FALSE;
    }
     $id = $param['id'];
    if(isset($_GET['vid'])) {
      $vid = $_GET['vid'];
    }else{$vid=0;}
    $session  = \Drupal::service('session');
    if (!$session->isStarted()) {
      $session->migrate();
    }
    $product_variation = $this->entityTypeManager->getStorage('commerce_product_variation')->load($id);
    if (empty($product_variation)) {
      return FALSE;
    }
    $store = $this->currentStore->getStore();
    if (empty($store)) {
      return FALSE;
    }
    // order type and store
    $cart = $this->cartProvider->getCart('pack', $store);
    if($cart) {
     $state= $this->remove_all_product_types(array('pack'),$vid,$cart);
    }else{
      $state=true;
    }

    if (!$cart) {
      $cart = $this->cartProvider->createCart('pack', $store);
    }
    $order_item = $this->entityTypeManager->getStorage('commerce_order_item')->create([
      'type' => 'pack',
      'purchased_entity' => (string)$id,
      'quantity' => 1,
      'unit_price' => $product_variation->getPrice(),
    ]);
    // unset($param['id']);
    foreach ($param as $key => $value) {
      if ($order_item->hasField($key)) {
        $order_item->set($key, $value);
      }
    }
    $order_item->save();

    if($state) {

      $this->cartManager->addOrderItem($cart, $order_item, TRUE);
    }else {

      //echo ' i am in update'; exit;
      $this->cartManager->emptyCart($cart, TRUE);
     // $order_item->set('subscription_type',$id);
      $this->cartManager->addOrderItem($cart, $order_item, TRUE);
     /* $cartManager=\Drupal::service('commerce_cart.cart_manager');
      $new_item=\Drupal::entityTypeManager()->getStorage('commerce_product_variation')->load($id);
      $cartManager->addEntity($cart, $new_item, 1,TRUE,TRUE); */

    }

    return $cart;
  }

  function remove_all_product_types($typesToRemove,$vid,$cart)
  {
    $orders = \Drupal::service('commerce_cart.cart_provider')->getCarts();
    $items = reset($orders)->getItems();

    foreach ($items as $item) {

      $purchasedEntityId = $item->get('field_vechicle_id')[0]->getValue()['value'];

      if ($purchasedEntityId == $vid) {

        $cart->removeItem($item);
        $status = false;
        return $status;
      } else {
        $status = true;
      }

    }
    return $status;

  }

Any help on this?


texts: Line breaks in site name but not in title tag

texts:
For design purposes I need line breaks in a multilingual site name. I have managed to do so by adding
 tags in the site name variable. But they show in the title within the html head tag and I don't know how to get rid of them.

I am using a custom Zen subtheme to which I have added the html.tpl.php file. In that I have tried the following approaches to no avail:

<title><?php print preg_replace('/
/iU', '', $head_title); ?></title>

<title><?php print strip_tags($head_title); ?></title>

<title><?php $head_title = str_replace('
', '', $head_title);
  print $head_title; ?></title>

Please excuse any profanities I may have committed in the use of php, I am no coder. Any ideas are most welcome.


texts: Any working techniques or examples for a multistep AJAX enabled node form

texts:
There's an AJAX enabled multistep form in the examples module and another in Chaos Tools (ctools_ajax_sample.module) In both cases the form is built in the function and doesn't use the default core node form.

Closer to what I'm after is a multistep node form using hook_form_FORM_ID_alter() but this one isn't AJAX.

Is it possible to use hook_form_alter() to create a multistep node form that is AJAX enabled, or should I build my multistep form independently, then use drupal_form_submit() or a new node object to save the data?

Drupal 7


texts: How do I change the ID of a copy of an exposed filter?

texts:
I'm using answers from Expose a view's filters both in a block, and in the actual view to duplicate an exposed filter as a block and make it appear in another region on every page.

I want to style both form copies a bit differently. When I started to look into the markup, I noticed that I'm getting two forms with identical IDs. Putting aside the styling, that's not good.
The code I am using is the following.

function MYMODULE_block_view($delta = ''){
  $block = array();
  switch($delta){
    case 'mysearch':
      $block['subject'] = t('My Search');
      $block['content'] = _MYMODULE_get_exposed_filter_form();
      break;
  }
  return $block;
}

/** Function to get the Exposed filter form **/
function _MYMODULE_get_exposed_filter_form(){
  $view = views_get_view('node_index_view');
  $view->set_display('page');
  $view->init_handlers();
  $exposed_form = $view->display_handler->get_plugin('exposed_form');
  return $exposed_form->render_exposed_form();
}

How do I alter the ID of the copied exposed filter block? If I use hook_form_alter() or hook_form_views_exposed_form_alter() it's going to apply the alteration to both instances.


texts:
On my Drupal site, I have about 100 nodes that need deleting. I have deleted them via Views Bulk Operations.

When I do this, if I make a backup of my site MySQL database and then try to restore it via PHP My Admin, I get the following error:

INSERT INTO `cache_form` (`cid`, `data`, `expire`, `created`, `serialized`) VALUES
('form_state_form-0ry4vXadnLIroZBOuRNpM4WJWgNm0HNVumQ1bNHLEu4', 0x613a363a7b733a31303a226275696c645f696e666f223b613a333a7b733a343a2261726773223b613a323a7b693a303b4f3a343a2276696577223a35363a7b733a383a2264625f7461626c65223b733a31303a2276696577735f76696577223b733a31303a22626173655f7461626c65223b733a343a226e6f6465223b733a31303a22626173655f6669656c64223b733a333a226e6964223b733a343a226e616d65223b733a31313a2262756c6b5f64656c657465223b733a333a22766964223b733a313a2236223b733a31313a226465736372697074696f6e223b733a303a22223b733a333a22746167223b733a373a2264656661756c74223b733a31303a2268756d616e5f6e616d65223b733a31313a2242756c6b2044656c657465223b733a343a22636f7265223b733a313a2237223b733a31313a226170695f76657273696f6e223b4e3b733a383a2264697361626c6564223b4e3b733a373a2265646974696e67223b623a303b733a343a2261726773223b613a303a7b7d733a383a227573655f616a6178223b623a303b733a363a22726573756c74223b613a3130303a7b693a303b4f3a3[...]
MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2

The error has been caused by deleting the nodes. If I go to an earlier back-up before the nodes were deleted, it works fine. However, everytime I delete the nodes, this error comes back.

How can I delete the nodes without the database becoming corrupt. I clear the cache after deletion and before backing up, but the problem still occurs.

Interestingly after deleting nodes, the size of the databse jumps from 16MB to 80MB. So I am not sure if the deletion is putting some bad data in the database.


texts: How to output correctly an html_restricted textarea field in Twig?

texts:
I don't know if that stupid question has already been asked...

But how should I output a field type "text_long" in Twig ?

Now what I do is to set myself an array with that :

$data = $journalist->field_bio->getValue();

$user['bio'] = [
                    '#type' => 'processed_text',
                    '#text' => $data[0]['value'],
                    '#format' => 'full_html'
               ];

Because I cannot find the filter to render a text_long in html.

In the twig I tried : {{ user.bio | raw }}, {{ user.bio | render }}...

=> What's the drupal 8 way to handle that ?


texts: Using forms API - sending submitted data as an XML attachment to an email address

texts:
I need to have a request form on a D7 site which does a few different things with the form data:

Writes to database table (standard);
Emails a copy of the form data to a site administrator on a pre-defined email address;
Creates a XML file attachment in a prescribed format (not valid XML, so possibly best being a template with placeholder values being replaced by form data) which is also attached to the email to administrator.

The generation of the XML is currently working fine in a bespoke PHP system and I'm thinking for ease re-using the functionality would make good sense.

However, is there a simple way to hook this into the submit process for the Drupal form? I believe using the Forms API may be the best approach?


texts:
I am using VBO and I want to change the submit function on my form. I have tried the following code:

function a_views_bulk_operations_form_alter(&$form, &$form_state, $vbo) {
  if($form_state['step']=='views_bulk_operations_confirm_form'){
    $form['#submit'] = 'a_myfunc';
  }
}

function a_myfunc(&$form, &$form_state, $vbo) {
  dpm('Hit');
}

The a_myfunc is not hit. Instead I go to the normal VBO processing page. How can I change the submit function>


texts: How can I add 'text/jsx' type to a script tag via libraries.yml?

texts:
I want to add some react js files to a theme's libraries.yml and I don't know how I can do this in drupal 8.

<script type="text/babel" src="scripts/example.js"></script>
or
<script type="text/jsx" src="scripts/example.js"></script>

I can't figure it out hot to make the type="text/jsx" appear when the file is added to the page.

Any ideas on how I can achieve this in Drupal 8?


texts: Remove All Unwanted js and css files from theme

texts: I create a website based on Drupal. When I look at the JavaScript and CSS files loaded from Drupal, I see many unwanted files loaded. I want to force Drupal to load only those files added to the .info file and remove everything else. I think I can achieve it by using hook_js_alter() but I want to know if there is a better solution.


texts: I want to install Drupal in https, but I failed.The page is trying to open resources (css, etc) in http. How to solve this ?


texts: Conditionally display a field based on another field's content by field.tpl.php

texts:
What i would like to achieve is to be able to show the field's content only if another field of the node being displayed has a certain value. So I'd like to put an if condition at the beginning of the custom field.tpl.php that controls whether the content is public or restricted based on another field's value (whether the node is tagged as free or not).

Actually, what I am trying to achieve is  to make a double control: if the node is tagged FREE, display it right away, if not, see the user's permissions and display it of he has "paid user" role (just to explain things).


texts: How can we edit www.example.com/user page?

texts:
The user page doesn't look good. I want to edit it, but (If I am right) that is a default page. I am not able to find where to edit it.

How can I edit the user page?


texts: Add a conditional CSS class to the label of the view exposed form

texts:
I try to add a CSS class sr-only to the label of my Views exposed form.

In form-element-label.html.twig I added:

{% if title is not empty or required -%}
  {{ title }}
  {% elseif title['#markup'] == "Search" %}
    {{ title }}
{%- endif %}

When I debug {{ kint(title) }} I get:

What I'm doing wrong?


texts: Show new result each time I visit the page

texts:
I want to display a result in a view, and each time I visit the page, the result will be the next node from the choosen contenttype.

Is this something I can manage in views or is there any other way?


texts:
Can anyone help me how to delete or hide the menu titles (eg MAIN MENU title)?

I know how it is done when I do it on a static template but I cannot find it in Omega.


texts: Javascript Not Functioning At All on Drupal 7

texts:
I haven't worked on building out my site for about 5 or 6 days only to come back to find that Javascript is completely non-functional on my site. As far as I can remember (about 90% positive), everything worked fine last time I worked on it.

Using Firebug, I've found the following error 4 times:

jQuery is not defined
})(jQuery);

And this error 7 times:

Drupal is not defined
jQuery.extend(Drupal.settings, {"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"capstoneskele","theme_token":"4I-qysgFuZXzCXVlRhgBo6i118JK5s1LLy2-a_ti1lE","js":{"misc\/jquery.js":1,"misc\/jquery.once.js":1,"misc\/drupal.js"......(cont'd)

I've been mostly playing around with a custom theme, so perhaps it's something with one of my tpl.php files - I'm new to Drupal so I really don't know. Any ideas/help would be greatly appreciated as my graduating college is dependent on this project...thanks!

please let me know what further details I can provide also...


texts: field_info_instances() returns an empty set in hook_uninstall but not in module file

texts:
Why would field_info_instances() return an empty set in hook_uninstall() when it returns the expected results in the main module file?

I've used the exact same code to delete the fields for a set of bundles in both the .install file and the main .module file:

  $bundles = array('property', 'open_house', 'agent', 'office');
  // Delete fields
  foreach ($bundles as $bundle) {
    $instances = field_info_instances('content', $bundle);
    if (!empty($instances)) {
      foreach ($instances as $instance) {
        dpm($instance);
        //field_delete_instance($instance);
      }
    }
  }

The following code (pulled from _field_info_collate_fields() in field.info.inc) outputs the fields in a list:

  $definitions = array(
    'field_ids' => field_read_fields(array(), array('include_deleted' => 1)),
    'instances' => field_read_instances(),
  );

as shown here:

 ... (Array, 2 elements)

     field_ids (Array, 149 elements)
     instances (Array, 8 elements)

It was suggested that I need to use drupal_load() and/or drupal_load_include() to load the field module or field.info.inc to use the field_info_instances() function. I also tried using drupal_load() to load my module, but the following code also does not work:

  $bundles = array('property', 'open_house', 'agent', 'office');
  drupal_load('module', 'field');
  module_load_include('inc', 'field.module', 'field.info');

  // Delete fields
  foreach ($bundles as $bundle) {
    $instances = field_info_instances('content', $bundle);
    dpm($instances);
    if (!empty($instances)) {
      foreach ($instances as $instance) {
        field_delete_instance($instance);
      }
    }
  }

Does anyone know why field_info_instances() would be unable to read the information about the field instances?

UPDATE:

When I run the following code: dpm(field_read_instances(null, array('include_inactive' => TRUE))); my fields are displayed.  Why are they inactive, is it because the module is being uninstalled and is disabled?  What should I do to work around this?


texts: How can I disable meta tags provided by the Metatag module for a custom route?

texts:
I have created a custom module for displaying the players information. Module will create dynamic pages and each page will display players stats. With the help of the following links, I was able to add meta tags to my module.

How to add meta tag in head
Adding meta tags

Since each of the page generated by my module for separate meta information, I was not able to use page_attachement_hooks. Using the above links, I was able to add meta information in my controller itself.

But, I am using Meta tag drupal module for generating meta information for other pages. Now I am getting multiple meta tags with same property name. Global configurations of meta tag module is displaying along with my meta tags.

I read in some blog that if multiple meta tags found with same property, few crawlers will ignore them. How do I keep only my meta tags?

I saw this post which says how to override the meta tags. But there the code has to be placed in the module and it will be static. I wanted dynamic meta tags for each page. How will I achieve it?

Here is my code.

PlayerController.php

<?php

namespace Drupal\player\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal;

class PlayerController extends ControllerBase {

  public function content($player) {
    $result = [];
    /* --------------
     code logic here
    ------------------ */
    return [
      '#type' => 'markup',
      '#markup' => $result,
      '#attached' => [
        'html_head' => [
        [
         [
          '#tag' => 'meta',
          '#attributes' => [
            'property' => 'og:description',
            'content' => $result->player_details,
          ],
        ],
        'player',
      ],
    ],
  ],
    ];
  }

}

For reference, I am adding link to my old question regarding how to add meta tags in dynamic module. It have more codes in case you need.


texts: How to set the parent of menu items creating using hook_menu()?

texts:
I need creating a series of menu items dynamically based on values from the database.

Here is a example of my hook_menu() function; in this snippet, I removed the DB queries and just added an array to prove the concept:

function MYMODULE_menu() {
  $years = array(2011, 2010, 2009);

  foreach ($years as $year) {
    $items['events/' . $year] = array(
      'title' => $year . ' Events Archive',
      'page callback' => 'page_archive',
      'page arguments' => array(1),
      'access callback' => TRUE,
      'type' => MENU_NORMAL_ITEM,
      'menu_name' => 'main-menu',
    );
  }

  return $items;
}

This works and I get three menu items in the Main Menu titled 2011 Events Archive, 2010 Events Archive and 2009 Events Archive.

The problem I am having is the position of the dynamically created menu items in the Main Menu tree; they appear at the top level, but I want they appear under the parent Events menu item.

Currently, my menu tree looks something similar to the following.

Home
Events
About Us
Contact Us
2011 Events Archive
2010 Events Archive
2009 Events Archive

It should look like the following.

Home
Events

2011 Events Archive
2010 Events Archive
2009 Events Archive

About Us
Contact Us

I know you can move the menu items using the Menu editor UI when logged in, but as these will be automatically created by the system; they need to appear automatically under Events without human intervention.

How can this be done? Is there an easier way to do this?


texts: Inject variables only in teasers (template suggestions)

texts:
How could I detect if node type is article (in template.php) but process variables only for teaser of article, not article i full mode. (I have template suggestions so i have node--article-teaser.tpl.php). Like:

if ($node->type == 'article' and inject only if article-teaser.tpl.php)

Thanks!


texts: How do I create a administration page (with overlay) through the UI

texts:
I would like to add an administration page (with overlay) to my site (not programatically). I assume the basic process is:

Create a 'basic page'
Set the path to /admin
Set permissions <-- How do I do this???  I can't see how do I
restrict the page??
Configure overlay - Is it automatic?
Add page to admin menu.

I'm stuck on 3, but I could probably use help on 4 and 5.

Thanks!


texts: How to get node's title and send list of it to mail

texts:
I am about to send an email to website admin.

First of all, there will be a function to get list of node's title that city field equal to 'barcelona'.

After that, the list will be send to website admin once every day using e-mail.

Any idea on how to do this with Rules or custom module?


texts: How can I add special classes to only all blocks that's generated in certain region?

texts:
I want to add some classes to each block that generated in custom region automatically.
For example I want to all blocks that generated within sidebar-left have some special classes and in addition I don't want to those blocks in other regions have those classes.

I try to use something like below code to add desired class to each block that's generated in sidebar-left:

region--sidebar-left.html.twig

{%
  set classes = [
    'region',
    'region-' ~ region,
  ]
%}
{% if content %}
  <div{{ attributes.addClass(classes) }}>
    {{ content }}
  </div>
{% endif %}

But it seems there isn't any loop functionality Like below to I can use for each blocks and add my desired classes to them:

{% for item in items %}
  <div class="my-desired-class">
    {{ content }}
  </div>
{% endif %}


texts:
I have search but not found so I need to ask.

I need a module that permit to my users to load a video into the node add form and this video need to be loaded into my youtube/vimeo page.

Is there? Please...

M.


texts: Views Filter Content Type Drop down option sorting

texts:
I have a view to with the Filter of Content Type in drop down and based on selection it is displaying the nodes.

Now I need to alphabetically order the Content Type options into Filter Drop down.

Currently the content type listed into drop down as

Press Release
News
Event

and I need to display it as

Event
News
Press Release

There is no such way I found into views configuration. Do any one have idea how to do so ?


texts: Setting the mime-type for files stored in the private directory

texts:
How do I set the mime-type of files being served from the drupal private directory. I have a webm file in the private directory, and the I've added the <video> tag to the page using a tpl file.

I've tried adding

AddType video/webm .webm

to .htaccess. I've also tried installing the module "File Mime" to try to set the right mime type. I've tried adding

function mymodule_file_download($uri){
    return array('Content-type: '.'video/webm');
}

to my .module file. Nothing seems to work. Any help would be appreciated.


texts: Why return AccessResult::allowed() ends up with "Access denied"?

texts:
I'm having a strange behaviour while trying to use hook_node_access in Drupal 8 (Lightning to be more precise) and I can't figure out why is doing this. Let's suppose that I want to always allow people to edit a certain content type (I know I can setup role permissions to achieve this, but I'm just trying to understand why it's not working):

function mymodule_node_access($node, $op, $account) {
  $type = $node->bundle();
  if($type == 'service' && $op == 'update') {
      return AccessResult::allowed();
  }
}

I always get "access denied" while trying to edit a "service" node.

This is what I've tried to do in order to debug it:

in reports > status reports there are no node access permissions in use;
the current user does not have "bypass content access control" permission;
hook_module_implements_alter doesn't return any other module using hook_node_access.

Is there anything I'm missing?


texts:
Drupal uses the concept of a placeholder quite a lot during form creation and theming, and also has a Placeholder Strategy in its the response event of its Render Pipeline.

What wasn't explained is what is a Placeholder?


texts: Drupal menu don't show up when menu based on token menu are fired

texts:
I have a menu in a drupal site. All elements was visible until I install "menu-token" module and make two elements based on tokens.
Now when I visit a page linked to a path that point on a views page, the two "token menus" disapear !

Al other menu items are still visible.

Can someone help ?


texts: Disable default view when offering module is disabled

texts:
I have the User IP Log that displays the logged data using a default view defined in the module; when the module is disabled, the view page becomes broken, throwing PHP warnings and notices.

I would like to disable the default view when the module defining it is disabled, to fix the PHP warnings I get. Is it the right way of handling this? If it is so, what API could be used for disabling the default view defined by a module?


texts: Getting parents' terms of terms tagged into a particular content type nodes

texts:
This is a bit confusing for me.

I am using Drupal 7 and Views 3.

I have a list of particular content type nodes tagged with a term (from a vocabulary "topic"). Vocabulary "topic" is 2 levels deep and nodes are tagged just with leaf terms. I have those same nodes tagged with another vocabulary ("level" vocabulary).

I'd like to get in a view all parent terms (exactly the term name) from the vocabulary "topic" whose children are tagged into a node which is tagged with a particular level (let's say beginners).

Let me show you an example:

Vocabulary "Level":

Beginners
Intermediate
Advance

Vocabulary "Topic":

Greek philosophy

Introduction to greek philosophy
First stage: Greek
Second stage: Greek

Latin philosophy

Introduction to latin philosophy
First stage: Latin

My content type nodes can be tagged with both vocabularies but in the case of "topic" they are only allowed to be tagged, as I said, with leaf nodes (i.e. Introduction to greek philosophy, first stage:greek, second stage: greek, Introduction to latin philosophy or first stage:latin).

In this context if one particular node  is tagged with "introduction to greek philosophy" and "beginners", I would get "Greek philosophy" on my view. If that same node is not tagged with "beginners" I wouldn't get it on my view.

I know it's a bit complex but I would really appreciate your help and orientation.

Thanks in advance.


texts: How to add multiple pagers in same page, with db_select queries? (In AJAX)

texts:
How to apply a pager with db_select?

I have setup a query like that:

$query = db_select('node', 'n');
$query->join('field_data_field_author_text', 'au', 'n.nid = au.entity_id');
$query->join('field_data_field_date', 'da', 'n.nid = da.entity_id');
$query->fields('n',array('title','created','type','nid'));
$query->fields('au',array('field_author_text_value'));
$query->fields('da',array('field_date_value'));
$query->condition('n.type', 'conference', '=');
$query->condition('n.language', $language->language, '=');
$or = db_or(); //Mandatory for OR conditions
$or->condition('au.field_author_text_value', '%' .db_like($keywords). '%', 'LIKE');
$or->condition('n.title', '%' .db_like($keywords). '%', 'LIKE');
$query->condition($or);
$query->orderBy('da.field_date_value', 'DESC');
$query = $query->extend('PagerDefault')->limit(10);
$result = $query->execute();

Then, I can print my results this way:

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

  print '
';
  $title = $value->title;
  $author_text_title = $value->field_author_text_value;
  $node_alias = url(drupal_get_path_alias('node/'.$value->nid));

  $field_title_excerpt = (search_excerpt($keywords, ' '.$title.' '));
  print '
'.$field_title_excerpt.'
';

  $author_text_title_excerpt = (search_excerpt($keywords, ' '.$author_text_title.' '));
  print '
'.$author_text_title_excerpt.'
';

  print '
';

}

Here is what my output looks like:

As you can see, I tried to apply a pager this way:

$query = $query->extend('PagerDefault')->limit(10);

Unfortunately, this is not working? Anyone has an idea how to achieve that? The best would be a page with AJAX feature!

EDIT

After I updated my code according to @Clive comment, the pager work perfectly as expected,many thanks!

Here is my code now:

$query = db_select('node', 'n');
$query->join('field_data_field_author_text', 'au', 'n.nid = au.entity_id');
$query->join('field_data_field_date', 'da', 'n.nid = da.entity_id');
$query->fields('n',array('title','created','type','nid'));
$query->fields('au',array('field_author_text_value'));
$query->fields('da',array('field_date_value'));
$query->condition('n.type', 'conference', '=');
$query->condition('n.language', $language->language, '=');
$or = db_or(); //Mandatory for OR conditions
$or->condition('au.field_author_text_value', '%' .db_like($keywords). '%', 'LIKE');
$or->condition('n.title', '%' .db_like($keywords). '%', 'LIKE');
$query->condition($or);
$query->orderBy('da.field_date_value', 'DESC');
$query = $query->extend('PagerDefault')->limit(5);
$result = $query->execute();

print '
Publications
';
print '
';

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

  print '
';
  $title = $value->title;
  $author_text_title = $value->field_author_text_value;
  $node_alias = url(drupal_get_path_alias('node/'.$value->nid));

  $field_title_excerpt = (search_excerpt($keywords, ' '.$title.' '));
  print '
'.$field_title_excerpt.'
';

  $author_text_title_excerpt = (search_excerpt($keywords, ' '.$author_text_title.' '));
  print '
'.$author_text_title_excerpt.'
';

  print '
';

}

print '
';
print theme('pager');

And here is what my page looks like:

Is it possible to display several pagers independent of each other?

And also, how can I turn them into AJAX featured?


texts: I created the basic page, then added alias front_page. Next, I created a translation of this node and have the same alias. In the settings admin/config/system/site-information in the field Default front page I added front_page, but on the home page is displayed when you switch the language is the same article, without translation. How to fix it?


texts: How to programmatically load a rendered view exposed filter block

texts:
I'm in Drupal 8 trying to load a Views Exposed Filter block based on its ID, similarly to how I would load a content block.

$bid = 'exposedformview_nameview_display_name'; // Found on mysite.test/admin/structure/block/manage/exposedformview_nameview_display_name/
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityManager()
        ->getViewBuilder('block_content')
        ->view($block);
return $render;

Nothing ends up printing out, and in the error log I see this message:

  Recoverable fatal error: Argument 1 passed to Drupal\block_content\BlockContentViewBuilder::view() must implement interface Drupal\Core\Entity\EntityInterface, null given

Sure enough, when I debug($block), it shows NULL.

I know this works for other blocks created in the content placement area, not sure why it wouldn't also work for views exposed filter blocks.  They are both available for placement in the manage blocks page.

EDIT: It seems as though it will not be possible to load the block like this.  This method depends on revisions being available for blocks.  There is no revision for a views exposed filter block so there must be another way to accomplish this.  Perhaps by loading the form directly.


texts: What may cause the text of a message created with the Message module to be empty?

texts:
I have installed the Message module to log activities, and set it up following these instructions.

All steps look good, and message (admin/content/message) is created after I added new content. But, the message's TEXT field is empty.

Also, Message: Render message (Get text) field in related View is also empty, and SHOW NO RESULTS BEHAVIOR is triggered.

I enabled message_example module come with message, same result.

Is there anything wrong with my options?


texts: Redirecting the home page to index.php, not index.html

texts:
I have an index.html file in the server root directory.

When users browse the domain, the index.html page should come first. In that index.html, I have created a link like enter website that links to index.php present in the server root directory to enter the Drupal site. When I click on the Home menu link, it automatically redirects to index.html; I need it to redirect to index.php.


texts: How can I exclude content older than... with Views

texts:
I'm trying to get my head around a Views setting, I can't find how to exclude older than two years old content from Views. I know it has to be somewhere in the Filter section. I would expect this to work, but it doesn't...

Content: Date (field_publication_date) - From date <= now + 2 year

I'm doing something wrong, can someone please help me out?

Thanks a lot!

PS: I'm on Drupal 6...


texts: Why are my if/else statements in page.html.twig ignored?

texts:
in my theme template of page.html.twig (theme is a subtheme of classy core theme), my if statements to render a region or not are completely ignored by twig template engine. The regions (e.g. the first sidebar are always rendered.

Code of my page.html.twig:

    {{ page.header }}

  {{ page.primary_menu }}
  {{ page.secondary_menu }}

      {% if page.navigation %}

        {{ page.navigation }}

    {% endif %}

  {{ page.breadcrumb }}

  {% if page.system_messages_area %}

    {{ page.system_messages_area }}

  {% endif %}

  {{ page.highlighted }}

  {{ page.help }}

      {# link is in html.html.twig #}

        {{ page.content }}

{# /.layout-content #}

      {% if page.sidebar_first %}

          {{ page.sidebar_first }}

      {% endif %}

      {% if page.sidebar_second %}

          {{ page.sidebar_second }}

      {% endif %}

  {% if page.footer %}

      {{ page.footer }}

  {% endif %}

Code of my theme.info.yml:

name: mytheme
type: theme
description: Based on classy core base theme.
core: 8.x
# Defines the base theme
base theme: classy
# Defines libraries group in which we can add css/js.
logo: logo.png
libraries:
  - mytheme/global-styling
# Regions
regions:
  header: Header
  navigation: Navigation and Menus
  system_messages_area: Area for system messages
  highlighted: Featured
  help: Help
  content: Content
  sidebar_first: First sidebar
  sidebar_second: Second sidebar
  footer: Footer

Maybe someone could help me to find the mistake, as far as I can see everything is at it's right place.

Thanks in advance

Best regards phil


texts: How do I add variables to a module's hook's existing render array and have them available as template variables?

texts:
As an example, the hook_search_execute function returns the following array:

$results[] = array(
      'link' => url('node/' . $item->sid, array('absolute' => TRUE)),
      'type' => check_plain(node_type_get_name($node)),
      'title' => $node->title,
      'user' => theme('username', array('account' => $node)),
      'date' => $node->changed,
      'node' => $node,
      'extra' => $extra,
      'score' => $item->calculated_score,
      'snippet' => search_excerpt($keys, $node->body),
    );

'link' and 'title' are required and the others are optional. However, what if I wanted to add my element to the array like 'photo' and then have that available in the $search-result.tpl.php file?

Whe I add that element to the search results array, I indeed see it when I do a dump of $variables in _preprocess_search_result(). If it's available there, then how to I make it available as <?php print $photo; ?> in search-result.tpl.php?


texts: Specific role can only change status (active/blocked) of any user

texts:
I've created a views page (holding all users information) for role ONE. Now I would like to give permission to that role he can change status (active/blocked) without editing the other fields (email, phone, username etc.) of the users.

I tried with Editable Fields module but it doesn't provide "editable formatter" in Users views field so it won't work for user's built-in field.

Is there a way to do so?


texts: Build page from content type course - use views or custom code

texts:
I'm looking to build a page like the wireframe below and need help to decide if I should use views or custom code. I haven't really used views before but looks like it could be a nice way to build up the page and add additional functionality (filtering, paging, searching etc) at a later stage.

My concern is the layout and also the links. One titled 'learn more' that links to the actual node and the other 'enrol' which is a course module link.

Should I use view or just custom code in a module?


texts: Why do I get an error about the extension.list.module service non existing?

texts:
I installed Drupal 8.5.6 and Drupal Commerce with Composer. They installed fine, but after I cleared the cache, I got this exception in a WSOD.

  Uncaught PHP Exception Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: "You have requested a non-existent service "extension.list.module"." at C:\wamp\www\drupal-8.5.6\core\lib\Drupal\Component\DependencyInjection\Container.php line 151

I searched for extension.list.module and I found this.

function system_rebuild_module_data() {
  return \Drupal::service('extension.list.module')->reset()->getList();
}

What did I do wrong to cause this problem?
What is my next step to solve this dilemma?


texts: Apply a product discount if orders are picked up

texts:
I have a Drupal Commerce site where customers get to choose whether to ship the order, or if they want to come and pick it up. Picking up is free, obviously.
This part works already, and I don't need help with.

There is an additional discount that should apply to one specific product only when the customer comes to pick up his order. There could be other products in the order besides the one specific product, and those products would not be discounted. This discount would be applied if "picking up" is specified during the check out process.
I'm having a bit of trouble getting the event/conditions right: it seems to me that no shipping method has been picked when the sell price is calculated.

Menno


texts:
I've never seen this problem in Drupal 7, but my home link contains the string <front> within its href. It's not working.

Any idea what could be happening?


texts: drupal_set_title not changing the navigation bar title

texts:
I have changed the title of a path with the drupal_set_title() function from hook_page_alter from a custom module. It works but the title in the navigation bar is still the previous one.

How can I change it too?


texts: How to make the UserProfile Info availlable on a block

texts:
I understand how to preprocess a specific block to make some variable available for that it, but what I don't understand is where I grab these variable that I want to be available in my  block.

I have the following code:

function THEME_preprocess_block(&$variables) {
    $variables['user_profile']= $user_profile;
}

$user_profile is NULL.

So in other terms what i would like is to grab all the data entered by a user during the registration and make it available within block under for instance a user_profile variable.
Is it possible at all?

Well i tried but it doesn't seem to do anything in drupal 7. Also isn't the user variable holding data only for the current loged in user ? I would like to retrieve the data of any user in order to populate the profile page with it.


texts: Keeping sensitive data from appearing in cache_form table

texts:
I'm developing a HIPAA compliant site using Drupal 7 that collects some personal sensitive data from users, and this data should be protected. I've already encrypted the data before it's stored in the database. However, the raw plain-text data remains (temporarily) in the "form_cache" table until the form cache expires (+6 hrs set from the Drupal 7 core).

If a parasitic villain were to somehow swipe a copy of the database, he wouldn't be able to read most of the data, but whomever had recently filled in a form would be compromised.

Has anyone found a relatively painless solution for keeping sensitive form field data out of the "form_cache" database table?


texts: Drupal - Save for Later using Workbench, conditional required fields

texts:
I have a node set up with a few workbench states. The first state, "Draft", should be used to allow someone to save the node without any required fields. The second state, "Submitted", should make the required fields active.
Essentially, I'd like to use default required field behavior for all states except the first "Draft". Is this something I can do programmatically with a module?


texts:
How do I give an authenticate user the permission to edit some contents before publishing it. So currently he has the permission to edit it, but he has to publish it first and then he gets the edit button. I tried going to the edit url which is node/nid/edit, but it didn't work before publishing the content.

Any help?


texts: Show all nodes with the same term, the current user is assigned to

texts:
That sounds quite simple but I can't find a hint how to do this:

I have invoices with a term reference to a "Department" vocabulary [field_invoice_department]. The user has a term reference to the same vocabulary [field_user_department].

So how should I configure my contextual filters to show all invoices assigned to the same department, the current user is assigned to?


texts: Advanced conditions in Database Abstraction Layer?

texts:
I have a module with a custom schema in it. On my cron job, I want to delete records older than 90 days. There is a date field in the table that holds a unix timestamp.

The query I want to run is DELETE FROM table WHERE UNIX_TIMESTAMP() - date > 778000, where 7780000 is the number of seconds in 90 days.

To test my query, I tried to make a select query with the same conditions:

$results = db_select('table')
->fields('table', array('field'))
->condition('UNIX_TIMESTAMP() - date', 7780000, '>')
->execute()->fetchAssoc();

However, the database AL doesn't parse the conditional the way I want it to:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'UNIX_TIMESTAMPdate' in 'where clause': SELECT ...

How do I write this conditional properly in the database AL?


texts:
I am using views 3 in D7 and have added custom field of percentage on students result listing. I want to sort on the percentage field, how can I add sort on custom field?

Thanks for your help.


texts: How to show the number of user points within the user who posted a comment?

texts:
I use the User Points module. Despite of my searches, I didn't find answer to this question:

  In the user profile of a comment, how to show the number of user points?

For example to show the number of points below the picture of the user who posted a comment.

Any suggestions?


texts: Remove the X-generator header from the response

texts:
I want to remove the CMS type and version disclosure , which Drupal is returning in the X-Generator:Drupal 8 (https://www.drupal.org) header.

I am using the following code, but it removes the x-generator header, but I can still see X-Generator:Drupal 8 (https://www.drupal.org) in the browser header response.

function xxx_page_attachments_alter(&$data, &$context1 = NULL, &$context2 = NULL) {
    foreach ($data['#attached']['html_head'] as $key => $attachment) {
        if ($attachment[1] == 'system_meta_generator') {
          unset($data['#attached']['html_head'][$key]);
        }
    }
}

How can I fix my code?


texts: How do I compare a field of a node with all nodes of a content type with rules?

texts: In Rules on Drupal 7, how do I set up a rule / ruleset so when a node is saved compares a textfield from the saved node with a textfield in all nodes of a content type and if match, not the saved node but the matching node should be unpublished?


texts: Strategy for upgrading large Drupal 6 site to D7

texts:
We are running a middle sized Drupal 6 site (about 10k nodes plus comments, 200k user accounts), which is using many additional modules like OG, Views, CCK, Messaging, Notifications, CKEditor, Syntaxhighlighter, Pathauto, Token, Captcha, User Relationships, Fivestart, XML Sitemap. In addition, there are about 10 custom modules, most of them rather simple.

We now wonder how to upgrade to D7? We evaluated the following strategies, which don't seem to work:

Start from scratch with a blank D7 installation, configure it, set up all modules as we need them and migrate the existing content. The problem is about migrating existing content. When we set up the site, we need to create things like node types, roles, taxonomies, but when we migrate the content, the IDs of those entities might differ. It seems to be a very error prone approach.
Use official upgrade procedure. If we are not mistaken, the idea of the official upgrade procedure is disable all third party modules, replace core with D7, run update procedure, upload D7 version of modules, enable them and run their update and hope everything goes well. Problem here is that a lot of the modules we are using are moved to core or work now differently, but we still reference their functions in our theme all over the place. This again is very error prone. Also, the database contains afterwards many unused tables, but it is very hard to tell if we really need them.

What other options do we have? Personally, I would prefer to follow strategy 1, but we can't figure out how to migrate content.


texts:
I'm having two customs content types in D7, one row (A) and another (B) that aggregates (via entity reference) the rows into bundles of rows (e.g. tables).

I can have up to 40 rows in a table. I'm translating manually each row in several languages.
And then I'm creating one node (lets say node 100) in English of type B aggregating the 40 rows (let's say nodes 1-40) in English, and another node 101 in French (a translation of the English  node 100) that aggregates the nodes 41-80 which are a direct translation of the 1-40 rows.

I would like while adding node 101 in French as a translation of node 100(English) to already pre-fill the node 101 to aggregate the nodes 41-80 which are in french and a one to one translation of the 1-40 English row nodes.

The translated entity reference module cannot help me in my case.

I tried to find a hook for the "add translation" to prepopulate the screen where the node 101 is being created as a translation of the node 100, and then just having to fill in 1-2 other extra fields in French and save...

Now I have to find the 41-80 references by hand, and since I'm having several languages (5 currently) the work involved is immense...

How could I achieve what I need? is there a module already written? otherwise which hook shall I use? I couldn't find an add translation hook in D7 (I believe there might be one in D8).
I just need to know which hook to use for adding a new translation, I think I can manage the rest (finding for each row the translation in the target language).

I also do not need to do anything upon editing the node 101 after it has been saved, thus I only need the hook used the first time the node 101 is being created as a translation of node 100.

Many thanks


texts: Programmatically Importing Nodes from one page to another another

texts:
I want to import node that are on one page to another programmatically.

Have tried to do by two method

$my_view_name = 'view name';
$my_display_name = 'display name';

$my_view = views_get_view($my_view_name);
if ( is_object($my_view) ) {
  $my_view->set_display($my_display_name);
  $my_view->$nid;
return $my_view

views_embed_view('Machine name', 'Page name', $nid);

Trying to get all the nodes from one page and use them in another page to do some operations. So in the first page I have written some sql queries to get a node. Now in the second page I want all those nodes without writing the sql queries. So whenever someone updates the first page, the person does not have to go to second page and update the sql queries over there


texts: Why images are not getting update in frontend when updated manual in files directory?

texts:
I'm facing issue with images cache on my d7 site. I have changed some images from files directory and theme's directory manually with same names. But I'm not able to see in front end.Old images are still there. I tried all cache clear,cron run and theme registery clear.

Please help!


texts: Connection reset on accessing admin pages

texts:
I've seen this error in several places online, but haven't really found a solution yet. I developed a site using the LAMP stack on Ubuntu, then installed a WAMP server in Win7. I copied the files, and imported the database. I can access normal pages fine (clean urls enabled), but whenever I access site/admin/*, I get a This webpage is not available The connection to www.site.com was interrupted. error.

I've already cleared the cache tables, and haven't yet found any other troubleshooting tips.

Thanks for the help

EDIT: The site is also on a vhost. I can run apps like phpmyadmin with no problems.


texts: Temporary disable ordering in Drupal Commerce

texts:
I need to temporary disable ordering until some date. So, I need to unable users to have add to cart button and unable them to go to checkout or cart.

But still I need to enable everything after this date.

How I can do this in Drupal Commerce? I'm using v7.x-1.13.


texts: How do I export fields of a content type in one website and import it into another website?

texts:
I'm trying to set up a data export through views that includes the title and a couple of fields of a content type and import it into another website. I'm using Feeds and Views Data Export and also tried Views XML but is doesn't seem to work.

How do I export fields and import them by creating nodes in another website?


texts: How to conditionally load a javascript or css?

texts:
I just got assigned to a project that requires bug fixes. It is not a bug, but the client is asking us to reduce size of our site's compressed javascript.

I found out that the compressed js' size is around 500kb, which is pretty big. I think it is that big because Drupal loads all the javascript from all the enabled modules. The problem is that there are scripts that I don't use on my homepage or other pages.

What would be a good solution or workaround for my issue? One thing I can think of is to turn off compreconditionally disable modules in my template...but...is that okay or even possible?


texts: Limit user (not role) publication of content to specific menu subtree

texts:
We have several roles. Each user is allocated to one role only.

Each user has a separate menu area - e.g.

user 1 - Profile
       - Product
       - Press Releases - release 1
                        - release 2

user 2 - Profile
       - Product
       - Press Releases - release 1
                        - release 2

What this question is NOT about:

It is not about restricting access to post by role (that is too blunt an instrument)

It is not about restricting access to view by role or individual user.

What this question IS about:

As the number of members increases, the "pick list" of menu items will become unmanageable. It also, of course, means that it is possible, for whatever reason, for users to post to someone else's area. We therefore need to lock each user's posting access to his own user account (in menu terms  [user1]  or [user2] and its subtree). Each user should not see, in the select box, menus that he cannot post to.

We need to allocate users to specific menu subtrees, presumably through either restrictions or permissions.

What does not work:

module: Menu subtree (applies to roles only)

module: Menu access (it crashed the site resulting in forced database maintenance)

module: User Permissions (it applies the standard permissions module for individual users, it does not add additional permissions.)

Node/content type: inserting a field - we can't see any way of importing the specific menu subtree that we want and, even if we could, we can't see a way of making the correct menu subtree appear for that specific user.

Any and all ideas are welcome!


texts: How do I display an alphabetical list of Webform titles in a block?

texts:
[new]
I have a series of Webforms created on my Drupal 8 site. I want to create a view that will list all of them in alphabetical order within a block. How do I create a view that will do this?
[/new]

[original]
*I want to have a block that displays an alphabetical list of all Webform titles, linked to those forms.

How do I create the view that will do this? I tried displaying anything of Content-type "Webform," but it displays a blank. If I go into Structures->Webforms, it displays all of them with no problem.*
[/original]


texts: Coding standards for custom theme functions regarding arrays passed as variables?

texts:
I have created a custom theme function and almost all the data that I pass via variables is in one big array. I have documented the keys of the array fairly well. In my first pass at the module I didn't always set every key so the template is giving me some undefined index errors. Basically is it reasonable to expect the themer to have to check isset($my_array['key']) or should I make sure $my_array['key'] is always set to an empty string?

Or perhaps I shouldn't be passing so much data in an array. Instead I should be breaking it up into multiple variables?

What is a good way of dealing with values that are optional? For example if I have an event and it has an optional address (subarray) how do I pass the information to the themer that there is no address? Should I create another key called 'has_address' for example?

I there a documented coding standard for custom theme functions regarding arrays passed as variables?


texts:
Lately I was trying to install drush for the first time. This is what I did..

Installed the drush tool manually
Extracted and renamed the tool to /Library/Drush
Gave the /Library/Drush/drush tool execution permissions.
Created an alias for drush in ~/.bashrc
Tried to bash drush by entering the alias drush, that's when I got the first problem:
Unable to load autoload.php. Drush now requires Composer in order to install its dependencies and autoload classes. Please see README.md
After lots of searching I tried way to many things:

which drush doesn't return anything.
Installing the composer (at /usr/local/bin/composer) results in this The requested package drush/drush 1.0.0 could not be found problem when executing composer global require drush/drush:dev-master

Help would be appreciated, because I don't know what I could do to make it work.

Thank you in advance, `F.


texts: Change Workbench state from Draft to Published programatically

texts:
I would like to do a bulk operation and change nodes from a state of Draft to Published. I created a new revision from a previous change, but all revisions default to Draft. Now I would like to basically just publish the new revision. (I am using the Workbench module.)

I have tried doing things like the below, but none of them seem to work:

$node->workbench_moderation['current']->published = "1";

or

$node->workbench_moderation['current']->from_state = "draft";
$node->workbench_moderation['current']->state = "published";
$node->workbench_moderation['current']->published = "1";

$node->workbench_moderation['published']->from_state = "draft";
$node->workbench_moderation['published']->state = "published";
$node->workbench_moderation['published']->published = "1";

$node->workbench_moderation['my_revision']->from_state = "draft";
$node->workbench_moderation['my_revision']->state = "published";
$node->workbench_moderation['my_revision']->published = "1";
$node->workbench_moderation['my_revision']->current = TRUE;

or

workbench_moderation_moderate($node, 'published');

I've tried saving using the below rather than node_save as well, thinking maybe the node_save triggered a new draft.

workbench_moderation_node_update($node);

I just want to simply load the node, publish the draft, then save it again.

Any idea what I am doing wrong?


texts: Filter in URL redirection is not working

texts:
There is a filter at "admin/config/search/redirect" that allows to search specific redirect entry. When I enter some value in the text-box and click on "Filter", I do not get filtered list. Instead, the filter box gets disappeared. I also tried to uninstall and re-install the latest version but the issue still persists.

This issue never occurred before and recently I am seeing this issue.


texts: Alter a form's values on submission but before validate?

texts: I'm trying to set up the user registration form to populate the username field with the email address field. Is there a way to do this without using hook_validate and having to manually do the form validation?


texts: Display different time from one field value

texts:
I have field to display event start date and time. This field uses date module's widget. I need display time of event start for different time zones. For example:

Eventname - starttime for Tallin: 05.07.2015 01:54

Eventname - starttime for Boston: 05.07.2015 09:54 (+8 Hours)

How can I add +8 hours to date field value and display result on node?


texts: Why are custom User Account fields not shown after account is saved?

texts:
Just upgraded to Drupal 7.54 and now when a user account is saved, any other users (other than admin 1 user) are unable to view or update the custom fields associated with the user account. They just see the core fields. The admin 1 user is still able to see all fields.

When the updated user account is viewed or edited by any other user than the admin 1 user (they do have 'administrator' role assigned), they only see the following fields:-

email
password
status
roles
locality

I have disabled modules that act on fields, such as Field Permissions and Conditional Fields, but still getting this behaviour.

Any ideas why this could be happening would be much appreciated!


texts:
I have a user flag that is called "follow" and am trying to setup the following views in Drupal 8.

I want to create 3 views for my website's user profile pages:

A list of users flagged by a user (for example, a "people I'm following" block)
A list of users flagging a user (for example, a "my fans" or "my followers" block)
A list of nodes from all the users that have been flagged by a user (for example, a news feed for nodes created from the users a user flagged)

This has been done before for older versions of Drupal (see View of users flagged by a user, users flagging a user, and nodes from users flagged by a user), but I can't get it to work on Drupal 8 because many of the fields are different.

Even after playing around with different values, I can only get to the point where I display the users the currently logged-in user is following, but that is not what I need.

How do I get a list of users flagged from a user account when I am watching its profile?


texts: Drupal Commerce - (free) Shipping , Pickup option , Order Comment?

texts:
I'm still facing some issues with my Drupal Commerce.

The shop is only available for authenticated users. When they want to checkout they should be able to pick a shipping option or a pickup option.

When the order total is less than 25 euro and they want to get it deliverd they will be a shipping fee of x euro's. When it is higher than 25 euro shipping will be free. When they pick the option to pick it up, it will be free.

I also want in both cases that a text fields appears so they can give a date/time that they want the package to be delivered.

I also have customer profiles enabled, but when I'm at the checkout my profile isn't getting filled in.

Any thoughts on how to achieve this?

Best regards.


texts:
I've got a field in a content type called "field_program_date" of type "Date". I'm using Drupal's format_date() function to format the date in the content template like this:

$program_date = format_date($node->field_program_date[$node->language][0]['value'], 'custom', 'F j, Y');
print $program_date;

Something is wrong because nothing gets printed out at all.


texts: Combine same city with different spelling into 1

texts:
I have a feed with information about companies. I import data from this feed to Drupal.
One of the field is City, and very often same city is spelled differently in that feed.

f.x. Copenhagen will be spelled like that:

København
København Ø
KBH
Kobenhavn

My task

I want to make a view categorised by cities and here the issue appear. I have multiple categories for the same city.

What I'm looking for

I would like to have possibility to define that 'København Ø', 'KBH' and 'Kobenhavn' are equal to 'København'.
I expect that city 'KBH' will be either converted or get an alias as København.


texts: exposed filter default values from user fields

texts:
How can i set the default value of exposed filter for a view with the current logged in user profile checkboxes?

There can be multiple choices.

Thank you


texts:
I am using Drupal 7, along with a Bootstrap 3 (simplecorp) and I am attempting to create a site tour using the Bootstrap Tour Module, which of course has no documentation beyond the project page.

I successfully installed all of the dependencies for the Bootstrap Tour Module (bootstrap.css, bootstrap.tooltip.js, bootstrap.popover.js) and I am successfully able to manually implement both tooltips and popovers flawlessly. I also host the bootstrap tour library locally, not via cdnjs.

I initialize the tooltips and popovers using the code below (NOTE: the project page for Bootstrap Tour doesn't indicate if the popovers need to be initialized or if the module itself performs that task (I have tested the Bootstrap Tour module with and without my own initialization code.)

(function($) {
$(function() {
  $(document).tooltip({ selector: '[data-toggle="tooltip"]' });
  $(document).popover({ selector: '[data-toggle="popover"]' });
});
})(jQuery);

Within my stylesheet, I created the following css selectors:

a#teststep1 { font-weight:bold;color:red;}
a#teststep2 { font-weight:bold;color:blue;}
a#teststep3 { font-weight:bold;color:green;}

Then I configured the Bootstrap Tour Module to create a " Test_Tour " with two steps using a#teststep1 and a#teststep2 as css selectors for each step.... a#teststep3 above is to manually test the operation of my popovers.

As instructed by the project page instructions, I set the tour to automatically run using " ?tour=Test_Tour " at end of my url /path.

I link to myPath/?tour=Test_Tour from my homepage, but when I land on the test page that has page html elements containing the css selector id(s) above, nothing happens, no popovers, no tour starts.

Am I configuring something wrong? Or is there a bug and can someone show me how to manually (programmatically) start the tour?


texts: How to include a field's suffix when using its Token?

texts:
My user accounts have an integer field Visits with the suffix visit|visits. It is very handy to let Drupal automatically decide which suffix is appropriate. I would now like to use this field in a status message with the simple Rules action Show a message on the site. Unfortunately, when I set the message to You currently have [site:current-user:field-visits]., the suffix is not included, only the integer appears.

Is there a way to solve this? I would like to prevent a cumbersome Rule with an extra check on the value of Visits and an according adaptation of the message.


texts:
I'm using Drupal 7.38 and I'm trying to print the creation date of a node in 3 separate divs, to be able to format it appart, so I created the following on the node.tpl.php:

<?php print $date; ?>

<?php print format_date($node->created, 'custom' , 'M'); ?>

<?php print format_date($node->created, 'custom' , 't'); ?>

<?php print format_date($node->created, 'custom' , 'Y'); ?>

But, when I go to the result page I've got this:

MAR, 07/28/2015 - 16:20

JUL

31

2015

So, why is the day showing the incorrect date???

Thanks.


texts: Views Row style Node heading between different dates

texts:
I need a view that display full nodes. So I have set my row style to Node. SO I have.

Node 1
Node 2
Node 3

What I want is

11/05/2010

Node 1

10/05/2010

Node 2
Node 3

I want to place a heading between each group of nodes on a certain date. Can this be done?


texts: How to add a modal which then opens a ctools modal?

texts:
I am trying to set up a modal that opens a ctools modal from inside it. IOW the user sees the first modal, clicks on a button inside that modal and it opens a second modal on top of the first modal. Then when the second modal's work is done, it closes and user can still see the first modal.

I understand that ctools is limited to one modal at a time according to this DO issue. My second modal is a ctools modal. I tried to set up a jQuery modal and a bootstrap modal as the first modal, but closing the second ctools modal always closes my first modal.

Any pointers as to where I can find a workable solution to this?


texts:
The User Points module doesn't have migrate integration yet.
Looking at the API I can probably use userpoints_service_add to assign "starting point" values for each user in a batch script.

Is there an option to update the "starting point" value for a user when I go live? Or do I have to calculate the difference and just add an adjustment?


texts: Is there any module that let (selected) users (/roles?) see the Administration pages in read-only mode?

texts:
Is there a module out there which lets us assign a permission to a role which lets a user look at the site from the perspective of an Administrator, or better, from within the permissions of any selected other role; in a view-only/read-only mode?

That would be useful to let people explore Drupal on sites with existing setup and content without having to create/clone and maintain example sites for such purposes.

(Click around in any (admin/content management) page related to the given "read-only role" without the ability to make/save changes.)


texts:
Whith a custom module, I'd like to update some nodes uid whenever a content type is updated.
I triple checked, and my database update function is called, as "changed" field is updated each time, and I send myself a mail to check that the data passed is correct.

I don't know how to call the equivalent of mysql_query() or die(), and don't manage to debug that.

I have only a notice:

  Undefined index: #language dans locale_field_node_form_submit().

function zen_custom_form_alter(&$form, &$form_state, $form_id) {
  global $user;
  switch($form_id){
    case 'lieux_de_pratique_node_form':
      if (in_array('Admin dojos', array_values($user->roles))) {
        // some stuff
        $form['#submit'][]='set_dojos_manager';
        // ...
      }
      // ...
  }
  // ...
}

function set_dojos_manager($form, &$form_state) {
  $dojo_editeur = $form['field_dojo_editeur_web']['und'][0]['uid']['#default_value'];
  $dojo = $form['nid']['#value'];
  $uid_updated = db_update('node')
    ->fields(array(
      'uid' => $dojo_editeur,
    ))
    ->condition('nid', $dojo)
    ->execute();

    mail('my_email', 'test', $dojo_editeur . ' / ' . $dojo);
  }
}


texts:
I'm trying to migrate rows from a Joomla K2 table.

The issue happens when I add the 'fulltext' field to the field list on my select inside my migration class. This field is a medium text field with html inside. The error only happens when I put this field in the query.

The error is like so:

  Migration failed with source plugin exception: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fulltext FROM j3_k2_items n WHERE (catid IN ('43', '45', '46', '51', '68', '7' at line 1,

I have set $this->source = new MigrateSourceSQL($query, array(), NULL, array('map_joinable' => FALSE)); but it didn't help.

Any ideas? I don't know what to do.


texts: Drupal files on NFS, performance degredation

texts:
Many people use NFS to keep the sites/default/files directory outside of the normal webroot of a Drupal install.

However, I'm running the entire Drupal install over NFS.

When the site has not been accessed in some time, there's a solid 15-20 seconds of delay before a page loads. After that everything is fine. I have Drupal's page caching turned off for these tests to provide consistent results.

Initially I found that PHP's realpath_cache needed to be adjusted, because the default of 16k is not enough to handle all of paths Drupal loads when bootstrapping. I have this raised to 128k, and I see now that the utilized cache size goes up to around 40-50kb (after browsing around the site all over to "trigger" more file loads).

However, that does not seem to affect performance at all. Those cache entries expire anyway and will eventually PHP will need to hit the FS again.

I also have the built in "poor mans cron" disabled, so it's not related to Drupal running a bunch of cron tasks on that page load.

I suspect it may be related to NFS.

Is anyone else running a Drupal install completely over NFS, or have you in the past and come to any conclusions that may help?


texts:
I'm looking for a way to delete about 1300 taxonomy terms (of 5250 in total) and their association with nodes.
I firstly thought to delete the content of these tables:

taxonomy_index
taxonomy_term_data
taxonomy_ter_field_data
taxonomy_term_hierarchy
node__field_tags
node_revision__field_tag

Is this sufficient?
Is there a better way to do it, without Drush, which I cannot install?

EDIT :

I'm trying to do it programmaticaly, but I have an error

Error: Call to undefined function field_attach_delete() in delete_taxonomy_terms() (line 42 of /var/www/html/d8/delete_tags.php).

Trying to add call to module_load_include() but still get the same error.
I put the file at the root of my Drupal installation (../mydrupal/delete_tags.php).

<?php
error_reporting(E_ALL);
date_default_timezone_set('Europe/Paris');

define('DRUPAL_DIR', $_SERVER["DOCUMENT_ROOT"]); //__DIR__ ); //.'/../drupal');

use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

$autoloader = require_once 'autoload.php';
$kernel = new DrupalKernel('prod', $autoloader);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

/**
 * Deletes taxonomy terms.
 *
 * @param array $tids
 *   Array of taxonomy term IDs.
 */

$tids = [830];

delete_taxonomy_terms($tids);

function delete_taxonomy_terms($tids) {

module_load_include("inc", "field", "field.attach");

  db_delete('taxonomy_term_data')
    ->condition('tid', $tids, 'IN')
    ->execute();
  db_delete('taxonomy_term_hierarchy')
    ->condition('tid', $tids, 'IN')
    ->execute();

  $terms = taxonomy_term_load_multiple($tids);

  foreach ($terms as $term) {
    field_attach_delete('taxonomy_term', $term);
    module_invoke_all('taxonomy_term_delete', $term);
    module_invoke_all('entity_delete', $term, 'taxonomy_term');
  }

  // Reset static cache after all terms deleted.
  taxonomy_terms_static_reset();
}


texts: What modules are required to make a seating chart website?

texts: I'm currently working on a site that wants to sell theater seating by section by clicking on a map overview of the seats like the one below. What drupal 7 modules are there or recipes that can be done to create this similar functionality?


texts: I have no fields available for sorting with Search API sorts module

texts:
This question is similar to another question I had, but now in a different context.  My previous question was: Search text box for Search API + Database + Search Views + Facets API + Facets Bonus

That option worked, except I can't use Current Search to reset the search box.  I can reset the filters, but not search box.  I also can't find an option to allow the user to sort the fields.  I installed the Search API Sort module, but was unable to get any fields to be available.  I kept hosing my index trying to enable/disable fields, and couldn't figure it out.

My question is how can I use a search form box with Search API + Views that will let me reset the search box with Current Search box, and, how can I have a sort box that will let the visitor select the field to sort by?

My view is rendering nodes via Display Suite view modes.  Right now, I am using exposed search and sort filters, but of course, they are grouped in one block.  The whole point of my having to use the Search API was to provide filters and decouple my search and sort filters from each other.  My sort option will be placed at the top right of the UI, and the sort in the left sidebar.

EDIT: Using Search API Sorts, per giga's advice below, I went back and tried to get my fields sortable.  I stripped down fields and still no luck getting them sortable.  It's a Commerce site, and I'm using the Commerce Search API, which gives me a Product Display index.  I originally move fields of content out of the index, so I'm only left with my product display and product fields.

My indexed fields right now are (field, type, boost):

Content type -- String -- 1.0
 Title -- String -- 1.0
 Date created -- Date -- 1.0
 Date changed -- Date -- 1.0
 Product Tags -- Taxonomy term
 Product Ref -- Commerce Product
 Item Type -- Taxonomy term
 Weight Sort -- Integer -- 1.0
 Product Ref >> Price >> Amount (decimal)(Min) -- Decimal -- 1.0
 Product Ref >> Price >> Amount (decimal)(Max) -- Decimal -- 1.0
 Title (Fulltext)  [search_api_aggregation_1] -- Fulltext -- 1.0
 Product Tags (Fulltext) [search_api_aggregation_4] -- Fulltext - 1.0
 Item Type name (Fulltext) [search_api_aggregation_5] -- Fulltext - 1.0
 Product tags >> Name -- String -- 1.0
 Proudct Ref >> Serving Size -- String -- 1.0
 Product Ref >> Portion Size -- Fulltext -- 1.0
 Item Type >> Name -- String -- 1.0
 Product Ref >> Price >> Amount (decimal) -- Decimal -- 1.0

The only fields I'm trying to index are Title, Min and Max price, and the Weight Sort as the initial default sort.  None of them are showing up in my table of sortable fields under the Sorts tab.


texts: Code inside attached behavior not executed

texts:
I nested jQuery code inside a behavior. I don't understand, why the code does not execute. I would be appleased if you could give me a hint on what I probably did wrong.

My code:

   $(function (){
    Drupal.behaviors.block_sidebar_register_buttons = {
        attach: function (context, settings) {
            var element = $('#block_register_buttons');
            //...
        }
    };
});