texts: can't save search box configuration under themes>config

texts:
I made a custom theme based on Zen. In my custom theme (and under stock Zen theme as well) there is a problem with enabling my search form. When I tick the checkbox that says "search" box under admin>theme>customtheme>config>Toggle Box and click save, the page refreshes and I notice that the checkbox at "search box" is unticked again. Obviously this results in me not being able to show the search form.

Here's the code from my page.tpl.php file.

<?php if ($search_box || $primary_links || $secondary_links || $navbar): ?>

        <?php if ($search_box): ?>

              <?php print $search_box; ?>

        <?php endif; ?>


texts: How to validate a Ajax enabled views exposed form in Drupal 8. Tried with normal form validation but it only working on page reload not on submit


texts: Node access depending on boolean field in user profile

texts:
I would like to control access to specific articles or categories of articles depending on a boolean variable in a user's profile.

For example, this would be on a site where a user gets access to all kinds of data about their product after they purchase it. I would like to manually enable or "tick" a boolean field on their profile which then allows them to see the corresponding information when they browse the website.

I hope you understand what I'm trying to say.

I have already set up a few fields on the user profiles and I'm trying to make it work using the Rules and Content Access modules but I'm not sure if I'm heading in the right direction. I have thought about just setting this up with a "View" but I think the content would still be accessible to everyone by default if they have a link or through Google?

If someone could point me in the right direction, that would be great.
Thanks in advance!


texts: How to set up the database for load-balanced Drupal 7

texts: We currently run two Drupal instances (www1 and www2) behind a load balancer, and both instances are reading/writing the same mysql database. This seems like the wrong setup to me. Shouldn't we have it set up so that www1 reads and writes to db1, www2 reads and writes to db2, and db2 is a slave of db1?


texts: Webform give error if default language is deleted

texts:
Created a webform in language en-gb. Now as per project requirement, en-gb language not a requirement anymore. After deleting en-gb language, admin/structure/webform/manage/contact start giving below error.
Is there is way to fix this issue? Is there a way to change the default language of this route programmatically?. Currently, the default site language is 'FR'.
On debug, found that webform is trying to load original language and then try to call getName(). As the original language value is empty, getName() throw error.
The website encountered an unexpected error. Please try again later.
Error: Call to a member function getName() on null in webform_form_alter() (line 48 of modules/contrib/webform/includes/webform.form_alter.inc).
webform_form_alter() (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter() (Line: 838)
Drupal\Core\Form\FormBuilder->prepareForm() (Line: 279)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 91)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 57)
Drupal\Core\StackMiddleware\Session->handle() (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 91)
Drupal\shield\ShieldMiddleware->handle() (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 49)
Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 708)
Drupal\Core\DrupalKernel->handle() (Line: 19)


texts: How can I sort a product display view by product popularity

texts:
I'd like to sort a view of Commerce product displays by their popularity (not too bothered by the specifics of how this is calculated). I found a comment by Ryan Szrama that implies it could be possible with vanilla Views:

  The gist of it is going to require a View of Orders joined to Line Items via the "Commerce Line Items relationship" joined to the Products via the "Referenced product" relationship. You can filter by Order State to only see purchased products and then count the occurrence of each Product ID to get the most referenced products. The hardest part will be establishing a relationship from the Product ID to the product display, but I believe you can use the reverse relationship from the product ID to a node referencing it so long as you only have a single product display per product.

Unfortunately even if my Views-fu was good enough to do that, I'd like for this to be just one possible sort (ie you can sort by price, title, or popularity) so I'd like to avoid using a View of orders. Is there an existing Views sort handler for this floating around at all, or perhaps another clever way to achieve it?


texts: Installing/Enabling Custom Webform Hander

texts:
I am very new to Drupal development though I am an experienced developer.  I created a custom Webform Handler following these tutorials and postings:
These for what files to create and where:
Create a custom webform handler in Drupal 8
Create a Webform Handler that sends a notification to Slack
Add a custom submission handler to a form
This post for the code to redirect a user to another webform upon form submission:
Page redirect in custom WebformHandlerBase
I have looked at everything and everything looks correct.  Here's what's in the YAML file modules\custom\redirect_to_ccbilling\redirect_to_ccbilling.info.yml:
name: 'Redirect to CC Billing'
description: 'Provides a custom webform handler for the "submit an event" webform so it will redirect to another webform node'
core_version_requirement: ^8.8
Core: 8.x
package: Custom
type: module

Here's what's in the modules\custom\redirect_to_ccbilling\src\Plugin\WebformHandler\RedirectToCCBillingWebformHandler.php:
<?php
namespace Drupal\redirect_to_ccbilling\Plugin\WebformHandler;

use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Serialization\Yaml;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\src\WebformSubmissionInterface;

/**
 * Form submission handler.
 *
 * @RedirectToCCBilling(
 *   id = "Redirect to CC Billing",
 *   label = @Translation("Redirect to CC Billing"),
 *   category = @Translation("Webform Handler"),
 *   description = @Translation("Redirect user to the credit card billing page."),
 *   cardinality =
 *       \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_SINGLE,
 *   results =
 *    \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
 * )
 */

 class RedirectToCCBillingWebformHandler extends WebformHandlerBase {
 /**
  * {@inheritdoc}
  */
    public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {

       $form_id = 'webform_submission_' . $webform_submission->getWebform()->id() . '_form';
       if($form_id == 'webform_submission_xxx_form') {
         $values = $webform_submission->getData();
         /* Take the action based on the Webform submission values */
       }
    }

    public function confirmForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
       $form_id = 'webform_submission_' . $webform_submission->getWebform()->id() . '_form';
       if($form_id == 'webform_submission_xxx_form')
       {
          if(based_on_some_condition) {
          /* Here 12 is the node id where i wanted to redirect to */
          $form_state->setRedirect('entity.node.canonical',['node' => 1764]);
       }
    }
}
?>

I went into the Extend menu and under Custom section I selected the Redirect to CC Billing module/handler and clicked Install at the bottom of the page.  However, when I go back to my webform >> setting >> emails / handlers >> +add handler all I see is this:

I don't know what I am missing for my custom handler to not be appearing in the list of handlers.


texts: How to migrate content of one content type to another content type

texts:
I have two content types. Content type A and Content type B

I have some nodes of content type A and want to migrate them to content type B but the content of type A should remains in the system.

I have tried the node_convert module but it simply changes the node type of the existing content as the node ids remains the same.

Is there any other module or some hint to move into a custom solution?


texts: Display a key from unserialized data field

texts:
I really don't understand how the "User: Data" field works. Couldn't find any documentation of this.

I want to set the Display format to "A certain key" to output the identifier value from this serialized data (relevant snippet):

a:1:{s:10:"hybridauth";a:26:{s:10:"identifier";s:17:"76561198181833179";

When I enter identifier as key, I only get this notice and no output.

  Notice: Undefined index: identifier in views_handler_field_serialized->render() (line 60 of www/htdocs/****/sites/all/modules/views/handlers/views_handler_field_serialized.inc).

What do I have to enter in the "Which key should be displayed" field exactly, to display the identifier value?


texts: How to make translatable Blog Paths from Blog module using i18n?

texts:
Now I only have 1 line for all blog paths.
i need to set up own blog path for each language in multilingual site


texts: When a module has a composer dependency, should it be automatically installed when the module is installed?

texts:
Trying to resolve a debate - if a drupal site that is configured correctly installs a module with a composer dependency, should I expect the composer dependency to be installed automatically during the install?

The other person thinks that modules with composer dependencies have to be installed through command line to work, I think that if things were configured correctly it should happen on its own.

Does someone know how it should work?


texts: How to add multiple value using autocomplete widget

texts: We create a input field using user interface for add multiple languages .How i can add multiple language using comma separate so after comma they will populate other language.


texts:
For various compatibility reasons, I would like my usernames to be standard no-spaces combinations, so jbloggs / jdoe / etc. This becomes unsightly when displaying blogs ("jdoe's blog") or node authorship ("15/09/2016 jbloggs").

I've added first/last name fields to the account, but can't find a way to have them displayed by default instead of the username. I am on Drupal 8, so Profile2 isn't yet ready, which means this answer isn't an option. Likewise, this answer proposes using the "Real Name" module, which doesn't have a D8 version.

If it's any help, I would basically like the full name used in every display context, so if there's a blanket solution that would do that, rather than giving me control by node-type, that would be more than acceptable.

Lastly, if the above isn't possible without a module, can someone point me to some info on referencing account/profile fields in twig? That way I could at least override it in the most prominent places using templates.


texts:
How do I get the form id of my form? I've just begun to make my modules and I'm at a standstill. I got this code from someone else and am trying to customize it:

function hook_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'the form id for the node form') {
    $form['#submit'][] = 'my_custom_submit_handler';
  }
}


texts: Product catalog site (+ Store) - what strategy?

texts:
I'm creating a site in Drupal 7 with a 200-item product catalog. Currently the products have only informative pages for which I created a custom content type and taxonomy, but at some point, when the site owner gets ready, I may have to launch a store.

Taking into account that the only store available for D7 is Drupal Commerce in its beta (is my research correct?), I was wondering what strategy you would choose:

a) install beta of DrupalCommerce only for product information pages, turn off the shopping cart, just to save yourselves work later (migrating the product pages content)

b) go on populating the custom content type pages and wait for the DrupalCommerce to go into stable release?

c) split the site into two domains - informative (www.example.com) and store (store.example.com). This solution scares me off a bit in that it'd require maintaining about twice as much content in parallel - this always smells of errors and problems... OTOH, I could employ a Drupal-independent solution, such as PrestaShop.

Has anyone used the DrupalCommerce beta? Does it cause much trouble at this point?

Looking forward to hearing your insights.

Artur


texts: How to limit webform submissions access to only users who have Webform submissions?

texts:
I am using Webform for surveys. But I want to permit users who have submitted to see all results. In other words: to see all Webform submissions.

Any user can submit but no user can't see all results without submission.

Any ideas or suggestions?


texts: Two different versions of the same base theme in the same site

texts:
I'm wondering if it's possible to get two different branches of the same theme into the same site, both to be used as base themes.

Specifically I'm talking about Omega 7.x-3 and Omega 7.x-4 in the same site, but I guess the question applies to any theme.

