texts: Composer keeps overwriting .htaccess (and other files) every time I do anything

texts:
Every time I try to update anything using Composer, it overwrites a load of files. One of the files it overwrites is .htaccess, which I have customised, so I have to keep patching it all the time. Here's an example (below) of it doing this even when package I asked to update didn't need updating. I'm guessing it's because I used the "drupal/core-composer-scaffold" package to create the site. I did that because I was following these instructions: https://www.drupal.org/docs/develop/using-composer/using-composer-to-install-drupal-and-manage-dependencies#composer-from-scratch.

What am I doing wrong, to make it keep scaffolding (if that's the word for it) repeatedly? Thanks.

~/sites/default$ composer update drupal/security_review
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Package academicpuma/citeproc-php is abandoned, you should avoid using it. Use seboettg/citeproc-php instead.
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Package technosophos/LibRIS is abandoned, you should avoid using it. No replacement was suggested.
Package zendframework/zend-diactoros is abandoned, you should avoid using it. Use laminas/laminas-diactoros instead.
Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead.
Package zendframework/zend-feed is abandoned, you should avoid using it. Use laminas/laminas-feed instead.
Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead.
Writing lock file
Generating autoload files
Scaffolding files for drupal/core:
  - Copy [project-root]/.editorconfig from assets/scaffold/files/editorconfig
  - Copy [project-root]/.gitattributes from assets/scaffold/files/gitattributes
  - Copy [web-root]/.csslintrc from assets/scaffold/files/csslintrc
  - Copy [web-root]/.eslintignore from assets/scaffold/files/eslintignore
  - Copy [web-root]/.eslintrc.json from assets/scaffold/files/eslintrc.json
  - Copy [web-root]/.ht.router.php from assets/scaffold/files/ht.router.php
  - Copy [web-root]/.htaccess from assets/scaffold/files/htaccess
  - Copy [web-root]/example.gitignore from assets/scaffold/files/example.gitignore
  - Copy [web-root]/index.php from assets/scaffold/files/index.php
  - Copy [web-root]/INSTALL.txt from assets/scaffold/files/drupal.INSTALL.txt
  - Copy [web-root]/README.txt from assets/scaffold/files/drupal.README.txt
  - Copy [web-root]/robots.txt from assets/scaffold/files/robots.txt
  - Copy [web-root]/update.php from assets/scaffold/files/update.php
  - Copy [web-root]/web.config from assets/scaffold/files/web.config
  - Copy [web-root]/sites/README.txt from assets/scaffold/files/sites.README.txt
  - Copy [web-root]/sites/development.services.yml from assets/scaffold/files/development.services.yml
  - Copy [web-root]/sites/example.settings.local.php from assets/scaffold/files/example.settings.local.php
  - Copy [web-root]/sites/example.sites.php from assets/scaffold/files/example.sites.php


texts:
I'm using Drupal 7.  Right now, I have a main-menu navigation and Language switcher that exists in my website header.  I placed them there by going to the CMS>Structure>Blocks and hten dragging the blocks into the header region.

How do I programmatically situate these block in the header?


texts: How can I use the core link field widget with title and URL in a custom form?

texts:
I want to add a link field to my custom form.

Below is the code that I have been trying to use but no success. So can anyone let me know how to use core link field in a custom form in Drupal8?

The below code works for Drupal7 but not for Drupal8. I have also tried using #type => 'link' in the below code.

$form['cta'] = [
  '#type' => 'link_field',
  '#field_name' => 'link_field',
  '#field_parents' => array(),
  '#delta' => 0,
];
return $form;


texts: Do I still need to add verifications if the site has been verified through Google Analytics?

texts: I'm working my way through the items in the SEO Checklist module.  One of them is the Site Verification module. We have already verified our domain name through a Google Analytics account.  Do I still need to add a verification using the Site Verification module, or is it redundant at this point?


texts: How to access variables in a fieldset with variable_get

texts:
function bi_mx_enhancement_form($form, &$form_state) {
    $form['bi_mx_enhancement_government_ws'] = [
        '#type' => 'fieldset',
        '#title' => t('Government Web Service Settings'),
        '#tree' => true,
        '#collapsible' => true,
    ];
    $form['bi_mx_enhancement_government_ws']['base_url'] = [
        '#type' => 'textfield',
        '#title' => t('Base URL'),
        '#default_value' => variable_get('base_url', 'https://'),
        '#description' => t('The base URL of the Government Web Service for Medic Validation. NOTE: Do not add a trailing slash.'),
        '#required' => true,
    ];

    return system_settings_form($form);
}

Variable base_url does not get saved, I always get the default value in the form.

I took a look at Drush, and it is like this:

bi_mx_enhancement_government_ws:
  base_url: 'http://52.203.204.11:8282/api/medicos'


texts: Editor role can only manage right region of page, no other region allowed

texts:
In drupal 7, I have a page that has 3 regions: header, right sidebar and footer.   I also have 2 user roles: Admin and Editor.   An admin should be able to create content, edit content, publish content, and manage blocks in all three regions.  An editor should be able to create content, edit content, NOT publish content and only manage blocks in the right sidebar of pages he created and edited.

I used the revisioning module to prevent editors from publishing content.  So now Admin's must review editor changes before publishing.  However, how do I restrict and editor's ability to managing ONLY the right sidebar of ONLY the pages he created/editted?


texts:
I have created several content types and using views I have created blocks that take the uid as an argument and displays content that that author has created. So far so good.

What I want to do now is create a module that displays all these blocks in a given area,

I have the HTML ready and I can create a page that passes the markup back to drupal and display that, what I would like to do is populate those areas with the given block.

so for example. If I have a page called:

www.example.com/displayMyContent/58 (where 58 is the user ID)

the HTMl of the page would be online these lines:

<?php
$uid = args(2);
$markup = "

 ". drupal_call_to_render_block("MyVideosBlock", $uid). "
";

?>

what would be the function to insert the given block into the given section and how would I pass the $uid to the block so that only the authors content would be displayed?

Also there are reasons why i am not using the blcok functions in admin mainly because there will be other blocks added on the page and I need control of where the blocks will be placed


texts: I have a view with an exposed form for searching titles/bodies of content. Is there a way I can display "Showing results for: $keywords" with the values that the user enters?


texts: Prevent enabling module if private streamwrapper not set

texts:
I need to create a subdirectory in the private files folder. I can check if the folder is available with variable_get('file_private_path', FALSE) in hook_install or hook_enable.

But how can I prevent my module from getting enabled? And preferably, I want hook_uninstall to run in case this happens so that the user can first setup the private files directory and then try again.

I played with module_disable and drupal_uninstall_modules, but (understandably) those don't seem to work if they target the module they are called from. I'm using Drupal 7.


texts: I'm using rules module to run my custom php code, but what i need is the number of the selected nodes return by VBO. How can i do this?


texts: Is there a way to tell composer about manually updated modules?

texts:
I am working on a drupal 8 site and tend to update some modules:

I run the composer outdated 'drupal/*' command and it shows me the list of modules need update.
Running composer update drupal/module_name --with-dependencies end up with discard changes output.
So I choose to update the module from admin interface, after updating db changes, the status report not shows any update anymore but running outdated command in composer list the modules again.

This means I somehow need to announce to composer about this manual update (I think by changing composer.json and/or composer.lock, but I did not find the flow of it, yet.


texts: Will image styles be applied when they do not logically apply?

texts:
I have a set of biography images in the site I'm working on, and I have an image style that will enforce the correct size for these.   Of course I'd rather not have them resized if they don't need it, so I'm wondering if the resize & crop effect will be skipped if the image is already the perfect size.

In other words, if the image is 130 x 170, and the effect of the image style would be to resize & crop it to make it 130 x 170, will the Image module be clever enough to skip that effect and leave it alone (so as not to degrade quality)?

If it will process the image anyway, then obviously I'll want to simply display the original image.  It would be very useful if the module were clever enough to know when not to run, so the image style could be there as a failsafe in case some future content editor is too lazy to crop the images beforehand.


texts: Views displaying content with link to en-US when it shouldn't

texts:
We have a site that has all its content translated for American English. Detection is through the URL via en-US/ been added to the paths.

I have a number of views returning content from specific content types and a couple of them are returning content with links to the en-US/ version and for the life of me cannot figure out whats causing this.

The views have their rendering language set to Rendering Language:
Content language of view row.

I also have a filter on this view to ensure that I dont get duplicates showing, without it the view returns results containing the content from both "languages". Filter is Translation language: (is one of) Interface text language selected for page

What I have tried:

Turned view caching off
Tried changing to different combinations
of the Rendering language and Translation Language filter.
Removing Filter
Running drush cr all after every change

The only way I can get the view to behave is by forcing the Rendering Language to English but this then is no good when you are wanting the en-US version.

Is there something else I haven't tried that may be an answer to my woes ?

Additional info as requested by Mario Steinitz in comments:

Two languages:
 1. en (Standard british english) which is default
 2. en-US translation (For American spellings of words, e.g. Inquire instead of Enquire)

By default when accessing the site with out the en-US prefix in the domain it will display the default British english. Adding en-US to the url should output the American translations of content.

Currently views I have are outputing the American version of any results, even when you are on the default language. All other content is fine, this is affecting my views only.

Also, $_SERVER['HTTP_ACCEPT_LANGUAGE'] is ALWAYS set to be en-US locale which I think is where the problem is but I am unsure what is forcing this.

So my questions are:

Is there something Drupal is doing that is changing the HTTP_ACCEPT_LANGUAGE variable to always be en-US (Even if you are on default language (no en-US in path)) and would this affect the output of the view results ?
If HTTP_ACCEPT_LANGUAGE wouldn't affect the views is there something else that could?


texts:
I have node_access hook in a module. I tried to prevent anonymous user from access unpublished node like the following:

function MODULE_NAME_node_access($node, $op, $account) {
   global $user;
if ($op == 'view' && $node->status == 0 ){
     return NODE_ACCESS_DENY;
  }
}

This is working fine and redirect to access denied custom page. However, I would like it to be redirect to the custom 404 not found page. i.e the http response to be 404. I tried to find any replacement of NODE_ACCESS_DENY but I could not able to find anything.

I tried to use drupal_not_found() but it generates Server Error on the server.

Also, I would like to know, if there a method or property of the $user object that determine if the user is anonymous user or not. I find that there is user_is_anonymous() but I could not know how to use it in this context.


texts: Entity Reference- How do I display more than one view mode?

texts: I am using entity reference to display some nodes. In manage display, I am rendering my entity reference content with teaser view mode. However, I need to display the first node different. I need the first one with a picture and the other ones I just need the date, text and a link. Something like  in the picture.


texts:
I'm developing a website which uses MongoDB drupal module, I also need ApacheSolr as search engine, I googled about the Compatibility of ApacheSolr and MondoDB but found nothing.
Can I use Mongo as database and ApacheSolr as search engine (with search api) together?


texts: Some Drupal 7.34 administrator actons are not working well?

texts:
I installed Drupal 7.34 and I saw some thing very strange when doing some administrative actions.

As an example when I'm trying to update a module like this image :

When I click in Continue it just reloads the page and nothing else is happened.

Another problem is with disabling modules. When I'm trying to disable a few modules, I uncheck them and click Save Configurations but when I check modules page they are still checked and are not disabled!

I've seen the same problem in other parts of website too. for example when I translate a string and click Save, the string is not translated.


texts: Modify a variable before it saves to database

texts:
I have a user profile form.  I'm having trouble modifying a variable before it saves to the database.  I have these hooks in my template.php but the value going into my database is still the same value that was submitted in the form post.

function mytheme_user_profile_form_presave()
{
  if($form['#id'] == 'user-profile-form') {
    if($_POST)
    {
            $ec = 'fooo';
            $form['field_last_name']['und'][0]['value']['#default_value'] = $ec;
            $form['field_last_name']['und'][0]['value']['#entity']->field_last_name['und'][0]['value'] = $ec;
            $form['field_last_name']['und'][0]['value']['#entity']->field_last_name['und'][0]['safe_value'] = $ec;
            $form['field_last_name']['und'][0]['#entity']->field_last_name['und'][0]['value'] = $ec;
            $form['field_last_name']['und'][0]['#entity']->field_last_name['und'][0]['safe_value'] = $ec;
            form_set_value($form['field_last_name'],array('und' => array(0 => array('value' => $foo))),$form_state);

    }
  }
    return '';
}

function mytheme_preprocess_user_profile_form()
{
  if($form['#id'] == 'user-profile-form') {
    if($_POST)
    {
            $ec = 'fooo';
            $form['field_last_name']['und'][0]['value']['#default_value'] = $ec;
            $form['field_last_name']['und'][0]['value']['#entity']->field_last_name['und'][0]['value'] = $ec;
            $form['field_last_name']['und'][0]['value']['#entity']->field_last_name['und'][0]['safe_value'] = $ec;
            $form['field_last_name']['und'][0]['#entity']->field_last_name['und'][0]['value'] = $ec;
            $form['field_last_name']['und'][0]['#entity']->field_last_name['und'][0]['safe_value'] = $ec;
            form_set_value($form['field_last_name'],array('und' => array(0 => array('value' => $foo))),$form_state);

    }
  }
    return '';
}

function mytheme_user_profile_form_validate()
{
  if($form['#id'] == 'user-profile-form') {
    if($_POST)
    {
            $ec = 'fooo';
            $form['field_last_name']['und'][0]['value']['#default_value'] = $ec;
            $form['field_last_name']['und'][0]['value']['#entity']->field_last_name['und'][0]['value'] = $ec;
            $form['field_last_name']['und'][0]['value']['#entity']->field_last_name['und'][0]['safe_value'] = $ec;
            $form['field_last_name']['und'][0]['#entity']->field_last_name['und'][0]['value'] = $ec;
            $form['field_last_name']['und'][0]['#entity']->field_last_name['und'][0]['safe_value'] = $ec;
            form_set_value($form['field_last_name'],array('und' => array(0 => array('value' => $foo))),$form_state);

    }
  }
    return '';
}

what am i doing wrong?

UPDATE

Ok, I added this in my template.php

function mytheme_form_alter(&$form, &$form_state, $form_id) {
  if($form['#id'] == 'user-profile-form') {
    $form['#validate'][] = 'mymodule_foo_data';
  }
}

Then I added this to mymodule.module

function mymodule_foo_data(&$form,&$form_state)
{

        $form['field_last_name']['und'][0]['value'] = 'foo';
}

The function mymodule_foo_data gets fired on save.  But the value foo doesn't get written to my database.  Instead, the value that's in the $_POST array is what gets written to the database.  how do I get foo into the databasE?


texts: Why is menu item for custom module not showing?

texts:
I'm new to Drupal and about to write my first custom module ("configurator") with help of the drupal documentation.

I've implemented the menu hook:

function configurator_menu()
{
    $items = array();
    $items['configurator'] = array(
        'title' => 'Configurator',
        'page callback' => 'configurator_init',
        'access callback' => TRUE,
        'type' => MENU_CALLBACK,
     );
     return $items;
}

function configurator_init()
{
    return "<p> Hello World </p>";
}

At "Administer > Site Building > Modules" the module is shown and activated. Cache has been cleared, but somehow the menu item for my "configurator" module is not showing up.

Why?


texts: Custom exposed filter for year in date field with ajax

texts:
I am trying to create a custom exposed filter which would be a select field with years (2015-2025).
This would filter the result with the year of the date they are created.
I followed this tutorial https://www.flocondetoile.fr/blog/filter-content-year-views-drupal-8
But here there is no solution for ajax submission, so the page does not refresh and the filter does not apply.

Currently I have this year as a contextual filter and the form field in the hook_form_views_exposed_form_alter():

$options = [
    'all' => t('- All -'),
    '2015' => '2015',
    '2016' => '2016',
    '2017' => '2017',
    '2018' => '2018',
    '2019' => '2019',
    '2020' => '2020',
    '2021' => '2021',
    '2022' => '2022',
    '2023' => '2023',
    '2024' => '2024',
    '2025' => '2025',
  ];

  $form['year'] = [
    '#title' => t('By year'),
    '#type' => 'select',
    '#options' => $options,
    '#size' => NULL,
    '#default_value' => 'all',
  ];

Is there a possibility for the filter to work with ajax submission?


texts: Adding attributes with hook_node_view_alter

texts:
I'm trying to modify the "Add new comment" link in certain nodes, and for this I'm using hook_node_view_alter like this:

function example_node_view_alter(&$build) {
//    $build['links']['comment']['#links']['comment-add']['attributes']['class'] = 'nice small radius blue button';
      $build['links']['comment']['#links']['comment-add']['title'] = t('Add a review');
}

The commented line is causing trouble though,... since the array doesn't have a 'class' attribute. If I just add it to the array like that, every time I clic on the "add a review" link, the website isn't rendered properly... so how can I add it without ruining everyhting else?


texts:
I am following the instructions at https://docs.drush.org/en/7.x/install/

My PHP version is PHP 7.0.33-0ubuntu0.16.04.1.

When I run this command...

composer global require drush/drush:dev-master

...I get this output...

Problem 1
    - Installation request for drush/drush dev-master -> satisfiable by drush/drush[dev-master].
    - drush/drush dev-master requires consolidation/site-process ^2.0.0-beta3 -> satisfiable by consolidation/site-process[2.0.0-beta3] but these conflict with your requirements or minimum-stability.

However, I have minimum stability set to dev...

"minimum-stability": "dev",

So why is the output telling me that beta code doesn't meet the "dev" stability level?


texts: Override theme function for menu callback

texts:
What I am looking for: I have a custom node link which, when clicked, displays a custom HTML content (option selections) in a lightbox. I need to pass an argument to the HTML content to generate the HTML code.

What I did: I created a menu callback with one argument, and a template file for this "page" that does the processing and display the HTML content in the lightbox. I guess it's a little bit overkill and it takes quite some time for the whole render to be computed.

Would it be better (faster) to override the render with theme function? If that's the preferred solution, how to do? Create a my_theme_page() function in template.php file?

Or can I generate the HTML in the callback function?

Any help would be appreciated.


texts: access node field variables in theming view-field

texts: How can I access a filed value of the node that I don't want to display in the view, is there any way to pass the field variable in $fields using view but not include it in display, I'm just want to use this field for checking a condition.


texts:
I have applied memcache by via instructions from this page to our production server. The difference in numbers don't look stellar.

My question: Did I configure memcache improperly? Can I increase the CACHESIZE to perhaps get a better overall performance?

Settings.php

In settings.php, I've included this bit of text as recommend by the README.txt inside the memcache module.

/**************************************************
 * MEMCACHE
 **************************************************/
$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['lock_inc'] = 'sites/all/modules/memcache/memcache-lock.inc';
$conf['memcache_stampede_protection'] = TRUE;
$conf['cache_default_class'] = 'MemCacheDrupal';

// The 'cache_form' bin must be assigned to non-volatile storage.
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

// Don't bootstrap the database when serving pages from the cache.
$conf['page_cache_without_database'] = TRUE;
$conf['page_cache_invoke_hooks'] = FALSE;

$conf['memcache_servers'] = array('server:11211' => 'default');

Memcache Conf

The memcache system conf has been left it's default:

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""

Benchmarks

I ran a battery of apache benchmark tests and these are the numbers

With memcache active

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    1   0.4      1       4
Processing:     4   50   8.6     52      62
Waiting:        4   50   8.6     52      62
Total:          7   51   8.2     53      63

Without / Before / Baseline

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    1   0.5      1       4
Processing:     3   50   8.4     52      61
Waiting:        3   50   8.4     52      60
Total:          7   51   7.9     53      62


texts: Ajax webform do submit without ajax when it is loaded via ajax

texts:
I'm trying to load a node containing an ajax webform and add it to an existing div, this works fine, but when I click to next step, the form is submitted to the webform action path.

Any idea?

Thanks!

          $.ajax({
            url: '/path/to/my/node/with/webform'
            success: function (data) {
              // Add html to existing container.
              $(data).appendTo('body');
            }
          });


texts: Combining 2 drupal 7 sites - how to move modules?

texts:
I am combining 2 drupal sites in to one, was not really my decision. What things I should be careful of and what pitfalls to avaoid?

List of things I will be combining

Content Types - Bundle copy module
View - Export functionality
Content Data - Feeds Importer
Blocks - Block Import Export module
Modules - I am going to install the standard modules from drupal projects and copy over any custom modules. How can I move the modules configurations?
Menus - How to move over the menus settings?
Users - Do not need to be migrated

There is not much taxonomy on the other site.
Anything else I am missing ?
Any suggestions on the sequence to do this?

Thanks.


texts: Can I program a check on a save on an admin page?

texts:
Take for example the CKEditor admin page, where at file browser settings you can choose IMCE at file browser type. Then  you click Save.

Can you program this? I mean in PHP; because I could also find out which SQL query is done, and use drush sql-query, but that is not what I mean. I want to program it because I have a multisite with about 70 sites.

Thanks,

Eric J.


texts: Is there a way to order by COUNT('column') without returning an integer?

texts:
I'm trying to make this query work correctly in Drupal 8. I want to return the events in order of most frequently occurring in the database table (Users vote for the event they prefer). But I only want to display the event name and not the number of times someone has voted. Here is my SQL query:

SELECT `event`
    FROM     `eventform`
    GROUP BY `event`
    ORDER BY COUNT(`event`) DESC

In SQL pro it returns correctly the following data.

Brewery
Conference
Concert
Dinner
Musical

With Drupal, I am getting the following data.

Brewery
10
Conference
8
Concert
7
Dinner
6
Musical
4

How can I make the following code return only the event names?

$query = \Drupal::database()->select('eventform', 'm');
$query->fields('m', ['event']);
// It doesn't return the correct order unless I use
$query->addExpression('COUNT(event)', 'count');
$query->groupBy('event');
// I want something like orderBy(COUNT('event'),'DESC'), but this
// returns incorrect ranking;
$query->orderBy('count','DESC');
$votes = $query->execute()->fetchAll();

Here is how I'm rendering:

 $rankings=array();
  foreach($votes as $key){
    foreach ($key as $value) {
      $rankings[] = $value;
    }
  }

    $build = [
      'rankings' => [
        'rankings_child_element' => [
          '#theme' => 'item_list',
          '#list_type' => 'ol',
          '#items' => $rankings,
        ]
      ],
      '#empty' => t('No votes found'),
    ];
    return $build;

}
}


