texts: How can you put a user profile item in a category on the user's account information page?

texts:
My attempt is:

function mymodule_user($op, &$edit, &$account, $category = NULL)
{
  switch($op)
  {
   (...)
      case "view":
         $account->content['my_cat']['plant_1'] = array(
                    '#type' => 'user_profile_item',
                    '#title' => 'Plant 1',
                    '#value' => '42',
                    );
  }

But that doesn't work as the 'Plant 1" form element appears at the top of the page without a category. The categories seem not to be derived from $op = "categories" where I defined 'my_cat'. So how can I tell Drupal that "Plant 1" should be in the my_cat category on the user account information pages?


texts:
I want to lightly alter the language switcher block's markup by adding additional classes, among others "clearfix" to clear the floats. I cannot however pin down where the markup is created.

This link http://drupal.org/node/1369090 (last post) suggests using template.php but again, I cannot see how I would alter the wrapper div's markup.

Is there any way to achieve this?


texts: How do I add a variant programmatically?

texts:
I have many sites in an installation that have many Panels pages. Many of them need a HTTP Response (404) variant added to them, which I would like to do programmatically.

Assume I have the page already via:

$page = page_manager_page_load($pageName);

Modifying something in the page is easy. Make the change then call page_manager_page_save($page);

It seemed the easiest way to accomplish adding a variant was to take an exported variant and import it. This is what the clone function does.

Here is an exported variant:

$handler = new stdClass();
$handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */
$handler->api_version = 1;
$handler->name = 'page_bes_homepage__http_response_0ab6f1a9-9c98-459c-b4d3-10f63ddace56';
$handler->task = 'page';
$handler->subtask = '';
$handler->handler = 'http_response';
$handler->weight = 1;
$handler->conf = array(
  'title' => '404 Error',
  'contexts' => array(),
  'relationships' => array(),
  'code' => '404',
  'destination' => '',
  'name' => '',
);

It doesn't appear necessary to set the subtask or provide a new name since the page_manager_handler_add_to_page() appears to handle that (though at first I set those myself; didn't help).

Attempting to add and save via:

page_manager_handler_add_to_page($page, $handler);
page_manager_page_save($page);

doesn't work. Some code in page_manager.module had me think that the failure might might be because of ctools caching so I tried this:

page_manager_save_page_cache($page);
page_manager_clear_page_cache($pageName);
page_manager_page_save($page);

and that doesn't work either. Scouring the web for an example of this has not turned up anything in code snippets, tutorials or books and ctools doesn't provide this level of documentation.

How does one add a variant programmatically? Note that I do not want this in Features and I do not want this stored in code via the ctools api. I just want to run through a list of Panels pages programmatically and add a variant.


texts: How to programmatically register a user with Mailchimp API

texts:
I have a contact form with a checkbox "Register to the newsletter". If this checkbox is checked, I want to register the email adress (a field in the contact form) to the Mailchimp list, which works fine with the Mailchimp block.

I want to do this in my contact_form_submit fonction in my module, but I can't find a way... Does anyone know how to do this ?

Thanks.

EDIT: I use this code :

if ($values['newsletter'])
{
    $list = array_shift(mailchimp_get_lists());
    mailchimp_subscribe_user($list, $values['mail'], array());
}

This code put the user in the table "cache_mailchimp_user" but not in the mailchimp list subscribers, even after I run the Drupal cron manually... Any ideas ?


texts:
I need to force the status value of a node=0 when the user has a certain role.

I've made

 function mymodule_node_save($node){
    if($node->type=="mytype") {
        global $user;
        if(in_array("simple",$user->roles)) {
            $node->status=0;
        }

    }
}

But the status is always saved as 1. What am i doing wrong?


texts:
I have a module with a plugin block. In the blockForm I create all the fields that I need for this block. In the CMS I realized that only the title of my block is translatable. I need some of my custom fields to be translatable. I just can't find how to do that.

public function blockForm($form, FormStateInterface $form_state){

    [...]

    $form['exit_link']['full_schedule_link'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('Full Schedule Link'),
      '#description' => $this->t('Enter the schedule node, ex: (/node/20)'),
      '#default_value' => isset($this->configuration['full_schedule_link'])?    $this->configuration['full_schedule_link']:'',
      '#maxlength' => 256,
      '#size' => 64,
      '#weight' => '1',
      '#translatable' => true // <-- NOT WORKING
    );

    [...]

}

Anyone has an idea how to do this?


texts:
I wonder how to decide either to use core Taxonomy module or Entity Reference module?

I didn't use Entity Reference module before but I've used the taxonomy module (and some related modules) on 10-15 websites.

What are the advantages or disadvantages of using reference based modules instead of taxonomy module?

Recently, I've started to build a magazine archive website.

There are lots of magazines.
These magazines have issues.
Each issue has articles.

The smallest (and deepest) part here is the articles.

Article

Page number (range):
Title:
Author:
Article type:
Keywords:
Magazine:
Issue:

Issue

Issue number:
Cover image:
Date (published):
Magazine:

Magazine

Description:
Cover image:

Here, there are (at least) 2 methods to implement this website:

1. There will be a content type called article and all others (issue,
    magazine, author) will be taxonomy terms (hierarchical). There would be a hierarchy between issue and magazine etc.

2. There will be lots of content types: article, issue, magazine,
    author. While creating articles; issue, magazine and author could be referenced etc.

So, theoretically both ways are seem very similar.

Is there anybody who faced similar situation and could you please say which method you preferred, why?


texts: I am trying to create user registration form in js which beautiful and flexible

texts:
I am using drupal 7. I am trying to create user registration form with javascript which beautiful and flexible. Something like this:

How can I achieve this?


texts: Autocomplete does not work on the server

texts:
I have a organization text field on the user profile. I wrote a module that uses dbpedia's lookup services to generate an autocomplete list on the field. The code works on my local instance using XAMPP. I installed the module on the server but it doesn't show the autocomplete list. It however recognizes the field as autocomplete by showing me a circle on the field

The code for the autocompelte is

<?php
/**
 * Implementation of hook_menu()
 */
function org_ac_menu() {
  $items = array();
  $items['org_ac/autocomplete'] = array(
    'page callback' => 'org_ac_autocomplete',
    'access callback' => TRUE,
    'access arguments' => array('access dbpedia autocomplete'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Implementation of hook_form_alter()
 */
function org_ac_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_profile_form') {
    $form['field_organization']['und'][0]['value']['#autocomplete_path'] = 'org_ac/autocomplete';
  }
}

/**
 * Check for possibilities in dbpedia
 */
function org_ac_autocomplete($string = '') {
  $found = array();

  $url = 'http://lookup.dbpedia.org/api/search.asmx/PrefixSearch?QueryString='.urlencode($string).'&MaxHits=5';
  $result = file_get_contents($url);
  $data = simplexml_load_string($result);

  foreach($data->Result as $res_temp)
  {
      $found[check_plain($res_temp->Label)] = check_plain($res_temp->Label);
  }

  drupal_json_output($found);
}


texts:
How can I remove these tags from my pages in Drupal 7?

<link rel="shortlink" href=" .... " />
<meta name="Generator" content="Drupal 7 (http://drupal.org)" />
<link rel="canonical" href="...." />

Update: I have the code for template.php, which removes the generator and canonical tags.

function program_html_head_alter(&$head_elements) {
  unset($head_elements['system_meta_generator']);
  foreach ($head_elements as $key => $element) {
    if (isset($element['#attributes']['rel']) && $element['#attributes']['rel'] == 'canonical') {
      unset($head_elements[$key]);
    }
  }
}

Can anybody add something to remove the short link tag?


texts: The module Node Embed does not work for a custom user role

texts: I am trying to use the Node Embed module with WYSIWYG editor in Drupal 7 to embed a node. I can do this as an Admin but cannot do it as a custom user role. It says Access Denied when I go to the WYSIWYG editor and the Node Embed plugin. I did check for the permissions for WYSIWYG profiles and also text formats. The custom role has permissions to use/access both. Any thoughts on this? Any help would be appreciated.


texts:
I use two shared hosts at present. One, webhostinghub.com, already has drush installed and it works. The other, 1and1.com, did not come with drush pre-installed so I installed composer and then drush with composer as recommended on drupal.org.

This puts a symlink to drush in ~/.composer/vendor/bin which points to ../drush/drush/drush. In the ~/.composer/vendor/drush/drush folder that this points to is a file drush which requires drush.php which is in the same folder.

So as recommended, I set up an alias for drush that runs this with php-cli.
Because 1and1.com sets up php and php-cli to default to php4, I also set up an alias for both php and php-cli to the php7.1 versions.

When I go to the root folder of one of my drupal sites and type in simply drush, I get the non Drupal specific commands listed and then the message:

  NOTE: Drupal root not found. Pass --root or a @siteAlias in order to
  see Drupal-specific commands.

I did see some posts saying that for this to work you have to just have one settings.php in the sites/default folder of the drupal tree. I have searched and have not found any stray settings.php files - just the one in the sites/default folder.

Does any one have an idea about why this is not working? Let me know if you need more information about my setup or the process that I went through.


texts: jQuery functionality lost from some modules after migrating to new host

texts:
My site was running good until recently. Suddenly none of the modules were able to use jQuery on the site. I came to know about this when I logged in as admin and my Nodequeues were not working.

The button on Panel pages on the top of each region to add content using CTools has also started behaving weirdly. Earlier one had to click on the button on top of each region to see the menu that said "Add content" but now that menu is fully expanded without clicking.

Is it correct to conclude that all this is happening because the modules are not able to access the jQuery library? The jQuery UI and jQuery modules are installed and were working properly before yesterday.


texts: Make global results header in a view appear below exposed filters

texts: I need to make the text in a global results header appear below the exposed filters on a view and it doesn't give me an option to wrap the header separately from the exposed filters so I can move it below. How can this be done?


texts: google analytics are killed after "cookie control" instalation

texts:
I'm new in drupal so I will write as simple as possible. I have installed the "google analytics" (GA) module. I have configured it and it worked. I was able to see live statistics on the GA web-page. Then I had quite stupid idea and I have installed "cookie control" (CC) module. After some time I have recognize that on the GA web-page I get no results... - no live-stats. So first I had disabled the CC module. But again there were no GA-live-stats :( so I have removed the CC module from the sites/all/modules, but that does not change anything. GA does not show any new stats since I have installed the CC module. How to proceed now?

Best regards,
kami


texts: find nodes by attribute and modify at once

texts: If I want to filter content by attributes (besides content type name), is there is some module around? if I am able to find these nodes, some way to update this attribute for all nodes at once?


texts: KernelEvents::REQUEST is not fired on cached pages

texts:
I am trying to implement a KernelEvents::REQUEST event subscriber to perform some action on page load.

I need this event to fire regardless of whether the requested page exists in the Drupal cache - it seems that KernelEvents::REQUEST does not fire when Drupal serves something from the cache.

Is there an event I can use to achieve this, or must I implement my requirements as some form of middleware?


texts: Can a sidebar span two zones in omega 3 theme?

texts:
I'm a bit of a newbee with Omega 3. I am having trouble arranging a grid which has a vertical sidebar span two zones. See the attached  diagram to understand the design requirements. I need to have a left sidebar and content block both appear under the header, and a right sidebar that spans both the the header and the content.

I would like to know if it is possible to create such a grid within the standard Omega UI, or if not how can this be accomplished.

Thanks!


texts: Reindex Search API indexes for Behat testing

texts:
I tried to use index the newly created contents to be able to test a page, but the problem is most of the times the tests fails, because the indexing process not finished yet until the contents starts checking. (i.e. if I stop before pageload with a breakpoint the testing, then the next steps always pass)

Method 1:

$search_api_index = search_api_index_load('SEARCH_API_INDEX_ID');
search_api_index_items($search_api_index);

Method 2:

search_api_cron();

The question, how can I call the indexing to wait until it's fully indexed before it goes forward?


texts: Getting the $user object of a logged out user based on a username and setting its status

texts:
As mentioned in the question here Using user_load() and user_save() to change the status of a logged out user, I want to be able to access the $user object of a logged out user based on a username and set the user status to active with user_save().

As advised, I put my code in a custom module and implemented hook_menu() with a page callback. However, I still don't fetch $user.

UPDATE: I've managed to get what I wanted: I'm indeed fetching the $user object by a username passed as a parameter and I manage to change the user's status. BUT, i'm not doing this the proper way. Here's the code inside mymodule.module:

<?php
function mymodule_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    // set user's status to blocked upon registration
    case 'insert' : {
      user_save($account, array('status' => 0));
      break;
    }
  }
}

