texts: Alter existing 'Log In' route so URL includes request_uri as query string

texts:
I am trying to alter the existing 'Log In' URL so that it points to a certain location and also includes  the REQUEST_URI as a query string that is not encoded. How do I do this?
Based on this article, Altering existing routes and adding new routes based on dynamic ones and this SE answer I can change the 'Log In' URL so it points to a different location (/login). What I can't seem to figure out is how to add a query string that isn't encoded.
This code:
$route->setPath('/login?destination=' . \Drupal::request()->server->get('REQUEST_URI'));

Gives me:
/login%3Fdestination%3Dpage2

What I want is:
/login?destination=page2

I have looked into RequestContext::setQueryString and Route::addOptions but can't seem to get anything to work.
Full code:
<?php
namespace Drupal\myModule\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
* Listens to the dynamic route events.
*/
class RouteSubscriber extends RouteSubscriberBase {

    /**
    * {@inheritdoc}
    */

    protected function alterRoutes(RouteCollection $collection) {
        // Change path '/user/login' to '/login'.
        if ($route = $collection->get('user.login')) {
            //$route->setPath('/login');
            $route->setPath('/login?destination=' . \Drupal::request()->server->get('REQUEST_URI'));

        }

        // Always deny access to '/user/logout'.
        // Note that the second parameter of setRequirement() is a string.
        if ($route = $collection->get('user.logout')) {
            $route->setRequirement('_access', 'FALSE');
        }
    }
}


texts: Some feedback please on my hook_search_execute function?

texts:
I'm following along with Pro Drupal 7 Development by Apress (page 321) and using it as a guide to create a module that searches a legacy database of pages I've yet to import into a drupal install. I'm also using the API as a guide as well.

Everything works except for the number of results returned by dynamic query.  What happens is, despite having PagerDefault and using a limit of 10, only 1 item shows up on the page. I can switch the number to any number and it's still 1.

I know for a fact there are 240 items that should be returned. And, indeed my pager list 24 pages (24 pages of 10 results). Again, however, there is only 1 result per page for a total of 24 results.

Here is my function:

function searchharvest_search_execute($keys = NULL) {

    // Set up and execute the query
    $query = db_select('search_index', 'i')->extend('SearchQuery')->extend('PagerDefault');

    $query->join('url_data', 'ud', 'ud.id = i.sid');
    $query->searchExpression($keys, 'searchharvest');

    //If there weren't any results return a blank result set
    if(!$query->executeFirstPass()){
        return array();
    }

    //If the first pass returned at least 1 record execute the search
    $found = $query->limit(10)->execute();

    //dsm($query);
    print_r($query->__toString());
    //Create the search results output
    foreach($found as $item){
        //dsm($item);
        //get found items from db
        $note = db_query("SELECT url, stripped_html from url_data where id = :sid",
                array(':sid' => $item->sid))->fetchObject();

        $results[] = array(
            'link' => $note->url,
            'type' => t('searchharvest'),
            'title' => 'my title ' .$item->calculated_score,
            'score' => $item->calculated_score,
            'snippet' => search_excerpt($keys, $note->stripped_html),
        );

        return $results;
    }

Thoughts on where the error is? Here is a photo as well with the query 'print_r' 'ed at the top


texts: How do I alter the page title after a controller sets the title?

texts:
Is it possible to modify a page title after a controller sets #title in the main element?

Normally you can modify the page title by setting _title or _title_callback in the route. However it seems that you cannot alter the page title if a controller sets #title.

(A correct answer would affect both the HTML <title> and the system title block.)


texts: get taxonomy term aliased path when its a referenced field in a $node entity

texts:
what I have is a $node and know how to get its aliased URL but I also have a field field_category that I know how to get the name but how do I get the url alias for it

$nid = 1;
$node = \Drupal\node\Entity\Node::load($nid);
$options = ['absolute' => TRUE];
$nodeurl = \Drupal\Core\Url::fromRoute('entity.node.canonical', ['node' => $nid], $options);
$categoryname = $node->field_category[0]->entity->label();


texts:
I have installed the Views Bulk Operations module and am looking to use it to mass edit my content. However, when I select a few nodes to edit and select Modify Entity Values and click Execute, I get taken to a page that simply says, "The website encountered an unexpected error. Please try again later."

Unfortunately, my server logs and Drupal logs come up empty as to what error may have occurred.

Additionally, it seems like when I select Modify Entity Values, I should see an option for what entity value I am looking to modify but I am never presented with that option.

As an alternative, I found a guide that demonstrates how to replicate this behavior with Rules components but I have not yet been able to figure out how to make this work with taxonomy terms.

I would prefer however, to simply get the Views Bulk Operations to work as I would expect.


texts: Commerce orders view for user and his subusers

texts:
The task is to create a view which will contain all orders of user and his subusers. I use the Commerce Kickstart and Subuser module. I have default view called "My orders" which prints all orders of the logged in user.  I don't know, how to integrate the subuser relationship properly. How can I do it?

Added: this is the sample. it works only for one user. I need it to be worked for user and his subusers

The result should be the following: the one table like at the screenshot but with different (specified) users - the current user and his subusers...


texts:
Currently with the Privatemsg (v7.x-1.3) module it shows the user ids when sending a new message and I'd like it to show the user names instead. Firstly is there any problem with doing this?

Secondly the 'Send this user a private message' link is formatted as:

 /messages/new/3?destination=user/3

and if I change it to:

 /messages/new/user_name

the 'To' field on the write new message page does not contain the username. Is there a setting or module that would allow this.


texts: Constant Contact module puts subscribe checkbox on every user profile page

texts:
So, we are using the Constant Contact module to allow users to sign up for newsletters on our website. In the admin pages the module provides a 'Subscribe Method' option that let's you specify how users opt-in to the newsletter feature. We are using 'checkbox'.

This is all fine, except that we are also using user profiles, with multiple categories. When a user goes to edit his or her account details this 'subscribe' checkbox is appearing on every single category page, even when its totally irrelevant.

Is there some way we would be able to hide / remove this field from displaying anywhere other than the user's 'account' page?


texts: Display feed of two or more entity types in a single view (e.g. node & comments)

texts:
I'd like to create a Views Block that displays the latest nodes and comments in a format like:

User 1 posted [ContentType]: [NodeTitle] in [Term] 10 minutes ago
User 4 posted comment on [Node:Title] in [Term] 1 hour ago
User 1 posted [ContentType]: [NodeTitle] in [Term] 2 hours ago
User 1 posted comment on [NodeTitle] in [Term] 2 hours ago

The problem is I can only "Content" or "Comment" when creating a view.
Any sane way to go about this? Or can this only be done in code?


texts: Is it possible to post video on Facebook user timeline using Facebook Autopost module?

texts:
I need to upload videos to Facebook and I'm using Facebook Autopost and Rules module.

I've followed the video tutorials from:

Facebook Autopost
Drupal & Facebook : How to Post Drupal content on Facebook P 2/2
Drupal & Facebook : How to Post Drupal content on Facebook - Drupal 7, Drupal 8.

They teach how to post images and text but none mention videos. How can I upload videos with this module?


texts: For security reason, I want to delete the first user (which has all rights, event without the admin role) and login only with the drush uli command. How can I do that? From the backoffice it say I can't remove that user


texts: I have created a view in Drupal 7 that uses the node's content for display. I would like to add an edit link to this view that only displays if you are an administrator viewing this page. I know how to do this if I am using fields as the display type but not when the display type is set to content. How do I accomplish this?


texts: How to move a drupal 6 installation to a new server?

texts: I backed up my files and database. uploaded files to new server, created and restored the database to the new server, edited the settings.php file. I navigate to the site, it pops up perfectly. I try to navigate to any other page and I get a 404 page not found error. What am I missing?


texts: user can not view nodes of custom content type

texts:
I have created a user with the rights to view, edit and delete nodes of all the content types including some custom content types. On admin / content page it shows the list of contents of all content types except one custom content type.

little edit Its showing the contents of that content type when I am adding the content from that user but not showing the contents of that content type posted as user1

When we try to filter the contents to banner content type it shows no results, when we filter the contents to other content types including some custom content types it shows the filtered list.

I checked the permission for that content type for the user role which was not defined earlier but even after granting the permissions its not showing up.

After defining the permissions I have also rebuild the permission but the result is still the same.


texts: Respect parent's node access level (Book)

texts:
I was wondering if there is a way (using some hooks for example) so the child pages in a book respect their parents access level, meaning if user doesn't have the access to view the parent node, he won't be able to view the child nodes as well?

I use Drupal 6


texts: How do I get the global user object in hook_preprocess_page()?


texts: is it possible to manipulate manage_file field on validation

texts:
Using the form api, is it possible to manipulate the managed_file field inside the validation function. For example if the fid of the field is 15, I want to change it to 10.

It seems like it isn't because when I try the field's value disappears.


texts: Custom module block programmatically assigning it to a specific role

texts: I have a Custom module that implements a block how do I programmatically assign it to a specific role or roles in drupal 8?


texts: Is it possible not to use utf8mb4 as encoding?

texts: Due to an old version of libmysqlclient, we are stuck and can't deploy a completed site to our server.  The client does not support utf8mb4.  We have the datacenter who manages the server looking into the issue, but is there a way to make Drupal use the regular utf8 character set without hacking core?


texts:
I have a calendar of content type as a block. Currently clicking the date link opens the single day calendar view (from the Calendar template). Is it possible to display a view/list of events for the selected date on the same page? like this:

Thanks in advance!


texts: Unable to use Composer (for Drush) on Bluehost - install problem

texts:
I apparently successfully installed Composer (for use with Drush) on bluehost. See messages below. It does not work, however. When I type composer.phar I get nothing or "command not found" among other error messages. See below.

I am a newbie so it may be that install worked just fine, but I just don't know how to properly execute composer to make sure it works.

I am using instructions found at http://avantidevelopment.com/install-composer-on-bluehost/ & https://www.drupal.org/node/2366283.

columck5@columbiablooms.org [~/bin]# cd ~
columck5@columbiablooms.org [~]# mkdir ~/common
columck5@columbiablooms.org [~]# cd ~/common
columck5@columbiablooms.org [~/common]# curl -sS https://getcomposer.org/installer | /ramdisk/php/54/bin/php54-cli
#!/usr/bin/env php
All settings correct for using Composer
Downloading...

Composer successfully installed to: /home5/columck5/common/composer.phar
Use it: php composer.phar
columck5@columbiablooms.org [~/common]# which php-cli
/usr/bin/php-cli
PHP Version     5.4.24

columck5@columbiablooms.org [/ramdisk/php/54/bin]# cd ~/common
columck5@columbiablooms.org [~/common]# ls -l
total 1164

drwxr-xr-x  2 columck5 columck5    4096 Oct 29 08:37 ./

drwx--x--- 21 columck5 nobody      4096 Oct 28 09:15 ../

-rwxr-xr-x  1 columck5 columck5 1176136 Oct 29 08:37 composer.phar*

-rw-r--r--  1 columck5 columck5     575 Oct 29 08:38 error_log

columck5@columbiablooms.org [~/common]# composer.phar

-bash: composer.phar: command not found

columck5@columbiablooms.org [~/common]# composer
columck5@columbiablooms.org [~/common]# php composer

Status: 404 Not Found
Content-type: text/html

No input file specified.

columck5@columbiablooms.org [~/common]# php-cli composer.phar
columck5@columbiablooms.org [~/common]# php-cli composer

Could not open input file: composer


texts: Is it possible for a product to have 2 different titles. One would be displayed on full product page and the other shorter one on a grid product catalog.


texts: How can I implement a shopping cart limit?

texts:
Possible Duplicate:
limit items in commerce shopping cart

I`m using drupal commerce for my webshop, i want to limit products in the shopping cart which means when the user has a product in his shopping cart he must not be able to add other products.
Is it possible ?


texts: what are some considerations to help me decide whether I should configure through the UI, when to configure programmatically

texts:
I restarted a site I was developing realizing that I didn't have a systematic approach to design, namely, I was implementing changes through both the UI/database and module code and hooks without thinking about why I was doing so.

My question is:  what considerations should I take into account when deciding whether to make configuration changes through the UI or by coding a module?

Of course this only matters for things that you can do through both UI and module development like hook_menu, views, etc.   Here is my list so far:

Reason for UI:

Ease of integration: (e.g creating a new content type through a module is a pain compared through the UI)
Specific-config: if you don't plan on installing this configuration on multiple sites, UI should be sufficient.

Reason for module:

Versioning:  code can be versioned, when stored in the database it's not
Portability: if you plan on installing this functionality on multiple sites, then a module is pretty much a must.

Unknown:

Speed (database v.s. module code)?
I also find that if you need to use an .install file for something you don't plan on being portable, it seems pointless to add this to module code if it can be done through the UI. Is this right?
Other?

I'm very new to drupal development, but I'm just trying to make the right design choices. Any information you can provide would be helpful.

Thanks!


texts: Programmatically adding and removing users to a user reference field?

texts: I would love to see some code samples for this task. I have found this example already http://www.midwesternmac.com/blogs/jeff-geerling/programmatically-adding-or, but it is unclear why that example uses node language for array key, and based on the comment the user removal could be better as well.


texts:
I am a newbie into Drupal.

what else other than module name can replace 'hook' from any hook function in Drupal?
For ex.
"myModule" replaces hook in hook_form_alter and defined as 'myModule_form_alter'


texts: Is there a way to hide the price on display of a product when the stock goes to zero?


texts:
I am trying to find out what are set of modules, or what can be done to emulate a CPA system on Drupal?

if we look at for example sharecash.org, a user upload a file. for distribution, a user click on a file to Download, which sends him a pop up to fill in a survey. there are normally various surveys options and those surveys are geo-targeted. If I am in the US, I will have a US related survey to fill, the same applies if I am in other countries.

now after a user finished fill in a survey, there is a callback url which is redirected to the user to unlock the file for the use to download. well I still don't get the picture clearly, if they use cookies or Callback url, but I will stick to the later one.

I am trying to find how can I do the same thing on drupal?

so far, the important part is a user click on a file, he fills in a survey on an external site, the external site redirect the user to the drupal page with an unlocking url/code whatever mechanism. I will be grateful if you can please clarify this and how it can be achieved.

regards,


texts: How to get content with their taxonomy term name and id?

texts:
Hello I have created content type product. I also add Taxonomy with name "category". I add field in with term reference in product content type.
Now I want to get all content with taxonomy name and id which have  content type named "product" using query in Drupal 8 .


texts: Set field_id for views "Global: Custom text" field

texts:
I have a view with several 'Global: Custom text' fields. These are actually just serving as place-holders, and I'd like to create a field template file for each, that essentially places some custom html/php when it encounters these fields in a view.

Almost everything is in place and working... except, I notice that Drupal automatically gives the id of 'nothing', 'nothing_1' etc to its global custom text fields.  So, if I have more than one of these global text fields and would like to create a separate field template for each, I'm presented with a problem.

I'd have to name my template files views-views-field-nothing.tpl.php etc.  This is undesirable, because I want to reuse these field templates throughout my site.  I shouldn't have to worry about ordering these global fields just so in my views, so that the one I expect to be nothing is 1st and gets that id and the one that I expect to be nothing_1 or nothing_2 gets that id...

Has anyone run into this issue before?  Any ideas whether I can set my own field-ids for global custom text fields in views, so they don't all have those generated id's?   Is there a module that does this out there?  My searching hasn't found anything yet.

Thanks for any guidance!

p.s.  The reason I'm doing this is because I'm trying to put some html in my view (like <fieldset>) that is getting stripped from the views fields, so I need to do it in a template file.


texts: how do I add a favicon to RSS feed in Bitnami Drupal?

texts:
I have the Bitnami Drupal AMI that is on the AWS marketplace. I have set up a blog and it is being syndicated at another site.

Everything is working great (the Bitnami Drupal AMI rocks), but (you knew there was a "but") I see other blogs that are being syndicated and they have favicons.

How can I get a favicon into my Drupal blog's RSS feed so a favicon shows up when that feed is syndicated at another site?


texts: Initialize & override a Drupal7 jQuery module's (Superfish) provided .js, in code

texts:
I'm migrating a Drupal6 site to Drupal7.

The v6 site was subthemed in Fusion, and used its bundled Superfish menu js.  The init I used that worked was:

$(document).ready(function(){
 $("ul.sf-menu").supersubs({
  minWidth:    12, // min sub-menu width, em
  maxWidth:    27, // max sub-menu width, em
  extraWidth:  1,
 }).superfish({
  hoverClass: 'sfHover',
  speed:       0,   // ms, cref jquery animate()
  delay:       0,   // mouseout delay, ms
  animation:   {opacity:'none',height:'none'},
  autoArrows:  true,
  dropShadows: false,
  disableHI:   true,
 }).supposition();
});

In moving to D7, Superfish has been UN-bundled from Fusion, in favor of using the Superfish module for system-wide support.

I'm using the module's js in some custom markup, and need to init the module & override the module's defaults.

I understand that in D7, we need to init jQuery a bit differently.  My 'best shot' so far (which, unfortunately, is NOT working) at reproducting what I had in D6 is:

( function ($) {
        Drupal.behaviors.mySuperFish = {
            attach: function(context, settings) {
                $('.sitemenu-inner .sf-menu ul', context).supersubs({
                    minWidth:    12, // min sub-menu width, em
                    maxWidth:    27, // max sub-menu width, em
                    extraWidth:  1,
                }).superfish({
                    hoverClass: 'sfHover',
                    speed:       0,   // ms, cref jquery animate()
                    delay:       0,   // mouseout delay, ms
                    animation:   {opacity:'none',height:'none'},
                    autoArrows:  true,
                    dropShadows: false,
                    disableHI:   true,
                    dropShadows: false, /* Needed for IE */
                }).supposition();
            }
        };
    })(jQuery);

noting that the targeted div/tag has changed.

With this code in place, Firebug is showing me no errors; then again, I'm seeing no sfHover autoclassing, or any of my Superfish submenu functionality.

What am I still doing wrong here?


texts: Views throw an Ajax error in the admin page

texts:
When I go to a View edit page in the admin of Drupal 7, two of them (one that's called front page and was already there, and one that's a jcarousel) throw an error:

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /admin/structure/views/view/frontpagecarousel/preview/page/ajax
StatusText: error
ResponseText:

"ResponseText" is followed by a huge load of unformatted text (not even a newline character). But I believe that it must have something to do with the "Path", which I don't believe exists. I'm not certain, but I think this is interfering with jCarousel's options, as it expects something to appear in the Fields section, but the Fields section says "The selected style or row format does not utilize fields."

So, what's going wrong, and how can I fix it?


texts: How to change transition to fade on Boostrap Carousel module?

texts:
I have a boostrap carrousel view that works fine, but the slide show only has one option, tansition in milliseconds.

How can I change the transition to fade instead of slide? I've looked at the css code but it keeps moving, so hard to know what to change, additionally, it seems to be getting the css from boostrap.min.css ...

Site is at:

www.xuzo.com
carousel on home page


texts: Files in Media and Plupload module not showing in content selector

texts:
I've got the Media module installed along with Plupload. I go to the Media listing, click Add File, then I drop 3 files onto the Drag and Drop area. They show up correctly and I click Upload. They all upload correctly and the Media listing reloads and they all show up.

However, when I go to add Content and click Select Media to choose those files they are not listed.

If I go to the Media List, click Add File and then I use the File Selector to select those same 3 files and upload them that way... it works properly and I can choose them in the Content Select Media popup.

I've verified this on Chrome and Firefox. Am I doing something wrong? Has anyone run into this before? I'll post this as an issue on the Media module, but I figured maybe someone here had experienced this.


texts: Run second site in the same VM: Is it possible?

texts:
I would like to run all my Drupal 8 sites in one Vagrant VM instead of just one. Is this possible?

I tried to remove the default drupal site from the "web" folder and pulled(git) 2 of my current probject into it.

For any reason drush does not recongnize the drupal roots as proper drupal sites.

I am not sure how other modules react...  Is it normal to create each time a new VM for each Site you are developing. Seems a bit overkill.


texts: Profile2 and profile fields by user role

texts:
I have some profile fields created with the Profile2 module, which creates a main profile containing all the fields.
In the user/%/edit/main path, I see a new tab which displays a form to edit profile fields.

I have also three user roles, ( e.g. role A, B and C), and I want to remove that menu path for the role C. Alternatively, I want to restrict the access to those profile fields by user role.

Can I use the module Profile2 Privacy to achieve the goal?


texts: How do I use hook_views_pre_render in template.php in Drupal 7?

texts:
I have some auto generated data from my articles stored in a view(my_amazing_view). I also have a custom field in articles where user can enter similar data. If user has entered the data, i want to show that data. Otherwise I want to show auto generated data.

To do this, I want to implement hook_views_pre_render in my template.php file and target that specific view. I tried naming the function as my_amazing_view_views_pre_render as well as mytheme_views_pre_render and targeting that view but I am unable to do so.

How do I use the pre_render hook in my theme?


texts: View comments in admin area before approval

texts:
How can I view posted comments in admin area before approval?

I mean previewing comment INSIDE admin area not node's page.


texts: Using drupal_form_submit for pass-through to external login on click

texts:
I need a way for already authenticated users to be able to click a menu link and have a POST submitted to an external site, allowing them to be logged in automatically. This is kind of the opposite from many of the other SSO questions I've seen. I have no control over the other service. Here is where I'm at right now:

Created a module that registers the desired path as a page callback function
Added a menu link for that path
Added a form builder function to generate the necessary fields
In the page callback, I'm using drupal_form_submit to submit the form

I've verified that the form, when rendered, has the correct action and method parameters, and all the necessary fields, and when submitted manually, it works as expected, but when submitted programmatically using drupal_form_submit, nothing happens. I don't really have a way of knowing what the redirect URL should be, as it's controlled by the 3rd party site, so I can't use drupal_goto. Is there any way to have drupal_form_submit honor redirects from outside the site? I really don't want to have to use curl directly, if possible.


texts: Domain Access + Domain i18n = Site names not translating in other languages?

texts:
I have 4 languages and 2 domains: site.com site.eu
I set up languages in these domains like:

site.com - english (default)

br.site.com - brazilian

site.eu - german

fr.site.eu - french

When I try to type Site Name for french and brazilian it does not save the line. but it save Slogan.
So Drupal use default site name of default language for both Brazilian And French sites: br.site.com and fr.site.eu

this instruction did not help me http://reyero.net/drupal/internationalization_domain_access_multilingual_variables_for_each_domain

There are Realms information that I've found. But how to configure correct I do not know.


texts: How to provide pagename.tpl.php to specific page?

texts: I have basic knowledge of Drupal ,I know that if I am giving page name with .tpl.php file taht directly apply to that specific page .but to apply that I don't know so can you please help me ?


texts: What is the difference between using drupal_goto('$path') and header('Location: $path')?

texts:
I've been struggling a lot with a drupal_goto() not redirecting from a view to correct path in all displays.

This is the snippet code.

/**
 * Implements hook_views_pre_render().
 */
function HOOK_views_pre_render(&$view) {
  //if only on node matches, redirects to that node
  if ( $view->name == 'FOO' && $view->current_display == 'BAR' && count($view->result)==1 ){
    if(is_numeric($view->result[0]->nid)){
      drupal_goto('node/' . $view->result[0]->nid);
    }
  }
}

Instead, header('Location:node/' . $view->result[0]->nid); is working in any case.
Why doesn't drupal_goto() work, sometimes?


texts: How to define multiple cronjobs within single module?

texts:
What would be a good way to define two (or more) cronjobs without creating multiple modules?

As far as I know, in order to define a new cronjob, a hook_cron needs to be used like following:

function example_cron(){}

However, I have come to the point where I need to create new cronjob (in order to set different launch times using Ultimate Cron).

At first I looked at Ultimate Cron module and it's hook_cronapi hook as in documentation. However, that and other hooks doesn't really work - https://www.drupal.org/node/2842834

How should I implement it without creating additional modules and using hook_cron's?


texts: Import from feed using a selector only if it has a given XML attribute

texts:
I'm working on an import from an RSS feed that includes two types of XML <category> elements:

Subject Areas, e.g. <category>Economics | Social and Behavioral Sciences</category>
Keywords, e.g. <category domain="keywords">immigration, emigration, immigrants, international migration, poverty, immigration enforcement, asylum policy</category>

I want to import the Keywords as their own taxonomy field. I can write the YAML as follows, but it predictably imports both Keywords and Subject Areas:

source:
  fields:
    -
      name: keywords
      label: Keywords
      selector: 'category'
process:
  field_keywords:
    -
      plugin: explode
      delimiter: ', '
      source: keywords
    -
      plugin: entity_generate

How do I adjust the selector so it only pulls from the <category> element that includes the domain="keywords" attribute?


texts:
I changed my server and when I uploaded my site this error appeared:

  Internal Server Error
  The server encountered an internal error or misconfiguration and was unable to complete your request.
  Please contact the server administrator, webmaster@xxxxxxxx.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
  More information about this error may be available in the server error log.

  Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
  Apache/2 Server at xxxxxxx.com Port 80

I tried to upload it again without success. I tried uploading the index.html file without the drupal site, and it worked.

How can I solve this problem?


texts: How to rearrange fields in user/%/edit page

texts:
I have tried rearranging fields in user/edit page and I succeeded in arranging only few fields.

I cannot move user image field and timezone field. I have used hook_form_alter and $form['#after_bulid'] to rearrange field but not working.

This is the code

function MY_MODULE_form_alter(&$form, &$form_state, $form_id){
  $form['#after_build'][] = 'MY_MODULE_user_profile_form_after_build';
}
function MY_MODULE_user_profile_form_after_build($element, &$form_state) {
  $element['field_user_image']['#weight'] = '';
  $element['timezone']['#weight'] = '';
}

I have tried all weight from -10 to 10 but not working. Fileds should be arranged in the order as I specified in the screenshot. Can any one help me?


texts: Why does Drupal url alias field allow apostrophes and passes validation?

texts:
In the node creation form, when a user unchecks the "Automatic alias" checkbox, the user can put apostrophe and other punctuation marks, which is not good in a URL.

How can I prevent this from happening?


texts: Calling get_theme_setting from php-as-css file

texts:
I'm developing a Drupal 7 theme, and I'm using a php file as my theme's css file, in order to be able to use variables to simplify colour changes across the entire css.

I've also defined some theme settings in the theme-settings.php

What I want is to be able to call get_theme_setting() from within my style.php file, and use the theme settings to determine CSS attributes.


texts: What is the difference betweeen hook_validate and case 'validate' in hook_nodeapi

texts:
I am bit confused about hook_validate() and case 'validate' in hook_nodeapi(). Both do  validate a node.

Could anyone clear me the difference with a simple example that even a beginner can understand?


texts:
I create a menu , in call back of menu create add content form , add one submit function to it, but the function not  call NEVER . where is the problem?

 $items['share/%'] = array(
        'page callback' => 'ym_alter_sharing_content',
        //'page arguments' => array(''),
        'access callback' => 'user_is_logged_in',
        'type' => MENU_CALLBACK,
    );

function ym_alter_sharing_content($form,$form_state) {
module_load_include('inc', 'node', 'node.pages');
$nid=arg(1);
$form = node_add('share');
//$form['#submit'][]='ym_alter_sharing_sub';
//array_unshift($form['#submit'], 'ym_alter_sharing_sub');
//array_unshift($form['actions']['submit']['#submit'][], 'ym_alter_sharing_sub');
//$form['actions']['submit']['#submit'][]='ym_alter_sharing_sub';
array_unshift($form['actions']['submit']['#submit'], 'ym_alter_sharing_sub');
//return render($form);
return $form;
}

function ym_alter_sharing_sub($form,$form_state){

 //dsm($form_state['values']);
 var_dump($form_state['values']);
 die("kill for debugging");
}


texts: How do I move a Drupal site from WAMP server to a live server?

texts:
I'm a newbie with this so am having quite a bit of trouble. I've created a Drupal site in WAMP Server and am raedy to move the site to my hosting with Heart Internet.

I've copied C:/Wamp/www/mywebsite into a zip folder and uploaded/unzipped into my hosting space so the files are uploaded successfully.

I then went into phpMyAdmin on my computer and exported my database. I then created a blank database on my web hosting on the live server. this database username is c150-drupal and i generated a random password. I then clicked 'restore' on my new blank database and selected the database that I exported from WAMP. however I keep getting the error message below:

ERROR 1044 (420000) at line 22: access denied for user 'c150-drupal'@'%' to 'postcodedatabase'

I'm so confused how I should be exporting mysql databases in order to upload them to my webserver. Also is it acceptable to export a database from WAMP in order to use as a backup incase anything goes wrong so I could import the database back into WAMP?

Thank you,.


texts: I would like to know how to display a custom pagination in search results. By default drupal search is displaying 10 results but no pagination even $pager; is printed in search-results.tpl.php. I know this question is asked many times but I did not find the answer. Is there any hook implementation for custom pagination?


texts: Content Type - Image able to link to other website

texts:
I had create image field at content type. Without any views module or java-script, am I able create link to other website?

I am not using panel for my website. My question is ONLY related to CONTENT TYPE.

Example: When someone click on the image, it will link to www.google.com

Many Thanks.


texts: Allowed HTML tags in "Allowed value list" are not working

texts:
I'm working on a select list content type which is essentially check boxes with words on one side. The issue appears to be that the html tags I put in that are allowed are stripped out when I go to save. I checked both text formats and it appears that all html is allowed, Any idea where I can look to see why the html is stripped out of the list?

Edit:
The allowed values list has  tags and I also am testing with a  tag, when I save the settings and refresh the view that has these check boxes and text, the text doesn't change according to the html assigned to it. I've looked and text formats (WYSIWYG, HTML, and plain text) do not have the  "limit allowed HTML tags" check box checked. So I am not sure why the tags are being filtered out any ideas? thank you.


texts: I want to make a payment method, that works with web services. I made set of rules that decrease the money from the bank. at last the bank give me a code that it notices whether the payment is successful or not.for example 1 or 0. I want that if the code is 1 for example, Drupal thinks that payment is successful, and when the code is 0, means payment failure. and affect stock to decrease or increase by the returned code. how can I do that? is there any simple sample of on-site payment method ? thanks


texts: CKEditor/TinyMCE does not apper or show up at text fields

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

drupal 7

tinyMCE 4.5.1

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


texts: How to provide permissions to edit a Page Manager Page?

texts:
For our Drupal 7 site, I am tasked with creating a role for a non-developer end-user in our organization to manage a page we have that is provided by the Page Manager. By provided by, I mean that this page is not a node, and you can edit it by going to /admin/structure/pages.

I'm not really all that familiar with Panels and Page Manager, other than occasionally clicking through the UI to add something to a pane. I believe this is a panels page, but I am not sure.

Looking through the long list of permission, I see a lot of things that may or may not apply. At our organization, we have a policy to follow the least permissions necessary to do the job.

I would like to avoid trial and error as much as possible. How can I figure out which permissions an end-user would need simply to edit one page editable under admin/structure/pages/edit/my_random_page?


texts: Page Manager Error: The requested page "/xxxx" could not be found

texts:
I am working almost 4 hours on the following problem, and can't solve it (Drupal 7).

I tried to build a new simple page in the page manager as I did few times before.
I entered a simple path as /xxxx
Then, after I saved the page, and tried to load it, I got the following error message:

  The requested page "/xxxx" could not be found

Can somebody help me figure out why I can't create new page?

In addition, when I tried to disabled the page on the page manager, I got the following error:

  Notice: Undefined offset: 1 in
  template_preprocess_page_manager_edit_page() (line 42 of
  D:\MYSITE\sites\all\modules\ctools\page_manager\theme\page_manager.theme.inc

Does someone knows what is the problem, and how can I fix it?

Thanks!


texts:
I recently set up a local version of a remote site. The remote site is allowing me to create content fine, but for some reason the local version is throwing the following error upon save:

Drupal\Core\Entity\EntityStorageException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) ORDER BY users_field_data_2.name ASC' at line 4: SELECT base_table.uid AS uid, base_table.uid AS base_table_uid, users_field_data_2.name AS name FROM {users} base_table INNER JOIN {users_field_data} users_field_data ON users_field_data.uid = base_table.uid INNER JOIN {user__roles} user__roles ON user__roles.entity_id = base_table.uid LEFT JOIN {users_field_data} users_field_data_2 ON users_field_data_2.uid = base_table.uid WHERE (users_field_data.status = :db_condition_placeholder_0) AND (user__roles.roles_target_id IN ()) ORDER BY users_field_data_2.name ASC; Array ( [:db_condition_placeholder_0] => 1 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 770 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

This error also crops up on some admin pages, which seems to be related: Warning: Invalid argument supplied for foreach() in Drupal\Core\Database\Query\Condition->compile() (line 227 of core/lib/Drupal/Core/Database/Query/Condition.php).

I've done a handful of updates to the site since creating the local version but haven't tried creating new content until now, so it's hard to tell what started causing the error. Any suggestions on how to move forward with diagnosing this?


texts: can't find how to use Backup and Migrate module

texts:
I've installed the module and enabled it.. the brief readme instructs me to go to mysite.com/admin/content/backup_migrate but when I go there I just see the same content as mysite.com/admin/content/ how am I supposed to use this module?

Any idea what might be wrong?


texts:
In my user profile, I have some fields I want to alter. For my regular fields I use:

mymodule_form_alter(&$form, &$form_state, $form_id)

That works, but inside the $form there are some fields missing. Like for example the Timezone settings and the Private Messages. So fields from another module (like Private Messages) or standard settings. How can I alter those?

I tried a custom template file for the user profile and there I have access to those fields inside the $form. But I shouldn't altern them in a template file, right? So what would be the right approach for this?


texts: Prevent 'AJAX HTTP request terminated abnormally' Error at registration

texts:
I am getting the following error message when trying to register (using Drupal 7). Any idea on how to fix this?

This happens when trying to join here: http://test-caal.gotpantheon.com/

Thanks!

  An AJAX HTTP request terminated abnormally.
  Debugging information follows.
  Path: /modal_forms/ajax/register
  StatusText: n/a
  ResponseText: SMTP -> get_lines(): $data was ""
  SMTP -> get_lines(): $str is "220 endpoint7ae8d1b7.chios.panth.io ESMTP Postfix
  "
  SMTP -> get_lines(): $data is "220 endpoint7ae8d1b7.chios.panth.io ESMTP Postfix
  "
  SMTP -> FROM SERVER:220 endpoint7ae8d1b7.chios.panth.io ESMTP Postfix
  SMTP -> get_lines(): $data was ""
  SMTP -> get_lines(): $str is "250-endpoint7ae8d1b7.chios.panth.io
  "
  SMTP -> get_lines(): $data is "250-endpoint7ae8d1b7.chios.panth.io
  "
  SMTP -> get_lines(): $data was "250-endpoint7ae8d1b7.chios.panth.io
  "
  SMTP -> get_lines(): $str is "250-PIPELINING
  "
  SMTP -> get_lines(): $data is "250-endpoint7ae8d1b7.chios.panth.io
  250-PIPELINING
  "
  SMTP -> get_lines(): $data was "250-endpoint7ae8d1b7.chios.panth.io
  250-PIPELINING
  "
  SMTP -> get_lines(): $str is "250-SIZE 10240000


texts: How do I theme forms elements differently based on location of form

texts:
I am using MYTHEME_form_element to customize the markup around individual elements. For example I wrap everything in DIV's except checkboxes and radios.

Now I have added a login toolbar to the website. These input controls should not have DIV's around them. But given the context of the hook I cannot determine which form they are from so i cannot conditionally remove the DIV's around only the form elements in the login_block.

Any ideas???


texts: Avoid PDOException while connecting to an external database

texts:
I'm trying to connect to another database (not related to drupal) in drupal to show extra info. This database server could be down and is not a problem, if it's the case I don't want to show the info with no errors, maybe an info message that is now available at this moment.

I setted up the settings.php correctly with the database credentials, and when the database is up, everything is ok.

I use the next code

  db_set_active('external');
  $query = db_select('extra_info', 'i');
  ...

If the database is down, the db_select() fails and throws an PDOException. The problem is the website is down in that case, shows the error and so on. I tryed to sorround it in a try catch.

  try {
      db_set_active('external');
      $query = db_select('extra_info', 'i');
      ...
  }
  catch (PDOException $e) {
      // Ok.. is not a problem
  }

I don't know if there is a way to check if the database connection is ok first and then do the select or do nothing if is there is a problem and continue showing the website.
I tried the isActiveConnection() function, but I think is not what I need.

Thanks.

EDIT: The solution to my problem is to use db_set_active() back to default.

  try {
      db_set_active('external');
      $query = db_select('extra_info', 'i');
      ...
      db_set_active(); // This won't be executed!
  }
  catch (PDOException $e) {
      // Ok.. is not a problem
      db_set_active(); // Needed!
  }


texts: How to set password strength indicator on password_confirm element

texts:
How to add the Drupal password strength indicator to a custom password_confirm fapi element like this one :

  $form['pass'] = array(
    '#type' => 'password_confirm',
    '#required' => TRUE,
  );


texts:
i'm testing zen 5.x and zengrids in subtheme, and images size doesn't adapt on mobile for example.
So what i need to do ?

thanks


texts: How can I check for a specific directory in my URL? I need to display an image if I'm in http://www.mywebsite.com/displayimg/mypage but not if I'm in http://www.mywebsite.com/mypage... would it be something involving drupal_get_path?


texts: Hook_init() and Hook_exit not triggering in template.php

texts:
I have implemented hook_init and hook_exit in template.php

<?php
/* Alter variables */
function mytheme_exit(){
  var_dump("template Hook exit called");
}

/* Alter variables*/
function mytheme_init(){
  var_dump("template Hook init called");
}

When I cleared cache, loaded the page, it didnt print anything
I would really appreciate any help from you guys since when I implemented the hook_init and hook_exit in a custom module , it did work. Does these hook not work in template.php??


texts: I am trying to learn the principals required to make a Drupal 7 math/calculator module that simply takes user's inputs and does some math on them and then displays the results on the same page without a page refresh.


texts: How can I sort a view based on a rewritten field?

texts:
I have a view of a content type that contains two different date fields (one with date repeats and one multivalued single dates). Only one date field is filled out at any given time. In the view's display, I have combined the two fields by hiding the first date field and rewriting the second and including the replacement token of the first and second. Is there any way to now use the rewritten field to sort the view in ascending order based on this combined date field? It appears it sorts it based on the original value of the date field.

I have done my research and have only found old, somewhat-related, threads with dead-ends.

views sorting by rewritten field?

Table does not sort on rewritten field, but on original field

Views: custom field for sort criteria

Sort by global:custom text. Is it possible?

I was hoping there is a new or sneaky way of making this happen.


texts: how to select a non-drupal (souce db) database in a migrate module

texts:
can i still use a db_select(); if my source database is a non-drupal site? how can the migrate module know what database im referring? i cant see any configuration for migrate module on how to change database selection.

$query = db_select('sourcedb.brands', 'b');
$query->addField('i1', 'foreign_key', 'foreign_key');
$query->addField('i1', 'locale', 'locale');
$query->addField('i1', 'content', 'brand_description');
$query->addField('b', 'name', 'brand_name');
$query->addField('b', 'owg_id', 'owg_id');
$query->join('sourcedb.i18n', 'i1', 'i1.foreign_key = b.id');
$query->condition('i1.locale', 'spa', '=');
$query->condition('i1.model', 'Brand', '=');
$query->condition('i1.field', 'description', '=');
$query->orderBy('i1.foreign_key', 'ASC');

is the "sourcedb" in 'sourcedb.brands' a keyword in drupal? or can i replace it directly with the table name?


texts: How to block uninstalling a module if some content refer to its configuration?

texts:
I have made a module that create a paragraph type, by adding yaml files in the config/install folder
Once installed, i have created some node contents containing nested paragraphs using the one provided by the module.
Those yaml files contains the module dependency, allowing to delete the configs when uninstalling the module.
dependencies:
  module:
    - my_module

When uninstalling the module , my node contents pages are not loadable, nor the edit page.
Call to a member function getEnabledBehaviorPlugins() on null in Drupal\paragraphs\ParagraphViewBuilder->buildMultiple() (line 37 of modules/contrib/paragraphs/src/ParagraphViewBuilder.php

How to ask to delete the associated content on the module uninstalling confirmation page ?


texts: How to move a form field inside a container

texts:
I have a "Birthday" field and the "date" module automatically adds the countainer around it.

Now I'm adding another field "Show Birthday". How can I display that field within the container?


texts: How to add images (as entity) in ckeditor?

texts:
The background: I'm creating an asset management system with Drupal, so for this purpose I've created a content type called Image which has an image (widget) attached to it. I then use module Entity Reference to link this content type with other content types (for instance, Article).

So far so far. This works for my requirements, however I'd like to:

1) Add the ability to upload a new image (therefore new node) from within Article
2) Use an existing entity (previously created) within CKEditor in Article

Is it possible? How?


texts:
To access the site, all users (except the logged-in users) need to pass through an age gate. They can only leave the welcome page if they are 18 years or older.

I started by adding a session to my custom theme.theme file.

<?php

function scottishleader_preprocess(&$variables, $hook) {
  static $hooks;

  $route_name = \Drupal::routeMatch()->getRouteName();
  $response = new\Symfony\Component\HttpFoundation\RedirectResponse('/welcome');
  $session = \Drupal::request()->getSession();
  $session->set('initialSession', 'initial');

  if ($session->get('ageGate') == 'passed') {
    $session->remove('initialSession');
  }
  if ($route_name != 'agegate.route' && $session->get('initialSession') == 'initial') {
    $response->send();
  }
  if ($route_name == 'agegate.route' && $session->get('ageGate') == 'passed') {
    $homeRoute = new\Symfony\Component\HttpFoundation\RedirectResponse('/');

    $homeRoute->send();
  }
}

Next, I created a custom module for the age gate and the routing.yml looks like the following.

agegate.route:
  path: '/welcome'
  defaults:
    _controller: '\Drupal\agegate\Controller\AgeGateController::content'
    _form: '\Drupal\agegate\Form\AgeGateForm'
  requirements:
    _permission: 'access content'

The AgeGateController class renders a form.

class AgeGateController extends ControllerBase {
  public function content(){
    return \Drupal::formBuilder()->getForm('Drupal\agegate\Form\AgeGateForm');
  }
}

It was all working fine until I realized that, if I am logged and I try to access the front page, I get redirected infinite times!

So, for some reason, my code only works on users that aren't logged-in.

How can I create this age gate functionality?


texts:
I am making a website for a museum that involves a questionnaire. I made this questionnaire with the webforms module, which in turn sends the answers to another page to be processed. The people at the museum do not know drupal, let alone php. So when they want to add questions to the questionnaire, it has to be done by me. This is because I also need to change the values that are passed on the next page (via the redirect URL in the webforms module).

To automate the process for them (they probably know enough to be able to add new questions), I wanted to know if there is any way to pass on all the answers from the webforms questions, so that they do not have to fiddle with the php? This way, all answers will be sent, regardless of the questions on the webforms. The page that receives the values has been coded so that it takes any amount of URL-parameters; You do not have to find a way to do that.


texts:
Just looking for more experienced drupal developers to steer me in the right direction, it's kind of a basic question:

What is the best way to design the content of the pages, as in, I have the page templates done (front/sub-pages), now I have a bunch of informational sub-pages that I have to design the content for. I thought I could just populate them using the wysiwyg editor, but starting to realize that has limitations. So what's the protocol?

thanks


texts: Use default menu links in multilingual site

texts:
I have a Drupal 8 site with Greek and English installed, where Greek is the main language. I have only translated some of the pages in English.

I have a flag to change the language in these translated pages, but when you see the English version, you also see the Greek menu. Instead of the original links in the menu, you see the auto translated nodes that have been created.

I want to use the default Greek menu. When I click on menu links, I want that link to take to the Greek page, not English.

I have searched enough, but everyone has the opposite problem and cannot create a new menu. I just want to use the same, with the same URLs.


texts: entity ref shows on node, but not when node is set as home page

texts:
I suspect I may just have a simple misunderstanding of how a home page is generated, but...

In a Drupal 8.7.5 website, I have a node (basic page) that I've added a paragraph entity reference field to.
in the node.html.twig, I added the field, like so:

{% if content.field_content_section %}
    {{ content.field_content_section }}
{% endif %}

When I view the node, at website.com/node/1234, everything shows fine.

This page is also set to be my home page. If I go to website.com, the field_content_section does not appear.

I don't have any custom templates for the home page.
html.html.twig just has {{ page }}

page.html.twig just has {{ page.content }}

I'm sure there's just some simple detail I'm missing or not understanding about how to get that entity reference field to appear on the home page (without using views to do it)

I suspected this may have something to do with an site glitch regarding language. It's something I need to resolve but can't yet. It prevents me from making paragraphs translatable... except, as I said, if I go to the node, I can see the content. It's specifically home page that doesn't work.

Hopefully that's enough information.


texts:
im trying to render/display a breadcrumb in a mini panel using both with text format 'PHP code' and 'Display suite code' but it display nothing. it works when i tried with common php code;

<?php echo date("Y"); ?>

but when i tried with

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

nothing is displayed. and

<?php var_dump($breadcrumb); ?>

return NULL.
meaning it cant read drupal variable right? any workaround for this?


texts: how to display all content for the people table

texts: How does one display all the data in the people table in a SQL or other statement? I would like to get a complete listing of the table(s).


texts: Publisher and Editor only without publishing rights role possible?

texts:
I want to have 2 user roles in the site:
one that can create content but not being able to publish
and the other just a supervisor that can (aprove-publish)


texts: how to get views field names/values for hook_views_pre_render?

texts:
I'm trying to figure out how to modify a view's results with hook_views_pre_render.
How do I get the available values to work with?
I've turned on Devel and Kint, but I don't see any array on the page that includes views stuff.

I've tried blindly finding fields using machine names, but it just breaks the page. I'm sure I'm doing the right thing, I have one field field_byline that I'm able to get just fine with a simple set() to see if I'm able to do anything.

Here's what I've got:

function webinar_rearrange_views_pre_render(ViewExecutable $view) {
  if ($view->id() == 'viewname' && $view->current_display == 'block_1') {
    foreach ($view->result as $key => $value) {
      $value->_entity->set('title', 'test title'); // worked
      $value->_entity->set('body', 'test body'); // worked
      $value->_entity->set('field_byline', 'test byline');
      $value->_entity->set('field_view_node', 'http://test.com'); // DOESN'T WORK - maybe it's an array? How do I do those?
    }
  }
}


texts: Remove home page navigation from logo at checkout

texts:
Usually users can go to front/home page from anywhere by clicking on the logo. But if I see some e-commerce site, they restrict it when we go for any steps of checkout.
I also want to do the same. If somebody clicks on checkout & URL form something like $base_url/checkout*, I want to remove home/front page navigation link from logo.
How can it be done ?


texts: Drupal 7 webform file field rules attachment

texts:
I have a webform where a user can upload a file; I want this file to be attached to the e-mail using the drupal rules module (https://www.drupal.org/project/rules).

I have installed all the required modules (rules, MIME mail, webform, ...)

I configured my HTML e-mail action in drupal rules. When I place a static link inside the attachment body: sites/default/files/some_file.pdf it works, but I want this attachment to be dynamic.

Everytime a user submits a file using the webform file field, drupal rules needs to send an e-mail with this file as attachment.

I tried using [data:{component}-value] but it gives me blank field in my e-mail.

How can I do this using the rules module? Not standard built-in attachment function from webform module. Thanks.

Update:

I am trying to use the following information: https://www.drupal.org/node/1431572

How can I combine this with my drupal webform file field? systemname of my field is 'logo'..

Also tried using: sites/default/files/webform/logos/[data:logo-value-html] in the attachment field of rules, but it gives blank email attachments...


texts:
Hiding a node field works great by default when the field is empty.

But I wonder how to hide a field when viewing a node if the value of a field is for example 3.

For now, I just need it for integer field.

Any suggestions?


texts:
Like the title says really, I'm trying to add a script to my register page, I'm using Zen as my theme, and I've added a script into the .info file, and to just test that it works I have added an alert() function, and it runs on just about every page except the default register page, and I don't know why, it just doesn't call the script at all.

The longer version is that I have a bespoke Drupal site, not intended for public use, just for specific medical personnel to use for an event we have coming up. What the client has requested is that the user must tick a box declaring they are a healthcare professional before they can register. I have added a boolean checkbox to my register form, and set it to mandatory, but obviously Drupal will accept either checked or unchecked, I want to make it so that they have to check the box before they can register (it's just a legal compliance thing)

I wanted to try to do it via Drupals methods only, but my backup was creating a js solution which would set the register button to disabled until the box was checked, except it doesnt seem to work on the register page.

Can this be done?


texts: How to show entityQuery results as block

texts:
I use entityQuery to retrieve nodes related to actual content. Now I don't know how to add them to template and show them in my theme.

In Drupal 7 I used Bean module to create blocks as entities. The module states the following, which I don't fully understand:

  As Drupal 8 supports fields on its block entities, this module is not
  needed for new sites.

So how do I get the results of my entityQuery into blocks to afterwords use them twig templates?


texts: I have a website which is developed in three languages. I created a taxonomy vocabulary (product category), which is output from the views. Inside the term gallery thumbnail image products. So, how do single language for the gallery to not have to add three times the same image for multiple languages.


texts: drush migrate:upgrade not behaving as expected

texts:
I'm working with the Migrate Tools modules for the first time. Specifically, I'm trying to use the Migrate Upgrade module to import users and roles from an old Drupal 7 site to a new, Drupal 8 rebuild of that site.

Per these instructions, I'm running this command to configure the migrations:

drush migrate:upgrade --legacy-db-url=mysql://olduser:password@localhost/oldschema --legacy-root=http://olddomain.test:8888 --configure-only

When I run drush migrate:status upgrade_d7_user,upgrade_d7_user_role immediately after that command, here's what I see:

----------------------------------------- ---------------------- -------- ------- ---------- ------------- ---------------
 Group                                     Migration ID           Status   Total   Imported   Unprocessed   Last Imported
----------------------------------------- ---------------------- -------- ------- ---------- ------------- ---------------
 Import from Drupal 7 (migrate_drupal_7)   upgrade_d7_user_role   Idle     4       4          0
 Import from Drupal 7 (migrate_drupal_7)   upgrade_d7_user        Idle     197     196        0
----------------------------------------- ---------------------- -------- ------- ---------- ------------- ---------------

This isn't what I expect to see. It looks like it has already imported all roles and all users (except for the admin user), and has none left to process. I expect to see zero imported at this point, since I used the --configure-only flag, and I haven't yet issued the Drush command to actually run the migrations.

Looking in the Drupal backend, I don't see that anything has actually been imported.

If I go ahead and run these commands:

drush migrate:import upgrade_d7_user_role
drush migrate:import upgrade_d7_user

...then I see:

[notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'upgrade_d7_user_role'
[notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'upgrade_d7_user'

It seems like the Migrate Tools thinks that the imports have already been completed – but they haven't.

Any ideas? Has anyone run into anything similar before?

I have been restoring the new (target) site's database from a snapshot periodically, because I'm learning the migration process as I go. So maybe that has hosed something up.

The very first time I ran migrate:status, I saw what I expected – some records queued, but none imported yet.

And the first time I ran migrate:import, it did import the records as expected.

So it seems like something about that previous import got "stuck" somewhere in the system. But I've taken increasingly drastic measures to burn my development site to the ground and rebuild from scratch – to no avail.

Is there perhaps something being cached by the Drush CLI itself?

Appreciate any suggestions. Thanks.


texts:
I'm writing a custom module for Drupal 6, and I need to execute some PHP no matter which page the user accesses.

I see that hook_init is not run on cached pages, so that's a no-go. hook_boot doesn't work, either, because it happens too early in the page request to let me use some functions I need.

So I was thinking about specifying a block using hook_block, but that hook just makes me pull my hair out:

function test_block($op='list', $delta=0, $edit=array()) {
  switch ($op) {
  case 'list':
    $block['test_block']['info'] = t('Test block');
    return $block;
  case 'view':
    $block = array();
    switch ($delta) {
    case 'test_block':
      $block_content = '<?php echo \'WTF?\'; ?>';
      $block['subject'] = NULL;
      $block['content'] = $block_content;
      break;
    }
    return $block;
  }
}

This renders as:

Obviously, that's not what I'm looking for, either. Why does the PHP in that block not render correctly? Even if I end up using something other than a block to solve my problem, this issue really sparks my curiosity.

If I can't use hook_block, how do I get some PHP to run on every page? I need access to the $user global and to the drupal_goto() function.


texts: Set Sticky enable automatically once ubercart order is completed

texts:
I need to set Sticky enable automatically once the customer completes the ubercart order.

I have tried this by creating custom module but didn't work. Here is my code :

function mymodule_purchasePaidListing($order){

  $i=0;
  foreach ($order->products as $key => $value) {
    if ($i>=1){
      break;
    }

    if ($i==0){

    $product_node_id = reset($value->data['attributes']['Product Node ID']);

      if ($product_node_id){
        $node = node_load($product_node_id);

        $node->sticky=1;

        node_save($node);
      }

    }
  $i++;
  }

}

Note : I am getting Node id in Product attribute Product Node ID mentioned above.

Any Help?


texts: Load page content with AJAX after being gated

texts:
I need to gate a page's content with a form so that the content isn't loaded until a form on the frontend is filled out.
I can hook into this form's onSuccess method (all via JavaScript) but I'm a bit at a loss on how I'd functionally delay the loading of just the page content and insert it later.
So I'd essentially have an function for my form:
myForm.onSuccess( function() {
    // Load the body copy for this Drupal page
});

Is there a way I can halt the rendering of this region of the page but initiate that via an AJAX call after this form fill?
Thank you!


texts: Purchases with points occupying ubercart

texts: I want to use ubercart to create a site for online purchases but I would like to know if you can use points as a form of payment, I mean that users are placed points with which they can buy items and their points are discounted for each purchase.


texts: What is the purpose of the tabs div when logged out?

texts:
I am using a Bartik theme and am getting some extra padding in between the breadcrumbs and page title. Using firebug I discovered that there is an empty div which is displayed when I am logged out.

What is the purpose of this div? I thought it's only used in logged in mode... Is there a way to remove it from logged out mode?


texts:
I am working on Drupal 7 project (omega 4 subtheme) with panels and views. I need to assign ID an ID (id="nav") to a DIV that wraps main menu UL. It is a child of div.l-region--navigation. It's the second row of the example bellow.

Home

Home

Anyone knows how to do this? Is there a specific drupal way of doing this?


texts: How can I clear caches on a local Pantheon site?

texts:
I am trying to clear all caches on a local install of Drupal (using pantheon aliases):

drush @self cc all

However, when the menu caches are cleared I get this error:

WD pantheon_apachesolr: Error unable to use client certificate (no key found or wrong pass phrase?) connecting to [error] https://index.live.getpantheon.com/sites/self/environments/dev/index/admin/luke?numTerms=0&wt=json on port 449 Creating default object from empty value Pantheon_Apache_Solr_Service.php:514                                                                                [warning]WD Apache Solr Views: "0" Status: Request failed

The command appears to try to connect to pantheon, but fails. Is there a set up step I might have missed - to cause this error? Or can clearing all caches not be achieved when using a local install alongside the Pantheon platform?


texts: How to enter transactions in a drupal environment

texts: I use drupal extensively, but I notice that one cannot enter data as if in the following situation: Suppose that you have a master  file containing (Customer name,  DOB, Date of first visit...etc ) and other fixed information. And suppose one will need to record the amount in Dollars of different purchases made on several visit for a customer. In this case there will be several purchases amount that must be recorded on different possible visits for that customer. How one can record these transactions in drupal and how one can display the sum of these amounts in a view for that customer.  I have reviewed view group module, but the important thing here is how one can enter the data before thinking to do any calculation. I would appreciate any help in this regards.


texts: How to output view content as grid in custom template?

texts:
I have created a view for content type xyz with fields F1, F2,F3,F4.

I open the group "advanced", clicked on "Theme: Information".

There are couple of template files, that are used by view.

I chosen the desired template and copy it into to the template folder.

Now, from views module, in theme folder, I opened views-view-grid.tpl.php and copy the content of this file to the file I have created in my template folder.

But output is not coming in grid format.

Is there any way to customize the fields of view in html structure?


texts: How would you incorporate a log out confirmation screen?

texts:
Scenario: When users click the "log out" link, I'd like a confirmation form to pop up asking them to click again "yes" to confirm and continue logging out.

Is there module that does this? Or some kind of Rules workflow?


texts:
I have created a view which displays the 10 latest news items (articles). They show up fine in teaser format. When clicking on the full article there is no title displayed and I can't work out why. This is my node--article.tpl.php:

  <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

        <?php print $user_picture; ?>

        <?php print render($title_prefix); ?>
        <?php if (!$page): ?>
        <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?>

        <?php endif; ?>
        <?php print render($title_suffix); ?>

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

        <?php if ($unpublished): ?>

                <?php print t('Unpublished'); ?>

        <?php endif; ?>

        <?php if ($display_submitted): ?>

            <?php print $user_picture; ?>
            <?php
                print t('!username • !date • !time',
                array('!username' => $name, '!date' => date( "d/m/y",$node->created), '!time' => date( "G:i",$node->created)));
            ?>

        <?php endif; ?>

    <div class="content"<?php print $content_attributes; ?>>
        <?php
            // We hide the comments and links now so that we can render them later.
            hide($content['comments']);
            hide($content['links']);
            print render($content);
        ?>

            <?php print render($content['links']); ?>

    <?php print render($content['comments']); ?>

Also I should note that I'm very new to drupal and I don't know PHP very well.
If anyone could tell my why that would be really helpful. Thanks.


texts: How do I dynamically change cookie_lifetime?

texts:
I'm trying to change cookie_lifetime dynamically in my D8 project, to set cookie_lifetime to 0 or to some value(for example 24 hours). I know that this can be partially acomplished by changing cookie_lifetime variable in sites/default/services.yml, but this is not my case.

I've tried to use this answer but looks like it works only when I use start() method of the session manager.

So how do I change dynamically cookie_lifetime for existing session?
Any answers appreciated, thanks in advance!


texts: what is the difference between "Commerce Product Attributes" and "Commerce Customizable Products"

texts:
Commerce Product Attributes

Commerce Customizable Products

What is the difference between these 2 modules.?

I'm creating orders from a view table, without a product display for each product. I've added a text field to a custom line item with "Commerce Customizable Products" module. The line item display shows the fields but I cant find how to edit it. (working on panels btw.)


texts:
I am going to import data from a csv file, specifically linking a node to a user. I see that I can link a node to a user via user id, however I won't know the user id on import. Is there a way I can link the node to the user via user email?

Thanks!


texts:
Within a node template I can retrieve the status of the published flag by calling the code: node.isPublished()

How do I retrieve the status of the published flag within a commerce product...

I've tried:

product.isPublished()
product.status
product.published

But I can't seem to get it to print. I've tried to look through the core code where status seems to be the key, but no luck, plus api.drupalcommerce.org is down.

Any advice?

Thanks in advance


texts: drush xmlsitemap-regenerate domain is incorrect

texts:
Whenever I run:

drush xmlsitemap-regenerate

on our live server, the domains in the sitemap all refer to:

http://default

Only when I generate the sitemap from the Drupal admin backend, do I get the correct sitemap.xml with the correct domain setup.

I need to have the drush command working correctly, as we're using it with a Capistrano deploy script.

Can I somehow pass the domain name to the drush command?


texts:
I'm trying to connect a field of a taxonomy term to a field in a content type, something like this:

Auto-Fill from on content type to another

I tried this on a node and it's working, but now I have some problems with the taxonomy term, is for this part?

// load node by nid
$node = node_load($nid);

Do I have to specify here the taxonomy? but I really don't know what to put in...

the field in content type is "field_descrizione_01" with empty field "field_udm"
the field with the data in the taxonomy terms is "field_udm_ti"

I've made this code (based on the link one):

/**
* Implements hook_field_widget_form_alter().
*/

function collegamento_field_widget_form_alter(&$element, &$form_state, $context) {

  if(isset($element['#field_name']) && $element['#field_name'] == 'field_descrizione_01') {
    $element['#ajax'] = array(
      'callback' => 'collegamento_auto_fill_callback',
    );
  }
}

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

  $commands = array();

  if(isset($form_state['values']['field_descrizione_01'])) {
    // get selected item/node from dropdown list
    $nid = $form_state['values']['field_descrizione_01']['und'][0]['nid'];

    // load node by nid
    $node = node_load($nid);

    if($node) {

      if(isset($node->field_udm_ti['und'])) {
        // fill text field
        $commands[] = ajax_command_invoke('#edit-field-udm', 'val', array($node->field_udm_ti['und'][0]['value']));
      }

    }
  }

  return array('#type' => 'ajax', '#commands' => $commands);
}


texts: How to properly perform a patch so that the correct directory is used?

texts:
I attempted to make a patch using Making a Drupal patch with Git and ran into one issue after creating the patch. For some reason, I cannot get the proper location to be stored in the patch.

How can I get the desired results in the patch?

Issue

the issue is that it is setting diff --git "a/docroot/modules/contrib/video_embed_vidyard/src..."

Command used to generate the patch:

git diff <commit#1> <commit#2> > patch-name.patch

Current results:

diff --git a/docroot/modules/contrib/video_embed_vidyard/src/Plugin/video_embed_field/Provider/Vidyard.php b/docroot/modules/contrib/video_embed_vidyard/src/Plugin/video_embed_field/Provider/Vidyard.php
index 94a7dc26b..4de97deb7 100644
--- a/docroot/modules/contrib/video_embed_vidyard/src/Plugin/video_embed_field/Provider/Vidyard.php
+++ b/docroot/modules/contrib/video_embed_vidyard/src/Plugin/video_embed_field/Provider/Vidyard.php

Desired results:

diff --git a/src/Plugin/video_embed_field/Provider/Vidyard.php
b/src/Plugin/video_embed_field/Provider/Vidyard.php
index 94a7dc2..be635ad 100644
--- a/src/Plugin/video_embed_field/Provider/Vidyard.php
+++ b/src/Plugin/video_embed_field/Provider/Vidyard.php

I want to be able to generate a/src/.. instead of a/docroot/modules/contrib/video_embed_vidyard/src


texts:
I was wondering if anyone knew of a way to generate a PDF of an admin page in Drupal. I've looked at a bunch of custom modules but they seem only to work on nodes, which I know are not used to generate admin items. I have a client I've given limited back-end access to that would like a "Create a PDF" button placed in one of the admin areas. Does anyone have any recommendations? Here are my specs:

Drupal version: 7.24
Modules tried: mpdf, print

Thanks! -Dave


texts: Custom template for view with block display in a page

texts:
I created a template views_block__applications_block_1.twig for a block used on one of my pages. The block is based on a block view (unformatted list). Under blocks, the machine-readable name is views_block__applications_block_1. After searching around, I found that views_block__applications_block_1.twig should be the right template name. But no matter what I try, it doesn't seem to be working, all changes to the file are invisible. Can anybody point me in the right direction?

File content:

{#
/**
 * @file
 * Theme override to display a view of unformatted rows.
 *
 * Available variables:
 * - title: The title of this group of rows. May be empty.
 * - rows: A list of the view's row items.
 *   - attributes: The row's HTML attributes.
 *   - content: The row's content.
 * - view: The view object.
 * - default_row_class: A flag indicating whether default classes should be
 *   used on rows.
 *
 * @see template_preprocess_views_view_unformatted()
 */
#}

TEST

{% if title %}

{{ title }} - TEST

{% endif %}
{% for row in rows %}
  {%
    set row_classes = [
      default_row_class ? 'views-row',
    ]
  %}

    {{ row.content }}

{% endfor %}


texts: Cannot update: "No available releases found"

texts:
I cannot update some of the modules and the Drupal core itself from "Available Updates" menu. The error is "No available releases found". However, I can list the updates with drush ups.

Why?


texts: How do I change the Date module to get 'days back and forward'?

texts:
I want to restrict the dates a user can select when using past dates. I want a pop-up message when he tries to select a day +1 month from current date.

How can I do this? Do I need to override the module? If so, how?


texts:
I have vocab Categories, I created it as a menu with Taxonomy Menus. It lists terms in the sidebar, but when clicked on term, it opens empty page saying 'There is currently no content classified with this term.' I have term Hats & Visors, so path to it is shop/hats-visors/ and I expect it to show the list of hats content. These are my settings (screenshots): http://imgur.com/a/odXf6

And to the actual Hat content path is i.e. shop/hats-visors/hat aka /node/5/


texts: Convert dropdown of exposed sorting of view into Checkboxes

texts:
I have created view in that view I exposed sorting with dropdown field 'Distance', 'Rating', 'Review', it works fine. Now I want to convert that dropdown into checkboxes with AJAX callback.
I used module  Better Exposed Filters please suggest me to how to do that.


texts: Feed importer different node from each element

texts:
i am having some issues with feed importer. I am trying to create two different nodes from a JSON with feed importer. For example i have the following JSON and i need to create a "HOME" titled node and an "IPHONE" titled node, and each one of these should have the right number. The question to simplify this, is how to have them in different nodes. Thanks in advance!

{
 "firstName": "John",
 "lastName" : "doe",
 "age"      : 26,
 "address"  :
 {
     "streetAddress": "naist street",
     "city"         : "Nara",
     "postalCode"   : "630-0192"
 },
 "phoneNumbers":
 [
     {
       "type"  : "iPhone",
       "number": "0123-4567-8888"
     },
     {
       "type"  : "home",
       "number": "0123-4567-8910"
     }
 ]

}


texts: What is needed to keep parent menu element active while browsing subpages (Bartik Theme)

texts:
Let's say we have 2 sections with pages like this structure:

/section1 *
/section1/page1-1 **
/section1/page1-1/page1-1-1 **
/section1/page1-1/page1-1-2 **
/section1/page1-2 **
/section1/page1-3 **

/section2 *
/section2/page2-1 **
/section2/page2-2 **

= Link in main menu / ** = Link in custom menu (sidebar)

and so on.

The main menu of Bartik theme is not supporting sub-links, so I created custom menus, which are visible to each section (content type pages) in the sidebar.

Now I want to have the main navigation element of section1 root (/section1) be always having css-class "active" if any subpage of section1 is being browsed.

Any tips? I'm new to Drupal and don't want to mess up my installation.


texts: How to check a boolean value in twig templates?

texts:
We have a field_boolean (boolean field) on an ECK Bundle on the article content type. While doing research we came across the question "How to test for a boolean field in a twig template?" but it does not solve my problem.

What is the appropriate way to check for the boolean value?

We have attempted but they don't work:

{% if entity.field_boolean == True %}
{% if '1' in entity.field_boolean[0] %}

These appear to work, but not sure it is correct approach.

{% if entity.field_boolean[#items].value == '1' %}
{% if entity.field_boolean[#items].value %}


texts: Problem with product page (sidebar goes down)

texts:
I am using Drupalcommerce (CommerceKickstart 7.x-2.0-rc2).
There is an issue with the display of the product page. The product page is composed of a content and a right-sidebar. Every page that uses this configuration is well displayed but not the product page : the sidebar goes down.
First I thought about a css problem but I found that it is a problem with the htlm structure :
- For good pages the markup "aside", that contains the sidebar", is included in the div "zone-content" that is included in the div "zone-content-wrapper".
- For product page the markup "aside" is included directly in the div "zone-content-wrapper".
I looked at the files tpl.php of the theme but found no issue (I don't have a good knowledge about templates...).

Does someone already faced with this issue?


texts:
I have been trying this for a while without success. After installing the OpenLayers module in drupal 7.14 and trying to configure it i get the following error:

Cannot establish a connection to the server:

I have tried all permutations including downloading the openlayers library in the local machine, giving it a local path in a number of different ways.

The second error that is seen suggests that i am installing an incorrect version of the openlayers library when in fact i have been installing the recommended version i.e. version 2.11.

It has been a frustrating experience getting Openlayers, Geoserver , PostGIS and Drupal 7 working together on Windows 7. The number of combinations are many and there are many issues that are difficult to solve if you are not a webmaster.


texts: In Views how to group by year in an archive and then split into months

texts:
Views 3 - Create an archive for a given type grouped by year, then split in to months

Node Type
  |-Year(2015)
    |-September (node count(12))
    |-August (node count(15))
      ...
    |-February (node count(20))
    |-January (node count(30))
  |-Year(2014)
    |-December (node count(25))
    |-November (node count(35))
    |-October (node count(15))

By default archive block that just groups by month (i.e. September 2012 (node count)).I want to be in above format. In contextual filter by default archive block has passed created year + month.

I tried passing separately like created year and then month as separate month and still it didn't help.

Any help on this will be really appreciated. Thanks in advance.


texts: In Drupal 8 how do I get the image path from a twig node template?

texts:
I'm working with Drupal 8 and twig

I created a Drupal content type called hero. It contains a title, body copy and an image. I'm overwriting node.html.twig for this content type but am having trouble accessing the image source to generate html I need to.

              Headline

              Subhead Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ex, sed voluptatum fugit ipsa animi quos nobis?

I can access the Headline and title with the code below but I don't want to load the image file I want only want the image path (source).

{{ content.body }}
{{ content.field_headline }}
{{ content.field_hero_image }}

How do I get the image file path from in my node template from
{{ content.field_hero_image }}? How do I access the attributes of content.field_hero_image?

I've looked at image.html.twig and see

So I know it's in the attributes, but don't know how to access the attributes from the node template.


texts: Passing Information to Drupal Referenced Entities before Render

texts:
I have a content type called basic_page.  This content type has a field called field_elements which is an entity reference field.  The display settings for this field is set to 'Render Entity' - in other words, when a basic_page node is being rendered, it will also render the referenced entity.  All good - no problem.

My question is, I would like to pass run-time information (based on basic_page node) to the referenced entity that should be used in mytheme_preprocess_node when the referenced entity is being 'pre-processed`.

The problem is, by the time hook_preprocess_node is called for the referenced entity - I have no information of the basic_page node that 'contains' the referenced entity.

I was hoping that in hook_preprocess_field I could check if it is field_element and then set some value in the &$variables param I am getting in hook_preprocess_field that will persist to exist up to the point where hook_preprocess_node is called?


texts: How can I get my WYSIWYG editor to stop *#@&%^ing up my HTML?

texts:
I've tried every combination of "CLEANUP AND OUTPUT" settings that might conceivably prevent munging my HTML, but nothing works.  No matter, what, my HTML gets flattened or in some way rewritten, mainly with whitespace being trimmed off that I want to leave in.

I would suspect CKEditor (version 3.6.4.7575) except that when I tell WYSIWYG to "Apply source formatting", CKEditor doesn't prevent that, so it seems that logically this problem is in the WYSIWYG module.  "Apply source formatting" simply causes the HTML to be screwed up differently.  Some linebreaks are left in place, but spaces at the beginning of the line are left in place.

How can I prevent this, and still use a WYSIWYG editor?


texts: How do I create and render a custom region?

texts:
How do I create and render a custom region in Drupal 7, when the Display Suite module is used?
I am not able to show/display a block into a custom region and  confused with the files structure. Please suggest any solution.


texts:
What do I need to adjust to make this code work?

{% if fields.field_video_video[1].content|striptags|trim is not empty %}
  {{ fields.field_video_video.content }}
{% endif %}

The logic is to check if this field (a URL field) has more than a value; if it has more than a value, print the content, starting from [1].


texts:
I need to show in the same page a form and a table which shows all results from a webservice response.

function collectivite_search_user_form($form, &$form_state) {
    $form['name'] = array(
      '#type' => 'textfield',
      '#title' => t('Name'),
      '#required'   => True,
    );
    $form['firstname'] = array(
      '#type' => 'textfield',
      '#title' => t('Firstname'),
      //'#required'   => True,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Submit'),
    );
    if (isset($form_state['table'])) {
        $form['table'] = $form_state['table'];
    }
    return $form;
}

function collectivite_search_user_form_submit($form, &$form_state) {
    module_load_include('inc', 'collectivite', 'collectivite.api');
    $results = collectivite_ws_get_users($form_state['values']['name'], $form_state['values']['firstname']);
    if(is_object($results->Dossier)){
            $rows[] = array(
                'id'       => $results->Dossier->id,
                'nom'       => $results->Dossier->nom,
                'prenom'    => $results->Dossier->prenom,
            );
    }else{
        foreach($results->Dossier as $dossier) {
            $rows[] = array(
                'id'       => $dossier->id,
                'nom'       => $dossier->nom,
                'prenom'    => $dossier->prenom,
            );
        }

    }

    $paging = pager_array_splice($rows, 5);
    $header = array(t('id'), t('name'), t('firstname'));

    $form_state['table'] = array(
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => $paging,
      '#empty' => t('Aucun résultat.')
    );
    $form_state['rebuild'] = True;
}

function pager_array_splice($data, $limit = 9, $element = 0) {
  global $pager_page_array, $pager_total, $pager_total_items;
  $page = isset($_GET['page']) ? $_GET['page'] : '';

  // Convert comma-separated $page to an array, used by other functions.
  $pager_page_array = explode(',', $page);

  // We calculate the total of pages as ceil(items / limit).
  $pager_total_items[$element] = count($data);
  $pager_total[$element] = ceil($pager_total_items[$element] / $limit);
  $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element], ((int)$pager_total[$element]) - 1));
  return array_slice($data, $pager_page_array[$element] * $limit, $limit, TRUE);
}

