texts: Where to programmatically enable a Feature module

texts:
I created a Drupal 7 feature and usually I would enable it with Drush, but someone suggested that I enable it with an update hook (which I assume means it gets enabled on updb or update.php).

I saw this discussion on enabling modules programmatically How do I programmatically install and enable a module?, but it blithely skips over where to write the code. Does it go somewhere in the installation profile? Does it have to be called from another custom module that is already enabled?

I'm actually an experienced Drupaler that has somehow managed to miss this one crucial lesson, I've just been using Drush to enable modules but I want to do this the best way.


texts:
I am using drupal 8 and I am trying to get the layout of my content type "jacuzzi" to go from this:

To this

As you can see, I am using bootstrap. What do I have to change (css or tpl or something else?) to group the text fields and add the right classes?

Thanks in advance


texts: Why isn't code for $op == 'presave' being executed in hook_nodeapi?

texts:
I want the administrator users can publish nodes of the story content type; the other roles can unpublish. The following is the code I am using, but it doesn't work. I unchecked the box "published", which is in the "story" content type.

   function mymodulename_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
     global $user;

     if ($op== 'presave' && $node->type == 'story') {
       if (in_array('administrator',array_values($user->roles))) {
         $node->status = 1;
       }
     }
   }

I am using echo 'test' above on the if ($op....), the page outputs "test." When I put the echo 'test' into if body, the page doesn't output "test." but When I delete $op == 'presave'， it can output "test."


texts: how to create domain specific domain admin

texts:
I am using domain access module to create different sites using subdomain. I want to create domain specifc admins so that they can view only listing of their own domain and want to able to install modules,themes etc all action on their specific domains.

Only Super admin should able to see all listings without any restricitons .

How can I achieve this ?

Thanks


texts: Print out custom field and footer in newsletter

texts:
1. I have two fields in my newsletter content, the normal 'Body' and another called 'The List' (.field-field-thelist). I am trying to print this out in the newsletter but I cannot seem to get it working.

htmlmail-simplenews.tpl.php:

// this doesn't work
<?php print $node->field_field_list[0]['view'] ?>

I don't think I am doing this correctly, but I am basing it from this walkthrough.

2. For some reason when I call the newsletter to print $body (simplenews-newsletter-body.tpl.php), it also prints the $footer (simplenews-newsletter-footer.tpl.php) content ($footer doesn't actually print anything alone).

htmlmail-simplenews.tpl.php:

//Prints body AND footer for some reason, I want to separate these as two variables
<?php echo $body; ?>

The reason #2 confuses me is because there is very clearly 2 variables for each a body and footer in the simplnews.module file. Is there another way I can call these separately?

Note: I am not using Views for this newsletter


texts: Missing edit tabs on only one content type

texts:
I have a custom node template for a particular content type, and it seems that the "view" and "edit" tabs are missing on nodes of that type. However, it doesn't appear that the node templates typically have accesss to the $tabs array; that seems to be something that goes in page.tpl.php (which I haven't overridden or altered). It still work for other node types though, so it must be something in the node template.

When I add a dsm($tabs); to the page.tpl.php and view a node of my custom type, it displays the arrays containing the info for the tabs, so it can't be that my user doesn't have permission, or the tabs wouldn't load any info at all, right?

What should I do to my node template to fix this?


texts: How to hide flag link if current user and author are same?

texts:
I need to hide flag link if the logged in user and the author are same.  Please find below codes.

function MODULE-NAME_views_pre_view(&$view, &$display_id, &$args)
{
    global $user;
    if ($view->name == 'VIEW-NAME' && $display_id == 'DISPLAY-ID') {
        $node = node_load(arg(1));
        if($node->uid == $user->uid){
            //echo 'hide flag';
        }else{
            //echo 'show flag';
        }
    }
}


texts:
I have two content types and a view that I want to count the number of Requests per Trial. The thing is I want to filter the Requests in a view of the Trials. Here's the problem laid out:

Content Types:
 - "Request"
 - "Trial"

"Request" has an entity reference field that references "Trial." (user can request a trial).

Aggregated view that lists the Trials with the number of Requests referenced to it. This is working fine now, but I need to filter the number of requests by workflow state.

___________________________________________________________
| Trial                              | Number of Requests |
| Example Trial Name                 | 10                 |
| Another one                        | 2                  |

The trick is that I want to filter the number of Requests according to their workflow state. I can filter the Trials in their own view, but I'm not sure how to "pre-"filter the referenced nodes.


texts:
beginner here,

I am trying to follow the typical entity example and create my own entity in Drupal 7. So I basically changed the name from typical_entity_example_1 to source_entity and the test fails (see picture below). I'm not sure what I'm doing incorrectly, any advice would be much appreciated.

install file:

function source_entity_schema() {
  $schema = array();
  $schema['source_entity'] = array(
    'description' => 'The base table for source_entity.',
    'fields' => array(
      'teid' => array(
        'description' => 'The primary identifier.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'title' => array(
        'description' => 'Entity title.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'description' => array(
        'description' => 'Entity description.',
        'type' => 'text',
      ),
    ),
    'primary key' => array('teid'),
  );
  return $schema;
}

Module file:

<?php

function source_entity_info() {
  $info = array(
    'source_entity' => array(
      'label' => t('Source Entity 1'),
      'base table' => 'source_entity',
      'entity keys' => array(
        'id' => 'teid',
      ),
    ),
  );
  return $info;
}

Test file

class SourceEntityUnitTestCase extends DrupalWebTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Source Entity Test 1',
      'description' => 'Check existence and possibilities of source_entity.',
      'group' => 'Source Entity',
    );
  }

  public function setUp() {
    parent::setUp('source_entity');
  }

  public function testSourceEntity1() {
    $entity_description = entity_get_info('source_entity');
    $this->assertEqual($entity_description['base table'], 'source_entity', t("Entity type 'source_entity' exists."));

    $new_entity = entity_create('source_entity', array());
    $this->assertFalse($new_entity, t("Can't create an instance of source_entity because 'source_entity' entity type has not create callback."));
  }

}


texts: error "EntityMalformedException" when creating a node as guest

texts:
We have a node type with permission to create new nodes for guests. When we try to create a new node of this type as guest we get the following error:

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7844 of /var/www/miwula/includes/common.inc).

In watchdog I get only the same message and nothing in apache's log.

I created a new node type with no other fields and with create permissions for guests too. Same problem.

I have no idea what I can do.


texts: How to display the abstract with javascript

texts:
I have a page that is a list of items, where I show the article title, author and abstract, but I want to show the abstract with javascript, a link that says show abstract and when I click out the absract od this article.

Then when clicking on the same link that hide the abstract.

Any idea to do this.
PS: I am using the latest version of Drupal 7.


texts: I came across this video showing how to setup custom home page using Panels. I installed the Chaos tool suite, and Panels modules, but I don't see the Layout designer interface anywhere as it is shown in the video.


texts: Javascript code appears in search results

texts:
I use JavaScript in the body of a node with some PHP code. After I run cron.php and search on the site, I can see Drupal indexes the JavaScript code contained in a node.

How do I avoid Drupal indexes the JavaScript code?
Alternatively, how do I avoid Drupal indexes those nodes?


texts:
I am attempting to add history states to view items that are loaded using the infitine scroll module. On my first attempt, I am adding the following code to the infinite scroll.js file in the load section. I have partial success in using Drupal.settings.basePath variable, however, I would like to get the node that gets loaded as opposed to the baseurl. Is there a call in javascript for this? Here is my sample so far:

var baseUrl = Drupal.settings.basePath;
history.pushState('', '', baseUrl);


texts: Prevent cron from flushing the cache indiscriminately?

texts:
I use Drupal 6 with the Cache Backport module, and all the available cache tables are configured to be stored in Redis (similar to Memcached in function for RAM caching). The caching works very well.

I have noticed that the amount of data stored in Redis gradually grows as the cache warms up, which is expected. However, the amount of stored data regularly drops suddenly to almost nothing.

I ran a test by loading up the cache by running a search for the word "the". Usually the amount of data stored in Redis will climb to between 20 and 40 MB on that query. Then, I ran the filter_cron job (I use the Ultimate Cron module and can run the different cron jobs selectively.) The Redis memory immediately dropped to almost nothing. After loading up the cache again to 20 - 40 MB, I ran the system_cron, which instantly resulted in Redis memory dropping even lower than it did on filter_cron. Both of these results are repeatable every time. So obviously both of the system and the filter cron jobs are indiscriminately flushing the Redis cache, which negates the purpose of a cache.

Can I prevent cron jobs from flushing the Redis cache, and if so, how? Is there not effective intelligent cache expiration logic on an individual key basis? Or would the cache system malfunction if I prevented it from being completely flushed by the cron job?

Thanks a lot for the help!


texts: Creating a Views Search Page AND Block (not just a search block and results page)

texts:
I have a site with a box on the home page (only) that has a search box. I also have a 'search' link available on all pages of the site, in the navigation. The search link takes the user to a page called 'Search' where the search box appears (again) and allows them to do searches there. I've built the search for that page so the search box appears and the results display only after the user types in a search.