Rationale: We're using Omega 4.x for the main theme (because of the nice front end stack), but for commerce sites (which this is), we also like to include Omega Kickstart as the admin theme. It's an improvement over Seven for very little work and clients seem to like it.

However, Omega Kickstart uses Omega 3.x as its base theme, and so conflicts with the newer version that's installed.

Short of taking a copy of one of the Omega versions, renaming it and all its internal functions, and then building a sub-theme from that, is there any way to get this sort of workflow?

UPDATE

Ok, er, so I made a bit of a mistake. I actually want to use the Shiny theme, not Omega Kickstart. Whoops.

But let's say I didn't, and definitely wanted to use Omega 3.x and 4.x in the same site...how might that go?


texts: Image upload in content type, no previous image is present

texts:
Oddly worded title, I know. I'm not sure how to phrase it or what to ask exactly.

In previous versions of Drupal if I added an image field to a content type, once an image was uploaded it was saved in a library of images and it was available without being uploaded again.

Currently in Drupal 8.5.4 that's no longer the case.

I'm given the option to either upload or embed but not to select from an already existing list of uploaded images.

This is more of a nuisance since I have to reupload images even if I want to use them on a separate content type.

I'm not sure if this is a bug or it has completely changed in this version.

Drupal 8 bug tracker doesn't offer anything relevant.

Any help is appreciated.


texts: Drupal Views: Create 3-Column Home Page with Taxonomy Terms

texts:
I am looking to create a 3-column home page design for my site that segregates 3 different items of a given taxonomy type (News, Training Alerts, and Advisories) into 3 separate columns. Each column shows not only the taxonomy term, but pulls the content associated with it (e.g. a teaser view of each item marked 'News').

I am not very familiar with Drupal themes, but currently I have been able to accomplish everything I've wanted with my site using the Bartik theme. Are there any ways I can accomplish this using Views and without having to change much about the Bartik theme? Or alternatively, is there a way to just create a table with PHP code that pulls the content associated with each taxonomy type into each column of a 3-column table?


texts:
I have two custom entities in a D7 site. One is 'additional' data on an entity, and I want to attach that data to the main entity every time it is loaded.

Within Entity/Entity API, how can I do that correctly? attachLoad sounded correct but seems to be Field related, all my data are not fields (yet).


texts:
Once I worked in a company that had its own CMS and we used to cache data in files so basically the system would check if the cache file existed, if not it would go to the database, get the data, save it in a file and then show it to the users (basic cache thing). This resulted in less connections to the database.

I would like to know if this is a good option to Drupal or if there is any problems with this way of caching things.


texts:
I am in the planning stage of a new project that will probably use Drupal 7 and one of the requirements of the new site is that existing MS Word templates can be merged with data from our database to create a Word document or possibly a PDF. Some of the templates are for labels and therefore the formatting is crucial.

I have looked for existing modules but the only one that I found that comes close is Webform Document https://www.drupal.org/project/webform_document. It however is in development still and appears to use a regular Word document that you insert tokens into instead of a template.

The functionality that LiveDocx provides is what we would like but it is hosted offsite (we need all hosting onsite) unless you are willing to pay $5000 (outside of our budget).

There are also solutions that use COM functionality but I am not able to have Word installed on the hosting server.

Another possibility is to convert all the Word templates to PDF forms and use PDFForms https://www.drupal.org/project/fillpdf but the 7x version has a dependency on PDF Forms API which is in development and does not appear to be very active. It also looks like the same form could not be filled out multiple times if you have multiple records returned.

What are your suggestions for a dependable solution?

Thanks,
Jbr


texts: How do I programatically add a Node to an Organic Group in Drupal 7?

texts:
This question and the documentation would suggest that the og_group function is the way to achieve this; however, calling og_group thus:

$values = array('entity_type' => 'node', 'entity' => $node);
og_group($gid, $values);
node_save($node);

Does not update the group_audience field on the node.

I'm referring to 7.x-1.3 of the og module; currently the only stable release on D7.

How can I go about programmatically adding a node to a group?

Thanks in advance.


texts: restrict user to libarary tab in media file selector in media module

texts:
I want use media file selector  as image field in content type . media module provides it to select and upload image by popup, but I dont want user can upload image ,I just want only user can select file from library tab in media file selector.
any body know how can I achieve this job?


texts: The Media module does not correctly render YouTube videos added with Media: YouTube

texts:
Trying to allow the user to embed YouTube videos from the Wysiwyg, CKEditor 3.6, Media: YouTube.

This is the module config :

Then I try to add a YouTube video by providing the URL link to the video or the embed code (iframe etc)

Both versions print this code which obviously won't render a video (url in src ?)

<video class="media-element file-default" controls="controls" data-fid="36" data-media-element="1">
  <source src="http://www.youtube.com/watch?v=qxeb0cwjE8U" type="video/youtube">
</video>

I'm a front end dev and not that much experienced with Drupal. I can provide every information needed.

Any insights ?


texts: How can I re-Install a site I pulled in from a git repo?

texts:
I cloned an entire site from git. I cannot install it.

Inside the foo.com/sites folder there are a couple folders. The settings.php file is in the folder dev.foo.com rather than the default folder.(I know this is how multisite is.)

I have added a line in my hosts file
    127.0.0.1       dev.foo.com

I have added a stanza to the http.conf file
    <VirtualHost *:80>
DocumentRoot /var/www/foo.com
ServerName dev.foo.com
    </VirtualHost>

Restart Apache - then I go to dev.foo.com - then I see the It Works! file created by apache rather than the drupal installer that I should see from dev.foo.com
How come?
2.. How can I use the database of the site I cloned? With Backup and Migrate?
EDIT: tried the site in a couple other browsers and I see this

Site off-line
The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.
If you are the maintainer of this site, please check your database settings in the settings.php file and ensure that your hosting provider's database server is running. For more help, see the handbook, or contact your hosting provider.

3...Looks like I need the database before trying to install? Yeah?


texts: How to replace the $title of one single page with a taxonomy term?

texts:
My setting here is like this:

I have a huge Druapl site here, and there's one single page that contains a views block displaying uploaded files with their taxonomy terms in a table. Title of this page is "Uploaded files".

Clicking on of these taxonomy terms calls the URL plus an additional query ?tid=123 applying a filter for that term on the table. So now only content of taxonomy tid 123 is displayed in the table and the URL ends with ?tid=123.

In that situation I want the title "Uploaded files" to be replaced by "Files of the taxonomy term 123", where 123 stands for the actual term connected to the tid 123. Let it be "To-Do-List".

Inside my theme's template folder I created a template file for that single page called page--node--nid.tpl.php, where nid stands for the actual node id of that page. I'm quite well able to manipulate the title of that page now when clicked on a term. At the place where the title is printed I can say <?php print $_GET['tid'] ?> and of course instead of "Uploaded files" it now prints the tid, here in my example: 123.

But how do I get the template to print the term instead of the id?

I know that there's a function called taxonomy_term_load to load the term connected with an id. But where would I call that function? And how do I pass maybe newly created $taxonomy_title into my page--node--nid.tp.php? Do I have to call some preprocess functions within the  tags at the top of my page--node--nid.tpl.php?

To make matters even more difficult, there are terms from different vocabularies. In my example it sets the query to ?tid=123, but when I click on a term from another vocabulary it sets the query to ?tid_1=234

I came so far on my own, but do really very much appreciate a helping explanation on how and where to use that function...


texts: replacing article or basic page image with video

texts:
How can I replace the main image at an article  or a basic page with a video?
I used the Video Embed Field module but it only embeds the video in the body.
What I need is the video to be in the place of the main image, not in the body of the content.


texts: Ubercart file downloads - group user's file downloads by product

texts:
Setting up a site using Drupal 6 and Ubercart (UC) to sell video downloads. I've configured UC as required to sell the file downloads and that all works. However, when a user visits their profile and views their file downloads, I need that page to display files on a per product grouping.

For example, a customer purchases product A, which includes three files. They then purchase product B, which includes two files. I need the user file downloads page to display the five files in two groups, Product A files and Product B files.


texts: My pager disappears when I use hook_views_pre_execute

texts:
I need to modify a query of one view. So, I use the hook_views_pre_execute.
The query is modified but the pager disappears.
My question is why? Do I need to add more lines to hook to use to display the pager?

Code:

function view_format_render_views_pre_execute(&$view) {

    if ($view->name == 'view_probe' && $view->display['block_1']->display_title =='List of categories') {
        $tid = $view->args[0];
        $tids = array_keys(taxonomy_get_children($tid));
        $tids=implode(', ',$tids);

         $search = "node_data_field_formatos_colecc.field_formatos_colecc_value = %d";
            $search_new = "node_data_field_formatos_colecc.field_formatos_colecc_value IN ( ".$tids." )";

            $query = &$view->build_info['query'];
            $query = str_ireplace($search, $search_new, $query);

            $view->build_info['query'] = $query;

        if (isset($tid) && isset($arguments)) {

                $query = str_ireplace($search_new, '', $query);
                $view->build_info['query'] = $query;
        }
    }
}


texts: Can I upgrade from Drupal 7.10 directly to Drupal 7.12

texts:
Should I upgrade from 7.10  to 7.11 first, then upgrade from 7.11 to 7.12?

Or can I just upgrade from 7.10 directly to Drupal 7.12?


texts: Ajax error while uploading or removing file through managed file

texts:
I am getting following error while using managed file through my custom form.

  "An Ajax HTTP request terminated abnormally."

Also, I updated my jquery version to latest using jquery_update module. Still no any benefit.

Any idea on how to solve it?

EDIT:

Code

  $form['path_image'] = array(
    '#title' => t('Image'),
    '#type' => 'managed_file',
    '#description' => t('The uploaded image will be displayed on the page unless it is marked as "removed".'),
    '#default_value' => $current_image,
    '#upload_location' => 'public://subpage_banner/',
  );


texts:
I'm using underscorejs function _.template() to render html on client side. I found that in many examples, the templates are placed in some

I try build a block to hold these tags, but drupal will break it, lost some tags eventually.

My solution right now drives me crazy: save the template as one line string or concat multiline strings with \ in js.

I really need a better idea. Thanks.

UPDATE:
I found a better idea, using coffee script raw string. From External template in Underscore