It works fine except I cannot see the pagination. Can you see where is the problem ?

Thanks


texts: Is there a Drupal 8 alternative for Inline Entity Form (to create an item while adding a reference)?

texts:
I have a Family content type and a Person content type. A Family has an Entity Reference field to one or more Persons.

The normal workflow requires me to first create the Persons, then create the Family and then add the Persons to the Family, but I want to create the Family first and create persons while adding them.

This is achieved in Drupal 7 with the Inline Entity Form. Is there something like that for Drupal 8? Any alternative?


texts: How to get all parent nodes from a menu item?

texts:
Imagine the following menu structure:

Page 1 type: article
Page 2 comes from a view

Page 3 type: desirable < want this

Page 4 type: random

Page 5 type: random

Page 6 type: article

Lets say I'm on Page 5. I want to know if any parent menu item's node has the content type desirable.

I got a menu item id menu_link_content:uuid for Page 5. My current approach is the following:

<?php

$values['menu_parent'] = 'main:menu_link_content:uuid';
list($menuName, $entityName, $uuid) = explode(':', $values['menu_parent'], 3);
$menuLinkManager = \Drupal::service('plugin.manager.menu.link');
$parents = $menuLinkManager->getParentIds($entityName . ':' . $uuid);

foreach ($parents as $parentPluginId) {

  $mlc_ids = \Drupal::database()
    ->select('menu_tree', 'mt')
    ->fields('mt', ['route_param_key'])
    ->condition('route_name', 'entity.node.canonical')
    ->condition('id', $parentPluginId)
    ->execute()
    ->fetchCol();

  // menu_tree gives back node=nid
  if ($mlc_id && strpos($mlc_id, 'node=') !== false) {
    // split node=nid into separate values
    list($entityString, $nid) = explode("=", $mlc_id, 2);

    // load the respective node and see if it is a project
    $parentNode = \Drupal::entityManager()->getStorage('node')->load($nid);

    if ($parentNode) {
      $parentType = $parentNode->getType();

      // we found the parent project node
      if ('project' == $parentType) {
        $node->set('field_project_ref', $nid);
        $node->save();
        drupal_set_message(
          t("The content was automatically added a project reference due to it's parent menu items."),
          'status'
        );

        break;
      }
    }
  }
}