The main question I have is this: how do I create a block for the home page that ONLY displays the search box (results of such search still showing on the results page I've created in Views)?

I know how to expose the View as a block but this doesn't solve my issue because I want the search box itself to still show on the results page too.


texts: drupal webservice error Access denied for user anonymous

texts:
experts:

I am new to drupal webservice,when I have set up the backend drupal webservice,I am trying
to use firefox poster plugin to test the user/login function but I always get "Access denied for user anonymous" message ,after what I have check and searched the solution all around internet I can't find out why this error happen,could anyone who kindly take a look and help me?thank you so much in advance.

1 using firefox poster to post message and get response like below snapshot:

2 after checked the http message in fiddler,I still confused that every thing seems correct
but still error message for "Access denied for user anonymous"

3 here is my webservice configration:


texts:
I made upgrade from 7.16 version to 7.19, everything works ok, but on Available updates it says Installed version is 7.16.

I done everything like drupal update steps say. Removed all old files of drupal core and put new one, made update.php for database.

What I do wrong?


texts:
I want to list all the posts with alphabetical headings like this site:

How can I do this with drupal 7 using views?


texts: Webform, let data expire after a period of time

texts:
How might I expire data collected in Webform? That is, I'd like to purge data after a period of 6 to 18 months.

Alternatively, I'd be happy to find a module that cleans up old data in a Drupal 7 database.


texts: How to print page/node templates being used on a page?

texts:
I'm using Drupal 6.19 and trying to debug why a custom page template for my login page isn't being picked up.
I've tried to use devel themer, but I don't see the "widget" when I'm not logged in, and of course I can't see the login page when I am.

I'm hoping for a script that I can drop in on my page tpl that will print the current template being used. Or maybe there are other suggestions?


texts: Accessing Webforms Parameters in hook_form_alter

texts:
I got a webform which is embedded in a paragraph template. I do this via renderArray which works pretty well - the form is embedded. However I need to grab parameters - the only example I could find is about how to get "GET" parameters or about how to set default values via parameter. This is not what I need. I need the host paragraph as ID in my hook_form_alter. But I cannot find the value.

     {{ {
       '#type': 'webform',
       '#webform': 'contact',
       '#values': {
         'paragraph_context': 21
       },
       '#parameters':[{'a':'1122'}]
       } }}

The hook_form_alter $form array should contain either "#values" or '#parameters' but they are not included. - at least not in an easy findable location.

Are they in any deep sub sub sub location in the array?
or is there a mystic way to define the parameters for the webform, so hooks can pick them up?

Oh when you ask your self why I just don't use the default value to fill the value of a field directly... The reason would be, that I actually have to create the select form field options first. That's why I need the id to the paragraph - it contains all the holy data stored in its entity.
===================================== EDIT ================
After 3 hours of searching and heavy use of Xdebug I found it.
$form_state->build_info["callback_object"]->originalData['value_name']

However it is a protected property. So I cannot access the value. There must be an easier way to get form parameters. Is there any?


texts:
After Install site, when I need to Configure Site, I got this error:
Error
The website encountered an unexpected error. Please try again later.
Error: Call to a member function setRecipients() on null in standard_form_install_configure_submit() (line 25 of core\profiles\standard\standard.profile).
standard_form_install_configure_submit(Array, Object)
call_user_func_array('standard_form_install_configure_submit', Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('install_configure_form', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm('Drupal\Core\Installer\Form\SiteConfigureForm', Object) (Line: 948)
install_get_form('Drupal\Core\Installer\Form\SiteConfigureForm', Array) (Line: 617)
install_run_task(Array, Array) (Line: 570)
install_run_tasks(Array, NULL) (Line: 118)
install_drupal(Object) (Line: 44)
And this is in php.ini:
php.ini
; List of headers files to preload, wildcard patterns allowed.
;ffi.preload=
[Syslog]
define_syslog_variables=Off
[Session]
define_syslog_variables=Off
[Date]
date.timezone=Europe/Berlin
[MySQL]
mysql.allow_local_infile=On
mysql.allow_persistent=On
mysql.cache_size=2000
mysql.max_persistent=-1
mysql.max_link=-1
mysql.default_port=3306
mysql.default_socket="MySQL"
mysql.connect_timeout=3
mysql.trace_mode=Off
[Sybase-CT]
sybct.allow_persistent=On
sybct.max_persistent=-1
sybct.max_links=-1
sybct.min_server_severity=10
sybct.min_client_severity=10
[MSSQL]
mssql.allow_persistent=On
mssql.max_persistent=-1
mssql.max_links=-1
mssql.min_error_severity=10
mssql.min_message_severity=10
mssql.compatability_mode=Off
[opcache]
zend_extension=php_opcache.dll
;Determines if Zend OPCache in enabled
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
mssql.secure_connection=Off


texts:
I've been stucked on problem since two weeks.
Basically, what i'am trying to do is:
1) Create a page, in which there is an link ("Click me"),
When i click on it, a form is fetched from another page and added to the current page.
The form is correctly fetched, but it seems any javascript/ajax related to the form is lost.
I have a custom  Ajax submit callback for this form, on the page of the form(submit button has class ajax-processed), it is working correctly but when fetched by Ajax(submit button does not has the class ajax-processed), it doesn't.

Below is my code:

<?php

function custom_preprocess_page(&$vars){

  drupal_add_library('system', 'drupal.ajax');
  drupal_add_library('system', 'drupal.form');
    drupal_add_js(drupal_get_path('module','custom').'/custom.js', 'file');
}

/**
 * Implements hook_menu
 * @return string
 */
function custom_menu() {

    $items['my-test/my_form'] = array(
        'title' => 'Ajax test',
        'description' => 'Page containing form',
        'page callback' => '_custom_retrieve_webform',
        'access callback' => TRUE,
    );

    $items['my-test/retrieve_form'] = array(
        'title' => 'Ajax test',
        'description' => 'Page where form should be loaded by ajax',
        'page callback' => '_custom_retrieve_html',
        'access callback' => TRUE,
    );
    return $items;
}
function _custom_retrieve_html(){
    return '
'. t('click me'). '
';
}
function _custom_retrieve_webform(){

   $node = node_load(12);
   $submission = (object) array();
   $enabled = TRUE;
   $preview = FALSE;
   $form= drupal_get_form('webform_client_form_12', $node, $submission, $enabled, $preview);
  return '
'.drupal_render($form).'
';
}

function custom_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'webform_client_form_12') {
        $nid = $form['#node']->nid;
        $form['submitted']['gender']['#default_value'] = 'M';
        $form['actions']['submit']['#ajax'] = array(
            'callback' => 'mymodule_webform_js_submit',
            'wrapper' => 'webform-client-form-' . $nid,
            'method' => 'replace',
            'effect' => 'fade',
        );

       //$form['#theme']=array('custom_web_form');

       array_unshift($form['#theme'], 'custom_web_form');
    }
}

function mymodule_webform_js_submit($form, $form_state) {
      // define the $sid variable (submission id from webform)
      $sid = $form_state['values']['details']['sid'];
      // if we have a sid then we know the form was properly submitted, otherwise, we'll just return the existing $form array
      if ($sid) {

        dsm($sid);

        $confirmation = array(
          '#type' => 'markup',
          '#markup' => 'sucess',
        );
        // return the confirmation message
        return $confirmation;
      }
      else {
        // return the form
        return $form;
      }
    }

My js:

(function($){

    Drupal.behaviors.my_custom= {

        attach:function(context,settings){
            $('a.clickme').click(function(e){
                $('#justadiv').load('/d7/my-test/ajax_loaded #webform-client-form-12', function(response, status, xhr) {

                    Drupal.attachBehaviors('#webform-client-form-12');

                });
                Drupal.attachBehaviors($('#webform-client-form-12')[0]);
            });

        }

    }

})(jQuery)

CAn anyone tell me what is wrong ?


texts:
Can someone please tell me if this is possible? I have 2 content types, with the following fields.

Asset

Title
Serial Number
Model

Event

Title
Event Type (taxonomy)
Asset ID (a plain text field used to store links to Asset nodes)

Is there a way in views 3 to create a view that looks like Asset Title : Asset Serial Number : Asset Model : Event Type, basically a view linking both content types on one line. I've heard you need to use relationships, but I can't seem to get anything working.


texts: File (Field) Paths upload/remove not recognized

texts:
This behavior started after upgrading our Drupal 7.43 system to 7.56. In the process we also upgraded the Views module to 7.x-3.18 and the File (Field) Path module is at 7.x-1.0.

In the content type field management the File field configuration is using this setting for File Name:

[file:ffp-name-only-original].[file:ffp-extension-original]

As an example the file name sellsheet.pdf is displayed on the content page.

In the files/pdf directory the files and revisions are:

  sellsheet.pdf
  sellsheet_0.pdf
  sellsheet_1.pdf
  sellsheet_3.pdf
  sellsheet_4.pdf
  sellsheet_5.pdf

This file is attached to a view using Rewrite results code of:

Sell Sheet

Which generates a link to sellsheet_5.pdf

When I delete this content on the content page I would expect the link on the view to disappear. It does not, it changes the link to the file sellsheet_2.pdf which did not exist before but does now because when looking the directory the files are:

  sellsheet.pdf
  sellsheet_0.pdf
  sellsheet_1.pdf
  sellsheet_2.pdf
  sellsheet_3.pdf
  sellsheet_4.pdf

This because sellsheet_5.pdf has been renamed to sellsheet_2.pdf.

So the view still provides a link even though it should not.

When I upload a new file in the content edit page the directory of files becomes:

  sellsheet.pdf
  sellsheet_0.pdf
  sellsheet_1.pdf
  sellsheet_3.pdf
  sellsheet_4.pdf
  sellsheet_5.pdf
  sellsheet_6.pdf

The new file was uploaded and named sellsheet_5.pdf and sellsheet_2.pdf was renamed to sellsheet_6.pdf.

So when you click on the link on the content editing page it opens sellsheet_5.pdf, but the view link goes to sellsheet_6.pdf.

I'm not sure what is going on but suspect it may have something to do with Drupal not being able to update the database.

There are no errors in watchdog, Apache or MySQL logs.

Has/is anyone else experienced this? I'm assuming it's a File (Field) Path issue.


texts: How to prevent translated nodes from showing as distinct nodes in Content list in Drupal 7?

texts:
I have several Movie nodes. When I create a translation of a node, it creates a new distinct Movie with a new nid and the corresponding language.

This is somewhat confusing as I would like the backend user to see a list of distinct movies and not a movie per translation. Is there some way to accomplish this from the administrative side when viewing lists of content?


texts: Altering a form to set it's target to _parent

texts:
I have a form in an iframe, when the form gets submitted I need the target to be _parent.

How do we add target="_parent" to a form element in drupal 7. I am pretty sure hook_form_alter is the best way to go just not sure about what var gets edited and how.

-thanks.


texts: Adding a block to the page but not declaring it in hook_block_info()

texts:
I have inherited some code from a contractor. This code adds a block to page_content but it is not defined in hook_block_info().

We then have the following code:

/**
 * Implements hook_block_view().
 */
function erepair_blocks_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    ...
    case 'page_content':
      $block['content'] = page_content();
      break;
    ...
  }
  return $block;
}

This block is then displaying on some certain pages but I can't work out how.

So I have looked into the database and have found an entry for the block in the table.

It is safe to presume that they have either:

executed some sql to add the block (but did not do it in an install file)
had an entry in hook_block_info() added the block to the page then deleted the deceleration in hook_block_info()

I imagine what ever they have done is not best practice. Is there anything else they could have done (we are not using features).


texts:
My D7 content type has a field for an MP3 file. I want the field to display as an image which the user can then right click to download the file ie like this. My field template file looks like this:

<?php
$link = 'http://www.desertcow.co.uk/pirates.mp4'; // url link?>
<a href="<?php print $link;?>">

<a href="<?php print render($items); ?>">

<a href="<?php print render($items); ?>

The result is here and you can see that the syntax for the pink and red boxes is not correct.

Can anyone please tell me the correct syntax or is there some reason that this approach is not going to work?

Thanks...


texts: Main_menu Google Analytics Event Tracking

texts:
I have been asked to insert a google tracking code to all of my main_menu Links

link-name

I try to found a module but i couldn't found how to use it to accomplish this task.
https://drupal.org/project/google_analytics_et

I thought i can use a hook_menu but i need some help..

Drupal 7


texts:
I am new to drupal and let me say I am very impressed with the ecosystem around it, however I am struggling to work out how I can implement the Editing Publishing Separation Pattern correctly where I can publish content to an entirely different instance of Drupal.  This instance will have identical code but will only have live content.  Any one who has experience with Sitecore the master and web databases is effectively what I am after.

One thought I had was to use RSS feeds or some sort of custom push to create content on the remote instance.

Any insight would be much appreciated

Thanks

Aaron


texts: How can I embed a node inside on another node?

texts:
In Drupal 7 I have a content type created by admin (say content type X), And the other part i have a content type created by users (say content type Y).
Now that is what I do when a user creates content type Y, he can select a node of content-type X to embed node x in node Y.

Without link title node by "References Module" or coding html by "node_embed Module".


texts:
I'm using the Inline Entity Form which is showing me too little information to know which entities are attached to a node. Below is a screenshot:

How can I add other details to this form i:e the entity title so it human friendly and makes more sense at a glance?


texts: Can I weight content based on taxonomy in Views?

texts: I have a list of nodes. Each node has a taxonomy term associated with it. Is it possible to give certain taxonomy terms more weight than others? For example, if I gave term 1 more weight than term 2, all nodes associated with term 1 would be listed first. I'll attach an image to illustrate what I mean. I can generate this behavior by creating multiple displays for the view, but I've prefer to contain all of the logic within a single view display. Any tips would be helpful!


texts:
Rules does not allow data selection of fields without first knowing the node type actually has said field.

Rules only allows you to schedule components.

Rules action components can't have conditions to fulfill the first requirement.

How do I schedule a "Set a data value" action on a field?

I considered passing the field as a parameter to the component but it will only let me send "Entity" types and a binary value is not an "Entity" apparently.


texts: content type or normal er table, that is the question

texts:
I was wondering, when should a drupal developer use normal er table instead a new content type? Is it never? When expected node entries reaches 100 000? i googled it and i didn't find any good answer.

selecting from custom content type with number of fields is very time consuming, because all the join-s. If you have 5-10 content types, each with 10 fields, and expect a lot of nodes, is then the right time to forget about content type?

What are your experiences in this matter?


texts: Drush installed and running; No Drupal site found even with uri specified

texts:
After much trial and tribulation, I thought I had drush all ready to roar. Much excitement. But then, no joy...

Drush is working. The sites operate fine via MAMP. Regardless, a "drush cc all" command returns:

No Drupal site found, only 'drush' cache was cleared.                                          [warning]
'all' cache was cleared.                                                                       [success]

This question has stumped drupalcon attendees and very experienced developers. Any ideas?

I am on Mac OS 10.9.3
using MAMP (free) Version 3.0.5

Here is my drush status:

 Drupal version         :  7.29-dev
 Site URI               :  http://default
 Database driver        :  mysql
 Database hostname      :  localhost
 Database username      :  db_user
 Database name          :  db_name
 PHP executable         :  /usr/bin/php
 PHP configuration      :
 PHP OS                 :  Darwin
 Drush version          :  7.0-dev
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /Applications/MAMP/htdocs/mysite.dev
 Site path              :  sites/default

Have tried executing drush from /Applications/MAMP/htdocs/mysite.dev; from /Applications/MAMP/htdocs/mysite.dev/sites/default; and using drush cc all --uri=http://localhost/mysite.dev

Tried running drush from sites/default. Same result.


texts: How can I set a Feeds Importer to accept multiple values for a field?

texts:
I created a Feeds Importer for commerce products. One such product is an album which contains multiple mp3 files. So in the files field of the content type, this is set to unlimited.

but my feeds importer isn’t accepting multiple values. Ive tried using the the pipe char  (|) but it’s not working.

my CSV looks like this. fyi - having one commerce mp3 file reference in the csv does work. but when adding another and separating w/ the pipe symbol, it does not.

How can this be achieved?

my csv file so far -

SKU,Title,Album cover front,Price,Files
SKU_ALB#8_CD_SOME_TITLE,http://staging.MYSITE.com/feeds/album_artwork/cd_cover_front.jpg,1000,private://albums/Killer Track.mp3|private://albums/Heavy Groove.mp3


texts:
I have a ctools plugin in a module folder. I have a theme call in the .module file:

function vimn_article_theme($existing, $type, $theme, $path) {
  dpm($path);
  return array(
      'vimn_article_template' => array(
      'template' => 'vimn_article_template',
      'path' => $path . '/templates',
      'variables' => array('title' => NULL),
    ),
  );
}

and then in the template file vimn_article_template.tpl.php

<div class="test" <?php print $title; ?>>

What am I missing here to get this to work?

The module name is vimn_article
My ctools plugin in is plugins/content_types/prevnext.inc
my template file is located in vimn_article/templates


texts: 500 Internal Error Drupal 7.26 - Can't access forums

texts:
last night my site (Drupal 7.26 core) was working fine and then all of a sudden after creating a new forum topic with some excel graphs included (copy paste from excel) the forums completely shut down. All other pages and content are available except the forums. I can't remember the exact error that was coming up at the time but I was getting an error due to the PHP memory limit not being enough. I contacted the hosting company and got them to change it from 32mb to 128mb and also created a php.ini file with the following code:

php_value memory_limit = "128M"

and placed that in the root folder. The PHP memory limit error stopped coming up but the forums are still inaccessible and I'm now getting the following error when trying to access the forums:

  The server encountered an internal error or misconfiguration and was
  unable to complete your request. Please contact the server
  administrator, webmaster@mysite.co.za and inform them of the time the
  error occurred, and anything you might have done that may have caused
  the error. More information about this error may be available in the
  server error log. Additionally, a 500 Internal Server Error error was
  encountered while trying to use an ErrorDocument to handle the
  request.

Could someone please help me with this? It is a community site which is pretty useless without the forums.


texts: Boost - Ignore url variables but still cache the page

texts:
It seems like I'm not the only one with this problem but none of the other issues presented a clear solution.

I have a url variable called "?slide=X" which is only controlling which slide opens on the javascript slideshow when the page loads. Obviously I don't need 10 different Boost caches for each of the slides since they're all loading the same html.

All the .htaccess rules above don't really do it for me. Anybody had any luck on this?

examples.com/node/10?slide=3 needs to call the cache/normal/examplecom/node/10_.html file instead the cache/normal/examplecom/node/10_slide=3.html

Is this at all possible?

It would be great to have a general option on the settings page to ignore all url parameters or maybe ignore specific ones but still cache the pages. I think boos for D6 had this.

Thanks in advance


texts: Block content type not showing up on homepage

texts:
I created a banner image I want to place on the homepage, I chose to place it in a block content type.  Everything is linked and saved correctly, but when I go back to the homepage the block isn't showing up. I went back and checked other sections that are set up the same way and copied there settings but even then the block still won't show.

Thoughts?


texts: What's the difference between web service (API) implementation with REST and routing?

texts:
what are the real differences between these two methods of creating a webservice :