texts: Get the value of password confirmation field register

texts:
I want to use the default register form to get the value of the password confirmation field on register. If a user change his password it will call my API ans send the new information.

I can't find the ID of this field.

EDIT: I find the solution with

$confirm_pass = $form_state->getUserInput()['pass']['pass2'];

function alter_form_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
{
    if ($form_id == 'user_form') {
        $form['#validate'] = ['update_validate'];
    }
}

function update_validate(&$form, FormStateInterface $form_state, $tab = array())
{
  $values = $form_state->getValues();
  $password_conf = $values['#ID#'];
}


texts:
I'm getting a really strange issue. I created a module that uses a template file:

/**
 * Implements hook_block_info().
 */
function emed_newsletter_block_info() {
  $blocks['newsletter_signup'] = array(
    'info' => t('Newsletter Signup'),
    'cache' => DRUPAL_NO_CACHE
  );

  return $blocks;
}
/**
 * Implements hook_block_view().
 */
function emed_newsletter_block_view($delta = '') {
  $block = array();

  switch ($delta) {
    case 'newsletter_signup':
      $block['subject'] = t('');
      $block['content'] = array(
        '#theme' => 'newsletter_signup'
        );
      break;
  }
  return $block;
}
/**
 * Implements hook_theme().
 */
function emed_newsletter_theme($existing, $type, $theme, $path) {
  return array(
    'newsletter_signup' => array(
      'render element' => 'content',
      'file' => 'templates/newsletter.tpl.php',
    ),
  );
}

The template file just contains HTML.

The problem is that the text/html inside the template is being printed on every page at the top. Even on a drush cc all

Has anyone run into this issue before?

Core Version = 7.24


texts: Drush to get and print single node data in terminal?

texts:
I want to do a raw dump of a single node's data with Drush, for testing purposes and just to inspect a node fast.  Similar to getting a variable with "drush vget".  Here is a PHP equivalient:

drush php-eval "print print_r(node_load(243271), 1)";

Only, I'd like it to be simplified to be like:

drush nget 243271;

Is there a command like that already?


texts: How to trigger a popup window/overlay in my module?

texts:
I am stuck in my project. I am working on a module for account management page. When the user update their billing address, a service call will be triggered to send request to a third party API to get a response indicating if the address if valid or not. If valid then display the returned normalized address in a popup box or overlay, the user can choose if he want to use that address or not. My question is that how to trigger displaying this popup box in php code?

Thanks!


texts: Custom Top Admin Menu: Intergrating Permissions

texts:
Looking into build a top bar to be used for clients for quick access to edit/add pages. Big question I have is, how do you hook this into the Permissions module in core? Say if I want to allow another user to log in and assign this due to certain permissions.

Is this easily done? Or something a bit much?

function mymodule_preprocess_html(&$vars) {
  if (user_access('moderator')) {
    drupal_add_css(drupal_get_path('module', 'mymodule') . '/css');
    $my_links = array();
    if (in_array('manager', $vars['user']->roles)) {
      $my_links[] = array(
        'title' => t('Add new page'),
        'path' => '/location',
      )
      $my_links[] = array(
        'title' => t('Edit pages'),
        'path' => '/location',
      );
    }
  }
}

Seen some things used as below, but having issues...

function mymodule_permission() {
  return array(
    'moderator' => array(
      'title' => t('Use these top links'),
      'description' => t('Blah blah blah.'),
    ),
  );
}


texts:
In commerce guys demos store I toggled off the main menu in commerce kickstart template and have enabled the main menu block to stay on sidebar first block. I want to get a vertical main menu instead of a horizontal one like the demo store default installation.

Besides, I disabled the slide show content. I want to get the products of a specific collection to be displayed in front page. So I went to Site settings > configuration > System information and changed the default front page URL to collection/my-collection.

But the page doesn't display the main menu on sidebar first. The my-collection colletion is displayed but lose that tiny margins that wrap the products.

I follow this drupal.stackexchange post and tried to comment out the lines

function omega_kickstart_alpha_preprocess_page(&$vars) {
  if ($vars['is_front']) {
    unset($vars['page']['content']['content']['content']['system_main']['default_message']);
  }
}

in both profiles/omega_kickstart/preprocess/preprocess-page.inc and profiles/commerce_kickstart/preprocess/preprocess-page.inc, but didn't work.

Could somebody please help me?


texts: How to disable/turn off Automatic URL alias

texts: Could anyone suggest how to disable/turn off automatic URL aliases?


texts:
I got a notice to update composer to 2.0 today and gave it a try, using "composer self-update --2". Now when I run composer update, I'm seeing this message.