texts: Error in Submit handler for custom node add form

texts:
Trying to theme my own node add form with hook_theme() in my own module. In the *.tpl.php page for the node add form, submit button is not actually adding the content to database.

Issue: Why is "php print render($buttons);" not adding the right submit handler that actually adds a node (Content) entry.

In my stories.module file:

 /* Implements hook_theme().
 */
/*
function stories_theme($existing, $type, $theme, $path){
  return array(
    'stories_node_form' => array(
      'render element' => 'form',
      'template' => 'stories-node-form',
      'path' => drupal_get_path('module', 'stories'),
    ),
  );
}
*/

function template_preprocess_stories_node_form(&$variables){

    $variables['sidebar'] = array();   // Put taxonomy fields in sidebar.

    $variables['sidebar'][] = $variables['form']['field_tags'];
    hide($variables['form']['field_tags']);

    // Extract the form buttons, and put them in independent variable.
    $variables['buttons'] = $variables['form']['actions'];
    //hide($variables['form']['actions']);
 }

In stories-node-form.tpl.php:

    <?php //print drupal_render_children($form); ?>

        <?php print render($form['field_nicname']); ?>

        <?php print render($form['field_email']); ?>

        <?php print render($form['title']); ?>

        <?php print render($form['field_category']);  ?>