function mymodule_init() {
  // needed due to Drupal's menu caching. Otherwise, mymodule_menu() won't be called
  menu_rebuild();
}

function mymodule_menu() {
  $account = user_load(array( 'name' => $_REQUEST['user'] ));
  user_save($account, array('status' => 1));
}

As you can see, I implement hook_menu() but there's no page callback. A working page callback would solve me 2 issues:

I would like the user activation functionality to be available only from a specific page in Drupal and i'd like to restrict access to that page.
Performance - currently, the menu_rebuild() is called on each and every page request on Drupal.. not pleasant at all :)

When I tried putting a page callback in the mymodule_menu() function and debugged the code, I saw that the page callback wasn't even fired. Here's what my initial code looked like:

function mymodule_menu() {
  $account = user_load(array( 'name' => $_REQUEST['user'] ));
  $items['auth'] = array(
    'page callback' => 'mymodule_page',
    'page arguments' => array($account),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function mymodule_page(&$account) {
  menu_rebuild();
  user_save($account, array('status' => 1));
}

Why isn't my page callback function fired with this code? How can I tell Drupal to rebuild the menus or to clear the menus cache only for a certain page?

Avner


texts: How to theme PDF generated by Print module?

texts:
I would like to theme the PDF generated by the Print module. I would like to add header, footer, margins, border to the generated PDF.

The certificate module in Drupal provides theming to the certificate, but my site is almost like a read and get certified site, so I wish not to change print module.

I tried the form alter and other stuffs, but not sure from where the PDF can be changed.


texts: How do I theme view fields, with custom templates or overwriting the output from the UI?

texts:
I am having some confusion in theming a view output in Drupal.

While theming a view with Fields, you can either create template files for every view like views-view-unformatted--view-name--block-name.html.twig or you can use the Rewrite Results option in the fields configuration as shown in the screenshot.

I want to know which is the best practice to follow and the reason for it.

Some of my points are the following.

The rewrite output is stored in the database; accidental wipes of the database will be destructive.
Creating template file will ensure that someone who is not familiar with Views will have no effect even if they accidentally altered the code.
Keeping the code in rewrite result will give easy access to edits through Views UI.

In my case, the homepage of the theme I am trying to integrate have so many sections (with different HTML structure like Collage, Card, and List) which are based on specific taxonomy terms.

What are the pros and cons of both the methods? What should I follow?


texts:
I'm having a bit of an issue with Ajax appearing inconsistent when loading my nodes. I initially followed the advice in this blog
http://mrkadin.com/blog/node/70

which appears to work perfectly well. I extended my site to include JS built NEXT/PREV buttons. I tried to tie these buttons into using AJAX to load the node info in the same way as the view items work, but alas my results are terrible.

The links loaded by the view look like this:

and here is my JS to add my NEXT link

jQuery('#nextbutton').append('Next ('+titles[1]+')');

which is then rendered to this:

Next (image2)

The keyword NOJS can be altered to AJAX, if I build with nojs this causes the node to load normally, i.e. a new page opens. If I alter this to AJAX, then ajax load is attempted but the page switches and what looks like the raw ajax data is loaded into a html output like this

[{"command":"settings","settings":{"basePath":"\/mysite\/","pathPrefix":"","ajaxPageState":{"theme":"mysite","theme_token":"x_b.....

so I go on to try doing it outside of the drupal module route which the view is using and load it via ajax directly.

my next button now looks like this:

jQuery('#nextbutton').append('Next ('+title[1]+')');

my listener:

    jQuery('#nextbutton a').live("click", function(){
        nid = jQuery(this).attr('rel');
  jQuery("#ajax-loader-area").load("http://localhost/mysite/imgdisplay/ajax/"+ nid);

    });

now this causes this same code like dump, but at least its on my page where it should be.

looking into the console I see that the working AJAX load (via the view) runs as a POST where as my jQuery code runs as a GET, unknown if that's significant.


texts: Is there anything like get_variable storage that doesn't get loaded every page?

texts:
I have a custom module and I want to store a long bit of text (~20kB).

I was going to use variable_get but as I understand all vars accessed this way are loaded for every request, which is a memory waste as this will only be used for one block.

cache_get is not appropriate because I don't want the data getting cleared on cache clear. It's not really cache.

Is there anything else like that?


texts: Clean urls - auto path alias - how to remove accents (Á É Ó Í Ñ ) from the urls?


texts: How to print edit link on a node page if the current logged-in user has access to node edit

texts:
I'm using Display Suite custom fields to have my Edit link rendered somewhere else on the node page, I'd like to see if there's an easy way to check if the current user has the permission to edit the node or not.

So far I tried this:

<?php
global $user;
      if (node_access('update', $nid, $user) == true) {
       echo l(t('Edit this node'), 'node/' . $node->nid . '/edit');
      }
?>

unfortunately does not work, Thanks a million.


texts: I am using login box on all pages. Is there a way to secure only the login box part of the page ?


texts: How to create a single slideshow combining several image fields?

texts:
I have 3 image fields in a content type: img1,img2 and img3. img3 is multi valued while the rest are single valued, and I'd like to create a single slideshow containing img1, img2 and img3 to be showed on every node of that content type.

I tried using views slideshow with as block with contextual filters and managed to select images from a node correctly, but they weren't displayed properly as a slideshow.

The reason I'm not simply using one image field to make things easier is that I'm using the Custom Formatters module and I have problems with using just one field with that module:

Custom formatter for a multi-valued field


texts: How to render Views anchors with `title` attribute?

texts:
By default the Views module doesn't put title attributes on anchors as it only puts them on anything that has an alt attribute.

Seeing as you're not likely to have an alt attribute on a standard anchor. Could someone please advise what you need to do in order to render Views anchors with title attribute?


texts:
I created a custom VBO action to change a value in the selected item. I have the button displayed as "hide item". When I activate it on the item it doesn't seem to fire and change the value at all. I did a test to change the name to xxxxx and visible to 0, but it doesn't look like its working. Maybe my code is wrong?

It does seem like its working as I output the result in the set_message function (in green box in screenshot). 1 indicates that 1 row has been affected, but i still see the item on my View and the name hasn't even changed.

Maybe something is off here?

Module Code:

function office_action_info() {
  return array(
    'action_off' => array(
      'type' => 'entity',
      'label' => t('Hide Item'),
      'configurable' => FALSE,
      'behavior' => array('changes_property'),
      'triggers' => array('any'),
    ),
  );
}

function action_off($entity, $context = array()) {

$blah = db_update('office')
->fields(array(
    'verified' => 0,
    'name' => 'xxxxxxx',
))
->condition('office_id', $entity->office_id, '=')
->execute();

drupal_set_message($blah .'====='. $entity->name .'===='. $entity->office_id);
}


texts: How to highlight the menu items related to the particular content type? Actually I want whenever the user visits the page related to the particular content type,it should highlight the particular menu item. Context module is the one solution for this. Is any other custom coding solution without installing any module?


texts: Render a controller template from a custom module in a theme page

texts:
I have created a custom module whose routes are defined as follows.

bigdeal_infos.infos_controller_infosScreen:
  path: '/bigdeal_infos/infos'
  defaults:
    _controller: '\Drupal\bigdeal_infos\Controller\InfosController::infosScreen'
    _title: 'Infos Controller'
  requirements:
    _permission: 'access content'

When I go to site.com/bigdeal_infos/infos, the custom/bigdeal_infos/templates/example.html.twig template shows up with dynamic content passed from infosScreen() (a controller method).

I want to show this template file in a content page, Home, which uses page--home.html.twig as template file, in my theme.

How can I achieve it?


texts: How can I generate custom XML for a SOAP client?

texts:
Im building a SOAP client that consumes from a SOAP web services in a Drupal 8 module.

I need to generate this final XML:

$inpunt_data = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:qual="http://websoap.com/">

                           <soapenv:Header/>

                           <soapenv:Body>

                              <qual:myMethod>

                                 <!--Optional:-->

                                 <qual:xmlMethod><![CDATA[

                                <Tag>
                                </Tag>
                               </qual:Method>';

How do I generate soapenv headers?

I'm using simplexml:

$getXML = new SimpleXMLElement($input_data);
             $urlTarifa = 'http://soapurl.com?wsdl';
             $client = new SoapClient($urlTarifa);


texts: D7: Create an administration page for my module

texts:
I have a custom module that sends an email with an order to the customer. I hardcoded the email body text in a string inside the module code but my client want to have control over it and I need to create an admin page for him:

I need to save it and use that text as a variable.

I started the page like this:

function shop_admin_settings($form, &$form_state) {
     $form = array();
     $form['mail_template'] = array(
       '#type' => 'fieldset',
       '#title' => t('Shop Email Template'),
       '#colapsed' => FALSE,
       '#collapsible' => TRUE,
     );

     $form['mail_template']['body'] = array(
       '#type' => 'textarea',
       '#title'  => t('Email template'),
       '#rows' => 10,
     );
     return system_settings_form($form);
 }

and use hook_mail_alter to append $form['mail_template']['body'] to the existing email body

function shop_mail_alter(&$message, $form_state) {
$client_body = $form_state['mail_template']['body']
if (is_array($message['body'])) {
    $message['body'][] .= $client_body;
  }
}

Now if you please help me, I am a bit stuck:

I need to retrieve the body provided by client, I don't know how (my code is not correct)
Do I need to create a separate admin.inc in order to work? Or do I simply need to add a menu path like admin/config/system/shop and a corresponding callback?
Is it possible for client to use tokens inside the body?


texts: How to add reCaptcha while doing comments on my drupal website

texts:
I am developing a drupal website. To avoid spam I have decided to use reCAPTCHA module while user registration and before putting comments on my website.

How to achieve this? Can I use reCaptcha while submitting comments?


texts:
I have a site-wide contact form setup that redirects the user to the homepage and posts the submission result to the help section. It works as intended, but I was wondering what I would need to do to change this behaviour.

Instead of redirecting, I would like to display the form submission result in a modal (maybe jQuery) popup.

How could I achieve this?

I wouldn't like to lose the core functionality, just maybe override it with a custom module or something. Any thoughts?

EDIT:

Starting with @rémy 's suggestion, I created a .module file where I'm trying to override the standard behavior for form submission.

Right now the only thing I have is as follows (although it doesn´t work):

<?php

/*
*  Override the the form submit behaviour.
*/

function modal_contact_form_result_form_node_form_alter(&$form,       FormStateInterface $form_state, $form_id){
    $form['actions']['submit']['ajax'] = array(
        'callback' => 'ajax_test_dialog_form_callback_modal'
    );
}

function ajax_test_dialog_form_callback_modal($form, FormStateInterface $form_state){
    $response = new AjaxResponse();
    $content = 'Form submitted successfully, thank you!';
    $title = 'YForm submited';
    $response->addCommand(new OpenModalDialogCommand($title, $content, array('width' => '700' )));

return $response;

}

But at this moment it neither prevents redirecting nor pops up the modal.


texts:
I have a module where I try to catch an url to use a specific function.

function my_module_menu(){
    $items['beneficiaire/commande'] = array(
        'page callback' => 'test_view',
    );
    return $items;
}

function test_view(){
    var_dump('test_view');
    exit();
}

Unfortunately, when I call beneficiaire/commande nothing append.
I know Drupal go through this hook because when I do

function my_module_menu(){
    die('poc');
}

I see 'poc'.


texts: How do I disable a module when Drush or the GUI doesnt work?

texts:
My site just gives a WSOD and throws this error:

  Error: Unsupported operand types in sites/all/modules/rules/includes/rules.state.inc, line 620

Since I can't even get to my site now without a WSOD, and when I do a rush cc all or drush pm-disable rules I get that error via the command line, how can I disable the Rules module?


texts: How to add another field collection instances on Add Form page load programatically

texts:
I have one field collection with unlimited values in Commerce Product Add form.

After performing some action, When user redirects to Add Product form, based on some predefined values in session, I want to display User a Field collection items pre-filled.

If I have 5 predefined values then 5 Field-collection items would be displayed to User and by clicking on save that product would be saved with that field collection item values.

By clicking on 'Add another item', User can add more as well. Above field collection items won't be saved until User clicks on Save form button.

I tried below code but it's not adding new items/instances :

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'commerce_product_ui_product_form') {
    if (isset($_SESSION['compatibilityInfo']) && $_SESSION['compatibilityInfo'] != '') {
      $compInfo = $_SESSION['compatibilityInfo'];
      $comp = explode('!c!', $compInfo);
      $cnt = count($comp);

        // Go one level up in the form, to the widgets container.
        $element = drupal_array_get_nested_value($form, array('field_part_details','und'));
        $field_name = $element['#field_name'];
        $langcode = $element['#language'];
        $parents = $element['#field_parents'];
        // Increment the items count.
        $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state);
        $field_state['items_count'] = $cnt;
        field_form_set_state($parents, $field_name, $langcode, $form_state, $field_state);

    }
  }
}


texts: Connection timed out and lock_may_be_available() on working site

texts:
I'm hoping someone can point me to a fix. My drupal 7 app was running fine locally this a.m. while I was testing a way to insert a row using mysql tools for a non-Drupal function. My environment is Apache running virtual host on php 5.4.34 on a Ubuntu VM.

After not getting satisfaction using the mysql functions, I started a simple PDO function using Drupal's database settings from the settings.php file. I was able to insert a row successfully but when I returned to the local site I got this error after a long time:

drupal_log_error(Array ([%type] => PDOException,[!message] => SQLSTATE[HY000] [2002] Connection timed out,[%function] => lock_may_be_available(),[%file] => /media/psf/Home/apps/habitatnashville/includes/lock.inc,[%line] => 167, etc

[%type] => PDOException
    [!message] => SQLSTATE[HY000] [2002] Connection timed out
    [%function] => lock_may_be_available()
    [%file] => /media/psf/Home/apps/habitatnashville/includes/lock.inc
    [%line] => 167
    [severity_level] => 3

I've looked here and on Drupal's site. Because it's a connection error the likely suspects are that I've munged the credentials somehow.

When something like this happened months ago, I did a service mysql restart, did that again a few minutes ago, rebooted the ubuntu VM and rebooted entire computer to shake that lock.

I've removed that test file with the PDO just in case. Here's the output of my drush status:

Drupal version                  :  7.27
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database username               :  admin
 Database name                   :  my_db
 Database                        :  Connected
 Drupal bootstrap                :  Successful
 Drupal user                     :  Anonymous
 Default theme                   :  My_theme
 Administration theme            :  rubik
 PHP executable                  :  /home/sam/.phpbrew/php/php-5.4.34/bin/php
 PHP configuration               :  /home/sam/.phpbrew/php/php-5.4.34/etc/php.i
                                    ni
 PHP OS                          :  Linux
 Drush version                   :  6.2.0

My database is running as "service mysql status" => mysql: start/running, process 1291.
What else could be affecting this?


texts: Add elements to webform dynamically via hook_form_alter

texts:
I'm trying to dynamically add multiple toggle fields to a form (in my case webform) via a form-alter-hook.

function module_form_alter(&$form, FormStateInterface $form_state, $form_id) {
....
  foreach ($roles as $role) {
    $form['elements'][$role->id()] = array(
      '#type' => 'webform_toggle',
      '#title' => t($role->label()),
      '#default_value' => 0,
      // More webform specific arguments follow here.
      '#webform_id' => "edit_membership_roles--" . $role->id(),
      '#webform_key' => $role->id(),
      '#webform_parent_key' => "",
      '#webform_parent_flexbox' => FALSE,
      '#webform_depth' => 0,
      '#webform_children' => [],
      '#webform_parents' => [$role->id()],
      '#webform_multiple' => FALSE,
      '#webform_composite' => FALSE,
      '#admin_title' => $role->id(),
      '#webform' => "edit_membership_roles",
      '#webform_submission' => NULL,
      '#access' => TRUE,
      '#webform_element' => TRUE,
      '#element_validate' => [],
    );
  }
}

This works in a way that the form is displayed correctly, with all dynamically added toggle elements. However, when trying to load the WebformSubmissionInterface $webform_submission via $webform_submission->getData(); in my custom class FormHandler extends WebformHandlerBase {...}, the array only contains the elements that I manually added to the webform via the GUI.

I checked the first answer of this question, but my $form does not have a $form['submitted']

Am I just missing something or does this approach not work at all?

Update

I did the same approach with a custom form built with Drupal FormApi and it works. So I must be missing something specific to webforms.


texts:
I have a page of node type: Page with the name 'latest'. I was looking at a module that lets me arse about with the comments form and things and i was wanting to add some code just to that one page. Not change all the Page content type.

Im sure i added something to my template, a preprocess thingy to achieve this before. Im using Drupal 6. Could anyone point me in the right direction? thanks.

I'll go see if theming a node is the same but ive a feeling from past experience i have to add something. Knowing me ive probably still got the preprocess thingy in there. ill go check.


texts:
I want to add a checkout of an SVN project in the .make file. However, the checkout only concerns a specific folder (new profile added). Has anyone made this before ?

edit : Folder and not file. My bad.


texts: How can I put form elements into a table and have a submit at the bottom?

texts:
I'm working on this module and I want it displays a page as follows.

What I am doing to get that is just displaying a table through theme() and typing out the HTML for the upload. I want the whole page to be seen as a form; the only element that will need changing is the image that's uploaded. I want also a submit button on the bottom to save changes.

One way to solve this would be to put an edit button and have it go to a new page that is just a form and that would work, but I'd prefer to have it on one page.

What is the best way to do this? Every site I read on is just confusing me more because they are all doing it different; it's not the result I am looking for because not all that is displaying is going to be a form element.


texts: Using Migrate API to select items from a JSON array

texts:
I have a module pulling a JSON feed into Drupal 8 using the Migrate API. However, one of the values in the JSON is an array.

For example, coordinates:

{
    "data": [
        {
            "id": "id:1",
            "position": {
                "coordinates": [
                    24.932974,
                    60.168495
                ],
                "type": "Point"
            },
            ...
        },
        {
            "id": "id:2",
            "position": {
                "coordinates": [
                    24.94416,
                    60.18831
                ],
                "type": "Point"
            },
            ...
        },
...

What sort of field selector is needed to get coordinates?

If I use selector: position/coordinates I get 24.932974.

How would I get the second one: 60.168495?
Should the extract plugin be used here?


texts: Commerce: retrieve coupon code used in order

texts: Using the Commerce Coupon module, how can I retrieve any coupon codes used in a particular order, given the order id? It seems that the coupons used are not actually stored in the database (as far as I can see).


texts: Suggestions for storing private user content lists

texts:
I have a feature on my Drupal7 site where users can store a list of personal stock symbols (NYSE, NASDAQ, etc) and then do different actions on that list; quote, chart, etc. These lists are private to each user.
For the first iteration, using a custom module, I've stored them in a custom table after the user enters them using the Drupal Form API. The form has a text box for list title, and a text area for entering symbols separated by space or comma. They can have multipe lists by clicking a 'add more' button. The data is stored in a flat structure of "-list_title1 sym1 sym2... -list_title2 sym1 sym2..." It is then split out for use in the UI. Some users have more than 300 symbols.

For the second iteration I would like to be able to store these symbols so that they can be referenced individually (deleted or added, notes about symbol) and the lists sortable. I would like to be able to utilize Views and features like Draggable_views so that the symbols could be re-orderd in a list. I would like users to be able to add symbols to their list from other content eg: news, trending symbols, symbol lookup.

There's a reference to $user->data in this Drupal8 article but I couldn't find more details on it.
https://www.webomelette.com/storing-user-data-such-preferences-drupal-8-using-userdata-service
The user_save api may work but I'm not sure how you would store this two-level data structure.
https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_save/7.x

I could not find any contrib modules for storing this data privately other than Profile2 which I don't think would work for this kind of content.
I'm looking for Drupal APIs to store this data on a per-user basis.


texts: How to create and display user content submission form?

texts:
Drupal 7

Could someone point me to the right direction on how to create a submission form through which users can post content? I have a specific content type that I expect the users to fill in while submitting.

I know it's horrible, but i was thinking to link to the relevant admin page, but there must be a better way (something like Views but for submission forms)

Thanks, Markus


texts: Why do I get "Command 'drupal-update' is not defined" when I run "composer drupal-update"?

texts:
I'm using Drupal 8.2.7 on XAMPP, on Windows 10. I am installing AMP via Composer, but I received an error  when I run composer drupal-update.

I ran the command from the Drupal root folder.

  [Symfony\Component\Console\Exception\CommandNotFoundException]
      Command "drupal-update" is not defined.

What happened?


texts: Building views relationship with location

texts: I have an article and food content types. I use location module fields in both content types. So for example, when I write an article about restaurants in New York, I choose article's location as country: US, state: NY and city:New York. Now, I want to be able to show related food items in view with same country, state and city. Now, how do I display food items matching with article's location.


texts: Loading Personal contact form and access denied

texts:
Into a user profile page I provide a personal contact to conact the profile woner and that contact form is loaded like this:

$recipient = user_load(array('uid' => $fptr->uid));
$output .= drupal_render(drupal_get_form(
    'contact_personal_form', $recipient));

The form shows up nicely and all is well so far. While testing this form after sending 5 test messages I get the warning that I cannot send more than 5 messages within 1 hour. That is OK, but it seems the access to the entire user profile page is denied and it screws up the page layout.

Is there any way I can just lock the personal contact form instead of locking the entire profile page?In other words, is there a way to check if an anonymous user can send a personal message, and based on that check to show or hide just the message form?

Thanks for your help, also I hope that is easy to accomplish:-)


texts: Taxonomy menu with custom path for taxonomy terms

texts:
I am trying to make a taxonomy menu using the Taxonomy Menu module with a custom path for the taxonomy terms. Instead of /taxonomy/term/tid I want /proj/!tid (or ultimately /proj/!term-name but I'll settle for what I can get). I have the taxonomy menu working fine when I leave the "menu path type" setting to default, which leaves it as /taxonomy/term/tid. Whenever I try to use the "vocabulary path" option though, the menu terms all disappear. I've tried to follow the instructions in the documentation here.

I have a view with Taxonomy: Term ID (with depth) and Taxonomy: Term ID depth modifier arguments and a page display with the path set to proj/%. I've tried additionally making a url alias at proj and proj/% but that didn't seem to make any difference. But basically whenever I set the menu path type to "vocabulary path" ("custom path" in the documentation), the menu items all disappear. The terms are still there, and I can navigate to /proj/%, but there are no menu items.

Any help with how to have a custom path for the vocabulary while keeping the menu items would be greatly appreciated.


texts: Install Webform on Drupal 8 : checkboxes greyed out

texts:
(Pretty much a Drupal newbie here)

I'm having difficulty completing he installation of "Webform version '8.x-5.0-rc3 released 4 February 2018'" on Drupal 8.4.5 on a development box running Windows 10.

My Webforms installation is in my htdocs\modules\custom\contrib\webform folder, and 13 modules are showing up in Drupal admin/modules. But I can’t click on the checkboxes to install any of these modules because they’re grayed out. I’ve been able to intall other modules successfully, both homebuilt and contributed ones.

Any thoughts on how to proceed? Thanks in advance…..


texts:
I am using boost for cache my website. the website can be accessed through multiple parked domains. When I clear all caches by accessing my admin area through one domain it clears the cached pages accessed through that domain. But when I visit a site through other domains it still shows the cached site.

Under public_html/cache/normal there is a list of folders for all domains.


texts:
What do I have to do to show help link in module menu?

My code looks like:

/**
 * Implements hook_help().
 */
function mymodule_help($path, $arg) {
  if ($path == 'admin/help#mymodule') {
    $output = '
' . t('About') . '
';
    $output .= '
' . t('descripton.') . '
';
    return $output;
  }
}


texts:
This may be some simple question, How to show the Add to cart button on the custom page,
I have listed the products in the custom page by programmatically, but displaying the "Add to Cart" button makes problem,

As I have displays the cart button using the below code,

  $line_item = commerce_product_line_item_new($productinfo);
  $wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
  $line_item->data['context']['product_ids'] = $productid;
  $line_item->quantity = 1;
  $qty = 1;
  $form_id = commerce_cart_add_to_cart_form_id(array($productid), $qty);
  $addtocart_form = drupal_get_form($form_id, $line_item);
  print render($addtocart_form);

it shows the Add to cart button but while clicking this, I got the below error,

Notice: Undefined index: quantity in commerce_cart_add_to_cart_form_validate() (line 2088 of \commerce\modules\cart\commerce_cart.module).
You must specify a valid quantity to add to the cart.
Notice: Undefined index: #datatype in commerce_cart_add_to_cart_form_validate() (line 2094 of \commerce\modules\cart\commerce_cart.module).
Notice: Undefined index: line_item_fields in commerce_cart_add_to_cart_form_validate() (line 2107 of \commerce\modules\cart\commerce_cart.module).
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in field_default_extract_form_values() (line 36 of \modules\field\field.default.inc).
Recoverable fatal error: Argument 2 passed to drupal_array_get_nested_value() must be an array, null given, called in \modules\field\field.default.inc on line 38 and defined in drupal_array_get_nested_value() (line 6811 of \includes\common.inc)

I think this error comes because of quantity field not in the add to cart form, how to add the quantity field in the add to cart form,

I am using drupal commerce,

what is wrong in my code?

thanks in advance.


texts:
needed to create some content types that have a field that creates a vote, as a poll.
Have you tested the modules and Advanced Poll Pollfield but as yet there is not a production version-these contain some errors.

Someone has a solution in order to implement content types with polls?


texts: How to prevent a field from wrapping in Views?

texts: I have a price field that gets squished and displays on multilines instead of a single line. The only way to solve this is to apply some css wrap magic?


texts:
I have managed to hide/lose the main menu bar - drupal 7.x.

overview of work I was doing:

I added mediaelements.js
I began adding videos to the site with add content
I attempted to make a Videos menu in the main menu

It was during some point of this process that I noticed the main menu bar was missing.
I have searched SE for solutions similar to  mine and have not had success with what was presented as solutions (having main menu in block and appearance settings toggled).
I have, so far, tried to go through each setting and compared them against settings in dev environment.
Are their other troubleshooting tasks I should follow which may point to a resolution?

thank you


texts: Is it possible to install Drush 9 without using Composer?

texts: Is it somehow possible to install Drush 9 without using Composer?


texts:
I've looked around for a couple hours but am not sure the best way to do what I need.

I need to set up a student teacher relationship so that when a student logs in on some pages viewed by the student the teachers picture and information will show up.

For example: the student logs in and is taken to the members area. Then the student clicks on lessons then on week 1 lesson 2. When the page for lesson 2 comes up it would have in the corner a picture of the teacher they are assigned to along with the teachers name, contact information...

What would be a good way to do this?


texts: How do I access webform components labels on the congratulations page

texts:
Am using the following code in the Congratulations page. There is more but this is the driving force to retrieve user submissions. Its working fine but I need to retreive as well the actual component labels. How do I include the actual questions (labels) on the form. Like if I have a component:

How old are you

10
25

How do I modify the code below to show "How old are you" on the congratulations page?

<?php
include_once(drupal_get_path('module', 'webform') .'/includes/webform.submissions.inc');
$nid = arg(1);
$sid = $_GET['sid'];
$submission = webform_get_submission($nid, $sid);
    for ($i = 1; $i <= 2; $i++) {
        echo $submission->data[$i]['value'][0];
    }
?>


texts: Views pager uses wrong URL when using views_embed_view()

texts:
I have a custom AJAX app which allows the user to filter some nodes, which uses a View. By custom AJAX app, I mean that this is not just a view with AJAX enabled.

The user accesses /reports which includes the output of views_embed_view(). An AJAX-enabled browser interacts with the page, resulting in an AJAX call to /reports/ajax to fetch just the results and save a full page re-load.

It all works, except that the results returned by the View in this case use /reports/ajax as the base URL for the pager (because that's the path used to invoke the custom AJAX controller), which means that when the user clicks one, they get a page of AJAX response.

I would like to train Views to use a different URL (i.e. /reports) for pager requests. Beyond a str_replace in the output of views_embed_view(), is there another way?


texts:
I am trying to use entity export to move existing entitys from a live to dev site. I tried the code below and it returned NULL int(1)
However, when I did a dump of the $node object, it did dump the object correctly, so I know that the entity exists

$query = new EntityFieldQuery();
$query
  ->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'events')
  ->propertyCondition('status', 1)
  ->propertyOrderBy('created', 'DESC');
$result = $query->execute();

$nids = array_keys($result['node']);
//var_dump($nids, 1);
$node = node_load($nids[0]);
var_dump($node,1);

//dpm(entity_get_info());
$entity  = entity_export('node', $node);
var_dump($entity,1);


texts: Form API 'image_button' vs 'submit' breaks my AJAX form

texts:
I have an AJAX form that works as expected with the following submit code:

$form['submit'] = array(
  '#type' => 'submit',
  '#value' => t('Go'),
);

I want to use an image for the button, but the type 'image_button' breaks the AJAX functionality (multiple repopulating select fields, won't appear, or update):

$form['submit'] = array(
  '#type' => 'image_button',
  '#src' => '/themes/moon/images/go.gif',
  '#value' => t('Go'),
);

Oddly, the 'image_button' works fine when clicking it (form works as expected) it's just the AJAX updating of the form that stops working? Drupal Form API Reference


texts: Deploying Drupal 7 with read-only DocumentRoot, especially concerning image handling

texts:
I'm deploying a Drupal 7 application in an environment where the web server's DocumentRoot is mounted read-only (so Drupals root directories and all directories below are not writable). For storing files a separate directory outside of DocumentRoot is provided which is mounted read/write. This directory is accessible from a separate web server instance (which only serves static files without executing PHP code, e.g. static.example.com).

What I did:

setting file_public_path to said writabke directory
implementing hook_file_url_alter to modify URIs in the public scheme to point to the separate web server instance

Everything seems to work fine (CSS, ...), except for delivering images. Drupal's concept for delivering images is whenever a requested image resolution isn't found on disk, the thumbnailing mechanism is invoked instead. The thumbnailer creates a new image, which is delivered to the requesting browser and stored below sites/default/files. Subsequent requests deliver the image directly from the disk (using Apache's rewrite rules, so PHP isn't involved any more).

Since we are using varnish in front of the web server, I'd prefer a different way of handling images:

images are served from a different virtual host (e.g. image.example.com)
thumbnailed images are never written to disk
instead a Cache-Control header is sent using a reasonable long max-age value, so varnish's LRU expiration mechanism can keep the often used images in memory and discard unused images

Any ideas how to accomplish this?


texts: Require First and Last Name on Comments in Drupal 7

texts: I enabled Comments on a content block in Drupal 7. I would like to have First and Last Name required on the comments. How do I make that happen?


texts: How to resolve configuration objects lang code differences?

texts:
The default language for my site is Arabic, but the administration bits are in English. This means that for now, the only needed translations are those of labels and the interface.
Earlier I tried to translate some of my content types and found most of them configured like this:

English
Arabic
None (original)  Edit

With this message above:

The configuration objects have different language codes so they cannot
be translated:

node.type.person: en
core.base_field_override.node.person.title: ar

I tried changing the language settings for the content type but the language remained set to 'None'. Any idea about how to fix this?


texts: How to union two views and pass on arguments

texts:
I want to union two views and pass on arguments from the first to the second view. Below is what I have so far. Not sure, if this is working. At least the bit to pass on arguments is still missing. Any ideas what I should put in the code?
use Drupal\views\Views;
use Drupal\views\ViewExecutable;

/**
 * Implements hook_views_pre_execute().
 */
function mymodule_views_pre_execute(ViewExecutable $view) {
  if ($view->id() == 'music_by_year' && $view->current_display = 'block_2') {

    $view_by_author = Views::getView('music_by_author');
    $view_by_author->setDisplay('block_1');
    $view_by_author->build();

    $query_by_author = $view_by_author->build_info['query'];

    $query_by_year = &$view->build_info['query'];
    $query_by_year->union($query_by_author);
  }
}


texts: How to query external database for Count

texts:
How do I query the below SQL query to an external database table from Drupal 8 custom module,

Select Count(requestID) FROM requestDB.request where request.dateCreated >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY) and ek_borrowerID = 111;

I have configured the settings.php already. Below is the query I tried to build, but it does not work

Database::setActiveConnection('requestDB');
$db = Database::getConnection();
$db->select('request')
    ->fields('request', array('Count(requestID)'))
    ->condition('dateCreated','DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY)', '>=')
    ->condition('ek_borrowerID','111')
    ->execute();
Database::setActiveConnection();


texts:
As the title suggests.

We have a menu with several top level items and then sub-menus under each element.

All the children for a given parent should expand when the parent is selected.

It works... most of the time then some times it does not... I can see no pattern to it. Clearing the site cache usually fixes it for a period but then the problem will return. Sometimes it will take days to reoccur other times it will take 5 min.

I cannot see any errors in the php error log file and no javascript errors being reported by the browser. Users on my network and elsewhere seem to be affected.

Can anyone give guidance as to what may be producing such an error? Is this a common error?

A 'sometimes' working menu is not really acceptable but locking it open is sub-optimal also as there are lots of children.


texts: alter query view by adding fields in an andGroup within an orGroup

texts:
I have a multilanguage site with two languages: English and Dutch.
Not all nodes are created in both languages. Some nodes even have no language ('und', 'zxx').
I want the default Drupal provided taxonomy view output all nodes of a taxonomy-term in the current and no node-language, AND, if present, other nodes of this term from the other language.
The Drupal provided sql is:
SELECT "taxonomy_index"."sticky" AS "taxonomy_index_sticky", "taxonomy_index"."created" AS "taxonomy_index_created",
"node_field_data"."nid" AS "nid", "node_field_data"."langcode" AS "node_field_data_langcode"
FROM {node_field_data} "node_field_data"
LEFT JOIN {taxonomy_index} "taxonomy_index" ON node_field_data.nid = taxonomy_index.nid
WHERE ((taxonomy_index.tid = '14')) AND (("node_field_data"."langcode" IN ('nl', 'und', 'zxx'))
AND ("taxonomy_index"."status" = '1'))
ORDER BY "taxonomy_index_sticky" DESC, "taxonomy_index_created" DESC
LIMIT 11 OFFSET 0

I want, if applicable, extend the where clause so it becomes by example:
WHERE (((taxonomy_index.tid = '14')) AND ((("node_field_data"."langcode" IN ('en', 'und', 'zxx'))
AND ("taxonomy_index"."status" = '1')))
OR (("taxonomy_index"."tid" = '14') AND ("node_field_data"."nid" IN ('43'))
AND ("node_field_data"."langcode" NOT IN ('en', 'und', 'zxx'))))

I wrote a function example_views_query_alter(ViewExecutable $view, QueryPluginBase $query) in which I found out which extra nodes should be added in the extra OR clause. By adding this code:
      $group_id = $query->setWhereGroup('OR');
      $query->addWhere($group_id, 'taxonomy_index.tid', $tid);
      $query->addWhere($group_id, 'node_field_data.nid', $missing, 'IN');
      $query->addWhere($group_id, 'node_field_data.langcode', $langcodes2, 'NOT IN');

But in the extended where clause I get OR instead of AND statements:
WHERE ((taxonomy_index.tid = '14')) AND ((("node_field_data"."langcode" IN ('en', 'und', 'zxx'))
AND ("taxonomy_index"."status" = '1'))
OR (("taxonomy_index"."tid" = '14') OR ("node_field_data"."nid" IN ('43'))
OR ("node_field_data"."langcode" NOT IN ('en', 'und', 'zxx'))))

But it should be an AND group within an OR Group, maybe like:
$query->setWhereGroup('OR');
$query->setWhereGroup('AND');
$query->addWhere(...

Who can help me out to achive this?


texts: In search result page, pagination is not showing up

texts:
I have migrated a site from Drupal 6 to Drupal 7. Search form I have rendered in page.tpl.php like this

<?php
     $block = module_invoke('search','block_view','form');
     print render($block['content']);
?>

I am able to search, but pagination is missing in the search result page.

In the theme folder I have search-results.tpl.php and search-results.tpl.php.

In the search-results.tpl.php <?php print $pager; ?>  is available.

If I change theme to default theme or core theme pagination is working fine.

What is the issue over here which is causing not showing pagination links?


texts: After logging off, a user is able to see the pages by pressing back button of the browser

texts:
I have a requirement in which the user should not be able to see the books in the site unless he is logged in. And the user is not able to see the content.

The problem is when a user logs in, views a book and its child pages, and logs out; he is still able to view the pages he opened before when he was logged in, by pressing the back button of the browser. He is not able to make any changes though.

This may create problems when users visit the site from a public computer, log off, and go away without closing the browser window.

Is there a module or any setting change I can use to solve this issue?


texts: How can I add a custom "Date" field as a field in a view?

texts: I created a custom Content Type called "Event". In it, I use a custom "Date" field (from the Date module). When I try to create a View that displays all of the Events sorted by their Date, I can do this. However, when I try to add a field for "Date" so that I can display it in the output, "Date" is not shown in the list of fields. Is this because not all content types have a "Date" field? How can I get around this?


texts:
I'm using panels and panelizer. I created a custom content in panelizer where I can upload a file. When I render the results, I have a lot of items. Now I want to paginate them.

How can I add the pagination in panelizer or use a view in panelizer?


texts: How can I programmatically load and display all available blocks?

texts:
$block = Drupal\block\Entity\Block::load($block_id);
ksm($block);

This code loads only one specific block. But how can I load and display all available blocks?


texts:
There are a few modules and methods specifically for disabling / removing the node summary page (at /node), like Node Page Disable, but I'm wondering if there's a way to redirect or override the page using the Page Manager module.

There's a good summary of other methods on this stack exchange question and answer and this Drupal forum post. One problem I'm running into with Page Manager is that the /node/%node path is already in use, and I'm not sure how to set it up for just the /node page without any additional arguments.


texts:
I am using the Drupal for Facebook module on both a D6 and D7 site to post to a FB page (not a group or a personal account/wall) via streams.

It is working fine except I would like the 'Post to Facebook' checkbox be automatically checked only when the node is created, but not on subsequent edits.  My users won't check this box on their own (and I may not even want them to see it).

I've tried using Rules, but there seems to be no FB posting action there.

I'm assuming it can be done via hook_form_alter, but have had no luck with that.  The Element ID for the checkbox is... fb_stream[fb_stream_do_post]

Any thoughts???

Thanks,

Eric


texts: How to check if the AMP module (Accelerated Mobile Pages) is working?

texts:
I'm testing the drupal AMP module (Accelerated Mobile Pages), well, I've installed it, pre-configured it (I've not created the subtheme..)but I've enabled it for one node (just for a test).

How can I test it ? Doing a google search on my browser ?

Thank you.


texts: How to enable contextual links for views content panes?

texts:
If I do not enable module "Views content panes", I see all block generated by Views in  "Miscellaneous" category. When I insert such block in my panels, contextual links are displayed well fore each block.

But If I enable "Views content panes" module, all views are moved to "Views" category and disappear from "Miscellaneous" category. I get some additional options, but I miss contextual links: no contextual links rendered for views.

How to output contextual links for views inserted with "Views content panes"?


texts:
I'm defining a base field for my custom content entity:

$fields['machine_name'] = BaseFieldDefinition::create('string')
  ->setLabel(t('Machine name'))
  ->addConstraint('UniqueField')
  ->addConstraint('Regex', ['pattern' => '[^a-z0-9_]+'])
  ->setTranslatable(false)
  ->setRequired(true);

However RegexValidator throws UnexpectedTypeException complaining that passed value is of type FieldItemList. This is obvious since in Drupal 8 even single value fields are lists (with one item).

So how can I use Regex validator with entity fields? Or do I have to write my own regex validator that will handle FieldItemLists?


texts: How to create custom placeholders on hook_menu, like "%node"?

texts:
For example, for menus like /node/%node:
when /node/1 is accessed, drupal automatically translates 1 as node_load(1);

I wanted to create something like /path/%student where, when /path/1 is accessed, I could translate 1 into student_load(1);


texts: Getting latest entity data from the database

texts:
The problem: I open a drush php:cli shell and run the following:
>>> \Drupal::entityTypeManager()->getStorage('paragraph')->load(477)->get('field_end_time')->getValue()[0]['value'];
=> "05:01"

I then change the value in the database to 05:02 via the admin panel (content section).
But if I run the same command again in the shell, I still get 05:01.
If I close the shell and open a new one I get 05:02. How do I demand the latest data without terminating the process and starting over? This seems like it must be a basic thing but I've searched far and wide and tried clearing caches and etc. but no dice.
This is affecting me because I have a PHP process that is started by cron that handles a Websocket connections and the same thing is happening there—it's getting stale data from the database.
Thanks for the help.


texts: Views date filter by year - only one select list for the year

texts:
I have a content type "news" and a views page to list the news. The views contains a exposed filter (category and year).

How can I realize the select list "Year" with the follwing options as exposed filter:

All
2016
2015
2014
2013
2012

When the user selects '2015' the list below is updatet (ajax) and only news entry form 2015 are listed.

How can I realize this?


texts:
How do I add a more/less link to drop-down and roll up a block?

I have a custom search block with a lot of field items and as such, the block is so long.
I want to be able to add a more link to drop down the redundant fields and less to roll up the block again.

I'm trying to do something similar to the search block on checki.com.ng. I am running a Drupal 7 site, naijabooker.com.


texts: How to avoid "An illegal choice has been detected" when updating select list values via ajax?

texts:
I have four entity reference fields to user entity in a form. Host form is node edit form.
Three of them are select lists, last is Inline Entity Form.

After adding a user entity via IEF I'm trying to update select lists values:

function ebep_users_feature_users_list_ajax($form, $form_state) {

  $ief = array_shift($form_state['inline_entity_form']);
  $options = array('_node' => t('- None -'));
  $commands = array();

  foreach($ief['entities'] as $data) {
    $options[$data['entity']->uid] = $data['entity']->name;
  }

  foreach(_ebep_users_feature_getUserListFieldNames() as $fieldName) {
    $form[$fieldName]['und']['#options'] = $options;
    $commands[] = ajax_command_replace('#'.$fieldName.'_wrapper', drupal_render($form[$fieldName]));
  }

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

It works, but when I try to add another user via IEF I am getting:

  An illegal choice has been detected. Please contact the site
  administrator.


texts: Why do functional tests require a running website?

texts:
I'm trying to set up functional tests in Drupal 9 using the BrowserTestBase class. The Type of Tests page on drupal.com and Browser test tutorial are quite clear that browser tests will build their own website and browser.

Browser tests create a complete Drupal installation and a virtual web
browser and then use the virtual web browser to walk the Drupal
install through a series of tests, just like you would do if you were
doing it by hand.

However, as soon as I try to run a browser test using run-tests.sh I get an error stating that the --url parameter needs to be provided (this led me down a rabbit hole: Curl error in basic functional test). There is a tutorial on running browser tests, which clarifies that the --url parameter is in fact needed.

In phpunit.xml make the following changes:

Set the SIMPLETEST_BASE_URL variable to the URL of your site.
Set the SIMPLETEST_DB variable to point to the URL of your Drupal database.
If you are placing phpunit.xml somewhere other than core, change the value of the phpunit tag's 'bootstrap' attribute to reflect the
new location.
For kernel and functional tests, set the BROWSERTEST_OUTPUT_DIRECTORY.

The section titled Run All PHPUnit Tests The Way The Testbot Does It sheds a bit of light on this by clarifying that when testbot runs a Browser test, it sets up a drupal site with the testing module enabled.

The first step is to make sure you have a fully working Drupal
installation, with the Testing module enabled. The drupal.org testbot
assumes that contributed modules will be installed inside the
modules/contrib directory and Drupal's application root for unit tests
is set to a value assuming this directory structure.

This seems to suggest that the browser test does not "create a complete Drupal installation" but rather requires one, but that leaves more questions about these tests.

Can the URL be any drupal site with the testing module enabled?
What changes does the test make to the website?
Do I need a fresh site everytime I run the tests?
Do I need to provide login details? Is that handled by the testing module?
What about the database, what changes are made to it? How do I revert them?

Any kind of clarity on how this works would be appreciated, as I think it will probably answer my other question as well.


texts: Database error after transferring Drupal 6 site

texts:
I just moved a Drupal 6 site from one server to another and have just started getting an error.

Warning: Table 'mydatabase.watchdog' doesn't exist.

The table does exist in the database and it does have the proper data in it. Some content does show up so the connection information is correct. Does anyone have any suggestions for this error? I am stumped.


texts:
How do you build up a LIKE condition in a db_select() query?

I know how to do this with a db_query() API call, but is there a special syntax / method for doing this with db_select()?


texts:
I just trying to save or insert data into a mysql from inside a custom module.

The table is 'my_table'.

I use this to insert:

  db_insert('my_table')->fields(array(
    'name' => 'Andy',
    'last_name' => 'Moore',

  ))->execute();

and this to update:

  db_update('my_table')
  ->fields(array(
    'name' => 'John'
  ))
  ->condition('last_name', 'Moore')
  ->execute();

So far so good, but now I need to update or insert a value:

If 'name=George' exist then update its 'last_name=Niels'. Otherwise if  'name=George' doesn't exist then create insert it with this values 'name=George' and 'last_name=Niels'


texts: Modifying page title with THEME_preprocess_page_title

texts:
I'm running Drupal 8.2.6, and an Adaptive subtheme and I am trying to modify the page title. I have created the following function in THEME.theme

function THEME_preprocess_page_title(&$variables) {
  $color_title = str_ireplace('some text', 'Some TEXT', $variables['title']);
  $variables['title'] = $color_title;
}

unfortunately, it's not working, at all. I've even tried just

$variables['title'] = 'Hello World';

to see if it would work, but no dice.

EDIT
So the hunt goes on!

Apparently AdaptiveTheme doesn't use the page title block, it writes it into node.html.twig via field--node--title.html.twig

so far, I have edited THEME_preprocess_field__node__title(&$variables) with no luck, but THEME_preprocess_node() seems to work. kind of. if i do

$variables['title'] = 'hello world';

it works, but it still won't let me put the span tags in. I have found the reason for that, titles aren't allowed to have code because of XSS threats.

OK. Fine. Fair enough.

There is options in the code to allow you to to allow certain tags (i found documentation, then i lost it ... argghh)

I will keep this question updated as I go


texts: What to do when there are defined constans in a module and you need to change it

texts: I have installed a module. In the module there are no configuration options. In the code of the .module, there is a cache time which is set to 20 minutes, in a constant. I need to refresh the data printed by the module with a cache of less than a minute (say seconds). The only solution I have found is to manually change the code and put a value define ('THIS_MODULE_CACHE_LENGTH', 0.1); //-- cache for 6 seconds. Is there another way of doing? Is it a bad designed module? (I do not mention the name if that is the reason). Please advice, because I am worried that with an upgrade to the module I will obviously loose the performance and will recover that excesive 20 minutes times (the module is for content which can upgrade very frenquently, so I do not understand the 20 minutes). Thanks!!


texts: See what path aliases are set up with Drush?

texts:
Ive installed Drush and my local system is a Mac. It seems to have worked as when I type drush into the terminal a long list of commands comes up.

When I type drush cc all I get the message 'drush' cache was cleared . Does that mean my path aliases are set up? Or could I be getting a false success message? I have a number of Drupal sites locally and I dont know which (if any) is having its cache cleared.


texts: How would I create conditional fields on install?

texts:
I am creating a content type in a module so that it gets created on install.

I got the fields and field instances in separate files and include those files in the .install file. I then call field_create_field() and field_create_instance() in the install file.

However, I also have conditional_fields for this content type. I have the code to create the conditions, what I need to know is what function do I now call from the .install file like I did with the other two field functions?


texts:
I made a module, and I want to add a JavaScript file to that module; I enable the module and obvious it works, but I didn't see the JavaScript file that module should take with.

I just put code similar to the following in hook_menu():

function my2form_menu() {
      drupal_add_js(drupal_get_path('module', 'my2form') . '/abc.js');
}

Is it OK?


texts: Prevent caching some selected parts of a html page

texts:
I've written a small block in php (used drupal) and have enabled caching because the page contains several static images. But I don't want contents of the block to be cached.

Tried to use Cache_Lite but it's not working. So is there a way to restrict some parts of the page prevent being cached?

thanks in advance...


texts:
To lock down access to nodes based on OG's, I have implemented a taxonomy as a group. The users can then can select that taxonomy and access level for each content. Is anyone aware of pitfalls I need to watch out for doing it this way?

I apologize if this is out of scope for this site.


texts: dynamic options list based on the previous select box value

texts: I have a webform. I want the second select box values to be loaded based on the 1st select box value. And these values should be loaded from DB table. Please let me know which hook i need to use and how to do it.


texts:
In using URL aliases, is there a way to have conditional token usage? An example of what I'm looking for is:

I have programs on my page, each having their own unique program code.

By default, say my program is General Arts, the URL alias would be /programs/general-arts

However, sometimes, the programs may have multiple program codes due to being taught in different locations.

What I'd like (if it's possible at all) is when I create another program with the same name (let's use General Arts again for example), except it has a different program code, I'd like the URL alias' to then be /programs/general-arts-C123 for the first one and /programs/general-arts-D321 for the second one because they're the same program, just different program codes (due to being taught in different locations). Pretty much appending the course code to the end of the URL to distinguish the two.

Or is the only way to do something like this is to manually override the URL alias and put the custom URL in?


texts: Create a Redirect for a page if its unpublished / deleted

texts:
We have an issue when a page is deleted/ unpublished someone forgets to add a redirect.

Now what i am looking for is when someone is about to unpublished a page or delete it, we pop something up that will offer a user a list of pages and they can select which one it should go to.

Any ideas where I should start with this and what hooks I could use.


texts: Automatically close webform after submission

texts:
I have created a Webform with some terms & condition. I have added this webform in node/upload page. When user access node/upload page webform comes as overlay on the page. When user selects all terms & condition and submits it redirects to another page which as close link. When close link is clicked webform hides.

What I want is instead clicking on close link to hide the webform. When user submits the terms & conditions the webform must be hidden. How can i achieve this. I have added screen shot of webforms.

I have added this code to get the webform in node/upload page

 if (!isset($user->data['guided'])) {
  $form['#attached']['js'][] = drupal_get_path('module', 'my_module') . '/js/my_module_ajax.js';
}
ctools_include('modal');
ctools_modal_add_js();
if (!isset($user->data['guided'])) {
$form['guideline'] = array(
  '#markup' => '
' . t('Review and follow the guidelines outlined in the Submission guidelines before uploading an item.', array('@guideline-page' => url('modal_forms/nojs/webform/' . 31))) . '
',
  '#weight' => -0.01,
);
}


texts: Move Comment form/render out of node.tpl.php (into separate region)

texts:
I would like to render the $content['comments'] part of my nodes outside the node.tpl.php file, and have the comments (form and all) rendered in a separate region of my theme.

I've noticed Commentsblock does something along these lines, but requires a view, and doesn't seem too complete.

Could I do some preprocessing to get the entire comments renderable array into the page.tpl.php template if I'm on a certain node type page, rather than rendering the array inside node.tpl.php? (Something along the lines of this comment).

Also, wouldn't simply not rendering the $content['comments'], and then getting the comments via some other method (like a View, how Commentsblock works) cause Drupal to load all the comments twice (worse performance, etc.)?


texts: Is there a way to minify HTML in Drupal 8, something like the Minify module which is for Drupal 7?


texts: How to show views filters on a block or page

texts:
I have a view with exposed filters to customers.

I want the exposed filters on a separate page/block and views result on a  separate page.

How to do this.


texts: Create Bundle Product link - Not found, missing

texts:
I have done a basic install of Drupal v7.43 with Commerce Kickstart (commerce_kickstart-7.x-2.34)
Both Commerce Bundle modules are enabled.

In "Add Product" actions I cannot find the "Bundle Product" link in order to create a new Bundle Product with some of the existing (previous added) Bundle Groups.

Also, the "Create Bundle Group" link is missing but I found it in the page: /admin/commerce/products/add.

Why are they missing?


texts: How to decode base64 image using pre save hook?

texts:
I am uploading image using jsonapi. But here the data is base64 format (As per requirement). Uploading to media entity. So I need to write a hook media entity pre save so that file uploaded should be decoded in our drupal backend. I am following this link :- https://www.drupal.org/node/3024331 .
/**

* Implements hook_ENTITY_TYPE_presave().
 */

     function hook_media_presave(MediaInterface $entity) {
        if ($entity->bundle() == 'image') {

            // need help here to convert

          }
         }


texts: change node author with rules. using an array of users with specific role

texts:
I am creating nodes with rules and the default author for these nodes is the user 1 (admin).

I have a set of users as 'administrator' roles.
e.g: John, Jack, Sophie

Is it possbible with rules(or custom php code in rules) to change the author from admin to one of the 'administrators' in randomly fashion.

workflow:
create node, author admin --> rule --> change author to John, Jack or Sophie --> save node


texts:
I have a question about using Varnish along with the Drupal page cache. I was wondering if using both of them is a bit redundant, since Varnish already caches pages for anonymous users?

Currently I have page cache off, page cache max-age zero and cache lifetime set to 10 minutes.

Am I reasoning this right or am I just missing something obvious?

Thanks.


texts:
I am in the process of building out a community site where each 'network' (like an OG group) can set up it's own RSS feed (simply by pasting the URL into their network node's 'network_feed' field).

I am in the early stages of figuring out how to build and implement a system whereby I can run through all those feeds (for networks that have them) and aggregate them, posting new nodes that contain node references back to the main network for each new item in the feeds.

I have had some limited experience with the Feeds module, and it seems the best candidate for this (Aggregator in D7 core seems a bit less hardy), but I didn't know if there was something I was missing that would make this much easier.

I'm thinking, right now, that I'll build some sort of system that queues up all the URLs contained in 'network_feed' fields, then maybe hook into some of the feeds.module's methods to retrieve and parse the nodes. Instead of doing this manually, does anyone know if there's something prewritten for Feeds, Aggregator, or another solution that does this kind of thing?


texts:
I already generate my xml sitemap with drupal module "sitemap" now i wanted to show that sitemap inside a view.

It is possible to do this?

Thanks


texts:
I have 2 pages that are highly customized per user, and I happen to know exactly when certain users are going to log in (this site is used by students during classtime). I have APC and memcache helping, but they are basically worthless here since my users hit these pages once or twice right at the beginning of their session and don't often return, but may spend over 10 seconds waiting for the page to generate when 40 users all log in at once and try to get the different versions of the same page.

I plan on significantly redoing these pages to make them less resource intensive, but for the moment, I'd love to be able to schedule a cron job to do a cache warm 10 minutes before class starts so they have a better experience sooner. Is there any way to do a cache warm for pages that are custom per user when I don't have their password?


texts: External script fails to load all drivers

texts:
Attempting to create an external script that allows me to query some things in Drupal. I was hoping to be able to use my external databases I have defined in the settings of my site to query some of their tables. As one of the databses is Oracle based I have the http://drupal.org/project/oracle module installed.

The following is a PHP script outside of PHP but on the same server (different host):

$_SERVER['HTTP_HOST'] = 'www.example.com';

define('DRUPAL_ROOT','/usr/share/drupal7/');

//require the bootstrap include
require_once DRUPAL_ROOT.'./includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$db1 = Database::getConnection('oracle','external');
$sql = "SELECT * from accounts";
$result = $db1->query($sql);
$accounts = $result->fetchObject();
print_r($accounts);

This code errors with:

PDOException: could not find driver in main()

The same code (just the Database::getConnection down) running from within a Drupal page works fine. What can I do to make this code execute externally?


texts: Efficient way to keep Drupal 7 session alive from another web app?

texts:
Is there a simple PHP file I could create which, when called by an authenticated user, will keep their Drupal session alive?

I don't want to do an AJAX call to /index.php as this will cause unnecessary overhead. I just need a way to keep the session alive from another app.

Could I use the bootstrap method below, rather than instantiating the whole stack?

<?php
    define('DRUPAL_ROOT', '/my/local/root');
    include_once(DRUPAL_ROOT . '/includes/bootstrap.inc');
    drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
?>


texts: How to check Commerce product type of current line item in Rules?

texts:
When building a Drupal Commerce rule, I would like to loop over all line items and determine the product type for each line item. I would like to use the product type in a Rules Component to check whether the product is a certain type.

How can I check the line item product type when looping over line items in a Drupal Commerce shopping cart?


texts: ge7Locations-7.x-1.13 does not show in the modules administration in Drupal 7.31

texts:
Installed getlocations-7.x-1.13 on the sites/all/libraries/
but it does not show in the modules or administration/configuration/services
what to do?  Thanks


texts: Drupal 8 Looking for an elegant alternative of rowCount in a query

texts:
In Drupal 8 we can not use the rowCount property anymore in case of a select statement. Is there an elegant alternative?

I can use a foreach, but when converting from Drupal 7 I would like to replace the result->rowCount() more elegantly


texts:
Am loving using Drupal 6 for creating a site with more than one user "type", with different Content Profiles, different Roles with associated Permissions, different access to nodes etc. My current site has 3 different roles - Recruiters, Candidates and a Simple Administrator (as a reduced feature subset administrator, to limit the amount of damage that a non-technical administrator can do to the site, yet still do things like edit the outgoing emails, add/remove users etc).

I was wondering... when I am testing, I am currently using multiple browsers (dev in Firefox, Testing one user type in Chrome, one in ie9) to get around the "current" session issue (you can only be logged in as one user). What techniques do people use to test on multiple roles simultaneously? Is there, for example, a Firefox plugin or something else to isolate different browser based session cookies in different tabs?


texts: Use order number instead of order id in Drupal Commerce checkout URLs

texts:
I'm trying to make the order_number be a randomly generated alphanumeric string and use it as the only customer facing unique ID that the customer ever sees relating to their order.  However, the auto-incremented order_id still appears in all the checkout and order URLs.

Looking for examples of if this is being done in the wild on https://drupalcommerce.org/showcase, I found Lush, whose order_id increments by multiples of 5 in the checkout and order URLs.  It's hard to tell if this is still the order_id or the order_number being displayed in the URL.

A popular solution is to change the order_number into an alphanumeric pattern on hook_commerce_order_presave(), like what’s mentioned here: https://drupalcommerce.org/discussions/8900/how-change-order-number-numerical-default-alpanumeric-pattern.  The problem with that is the order number gets a new format, but the order id itself remains the auto-incremented integer and is still displayed in the checkout and order URLs.

Most examples I found recommend altering the commerce_order table and setting the starting order id to 1000 and letting it increment by 1 from there.  Like what’s mentioned here: https://drupalcommerce.org/questions/3172/how-can-i-change-starting-order-number.  This is a somewhat better solution, but still not as customizable as I would like because the order_id is still incrementing by 1.

The most promising solution seems to be encrypting and decrypting the order_id in the URL using hook_url_inbound_alter() and hook_url_outbound_alter(), like what’s mentioned here:
Drupal Commerce | Hide or set an alias to the order number in the checkout path.  This however requires the php mcrypt library, which I will not be able to use on my production server.

Any help, examples, or advice would be greatly appreciated!


texts: Programmatically created revision set as the main node instead of revision

texts:
I am using D8 and creating revision for a node with the following code.

  $nid = "my_node_id";
  $node = \Drupal\node\Entity\Node::load($nid);
// Make this change a new revision
  $node->setNewRevision(TRUE);
  $node->revision_log = 'Created revision for node' . $nid;
  $node->setRevisionCreationTime(REQUEST_TIME);
  $node->setRevisionUserId($user_id);
  $node->save();

When I create a revision, it is set as the main revision, instead of one of the revisions. Is it taking the revision timestamp when creating, and pushing latest to the top? Is there a function that tells me I am using the latest revision?


texts: How can we pass And condition as slash( / ) in views contexual filter?

texts:
I have allowed multiple values in contexual filter (has taxonomy term id). Content is filtering based on multiple taxonomies like 12,14,16 when we are passing term ids in contexual filter.

But how can we get the same result when we pass the term ids in such format 12/14/16?

Actually I am working on REST API and I have to create URL something like :recipe/term1/term2/term2

What I have tried:

use Drupal\views\Views;
use Symfony\Component\HttpFoundation\Request;

$view_id = 'rest_api_ravi';
$display_id = 'rest_export_1';
$filters = [
    'field_recipe_tags' => ['12' , '124'],
];
$view = Views::getView($view_id);
$view->setDisplay($display_id);
$request = new Request($filters);
$view->setRequest($request);
dpm($request);

$view->execute();
$view_result = \Drupal::service('renderer')->renderRoot($view->render());

$view_json_decode = json_decode($view_result);

dpm($view_json_decode);

But it's giving no result.


texts: View mode template for user-profile.tpl.php?

texts:
I can set up a view mode for the user profile, but I don't know how to create a template targeting it. user-profile.tpl.php is the template used, but I can't figure out how to make a view-mode targeted version of it.

Any suggestion?


texts: Utilizing private methods/vars inside module

texts:
I'm creating a custom module which uses a few hooks and then after the form is submitted it will dive into custom PHP interaction that interfaces with an external restful API.

I want some of these variables and functions to be private as they will contain business rules and some variables that I wouldn't want someone to get their hands on (easily).

I'm uncertain of how to do this in Drupal. I understand that I would need to create a PHP class which would then have private/public methods available inside of it. But how do I do this?

Do I build this PHP class in its own file outside of my .module file and then use files[] = includes/MyClass.class.php in my .info file to import this external class file in?

Then once it's successfully imported in I could instantiate it with $something = new MyClass();?

Is it that simple to do, or is there another/better way?


texts: append settings.php during profile installation

texts:
I would like to add lines to my settings.php during my custom installation. I'm using some $conf['...'] to match external content to my drupal and i would like not to do this by modifying directly the file.
During my custom install i want to use the external content to have a fully operational website after running my script.

Do you have an idea how i can do this ?

Thanks.


texts:
I'm creating a collection manager for movies and books in Drupal 8. Now I have a content type called "collection" and one that is called "Movie". The collection is just a collection of different movies. Now I'm searching for a way that a user can give another user access to his collections and movies.

How can I achieve this in my module?


texts: Handling uploaded resources for local development

texts:
With our Drupal site we develop locally, commit to svn and deploy to the live site. Some content gets uploaded on the live site (some images, videos etc). I am trying to sort out the best way to handle those uploaded resources.

Currently, we do daily database dumps, and use those for local development, but if someone has edited a page and added an image, it will 404 on the local since the image doesn't exist.

I rsync content down, but not all the team has ssh access (security). Should I tar up the uploaded assets at the same time as the database dumps? Or, is there a better way to handle this?

Basically; Whats the best way of getting uploaded content, for local development?


texts: Panels template files: Inheriting a tpl file in a sub theme

texts:
In my Drupal custom parent theme, I have included a file called panels-pane.tpl.php.
This is the main panel pane template. By including this tpl file in my theme, I can override the one in the Panels module folder, which allows me to control its mark-up.

It all works fine. However, when I enable a sub theme that is based on the parent theme, this particular file is ignored. All the other files are inherited.

How can I get this file to be inherited as well?

Would it be possible to force this to be always loaded regardless of the theme?

Please note: I am talking about overriding the panels-pane.tpl.php that comes from the original Panels module. I am not talking about creating a custom Panels layout.

Steps I have tried:

Copying the panels-pane.tpl.php into the sub themes template directory.
Clearing the caches
Uninstalling and then re-enable the parent and sub themes

UPDATED
Panels has a file called panels.module. In it has a function called panels_theme(), which contains the following:

  $theme['panels_pane'] = array(
    'variables' => array('output' => array(), 'pane' => array(), 'display' => array()),
    'path' => drupal_get_path('module', 'panels') . '/templates',
    'template' => 'panels-pane',
  );

Can I use this to control panels-pane.tpl.php from inside a module by using theme_registry_alter?

I have tried the following code, but it doesn't work:

function legendary_theme_registry_alter(&$theme_registry) {
 $theme['panels_pane'] = array(
    'variables' => array('output' => array(), 'pane' => array(), 'display' => array()),
    'path' => drupal_get_path('theme', 'legendary') . '/templates',
    'template' => 'panels-pane',
  );
}


texts: Ajax form submission error when using use-ajax-submit

texts:
I receive the following message when I attempt to submit a form with use-ajax-submit class attached to the submit button:

  An error occurred while attempting to process /my_form?_wrapper_format=drupal_ajax: ajax.$form.ajaxSubmit is not a function

Similar to this question, but for Drupal 8.


texts: How does Drupal know when to run an update script?

texts:
How does Drupal 8 know what module needs updating and to what version he needs to update?

I have build a module and I'm trying to update it (adding a table). I implemented a update hook numbered 8001, which is the first update, but when I go to update.php Drupal does not see any update for my module.

I expect there must be a place in my module where I can define the current version of my module and another place in the database where Drupal stores the latest installed update of my module. (I need this for debugging the update script later on.)


texts:
I developed a site in Php using Laravel 4. This site will show many articles and images, that´s why I start to use Drupal 7  for present those,  but the problem is that  I cant't found how manage only one drupal site and one sub directory for the application inside it.

I had seek but only found how use many sites but all using drupal, and include modules too, but no applications. Could someone help me please ?

Thanks.

The site is only one and  it is developed in Laravel 4 but I want to use the features of the Drupal for add content and images, post, user management etc.

But Laravel manage routes and ORM to access the database and easy to integrate with bootstrap. That's why I used Laravel to develop the aplications.
So to add content I want to use drupal.

I have a directory as:

HTDOCS

    Aplication

    Drupal

But I want to has someone like this;

 HTDOCS
   Drupal/Aplication

Thanks.

<VirtualHost *:80>
   ServerName www.BolsaGame.com
   DocumentRoot "C:/Servidor WEB/www/Drupal"
</VirtualHost>


texts: Disabling some modules installed via a feature

texts:
Is it possible to disable a module that was installed via a feature?

For example, I'm using a theme that came with a feature that installed a lot of modules, I realized that I don't need a bunch of the modules, but I can't disable them in the module page (the 'enabled' checkbox can't be toggled anymore).

Is it possible to just remove the feature but keep each individual modules configuration?


texts: Is it possible to suppress another module's warnings? My module calls another causing a warning to appear.


texts: View will not display taxonomy location information

texts:
I have a taxonomy that contains information about event venues. I am using the location module to add locative information to these taxonomy terms.

I've created a view so that I can see all my venues and their location information, but the location information is not appearing in the view.

Here's a screenshot of the view I have built, but the location information does not appear!

Each term has its location info filled in:


texts: Does calling query() on a container prevent SQL Injection?

texts:
According to this link, db_query is now deprecated, and should be replaced by calling query() on a container containing a service injected with a database connection.

How do you prevent SQL Injection when using query()? The docs only cover how to do so when using db_query(), which is deprecated.

Thanks.


texts: How to disable creating links for content types?

texts:
I don't want my slideshow text and image to be accessible in url (it is a contentype called slider).

Because normaly nobody will access that, but if he knows the url he can access that and also google bot etc.

I am using this content type only in Views Block.

I don't need pages.

How to do that?

Any module or template?


texts: Load jquery action on link menu click/node load

texts:
So what I would like to do is great a sliding door effect for my drupal site using jquery-ui action. Does anyone know of examples or a module for this?

Also I would like the action to execute on two triggers.
            -open close sliding door on "menu link to new node click"
            -close sliding door once node is loaded

I've seen example for what I want to do and I know that you can insert jquery-ui. All I need to know is where do I need to insert the jqurey-ui. Examples would be great!


texts:
I have looked at previous posts but can't seem to get the following to work. It just displays the form line all the time, I can get it to work when checking for just a single option.

$form['type'] = array(
  '#type' => 'radios',
  '#options' => array(
    '10' => '10',
    '29' => '29',
    '30' => '30',
  ),
  '#title' => '',
);

$form['line'] = array(
  '#type' => 'radios',
  '#options' => array(
    '1' => '1',
    '2' => '2',
    '3' => '3',
  ),
  '#title' => '',
  '#states' => array(
    'visible' => array(
      ':input[name="type"]' => array(
        array('value' => '29'),
        array('value' => '30'),
      )
    ),
  ),
);