The "grasmash/composerize-drupal" plugin was skipped because it requires a Plugin API version ("^1.0.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option.

I then tried installing colorbox and see "drupal/colorbox": "^1.6" in composer.json, but it does not appear when I refresh the extend page; is this related to the above problem?
Next, I tried updating core from 8.9.6 to 8.9.7, following a message I saw, I tried composer update drupal/core-recommended --with-dependencies -W --no-plugins and now I see this message.
  Problem 1
    - Root composer.json requires composer/installers ^1.2 -> satisfiable by composer/installers[v1.7.0].
    - composer/installers v1.7.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
  Problem 2
    - composer/installers v1.7.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
    - signature_pad/signature_pad 2.3.0 requires composer/installers ~1.0 -> satisfiable by composer/installers[v1.7.0].
    - signature_pad/signature_pad is locked to version 2.3.0 and an update of this package was not requested.

I don't understand all these errors, and I am afraid to do anything else. How do I get out of this without reverting composer to 1.x?


texts: CDN module enabling "Far Future expiration" breaks whole site theme drupal 7

texts:
CDN module
Version:    7.x-2.6
component -- Origin Pull mode — Far Future expiration

I am using CDN module on drupal 7.22. We are using custom theme where adaptive theme is as base theme for all other users and "seven" theme for admin.
As soon as i check the "Far Future expiration" and save, whole site theme is breaking except admin theme.

And without checking "Far Future expiration" Iam facing http://drupal.org/node/1993600 issue.


texts:
Problem

I'm trying to locate a node using EntityFieldQuery. Using fieldCondition removes all of my search results. What am I doing wrong?

So Far

I've built my function using How to use EntityFieldQuery. It's running in a custom form submit.

function mymodule_form() {

   $query = new EntityFieldQuery();

   $query
     ->entityCondition('entity_type', 'node')
     ->entityCondition('bundle', 'contact_details')
     ->fieldCondition('field_user_reference_manual', 'value', '154');

   $result = $query->execute();

}

If I remove the fieldCondition query line it returns both contact_details nodes that I've created. One has field_user_reference_manual = 154 the other 140

The important values in my MySQL table are:

Field: field_data_field_user_reference_manual

Column: field_user_reference_manual_value


texts: Creating a temporary content type on the fly?

texts:
I want to create a temporary content type, and a node of that type, in code. It preferably should not live past page load. Can I do that?

For the reason to this very strange request, please see Using field widgets in non-field forms.

If you have suggestions for completely different solutions, then please take those to the linked issue, since this question is mainly a "support" question to the current answer to that question.


texts:
I want to keep field revisions: I want to see who changed a field to which value and when. Currently I can keep node revisions, but in the revisions tab, it only shows title and body changes.

How can I also keep field revisions?
How can I display revisions preferably like this:

User 1 changed Color: red to Color: green
User 2 changed Color: green to Color: white

Is the second one achievable by Views?


texts: prevent file upload renaming for each node

texts:
I would like to re-use some pdf files that doesn't change for my product content type and avoid to have by example:

node/product01-> product-datasheet-01.pdf

node/product02-> product-datasheet-02.pdf
...

but instead:

node/product01->|

                  | --> product-datasheet.pdf

node/product02->|

Already tried "File (Field) Paths" and "File (Field) Paths" modules but doesn't really fit on my needs because they works on single node.

Conf: D7+Ubercart3

thanks!
LS


texts: How can I simplify the use of flags with Views Bulk Operations?

texts:
I have an administrative display (made with views) that lists content that is pending approval.

In the case of my site, approval means flagging with the approval_for_pub flag (which triggers a custom rule).

VBO allows nodes to be flagged/unflagged all at once by clicking a handy button:

However, upon clicking this button, by default it shows all possible flags and the flag/unflag option:

This is a problem on my site because some of the people responsible for approval get confused by the names of the flags and select the wrong option.  So, what I would like to do is create a VBO option that, when the button is pressed, automatically flags all applicable content with the approval_for_pub flag.

How can I approach this?

It seems like a small detail, but this step happens several times a day, so the chance of making a mistake is quite high.


texts:
I have a Drupal 7 site running the latest Drupal Commerce and Paypal WPS as a payment method.  Everything is working correctly.  When a customer is checking out and can pick between Paypal and credit card, the radio button for the area that lists the credit card does not show up.

Screen shot attached.

I've checked and re-checked every possible setting.  Is there a way to disable the Paypal only button and enable the credit card and paypal option?  Or just get the radio button to show up so users can pick.

I've inspected elements and the input tag is not present in the html.

Any help or guidance is appreciated.


texts:
I have an index for a content type that has a taxonomy field attached.

I have a fulltext search up and running using the index, but would like to be able to filter the results additionally using tags.

If I add the taxonomy field to the index, it is added as an integer value, and the ID of the tag assigned is being indexed in Solr.

If, however, I try to add the field as a filter in my View, I get an error that there is no handler available.

What is the correct way to implement filtering by taxonomy term?


texts: How can I render more than one field value in the controller?

texts:
in my case i have a controller that it send for me the title , to the view , but i want to send the tittle and the body of the article both , i have tried to send them from the controller but it doesn't work for me
how can i send them both from the controller (title and body) ?

here is tmy controller

 public function myPage() {
    $data = \Drupal::service('myservice.ran');
    $dataService = $data->getArticles();
    return $this->renderMyPage($dataService);
  }
  function renderMyPage($articleObjects) {
    $articles = [];
    foreach ($articleObjects as $article) {
      $articles[] = [
        '#type' => 'html_tag',
        '#html_tag' => 'h2',
        '#value' => [$article->title->value,$article->body->value],
        '#cache' => [
          'tags' => $article->getCacheTags(),
        ],
      ];
    }
    return $articles;
  }


texts: How to add a class attribute to a block?

texts:
How can I add a class attribute to a Drupal 8 block?

There are many examples in Drupal core such as the help modules that sets the role attributes for the block. So following that I can succesfully add a class.

/**
 * Implements hook_preprocess_HOOK() for block templates.
 */
function mymodule_preprocess_block(&$variables) {
  if ($variables['plugin_id'] == 'mymodule_my_block') {
    $variables['attributes']['class'][] = 'my-nice-block';
  }
}

Is it possible to add a class without the preprocess hook?
Ideally within the block plugin file located in src/Plugin/Block/ ?

This would help keeping all the code related to one block contained in one location.


texts:
Is it possible to create a table like "tablename_mmyyyy" from my module using hook_cron?
db_create_table does not work. I need to create a new table every month.


texts: How to pass ckeditor settings to wysiwyg module?

texts:
I am using WYSIWYG module with CKeditor and custom module that enables image2 widget. Image2 widget are inserting images with height and width attributes in img tag. I need remove these attributes.
Ckeditor have feature called disallowedConcent (doc here) but I don't know out how to apply these setting to my custom modules. Solution is this snippet:

config.allowedContent = {
    $1: {
        // Use the ability to specify elements as an object.
        elements: CKEDITOR.dtd,
        attributes: true,
        styles: true,
        classes: true
    }
};
config.disallowedContent = 'img[width,height]';

But I don't know how to passed this to hook_wysiwyg_editor_settings_alter function.


texts: ul list with ajax items is not build correctly

texts:
I have an ul list, which is build with default items, depending on a dropdown value.
When I change the dropdown, the area with the ul should be replaced by ajax with new items depending on the selected dropdown value.
The problem is:
After replacing the div with the ul inside, the ul tag is opened and closed immediately, the li items are generated directly after the ul closing tag.
Here is some sample code:

 $drop_value=isset($form_state['values']['dropdown'])?$form_state['values']['dropdown']:$default_value;
 $form['images']['drop_area'] = array(
  '#markup' => '

        '.get_items($drop_value).'

',
  '#prefix' => '
',
  '#suffix' => '
',
);
function get_items($drop) {
  ...
  //builds li elements
  return $li_elements;
}

The ajax event is assigned to the dropdown.
The output is correct after loading the page with the $default_value.
After changing the dropdown, the li elements are generated correctly, but the resulting html looks like this:

item

...

Why do the li elements are generated outside the ul, although the function for generating the items is called inside the ul markup?
I also tried to declare a variable before the markup, holding the result of the get_items function, but this has the same effect...

Thx.


texts:
I have a site where Drupal generates rss through a view and then an external source uses that rss. Now the client says that I should remove the source from RSS. How can I remove the source from rss? See the source in image.
The source shows the url.


texts: Appending string causing link to render as plain html

texts:
The following code is returning html in plain text instead of link.for example its printing Edit slides intead of converting in to link.

$editslides = Url::fromUserInput('/admin/dexp_layerslider/'. $row->id . '/editslides');
      $editslides_link = (Link::fromTextAndUrl('Edit slides', $editslides)->toString());
      $exportslides = Url::fromUserInput('/admin/dexp_layerslider/'. $row->id . '/export');
      $exportslides_link =  (Link::fromTextAndUrl('Export slides', $exportslides)->toString());
      $deleteslides = Url::fromUserInput('/admin/dexp_layerslider/'. $row->id . '/delete');
      $deleteslides_link =  (Link::fromTextAndUrl('Delete', $deleteslides)->toString());
      $tmp[] =  $editslides_link .' ,' .$exportslides_link .' ,' .$deleteslides_link;

Though if i don't append string in $tmp[] code render the links. For example

  $tmp[] =  $editslides_link;

The complete code is as below

  public function dexp_layerslider_list() {
    $header = [
      'ID',
      'Name',
      'Action',
    ];
    $results = \Drupal::database->select('dexp_layerslider', 'd')->fields('d', [
      'id',
      'name',
    ])->execute();
    foreach ($results as $row) {
      $url = Url::fromUserInput('/admin/dexp_layerslider/'. $row->id . '/edit');
      $row->name = (Link::fromTextAndUrl($row->name, $url)->toString());
      $tmp = (array) $row;
      $editslides = Url::fromUserInput('/admin/dexp_layerslider/'. $row->id . '/editslides');
      $editslides_link = (Link::fromTextAndUrl('Edit slides', $editslides)->toString());
      $exportslides = Url::fromUserInput('/admin/dexp_layerslider/'. $row->id . '/export');
      $exportslides_link =  (Link::fromTextAndUrl('Export slides', $exportslides)->toString());
      $deleteslides = Url::fromUserInput('/admin/dexp_layerslider/'. $row->id . '/delete');
      $deleteslides_link =  (Link::fromTextAndUrl('Delete', $deleteslides)->toString());
      $tmp[] =  $editslides_link .' ,' .$exportslides_link .' ,' .$deleteslides_link;
      $rows[] = $tmp;
    }
    $table = array(
      '#type' => 'table',
      '#header' => $header,
      '#rows' => $rows,
      '#attributes' => [],
      '#caption' => '',
      '#colgroups' => [],
      '#sticky' => FALSE,
      '#empty' => t('No slider created yet.'),
       );
     return  $table;
  }


texts: Is there a way to add a Captcha to Ubercart?

texts: After some fraud attempts, I've been requested to add a Captcha to an Ubercart store in Drupal 7 and am surprised that in my searching I can't find any information on how to do this. Has anyone achieved this?


texts:
So, this seems like a rather simple task but I've been stuck on it for a while.

I need either in hook_node_presave or in hook_node_submit (but NOT in hook_node_validate) to check for a field value in a node and according to that value choose whether or not to cancel the node saving procedure.

How do I do that? (The canceling part, not the checking part ;) )


texts: How should I share sessions transparently across domains?

texts:
I work on a Drupal site which has multiple domains (not sub-domains) using Domain Access to set different themes, display different content, etc. on each of them.  These multiple domains are used for canonical HTTP URLs. Each domain also has a corresponding sub-domain of a common domain which is used with Secure Pages for HTTPS (there's a wildcard certificate). This all works fine.

My next step is to manage to unify the session between HTTP (on the canonical domain) and HTTPS (on the sub-domain of the shared domain). Many other sites accomplish this by redirecting back to their main domain to assign or discover the session cookie and redirect back to a "set cookie" script on the the current domain to set it there too.

A semi-serious search of D.O and with Google didn't turn up anything useful so I'll ask here: has anyone done this before in Drupal before? Is there a module or (more likely) a patch I can use and am I on my own here?

Thanks for any suggestions.


texts: Different Feeds Tamper per destination in mapping

texts:
I have a csv feeds importer I'm trying to build where I would like the last 2 digits of a code to be mapped to the task code field, but the full 4 or 5 digit number be mapped to the GUID.

From the interface I can only see a way to run the tamper on the source field for all destinations.  Is there some way I can tamp in different ways for different destination fields?  (or tamp for one destination, and use the raw value for another)


texts: Can we move a module from the directory "/modules" to the directory "/modules/contrib" without uninstalling it?

texts:
We have a Drupal 8 application which has modules directly in the directory "/modules" on the file system. I want to move a contributed module from the directory "/modules" to the directory "/modules/contrib". Do I need to uninstall the module before doing it?

Are there any steps that need to be performed before and after moving the module?


texts: Card declines with authorize.net when more than 1 numeric value in address field

texts:
I can't find any related issues reported in the commerce_authnet module, so I must be doing something wrong in the configuration of my site. At least once a week, sometimes a dozen times a week, a customer cannot complete their shopping cart order because Authorize.net declines their card for having an erroneous address.

After collecting months of data on this issue, it seems that when a second set of numerical values is entered into the address field, the information that is pushed to authorize.net is presented in the wrong format. For example, if you type in one of the following addresses, you would be declined:

21 8th Street

478 Commerce Way #4

6224 B Street Apt. 6

When the decline occurs, we receive the address information and enter it directly to the authorize.net portal, changing the "8th" to "Eighth" and moving the "Apt.6" to the second address line, and it works fine.

Can anyone help me understand how to adjust my configurations such that this is no longer a problem?

Or can you please give me an easy way to change the "Address 2" title to "Apt/Suite" in an attempt to circumvent the issues related to Apt/Suite?

Many, many thanks for any and all help!!

Edit: Drupal.org issue link: https://www.drupal.org/node/2545646


texts: How to stop Script Injection in field collection

texts:
I have created Field Collection with Text and image. Now if i insert  java script like

<script type="text/javascript" >alert("hacked")</script>

How to skip this
same i did for node body and title using hook_node_presave($node) and its working but for field collection it is not working.
Below is my code

function mydrupal_common_node_presave($node) {
  if($node->type == "test") {
    $node->title = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $node->title);
    $node->body['und'][0]['value']=preg_replace('#<script(.*?)>(.*?)</script>#is', '', $node->body['und'][0]['value']);
    if(is_array($node->field_activity_images['und'])){
      foreach($node->field_activity_images['und'] as $key => $value){
        $location= $node->field_activity_images['und'][$key]['field_location']['und'][0]['value'];
        $node->field_activity_images['und'][$key]['field_location']['und'][0]['value']=preg_replace('#<script(.*?)>(.*?)</script>#is', '', $location);
      }
    }
  }
}

I am using drupal 7.59


texts: Registration form customization to meet COPPA and similar "under 13" laws?

texts:
I want to add an extra field for user age. If age is below 13, it should show another text input for getting mail address of user's parent or other legal guardian. Accounts with age under 13 should only be activated after email verification by said parent.

How can I add this field, validate age and process validation mail?


texts: Theme suggestions not working for custom templates

texts:
I have a custom theme hook that I have a tpl for but my theme suggestions are not working. It appears that they are not even being looked for. I am guessing that I am missing something.

Code:

function MYMODULE_theme() {
  module_load_include('inc', 'mymodule', 'theme/mymodule.theme');
  return mymodule_theme_theme();
}

function MYMODULE_theme_theme() {
  $path = drupal_get_path('module', 'MYMODULE') . '/theme';

  return array(
    'mymodule_theme' => array(
      'variables' => array('module' => NULL, 'key' => NULL, 'body' => NULL),
      'template' => 'mymodule-theme',
      'pattern' => 'mymodule_theme__',
      'file' => 'mymodule.theme.inc',
      'mail theme' => TRUE,
      'path' => $path,
    )
  );
}