<?php print render($form['field_share_your_story']);        ?>

<?php print render($buttons); ?>


texts:
Our website have a large Url when paste as a link, now we want to short it.

for example

http://www.awene.com/article/له%E2%80%8C-ژێرناونیشانی-ئه%E2%80%8Cو-شته%E2%80%8C-چیه%E2%80%8C-كه%E2%80%8C-ره%E2%80%8Cوشته%E2%80%8C؟-كۆرێك-بۆ-ئازاد-حه%E2%80%8Cمه%E2%80%8C-ساز-ده%E2%80%8Cكرێتوك


texts: Views duplicates cause of linking two content types "Author" and "publications"

texts:
I have created an "author" content type, with, for the moment, these fields:

First Name:
Second Name:
e-mail address:

I also created "publications" content type with field reference to the author's names from "author" content type.
Now, I am trying to get an "authors" view which shows author's name, email address, and, I want to show the list of documents for each author.

Screenshot http://drupalfr.org/sites/default/files/Untitled-1.jpg

So, I linked the author's node title to "content referencing content from field_publication_author" with a Link this field to the original piece of content through a relationship

When I did this, I got duplicate entries for author name when there is more than one document referenced to this author.
I have tried to change query settings, but without success.
When i aggregate the field that shows the documents, I have only one result instead of getting a list of documents.

Could anyone help me ?


texts: How to display article from category and show it in block

texts:
I have created a content type which has some fields, and I want these fields to be displayed as a block.

I need to display some article like 5 articles from category called sport news only.

how can i do that in drupal 7


texts: URL paths taxonomyterm/pagename instead of content/pagename

texts:
I've set up a vocabulary with some terms. I've created some new pages and tagged with the newly created terms. However, the node urls are in the form of content/pagename and I would like them to be taxonomyterm/pagename instead.

What do I need to do in order to get the urls to display in the taxonomyterm/pagename format?

Drupal 7


texts:
I have Drupal 7, without Drupal Commerce modules installed, because we are nor e-commerce place. For some items, we need to show up two prices (old_price and new_price). Only for items for new_price filled I need to show up old_price line-trough or with an X on top. I suppose that I need to put some code in someplace, but where?

I have been looking for a module, but all modules are for commerce. I do not want to install commerce and all the pile of commerce modules just to add this feature.


texts: How to remove the value Search from the site search form?

texts:
I would like to style the Submit button and use an icon instead of the standard button. I would also like to remove the text/value Search.

How would I go about doing this?


texts:
In drupal 6, I have an event node type and an event_attend node type.

The event_attend node type has a nodereference to event. In hook_form_alter for the event_attend node type, i added a validation routine.

In the validation routine, i would like to have access to the parent event node. I would like to compare event_attend's date of participation to the date when the event is taking place.

Is there a way of doing this without doing a node_load($nid_of_parent_event)?

I was kind of hoping that somewhere in the $form variable lies data for the parent event's date but I think such is not the case. That is why I am posting the question here.

I am using openatrium 6x by the way. Anyway, I'll just make a query directly to the database to get the parent event's date using the event nid.

Thanks to everyone.


texts:
Is there a way to create "familly group" in drupal commerce, like with an image and a description ( looks like a product ) and when you select it in shop you've got a list with all the product with this image in different shape ( with price, ... )

I guess there must be a module for that,  i don't think this is very special.

If someone know what I can do, please tell me.

Thank you


texts: Show referenced nodes as links if they have content in a field

texts:
Nodes of content type A are attached to nodes of content type B with an entity reference. Im listing Nodes of type A on Node B with a view.

Now I need the list of Node As to be links if their node's body has content. If their node's body doesnt have content then I need it to not be a link.


texts: Write errors to the log unless the user is an administrator

texts: Under error reporting it is possible (and actually recommended for live sites) to write errors to the log, but not to the screen as well. I don't want to show errors to my users, but at the same time I never check my logs. Is there a way of only showing these errors on screen to administrator users?


texts: How do I render a form from a controller?

texts:
Render form in Drupal 8.

In modulename.routing.yml

modulename.fp:

path: '/formpage'

defaults:

_controller: '\Drupal\modulename\Controller\*Controller::formpage'

Write code in controller.php

public function formpage() {

$form = '';

$form = 'Form Title';

$form .= \Drupal::formBuilder()->getForm('\Drupal\modulename\Form\fp');

return [

  '#type' => 'markup',

  '#markup' => $form,

];

}

and write form code in modules\modulename\src\Form\fp.php.

but showing
Form Title Array

how to render form.


texts: How to translate the user profile page in commerce kickstart

texts:
Hello,
I'm using commerce kicksart in my website, I use french as source language instead of english, I translated many words in the user profile page, but I can't translate or edit some titles:

-HELLO
-PRIMARY SHIPPING ADDRESS
-PRIMARY BILLING ADDRESS
-RECENT ORDERS

I didn't find them in the translate interface page admin/config/regional/translate/translate, also I didn't find any view or block to edit them.

How I can translate or edit them without touch the tpl file?

Thanks


texts: Select query for get title and url of node

texts:
I need to query the database directly using php. I need to limit my query to nodes created in the current year. I know that the node table contains the date the node was created in the 'created' column and that this contains a date as a timestamp.

I am not sure how to get the current year and express it as a range of timestamps and return only nodes that were created between the two timestamps.


texts: I need to group a view by first initial (A,B,C) but both A and a are considered separate groups

texts:
How can I get views to group upper and lowercase together?
I have the title field added twice in the view and the second instance under REWRITE RESULTS I have "Trim this field to a maximum length" of 1.  My view is grouped by this second field (so the first letter of the title.)
I have tried glossary mode with a contextual filter and that also didn't yield results.
Do I have to convert the field with strtoupper in a view template to achieve this?


texts: How can I pass a value from block to page in a view?

texts:
I'm trying to create a search in Drupal 7 using views. I can create the basic search easily, but I'm trying to have the search work like http://leg.colorado.gov/.

I have a view created with a block that has an exposed filter, and a page with multiple exposed filters. I'm trying to get the block to pass the searched term to the page where a user can use more filters to specify what they're looking for. However, all I can seem to do is create a block that performs a search within the block.

Is it possible to set this up using admin configuration in Drupal 7 views, and if so, how? Or would this required coding or other modules?

Thanks


texts: How to add tabs to a form without a module

texts:
I want to add horizontal tabs (not vertical tabs as shown in examples) as shown on the site : http://www.nseindia.com/ (Get Quotes on the top). I tried using menu modules like superfish and nice menu's it didn't solve my purpose.

I want to add this form with tabs via code and this is what I'm using for adding form to my block:

/**
 * Create the form.
 */