So I would go on and load the node if the database statement found something and check the node type etc. I just wonder if there was a more performant/ better, out of the box way of doing that?

Something like

$menuLinkContent->getTargetEntity()->getType()

or

entityManager()->loadEntityFromMenu()

would be nice.


texts:
I'm using Drupal 7 with views 3.

I have used VBO for a user list view. I select some users for any action and then moves to next page and if I come back to my previous page, the  select boxes (bulk operation) does not retain the checked value. Same happen, if I select users by using filters. How can I retian the selected users while moving to next page?

Thanks in advance for your help.


texts:
I've got a form that gathers some data. The data is then modified and should be passed to the user as a file. To manage this I did the following:

header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: text/out');
header('Content-Disposition: attachment; filename="file.out"');
echo $file;
module_invoke_all('exit');
exit();

What I need now is to somehow display some additional info to the user without losing the input data. In other words, when user submits a form, it should let him download the file and then, for example, print out a success message, contents of the file downloaded or another form. Is there any way to do that?


texts: How do I get the number of rows selected from the query?

texts:
In my custom module for Drupal 8, I am using the following code.

$query = $this->connection->select('node_field_data', 'nf_data');
$result = $query->execute();

I can get the number of rows looping over $result.

foreach ($result as $row) {
  $num++;
}