function MYMODULE_preprocess_mymodule_theme(&$vars) {
  $module = $variables['module'] ? $variables['module'] : basename(__FILE__, '.theme.inc');
  $functions = array();
  $variables['theme_hook_suggestions'][] = $functions[] = 'MYMODULE_theme__' . $module;
  if (isset($variables['key'])) {
  $variables['theme_hook_suggestions'][] = $functions[] = 'MYMODULE_theme__' . $module . '__' . $variables['key'];
  }
  foreach ($functions as $function) {
    $function = "MYMODULE_preprocess_$function";
    if (function_exists($function)) {
      $function($variables);
    }
  }
}

The theme hook suggestions are being applied as the new preprocess function works.

function MYMODULE_preprocess_MYMODULE_theme__MODULE__KEY(&$vars) {
  dpm($vars);
}

$vars gets printed.

However my MYMODULE-theme--MYMODULE--KEY.tpl.php is not being called.

The base MYMODULE-theme.tpl.php does work.
Theme debug output:

<!-- THEME DEBUG -->
<!-- CALL: theme('MYMODULE-theme') -->
<!-- FILE NAME SUGGESTIONS:
   * MYMODULE-theme--MYMODULE--KEY.tpl.php
   * MYMODULE-theme--MYMODULE.tpl.php
   x MYMODULE-theme.tpl.php
-->

Any ideas?

EDIT: I forgot the calls I have tried. Here they are:

$output = theme('MYMODULE_theme', array('body' => $body, 'key' => $key));

and I even tried:

$output = theme(array('MYMODULE_theme', 'MYMODULE_theme__MYMODULE__KEY), array('body' => $body, 'key' => $key));


texts: Use Token in contact form as default value

texts:
I have a contact form build from the drupal core contact forms.

I am trying to prefill some fields from URL GET parameters like this. /?foo=bar But it seems that "default value" doesnt support tokens.

I want to use something like this: [current-page:url:args:value:foo] in the default field of my form field.

But this gets just rendered as plain text.
Any help is appreciated.

EDIT: Working solution with form_alter:

function MY_MODULE_form_alter(&$form, &$form_state) {
  $args = \Drupal::request()->query->all();
  $form['field_test']['widget'][0]['value']['#default_value'] = $args['foo'];
}

Maybe there is a solution with tokens relating to the topic?


texts:
I've got content-type includes 'field1' and 'field2'. These fields are integer value.
Thanks to Views module I created page 'Page1' with contents. In main menu I've got search whit some filters. After filling filters and entering, we can see appropriate contents in 'Page1'. I'd like to create filters or fields in search to allow user to fill in 'min' and 'max' values. After it I want to choose a content only if 'field1' and 'field2' of that content is beetwen 'min' and 'max'.
How can I do it?


texts:
From time to time (and anytime after I run "drush cc all") my custom module with an access callback returns an 'access denied' error for Admins when they attempt to edit a user. I can solve this issue by disabling and re-enabling (any) module -- not just the one with the access callback code. If I remove this code, an admins ability to edit a user is fully and permanently restored. Here is the code in my custom module:

function cs_menu_alter(&$items) {
    $items['user/%/edit']['access callback'] = 'cs_user_edit_access';
}
function cs_user_edit_access() {
    global $user;
    if (!user_has_role(3, $user) || !user_has_role(4, $user)) {
        return FALSE;
    }
    else {
        return TRUE;
    }
}

I don't know why this code would suddenly stop working, but I don't really want to lose the functionality that this custom code supplies (most of the time).


texts: How do I pass a response from a Webform custom handler back to Drupal to display on the confirmation page

texts:
I have created a custom module for a custom Webform handler. The custom handler submits to an external SOAP api. There are various response options that are received back from the SOAP api that currently I am printing to screen (for testing purposes). But when using this module in production, I obviously want these responses to be displayed at the top of the confirmation page.

Is there some way to populate a token (possibly the Webform Handler Response token?), which I can then use to print the information on my confirmation page?

F


texts: Drupal 7 Teaser Image Block - no titles or other data

texts: I am setting up a pretty straightforward Durpal 7 site, so I am trying to keep things simple. I have an image gallery set up just fine. On the home page, I am trying to set up a block that simply displays 4 random thumbnails from the gallery. I only want the thumbnail images, but I currently also have the image titles, date posted, and posted by data. Is there a simple way to post only the thumbnails and not the other associated data? I have tried to strip down the teaser view to the bare bones, but still the other data are viewable.


texts:
I want to remove all the HTML code from the feed created using the Views module, since LinkedIn doesn't seem to like it that way it comes. I have seen the module clean links, but I'm running Drupal 7 and even with the patch I found I can't get it to work.
Is there any file I can edit and add "strip_tags" to get it to work?

Note, that Im the biggest newbie on Drupal, but I know my way around PHP.


texts: How to create multi-page node views in D7

texts:
I have a content type with user related fields that users can fill out, similar to a profile. I would like to split this node into a series of sub-pages/multipages and group fields together on each sub-page, rather than having all fields show as one huge node.

It's very similar to having tabs or a pager system but I don't want the actual tabs or pagers to be visible since I need to have my own links to each "tab"/multipage. I have tried to do this with Field Group module but it doesn't allow multipage groups in the node view (only in the node edit form). If I create Field Group tabs, that does split the node but then I have no way to hide the actual tab labels and (as far as I know) it is awkward trying to link to each of the individual tabs since they don't have a proper url. If it were possible to create additional local task tabs (after View, Edit) each tab would have its own url (node/#/edit, node/#/info, etc), and I could then hide, sort and rename the tabs very easily using Tab Tamer. But it's my understanding that there's no module with this sort of "add a local tab" functionality.

Is there currently a way to create multipages with D7, in the node view?


texts: getting URL from Route: breaks in localhost subdirectory

texts:
I just had a Drupal 8 site break when moving it from a top-level domain on a server to a subdirectory on my desktop machine: apparently that subdirectory wants to be included in the URL as converted from routes.  This threatens to ruin my sandbox environment so I would like to figure out 1) why this is happening and/or 2) what isn't portable about my code fragment below.  I've been using

Url::fromRouteMatch($route_match)->toString()

to get the URL Alias of the current page: e.g., the RouteMatch passed as argument to the breadcrumb service.  On the server, this returns a proper pathname relative to the top-level domain, for instance:

/dir1/dir2/dir3/myAlias

... but running the same code in my sandbox (http://localhost/mySite) includes the subdirectory name, as if Drupal is returning the URL relative my local web server's document root, instead of the root of my Drupal site:

/mySite/dir1/dir2/dir3/myAlias

I realise there may be better ways to get the current URL Alias (e.g., \Drupal::service('path.current')->getPath() and then passing it to \Drupal::service('path.alias_manager')->getAliasByPath, but I'd really like to convert the route itself since that's the argument to the breadcrumb builder in Drupal 8.

p.s., clarification, tentative answer: it is clear from comments below that the variable $base_path is expected to be used here, and that "base path" is how one refers to the name of the site subdirectory (if there is one). Neither of these were known to me when I submitted my question above and I can safely say they're not detailed in the Drupal 8 documentation either. Therefore the question becomes trivial: "How do I strip out that string from the provided URL?" and the answer is a matter of text processing:

global $base_path;
$route_url = Url::fromRouteMatch($route_match)->toString();
$alias_url = substr($route_url, strlen($base_path) - 1);

p.p.s., maybe a better answer: I think I know why comments suggest that finding the URL Alias from the request is the wrong approach, since the path.current service factors out any base path beautifully, without the gross string processing as above, and works fine in a breadcrumb builder:

$current_path = \Drupal::service('path.current')->getPath();
$alias_from_path = \Drupal::service('path.alias_manager')->getAliasByPath($current_path);

Sorry for all the fuss here: from my not knowing about the global variable $base_path or about how the Drupal services already deal with subdirectory installations.  Looking forward to the answer as expressed by other contributors with an eye on the big picture.


texts: How can I provide a checkbox to display name as 'anonymous'?

texts:
When users register on my website, they have to fill in their name. However, not everyone wants his/her name to be displayed on his/her profile page. Therefore, I'd like to provide a checkbox "Show as anonymous" during the registration which changes the name to anonymous on the profile page. In other words, the checkbox rewrites the displayed name, as opposed to Is there a way to let every user can choose (e.g. on registration) whether their field is private or public?, where the field is hidden.

I rewrote the profile pages with user_view in the Pages section and I'm using Panels.

How can I do that?


texts: How are contextual arguments specified explicitly in the URL?

texts:
The examples in contextual arguments simply call for specifying them with slashes without specifying the name of the filter, but if you wish to apply the second or third filter in the contextual link, what syntax should be used?
eg if there are contextual filters, on field_1, field_2 and field_3 and you want to ignore field_1 and field_2 in the URL, how do you write the URL for field_3 only?

Even if you want to apply only the first filter, but specify it explicitly in the URL, what is the syntax for it?

PS. When contextual fields for different fields are applied are they combined with OR or AND? are they


texts: Why is my taxonomy term name no longer outputting?

texts:
I have created a custom node with a field where you can select one tag from a list of a custom taxonomy term (location)

I was originally using this to print out the name of the selected tag for the node:

echo $field_location[0]['taxonomy_term']->name;

However it has since stopped working (it now outputs NULL). All I have done since is remove an unrelated field in the content type.

Now when i do a var dump of $field_location all I get is:

  array(1) { ["und"]=> array(1) { [0]=> array(1) { ["tid"]=> string(1) "1" } } }

Wheras before I had a load of extra stuff like the name of the tag etc...

Anyone have any ideas what's happened?


texts: I have a list of titles in a view block. But I never want the very first title of the view to display is this possible? I am using Drupal 7 with views 3.X


texts: Templating a View with "multiple fields"

texts:
I'm templating (modifying the .tpl.php files) of a View which has a field with multiple outcomes. This can be controlled using the "Multiple field settings" options. (see screenshot)

How I can achieve more freedom in templating it's look and feel? I know I can edit views-view-field.tpl.php file but that doesn't help much because that file has only a single line of code!

<?php print $output; ?>

Any idea how I can edit/modify individual fields of a multiple-field?

Screenshot:


texts: How don't I get HTML entities in menu tabs?

texts:
I'm setting up a group of tabs in (what I think is the) usual way.  One of these tabs has a title with an ampersand:

$items['user/%user/q-and-a/all'] = array(
    'title' => "Q & A home",
    'type' => MENU_DEFAULT_LOCAL_TASK,
    );

When the page containing this tab is rendered, the ampersand shows up in its entity form, i.e., Q &amp; A home.  How can I get this rendered on the page as a real ampersand?  FWIW, I'm not doing anything funny on the page template; it's a pretty stock page.tpl.php.


texts:
I am trying to render the form element below in telisim module but it's not working, no output (see the screenshot).

The telisim.module file looks as follow:

//hook_menu

function telisim_menu() {
    $items['simcodes'] = array(
    'title' => 'SIM CODES',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('telisim_examples'),
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

/**
* Implements hook_element_info().
*/

function telisim_element_info() {
  return array(
    'telisim_notepad' => array(
      '#input' => TRUE,
      '#process' => array('porta_teslisim_notepad_process_callback'),
      '#theme_wrappers' => array('telisim_inline_form_element'),
    ),
  );
}

function porta_teslisim_notepad_process_callback($element, &$form_state, $complete_form) {

 $element['#tree'] = TRUE;

  // Normal FAPI field definitions, except that #value is defined.
  $element['areacode'] = array(
    '#type' => 'textfield',
    '#size' => 3,
    '#maxlength' => 3,
    '#value' => $element['#value']['areacode'],
    '#required' => TRUE,
    '#prefix' => '(',
    '#suffix' => ')',
  );
  $element['prefix'] = array(
    '#type' => 'textfield',
    '#size' => 3,
    '#maxlength' => 3,
    '#required' => TRUE,
    '#value' => $element['#value']['prefix'],
  );
  $element['extension'] = array(
    '#type' => 'textfield',
    '#size' => 4,
    '#maxlength' => 4,
    '#value' => $element['#value']['extension'],
  );

   return $element;

  }

  function _telisim_element_theme() {
  return array(
    'telisim_inline_form_element' => array(
      'render element' => 'element',
      'file' => 'telisim.module',
    ),
    'telisim_checkbox' => array(
      'render element' => 'element',
      'file' => 'telisim.module',
    ),
  );
}

function telisim_examples($form, &$form_state){

  $form['a_form_example_element_discrete'] = array(
    '#type' => 'telisim_notepad',
    '#title' => t('Discrete phone number'),
    '#default_value' => variable_get(
      'form_example_element_discrete',
      array(
        'areacode' => '999',
        'prefix' => '999',
        'extension' => '9999',
      )
    ),
    '#description' => t('A phone number : areacode (XXX), prefix (XXX) and extension (XXXX).'),
  );

   dsm($form);
    return $form;
}


texts: disappeared comment fields in content type, how to put them back

texts:
I'm working on a drupal page and recently encountered a problem when I couldn't enable comments on a certain content type. Looking for the problem I found that there were no fields for the comments in that content type.

I checked the other content types where comments were enabled without problems and checked which fields were enabled for the comments.
I tried to enable the comments in the first content type by adding an existing field for comments, but the comment fields were not available to choose.

Here i attach an image of what it looks like on the drupal (It's in spanish but I hope you can get the context)

This is how it should look like with the comment fields:

Is there a way to retrieve this fields so comments can be enabled for this content type?


texts: Displaying fields from an entity reference of another entity's field

texts:
I have three content types: compositions, recordings and artists. Compositions have entity references to artists for the field composer.  Recordings have entity references to compositions for the field composer and to artists for the field recording artist.
This is what I want to do:

I would like to display a page with a list of all the compositions and their composer (entity reference to Artist content type).  No problem here.
I would like another field with the field recording artist (an entity reference field in content type Recording) that is being referenced by an entity reference for the content type composition.  This is the problem.

I think the main problem is I'm trying to call a field from an entity reference's entity reference.  Is there a way to build that bridge?


texts: Common reference field to search upon for taxonomy vocabularies

texts:
TLDR: I need a way to consistently name/search a field that is referencing the same term reference across multiple vocabularies.

I have several Vocabularies that all apply independently to a content type.  Within these vocabularies though, terms from certain vocabularies should only apply if its tagged with another term in a Term Reference field that has been added to the vocabularies.

For example:

Master Category (vocabulary)

Category A
Category B
Category C

Option Set One

Option A  (applies only to Category A)
Option B  (applies only to Category A and B)
Option C  (applies only to Category C)

Option Set Two

Option A  (applies only to Category C)
Option B  (applies only to Category B and C)
Option C  (applies only to Category A and C)

...and so on.  The specifics of what applies to what does not matter, but only that I need to filter vocabulary terms based on them being referenced to another vocabulary term, and they can be tagged with one to many terms from the related vocabulary.

I have set it up so that the other vocabularies have a term reference to the "Master Category" and I can tag it with one to many of those.  So far so good...

I can get lists of terms correctly based on this relationship using this Entity Field Query:

    $query = new EntityFieldQuery();
    $result = $query->entityCondition('entity_type', 'taxonomy_term')
        // vid is the specific vocabulary Im trying to search in this case
        ->propertyCondition('vid', $vid)

        // This is the term reference field.  I can filter by its referenced term ids
        ->fieldCondition('field_related_terms', 'tid', array(14, 15))
        ->propertyOrderBy('weight')
        ->execute();

    if (!empty($result['taxonomy_term'])) {
        // Load all terms
        $terms = taxonomy_term_load_multiple(array_keys($result['taxonomy_term']));

        foreach ($terms as $term) {
            $term_options_list[$term->tid] = $term->name;
        }
    }

Ok, so far this is all great.  $term_options_list contains all of the terms that have been tagged with the related terms specified in the query.

Now the problem:  This actually applies to a lot of different sets of vocabularies, and I need to perform the query above completely dynamically.  The issue is the machine name in the fieldCondition function.  Since I can't use the same name for this term reference on each vocabulary (can't duplicate machine names) and I won't know specifically which vocabulary I'm working with, how can I make a function which can perform the query above regardless of which vocabulary it's operating on?  I need to pass in the vid for the vocab to be searched, and the array of vid's that this term reference field needs to include, and get the results.

Hopefully that makes sense and it's not too long winded.  Let me know if I'm going about trying to do this in the wrong way all together.  Any advise is appreciated!


texts: How to make sure that panels classes are added to a CTools pane?

texts:
I am attempting to define a CTools content pane based on the tutorial here.  However, when I add my pane to the panel, no matter what region (left sidebar, header, footer) I add it to, it is printed at the top of the page without any of the region or pane CSS classes.

This is the function I am using to render the pane:

function MYMODULE_messagelimits_content_type_render($subtype, $conf, $args, $context) {
  if (!empty($conf)) {
    $block = new stdClass();
    $block->title = check_plain("");
    // Show message limits
    $block->content = MYMODULE_show_message_limits();
    return $block;
  }
}

MYMODULE_show_message_limits() is a function that prints out some information to show users what their messaging limits are, for example:

if ($sent_total > 1) {
  print '
';
  print t('You have already started conversations with 2 people this week.') . '
';    }
else if ($sent_total == 1) {
  print '
' . t('You can start a conversation with 1 more new person this week.') . '
';
}
else {
  print '
' . t('You can start conversations with 2 new people this week.') . '
';
}

If I make a change such as $block->content = t("my sample content"), then the pane is printed with the correct classes in the proper place on the page.

So how can I set the output of $block-content to be the output of my custom module's function while retaining the panels CSS classes?  Please help me stop abusing the PHP filter within Panels!


texts: Should the plain text filter convert line breaks into p and div elements?

texts:
I have a plain text field in a content type. When I hit return between paragraphs the line breaks are there and show inside of firebug when I inspect the code. However, the body on the view page doesn't render any line breaks. I looked at the plain text input filter and the convert line breaks filter is checked. When I change to filtered html in the settings form of the body widget it works fine.

Do have to use the filtered HTML setting to get the line breaks converted?


texts: Why are my prices showing up as unformatted (minor units) in a view on a search index?

texts:
Bit of an odd one here, I am experimenting with the Search API, Search DB and Views. I have a view based on Commerce Products. The view works, along with most of it's facets (but that's another story).

I'm running into a strange issue. I have a view based on a search index using Search API and Search_DB. I have access to all the fields that I indexed, but price is presented as the unformatted price in minor units. It is pulled in as "Indexed Commerce Product Price>> Amount (Price >> Amount)"

The issue I'm having is that it's displaying price as 98,000 rather than $980

Why is the formatting changing? and what's the right way to pull that info into my search view? D-Commerce wants the prices in minor units for it's own internal formatting. I have a regular non-search view which has the correct price...


texts: What causes very long initial visit load times intermittently?

texts:
I'm working on what is basically a one page site externally:

http://drupals.badgerfort.com.

There's very little to it. But I'm getting reports that it's sometimes loading so slow to the point that a couple refreshes are required to get it to load on first visit.  Now as this is such a small site, virtually every significant module is turned off.

I mean Update is off, Views is off, Date is off and on and on. In addition to that the few graphics are optimized. There's no external content integrated that could be causing it to hang that I can think of. CSS and JS are being aggregated. Caching is off, but it is a one page site, so on initial visit I wouldn't think caching would provide any advantage.

What are some of the potential causes of an issue like this?


texts: How to create an image gallery in Drupal 7

texts: I would like to create image galleries in my Drupal 7 site. Ideally the gallery should be easy to create and themable. What is the best way to do this?


texts: I am adding files to a file field in my node object.  Do I have to specify a path for the file(s)?  Can't I just add the files to the DB and just add the file objects to the node? I'd rather let Drupal care about the file system.


texts:
I have this simple ajax form with some ajax taxonomy checkboxes and a function that renders the content when the users changes the selected checkboxes. Everything work fine, the first time. The second time the user changes a checkbox I get this error:

Undefined index: form_build_id in ajax_get_form() (line 320 of /var/www/mf/includes/ajax.inc) and Invalid form POST data.

The only strange thing I've seen is when I inspect the request, there are a settings command, and ok insert command and another empty insert:

{command:insert, method:prepend, selector:null, data:, settings:null}

And in my html there is an empty .

My form:

function courses_lists_form($form, &$form_state) {dd(date('l jS \of F Y h:i:s A'));
  $terms = taxonomy_get_tree(1); // 1 = courses taxonomies vid
  $terms_array = array();
  foreach ($terms as $term) {
    $terms_array[$term->tid] = $term->name;
  }
  $form['taxonomias'] = array(
    '#type' => 'checkboxes',
    '#options' => $terms_array,
    '#title' => t('TEMÁTICAS'),
    '#ajax' => array(
      'callback' => 'courses_lists_form_ajax',
      'wrapper' => 'courses-lists-ajax',
    ),
  );
  $form['block'] = array(
    '#prefix' => '
',
    '#markup' => mf_form_commons_courses_lists_gen(0, 0, TRUE, 'matrix', array(0 => 9), ''),
    '#suffix' => '
',
  );
  $form_state['redirect'] = FALSE;
  return $form;
}

function courses_lists_form_ajax($form, &$form_state){
  $taxs = array();
  foreach ($form_state['values']['taxonomias'] as $tid) {
    if($tid) $taxs[] = $tid;
  };
  $outp = '
';
  $outp .= mf_form_commons_courses_lists_gen(0, 0, TRUE, 'matrix', $taxs, '');
  $outp .= '
';
  return $outp;
}


texts:
What is the preferred way to add functionality to nodes?
More explicitly stated: What is the node-entity equivalent of the Entity-class from the entity-API-module?

Sometimes you want to add methods to a entity. That is possible when using the entity-module, where each entity has a "entity class" property. You can take this entity class and extend it to your heart's content.

However, this is not possible with node-entities, since these don't use the "entity class" attribute.

So, the following code would work if drupal-core worked like the entity-module, but throws an error as is:

function myNode_entity_info_alter(&$info){
    $info['node']['entity class'] = 'MyNode';
}

class MyNode extends Entity{
    public function sayHi(){
        drupal_set_message("Hi!");
    }
}

function myNode_entity_load($entities, $type){
    if($type == 'node'){
        foreach ($entities as $entity) {
            $entity->sayHi(); # Error: Call to undefined method stdClass::sayHi()
        }
    }
}

How can I make this work with node-entities?

PS: as a follow-up question: is this any easier using drupal8?


texts: How to use User Points to buy/sell a custom content type?

texts:
I'm currently working on an educational project as a sort of final keystone project for my major in undergrad. The project is a online artwork trading game, in which students take on the role of being an art dealer/collector, and buy, sell, trade, and advertise artworks to each other on the site. I chose to use Drupal as a CMS due to its flexibility, but relative user-friendliness, as I won't be maintaining the project after my graduation in a few weeks.

I've polished off most of the site's features, with the exception of one, the currency system. At the moment, I have used the User Points module to create a virtual currency (guilders) for students to use when trading their artworks. I have also created the artworks as a custom content type. I am trying to make it so that students can buy/sell or just straight trade artworks between each other. I've attempted to install the Drupal Commerce module and pursue that route, which doesn't seem to be working. I've also tried making it so that students can manipulate node ownership, but it looked like that would create a permissions nightmare eventually, leaving me at a loss as of what to do. Due to the fact I won't be around to maintain the site, my original question of module recommendations really more is a recommendation of a solution that's not overly technical, and is fairly stable. My professor (who is an Art Historian) will be maintaining the project, and while he has taken an introductory computer science course, an astute programmer he is not.

TL;DR: I need a way for users to use userpoints to buy/sell a custom content type between themselves, and I need to keep the solution as stable as possible due to long-term maintenance concerns.


texts: Block images link to colorbox of clicked image on new page

texts: I want to have an Images Block, which when an image is clicked, links to a gallery page with the clicked image opened in colorbox. I'm using drupal 7.


texts:
Is the new Drupal 8 supported/certified by the Drupal community to run on PostgreSQL?

This is the top hit,

https://www.drupal.org/node/2157455

I don't really know what that means here in the Open Source part as the majority of support is MySQL (or so it appears).


texts: Trigger submission via Javascript when exposed filters are changed on a block display in Views

texts:
I have a View showing a list of nodes that has a block display, with AJAX enabled. It seems that that is required when you using exposed filters on a block display in 8.

What I want to do is autosubmit the form (where did this option go?) when a filter is changed. This is the jQuery I have tried:

    $('select[data-drupal-selector="edit-field-article-category"]', context).change(function() {
      $('input[name="sort_by"]').attr('value', 'created');
      $('form#views-exposed-form-blog-blog-listing input[data-drupal-selector="edit-submit-blog"]').trigger('click');
    });

    $('select[data-drupal-selector="edit-field-article-category"]', context).change(function() {
      $('input[name="sort_by"]').attr('value', 'created');
      $('form#views-exposed-form-blog-blog-listing').trigger('submit');
    });

    $('select[data-drupal-selector="edit-field-article-category"]', context).change(function() {
      $('input[name="sort_by"]').attr('value', 'created');
      $('form#views-exposed-form-blog-blog-listing').submit();
    });

In the first case, nothing happens. In the latter cases, the page reloads with the query string attached. Nothing in the view is filtered.

What am I missing?


texts:
I installed Drupal 7 on a web server and can;t access the root domain.
When I comment the following lines in the .htaccess file I can load the site without any problem:

<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$">
  Order allow,deny
</FilesMatch>

I don't want to comment the complete FilesMatch tag as I understand that it protects from unwanted access to files and server resources.

What should I change?


texts: CCK to Fields: content_migrate says missing widgets (image, matrix), but modules enabled

texts:
I am attempting an update from D6 to D7 on a site with multiple CCK types (yes, optimist me after reading lots of horror stories), I am following the CCK migration guide and have installed the cck module for D7. When accessing admin/structure/content_migrate to migrate cck to fields, I get the following warnings for all image and matrix type fields.

This looks like a bug in the migration code, but where to report to, CCK content_migrate, image or matrix module?

This is somewhat urgent as it affects the migration from d6 - d7 so I would be very grateful for any pointers.

Details below:

field_image   image
RNAi
Changed field type: The 'field_image' field type will be changed from 'filefield' to 'image'.
Missing widget: The 'image' widget is not available for the field_image field, it will be set to the default widget.

Edit: the same for the matrix module: "Missing widget: The 'matrix' widget is not available for the field_primer_group field, it will be set to the default widget."

But the image and matrix modules are both enabled:

 Core        Image (image)                      Module  Enabled   7.41
Fields       Matrix Field (matrix)              Module  Enabled   7.x-2.4

-- php is 5.3.3 (centos) and postgres is 8.4 if that matters.


texts: How to get field values of a just created (or not yet) node?

texts:
I am calling node_load() function in a custom module and it returns only part of the variables like title, uid, vid, status (all the meta), but it never returns actual field contents. I tried node_page_view(), tried menu_get_object() - all in vain, no field values.

What am I doing wrong? Is this because maybe my module is calling node_load() too early before the saving node, but then how it has already $node->title, $node->nid and other values? If they are some kind of prepared values, then how can I get the same prepared value for a custom field?

And here is the code from the Community documentation page Sending Notification Messages that I am using in my module:

/*
 * Implements hook_node_insert().
 */
function foo_node_insert($node) {

  $message = message_create('foo_message_type', array('uid' => $node->uid));

  $wrapper = entity_metadata_wrapper('message', $message);
  $wrapper->field_node_ref->set($node);

  $options = array(
     'rendered fields' => array(
       'message_notify_email_subject' => 'field_rendered_subject',
       'message_notify_email_body' => 'field_rendered_body',
     ),
  );

  message_notify_send_message($message, $options);
}

and it works just fine for the message subject, however for some reason I can't get node body to be mailed properly.

I tried to see the content of the $node variable in the following code from example module:

elseif (isset($message['params']['message_entity']->field_node_ref)) {
    // This is a node.
    $nid = $message['params']['message_entity']->field_node_ref[LANGUAGE_NONE][0]['target_id'];
    $node = node_load($nid);
    $messageid_params['uid'] = $node->uid;
    $messageid_params['nid'] = $node->nid;
    $messageid_params['cid'] = 0;
    $messageid_params['time'] = $node->created;
    if (variable_get('mailcomment_alter_subjects', 1)) {
      $subject = $message['subject'];
      $subject = variable_get('site_name', '') ? '[' . variable_get('site_name', '') . '] ' . $node->title : $subject;
      $message['subject'] = $subject;
    }
    dpm($node);
   }

and unfortunately my custom node field always returns empty:

field_description (Array, 0 elements)
$...->field_description


texts:
I am running Drupal 8.7.8

I've created a view and excluded my fields from display except for the last field for which I have rewritten the results to output all the replacement strings in a certain layout. Everything works fine except for the videos.

I have two videos {{ field_video }} and {{ field_youtube }}. Both replacement patterns do not render to the screen.

Any fixes for how to render them when rewriting the results of fields?


texts: Field Collection Value field is not deleting correctly(using programmatically)

texts:
I have installed a field collection module in my D7 site.
There is a multifield(unlimited) field collection with 3 field collection items.
I need to delete the field collection programatically.

i use

$field_collection_delete = $node->field_accommodation['und'][$j]['value']  ;
entity_delete_multiple('field_collection_item', array($field_collection_delete));

$j is a for loop increment value(0,1,2...) to remove field collection

but when i run the code the value in the field collection item deleted(deleted from the db table) but
the field collection field i added in the content type is still in the database as none value.

I need to delete that too programmatically.


texts: Autocomplete textfield displays value when selected and not label

texts:
I have a textfield autocomplete field that shows a list of full user names and email addresses as designed but when a user is selected, the user id is displayed in the field; not the name and email address.  This is the form element:

$form['people'] = [
  '#type' => 'textfield',
  '#placeholder' => t('Search by name'),
  '#autocomplete_route_name' => 'my_module.people',
];

This is the autocomplete handler in the controller:

public function handleAutocomplete(Request $request) {

  $query = $this->database->select('simplenews_subscriber', 'ss');
  $or = $query->orConditionGroup()
    ->condition('pa.address_given_name', '%' .$request->query->get('q') . '%', 'LIKE')
    ->condition('pa.address_family_name', '%' .$request->query->get('q') . '%', 'LIKE');
  $query->leftJoin('simplenews_subscriber__subscriptions', 'sss', 'sss.entity_id = ss.id');
  $query->leftJoin('profile', 'p', 'p.uid = ss.uid');
  $query->leftJoin('profile__address', 'pa', 'pa.entity_id = p.profile_id');
  $query->fields('ss', ['uid', 'mail']);
  $query->fields('pa', ['address_given_name', 'address_family_name']);
  $query->condition($or);
  $query->orderBy('address_given_name');
  $query->range(0, 10);

  $results = $query->execute()->fetchAll();

  $users = [];

  foreach ($results as $user) {
    $users[] = [
      'value' => $user->uid,
      'label' => $user->address_given_name . ' ' . $user->address_family_name . ' (' . $user->mail . ')',
    ];
  }

  return new JsonResponse($users);
}

The autocomplete textfield populates properly.  I just want the first name, last name and email address to show after a selection has been made.


texts: What's the class or id of the autocomplete suggestions pane?

texts:
I'm doing a form with a fairly standard autocomplete_path textfield, like:

$form['the_field'] = array(
    '#title' => t('A title'),
    '#type' => 'textfield',
    '#autocomplete_path' => "path/to/autocomplete",
    '#description' => "Some description."
);

It's working fine, but I want to do some styling of the suggestions that show up in response to the user's type-in.  I'm trying to track down the id or class of this pane so I can add some css or whatever, but I can't find it -- the various browser inspectors keep closing when I try to look at the pane.  Does anybody know what this is?  Thanks!


texts: Drupal form creating method without using a module

texts:
I am working on a Drupal site and it has a custom form in the frontend. I want to remove that form, but the problem is it is not generated by a custom module.

There is only one custom module. so I disabled it to check if that's the module generating the form. I cleared the cache also.

But the form is still there. So is there any other method of adding a form to a Drupal site without using a custom module?


texts: Sharing variables between node preprocess and page preprocess

texts: Both of my preprocess files use the $vars array. I assigned a new element to the $vars array in page preprocess but I can't access this variable in node preprocess. I tried doing it the other way around and had the same problem. How can I get around this?


texts:
I have a taxonomy term ID that I would like to generate the the URL alias for. In other words, instead of /taxonomy/term/{id} I would like to get the alias I have defined for this, eg: /some/path/myawesometerm.

How can I accomplish this?


texts: How do I get the entity ID when inserting a new node?

texts:
How do I get the ID of the inserted entity?

I am trying to use hook_ENTITY_TYPE_presave() and hook_ENTITY_TYPE_insert(), but in neither of those I can get the entity ID.

In hook_ENTITY_TYPE_presave(), I used the following code.

 if ($entity->isNew()) {
    print $entity->id();
 }


texts:
I have a few hardcoded links in a block on my homepage.

Info

But I want them to include the selected language.

e.g. Wen french is selected I want it to link to

Info

How can I do this?


texts:
I am new to Drupal and I am a bit confused right now.

I can't understand why 'reply' link is missing from here

any suggestions ?

Have read this, but no luck :(


texts:
After we deployed our website to production, the number of users is big, so the cache size is also too big (30 GB); I believe its created per user per page. Our website for now only contains public sections, so no need to cache it per user per page.

Is there an option or a configuration to enable caching per page only in order to reduce the total cache size?


texts: Prepopulating a multi-select on a webform

texts:
I have a webform with a multiselect box.  I want to use the prepopulate module to allow people to set the default value in the URL.  The following works, but it only supports selecting one value:

/mywebform?edit[submitted][multiselect_name]=Value

Other places have suggested using URLs like the following, but that doesn't work for either one URL or multiple:

/mywebform?edit[submitted][multiselect_name][]=Value

When I pass multiple URL parameters, it just takes the last one, so Value2 is selected in the following example rather than Value and Value2:

/mywebform?edit[submitted][multiselect_name]=Value&edit[submitted][multiselect_name]=Value2

As a workaround, I could define custom GET parameters for each item in the webform using the webform module, but I was hoping to make everything consistent, and as far as I can tell, webform doesn't support GET parameters that use array notation (as per http://drupal.org/node/824606), so neither of the following works as the default in the webform module:

%get[edit][submitted][multiselect_name]
%get[edit[submitted][multiselect_name]]

Thanks for the help!


texts: Is there a way in D7 that allows for multiple links in an image in a slider?

texts: Is there a way in Drupal 7 that allows for multiple links in an image in a slider?


texts:
is there a way to restrict content access to a specific subset of users upon node creation without having to create a specific user role and/or organic group?

For instance having a list of users to refer to upon node creation, and allowing ONLY them to view/visit/edit the node.


texts:
I'm attempting to display a data collection form inside of a lightbox on Drupal 7. The form is being generated with custom code.

Forms support for Colorbox 2.x has been removed according to the documentation. I went ahead anyway and installed colorbox2 and colobox_node; the form WAS displayed correctly. However, any attempt to process the form resulted in a page of garbage text.

Next attempt is lightbox2. That is a little more forgiving. The form was displayed correctly. And when "submit" is pressed, the form processes. However, if any validation occurs, (resulting in a redisplay of the form), the form is redisplayed outside of the lightbox.

Question is how can one display and perform processing of a form within a lightbox on Drupal 7?


texts: How do I get each taxonomy term associated to a node?

texts:
I'm trying to add a preprocess hook to add classes based on taxonomy name to the body css of my drupal installation.  I've managed to get all the information about the node based on doing some searching around and trial and error, but I'd like to take it to the next step and get all the taxonomy terms based on the particular node id.

The code I am currently using is the following.

function custom_preprocess_html(&$variables) {
  // Add the node ID and node type to the body class.
  $body_classes = [];
  $nodeFields =\Drupal::service('current_route_match')->getParameter('node')->toArray();

  if (is_array($nodeFields) && count($nodeFields) > 0) {
    if (isset($nodeFields['nid'])) {
      $body_classes[] = 'node-' . $nodeFields['nid'][0]['value'];
    }
    if (isset($nodeFields['type'])) {
      $body_classes[] = $nodeFields['type'][0]['target_id'];
    }
  }

  $variables['attributes']['class'] = $body_classes;
}

It works fine and pulls down the information regarding the node. Based on the answer here it seems like all I should have to do is add the following line to get the taxonomy terms: $taxonomyTerms = $nodefields->get('field_yourfield')->referencedEntities(); but when I do so Drupal throws an error. I'll freely admit I'm new to Drupal 8, so any suggestions about where I'm going wrong (is field_yourfield not something that exists, maybe?) would be greatly appreciated.


texts:
In drupal.org I would like to get email notification when an issue that involves me is updated with a new comment. Right now I have to subscribe per project from URL http://drupal.org/project/issues/subscribe-mail/[project-name] by clicking "own issues" checkbox. This is pain. Sometimes I fail to subscribe to a project and I get no follow-up comments in email.

Is there a page where I can enable it globally to subscribe to all my own issues as against doing it for individual project ?


texts: Drupal 7 in subfolder behind reverse proxy, login not working

texts:
I'm trying to run a Drupal 7.12 site behind an nginx reverse proxy, so that it shows up in a sub-folder to the primary domain (company.com).

Nginx is handling all incoming traffic to http://company.com, and Drupal is installed on another server with Apache. We want the content from Drupal to show up under http://company.com/drupal/.

For nginx, there is a proxy_pass specified like this:

  location /drupal/ {
    proxy_pass http://drupal.company.com/;
  }

For Drupal, I have set

$base_url = http://company.com/drupal;

This works fine to browse the content, Drupal is generating correct links, etc.

But when I try to login /drupal/user, I get the login form, but the action parameter for the form is set to "/user" - it seems that Drupal is forgetting to apply the base_url here.

Any ideas how to solve this issue? Help appreciated...


texts: how do i store fields in one table via the install file?

texts:
I am new to d7 and I am writing an install script.  This install script needs to create a content type (I've done that) and then create lots of fields that are used in this.

The problem I have found is that d7 automatically creates lots of tables for each field.  Considering I will have something like 60+ fields per content type, this isn't very practical.

How can I code into my .install file a way of making all these fields be in a single table e.g. |ID|value1|value2|value3|  instead of 3 tables for value1,2,3

Thank you.


texts:
What is the right or omega way of integrating print styles in omega 4?

I've found no references in the docs.


texts: How to set one variable for each link on a views un-formatted list

texts:
I'm trying to create a variable to put in a l() function. It's the $rellink below.

<?php print l('', "$rellink", array ('html' => TRUE)); ?>

I have a list of content nodes I'm displaying in an un-formatted view. I want $rellink to be the link for each of them. So on item 1, it's the link to item 1. On item 2 it's the link to item 2 and so forth.

In the unformatted.tpl.php file I can print out

<?php print $view->style_plugin->row_tokens[$id]['[view_node]']; ?>

Which will print the correct link. But I need this inside the link part of the l() function and when I copy and past it in, it doesn't work.

So the question is, what have I done wrong there or if that's not possible/bad practice how do I set-up a variable in my preprocess function that I can use instead?

I've tried this in the preprocess funtion:

$view = $variables['view'];
$rellink = $view->style_plugin->row_tokens['$id']['[view_node]'];

But it doesn't recognise the global $id variable and I get an un-defined variable rellink variable warning anyway.


texts:
I've been trying to set up a site on Acquia for a good 3 days now, and am baffled - Acquia doesn't allow Composer, the Acquia Dev Desktop does not sync libraries.  I've tried ludwig with no luck.

Is there any way to add csv/league libraries to Acquia? W/o this capability, I'm not sure how useful Acquia is, or am I missing something simple?


texts: Drupal theme IMG folder rewrite rule from vhosts conf file?

texts:
I am wondering if it is possible to create a rewrite rule in my vhosts config file for a site to remap the location of the images folder in the theme directory.

The scenario is that I don't want to create a whole new theme for on region of a multilingual site but given that the URL is different for this region I would like to remap for example:

sites/all/themes/theme/img/(.*) to sites/all/themes/theme/img_other/$1

I have tried some variations ion what I have just put there as the example but nothing is working as yet.

Any help would be much appreciated.

Thanks