function getQuotes_search_block_form($form, &$form_state) {
  $form['keys'] = array(
    '#type' => 'textfield',
    '#title' => 'Get Quotes',
    '#default_value' => t('Enter Script name/Code /ID'),
    '#size' => 35,
    '#maxlength'=> 255,
    '#attributes' => array(
         'onblur' => "if (this.value == '') {this.value = 'Enter Script name/Code /ID'}",
         'onfocus' => "if (this.value == 'Enter Script name/Code /ID') {this.value = ''}",
         ),
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Search',
    '#states' => array(
         'visible' => array(
            'input[name="keys"]' => array('filled' => TRUE),
          ),
    ),
  );
  return $form;
}

/**
 * Create the form submit handler.
 */
function getQuotes_search_block_form_submit($form, &$form_state) {
  $id = $form_state['values']['keys'];
  if ($id && $id != 'Enter Script name/Code /ID') {
    drupal_set_message(t('The form has been submitted'));
    drupal_goto('custom/node/search/' . $form_state['values']['keys']);
  }
}

/**
 * Create the search results menu callback.
 */
function mymodule_menu() {
  $items['custom/node/search/%'] = array(
    'page callback' => 'mymodule_do_search',
    'page arguments' => array(3),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Create the search results callback function.
 */
function getQuotes_do_search($keys) {
  // set the page title
  drupal_set_title('FAQ search results');
  // get the search results
  $results = module_invoke('node', 'search_execute', $keys . " type:faq");
  return theme('search_results', array('results' => $results));
}

/**
 * Create the search form block.
 */
function getQuotes_block_info() {
  $blocks['faq_search'] = array(
    'info' => t('FAQ Search Block'),
    'cache' => DRUPAL_NO_CACHE,
  );
  return $blocks;
}

function getQuotes_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'faq_search':
      $block['title'] = 'Custom FAQ Search';
      $block['content'] = drupal_render(drupal_get_form('getQuotes_search_block_form'));
      break;
  }
  return $block;
}

How do I add the horizontal tabs?


texts: Drupal 7, login, "form_build_id" not used?

texts:
I write some functional tests for my website.
I have this test :

go to login page
post username/pass/form_build_id
check if the user is connected

In the test script, my form-build-id is "hardcoded". So, I run the connection test severals times and...The user connects each run (whereas the form-build-id does not change)

I don't understand, why the form-build-id is ignored ?
I check with my web browser, each time I refreshed my page, the form generate a new form-build-id.


texts:
I'm building a custom block that shows Hierarchical select form , I'm trying to autosubmit it after make a selection I'm using this code :

(function ($) {

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

      $(".hierarchical-select-wrapper").bind("change-hierarchical-select",function(){
        console.log("Yes changed hierarchical-select");
        jQuery("#location-selector-form").submit();
        //$("#location-selector-form .form-submit").trigger("click");
      })

    }
  };

})(jQuery);

My form is autosubmited but with no values (I checked this with dpm($form_state); )


texts: What argument to use in Views that excludes the node currently being displayed?

texts: For instance: if you have a view that produces a list of titles of nodes of content type X, how can you make that list exclude the node that is currently displayed to a site visitor?


texts:
I'm running Drupal 7.12 and had to build a module that extends the search functions of the core Search Module. I made the module, installed it in my custom module folder and reloaded my Drupal site only to find that the search bar couldn't be found on the page...

I looked through the module selector on my dashboard and looked through the core modules. Surprisingly, there was no search module listed in the core module section, although my module did show up in my custom module section (which is irrelevant because the module I wrote needs the core search engine to work).

I checked through my Drupal on my FTP site and found that the files for the core search module are still there.

Why isn't it appearing in my dashboard core module list, and how do I get my Drupal site to recognize that the files are still there?


texts: Webform save draft after each field update

texts:
I need to save a draft of the webform after each field change. I know that you can save a draft by clicking a button (or between pages in multi-page forms) and my initial tough was to do a form_alter, add an ajax callback to fields and call the submit handler for save_draft. Had anyone tried something like this?

Some conditions:

If there is an existing draft for the current user, it needs to update that one (not create a new one);
it needs to work for anonymous users as well.

Drupal 7 + Webform 7.x-3.x

I'll post the answer here if I manage to do it, but any feedback would be appreciated if there are people who've done this before.


texts: reCaptcha has blocked me out of my website

texts:
I had enabled reCaptcha yesterday on my site. The keys that I had entered were generated for my real site while I had been working using my temp.

My site displayed this message continuously:

  Input error: Invalid referer

I didn't take it seriously for I thought it will be resolved when I start using the real url for my site.

Today, when I logged out, I realized that I was wrong. I am not able to log inside my administrator account because the captcha is blocking me out. This is the message that I got when I tried to enter the site using my login id password:

  The answer you entered for the CAPTCHA was not correct.

I can not disable the captcha on login screen because I am not able to enter the site. Should I delete the captcha module from my directory right way? Or will that screw up things further because I won't be able to clear the cache of my website?


texts:
How do you change the email recipient of drupal 7 webform based on checkbox value using hook form alter?
I have a group of checkboxes (Texas, DC, Maryland, Virginia). I would like to change the recipient if Texas is checked and use the default for the other options. I do not want to change the key of the checkbox component to the Texas email address because I need to state which location was selected in the email template.


texts: Allot space to individual registered user

texts:
I have a drupal site with many users.

How to add space to individual registered users in drupal site? Each user can be alloted a maximum space of 500MB for all his events, messages, videos and hotlist. How could this be done?


texts: Filter by the label of a content type in a query

texts:
I'm trying to modify the entity reference autocomplete to search by the content type label. Does anyone know how to search by the label of a content type? With "node_field_data.type" I can search by the machine name, but I need the label.

$or = $query->orConditionGroup()
  ->condition($title_field, $value, $operator)
  ->condition('node_field_data.type', $value, $operator);
$query->condition($or);


texts: Is there a way to hide the Apply button on an Exposed Contextual Filter?

texts:
I'm using an Exposed Contextual Filter in a view. It's working nicely; however for aesthetics, we'd like to remove the Apply button and have the view change when the pull down does. How might I accomplish this?

Follow up:

Thanks to both of you Lance and agargy below. Yes, hide the Apply button by checking 'Hide submit button'.


texts:
I'm trying to get my breadcrumbs to display in a default site template with panels, but they aren't showing up when I go to view my pages, although everything else is. It also says that they are there in layout designer.  I downloaded custom_breadcrumb module in hopes that it might right something with panels, but no luck.

This is how I'm adding them to my panels;
Add Content > Page Elements > Breadcrumb > save & update

No other settings.  It may also be worth mentioning that I'm using Bear and Aurora base  theme.

What can I do to get these back up?


texts:
I've started a big project and need to create some kind of staging area or testing environment, where I'm able to start off with developing the site and after launch will be able to use as the server where I'm able to add new features etc.

I've tried searching around, but haven't found a satisfying solution yet.

So I was hoping someone here could guide me through how to start off my Drupal adventure. Setting up a testing environment, which in the end I'll be able to push to a live server and then use it just for coding new features and push them live later.


texts:
I am working through a Drupal 8 module building exercise from YouTube and I am not able to figure out what is causing an error. The relevant page loads and displays the form but I get the following error message:

Notice: Trying to get property of non-object in Drupal\rsvplist\Form\RSVPForm->buildForm() (line 29 of modules/custom/rsvplist/src/Form/RSVPForm.php).