Is there a way to get the number of rows with a function / class method?


texts: Can you preprocess a specific region in template.php?

texts: In your template.php file, I know you can use theme_preprocess_region and check what "region" you are in, and accomplish what I am attempting like that...but I was wondering if you can do something like theme_preprocess_region_specific_region to further break things up and not have a lengthy preprocess_region function?  I can't seem to find any documentation on that.


texts: Drupal insert query with uploaded CSV file

texts:
array
  0 =>
    array
      'id' => float 1110
      'description' => string 'Culture de céréales (à l'exception du riz), de légumineuses et de graines oléagineuses' (length=86)
      'field2' => float 11
      'field3' => float 26.631
  1 =>
    array
      'id' => float 1120
      'description' => string 'Culture du riz' (length=14)
      'field2' => float 11
      'field3' => float 7.556

With this array what is the correct process for the string "description" to avoid SQL error when data is added with db_insert ?

I use this code for multiple insert :

$query = db_insert('table')->fields(array('id', 'description', 'field2', 'field3'));

foreach ($sql_query as $record) {
     $query->values($record);
}

$query->execute();

// $sql_query is the array described above.


texts: Array Flip Error Message on All Node Pages

texts:
Hello i dont know where to begin. All of a sudden MY WEBSITE is displaying this error when i view a node-

  Warning: array_flip() [function.array-flip]: Can only flip STRING and
  INTEGER values! in DrupalDefaultEntityController->load() (line 178 of
  /home/onlineba/public_html/onlineplac.es/includes/entity.inc).
  Warning: array_flip() [function.array-flip]: Can only flip STRING and
  INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 355
  of /home/onlineba/public_html/onlineplac.es/includes/entity.inc).