Routing + Controller (https://www.chapterthree.com/blog/custom-restful-api-drupal-8)
REST plugin (https://www.drupal.org/docs/8/api/restful-web-services-api/custom-rest-resources)

advantages/disadvantages of both?

I think we can create a restfull API with one as with the other, isn't it?

Thanks


texts: jQuery Uncaught TypeError: Object # has no method 'on'

texts:
I downloaded a jQuery Lightbox2 library (not module, just a raw library) and added the following in my custom module:

drupal_add_js($libpath . '/js/jquery-ui-1.8.18.custom.min.js');
drupal_add_js($libpath . '/js/jquery.smooth-scroll.min.js');
drupal_add_js($libpath . '/js/lightbox.js');

But it causes an error like this (see below debug printscreen):

Could someone tell me, what to do to get rid of the error?

After some googling I installed the JQuery Dollar module but the error is still there.  No clue what else to do.


texts: Why making a Views page instead of Views block?

texts:
In most of my projects views are displayed in a block instead of a page, eventhough it would be perfectly possible to make a views page in these cases.

The reasons why I do this:

If the client wants to add some content on top of the view, he can
easily do so by clicking the "edit" tab of the page the block is
nested in. This is more accessible and easier to understand than
creating/positioning blocks and setup their visibility, or even worse: use the header field feature of Views
(which the client has no access to in normal cases).
It's cleaner to manage the translated menu items to that page (taking in account that the menu items are manually grouped by language)
If the client needs to, he can easily translate the page, and alter
the visibility settings of the block so it would appear on the
translated page as well. This makes more sense to clients than to fiddle
around with translated alias urls.

Ofcourse, there must some downsides to this approach. One I believe is that it may increase the loading time of pages when there are a lot of other blocks in use (is that true?), but one should be able to counter this with the Context module I believe.

I'm bringing up this question to check this approach with other dev's to figure out if I should maintain this, or if I should reconsider it.

I live in Belgium, a country with two language communities (Dutch and French), so almost every project is multilingual, which is is also an important factor in the motivation above.


texts: phpcs rule or sniff for detecting usage of the "ksm()" or "kint()" function?

texts: Would it be possible for my local PHPCS standard to warn me when I use certain PHP functions like kint() or ksm()? It's not part of the Drupal Standard but I'm running a modified version with some improvements like this.


texts:
In a site where some of the pages are written using the Hebrew alphabet, I created a view displaying linked headings of nodes. The view's title is shown on the right (as it's commonly done for right-to-left scripts), but the linked headings are on the left.
Is there a way to make a view's content shown right-to-left without manually changing CSS styles?


texts:
I have created a view to render all taxonomy terms and displayed it through a service. I have also created an endpoint in the service module to hit the url through firefox add-on RESTer to test the JSON response. Now I want to alter the JSON response to add more key and value programatically. I am sharing all my resources which I have used but nothing changed

This is my JSON response so far:
[
        {
            "Name": "General discussion",
            "tid": "1",
            "description": ""
        },
        {
            "Name": "Miscellaneous - Hangout forums",
            "tid": "2",
            "description": ""
        },
        {
            "Name": "Debt Management and Debt Consolidation",
            "tid": "3",
            "description": ""
        },
        {
            "Name": "Archive",
            "tid": "6",
            "description": ""
        }

But I want my JSON like this:
[
        {
            "Name": "General discussion",
            "tid": "1",
            "description": "",
            "MY_CUSTOM_KEY": "MY CUSTOM VALUE"
        },
        {
            "Name": "Miscellaneous - Hangout forums",
            "tid": "2",
            "description": "",
            "MY_CUSTOM_KEY": "MY CUSTOM VALUE"
        },
        {
            "Name": "Debt Management and Debt Consolidation",
            "tid": "3",
            "description": "",
            "MY_CUSTOM_KEY": "MY CUSTOM VALUE"
        },
        {
            "Name": "Archive",
            "tid": "6",
            "description": "",
            "MY_CUSTOM_KEY": "MY CUSTOM VALUE"
        }
]

I had used hook_views_pre_render to alter the JSON but couldn't get it:
function MY_MODULE_views_pre_render(&$view) {
    if($view->name == 'MY_VIEW_NAME') {
        $results = &$view->result;
        foreach($results as $key=>$value) {
            $value->MY_CUSTOM_KEY= "MY CUSTOM VALUE";
        }
    }
}


texts: How to call a SOAP function to send Drupal user data to a SOAP server?

texts:
I'm trying to send user data to a remote SOAP server with the Rules module. I have installed the wsclient_soap module (a sub-module of the Web service client module) and put in the URL for the WSDL file.  It seems to work as I get a few of the data types back on the Drupal end.

What I do not see, is a way to use the SOAP "operation" to send the values of a Drupal user back to the SOAP server.

Has anyone had any luck sending this type of data to a remote SOAP server?

Here is the code for my php evaluation I'm using to test:

$client = new SoapClient('http://something.wsdl', array('trace' => 1));
syslog(1, print_r($client->__getFunctions(), TRUE)); //this shows the correct function
$newuser = array(
     'email' => 'test@test.com',
     'phone' => '+33 06 12 34 56 78',
);
$client->__soapCall("availableFunctionFromGetFunctions", $newuser);
syslog(1, print_r($client->__getLastRequest(), TRUE));
syslog(1, print_r($client->__getLastResponse(), TRUE));

For the available functions, when printed to syslog, it shows the one I want with THREE variables, the two I want to send and one called "authentication".  The documentation I was given does not say what the value of authentication is supposed to be, so I have a feeling the "error" that is being thrown when I act out the rule is caused by this.

I will update as I get more information.


texts: Retrofitting CSS media queries into an existing project

texts:
I've inherited a Drupal 6 project with a custom theme based off fusion. I would like to keep the current design for screen sizes above 800. Should I wrap existing CSS in @media screen and (min-width:800px)? Or, might I be able to use a "reset" technique under another media query?

How would you retro fit media queries into an existing site?


texts: change views global text field conditionally

texts:
I am trying to either show a text field or hide it depending on the date of another field in a view.
I am trying to use the views_pre_render hook and so far have:

function MODULE_NAME_views_pre_render(&$view) {
if ($view->name == 'user_dashboards' && $view->current_display == 'my_tutorials')
{
    foreach ($view->result as $index => $value)
    {
        $tutorialtime = strtotime($value->field_field_tr_tutorial_start[0]['raw']['value']);
        if($tutorialtime < strtotime('now'))
        {
            $view->field['nothing']->options['alter']['text'] = '';

        }
    }
}

}

So I can successfully test whether to show the field or not, however I can't then change the field.  Using the code above changes every global text field in the view.  Is there a way to target just the row in the comparison?


texts: Drupal Commerce variations missing when creating content

texts:
I have downloaded and installed the Commerce module.

Note 1:
I have a product which is made up of 2 changeable parameters e.g. say size and colour... depending upon the size and colour chosen the user will be presented with a price... Currently, this leads to a potential 18 combinations all with unique prices.

Note 2:
I have created a product content type e.g. T shirt

Note 3:
I have created 18 products with unique SKU codes for each of the possible combinations and associated prices (of the product type created in Note 2)

Note 4:
I have created a standard content type (under structure - which is intended to be used to show the product as a piece of content e.g. admin>structure>content type).  The field holding the product is of type "Product Reference" and the product reference fields, field setting is set to unlimited

Note 5:
The content type is configured to allow the user to select the 18 different variants (created in Note 3) of the product type created in note 2.

Note 6:
The content node of the type created in Note 4 works by showing the product and changes the price depending upon what the user selects from the two options e.g. size and colour

The issue:
In the content type created in Note 4 (e.g. the content node) it only shows the last 10 products created (of the product type created in Note 2) rather than showing the required 18 products... how do you get to see the other 8 product variations so that they can be selected and show up in the content node in order that those combinations may be selected?

Anyone else experience this issue?  And found a solution to it?

It looks like the widget in the content creation gui only lists up to 10 items - so I'm only seeing the last 10 items created but how to I also see the addition 8 items created.


texts: Creating Primary Sub menu's programmatically

texts:
I want to display the latest 10 nodes of node type 'ABC' as a sub menu link under my primary menu. Are there any modules for Drupal 6 to help me achieve it.

I have created a view which gives me a latest 10 nodes sorted by creation date. However, I am unable to figure out how to integrate as an submenu links under the primary menu link.

So is there any other way I can achieve this?


texts: How to debug a configuration object, when testing?

texts:
I write tests for a custom module using Drupal\simpletest\WebTestBase. I can not find a method, how to debug the configuration object.

I tried e.g. the following commands:

$config = \Drupal::config('mymodule.settings');

debug($config); // AJAX-HTTP-Error
debug(get_object_vars($config)); // Empty array
debug($config->getRawData()); // Empty array
debug($config->getOriginal()); // Empty array
dump($config); // AJAX-HTTP-Error
var_dump($config); // Needs extremely long time
ksm($config); // Nothing is shown
kint($config); // Nothing is shown
dpm($config); // ServiceNotFoundException
dpm($config->toArray()); // AJAX-HTTP-Error
dsm(get_object_vars($config)); // ServiceNotFoundException
print_r($config); // Needs extremely long time

The debug() command works fine for arrays and strings (and is nice integrated in the test report).

 debug($var, 'Label');


texts: Saving date field programmatically on node, but not on profile

texts:
I'm saving some date field on the code both on node and profile entity. I'm success on saving it for nodes, but when I try to save for profile2 entity, using the same chunck of code, no data is saved.

I'm doing this to nodes (after creating a new node with entity API):

// Creating a node and an entity wrapper
$entity = entity_create('node', $values);
$ewrapper = entity_metadata_wrapper('node', $entity);
// Saving the date field
$entity->field_date[LANGUAGE_NONE][0] = array(
   'value' => strtotime($date),
   'timezone' => date_default_timezone(),
   'timezone_db' => date_default_timezone(),
   'date_type' => 'datestamp'
 );
//Saving the node
$ewrapper->save();

And almost the same way with profiles:

//Creating a profile2 'info' bundle
$profile_info = profile2_create(array('type' => 'info', 'uid' => $user->uid));
// Trying to save the date field, same way as above
$profile_info->field_date[LANGUAGE_NONE][0] = array(
   'value' => strtotime($mydate),
   'timezone' => date_default_timezone(),
   'timezone_db' => date_default_timezone(),
   'date_type' => 'datestamp'
 );
// Saving the profile
profile2_save($profile_info);

If someone knows what is happening I'd appreciate!


texts: Profile 2 - My account displayed together

texts: i included profile2 into my account page via any settings, and now have realy problem to find where i set it, could someone please help me? It was just one check box, please help me. thx


texts:
I try to hook the node form by hook_form(), but I can't modify the base form.
I try to do this like below

function products_form($node, &$form_state) {
  $type = node_type_get_type($node);

  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => check_plain($type->title_label),
    '#default_value' => !empty($node->title) ? $node->title : '',
    '#required' => TRUE,
    '#weight' => -5,
  );
  return $form;
}

What's is wrong? My module name is 'products'.


texts: A question about performance with Form API and Ajax callbacks

texts:
Im creating a dynamic form, using FORM API.
Several lines of results, fetched from DB, and several functionnalities like deleting a row, adding a row, modifying quantites and calculating total prices.

I did everything using ajax callback, but Im not sure this is the best way of doing it, especially with the 'change quantities' and 'calculating prices' functionnalities.

What I understand about AJAX Callbacks is that a full refresh of the form is done during callback (using cache if possible), and that alony a certain part of the form is returned (using return $form[XXXX]).

So when I change a quantity input field, the form is rebuild, and Im updating the price col and total.

The question im asking to myself is : should I use simple javascript to manage my prices when quantities change ? For me its seems more logical, avoiding by the way useless PHP requests.

As Im not sure about it, likely to forget something important, I prefer asking it to you guys. Thx !


texts: How to add multiple suffixes for an integer field type?

texts:
Is there a way to add multiple suffixes for an integer field type? For example, I want to input a value, and I want to be able to specify whether this is in inches or centimeters with a drop down box.

Is there a way to do this using only the field module?


texts: How can I schedule adding a new field collection item for all users?

texts:
My users have a field collection, called 'Score', with two fields: 'Date' and 'Points'. I'd like to add a new field collection item for all users at the end of the day, with the current date in 'Date' and their current userpoints in 'Points'.

I thought about using a scheduled rule, but I don't know how I can select something like 'all users'. Is this possible with Rules or is there another way to achieve this?

This question is part of How to create a line graph of the total user points on a profile page?.


texts: Is it possible to have an external script run index.php that bootstraps Drupal?

texts:
It seems like such a simple question, and I apologize for my Drupal ignorance, but I am unable to get our Drupal contractors to accomplish what seems to be a simple request.  I need the below script to work without paying for a month of contracting work:

The user will be logged in, and of course, there is a valid database.  If it matters, the site is hosted by "Pantheon", and the script will also call a custom Drupal function to return a recordset.

Is this code not possible?  Am I asking something that cannot be done ind Drupal thus the endless stream of complicated files that they keep giving me?

root\myscript\index.php  (to run as www.mysite.com\myscript\index.php)

<?php
/* Check for Drupal Instance and then bootstrap to get User and Database connection */
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $db_url;
$creds      =  parse_url($db_url);
$db_host    = isset($creds['host'])     ? $creds['host']    : null ;
$db_user    = isset($creds['user'])     ? $creds['user']    : null ;
$db_pass    = isset($creds['pass'])     ? $creds['pass']    : null ;
$db_name    = isset($creds['db_name'])  ? $creds['db_name'] : null ;

$db = mysqli_connect ($db_host, $db_user, $db_pass, $db_name);
if(!$db){
    die('Failed! Could not open a db connection'.mysqli_connect_errno() . mysqli_connect_error());
}elseif(!$user){
    echo 'Failed! Connected to database, but did not get $user - we canNOT proceed';
    echo '
'.print_r($db,true).'
';
    die('Connected to database, but did not get $user')    ;
}else{
    echo "Success! User and DB are set and ready to use - we can proceed";
    echo '
'.print_r($user,true).'
';
    echo '
'.print_r($db,true).'
';
}

This (I think) is at least the start of the Drupal function that will return a recordset when the main code above is working.

/**
* Implements hook_block_info().
*
*/
function xyz_listofmyitems_block_info() {
    $blocks['xyz_listofmyitems'] = array(
        // The name that will appear in the block list.
        'info' => t('List of available items'),
        // Default setting.
        'cache' => DRUPAL_CACHE_PER_ROLE,
    );
    return $blocks;
}


texts:
I currently have a page which has a block with taxonomy terms displayed.  Each link has been made to work with ajax to display information below if clicked, generated in a module callback.

What I am trying to acheive is also have this work if linked to.  So for example my page URL is currently http://localhost/events/building01
If someone was to visit http://localhost/events/building01/printer then the information for printer would be displayed under the taxonomy term as it would if someone had clicked on the term.

My ajax links are currently setup like:

function building_block_menu()
{
  $items['events/%/%/ajax'] = array(
  'title' => 'ajax call',
  'page arguments' => array(1, 2),
  'page callback' => '_event_ajax_callback',
  'access arguments' => array('access content'),
  'type' => MENU_CALLBACK,
  );
  $items['events/%/%/nojs'] = array(
  'title' => 'nojs call',
  'page arguments' => array(1, 2),
  'page callback' => '_event_nojs_callback',
  'access arguments' => array('access content'),
  'type' => MENU_CALLBACK,
  );
  return $items;
}
function _event_ajax_callback($building, $type)
{
  $markup = $building . ' - ' . $type;
  $ajax_commands = array();
  $ajax_commands[] = ajax_command_html('#ajax-target', $markup);
  ajax_deliver(array('#type' => 'ajax', '#commands' => $ajax_commands));
}
function _event_nojs_callback()
{
  return "no js to be built";
}

And called from links built like:

$output .= l($term->name, 'events/$building/'.$term->tid.'/nojs', array(
            'attributes' => array('id' => 'building-term-'.$term->tid, 'class' => 'use-ajax')
            ));


texts: How to prevent Drupal from automatically truncating blog entries?

texts:
When you enable the Drupal 7 Blog module, the blog page (http://mydrupal.tld/blog) displays truncated blog entries.  It looks like Drupal truncates after the end of the first paragraph (<p>).  In order to see the entire blog entry, you have to click on its title or on the Read more link.

I'd like to save that click to my visitors by displaying full length blog entries directly on the blog page.

It seems that print render($content); performs the truncation, but I couldn't find anything in the method's API about that.

Any idea ?


texts: Views 3 "no results behavior" for different languages

texts: I use i18nviews for the translation and it works fine! Under the Point "no results behavior" can i only choose Global:Textarea, but this is not allowed in different languages.  What can i do?


texts: Reply for comment redirects to the next page

texts: I am using advance forum module and having commenting functionality for the forums. But the problem is when I use to reply to the comments it redirects me to the next page. Where I want to display a comment form exactly below to the comment to which I am replying. Where should I configure for this? With comment module or just with advance forum module?


texts:
For my purposes I don't need these types of messages:

2 rows processed in about 261 ms:
Performed Email Reviewers on user joren1.
Performed Email Reviewers on user joren5.

I don't want to hide messages in general. Is there a way to specifically target messages from this module, or specific messages at all?


texts: How to revolve TinyIMCE error 'The version of TinyMCE could not be detected'?

texts:
I installed these modules: Wysiwyg, IMCE Wysiwyg bridge, IMCE.

Then downloaded the libraries from:

https://www.tinymce.com/download/ (developer edition, community doesn't even have a non minified imce.js file...)

Now the file structure is not the same as the instructions from Drupal Backend:

Extract the archive and copy its contents into a new folder in the      following location:
sites/all/libraries/tinymce

So the actual library can be found at:
sites/all/libraries/tinymce/jscripts/tiny_mce/tiny_mce.js

So I deducted I had to change folder structure from:

sites/all/libraries/tinymce/js/tinymce/tinymce.js

To:

sites/all/libraries/tinymce/jscripts/tiny_mce/tiny_mce.js

But still not working, I get this error:

TinyMCE (Download)  Not installed.
The version of TinyMCE could not be detected.


texts:
Currently using D7 (specifically the Commerce Kickstart installation profile). When trying to reach update.php, I get a "Page Not Found" error. I also noticed that the url Drupal is trying to reach is /core/update.php.

Has anyone else encountered this?


texts:
I have a working page listing items in a block (created by the 'block_view' hook) which when displayed link to another set of pages where I want to list content types associated with them. The items are not standard drupal types so there is no relation between these two sets except through my DB table.

So say I have a link on the original page to mysite/speech/3, and I want to see all speeches associated with speech 3.
To do this I created a block, made it display on speech/* and all is good. I can see the content types associated with speech 3 in a nice table, except it also displays a 'Page not found error' along with the correct data.

Why?
I'm trying to use the Drupal structure as far as possible where I can. When I can't are there issues with using blocks extensively performance wise?


texts: As it is not possible to set a default price to products I was trying to achieve that by using rules. I'm checking "Before saving a commerce product" Event. Condition is "Data value is empty" and my Action would be "Set a data value", but all I get is an error because price isn't set. Anyone know why this is happening?As this is the first time I use rules, maybe I've done something wrong.


texts: feedback for duplicate registration attempt

texts:
if a user tries to register with a username or email that is already in use, there is no feedback telling them this, it just highlights the form field red, this is quite a bad UX.

How can I add translatable text to the effect of "that email is already in use, have you forgotten your password?" ?

I would really like to do this without adding a module.

Here you can see there is validation feedback, but it's not relevant, as my username meets its criteria, it should highlight the duplicate account problem. The user would just get frustrated at this point as they are told to do something which makes no difference.


texts:
I need to set the  $form['langcode']['#weight'] to -251.

I tried also to access the widget weight. But the position weight still remains on bottom of the form.

Why is that? I tried:

//form field sort ('#weight')
$form['langcode']['#weight'] = "-251";
$form['langcode']['widget']['#weight'] = "-251";
$form['langcode']['widget'][0]['#weight'] = "-251";
$form['langcode']['widget'][0]['value']['#weight'] = "-251";
$form['langcode']['#weight'] = -251;
$form['langcode']['widget']['#weight'] = -251;
$form['langcode']['widget'][0]['#weight'] = -251;
$form['langcode']['widget'][0]['value']['#weight'] = -251;

Also on the hook_form_alter I cannot change the weight.


texts: Create a block showing the latest of a certain content type

texts:
I am very new to drupal, so I already apologize if I ask something very simplistic...

I have a site where I would like to add a new block to the front page of the website. This block would show the companies newest available training's. I created the sub-pages of the training's.
My thought process was that I create the sub-pages, then create a new type of content (with the cck) where I can add the new sub-page node names and their links.
I created the new content type with two fields. field_offeringlink and field_offeringtext. Where the the text would be the actuall promotional text and the link directing to the sub-page.
After this I wanted to create a Block that I would place on the front page, showing these two fields.
I couldn't figure out this part...
So how do I make the bloody block show my fields?

OR

If you have a better idea for this whole shannanigan then I am welcome to ideas.

My goal:

Create a dynamic block on the front page, that shows all the latest training's. Under dynamic I mean, that we can add-remove the links from the admin/content menu.

Thanks in advance!


texts: Hai am working on an ecommerce site using ubercart module. I have created a view for listing products in a particular category. each product direct to a page which consists of its details and add to cart buton. In the bottom of this page i have a related products block which list all the other products in this category.but in this block it repeats the main product once more. how can i remove it? can anyone help me to solve this issue?


texts:
I am working on a site which uses someones custom module which makes some modifications on the user account page as well as his profile pages.

On this site, I registered myself as a user and logged in and found that I was assigned to all roles, even administrator. When I tried unclicking the checkboxes on the user page to unassign roles, it didn't work, the roles stayed the same. I tried this while logged in as the user himself and also as the admin.

What types of things could be causing this issue? Where should I look?


texts: Add image file programmatically in drupal 6

texts:
i want to upload an image on my site. I have a custom form in a module with

  $form['picture'] = array(
  '#type'   => 'file',
  '#title'  => t('Avatar'),
  '#prefix' => '<img src="' . $user->picture . '">'
  );

  $form['#validate'][] = 'product_validate_picture';

and in my validate fucntion :

$validators = array('file_validate_extensions' => array('jpg png'),
                    'file_validate_image_resolution' => array('500x500'));

$file = file_save_upload('picture', $validators);
dsm($file);

The problem is that i do not get the picture returned by the form, i only get "0" which is an error. So, did i do something wrong, or another method is better to get and save a picture returned by a custom form?

Thanks.


texts:
Hi I got neat facebook style chat called arrowchat for my drupal website, however the script was lacking user picture integration. I managed to get user pictures but if user didn't set picture and is using default picture I'm getting broken image and 404 not found in logs. I've tried to fetch gravatar for users without picture set but couldn't make it work..

/**
 * This function returns the URL of the avatar of the specified user ID.
 *
 * @param userid the user ID of the user
 * @param image if the image includes more than just a user ID, this param is passed
 * in from the avatar row in the buddylist and get user details functions.
 * @return the link of the user ID's profile
 */
function get_avatar($image, $user_id, $account)
{
               return "http://mypage.com/files/pictures/picture-" . ($user_id) . ".jpg";

    if (empty($account->picture)) {
    return "http://www.gravatar.com/avfatar/" . md5($image) . "?d=identicon";
     }
}


texts: How to query all fields of the node that is tagged with taxonomy term from a specific vocabulary

texts:
I'm struggling to find a way to retrieve all the node fields where a specific taxonomy is implemented. I was close to find something with this query :

$query = db_query('SELECT fci.field_name
    FROM d7_field_config_instance fci
    LEFT JOIN   (SELECT tv.vid, tv.machine_name
    FROM d7_taxonomy_vocabulary tv
    LEFT JOIN d7_taxonomy_term_data ttd
    ON tv.vid = ttd.vid
    WHERE ttd.tid = 76) AS tax
    ON tax.machine_name LIKE fci.bundle'));

But it seems like machine_name and bundle have different values for a same technology.

The idea is : From a taxonomy id => find taxonomy vid (vocabulary id) => find machine name of the vocabulary => find the bundles where this vocabulary is used.

Any help would be appreciated.

Solution  : Thanks to @Eugis' answer (Accepted answer), I came up with this solution :

db_query("SELECT fcf.field_name, fcf.data FROM
          (SELECT fc.field_name, fc.data FROM field_config fc
          WHERE fc.type LIKE 'taxonomy_term_reference') AS fcf
        INNER JOIN field_config_instance fci
          ON fcf.field_name = fci.field_name
          AND fci.bundle LIKE :bundle",
      array(':bundle'=> $bundle));

Hope it'll help someone else.


texts:
I have about 5 drupal sites on in motion server but for some reason all sites are showing me the same error which is

"PDOException: SQLSTATE[HY000] [2002] No such file or directory in lock_may_be_available()

My host is telling me that there is nothing out of the ordinary, but clearly some thing is wrong, all 5 websites are showing me this error simultaneously. I need a to resolve this issue , I need some help.


texts: Views - Multiple filters on a single field with multiple values allowed

texts:
I have a field in my view with unlimited number of values. I need to have the ability to filter on combinations of these categories (i.e. DOCTOR & SANTA MONICA & TAKES INSURANCE. I want to have 3 filters, all on the same field, but when I do this, the resulting view set is empty.

Can anyone point me in the right direction as to how to do this? I'm baffled!

Thanks!

Jeff


texts: How to: Multilanguage site, but single language backend?

texts:
I have almost completed my first Drupal 7 multilanguage test site. As long as I'm not logged in, I can browse through all pages and switch languages. When logged in, my first issue was that the backend language would switch, when switching the frontend language. I.e., the admin menus are translated, but should stay English (or whatever the editors preferred language is).

Then I found that in Configuration > Languages > Detection and Selection, I can select how the language is chosen. So: User first, then the backend stays in the user language. Fine.
But then, the frontend stays in that language, too! So when logged in, I cannot browse all pages anymore, only the English ones ...

There must be a way to select front and backend languages independently.
How?


texts: How do I use the Rules module to unpublish content when End Date is hit?

texts:
I have a Content type called Event, has a Start Date and End Date.

How do I use the Rules module (version 8.3.0-alpha1) to:

Publish the Event on the Start Date and
Unpublish it on the End Date?

My priority is to Unpublish the content when the End Date is hit.

Note: If Rules isn't the way to go, what would be a better way to unpublish a piece of content based on a supplied End Date?


texts: 8 - Change taxonomy field's link text in view

texts:
In drupal 8 when creating a view for taxonomy terms and add a field I enabled

  Link to the Taxonomy term

option. The pathauto module is enabled so it gives following link:

Taxonomy Term

But I want something like this:

Read More

I have created a twig file views-view-field--my-region--name.html.twig as following:

{{ output -}}

I cannot go into more deeper with this setup. Can you help me to change the anchor text OR just get the taxonomy term url?


texts: How to create a custom payment page attached to a user account's form

texts:
I am on Drupal 7 and I am building an ads website in which people can buy credits via their account form. I am not using Commerce or Ubercart for very complex reasons that would be a bit long to explain.

So lets move forward.

Users will use the credit that they buy to make payable actions on their content, such as making a content sticky.

1. What I already did :

Now a user who is connected to his account can select the number of credits to add to his balance. And the balance will be added that amount of credits.

And all the payable action on the ads decrease the balance of the concerned user.

So to say that the system works fine.

2. What I need to do now :

I set up field to let the user choose the type of payment his wants : PayPal or Credit Card.

How can I create a payment page without programming ?
How can I make people really see a payment page ?
How can I make that payment page appear before the users saves the
account forms ?

These are the things that I really need to know.

Anybody know how to ?


texts: hook_update_N - expose new field to views after module update

texts:
I've added new field to existing table with hook_update_N. Now, is it possible to expose this new field to views? I want it to be exposed when module is updated...

Possible?


texts: drupal 7.34 cannot rearrange form component and others

texts: I have a fresh installation drupal 7.34 the install module ctools views and webformm. I cannot rearrange the form component. Both weight and the + symbol appear. Normally in the previous version I can switch using weight or drag the component to rearrange. How can I rearrange the form components. This problem also in other similar list, such as menu.


texts:
I want to create a question/answer block.

I guess I need to create a content type, turn comments on, and in page.tpl.php display nodes with comments. It should appear as in the image below.

What's the easiest way to get that block?

Update:

I decided to use 2 content types, one for question and another for answers, and link each other with node reference.

For example any registered user on the site can write a question, but only moderators can make answers on their questions. When moderator does node/add/answer he/she chooses with a select list to which node the answer would be linked.

Is this a right solution?


texts: List Private Organic Groups Publicly without giving access to the node page?

texts: I have a view setup to list my OG Nodes, those nodes and their greater content need to be private to only the group, but on the front end of the site I want to list some of the featured Nodes.  As it stands the node access system is removing those nodes from my public listing.  Any solutions to keep the full node private, but list these OG Nodes publicly?


texts: How do I choose which module to use when there are several options for the same functionality?

texts: It's not at all uncommon to find multiple modules that provide basically the same functionality. For instance, there are many SPAM control modules that offer extremely similar functionality (e.g., Spamicide and Hidden CAPTCHA). And there are lots of Taxonomy modules that do similar things. So when multiple modules meet my requirements, how should I choose which one to use?


texts: I have an Image field that I can add more than one field but I want the user when upload an Image the image appear below the input not above it and sort them desc so the input form will be above the table of images not below them


texts: template suggestion not working (page--front.tpl.php) in windows 7 env

texts:
I do my development in a windows 7 env. Using XAMPP to run D7 and supporting apps.

I am giving the template suggestion of page--front.tpl.php for my D7 theme. For whatever reason the file doesn't seem to be getting recognized by D7. I pushed my code to my development server (linux) and page--front.tpl.php is picked up without issue.

has anyone seen this behavior? I can't lock down what is happening here.


texts:
there's option setting on Lightbox2 General settings tab:

And there's my Basic Page's content type settings for Image field:

So no matter what, but it applies the Lightbox2 to all Basic Page nodes that has content in the image field. What I want is that it would apply those settings from the Format Settings only to the Image field at node/72. What's wrong and what is the use of Page specific settings?


texts: Why can't I modify my comment form using hook_form_alter

texts:
I have enabled comments for a custom node type.

I am trying to theme that comment form using hook_form_alter(&$form, &$form_state) (For example, I'd like to remove the label of the comment_body form field)

To do that, I use the following function:

function MYTHEME_form_comment_form_alter(&$form, &$form_state) {
    $form['comment_body']['und']['#title'][0] = '';
}

However in the output the title of the form field is still there:

Here's the markup:

The value of $form does not correspond to what I am used to see. Here's a screenshot from my debugger:


texts: Why does the Node reference module search only for node titles?

texts:
I have two content types: Type A and Type B. Type A has 3 fields: title, location, and zip code.

I want to get references to Type A in a field for Type B. I have tried using the Node reference and the Entity reference modules, but they allow only to get options in autocomplete when I write the title of a Type A node. I want to get a list of all the Type A nodes with the zip code entered in the field.


texts: Add field to node without new content type

texts:
I need to create a field for a specific node, but I really don't want to create a new content type, for various reasons...

Is there a module that does that?

Say I wanted to create my own module that does that, how do you recommend I approach this?


texts: Views: Change path and redirect old to new path?

texts: I would like to change the path for one of my Views. How do I redirect the old Views path to the new one including all the variables that may follow the old path?


texts: Do translated taxonomy terms have different tid's?

texts:
As per title; or are they translated in the same way user interface elements are handled?
Im using Drupal 7 btw.


texts:
I am using the Text Resize module to dynamically change the font size of my page content. However, instead of having two buttons which increases and decreases font size, I need, instead, to have three buttons so when the user clicks on one, the font size will be set to a preset value. This value should be able to be changed by the client themselves.

Is there a module which is similar to Text Resize but with defined font sizes?


texts:
I have set a Drupal 8 project into another server with some child directory. This D8 project is working good, But images are not showing due to path missing. E.g

My project is setup:- http://abc.xyz.com/client/development/project-name/

but when I was inspecting element then I got image URL:-http://abc.xyz.com/sites/default/files/images.png

I know client/develoment/project-name/ path is missing into the image path. May you let me know how to get full image path display?

Full path must show:-http://abc.xyz.com/client/development/project-name/sites/default/files/images.png

Thanks


texts: 8 How to configure add-on products in Commerce 2.x

texts:
What is the best way in Commerce 2.x to allow the shopper to check boxes to add optional accessories to a product before he adds the product to the cart. In addition, the product price should be updated.

Sounds like this module would do it in D7: Commerce Product Add-on.

This question asks the same question, but it's tagged with 7. Can a VBO form be integrated with the Commerce Add-to-Cart form to allow adding optional add-on products with checkboxes?


texts: User with permission can't add an event to calendar by clicking

texts:
I have a working calendar (from the module calendar).

As administrator, i can click on a date and a popup allows me to add an event.

But users, who are allowed to add an event, can't do it. They can add an event by navigation and clicking on"add content", but they can't do it, like me, the administrator.

Can someone help me? I guess, it's somewhere in configuration but I don't find anything.

Thanks for any advice!


texts: Why is the first visit to a rarely used site slow or even lead to timeout?

texts:
I am looking for suggestions on Apache/Drupal/MySQL (localhost) configuration, to solve my issue. I use Ubuntu servers 8 LTS with classic Apache installation, and perform manual Drupal installation too. After publishing a site for customer review, I notice, that if a site is not visited very often or not visited at all for some time, such site response time increases significantly, up to situations with timeouts. Although, other vhost sites not on drupal on the same server run smoothly. E.g., if a site is rarely used, opening and navigating through out it takes very long times, or even timeouts. Each next page visit opens faster.

I use regular Apache settings and PHP memory up to 512MB, as sometimes Drupal module installations ask for more. Server is with 4GB RAM, and around 10 sites running on it at a time. Drupal for customer review is set without caching and performance settings turned on, thus I consider, that this can be a bottle neck in some cases, but still, if I work on the site, it is quite responsive, even without performance settings turned on.

I understand that there are very many ways of solutions and potential issue roots, but wondering, if there are some constructive ways to track this down to small list of tasks to accomplish better configuration. I've experimented with different Drupal performance tuning solutions found on the net, but it still does not solve issue, if a site is not used frequently. Restarting apache helps for a while.


texts: Location/Country based user redirection using ip2locale module

texts:
I am using IP to Locale (7.x-1.x-dev) for redirect the user to a multilingual website based on user country.
I used the following modules also.

IP to Locale - WebHosting.info
IP to Locale - Redirect

In Configuration » Regional and language » IP to Locale » Country Code to Language Code mappings i have:

gb,en

us,en

ch,de
But its not working? Its not redirecting.Any one help me?


texts: How to display image preview right away for managed_file form element?

texts:
I have managed_file for uploading an image in my form and I would like to display the image(thumbnail) right away when the user uploads it so he won' have to submit the form to see it(I am rendering it in the form if the image exists).

I think there might be an issue with the ajax wrapper/structure so I am not sure how exactly it should be achieved without too much customization/coding.


texts: Is the latest Drupal 7 core, 7.59, fully PHP 7 ready?

texts:
I just transferred a Drupal 7 installation to Debian 9 and when I try to connect to the site I get the error PHP Fatal error:  Cannot use "self" when no class scope is active in vars.module on line 39.

There is a Drupal issue on it Upgrade to PHP7: Cannot use "self" when no class scope is active [#2668622] , but it doesn't seem to be fully resolved and I am not sure which PHP7 version it works on.

The version of PHP currently on Debian 9 is PHP Version 7.0.27-0+deb9u1

The point is I am running the latest version (Drupal 7.59) on Ubuntu 16.04 whose PHP version is PHP Version 7.0.30-0ubuntu0.16.04.1 and it runs without that error.

Are there versions of PHP 7 running on Debian 9 which work with latest unpatched Drupal 7.59, perhaps later ones like PHP 7.1 or PHP 7.2?

Maybe the bug only manifests in  early versions of PHP 7.

UPDATE: It turns out that vars.module is from the contrib module Variable API and not part of core, and was only enabled to support the Textile module. Disabling it solved the problem.


texts:
I have been trying to get the current authenticated user ID in Hook_cron() function.

But Its showing only the anonymous user, though the current user is an authenticated user.

How Could I get the current authenticated user in hook_cron()


texts:
One of the security principles is sanitizing strings and variables passed from client to server. In plain PHP there are some functions to prevent XSS (Cross-site Scripting) vulnerabilities:

htmlspecialchars()
strip_tags()

What is Drupal 8 strategy to prevent XSS  attacks? How can I clean up client data post to protect my site from XSS attacks?

I remember Drupal 7 has filter_xss() to prevent XSS vulnerabilities, but what is Drupal 8 strategy against XSS vulnerabilities?


texts: Is it possible to render multiple tokens in custom content pane?

texts:
I have created a custom content pane in a Panels layout, so that I can output a part number and short description field side-by-side as one element.  I added the tokens %node:title and %node:body (the two fields containing the data) and wrapped them in an <h2> tag. However, when the page is rendered, it only puts %node:title inside the <h2> tag and adds the %node:body as a separate <p> element.

What gives?


texts: Setting node title as view argument/path

texts:
I'm creating a feed view that generates a specially-formatted file when nodes of a specific content type have /tsv appended to the path (generated by path_auto)

I.e.,

http://localhost/content/a-title/ --
node
http://localhost/content/a-title/tsv
-- feed view

How do I do this? I have node/%/tsv as the feed path, Node: Nid as argument (with "Node ID from URL" as the "Action to take if argument not present").

I feel there must be something really obvious I'm missing... Apologies if this has been covered before, I really did look for a solution before posting.

Thanks!


texts: Where does field help text get filtered?

texts:
Drupal 7 fields, by default, have a nice text box beneath them for Help Text.  This is set up with field_ui_field_edit_form():

$form['instance']['description'] = array(
  '#type' => 'textarea',
  '#title' => t('Help text'),
  '#default_value' => !empty($instance['description']) ? $instance['description'] : '',
  '#rows' => 5,
  '#description' => t('Instructions to present to the user below this field on the editing form.
Allowed HTML tags: @tags', array('@tags' => _field_filter_xss_display_allowed_tags())),
'#weight' => -5,
);

Widget forms then can use this when they actually get used, such as from file_field_widget_form():

if (empty($element['#default_value']['fid'])) {
  $element['#description'] = theme('file_upload_help', array('description' => $element['#description'], 'upload_validators' => $element['#upload_validators']));
}

Which then get themed, such as with theme_file_upload_help()

if (strlen($description)) {
  $descriptions[] = $description;
}
if (isset($upload_validators['file_validate_size'])) {
  $descriptions[] = t('Files must be less than !size.', array('!size' => '' . format_size($upload_validators['file_validate_size'][0]) . ''));
}
if (isset($upload_validators['file_validate_extensions'])) {
  $descriptions[] = t('Allowed file types: !extensions.', array('!extensions' => '' . check_plain($upload_validators['file_validate_extensions'][0]) . ''));
}

The trusty eye will notice that this is user supplied text and it is not being filtered (oh noes!).  Don't worry, it gets filtered somewhere (I actually tested this to be sure).

Where / how does this filtering happen?


texts:
How can parameters be passed to service? I have a class that I would like to change to a service and load other services from the container. What I don't understand is how to deal with other parameters in the constructor when calling the service.

For example, I have a CustomService class.

public function __construct(QueryFactory $query_factory, EntityTypeManagerInterface $entity_type_manager, param1, param2) {

    $this->entity_query = $query_factory;
    $this->entity_type_manager = $entity_type_manager;

    $this->param1 = $param1;
    $this->param2 = $param2;

  }

public static function create(ContainerInterface $container) {
   return new static(
       $container->get('entity.query'),
       $container->get('entity_type.manager')
    );
}

How can I instantiate the service I would instantiate with \Drupal::service('CustomService')? It does not work for me; it only works when I remove the custom parameters from the constructor.

This might be a wrong approach, but I'm new to Drupal 8 and would like to use proper coding with dependency injection.


texts: Running updatedb fails with UnknownExtensionException error

texts:
I am attempting to update my site's database after updating three modules: Configuration Update Base, Search API, and Simple XML Sitemap. Running drush updatedb produces the following error:

Drupal\Core\Extension\Exception\UnknownExtensionException: The module devel_generate_example does not exist. [error]in /Applications/MAMP/htdocs/mysite/core/lib/Drupal/Core/Extension/ExtensionList.php:265
Stack trace:#0 /Applications/MAMP/htdocs/mysite/core/lib/Drupal/Core/Extension/ExtensionList.php(579):
Drupal\Core\Extension\ExtensionList->get('devel_generate_...')
#1 /Applications/MAMP/htdocs/mysite/core/includes/update.inc(318):
Drupal\Core\Extension\ExtensionList->checkIncompatibility('devel_generate_...')
#2 /usr/local/Cellar/drush/8.1.12/libexec/commands/core/drupal/update.inc(134): update_get_update_list()
#3 /usr/local/Cellar/drush/8.1.12/libexec/commands/core/core.drush.inc(462): update_main()
#4 /usr/local/Cellar/drush/8.1.12/libexec/includes/command.inc(422): drush_core_updatedb()
#5 /usr/local/Cellar/drush/8.1.12/libexec/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#6 /usr/local/Cellar/drush/8.1.12/libexec/includes/command.inc(199): drush_command()
#7 /usr/local/Cellar/drush/8.1.12/libexec/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#8 /usr/local/Cellar/drush/8.1.12/libexec/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#9 /usr/local/Cellar/drush/8.1.12/libexec/drush.php(12): drush_main()
#10 {main}

I have confirmed that Devel and all of its submodules (including devel_generate and devel_generate_example) are installed. I have attempted deactivating, uninstalling, and reinstalling them, but I am still getting the same error. Does this look familiar to anyone?


texts: how to filter nodes that match url of current node or particular field of current node

texts:
For my contenttype 'cars' i use a panel node-view.

Each 'car' node has fields 'categorie' and 'type'
Each 'car' node has url 'categorie/type/model' e.g.
'car/toyota/yaris'

In my 'car' panel node-view i like to insert a view.
This view should filter nodes  that match the field 'type' or part of the url 'type'

Without succes i have tried to pass the node id as an argument from my view (master) to my panel. Then using node id as a contextual filter.


texts: I get image field upload errors with a custom node_add() form

texts:
I've exposed a node_add form and styled it for certain roles to use. The form is being displayed in panels, through an 'article' node type using the PHP text filter. Users can create new nodes with no issues, but there are errors displayed when users try to upload an image in the form:

  Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'node_form' not found or invalid function name in drupal_retrieve_form() (line 795 of /var/www/html/includes/form.inc).
  Notice: Undefined index: #node in comment_form_node_form_alter() (line 1193 of /var/www/html/modules/comment/comment.module).
  Notice: Trying to get property of non-object in comment_form_node_form_alter() (line 1210 of /var/www/html/modules/comment/comment.module).
  Notice: Undefined index: #node in menu_form_node_form_alter() (line 629 of /var/www/html/modules/menu/menu.module).
  Notice: Trying to get property of non-object in menu_form_node_form_alter() (line 629 of /var/www/html/modules/menu/menu.module).
  Notice: Undefined index: #node in menu_form_node_form_alter() (line 630 of /var/www/html/modules/menu/menu.module).
  Notice: Trying to get property of non-object in menu_form_node_form_alter() (line 630 of /var/www/html/modules/menu/menu.module).
  Notice: Undefined index: field_obs_image in file_ajax_upload() (line 271 of /var/www/html/modules/file/file.module).
      Notice: Undefined index: #suffix in file_ajax_upload() (line 280 of /var/www/html/modules/file/file.module).

The actual node form code looks like this:

module_load_include('inc', 'node', 'node.pages');
$form = node_add('observation');
print drupal_render($form);

I have also tried this code with the same results:

$node_type = 'observation';
$form_id = $node_type . '_node_form';
// maybe add current users info
global $user;
// create a blank node

$node = new stdClass();
$node->uid = $user->uid;
$node->name = (isset($user->name) ? $user->name : '');
$node->type = $node_type;
$node->language = '';
node_object_prepare($node);
$output = drupal_render(drupal_get_form($form_id, $node));

print $output;

The content type being added is 'observation'. I am also using the identical technique on another page with a different content type, and it results in the exact same error. The error appears directly above the image field during the AJAX image upload call.

I have also done a debug_backtrace() near line 795 of form.inc and can post the results if requested.

I have read all of these articles, to no avail:

"Notice: Undefined index: field_xxx in file_ajax_upload()" and "Undefined index: #suffix in file_ajax_upload"
D7 Image field upload errors with custom node_add() form
How to disable AJAX for a file field
The Field module shows an error when I call drupal_get_form()
Can't use file field in custom form - gives AJAX errors

Does anyone have an idea as to where I can start looking? This seems to be a tough problem. Thanks for your time!


texts:
I am trying to append a variable on the URL through a custom submit function. Is that possible?

My issue is that I am coming to the node/%/delete from different pages. I want to modify the delete form if the user comes to it from the node/%/edit. How can I detect this?

As @Clive suggested I'll try to add a query param in the following structure:

actions (Array, 5 elements)
  #type (String, 7 characters ) actions
  submit (Array, 5 elements)
  preview (Array, 5 elements)
  delete (Array, 4 elements)
    #type (String, 6 characters ) submit
    #value (String, 6 characters ) Delete
    #weight (Integer) 15


texts: Flag count is incrementing only after page reload

texts:
I have a views with like and unlike flag. When I click on like flag the count not increments. But when I reload the page, then only like's count will change. How can I solve this issue?

Note: I have already enabled ajax for my views.


texts:
I found simple code to put inside custom module that prints extra field inside cart view table

<?php
function ucaddsku_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'uc_cart_view_form') {
$form['items']['#columns']['model']['cell'] = 'SKU';
        for($i=0;$i<count(uc_cart_get_contents());$i++){
        $form['items'][$i]['model']['#value'] = node_load($form['items'][$i]['nid']['#value'])->model . ": ";

    }
}
}
?>

How can be any cck field printed like this?


texts:
I'm working on themeing a single site of a multi-site Drupal install.  The organization that set up the site has jquery 1.2.6 installed which is fine for most things... but as I'm planning on using a few other javascript libraries and maybe a few $.ajax calls, I was hoping for a more up to date jquery for the sake of compatibility.

Is there a way I can write a javascript call to remove the:

<script type="text/javascript" src="/misc/jquery.js?K"></script>

and then call my own?


texts: "Remove All" button for unlimited fields in Drupal 7

texts:
I've written a custom module for this functionality where my below code is able to delete the files but I think there should be a better way for doing that!

<?php
/**
 * Implements hook_field_widget_form_alter().
 */
function MYMODULE_field_widget_form_alter(&$element, &$form_state, $context) {
  $found = FALSE;

  if (isset($element['#field_name'])) {
    $details = $element;
    $found = TRUE;
  }
  else {
    foreach ($element as $key => $value) {
      if (isset($value['#field_name'])) {
        $found = TRUE;
        $details = $value;
        break;
      }
    }
  }

  if ($found && variable_get('MYMODULE_' . $details['#field_name'], 0) == 1) {
    $remove_button = array(
      '#type' => 'button',
      '#value' => t('Remove All'),
      '#ajax' => array(
        'event' => 'click',
        'callback' => 'MYMODULE_fields_callback',
        'wrapper' => 'checkboxes-div',
        'method' => 'replace',
       ),
    );
    $element['remove_button'] = $remove_button;
  }
}

function MYMODULE_fields_callback($form, &$form_state) {
  $new_var = $form_state['build_info']['args'][0];
  $nid = $new_var->nid;
  if(is_numeric($nid)){

    // get all fid's attached to this node
    $get_fids = db_select('file_usage', 'fu')
    ->fields('fu')
    ->condition('fu.id', $nid, '=')
    ->execute()
    ->fetchAllKeyed(0,1);

    foreach ($get_fids as $key => $value) {
      $fids[] = $key;
    }
  }

  // delete all files
  foreach ($fids as $key => $val) {
    $file = file_load($val);
    // file_usage_delete($file, 'MYMODULE');
    file_delete($file, $force = TRUE);
  }
}


texts: How do you dynamically redirect a user's role?

texts: This is a two parted question that deals with two different Modules "User" (or even possibly "triggers and actions") and Profile2. The main task is to have a user dynamically placed within a user role based on the information they submit within the user registration form fields. Presently, I have the form set up with a taxonomy button list. What happens next is the user should then be given a profile type that they can edit after the account creation is complete. Can you help?


texts: How do form #states interact with dialog action buttons, if at all?

texts:
A dialog can be fired by a link formatted as such:

    Some path displayed in modal dialog.

If the contents of /some/path are a form, then drupal takes its action buttons and drops them into a "footer"

 in the dialog. This seems to take into account the initial state of the buttons -- so if submit has the disabled attribute by default then the corresponding UI button gets the .is-disabled class applied. The "real" form action buttons are rendered but set to display: none.

However, I've got #states set up on my submit button with

$form['actions']['submit']['#states'] = [
  'disabled' => [
    ':input[name="field_fivestar_rating[0][rating]"]' => [
      [
        ['value' => '-'],
        ['OR'],
        ['value' => '0'],
      ],
    ],
  ],
];

The "real" form submit button is updated correctly according to its #states attribute, but the same cannot be said for the corresponding dialog button. It seems to be static based on the initial state of the submit button.

Is this expected behavior? If so, is this something that deserves an issue in the queue? Seems like an oversight and usability concern.


texts:
I have been using the migrate module to migrate users from Drupal 7.59 to Drupal 7.59. I encounter the following error.

Migration for NonDomainUserMigration failed with source plugin exception: SQLSTATE[42S22]: Column not found: 1054     [error]
Unknown column &#039;pgid&#039; in &#039;on clause&#039;, in /app/includes/database/database.inc:2227

What could be the issue? I can't find any pgid column in the drupal database.

the following is my User migration code

<?php
abstract class NonDomainBaseMigration extends Migration {

  // A Migration constructor takes an array of arguments as its first parameter.
  // The arguments must be passed through to the parent constructor.
  public function __construct($arguments) {
    parent::__construct($arguments);

    // With migrate_ui enabled, migration pages will indicate people involved in
    // the particular migration, with their role and contact info. We default the
    // list in the shared class; it can be overridden for specific migrations.
    $this->team = array(
      new MigrateTeamMember('Moses Liao', 'moseslgz@sph.com.sg',
        t('Tech Lead')),
    );

    Database::addConnectionInfo('legacy', 'default', array(
      'driver' => 'mysql',
      'database' => 'zaobao_drupal',
      'username' => 'root',
      'password' => 'password',
      'host' => 'mysqldb',
      'prefix' => '',
    ));
  }
}

class NonDomainUserMigration extends NonDomainBaseMigration {
  public function __construct($arguments) {

    parent::__construct($arguments);
    $this->description = t('Legacy Zaobao Drupal 7 system Users');

    $query = Database::getConnection('default', 'legacy')
    ->select('users', 'u')
    ->fields('u');

    $this->source = new MigrateSourceSQL($query);
    $this->destination = new MigrateDestinationUser();

    $source_key = array(
      'pgid' => array('type' => 'int',
                      'unsigned' => TRUE,
                      'not null' => TRUE,
                      'description' => t('Source ID'),
                     )
    );
    $this->map = new MigrateSQLMap($this->machineName, $source_key,
      MigrateDestinationNode::getKeySchema(), 'legacy', array('track_last_imported' => TRUE));

    $this->addSimpleMappings(
      array(
        'uid',
        'name',
        'pass',
        'mail',
        'theme',
        'signature',
        'signature_format',
        'created',
        'access',
        'login',
        'status',
        'timezone',
        'language',
        'picture',
        'init',
        'data',
      )
    );
  }
}


texts: How to get field values in node template in Twig

texts:
I have an image field named Gallery. You can add multiple images in this field. It’s in a content type named Gallery with Captions.

I have a twig template named field--node--field-gallery--gallery-with-captions.html.twig. Within that, I have the following, so that I can use the title and alt fields as content:

{% for item in items %}

 {{ item.content }}
{{ item.content['#item'].title }}

{{ item.content['#item'].alt }}

{% endfor %}

This all works great! Except when I want to use a different Display for this where it’s related to another entity type. There are two template hints I can use there:

node--gallery-with-captions--teaser-complementary.html.twig

field--node--field-gallery--gallery-with-captions.html.twig

I don’t want to use the latter, because I've already configured that for the full gallery/node page and in this case a) I only want to output the first image as a thumbnail to link to the gallery and b) I don’t want the title or alt. The node template has the right display type, but I’m struggling with digging into a) the first image in the gallery and b) the fields I want.

Any suggestions on zeroing in on the first image in this field displaying it as just the image linked to the entry? The template debug suggestions aren't suggesting a field template by display type, which is where this would ideally reside.


texts: Simple key => value array with QueryInterface

texts:
I'm looking at building a simple key => value array with a certain type of node I have in order to generate a select list in a form.

The thing is that I have thousands of nodes of this type and the page takes forever to load with the current code I have.

Is there a way to load only certain fields using the QueryInterface in order to cut on loading times? Is there a more efficient way to do this?

$query = \Drupal::entityQuery('node')
  ->condition('type', 'product')
  ->condition('status', 1)
;

$nids = $query->execute();

$nodeStorage = \Drupal::entityTypeManager()->getStorage('node');

// Load multiple nodes
$nodes = $nodeStorage->loadMultiple($nids);

$list = array();

foreach ($nodes as $node) {
  $list[$node->field_code->value] = $node->title->value . ' (' . $node->field_code->value . ')';
}


texts: Book navigation - how to customize outline to show progress and enforce serial navigation

texts:
I have a task to customize Book outline to:

force the pages of the book to be read from start to finish.  Once a page has been read it can be revisited.
show the progress through the book.

I was thinking of using the outline links to do this.  For pages that have not been read the outline item would not be a link.  Once the page has been read it becomes a link.

I am fairly new to Drupal and have some experience creating and modifying modules.  It would seem that this could be accomplished by extending the Book module but I have not looked at the code yet.

Does this seem like the best way to go or is there an existing module that would help?