Drupal\rsvplist\Form\RSVPForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 518)
Drupal\Core\Form\FormBuilder->retrieveForm('rsvplist_email_form', Object) (Line: 275)
Drupal\Core\Form\FormBuilder->buildForm('rsvplist_email_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 38)
Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

The code for the form is here:

<?php
/**
  *@file
  *Contains \Drupal\rsvplist\Form\RSVPForm
  */
namespace Drupal\rsvplist\Form;

use Drupal\Core\Database\Database;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 *Provides an RSVP email form
 */

class RSVPForm extends FormBase {
  /**
   * (@inheritdoc)
   */
  public function getFormId() {
      return 'rsvplist_email_form';
  }

  /**
   * (@inheritdoc)
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
      $node = \Drupal::routeMatch()->getParameter('node');
      $nid = $node->nid->value;
      $form['email'] = array(
          '#title' => t('email address'),
          '#type' => 'textfield',
          '#size' => 25,
          '#description' => t("We will send updates to the email address you provide"),
          '#required' => TRUE,
      );
      $form['submit'] = array(
          '#type' => 'submit',
          '#value' => t('RSVP'),
      );
      $form['nid'] = array(
          '#type' => 'hidden',
          '#value' => $nid,
      );
      return $form;
  }
  public function submitForm(array &$form, FormStateInterface $form_state) {
      drupal_set_message(t('The form is working'));
  }
}

The Drupal version is 8.6.15. PHP Version is 7.0.15 Can anyone spot an error I am missing?


texts: Drupal 8: Rendeirng node fields in another region

texts:
my content type contains several fields; body, field_meta_tags, field_image, field_date, etc.

In node.html.twig, using the without filter, I can replace the standard rendering of {{ content }} with {{ content|without('field_image') }} and all of the content, less the image, will display.

How can I expose this variable to another region and render the image through a different template, perhaps region--hero-image.html.twig?

Thanks!


texts:
$acl_ids = array(1,2,3);
$database = \Drupal::database();

$result = $database
  ->query("SELECT {nid} FROM {acl_node} WHERE grant_update = :grant",
    ['grant' => 1,])
  ->condition('acl_id', $acl_ids, 'in')
  ->fetchField();

Unfortunately the ->condition part does not work, since I get the following error:

  Call to undefined method Drupal\Core\Database\Statement::condition()

What method should I instead use?


texts: Turn off responsive behavior for Bootstrap 3

texts: I know how to turn off responsive in bootrap . but how it can be in drupal theme. As i am using Drupal Bootstrap and created a subtheme. can that subtheme be non-responsive ??


texts: How to implement Administration UI notifications for new revisions?

texts:
I'm new to Drupal and I'm customizing an administration theme to be designed to our needs.

One of the things we would like to have is a visual notification of a new REVISION (content needing approval/revising/reverting, not already published). I've set this up via email, using Rules, but we need the visual indicator, like a red circle with the number of new revisions in it somewhere in the header.
Extending from that, when they click on the icon, then a page where they can administrate all the revisions needing their attention. The page would list all content types needing approval from an admin for publishing, where the admin can approve, go to the type to edit or revert to previous revision.

I thought I would have access to at least #1 via a module but cannot find something similar. Does anyone know of a module or modules that can fulfill the above requests? If the module was specifically written for something else, like notification of comments, I'm happy to rewrite it to fit - just anything that can me some time.


texts:
Is there a function that captures search parameters? Specifically I just need the search term as a variable to compare against certain node taxonomies to add a custom filter on the search template.

I want to capture the search term without going through any Solr API. Is this possible?


texts: Ubercart Numerical Attributes Not Respecting List Position Settings

texts:
I have an attribute option select box field that has numerical options, like this:

LENGTH
1
1.5
2
10
100

However, this is how the options are displaying on the front-end view of the product:

LENGTH
1
1.5
10
100
2

As you can see, it is sorting anything that starts with a "1" before anything that starts with a "2". I need it to be in literal numerical format.

Any ideas on how I can make this work the way I need it to?

Thanks!


texts: Upload to none public or private folders when using managed_file field type

texts:
Is there a way to use an arbitrary directory for uploading a file? One that is not the public or private folder? I do not mind if it doesn't save a record in the Database.

$form['upload_logo'] = array(
    '#type' => 'managed_file',
    '#title' => t('Upload a Logo'),
    '#weight' => 18,
    '#upload_location' => drupal_realpath('sites/all/files/images/logos'),
    '#upload_validators'  => array('file_validate_extensions' => array('png gif jpg jpeg')),
);

The current code returns this message:
The file could not be uploaded, because the destination "Path Generated By drupal_realpath()" is invalid.


texts: View a log of administration configuration changes for Drupal 7?

texts: I'm working on a Drupal 7 site and we have multiple developers and administrators accessing the site. Many times when the site breaks I can't see what was changed previously and by whom. Is there a log tracker where I can see what things were changed on the site? I know I can goto admin/content to see what content has been updated, but this isn't the case for configuration changes.


texts:
My cars data is as the following:

id    make        no         parent
1     bmw         NULL          0
2     bmw         bmw987        1
3     bmw         bmw654        1
4     ferrari     NULL          0
5     ferrari     ferrari987    4
6     ferrari     ferrari654    4

(Note: I am using two tables for above data. This is just to get an idea of data.)

I am creating permissions to book cars as:

Book bmw; the user will have permission to book bmw987 and bmw654 means
children of BMW
book bmw987; the user will have permission to book bmw9987 only.
Book ferrari; the user will have permission to book all Ferrari cars.

In my car booking portal, I have 100's of cars and many makes. When I used hook_permission() and loop through all available cars to create book permission on each car, it pollutes my permission page (admin/people/permission) and believe me handling these many permission will faint Admin.

Is there any other alternative to handle such huge permission?


texts: Creating referenced nodes together with parent node

texts:
I've 4 node types(Area1-4) which all contain a field of node type of Address. Since address is common to all four nodes, I want each of them to link to Address node as node reference just to save space.

I'll have common people accessing sites so when one visitor tries to create Area1 he'll be confused as address field would require him/her to link to Address node.
That means one'd need to create Address node first which is difficult to explain to site users.

What I want is single form where one'd enter Address details first followed by Area nodes.
What is the best way to handle this situation?


texts: How to show different options for a dependent field

texts:
I've 2 options for a dependent field, I would like to show only one option from the dependent field, when the dependees field has a particular value.
Dependees is a radio button. If the value is 'hotel', I have to show the options room and restaurant from the dependant field. Other wise only show restaurant.

Is it possible through manage dependencies of the content type?


texts: What is the difference between implementing hook_url_inbound_alter() and hook_url_outbound_alter(), and using a path alias?

texts:
In Drupal 7, a module could implement hook_url_inbound_alter() and hook_url_outbound_alter() to rewrite URLs used in Drupal. The same effect could be obtained with path aliases. The only difference is that for path aliases that are someway dynamic, you would need a module that adds a path alias every time there is the need. That is what the Pathauto module does.

Is there any difference between the two approaches (implementing those hooks, and using path aliases)? Is there any reason to prefer one approach to the other one?
Is there any performance difference between the two approaches?

The only difference I can see is that with those hooks there could not be the need of accessing the database (depending on how the hooks are implemented). Is that the only difference, or are there more differences?


texts: In a writing a Views style plugin, how can I create a text input that accepts Twig?

texts:
I am writing a Views style plugin, and I have a text field (input) that I want to be able to accept Contextual Filter arguments (or potentially field values). I am envisioning it working the same as the input that shows up when you click "Override title" under the "WHEN THE FILTER VALUE IS AVAILABLE OR A DEFAULT IS PROVIDED" fieldset. So, for example, you could add {{ arguments.nid }} into the text field.

This (below) is my current form element/text field that I'd want to be able to accept the arguments. I looked into the Views codebase, but was wasn't able to figure out how Views implements accepting arguments in a text field.

$form['display']['title'] = [
    '#title' => t('Chart title'),
    '#type' => 'textfield',
    '#default_value' => $options['title'],
    '#parents' => array_merge($parents, ['title']),
  ];

Any help would be greatly appreciated!


texts: Loading a library only for the front page

texts:
I want to load JavaScript only on the home page of my site. I found this preprocess function but I don't know how to customize it for the home page:

function mytheme_preprocess_maintenance_page(&$variables) {
  $variables['#attached']['library'][] = 'mytheme/cuddly-slider';
}

I was originally including the library I needed in every page of my site, but I only need it on the home page, so I need to figure this out.

Originally I had it in the .info.yml file like so:

libraries:
 - 'themename/library'

Any help is appreciated.


texts:
I am trying to find the code that is responsible for deciding which template file to choose in different cases. For example I need find out what are possible template names for the form rendering.

I have tried to find this grepping source code for key words, but unfortunately, haven't found this part of code.

Please explain the flow and where I can find this logic in the Drupal Core.

P.S. I've already enabled debug mode, but not all suggestions are displayed.


texts:
I want to create a view page with the city events /attractions ... I want to categorize them as family , kids , outdoors etc. So that when a user clicks on a particular category they see the events/attractions listed under it.

How do I do this using Drupal 7 and views?


texts: Fatal error: Call to a member function execute() on a non-object - db_select() addExpression

texts:
I'm fixing up a module and I have the following db_select() code, but I'm getting the following error:

  Fatal error: Call to a member function execute() on a non-object in
  /var/www/xxx/sites/all/modules/xxx/xxx.module on line 414

I think it has something to do with the addExpression line, but I'm unsure of what this line does or what is the equivalent of addExpression in sql? What is MAX(poss), poss -- mean?

$query_poss = db_select('saved_lists', 'saved_lists')
  ->condition('saved_lists.lid', $lid)
  ->addExpression('MAX(poss)', 'poss')
  ->execute()
  ->fetchField();


texts:
I have sort link 'Best' in exposed form. I want after user click this link, link title changes to 'New'
I'm try this, but it don't work:
function helper_form_views_exposed_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
    if($form['#id']== 'views-exposed-form-pozdravleniya-taxonomy-term-page-1') {
      $form['sort_by']['#title'] = '';
      $form['sort_by']['#options']['created'] = '';
      if ($form['sort_by']['#value'] == 'count') {
        $form['sort_by']['#options']['count'] = 'New';
      }
    }
}

Also I'm try this, it don't work too:
function helper_form_views_exposed_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
    if($form['#id']== 'views-exposed-form-pozdravleniya-taxonomy-term-page-1') {
      $form['sort_by']['#title'] = '';
      $form['sort_by']['#options']['created'] = '';
      if ($form_state->getValue('sort_by') == 'count') {
        $form['sort_by']['#options']['count'] = 'New';
      }
    }
}


texts: How do I run PHP code when visiting a specific URL?

texts:
In Drupal 8, I want to visit a link (e.g. www.domain.com/url-link) which should activate PHP code which is in a module.

Is there a hook which support this? If so, how do I implement this?


texts: Drupal 7 + Data (External) + Views - Can't Add Relationship [White Screen + JSON]

texts:
I can't add relationships to Views generated by the Data module.

I have some external (related) tables I need to patch together for viewing, and linking from other parts of the site.

I get a white screen, with a JSON-style dump of state.

As per Cannot edit my views.. I get a JSON string? I've got jQuery Update installed and tried:

using a different version of jQuery for the admin (v1.5) [same result]
disabling jQuery Update entirely [same result]
disabling JavaScript for Views editing (Structure > Views > Settings > Advanced) [no error, but no relationship editing, just back to main View edit screen]
switching the theme for editing Views (Bartik and Seven) [same result]

NOTE: Also confirmed no PHP errors present, have cleared caches after each settings change, etc.

So, since the tables are related (actually coming from another database), I figured I'd experiment with Foreign Keys. I understand that Drupal doesn't (or didn't) natively honour them (due to breaking integrity in some cases), but I figured it might give Schema the push it needed to associate the related tables.

Foreign Keys didn't work either (in fact, now I can't update adopted tables and or set Joins).

The last option I can see is to use a programmatic approach via a custom module using hook_views_data (something like How do I display an external database data?)

Any confirmation, suggestions, etc.?

Any assistance greatly appreciated.


texts: How can I protect a disabled form from being submitted?

texts:
I need to protect URL alias from being submitted.

I've tried setting #disabled, #access, unset(), and what not. It hides the form, but the user is still able to modify the form on the client-side and submit it.

How do I prevent this form from being submitted on the client-side?

My current module code

<?php
function mymodule_form_alter(&$form, &$form_state){
  if (empty($form['type']['#value'])) return;
  $form['#after_build'][] = 'mymodule_after_built';
}

function mymodule_after_built($form, &$form_state) {
  $form['path']['#access'] = FALSE;
  $form['path']['alias']['#access'] = FALSE;
  $form['path']['alias']['#value'] = $form['path']['alias']['#default_value'];

  return ($form);
}

UPDATE:

To clear the question, I am not asking how to hide the form, but how to prevent the end-user from manually altering the code and submitting the form I just hid.

End-user can just edit source code and add <input type="text" id="edit-path-alias" name="path[alias]" value="" size="60" maxlength="255" class="form-text"> and still enter the alias.


texts: For settings.php $conf, how can I tell what a variable in Drupal 7 is named in Drupal 8?

texts:
This article explains that using $conf in settings.php works differently in Drupal 8 compared to Drupal 7:

  The settings.php file could contain environment level overrides. Just
  remember how we disabled email sending on development servers in
  Drupal 7:

  $conf['mail_system']['default-system'] = 'DevelMailLog';

  That’s how it will look in Drupal 8:

  $config['system.mail']['interface']['default'] = 'devel_mail_log';

In Drupal 7, I used $conf to set different Google Analytics accounts per site environment like this:

  if (PANTHEON_ENVIRONMENT == 'dev') {
    // Google Analytics.
    $conf['googleanalytics_account'] = 'UA-XXXXXXXX-X';
  }
  else if (PANTHEON_ENVIRONMENT == 'test') {
    // Google Analytics.
    $conf['googleanalytics_account'] = 'UA-XXXXXXXX-Y';
  }
  else if (PANTHEON_ENVIRONMENT == 'live') {
    // Google Analytics.
    $conf['googleanalytics_account'] = 'UA-XXXXXXXX-Z';
  }

How can I determine what $conf['googleanalytics_account'] was renamed to in Drupal 8?


texts:
Is there any existing Drupal 8 module (on drupal.org, GitHub or anywhere else) that would leverage Guzzle to consume JSON and/or HAL+JSON Web Services over REST?

Alternatively, is the recommended way to necessarily write a custom module leveraging the Guzzle HTTP Client that ships with Drupal core?

My end goal is to be able to create a 1:1 relationship to map fields (node, user...) with key/value pairs from RESTful web services. Then I need to be able to read, update or delete those values.


texts: Is there a way to turn off the paypal checkout button in /cart view in drupal 7 commerce?

texts: After adding an item to the cart in drupal 7 commerce, the /cart page has a checkout with paypal button. Is there a way to remove this in the commerce payment configuration pages? It seems unnecessary and confusing. I know I can hide it via css, but was wondering if there was a option somewhere.


texts: Why would I provide a composer.json for my modules?

texts:
I’ve come across several Drupal7 modules that include a composer.json. It seems that this somehow influences how Drupal-CI determines test dependencies. Now I’m trying to find out whether it’s worth providing a composer.json at all in Drupal7 modules/themes maintained by me. I couldn’t find any hard facts about what exactly can be achieved by providing a composer.json, that’s why I’m looking for pointers to …

How does the presence of a composer.json affect processing in the Drupal-CI?
What other functionality is enabled by providing a composer.json file for Drupal7 modules (or themes)?

Note: There seems to be a lot of documentation about Drupal 8 / composer, but nothing specific for Drupal 7 / composer.

Here is a list of some Drupal7 modules with a composer.json:

currency: Specifies exclusively non-Drupal dependencies.
raven: Specifies exclusively non-Drupal dependencies
stringoverrides: Only  package metadata, no dependencies.


texts:
How can I get feeds to show up on front page or other designated sections of my news site?

I have a DFrupal 8 site using the News theme. I don't know how to set up the RSS feeds to show on the front page as teasers for the section where the feed would normally reside.


texts:
I am helping a client get back up to speed with their website on a strict budget.

So key is keep the site updated for Drupal 6 through the year then upgrade to latest stable version of Drupal first of next year.

Having said this, I am not as familiar with Drupal 6 and keep getting a warning message when using rich-text icon to upload an image into the body field of a node.

Here is the message:

Properties: Change how the image is displayed.

ImageField Assist Upload "name of image.jpg or .png" has been created.

warning: Parameter 2 to imagefield_assist_properties_form() expected to be a reference, value given in /mnt/stor2-wc2-dfw1/428972/572960/www.kennebecriverangler.com/web/content/includes/form.inc on line 378.

on line 378 of form.inc is this code:

  $form = call_user_func_array(isset($callback) ? $callback : $form_id, $args);

Also if this info helps, the theme has been adapted from a WordPress theme...
and configured with CCK, imagefield assist imagefield import and imagefieldAPI.


texts: LimeSurvey RemoteControl JSON_RPC API from Drupal

texts:
Has anyone used LimeSurvey's RemoteControl JSON_RPC API PHP script from Drupal to connect to LimeSurvey in a different server?

I have tried the PHP Example in https://manual.limesurvey.org/RemoteControl_2_API#Example_and_helper in my local instance to export a survey responses and it works perfectly fine.

I have now copied the script to my Drupal folder (installed library jsonrpcphp through composer) in a Test server and trying to connect to Limesurvey in a different Test server; and I am unable to get the connection right.

I have updated the filename, base URLs, username and passwords for the Test instances. Not sure If it is something to do with "https" in the URL? URL for Local instance was "http". Because the script breaks at get_session_key line.

Any help with this will be appreciated! Please drop a comment if more info is required.


texts: How can I add folders to my template directory and have Twig find them?

texts:
I was listening to a Drupal Developer on youtube and one of the suggestions he has, is that when you go into a template folder, create some subdirectories for easier management, like this:

Templates
->Blocks
->Fields
 ->YourField.html.twig
->Nodes

So I want to do the same thing for my template folder, however when I do that, I get this error:

  Twig\Error\LoaderError: Template "modules/custom/task/templates/field--expire-date.html.twig" is not defined.

Now granted, I learned with Drupal that Twig + Theming Templates is different than Twig + Module Templates. I am using my own module.

Is there a way for me to tell Twig there is another subdirectory (Ex: Fields Folder), so it can find the code?


texts:
Is it possible to include extra arguments when migrating via command line?

I have a custom migration which migrates XML content into Drupal as entities. However, each XML document of migrated entities need to be associated with a different node.

I'm successfully doing this entities to node association via the following code:

function complete($entity, stdClass $row) {
    $node = node_load(1);
    $node->field_questions[$node->language][ sizeof($node->field_questions[$node->language]) ]['target_id'] = $entity->id;
    node_save($node);
}

As you can see from the code, the NID is hardcoded. Of course, the NID could be extracted from the XML input but it is unknown in advance of the migration.

So, I just wonder if running drush migrate Questions could be run with custom arguments where I could specify the target NID to associate my migrations with?
Something like, drush migrate Questions --nid=10


texts: Display multi-value entity reference field in node edit form as draggable?

texts:
Is there a way to display a multi-value entity reference field as a draggable widget in a node edit form? I'm looking for the exact same behavior that a multi-value image field has by default. I would like a way for the content editor to easily reorder the referenced entities after they have been added via an autocomplete field. I really thought this was core functionality.

Thanks for your help.

I have found this module, but the UI is pretty bad and I really want the same UI that an image field has. https://www.drupal.org/project/entityreference_dragdrop


texts:
I'm new to Drupal 8.

I need to let users to create new node of some content type by pressing a button or custom link. In Drupal 7 I could achieve this by Rules and Rules link modules but I can't figure out how to do it in D8.

Let's assume I have a content type where all fields have default values and I want to create new node of this content type just by pressing a custom button.

How can I get this working in D8? Any tips?


texts: How to change view mode of view row using hook_views_pre_render?

texts:
Is it possible to change the view mode of a view result in hook_views_pre_render?

For example I have 3 different view modes (teaser, teaser-full, teaser-short). The goal is to have the view repeat these 3 teaser templates in the view page/listing, but I'm firstly struggling to change the view mode at all.

I tried the below, but it doesn't seem to do anything.

function themename_views_pre_render(ViewExecutable $view) {
  foreach ($view->result as $index => $row) {
    $view->row_index = $index;
    $view->rowPlugin->options['view_mode'] = 'teaser';
  }
}

Note: If I drop a breakpoint into the code, it is being hit. But still gets rendered out as default view mode.


texts: i want to set input filter for blocks to only allow plain text, but on nodes I want to only allow full html how do i do this?


texts: Is it possible to get client ip in setting.php

texts:
I'm trying to get the client IP in settings.php for security reasons, using the following code.
I have to support X-Forwarded-For header because accessing web server over loadbalancer.

$clientIp = \Drupal::request()->getClientIp();

It causes the following error.

  The website encountered an unexpected error. Please try again later.
  Drupal\Core\DependencyInjection\ContainerNotInitializedException: \Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container. in Drupal::getContainer() (line 129 of /var/www/my-site/docroot/core/lib/Drupal.php).
      Drupal::getContainer() (Line: 218)
      Drupal::request() (Line: 759)
      require('/var/www/my-site/docroot/sites/default/settings.php') (Line: 116)
      Drupal\Core\Site\Settings::initialize('/var/www/my-site/docroot', 'sites/default', Object) (Line: 1015)
      Drupal\Core\DrupalKernel->initializeSettings(Object) (Line: 642)
      Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Any suggestions to fix this?


texts: programmatically enable and disable theme from update hook

texts:
I need to programmatically update my default theme and disable bartik on a live site. I know I need to update the config. In Drupal 7 I would have used theme_enable(), but I am not sure how to do this in Drupal 8.
Below my function sets 'mycustomtheme' by default but it does not enable the theme. Thanks in advance.

  function mysite_deploy_update_8001() {
      \Drupal::configFactory()
      ->getEditable('system.theme')
      ->set('default', 'mycustomtheme')
      ->save();
    }


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

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


texts:
I have a website in English language and i want to translate some button in own language .
i know that i can add my language and simply translate all my stuff, but the point is i have to translate these buttons like subscribe in Simplenews module in en language.

Here is my step :
i went to config/regional/translate/translate and add my word to translate but i could not do that .

am i missing something ?


texts: ajax http 500 error while editing panel in drupal 7

texts:
I am getting this error when I tried to edit my panel in drupal 7.

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /panels/ajax/editor/edit-pane/panel_context%3Apage-contacts%3A%3Apage_contacts_panel_context%3A%3A%3A%3A/8
StatusText: Internal Server Error
ResponseText: 500 - Internal server error.
Server Error 500 - Internal server error.

Anyone with solution highly appreciated.
Thanks


texts: how to add order on cart programatically in ubercart?

texts:
I need a custom create price functionality for a product. My order is created with uc_cart_add_item() but the price can't be set here.

How can I price the order programmatically?


texts:
In Administration -> Structure -> Blocks I have defined Search box region with search box block and Left sidebar region with navigation block. These blocks are visible when I'm logged in but when I log out the blocks disappear?

Do you where is the fault?

I have an idea where could be the problem. There are two files with page template - page.tpl.php and page--front.tpl.php.

thank you


texts: I would like to add bootstrap classes to a load more pager, with the views load more module. I am currently using javascript to add it on, but the moment I change the view the classes are no longer there. I assume I have to use theme_preprocess_item_list() but I'm not quite sure how to go about this.


texts: How to use features-export drush command?

texts:
I'm using Drupal 7. We have a large feature that we want to break apart. I am following the instructions here, and since there are a number of objects in the feature, I want to use drush commands, instead of clicking around the UI, to export the different objects.

I am looking at the drush commands from the features 7.x-2.10 module and found features-export. I'm not sure how to use the drush help command, but I found this description in features.drush.inc

case 'drush:features-export':
  return dt("Export a feature from your site into a module.
   If called with no arguments, display a list of available components.
  ...

But I called it with no arguments, and instead of a list of components, I got this error message:

$> drush features-export
No feature name given.

Poking around more, I found the features-components command, which gives me this:

$> drush features-components
Enter a number to choose which component type to list.
 [0]   :  Cancel
 [1]   :  all
 [2]   :  breakpoints
 ...
 [11]  :  field_base
 [12]  :  field_group
 [13]  :  field_instance

Selecting 11 (field_base) gives me these tokens:

...
field_base:field_address_1
field_base:field_address_2
field_base:field_state
field_base:field_zip_code
...

So I thought that I could use a line or token from the above output in the features-export command. However, I still get errors:

$> drush features-export field_instance
No components supplied.                            [error]

$> drush features-export 11
No components supplied.                            [error]

$> drush features-export field_base:field_address_1
No components supplied.                            [error]

$> drush features-export "field_base:field_address_1"
No components supplied.                            [error]

How do I use the features-export command from the features 7.x-2.10 module?


texts:
I have created one custom page. Also created breadcrumb service which perfectly work for admin page but doesn't work for custom page.Even I have checked my custom theme setting where breadcrumb visibility is set true.

Snippet of code

company.services.yml
services:
  company.breadcrumb:
    class: Drupal\company\Breadcrumb\CompanyBreadcrumbBuilder
    tags:
      - { name: breadcrumb_builder, priority: 100 }

CompanyBreadcrumbBuilder.php

namespace Drupal\company\Breadcrumb;
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Link;

class CompanyBreadcrumbBuilder implements BreadcrumbBuilderInterface{
    /**
        * {@inheritdoc}
        */
    public function applies(RouteMatchInterface $attributes) {
        $parameters = $attributes->getParameters()->all();

        return true;
    }

    /**
        * {@inheritdoc}
        */
    public function build(RouteMatchInterface $route_match) {
        $breadcrumb = new Breadcrumb();
        $breadcrumb->addLink(Link::createFromRoute('Home', '<front>'));
        $breadcrumb->addLink(Link::createFromRoute('Article', '<front>'));
        return $breadcrumb;
    }
}

m missing something like setting?

Note: I m using bootstrap as base theme.


texts: How to use Rules to send an email after a user submits a first node and grant a new role after 5 nodes?

texts:
I want to send a congratulations email to user on submitting his/her first node.

I want to implement this through the Rules module. But I am confused and think that there is no such option except PHP evaluation which seems bad to me due to eval().

And I also want to assign a special role to a user after a user submitted (= Save new content) 5 nodes.

Any suggestions?


texts: How can I import the contents of an uploaded csv file into a drupal managed table using rules custom php?

texts: I am using drupal 7 and have the data module managing/adopting a table I have manually added to my drupal db. What I was hoping was that when a csv file is uploaded via a specific content type I could use rules to execute some custom php and import the csv into the table (as feedsdataprocessor no longer exists from what I can see). I see there is a drupal_write_record function but the problem is first how do I get the array out of the file and secondly my file can be different to the table in structure - for example, sometimes the csv will have columns 1,2,3,4 and sometimes 3,4,5,6,7. How can I check the headers and import into the managed table?


texts: How do I put a div around table with class = table-responsive?

texts:
I want to put a div around tables in general and give them the class table-responsible. Therefore I changed the table.html.twig in my theme like this:

<div {{attributes.addClass('table-responsive') }}>
  <table{{ attributes.addClass('table') }}>
    ...
  </table>
</div>

But if I create a table in CKEditor nothing happend. It's only an ordinary table and nothing changed.

What did I do wrong?


texts: What is the problem in my code ? [ SESSION ]

texts:
I create a code for my form . When I choose a product in node,data send to my form page and sessions sav data and then I chose seconde product I see two products in my form page . But when I refresh page just show 1 pruduct . What is the problem ?

public function buildForm(array $form, FormStateInterface $form_state) {
    $session_manager = \Drupal::service('session_manager');
    $session_manager->start();
    $newlabel = \Drupal::request()->request->get('label');
    $newcode = \Drupal::request()->request->get('code');
    $newprice = \Drupal::request()->request->get('price');
    $newsellercode = \Drupal::request()->request->get('sellercode');

    if ((isset($_SESSION['loop'])) and ( isset($newcode)) and ( !in_array($newcode, $_SESSION['code']))) {
        $_SESSION['loop'] = $_SESSION['loop'] + 1;
        $_SESSION['label'][$_SESSION['loop']] = $newlabel;
        $_SESSION['code'][$_SESSION['loop']] = $newcode;
        $_SESSION['price'][$_SESSION['loop']] = $newprice;
        $_SESSION['sellercode'][$_SESSION['loop']] = $newsellercode;

        for ($count = 0; $count <= $_SESSION['loop']; $count++) {
            $forms[$count] = [
                '#markup' => '
' . ($count + 1 ) . '	' . $_SESSION['label'][$count] . '	' . $_SESSION['code'][$count] . '	' . $_SESSION['price'][$count] . '	' . $_SESSION['sellercode'][$count] . '
',
            ];
        }
    } elseif ((isset($_SESSION['loop'])) and ( isset($newcode)) and ( in_array($newcode, $_SESSION['code']))) {
        for ($count = 0; $count <= $_SESSION['loop']; $count++) {
            $forms[$count] = [
                '#markup' => '
' . ($count + 1 ) . '	' . $_SESSION['label'][$count] . '	' . $_SESSION['code'][$count] . '	' . $_SESSION['price'][$count] . '	' . $_SESSION['sellercode'][$count] . '
',
            ];
        }
    } elseif ((isset($_SESSION['loop'])) and ( !isset($newcode))) {
        for ($count = 0; $count <= $_SESSION['loop']; $count++) {
            $forms[$count] = [
                '#markup' => '
' . ($count + 1 ) . '	' . $_SESSION['label'][$count] . '	' . $_SESSION['code'][$count] . '	' . $_SESSION['price'][$count] . '	' . $_SESSION['sellercode'][$count] . '
',
            ];
        }
    } elseif ((!isset($_SESSION['loop'])) and ( isset($newcode))) {
        $_SESSION['loop'] = 0;
        $_SESSION['label'][$_SESSION['loop']] = $newlabel;
        $_SESSION['code'][$_SESSION['loop']] = $newcode;
        $_SESSION['price'][$_SESSION['loop']] = $newprice;
        $_SESSION['sellercode'][$_SESSION['loop']] = $newsellercode;
        for ($count = 0; $count <= $_SESSION['loop']; $count++) {
            $forms[$count] = [
                '#markup' => '
' . ($count + 1 ) . '	' . $_SESSION['label'][$count] . '	' . $_SESSION['code'][$count] . '	' . $_SESSION['price'][$count] . '	' . $_SESSION['sellercode'][$count] . '
',
            ];
        }
    } else {
        $forms = [
            '#markup' => 'Nothing',
        ];
    }

    $form['loop'] = [
        '#markup' => '' . $_SESSION['loop'] . ''
    ];
    $form['theme'] = [
        '#theme' => 'basket',
        '#content' => $forms,
    ];
    return $form;
}


texts:
I've been following the Drupal example on how to create a new field. I can get their example to work fine, but when I try my own it does not seem to store any data, i.e. the field is always blank when I load the node back. I am ultimately attempting to create a field which can hold multiple pieces of information, a bit like the example three field color code. Although I would want a better storage then expanding a value into an array (I have an idea on this, but until I have the basic data storage working I cannot comment on this).

The example is here.

This is my code from the module; I have stripped the example down to the bare minimum, and I have checked it works on the color wheel code.

 function prodlist_field_schema($field) {
  if ($field['type'] == 'prodlist_code') {
      $columns = array(
        'prodcode' => array(
          'type' => 'varchar',
          'length' => 7,
          'not null' => FALSE,
        ),
      );
  }
  return array('columns' => $columns);
}

function prodlist_field_info() {
  return array(
    'prodlist_code' => array(
      'label' => t('Product Code'),
      'description' => t('Used to assign product codes'),
      'default_widget' => 'prodlist_text',
      'default_formatter' => 'field_example_simple_text',
    ),
  );
}

function prodlist_field_widget_info() {
  return array(
     'prodlist_text' => array(
      'label' => t('Prodcode entry fields'),
      'field types' => array('prodlist_code'),
    ),

  );
}

function prodlist_field_is_empty($item, $field) {
  return empty($item['prodlist_code']);
}

function prodlist_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $value = isset($items[$delta]['prodlist_code']) ? $items[$delta]['prodlist_code'] : 'emptyonload';

  $widget = $element;
  $widget['#delta'] = $delta;

    $widget += array(
          '#type' => 'textfield',
          '#title' => 'prodcode',
          '#size' => 23,
          '#default_value' => $value,
        );

  $element['prodcode'] = $widget;
  return $element;
}