I havent added anything or changed anything. I was hoping it was because OG groups upgraded to 7.2 but i seem to get it when viewing a node that is not in a group. Let me see my page content type as thats got no OG fields attached or postable in groups.... yes exactly the same thing. its only got a title, body and image field attached to it. Oh and a term referance. Lets remove that...yes still the same.

Panels node page is disabled. Im sorry i cant tell you anymore about my problem but if anyone could be a lifesaver and offer any advice it would be gratefully reveived. I get really depressed when things like this happen. :(

thanks


texts: Using drupal 5.x.  I have a content type I created called "Blog Entry"  it has no fields other than the standard title and body.  Now I want to be able to place images at arbitrary points in the body of the blog entry and have them appear.  I already have ImageField and ImageCache installed for use with another content type.  Is there a way I can use those two modules to achieve my goal or do I need to install something like the Image module?


texts: How do I add a template suggestion for a Views block?

texts:
I am very much so new to Drupal and have moved to this platform after working with Magento for 5 years.
I am trying to create a template for a view. I have created the twig template under /templates/views/ called views-view--partners--partners--sales.html.twig but do not know how to hook the theme into using this twig template.


texts: Images are not migrated and the body field is empty

texts:
I tried to migrate a site from Drupal 7 to Drupal 8.1 using drush (migrate-import --all) and the following modules:

Migrate Plus
Migrate Tools
and the D8 core migrate modules.

It doesn't migrate the image of my nodes and the body field is empty. Do I have to create the same content types with similar fields first, or should I let the Migrate module do this?

The empty body looks like a problem with the text format filter. I use the full HTML text format with CkEditor on Drupal 7, but this filter exists on Drupal 8 too, so I don't understand why it happens.


texts: Debug: 'Handler views_handler_field_node_revision node could not be added!'

texts:
i have a problem when i try to create a task on ERPAL, i have this message

Task toolerp has been created.
   Debug:
   'Handler views_handler_field_node_revision tried to add additional_field language but    node could not be added!'
   in views_handler_field->add_additional_fields() (line 142 of   /var/www/vhosts/.../erpal/profiles/erpal/modules/contrib/views/handlers/views_handler_field.inc).

does any body have a hint ?

Thanks


texts: Unserialize() Error after moving the installation directory

texts:
I have just added a repository from git to my Eclipse IDE , setup the database with proper imports and dumps, however getting

Error at offset in cache.inc

Any suggestions what went wrong and solution.