texts:
We are using 3 different languages by multilingual module. If we search by the English word, then search content should be in English, and if we search by Marathi/Hindi word, then search content should be in that particular language.

How can I perform multilingual specific search?


texts: Drupal best way to render content type data and meta-data

texts:
I am new to Drupal and struggling on the best approach to choose, I have several questions which are all related to my approach.

Let say I have a content type "Rooms" and would like to create 2 pages: 1 for listing the rooms and one per room (let's call that one Room A), plus I would like to add some additionnal data for the page listing rooms. Of course I need menu item when being on page "Rooms" but still need the item to be active when on page Room A.

Finally, the page Rooms not only list the room's content type but also display some static blocks which both has and has no relationship to the Room content type.Eg: an image's banner with a small description.

After doing some research, I have found several approach to do this:

Have a taxonomy "Rooms" with no terms and in which I classify all my rooms and add additional field for data specific such as my banner picture. I then create a basic page which I theme to call my blocks and taxonomies. The menu active trail issue is realized by taxonomy-menu trail.

Pro: it works. Cons: the logic bothers me, the purpose of taxonomy is more like a tagging system rather. Therefore I have to tag my content's instance each per each

I create a new content type "Banner" in which I add new fields, an image, a description... Using Node Hierarchy menu, I create a parent relationship for a basic page to a room content type, on that basic page i display all my block...

So, OK the content type is not a page it's an abstract of fields, but what if I want to display in the most efficient way data that are on higher level of abstraction of the content type and that are specific to that content type ?

What's your opinion ?


texts: Linking to a php site located in a subdirectory of the Drupal site

texts:
So I've taken part in a very interesting Drupal project that has a multilingual Drupal 7 site and three sub-sites (all using the same domain) in sub-directories of the main Drupal site. So it's kind of like this:

http://example.com <- main Drupal site
http://example.com/site1 <- php site that doesn't use Drupal
http://example.com/site2 <- php site that doesn't use Drupal
http://example.com/site3 <- php site that doesn't use Drupal

Now I can create relative links to these sites on the Drupal site by adding links like

Site 1

And that works when I'm on the homepage, but since this is a multilingual site, any other page I go on uses a language prefix on the URI like this:

http://example.com/en/contact

If I try to click on the Site 1 link I made above while on the contact page, it takes me to:

http://example.com/en/site1

and displays a 404 error.

Currently, the site uses hard-coded absolute links to get around this issue, but it's becoming a real pain to use this in our local and testing environments and I've been asked to remove the absolute urls from these links.

I've tried a few different things like using Token Filter with [site:url]/site1, but it still tries to add the language prefix and gives me the same 404 error. I thought of trying to use a module to look for these specific links and set them accordingly, but I can't think of an efficient way of doing it. Other ideas like using JavaScript to edit the links after the page loads or redirecting to the right page just smell so bad I don't want to try them.

Any ideas on how I can create links to these sub-directories without hard-coding them?


texts: Exposed filter term as view title: term name instead of tid

texts:
I have a View with two exposed filters (in a block):

Select list with 4 options (lets say cats, dogs, horses and birds)
Autocomplete text field for tags

I am using Exposed Filter Data and Better Exposed Filters modules.

I am trying to use the exposed filter(s) as the title of the View. There is no problem with the autocomplete text field (Views gets the value from the field and sets it as the title), but when you select one of the terms of the select list, Drupal prints the tid (a number) instead of the term name (“cats”...).

I have added the php snippet in the view´s header as pointed out in Exposed Filter Data module’s page:

<?php
print get_exposed_filter_output();
?>

I have tried replacing the text manually with Javascript (.replace), but this is not a valid solution because these terms might change in the future.

I have also tried looking at  exposed_filter_data.tpl.php, but I couldn’t find a solution. This trick (page title from the Views Exposed filter term using contextual filter) doesn’t work for me either: I can only use one field as the View title, and I need both of them.

In short, I need to print the name of the taxonomy term, NOT the tid (a number).


texts: Content Statistics: Total View not showing up in Services

texts:
I'm pretty sure this worked the other day, but today I checked and it didn't appear in my Services

If I add a new field such as body, it appears in my json file.. When I add Content Statistics: Total Views it won't add it.

I tried doing it a dirty way by adding a Global Text and use a replacement pattern, but then it outputs it like: [totalcount]

Also worth noting I can see it in the preview.


texts: Create a Corresponding Entity Reference preset programmatically

texts: I'm using the CER module in Drupal 7. Is there a way to create a preset programmatically?


texts: Drupal 7 "Panel Nodes" Content Pane Contextual Filter

texts:
Does anyone know how to set up a taxonomy-based contextual filter (argument) for a Views Content Pane that is going to be displayed in a "Panel Node" (from the "Panel Node" module that comes with Panels) tagged with the same taxonomy term?

I think I am missing something about how "Panel Nodes" works. I don't get the option for a term ID unless I add a "Relationship" to the taxonomy field in Views. Then I can set the Contextual Filter to the term ID, but it does not work consistently. If I set the "Argument Input" for the pane to "From Context", it works in Views preview with an argument, but it's blank on the actual Panel Node (if the Pane even shows up to be added). If I set it to anything other than "No Argument", it doesn't work at all.

When I use an argument to preview the Content Pane in Views, it works as it should. But on the "Panel Node" page, it's blank. I don't think the argument is making it to the pane.

Some background:
"Panel Nodes" is a module that comes with Panels and it creates this Panel-ified content type, but I'm finding very little documentation on how to use it. Panel Nodes are not in Page Manager and so you cannot set a context for them there.

I have a client that could use Panels in their Drupal 7 site just for one particular kind of content type. For this particular use case, the the "Panel Nodes" way of generating the content is the most intuitive for the client (enter a title, body, an image into a node add form, and then click on the Panels Layout and Panels Content tabs right from the node form; I believe this is a similar model to the way http://drupal.org/project/panelizer is supposed to work).


texts: How to programmatically check a view to test if it has any results?

texts:
What's the most lightweight way to test if a view has any results in it or not? I have a system which creates links to various views, but if the view has no results I want the link to be greyed out. I can only think to load the whole view and execute it, but hopefully there is an easier solution?

I should also note that these views contain contextual filters, if it makes any difference.


texts: The provided host name is not valid for this server on OVH Web Server

texts:
I'm using an OVH web server, I went to the ftp browser and did add all my files into www.
I was using Drupal 8 in local.

When I want to go to my website, I've this error:

  The provided host name is not valid for this server.


texts: Install a module that creates a content type with fileds via YAML

texts:
I am new to drupal 8, I have been using drupal 7 for quite some time and I used to write the code that creates content types and fields in hook_install / hook_update.

Now I am creating a module that creates a new content type with a few fields. I tried to do it with YAML config files but it does not create my fields.
The code I have so far:

/module/custom/mymodule/mymodule.info.yml

name: My Module
description: Applies customizations for my website.
package: Custom

type: module
core: 8.x

dependencies:
    - breakpoint # toolbar dependency
    - image
    - link
    - taxonomy
    - toolbar

/module/custom/mymodule/config/install/node.type.article.yml

type: article
name: Article
description: 'Use articles for time-sensitive content like news, press releases or blog posts.'
help: ''
has_title: true
title_label: Title

settings:
    node:
        options:
            status: true
            promote: true
            sticky: false
            revision: true
        preview: true
        submitted: true

status: true
langcode: en

new_revision: true
preview_mode: 1
display_submitted: true

dependencies: {  }

And one of my fields:
/module/custom/mymodule/config/install/field.field.node.article.image.yml

langcode: en
status: true
dependencies:
  config:
    - node.type.article
  module:
    - image
id: node.article.image
field_name: image
entity_type: node
bundle: mymodule
label: Image
description: 'A representative image for the current article.'
required: false
translatable: false
default_value: {  }
default_value_callback: ''
settings:
  file_directory: '[date:custom:Y]-[date:custom:m]'
  file_extensions: png
  max_filesize: ''
  max_resolution: ''
  min_resolution: ''
  alt_field: true
  alt_field_required: true
  title_field: true
  title_field_required: true
  handler: 'default:file'
  handler_settings: {  }
field_type: image

What am I missing? Why don't the fields get created at install time?


texts: What are the best practices to manage site mirrors with Drupal?

texts:
I have gone through the reading of this Backing up and migrating a site from which i know basically there are two parts to backup - keeping the Drupal folder and the dump of MySql.

I am not really planning to migrate a site, but want to create a development environment separate and then push it to the live site.

Apart from the link above, are there any best practices that are worth doing? What are the problems or pit falls that should i avoid? What tools works best?

Looking at the practical experiences people have been through which is not obvious.

PS: I am planning to host it in a Linux based environment.


texts: OpenDialogCommand how to include Buttons in dialog_options

texts:
How can I inlcude buttons in OpenDialogCommand?

$options = [
        'dialogClass' => 'my-dialog-class',
        'width' => '700px',
        'buttons' => [
          'text' => 'Continue',
          'class' => 'btn-primary ok-button',
          'click'=> "function() { $(this).dialog('close'); }",
  ],
      ];

      $response->addCommand(new OpenModalDialogCommand($title, $content, $options));

This seems not to work. The class is set, but no buttons are shown.


texts: View shows different data to administrator users and anonymous users

texts:
I have created a simple page that only shows JSON. The issue I have is that administrator users and anonymous users see different data.

I assume this is a cache problem, but I am not sure, nor am I sure how to fix this.
I am new to Drupal but I was able to find this settings page, which shows that caching is disabled.

Does anybody have an idea on what I can do?


texts: How do we pass php code as a twig variable in global custom text field of views

texts:
How can we pass this php code as a twig variable in global custom text in views without using views php module?

I have created a view of news content with masonary layout .

<?php
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$alias = \Drupal::service('path.alias_manager')->getAliasByPath('/node /'.$row->nid);
echo $language.$alias;
?>

I just want to render it as a twig variable in custom text field of views without creating template because i have already created a page long ago i dont want to rework by creating template.


texts: How to insert the node comments form into quicktabs?

texts: Im trying to insert node comments inside the quicktab, I can use views to list the comments and make the tab with it, but how to add the "Add comment" form to it ?


texts: Composer packages changed, even though same version used

texts:
I'm sorry, but in my project, composer update is changing files in my vendor directory even though I'm getting the exact same version of the libraries before & after.  I just want to ask, is this because the packages on packagist are changing, like a branch which is receiving new commits?  Or, is it that something is going wrong in my project?

I thought that if you use composer.lock to keep the versions exactly the same, no files should be changed.

We have kept our libraries versioned, is it possible that a developer modified them incorrectly?