texts: I don't have an "HTML no editor" option for text format for a block. How do I display these font awesome links in a block?

texts:
I am going through Drupal 8 theming with twig. It says to use "HTML no editor" text format for a custom block displaying font awesome links. There is no "HTML no editor" option, just basic HTML, restricted HTML, and full HTML. I am using the version Drupal 8.0.1 since that is the version needed for importing the database snapshots.

This is the code I am using for the links:

How do I get this code to display the font awesome links in a block? Why don't I have an "HTML no editor" option under text formats?


texts: PDO Error, __construct(): php_network_getaddresses: getaddrinfo failed:

texts:
I'm pulling a site from my production server down to a new development server that I'm setting up.

I can't get this to work though unfortunately. I imported my database into mysql and made sure that all of my account/privileges information was correct with what I had in my site-root/settings.php file.  I even created a new account with all the privledges and edited my settings.php file to it and still couldn't get it to work.

Is there somewhere else in my drupal installation that I need to input this information that I'm not aware of?   As a side note, I have other sites running locally in the same development environment, and they're running fine, however, I've noticed that they don't have a settings.php file.

Details:

This installation was originally created in MS WebMatrix using the Acquia Distribution As far as I can tell there's not a huge difference between this and other drupal distros beyond it having some really basic stuff already included. My other sites, that work, are running bear distro  and my development server is just your basic XAMPP setup.

This is what's in my settings.php file.  Obviously, the db, user and passwords where all replaced with comments for security reasons.  You'll just have to trust me that they match up.

$databases = array( 'default' => array( 'default' => array ('database' => '####commented for security###', 'username' => '####commented for security###', 'password' => '####commented for security###', 'host' => 'localhost', 'driver' => 'mysql', 'port' => '3306', 'prefix' => '' ) ) );

Here is a screenshot:

Thanks in advance for your time!


texts:
I'm trying to create a new page template for a custom form I'm building in my module. My goal is to use create something like a new page.tpl.php for this specific form and it looks like this method is creating the equivalent of a custom node.tpl.php within the content area of my site instead of generating a separate page template.

For example

/*
 * Implements hook_menu
 */
function mymodule_menu() {
  $items = array();
  $items['foo/my_custom_form'] = array(
    'title' => 'My custom form',
    'page callback' => 'mymodule_custom_page',
    'access callback' => TRUE, // Everyone has access.
  );
  return $items;
}

function mymodule_custom_page(){
  return theme('mymodule_template');
  return drupal_get_form('mymodule_form');
}

/*
 * Implements Hook_theme
 */
function mymodule_theme() {
  return array(
    'mymodule_template' => array(
      'template' => 'custompage', // template file called custompage.tpl.php
      'arguments' => array(),
    ),
  );
}

function mymodule_form($node, &$form_state){
//my form in here
}

I'm having an issue with the form not appearing.

Maybe I'm going down the wrong path and should be trying to create function in my theme's template.php, and then use a hook_preprocess_page to set some variables to create a page--custom.tpl.php for my form?

I can achieve what I'm trying to do by making some configuration changes to some blocks and redrawing the content area with CSS, but not sure if that's the best practice.


texts: How to check for entity type in Views when using hook_field_access?

texts:
I have some code that checks user access to a certain field using hook_field_access below.

The code runs fine when viewing nodes normally, but throws an error when viewing a node of type 'lesson' through a View:

Notice: Trying to get property of non-object

The error comes from the check for entity type: $entity->type == 'lesson'

If I debug with:

dpm($entity->type);

I get the right value ('lesson'), so the check seems to work.

How can I resolve this error?

function HOOK_utility_field_access($op, $field, $entity_type, $entity, $account) {

  //Check video field only when attached to 'lesson'.
  if ($field['field_name'] == 'field_video' && $entity_type == 'node' && $op == 'view' && $entity->type == 'lesson') {

    //Grant access only if user is logged in.
    if ($account->uid > 0) {
      return TRUE;
    }
    return FALSE;
  }
}


texts: When paging through a block, another block on the page disappears

texts:
I am using Drupal 7 with Organic Groups and Views. Currently within my team node I have 2 blocks appearing with the proper filters in place. The first block is configured to only appear only on pages with the group content. The second block displays 1 item per page and has a pager appearing belong the content in order to page through the multiple nodes belonging to the block.

I have noticed whenever I go to another page through the pager at the bottom of block 2 the 1st block completely disappears. Am I suppose to configure the first block differently? I don't know what I am doing wrong.

Edit

I would also be willing to remove the pager and make it so that if you click the second block's title it brings you to an alternate page/view/block that displays all of the content yet I haven't figured out a way since then it isn't on a group page anymore and I don't know how to grab (or set it up to grab) the group id to filter the content by.


texts:
I am building a site where people can log power failures in their area on a google map in Drupal 7.

I want to be able to have my site users register their location on their profile. This seems pretty straightforward to do using the Profile 2 and Location modules, however it's the next step that I'm hung up on.

I want the user to be able to click an "add a power failure" button, fill in the details of the failure (time, date etc) and hit save. Once this is done, I want to be able to plot a point on the map (using views or whatever) with the location details they entered in their profile when they signed up.

I've been trying to play with User reference and node reference in the power failure content type, but this doesn't really give me what I want.

Does anybody have any ideas on how I can accomplish this?

Thanks!

G


texts:
I know there is a lot written on Drupal and tables that have tens of thousands and even millions of records but everyone has a different solution and I want to bring up a specific case.

I am using the log module (https://www.drupal.org/project/log) for Drupal 7 to save detailed custom log messages about a process that I have created for an internal system running on a small ubuntu VM in the Azure cloud. My bundle for the log entity has three custom fields. At 1.5 Million records with 4 custom fields that is 6 Million Records and we are growing every time the process iterates.

As you can imagine the site is slowed down to a near stop when making queries against the log table.

I am thinking of writing a little module to put the entities into a table that is not part of Drupal or exporting the data into a CSV file.

Is there a better way?

Thanks,
Josh


texts: Advanced forum: How to modify template of forum list page?

texts:
Here's the normal template for Advanced Forum:

I'd like to modify the template of advanced forum so that I can

Remove the elements in red
Rearrange the elements in blue
Edit the elements in green
Display the topic starter's profile2 picture

so that I can achieve the result below:

So far, I've tried editing advanced-forum.naked.topic-list.tpl.php but it doesn't change anything. I've managed to remove some of the content with Panels but I cannot modify what's left over here.


texts: Anonymise Webform submission in database

texts:
I am asked to modify the behavior of some webforms on a Drupal 8 instance; data who could identify a user submitting a form should not be stored in the database. Submissions must be sent by email though.

Webforms do have a "Disable saving of submissions" option, however, some of the forms have file fields; files that must be sent as attachements to the mail I mentionned, and those forms cannot work if I activate the option.

I tried creating my own Webform handler but I couldn't find a way to successfully alter submission there. I managed to alter data by using a custom validation class but as I suspected, the data is altered before it gets emailed.

Drupal 'Cron' tasks won't do it either. The legal team asks that the data does not persist in database longer than the time required by the processing of the form.

I may be blind, but am running out of ideas and cannot find a relevant documentation for my problem.

TL;DR: On webforms with file fields, how can I prevent storage of specific fields in the database or rewrite them while still sending the original data by email


texts:
I sucessfully printed the whole taxonomy tree using this code.

$voc = taxonomy_vocabulary_machine_name_load('product_sub_categories');
$tree = taxonomy_get_tree($voc->vid, 0, NULL, TRUE);
foreach ($tree as $key => $term) {
  print $term->name."
";
}

Now I want to separately print parent and child in order to custom theme them, because I already have a mark-up in which parent has separate
 Parent terms
 and children has separate
Child terms
.

How should I do this?

I have done it using taxonomy_get_children(), but it is giving me the children of parent of the taxonomy whose ID is 1.

child1
child2
child3

This is what I need, but now I want to get the children of parent
child1. I tried to get them by reusing the above function but it give me this.

child1

children of child1

child1
child2
child3


texts: Drush and web front end reporting strange updates?

texts:
Is anybody else seeing this:

root@dev:/etc/apache2/htdocs/drupal-7/sites/tpppdonate.org.uk# drush pm-update --pipe
imagecache_token 7.x-1.0-rc2 7.x-1.x-dev Update-available
uuid 7.x-1.0-beta1 7.x-1.x-dev Update-available

The update process is reporting that a dev version is the recommended version over the stable release.  The same story is reported in the front end.

When I take the bait and run the import - all I see is a verison number change in the .info file:

before: version = "7.x-1.0-rc2"
after: version = "7.x-1.0-rc2+0-dev"

Anybody any idea what is going on?


texts: I'm faced with the situation of needing to be able to publish content with Drush.  Is there a way to use Drush to publish nodes?  If there is, how can it be done?


texts: How to add fields in Drupal Registration Form?

texts: I have installed content profile module. I just want some fields in drupal sign up page. I am using Drupal 6. How can I achieve this?


texts:
This is something I have run across on multiple drupal sites so I feel like

A) There MUST be a straight forward way to do this as there usually is with drupal

B) this must have already been answered (I just can't find a suitable answer when searching)

C) If there's a module that does this that I'm unaware of, that's a fine solution.

When using contextual filters with taxonomy I often want "no results" to give a summary. But a linked list of terms is pretty unattractive. What I want is to add thumbnails and lay it out (often in a grid). Taking the first thumbnail from the term is ok, though setting the image would be even better.

Take a look here: http://worldtouringentertainment.sander-martijn.com/categories - once you click on a category you get thumbnails of the primary/featured image and can click through to the actual content page - but this page is just a list of links.

Is it possible, without creating a totally separate view or a static page (both of which require further long-term management for non-savvy clients), to get a thumbnail into this first list so it looks attractive?


texts:
On the module update area, my install of 7.56, can seem to find matches to core and a few modules.

How do I begin to fix this?

What I've tried so far:

Based on translating an answer in  Cannot update drupal8: “No available releases found” to v7, I attempted

drush vdel update_last_check -y
drush rf
drush cc all
drush cron

This failed to do anything meaningful.


texts: db_update query in custom installation profile gets ignored

texts:
I am currenty working on a custom installation profile that enables modules, performs some db queries and so forth.

It also sets my default theme and admin_theme...

Nothing too special ;-)

I have 2 db_update queries as well, located in my .install file.

The first one works perfectly

// Enable the admin theme.
db_update('system')
->fields(array('status' => 1))
->condition('type', 'theme')
->condition('name', 'rubik')
->execute();

The second one gets 'ignored'

// Locate menus is right regions
db_update('block')
->fields(array('status' => 1, 'region' => 'sidebar_first'))
->condition('delta','menu-left-menu')
->condition('theme', 'mytheme')
->execute();

I have tried the last query with devel/php and then everything works perfectly.

What am i missing?

When i put the query in a .module file it works as well...

Thanks for any advice!


texts:
I'm making my first Drupal Module, and I'm just looking for some tips/direction for development.

The module will parse a JSON feed and simply show each object in a formatted way as a simple page. I plan to expand this to be much more modular (including writing to a database table) in the future when time permits.

The "page" display will be something like:
 - Thumbnails for each different object within the JSON feed
  - Each thumbnail will have a small thumbnail image, title, and teaser (short description)
  - Each thumbnail will be clickable
 - Clicking a thumbnail will produce a lightbox (Lightbox2 or Colorbox) style pop-up with more information for that specific object
  - Information inside the pop-up should be full description, various other images, etc.
 - I suppose that each thumbnail will be around 280x320px (though I may want to administer the size of this)

Currently I am able to parse the JSON feed and get the data that I want using: $json = drupal_http_request($url) then $data = drupal_json_decode($json->data). After this I can simply create a string that I can use for the output to 'page_callback' in the hook_menu().

However for returning the output, should I just return one large string that gets printed to the page? or is there a better way?


texts:
My vocabularies machine name is vocab_ . $account_id .
First Funcs: too see the user $account_id is the same with vocab.. if yes then return TRUE.

function _term_account(){
  global $base_url;
  global $user;
  $account_id = custom_get_user_account_id();
  $tesr = explode('_', arg(3));
// admin/structure/taxonomy/vocab_21117 .. witch 21117 is $account_id
 if($tesr[1] == $account_id){
    return true;
 } else {
    return false;
 }
}

I use hook_menu_alter to alter the taxonomy url:

function custom_menu_alter(&$items) {
  // Works fine.. So every user has he's own and only vocabulary..
  $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/list']['access callback'] = '_term_account';
  // DOESN'T WORK.
  $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/add']['access callback'] = '_term_account';
}

UPDATE
When User edit term..

function _term_account_edit(){
    $account_id = custom_get_user_account_id();
    global $base_url;
    $term = taxonomy_term_load(arg(2));
    if($term->vocabulary_machine_name == 'branches_'.$account_id){
        return true;
    }else{
        return false;
    }
}

function custom_menu_alter(&$items) {
  $items['taxonomy/term/%taxonomy_term/edit']['access callback'] = '_term_account_edit';
}

The Delete Button dosen't Show up? Why?


texts: Get node form inside preprocess_views_view_fields()

texts: how can I get the node id  through the  : preprocess_views_view_fields()


texts:
I can't filter list term under admin/content.

There is not filter option for list term, just the types (taxonomy)

This is Drupal 7, ther is no category option.

This is Drupal 6, it can filter category.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Installed Admin Views and add the following settings to /admin/structure/views/view/admin_views_node/edit

But term list still not appearing.


texts:
admin/config/search/clean-urls just isn't loading. I don't mean it shows a white screen or anything like that - the browser just doesn't load it at all. The browser's loading gif spins and it says "waiting for ".

I've disabled every single module I can; the only ones left have the ticks greyed out and cannot be disabled.

PHP memory limit is 1024M and execution time 60s.

There is nothing in php_errors.log or in (once I re-enabled it) dblog.

Version 7.40, but don't know how many versions it's been like this for.

Any ideas?


texts: How to integrate properly Kerberos based SSO in Drupal 7

texts:
I'm trying to install Drupal with Single Sign On over Active Directory.
My customer does not have any SSO suite like CAS, and their general recommendation are to use Kerberos (or NTLM as a second choice). I am clearly agreed with that.
Each time I had to integrate SSO with Active Directory using Kerberos, I use "native" product facilities, or apache mod_auth_kerb with headers rewrite.
Does someone implemented such a working module ? Everything I read about that is around "on developpement modules" on "snapshots realeases". We are currently using a ldap module that allow authentication over LDAP, and it seems that it provide SSO features, but I don't have any feedback on it.
So : Should I implement SSO over Kerberos using Apache mod_auth_kerb, or is there a real functional module that would encapsulate all those tedious configuration and dialog ?
What is the best pratice, at this moment ?
Could you provide me "real" (anonymised) examples ?
As soon as I would installed it and put in in production (around the end of december), i would give you my feedback.
Thanks in advance


texts: Unable to upload large files (>50mb) to Amazon S3 from D7 on EC2

texts:
I'm trying to configure Drupal to upload large videos (eventually goal is ~300mb, but currently testing with ~50mb files) to S3 through my Drupal site running on an EC2 instance.

I have configured and tried both the Amazon S3 and Storage API modules. When trying to upload a small file around 5mb, everything is fine and works perfectly. However, when I try with a large file, I receive the following error:

  Warning: filesize(): stat failed for storage-field-storage-test://[FILE NAME].mp4 in file_save() (line 601 of /var/www/includes/file.inc).

This error is the same for both the Amazon S3 and Storage API modules.

It turns out that the large videos are not being uploaded to S3, which explains the error message.

I am able to upload files directly to S3 okay and I am able to upload large files to local storage just fine as well (the PHP upload limit is set well above what I'm trying). What I don't understand is what could be causing the failure with the large file sizes between Drupal and S3. Any suggestions?


texts: drush status only showing drush info, not drupal info

texts:
I have drush installed globally on my VPS (thanks to a previously answered question on here :D), logging in as root all works fine, but using a different user (let's call it drushuser) if I run:

drush @mysite st

I just get the drush version etc, not the drupal info.
I assume this is down to the 'root' path in my alias:

'root' => '/home/accountname/public_html',

so logged in as root on the VPS that works - but what should I change it to for drushuser? I'm guessing drush is currently looking in /home/drushuser/home/accountname/public_html and not finding drupal (since it doesn't exist there) so just giving the drush info instead?

I've tried '../accountname/public_html' which didn't work.


texts: What events, conditions and actions I should use for this case?

texts:
I use "commerce" and "commerce stock" modules, I created a list with products and a few extra fields in Product types:
- Image
- Deposit 1 Stock
- Deposit 2 Stock
- Deposit 3 Stock

I created a view (table - http://ucreateawebsite.com/DRUPAL/dalexgrup/pt)  with this fields:
- Bulk Operations
- SKU
- Imagine
- Title
- Deposit 1 Stock
- Deposit 2 Stock
- Deposit 3 Stock

I have a problem in succeeding to create another stock field (the fourth - called TOTAL STOCK) and making it to automatically update when the other 3 fields are being changed. I want the fourth field to calculate and show me the sum of the other 3 fields.

Example 1 *
Deposit 1 Stock -> 15
Deposit 2 Stock -> 15
 Deposit 3 Stock -> 15

     TOTAL STOCK -> 45

Example 2 *
Deposit 1 Stock -> 10
Deposit 2 Stock -> 05
 Deposit 3 Stock -> 01

     TOTAL STOCK -> 16

This TOTAL STOCK field I should create in Product type like:
- Deposit 1 Stock
- Deposit 2 Stock
- Deposit 3 Stock ??????

Then I should create a rule? What events, conditions and actions I should use?

Thank you.


texts: I have a content type that has an integer field, but I can't find the table for that field in the database, what gives?

texts:
I'm working on a project inherited from another developer. One of the content types has an Integer field and I wanted to do a custom query that checked the value of this fields. When I went looking in the database I couldn't find the associated table.

The field is field_company_upgraded in the content type editor so I was expecting to see a field_data_field_company_upgraded table, but it didn't exist. Is there a reason for this?


texts: How to get the raw value of the url in a link field

texts:
I'm doing this:

$link = $node->field_link->first();
if ($link) {
  $url = $link->getUrl()->toString();
  ...
}

If the value in the link field is /node/123 but there is a URL alias defined as:

Alias: /about-us    System path: /node/123

I get /about-us in $url. I want to get /node/123.

How do I get the raw url value instead of the aliased value?


texts: How does drupal 7 know its version? which file does it check?

texts: Hi Im just curious to know where is the metadata of the version info, where does drupal have defined its version in the files...


texts:
Users have 'edit own content' permission for content type 'diary'. When viewing own diary node, I would like to present a simple checkbox to 'make private'. Then only that user can view the node.

I've looked at some options for doing this:

1) Write a module that uses hook_node_access() - overkill?

2) Perhaps an existing content access module provides a useful hook?

3) Create a 'private yes/no' field, then use Editablefields module to expose it on view. Then use theming layer to hide if set to 'yes'. - clunky?

I'm learning to write simple modules so perhaps a good learning opportunity here, but not sure where to start.


texts: Is there any way to use views contextual filters in block configuration?

texts:
For my situation, i need to create views for taxonomy terms content listing, I have created that with blocks. I am using contextual filter in that views to filter the content with taxonomy terms dynamically.

Is there any way to give value for contextual filter from block configuration page ?

If we have that options, then it would save me from creating separate blocks for each terms.

Contextual filter configuration :

My question is can i give value for the contextual filter from the block configuration page ?


texts: Hello I Have Created A Slideshow Using Views  but in slideshow if anyone is clicking The link was opening node/8 I Don't Want To Show Link In When Anyone Clicks on slideshow here is my website link Windowhelpdesk.com


texts: CKEDitor removes class names, even with the exception in config

texts:
CKEditor seems to be stripping out class names when I toggle between HTML view and Rich Text view.

As per many suggestions across the web I have added the following to the config.js file:

config.allowedContent = true;

Uploaded, cleared cache and even gone to the JS file directly to check it is not caching on my machine, but it's still removing classes.

Is there another solution?


texts: Print node title in custom block module twig file

texts:
I want to send node title and description into twig file. See my code

public function build() {

return [
'#theme' => 'block--maincontentlatestnews',
'#latest_news' => $this->read_latest_news(),
'#sample' => 'sample_txt',
'#attributes' => [],
];
}

function read_latest_news(){

$nids = \Drupal::entityQuery('node')->condition('type','article')->execute();
$nodes = entity_load_multiple('node', $nids);

return $nodes ;

}


texts: Facebook Friend List Import using fboauth

texts:
I am using fboauth for enabling login with facebook for the website. Here is an overview of how I achieve the functionality:

When the user clicks on the facebook login button on the website, he or she is taken to a facebook login page. After logging in with facebook, the user is taken to the app authorization page where the user asks for permission to connect with the app. Once necessary permissions are granted, a local account (account at my website) is automatically created for the user and the user is brought back to a welcome page to set password. The user won't even have to verify their email address. On subsequent visits, when the user clicks on the login link, he/she is taken to the same facebook login page where they supply their login credentials. On successful login, they are brought back to the website. So far, everything works fine with the fboauth module.

What I am trying to achieve now is a functionality similar to what is found with the fbconnect module. The user is provided with a block/page where the user can import the list of his friends who has authorized with the app, and see the links to their local accounts (accounts at the website). How to achieve this functionality? The fboauth module has its own API which can be utilized. Here is what I already have, written using the API of fboauth.

<?php
function mymodule_fboauth_actions() {
  $actions['mymodule_friend_import'] = array(
    'title' => t('Imports your friends),
   'callback' => 'mymodule_fboauth_action_friend_import',
    'permissions' => array(
      'user_friends',
    ),
);
  return $actions;
}
function mymodule_fboauth_action_friend_import($app_id, $access_token) {
$result = fboauth_graph_query('me/friends?fields=name', $access_token);
drupal_set_message(t('Import complete!'));
}
?>

This will import all the friends of a user as an object into $result. However, what I am finding it difficult is to display those names with the user's corresponding local accounts (accounts at the website). This is because of my lack of knowledge in php. What I am looking for is here is the exact lines of code that can be inserted after $result recieves its value so that the names of the users are displayed along with the links to their profile pages at my website.


texts: How to add Drupal Commerce to an existing Drupal site?

texts:
I wonder how to add the Drupal Commerce module to an existing Drupal installation.

I've had problems with the documentation about this topic that I have looked at so far:

A video about Adding Drupal Commerce to Existing Sites.
The Drupal Commerce User Guide.

I've also looked at the available Community documentation about Drupal commerce and I have installed the required modules. But when I try creating the products I'm having issues.

After following the aforementioned documentation and creating a custom product I get this error when trying to view the newly created product:

  EntityMetadataWrapperException: Unknown data property
  commerce_product. in EntityStructureWrapper->getPropertyInfo()

Any suggestions about how to resolve this error?


texts: Why has my security shield for my new module on Drupal.org been removed?

texts:
I have recently managed to create a module on drupal.org, by following the entire process from Sandbox->Project Application->Module Publish.

However after few weeks my module lost the security shield, and am getting this message instead:

  This project is not covered by the security advisory policy.
  It may have publicly disclosed vulnerabilities. Use at your own risk!

I have gone through some of the documentation (Security advisory process and permissions policy), but I couldn't find suitable explanation.

Here is a screenshot of how it looks like now:

My questions:

Why has my module been tagged with this message?
How can I resolve it, or how can I find what is wrong in my module?


texts: Deprecated Dependency Warning not removing

texts:
In my Drupal 8.9.6 (Installed with Lightning distribution) Status Admin Page, there are three warnings showing after updating several modules and core to the latest versions:

DEPRECATED DEPENDENCY: ENTITY EMBED Lightning Media 5.0 will not include the Entity Embed module. Please add it to your project directly: composer require drupal/entity_embed:^1.0
DEPRECATED DEPENDENCY: VIDEO EMBED MEDIA Lightning Media 5.0 will not include the Video Embed Media module. Please add it to your project directly: composer require drupal/video_embed_field:^2.0.
DEPRECATED DEPENDENCY: VIEWS INFINITE SCROLL Lightning Media 5.0 will not include the Views Infinite Scroll module. Please add it to your project directly: composer require drupal/views_infinite_scroll:^1.6.

I have installed the latest versions of these contributed modules through composer. But the warning not going away from the admin status page. How to remove these warning?


texts: Link to create a node, save it, and then go to the edit page

texts:
I want to enable users to click a link to create a node of a specific content type. However, instead of going to /node/add/contenttype, which is the standard Drupal flow, I want the node of the relevant content type to automatically be created and saved, and then redirect the user to the newly created node's edit page.

In other words, when a user clicks "add a node," I want to create the node for the user and send the user to the edit page.

I want to do this because I have a very long, complicated form and I want to use the Autosave Form module to automatically save the form; however, this module can only save a node/entity that has already been saved once (entities with an entity ID).

What's the simplest way to implement this?

I'm thinking that I will need to define a custom route that checks permission, runs code to create the node, and then redirects to the node.

EDIT: Overriding the NodeController

As suggested by 4k4, I overrode the NodeController as follows.  However, the problem is that when I go to /node/add/contenttype, the node is created and the form is shown, but it's an old form; when I try to save it, I get this error: "The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved."

class MymoduleNodeController extends NodeController {
  public function add(NodeTypeInterface $node_type) {
    $content_type = $node_type->id();
    if ($content_type == 'MYTYPE') {
      $node = $this->entityManager()->getStorage('node')->create([
        'type' => $node_type->id(),
      ]);
      $node->save();
      $form = $this->entityFormBuilder()->getForm($node);

      return $form;
    }
    else { // Default node creation behavior


texts: Setting Simple Sitemap Values Programmatically not reflected in form

texts:
I'm trying to set some Simple Sitemap settings programmatically. I'm using the following to set whether or not a specific node is indexed:

\Drupal::service('simple_sitemap.generator')->setEntityInstanceSettings('node', $node->get('nid')->value, ['index' => FALSE]);

This works fine and I was able to see the results reflected in my sitemap. However, this is only reflected in the "Simple Sitemap" form of that node if the value is set to TRUE. If FALSE neither radio button is selected.

This is confusing to others who are editing the site. How can I get this reflected in the form?


texts: Can I target a specific node type in page.tpl.php

texts:
I just created a template page--article.tpl.php to apply ton nodes of the [article] type. It works when declared in the template.php file.
My problem is that there is a very slight change compared to the generic page.tpl.php, nothing worth having another file.

I was wondering if I could place the adde part between a condition, just as I could do with if $is_front
Something like:

<?php if ($node->type == 'article')
  // render my thingees
?>

I would be glad if someone could tell me.

--- Edit, to answer Kiwimind ---

I did the test with the 'page' content type, so I didn't have to skip my page--article.tpl.php file. I checked that 'page' was the actual machine name and 'nature' is my theme's actual name, it works on other functions.
I wrote in template.php

/**
 * Détection du type de contenu pour affecter le template page
 * https://drupal.stackexchange.com/questions/264550/can-i-target-a-specific-node-type-in-page-tpl-php
 */

function nature_preprocess_page(&$variables, $hook) {
  $variables['is_page'] = false;
  if (isset($variables['node']) && $variables['node']->type == 'page') {
    $variables['is_page'] = true;
  }
}

Then in page.tpl.php

<?php if ($is_page) : ?>

This is a “page” content

<?php endif; ?>

Nothing more, nothing less. Do you see any missing (or unnecessary) character, that could trigger a parse error? For I still get a whole blank page when clearing the cache.


texts: Multipage Registration form, Confirmation Page Security Issues?

texts:
I have a multipage registration form working on a site, but the confirmation page is supposed to show some of the information (account name and other data) after the account has been submitted/created. I can treat this confirmation page as the last page of the multipage form, but I'm concerned that the user can then press the back button on the browser, the session data will still be there, and they can then re-submit the same data again.

Another approach would be to end the session and display the data on a redirect page, but I could not find how Drupal 7 would pass this form data to the redirect page. There would be too much data to put it in the URL.

Does anyone have a suggested Drupal 7 method to achieve a confirmation page showing session data, but not allow the user to press back on the browser and re-submit the form again?


texts: How do I get line breaks when using Plain Text format?

texts:
I feel like this should be reaaaaaally simple, but it's driving me crazy.

I have 'plain text' selected for all my Body elements. I don't want anyone to be able to put in any html at all when filling out forms.

However, I do want the line breaks preserved.  On the configuration page for plain there there is indeed a 'check this box to to turn line breaks into br and p, but no matter what I check or how I rearrange the weight of the filters, I cannot get it to preserve the breaks.

What is the correct configuration to get this to work so that I can preserve returns in the texts?


texts:
I am using migrate module to transfer data from one site to another here is my query

$query = Database::getConnection('db1', 'db1')
        ->select('users', 'u');
$query->leftjoin('field_data_field_user_insti_name', 'insti_name', 'insti_name.entity_id = u.uid and insti_name.bundle = \'user\'');
$query->leftjoin('users_roles', 'ur', 'ur.uid = u.uid');
$query->fields('u', array('uid', 'name', 'mail', 'pass', 'status'));
$query->fields('insti_name', array('field_user_insti_name_target_id'));
$query->condition('u.uid', '1', '>');
$query->condition('ur.rid', '6', '!=');
$query->distinct();

than I am getting this error

  Integrity constraint violation: 1052 Column 'uid' in on clause is ambiguous

I found a solution for this problem that i have to add line

$this->source = new MigrateSourceSQL($query, array(), NULL, array('map_joinable' => FALSE));

After this error is solved, but don't know what this line do, is it safe to use this line


texts: I would like to multi-select files in media browser. I came across this sandbox module: Media Multiselect but it has bugs that render it not usable. Does anyone know of a solution to multi-selecting files in media browser?


texts: How can I purge unused translatable strings from the translation interface?

texts:
During the development, the wording changed quite a lot. When I generate translation jobs with tmgmt module (or by any other means), all the old wordings are listed as well.

Is it possible to have a fresh start? Per hand removal would also be ok.


texts: Node translation syncing problem with entity references

texts:
I have a content type with multilingual support (node translation). This content type also has an entity reference (module: entityreference) field.

My content is:

/node/1 English story 1
/node/2 French  story 1 (translation of #1)
/node/3 English story 2 with reference to #1
/node/4 French  story 2 (translation of #3) **entityreference problem here**

I've configured the reference to be synchronized. The problem is that whenever I translate or edit a node, it'll try to sync the reference to other translations.

So I'll always end up with:

#3 -> #1 (correct)
#4 -> #1 (wrong)

or:

#3 -> #2 (wrong)
#4 -> #2 (correct)

I can solve this by disabling syncing on the reference field but then I will have to be maintaining the references for all translations manually which is a problem in a website with many translations.


texts:
I am converting a module from drupal 7 to drupal 6. I have a query in drupal 7.
The query contains function db_merge()

   db_merge('facebook_rules_user_tokens')
    ->key(array('uid' => $form_state['user']->uid))
    ->fields(array(
      'user_grant' => $form_state['values']['facebook_rules_allow'],
    ))

Which function should I use in d6 for the above sql?


texts: How to show preview of entered values in previous steps in webform with multiple steps

texts:
I am configuring a "Webform". In my webform field components, I am using "page break" in order to create Multiple step forms.

But I like to show the entered value in previous steps in current step.

for example, if user is in step 2, I want to print entered value of step 1 bellow the form.
or if user is in step 3, I like to print the entered value of step 2 and step 1 bellow the form.

is there any module to run this scenario? or I have to program a custom module?

Please guide me.

Thanks a lot


texts: How do I import attributes with the feed mapper?

texts:
I have a Drupal 7 instance with Ubercart 3, and I'm also using the Ubercart Feed Mappers module to map out the importing of product fields. I have all the fields, images and categories working well, but not attributes.

I've searched high and low for an answer or a short how to for importing attributes and multiple attributes for each product but with no success. How can I achieve it?


texts: How can I install CKEditor on a server without downloading the files locally?

texts:
A bit of background info before I get down to my question - I'm using the URL method of loading modules to Drupal as I do not wish to save them to my dinosaur age PC. I have also not uploaded Drupal to my PC, but am operating it via Pantheon. This is not only because of my old PC, but as I am only in the very early stages of developing my website, one advisor has said I don't need to worry about that and other programs such as MySQL.

I'm keen to get CKEditor onto my Drupal platform, so have added the CKEditor - WYSIWYG HTML editor module and this appears so far to be successful.

The tutorial I am following assumes that I am able to save the CKEditor program to my PC... which I guess in essence I can, but I am hoping there is a way to avoid doing this and load it the same way I do a module via URL perhaps?


texts: How to use profile 2 to display user profile page with comments enabled?

texts:
I have  Downloaded, Installed and enabled profile 2, profile 2 pages & profile 2 group access ( i have organic groups)

Then went to permissions View any profile (all users), View own profile (authe. , admin), Edit own profile (authe. , admin.)

After which i Went to Config > People > Account settings > Manage Display > Custom Display settings and checked user account.

Whats are the next steps that i should do, or are missing, that i should have done, inorder to enable user profile page along with default comments enabled on this page ?


texts: Am I allowed to include a JQuery Plugin in my Drupal Module?

texts:
I'm writing a Drupal module and I want to make use of a JQuery plugin, but I'm unsure if I'm a) breaking any rules and b) if there are any licensing considerations.

My question is can I use plugins and what is the best way to include them (i.e. in the libraries folder or as part of my module or via something third party).


texts: Overwrite an empty field value on node / rendered entity

texts:
I have a text field in a media image type (for a photo caption) - I'd like to output a default value whenever it's empty.

I tried using HOOK_preprocess_field, but that hook isn't reached if the field of the node is blank.

It's being inserted in a View, but it's more than one field (a display mode of a Rendered Entity showing a photo thumbnail and the caption) and therefore as the photo is present when the caption isn't, I can't use the No results behaviour.

I also tried HOOK_preprocess_node and HOOK_preproces_content_field, neither of those seem to be called at all in the view.

Is there anywhere else I can edit it?


texts: Display one recent comment in node teaser?

texts:
Trying to find the easiest way to include the first most recent comment in my view that is using the 'teaser' mode. I am using the rate module to display number of votes in the view as well which doesn't have a 'field' to add so that is why I need to use teaser mode instead of fields mode.
Thanks


texts: Term Reference Autocomplete field that searches fields besides name

texts:
Is there any way to have a term reference autocomplete field search other fields than just the title?  In my case I have a organizations vocabulary with the taxonomy name and an acronym.  The main point of adding an acronym field is to stop users from putting in the acronym in place of the full organization name.

If I turned it into an entity reference field would, the autocomplete widget type allow me to do this?


texts: How to create incremented view filters for numeric fields in Drupal?

texts:
In my Drupal 7 I'm building a view of homes/properties with exposed filters of "Minimum Rent" and "Maximum Rent" - so that people can find homes according to their budget.

Rent (per month) is basically an integer number field and can be whichever number (£475 or £677 or whatever an end user enters when creating the node). But in my exposed filters for "Min Rent" and "Max Rent" I want it to be a dropdown list of £100, £200, £300, £400, £500 etc -in other words, automatically incremented. Exactly as we see on websites like www.rightmove.co.uk or www.zoopla.com or any other property listing website.

How can I achieve this?


texts: Drush not working on a docker based enviroment on ubuntu 16.04

texts:
I have set up a local dev docker environment with the Drupal social distribution. My issue is that Drush commands do not work and whenever I run a Drush command, it takes approximately 45 seconds to get a response. Generally, the output is always the same or similar to the following.

  [warning] proc_open(): unable to dup File-Handle for descriptor 2 - Too many open files exec.inc:243
  [warning] proc_get_status() expects parameter 1 to be resource, boolean given exec.inc:244
  [warning] proc_close() expects parameter 1 to be resource, boolean given exec.inc:245

I am unsure what the reason for this response is or what I may have done wrong to get to this point. I tried googling the warning errors but without getting a usable answer. If someone has had similar problems and managed to solve it, some directions on what to do would be appreciated.

I also want to state that outside the docker environment I have setup multiple Drush setups; Drush commands work normally without any delay outside of it.

My environment is Ubuntu 16.04 with 15.5 GB RAM, i7-6500U CPU 2.5 GHz x4 Processor, 200GB DDR disk.

I googled some more and found out that for running Drush inside a docker environment you need docker-compose run drush "drush command here" since Drush container gets run only for one specific command and then shuts back down, but now I am getting different errors.

docker-compose run drush cache-rebuild --verbose --debug gives this as output.

  Phar detected. Proceeding to drush_main().Drush preflight prepare loaded autoloader at  [0 sec, 2.92 MB] [preflight]
  Starting Drush preflight. [0 sec, 2.92 MB] [preflight]
  Cache HIT cid: 8.1.2-commandfiles-0-9c75c37463d39480ab97163ab2be3712 [0.01 sec, 2.96 MB] [debug]
  Scanning into /etc/drush for /.*aliases.drush(8|)rc.php$/ [0.02 sec, 5.02 MB] [debug]
  Scanning into /etc/drush for /self.alias.drush(8|)rc.php$/ [0.02 sec, 5.02 MB] [debug]
  Scanning into phar:///usr/local/bin/drush/includes/.. for /.*aliases.drush(8|)rc.php$/ [debug] [0.02 sec, 5.02 MB]
  Scanning into phar:///usr/local/bin/drush/includes/.. for /self.alias.drush(8|)rc.php$/ [debug] [0.03 sec, 5.03 MB]
  Scanning into /root/.drush for /.*aliases.drush(8|)rc.php$/ [0.04 sec, 5.03 MB] [debug]
  Scanning into /root/.drush for /self.alias.drush(8|)rc.php$/ [0.04 sec, 5.03 MB] [debug]
  Bootstrap to phase 0. [0.05 sec, 6.01 MB] [bootstrap]
  Bootstrap to phase 2. [0.05 sec, 6.01 MB] [bootstrap]
  Command cache-rebuild needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command. [error] [0.05 sec, 6.01 MB]
  Command cache-rebuild requires Drupal core version 8+ to run. [0.05 sec, 6.01 MB] [error]
  The drush command 'cache-rebuild' could not be executed. [0.05 sec, 6.01 MB]

Hope that gives you a clue of what is the matter here.


texts: Search only for the currently active language

texts:
How can I restrict the results from a default search in Drupal 7, to bring only the nodes that are in the current language?

My website has a three language switcher; the user chooses what language he wants to use when viewing the site. If he searches something, the result page bring results from other languages. Today I have only 3 enabled languages, but we plan to expand this to 6 or more.


texts: Related taxonomy blocks on taxonomy page

texts:
I have a property website with several taxonomies

Area
Post-Code
Station
Size

What I would like is a series on blocks/ views on each taxonomy page which show the realted taxonomies of all properties of a specific taxonomy

For example, if I In Taxonomy Page - Area/Area1 I would like to display a list of related taxonomy terms in a block for post-code, Station and size.

I can create blocks on an individual property which display blocks showing all taxonomy terms for that property., and using the example above I can show a block which shows area on the area taxonomy page or I can show all post-codes, stations, and size .

What I cant do is limit the terms to only show related terms drawn from the current taxonomy

I guess this is similar to a faceted search

Thanks


texts: Ho to improve Drupal site score on PageSpeed Insights Site

texts:
I have check score on PageSpeed Insights,
But I am getting following error

Should Fix:
Eliminate render-blocking JavaScript and CSS in above-the-fold content
Your page has 16 blocking script resources and 8 blocking CSS resources. This causes a delay in rendering your page.
None of the above-the-fold content on your page could be rendered without waiting for the following resources to load. Try to defer or asynchronously load blocking resources, or inline the critical portions of those resources directly in the HTML.


texts: Metatags trimmed body in description/summary

texts:
I am using the Metatag Module. Everything works as expected, till I checked the description for each node and saw that it is empty.

Since there is no output with [node:summary] I changed it to [node:body] which works, but now the whole node is in the description field... I checked the available tokens [*:summary, *:value, *:format] with no success.

Any suggestions how to use the [node:body] in a trimmed version?


texts: I am working on a large project for a bilingual site. I would like to move their site from Wordpress to Drupal and see the multilingual capabilities of Drupal 8. However, the site won't be ready to build until late summer of 2015. Would it be a good idea to build on Drupal 8 or because of lag of modules and such, use Drupal 7. As I'm not using Drupal 7 now and don't need to worry about upgrading modules, I think it would be ok to go right into 8. I would like some feedback as to the best route.


texts: Setting up regex-style rewrite rules within Drupal?

texts:
I have a couple of legacy rewrite rule redirects that I've traditionally put in .htaccess. For instance, paths are of the format:

story/[story:title]

And paths like:

story/[story:nid]

redirect to that.

Is there any way of setting up regex-matching redirects within Drupal? I could always do it in .htaccess, but that would get overwritten on the next Drupal core update. Further, it seems that Boost is nerfing any redirect I put in .htaccess -- the above hasn't worked since I installed its redirect rules.

Thanks!


texts: I want to use CKEditor to edit page contents in my Drupal web site. The problem is after installing the newest version of CKEditor toolbar is not showing when I want to edit certain Block body. Is this a bug or editor itself requires more configuring ?


texts: How can I display an entire page at a specific path/url in a block?

texts:
I am using the HomeBox Module which outputs a page with a "Dashboard" like functionality. However I would like to be able to take this functionality from the page and turn it into a block, so that I could then add this functionality to any node/content type I would need.

What I have tried:

Nodes In Block, Node Blocks, Node As Block modules - these modules would do the trick if the page outputted by HomeBox was actually a proper node. In actual fact it cannot be edited as a node and so the additional options the above modules provide are not available in the page edit form.

Views module - when creating a View, I have tried filtering only by the url/path to show everything from the particular HomeBox page url. However this doesn't seem to be possible in Views. Since the page can't be tagged with taxonomy, isn't a content type, and (as far as I know) doesn't have a node id; by specifying the url and showing the page inside a View I could then make a block display and be done. But there doesn't seem to be general path/url filter in Views.

Does anyone have any suggestions as to what else I should try?


texts: How to set multiple error messages with form_set_error?

texts:
I notice I can pass in a message variable to form_set_error().

How can I pass in multiple messages?

I tried calling form_set_error() several times, but always the first one is displayed.

So, to sum up I want to show something like this:

error 1
error 2
error 3

Currently, I can only get:

error 1

Then, once the users correct it, and resubmit it, they get:

error 2

if (strpos($form_state["values"]["body"], "

if (strpos($form_state["values"]["body"], "

If both of these control statements trigger an error, only the first one is shown.
After the user corrects the error, the second error message is shown.


texts:
I need a way to get the output of a view as a REST service in JSON format.

I read about the RestfulWS and the Services modules, but I didn't find enough documentation.
Are these straight forward, or should I just go with a custom module?


texts:
I have a content type called SimpleNewsletter which has an Entity Reference field called field_newsletter_content. Multiple articles are linked with one SimpleNewsletter node.   Under Manage Display of SimpleNewsletter, I can manage which fields to display.

But I have a situation where I only need to display certain fields not all the fields (ex: "Node Title")

In order to theme field_newsletter_content field I have created a new file called field--field_newsletter_content.tpl.php

Is it possible only to display certain fields?


texts: Filename for the front page template file

texts:
How do I create a theme for the front page only?
I only want to change what is in the content area but leave the rest of the stuff the same from page.tpl.php.


texts:
I have an app that has a front end in tons of custom AJAX and fancy JS controls.

These controls all pull from URL which return JSON in a specific format.

I would like to remove all the selection code from the existing system and integrate with drupal:

Can views be linked to tables which are not directly managed by Drupal?
Can Views have their output overridden to support JSON instead of HTML?

I have googled and found a few projects but none seem to be very active -- I am using D7 maybe D8 for this project :)

Any pointers, hook suggestions, etc?


texts: Views does not show content if any of fields from relationship are empty

texts:
I have a view which displays fields from a content type but it also has a relationship to any entities which have a reference field to a node of this content type.

I have things like a title and body text plus some custom text fields on the view, the title and body are from the node.

However these do not display unless the referenced fields are not empty.

How can I get the view to display these fields still when the entity fields are empty?


texts: add users to og group via vbo doesn't work: record is deleted immediately

texts:
I like to add users to an OG group using vbo, a custom action and og_group().

I build up a page with a view of users to add (/node/%nid/add_user).

On this view I added a views bulk operations field with the "skip batch" option. (I skipped the batch to get the current %nid from the url).

In the custom code I like to add the selected user to the page shown. I know I can do this also with the standard group forms, but I want to do it this way :-)

So here is my code to subscribe the user to the group:

function mymodule_vbo_actions_users_woform(&$user_node, $context) {
  global $user;
  //dpm($node); dpm($context);return;
  switch ($context['settings']['action_type']) {
    case 'add_user_to_group':
      $nid_page = menu_get_object();
      if (!isset($nid_page)) $nid_page = arg(1);
      $nid_page = $context['page_nid'];
      $account = user_load($user_node->uid);
      //dpm($nid_page);
      $node_page = node_load($nid_page);
      dpm($user_node);
      dpm($account);
      dpm($node_page);

      $aValues = array('entity_type'=>'user','entity'=>$account,'membership type' => 'OG_MEMBERSHIP_TYPE_DEFAULT',);
      $og_membership = og_group('node',$node_page->nid,$aValues,FALSE);
      $og_membership->save();
      dpm($og_membership);

      // get member roles id for selected group bundle
      $result_roles = db_query("SELECT rid FROM og_role o where group_bundle = :bundle and name=:name and gid=:gid;",array(':bundle'=>$node_page->type,':name'=>'bidder', ':gid'=>$node_page->nid));
      $role_id = NULL;
      foreach ($result_roles as $key_roles => $value_roles) {
        $role_id = $value_roles->rid;
        break;
      }
      dpm($role_id);
      og_role_grant('node',$node_page->nid,$account->uid,$role_id);
      break;
  }
}

This code seems to be correct. I watched the og_membership table and the record for the selected user is inserted, but then DELETED immediately!?

So the question is of course: Why is the record deleted?


texts: Exposed filters submit with AJAX not working - regular submit instead

texts:
I created and customized exposed forms. When I change some values I change exposed filters widgets accordingly. Then I call submit with JavaScript, but my form is send with regular submit not like I checked on Views Advanced Settings form to use AJAX. What could be wrong with that? Pagination also change current URL.

-- edit --
When I click on item connected with exposed filter I execute this code:

$('#category-product-finder .frame a').each(function() {
    var $a = $(this);
    var $exposed_filter = $('#views-exposed-form-product-finder-page');
    $a.click(function(e) {
        e.preventDefault();
        $exposed_filter.find('#edit-product-category').val($a.attr('rel'));
        $('#views-exposed-form-product-finder-page').trigger('submit');
    });
});

And this make my form to submit without using AJAX.


texts: How to attach files to node instead of uploading?

texts:
I have 2 content types, Files and Events. Files content type is used to upload files like Image, PDF, Doc etc.

Events content type has a field to attach a document which is uploaded by files content type. The requirement, in event content type I need a field called 'attach files' with maximum five attachment. On click of 'attach files' button, needs to open a page which lists all files uploaded by files content type. On hover of any files an attach button will appear and while clicking it will get attached to the event newly creating event node.


texts: How to alter the result of my view using filters?

texts:
I have a view with 2 exposed filter.. I only want to change the result of my view when filters are used, ie if they have any value and press the button to run the filters.

I try to used the hook_views_pre_render, but doesn't work...

function node_db_views_pre_render(&$view) {
   if($view->name=="demo" && $view->current_display == 'page_1' &&  $view->exposed_input['date_filter'] != NULL) {
       $get_date = $view->exposed_input['date_filter'];
       $min = $get_date['min']['value'];
       $max = $get_date['max']['value'];

         $query_power = "SELECT h.id, h.name, count(c.room_id) as busy
                         FROM table_1 c JOIN table_2 h ON c.id = h.id
                         WHERE '%s' < c.in_date OR '%s' > c.in_date
                         AND '%s' < c.out_date OR '%s' > c.out_date";

         $result = db_query($query_power, $min, $min, $max, $max);

       $items = get_rows($result); // this is a function gets the data from the sentence and makes a array.

       $view->result = $items;
   }
}

Exist other hook that can help me?..Thanks :D


texts: How to remove unwanted div from view rendered block?

texts:
In D8 I've created a view and assigned it into a block,

I've created corresponding template for both view and block.
Most of the unwanted addition of div's and classes has been removed.

But the following empty div is still there in the rendered HTML

<div class="js-view-dom-id-e0cc1fe812f18c9b5d6660b04594c41b597ae5ee9b28cf43f718dc43b43a2f42">

Anyone experienced the same issue?


texts:
Are there any hooks to alter the Services modules output.
For eg : If I get a result like this for a file object.

{
  "fid": "132",
  "uri": "public:\/\/512dab4918036.jpg",
  "filename": "512dab4918036.jpg",
  "filemime": "image\/jpeg",
  "uid": "1",
  "status": 1,
  "timestamp": 1361947464,
  "filesize": 2521,
}

I want to limit it for users with certain roles.

I am looking for this as I have made many services resource manually so I don't want to edit them all and simply use the output alter hook to do something.

Is it possible ?


texts: Is it stable to run Drupal 7.8 on php 5.3.8?

texts:
I would like to make use of php 5.3.x built-in fastcgi functionality and therefore I would like to migrate from php 5.2.x to php 5.3.8.

Is it stable to run Drupal 7.8 on php 5.3.8 ?


texts: What MySQL privileges would a read-only drupal db user need

texts:
I am in the process of configuring a server that will be on the front end and will be the read-only installation.  Can anyone give me some guidance on what to look for for in regards to what tables the mysql user will need write access for... such as like access log, etc.

I am just looking for a starting point. It doesn't need to be specific.


texts: Drupal 7 - Retain checkbox values across pages

texts: In Drupal 7, I am using tableselect theme with PagerSelect to generate table with checkboxes and pagination. Any thoughts on how to retain checkbox values on pagination?


texts: How to show Search API search box? No block available, nothing from

texts:
I'm updating a site to use Search API (with Search API DB) instead of the built-in search module. I've set up my Search API server and search, indexed everything, and now am just trying to replace the old search box with the new one in the theme.

But I can't find any way to do this.

Before disabling the built in search module, there was only one search block. After disabling, there are none, including after clearing caches. According to Integrate core search block with search_api and Solr and various other sources, I should get a search block automatically, but I don't.

Before, I got the search box into my template .tpl file with <?php print render($search_box); ?>. After, this throws an error.

I can't find anything on what to use instead, and the relevant documentation page about search forms talks only about search results pages, not about how to put a search box on other pages. I'm confused at how hard it is to find how to do something so basic. I can't find anything about how to find the code to either populate this variable in template.php or access any inbuilt template variable.

How do I show a basic search block on the front page that integrates with search api? is similar but the asker reports its answer doesn't work, and I'm not fussy about whether it's specifically a block or specifically on the front page or connected to a view, I just want the search input element.

How do I add a Search API search box to a theme? How do I make it generate the block or load the search box from code?


texts:
I am looking at the ability to management off and online video content.
I need to be able to add media using text filters and to search for media within the cms.
What is a good module for a modal style background when playing video?
I need to arrange videos into playlists by artists and create gallerys.

On my research I have come up with the following:

Media
Searching Media
http://drupal.org/project/apachesolr_media
http://drupal.org/project/apachesolr
http://drupal.org/project/apachesolr_file

http://drupal.org/project/media (for managing media)
http://drupal.org/project/media_gallery (for managing galleries of images and videos) http://drupal.org/project/mediaelement (for local files) http://drupal.org/project/multiform

More info:http://www.slideshare.net/G_N/drupal-7-media-modules

If you can give me any more information that would be great.


texts:
I'm trying to change the label and field instructions for the name field on the User Account Creation form. I'm new to coding, and thought this would be an easy task.

My custom module is enabled and I've cleared caches, but none of my changes show up. Here is my code. I've tried a bunch of variations and a bunch of searching, but I never see a single sign of this working.

<?php

/**
 * @file
 * Contains mymodule.module.
 */

use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_FORM_ID_alter() on behalf of mymodule.module.
 * @see \Array method Array at Array
 */
function mymodule_form_account_alter(&$form, FormStateInterface $form_state, $form_id) {
  // print_r($form); die;
  // ksm($form_id);
  if ($form_id == 'user_register_form') {
    // print_r($form); die;
    // kint($form_id);
    $form['name'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('First and last name'),
      '#maxlength' => USERNAME_MAX_LENGTH,
      '#description' => $this->t("Rewrite this about spaces, periods (.), hyphens (-) and apostrophes (')."),
    );
  }
  drupal_set_message('mymodule_form_account_alter() executed.');
}


texts: How to hide certain fields on the User Edit form?

texts:
So I have three types of users - admin, LA admin and users.
I am trying to set it up so that admins and LA admins cannot edit the username, password and timezone for users. I am talking about the default user edit form for admins and the form ID is "user-profile-form".

I have created a custom module but this doesn't seem to be working. Any idea what I might be doing wrong?

Even the var_dump does not seem to be outputting. I have cleared the cache and verified that the module is enabled.

function profile_change_form_alter(&$form, $form_state, $form_id) {
    if ($form_id === 'user-profile-form') {
    // Use var_dump  to dump the $form array to see the fields.
        var_dump ($form);

        hide($form['account']['pass']);
        hide($form['account']['current_pass_required_values']);
        hide($form['account']['current_pass']);
    }
}


texts: How to disable CACHE in FORM which loads database values in form fields

texts:
I am loading database values in my FORM and seems form is CACHING and loading old data from the database.

I have followed instruction here (How do I prevent a form from being cached for Anonymous users in D8?) but still old data is loaded in form fields.

Here is my code and would appreciate if anyone can shed light where I am missing;

....

/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {

// Define form fields.
$form['#cache']['max-age'] = 0;

$form['name'] = array(
  '#type' => 'textfield',
  '#size' => 80,
  '#title' => t('Your Name'),
  '#default_value' => $result->name,
);

return $form;
}

....

Do I have to add 'use Drupal\Core\Cache;' on top of this file?

Thanks a lot.


texts: How to dynamically set the maximum cardinality for a multi value field?

texts:
I am using a multi value image field which is set to hold 5 values. What I need, is to be able to set a lower cardinality for this field on specific nodes of the same content type.

Edit: Below is what I ended up using, it might help someone.

/**
 * Implements hook_field_attach_form().
 */
function example_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
  // Our field name
  $field_name = 'field_listing_images';

  // You may want to add more conditions
  if (isset($form[$field_name][LANGUAGE_NONE])) {

    // Our custom cardinality (hardcoded here)
    $custom_cardinality = 3;

    // Unset all field multi values that are equal or larger than our $custom_cardinality variable
    foreach ($form[$field_name][LANGUAGE_NONE] as $k => $value) {
      if ($k >= $custom_cardinality) {
        unset($form[$field_name][LANGUAGE_NONE][$k]);
      }
    }

    // Our custom form validation
    $form['#validate'][] = 'example_custom_form_validate';
  }
}
/**
 * Our custom form validation callback.
 */
function example_custom_form_validate($form, &$form_state) {
  // Our field name
  $field_name = 'field_listing_images';

  // You may want to add more conditions
  if (isset($form_state['values'][$field_name][LANGUAGE_NONE])) {

    // Our custom cardinality (hardcoded here)
    $custom_cardinality = 3;

    // Unset all field multi values that are equal or larger than our $custom_cardinality variable
    foreach ($form_state['values'][$field_name][LANGUAGE_NONE] as $k => $value) {
      if ($k >= $custom_cardinality) {
        unset($form_state['values'][$field_name][LANGUAGE_NONE][$k]);
      }
    }
  }
}


texts: Custom function doesn't get triggered by hook_cron()

texts:
I have set up some FeedImporters and I've linked some custom batch imports to these FeedImporters. But for some reason, the function isn't triggered when running the cron... I'm wondering why. Anyone who can help me out on this one?

I've linked some custom functions to be triggered after the import:

/*
 *  Initialize hook_feeds_after_import()
 */
function my_module_feeds_after_import(FeedsSource $source) {
    _my_custom_function();
}

function _my_custom_function() {
    // Define fields
    $fields  = array('field1', 'field2', 'field3');

    // Trigger Batch for import
    batch_set(_start_my_batch('myfile', 'mytable', $fields));
}

And then my custom batch import:

function _start_my_batch($file, $table, $fields) {
    $batch = array(
      'operations'        => array(
        array('_import_csv_to_database_batch', array($file, $table, $fields)),
      ),
      'finished'          => '_import_csv_to_database_finish',
      'title'             => t("Import data in the $table-table"),
      'init_message'      => t("Feed is starting ($table)."),
      'progress_message'  => t('Processed @current out of @total.'),
      'error_message'     => t('Feed has encountered an error.'),
      'file'              => drupal_get_path('module', 'batch_example') . '/batch_example.inc',
    );

    batch_set($batch);
}

the _import_csv_to_database_batch is a custom batch import by the book. But for some reason, when I run following cron function, the _my_custom_function() isn't even triggered...

function my_module_cron() {
    _my_custom_function();
    watchdog('my_module', 'feed cron');
}

So why is that and how can I configure my cron to trigger this?


texts: Should I enable a feature I created on the same site?

texts:
I created a view and some configurations and used features to save it into code. When doing so, I used the GUI interface and selected Advanced Features and named a file path (sites/all/modules/custom) and then clicked "generate". In doing so, the code was saved to that file path. It is now listed in the website under features > custom but it is listed as disabled.

What is the best practice for this scenario: should I enable it or keep it disabled since I clearly would like it to be active and part of the code? Thanks!


texts: Using db_select, how can I select all nodes with any of an array of taxonomy terms and order by the number of terms it is associated with?

texts:
I have this so far:

// for example, $tags = array(2, 8, 18);
$query = db_select('node', 'n')
  ->fields('n', array('nid'))
  ->condition('n.type', 'post')
  ->condition('n.status', 1);
$query->join('field_data_field_tags', 'tags', 'tags.entity_id = n.nid');
$query->condition('tags.field_tags_tid', $tags, 'IN');

I need to order these results by the number of "tags" associated with each node.

I've tried many things, using addExpression() with count() statements, then an orderBy(), etc, but I can't get it right.  Any help would be greatly appreciated!


texts:
I need to inject a service inside a block. Since I need some logic before displaying the block, it feels dirty to do it inside the block itself, not to mention it's not actually related to the block itself.

Normally I'd inject a service by using the create() method available in the controller, but blocks don't seem to have this method.

How do I use a service from a block?


texts:
My Drupal 7 installation works fine, except for drush, which does not.

  $ cd /srv/www/drupal_site

  $ drush pm-refresh

  PHP Fatal error:  Call to undefined function user_load() in
  /usr/share/php/drush/includes/drupal.inc on line 138

  Drush command terminated abnormally due to an unrecoverable error.

  Error: Call to undefined function user_load() in
  /usr/share/php/drush/includes/drupal.inc, line 138

  Drush was not able to start (bootstrap) Drupal.

This is Drupal 7.24 and drush 5.10.0 from Debian. A couple of modules and themes have been installed from drupal.org but IMHO nothing fancy. Curent versions of drush6 or drush7 refer to a missing drupal_get_profile() function but otherwise don't help.

Any ideas what the cause of this problem is, and/or how to debug this?

EDIT: It works fine, except for these spurious error lines displayed on the web page (even though I do not use any sort of debug mode), as reported by a user:

  Notice: Undefined index: post-load integration files in libraries_load_files() (line 697 of /var/www/drupal7/modules/libraries/libraries.module).

This may or may not be related to my problem.

I tried using Drush 6.x/7.x, but it just returns a different error message.

  Call to undefined function drupal_get_profile() in /usr/share/php/drush/includes/bootstrap.inc on line 963

drush cc hits an error before it can do anything; the same happens with drush rr, which returns a different error, but equally intractable.

php-apc is not installed; I have Memcached, but killing it didn't change anything.
I did not change any module weights.


texts: "\Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container."

texts:
I am attempting to write a PHPUnit test for a service of mine.

My test looks like the following.

class CustomServiceTest extends UnitTestCase {

  public function testDefaultBehavior() {
    $service = new CustomService(\Drupal::service('custom_utils.some_resolver'), \Drupal::configFactory());
    $service->execute();
  }
}

However, it raises the following exception.

Drupal\Core\DependencyInjection\ContainerNotInitializedException:
\Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.

What am I doing wrong?


texts:
I am using drupal 7, when I am going to path of  terms I see only white page, no error and nothing in another page I have not this problem,
 some php properties are :

error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_WARNING
max_execution_time = 360
max_input_time = 120
memory_limit = 32M
upload_max_filesize = 32M
post_max_size = 32M
mbstring.func_overload = 2
mbstring.internal_encoding = UTF-8

where is the problem? and how can I solve it?


texts:
I'm using the following to get the raw value of a field Drupal:

$foo = field_get_items('node', $node, 'field_foo');
$foo_shift = array_shift($foo);
$foo_value = $foo_shift['value'];

Which works a treat but every so often I get the following error:

Warning: array_shift() expects parameter 1 to be array, boolean given in include() (line 106 of ).

I think it might have somehting to do with checking the value is set as I only get it after going to a page where the value isn't set. But if I try to check 'field_get_items('node', $node, 'field_foo')' is set that doesn't work.


texts: Queue doesn't enter on worker function with Elysia cron

texts:
I'm trying to use queue api with cron, everything seems work but drupal does not enter on the "worker" function.
The problem there is only if I enable Elysia Cron (and I've to enable it..)

<?php

/**
 * Implements hook_cron_queue_info().
 */
function monitor_import_cron_queue_info() {
  $queue['monitor_import_queue'] = array(
    'worker callback' => 'monitor_import_queue_worker',
    'time' => 10,
  );
  return $queue;
}

/**
 * Implements hook_cron().
 */
function monitor_import_cron() {

  $call = new MyWS();
  $params = new getSoggettoView();
  $params->limit = '10'; //$limit;
  $params->offset = '0';
  $results = $call->getSoggettoView($params);
  $items = $results->return;
  $queue = DrupalQueue::get('monitor_import_queue'); // grab queue
  $queue->createQueue(); // initialize
  foreach ($items as $item) {
    $queue->createItem($item);
  }
}

/**
 * Worker callback
 *
 * @see mymodule_cron_queue_info().
 */
function monitor_import_queue_worker($item) {
  $a = 1;
}


texts: How to do social links with icons as a link field in a block?

texts:
I have a footer that contains a simple contact information and underneath is a social follow set of links.

I created the block type, with the thought that the top part (Connect) is a WYSIWYG.

My second thought was to make the Follow Us just a link field with 5 values, but I want to add a little flexibility and for theming concerns, I need to know what link goes with which service.

Can I either do this with the link field, or can I reference a menu somehow and attach it to this block type? As a menu, I can rig up menu attributes. But if there is a more practical way, I would like to know how to do it.

I do not want to hard code it because they might change URLs or want to reorder the list of services at any time.


texts: How to show a field value instead of the node title for nodes displayed through an entity reference field?

texts:
Edit: I think I found the place, just not the method yet. If correct, I will close this question. Sorry.

I have no clue which hook or direction to look into. I would like to have a label or title preprocess function, but that doesnt exist I think.

Its only for a specific content type that I need to show a field's value as title for the referenced nodes.

So it's not about the entity reference widget when editing nodes but rather the title display wherever that reference field is rendering the nodes' titles.


texts: How to programmatically set node field values.

texts: I have a content type.  I have firstname, lastname and email address fields.  I need the default value for each field to be the firstname, lastname and email address of the user profile.  Also, I need to prevent the user from modifying these values. The user should be able to see the values by default, but the user shouldn't be able to edit them.


texts: how to resize image programatically with theme image

texts:
i need to resize image in my module output, but this code seems not working

$file = file_load($fid);
$image = theme('image', array('style_name'=> 'small', 'path' => $file->uri, 'alt' => 'user picture'));

i am getting my image from database. i have created media type small to scale my image,
but style_name does not work.


texts: Please help for the moment no way to include chemistry in Mathjax

texts:
I'm using the Mathjax Module on drupal 7. All working pretty good but when i'm trying to add the chemistry js, it was not the same !! I tried to enable it without success. I have read a lot of documentation, i forget where but i read : if you use "\ce", mhchem will be loaded automaticly.

Apparently it's not the case :

My custom configuration :

MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ['\\(','\\)'] ],
processEscapes: true
},
showProcessingMessages: false,
messageStyle: 'none'
});

Tring to change

extensions: ["tex2jax.js"],

to

extensions: ["tex2jax.js","mhchem.js"],

without success and a lot of other test.

No way to force the js to be loaded. May be there is a trick ?

thanks for helping


texts: What meaning do the primary / secondary menu links have when it comes to SEO?

texts:
Is there some meaningful difference between the primary / secondary links when it comes to SEO? Do they carry a different weight from a search engines perspective?

Thank you!


texts: Use createFilter to build an advanced query using AND and OR with the search API

texts:
I have a search index of about 15 fields (profile2 fields) build with the search API indexer (mysql) and I need to build an advanced query. All fields are fulltext. The query input form would have about 6 fields:

name, postal code, zip, city, keywords

The complete sql query (pseudo code), conditionally based on what the user entered in the form fields, would look like this

SELECT
  *
FROM
  {index}
WHERE
  (field_last_name = 'name' OR field_first_name = 'name')
AND
  field_postal_code = 'zip'
AND
  field_city = 'city'
AND
  (field_interests = 'keywords' OR field_hobbies = 'keywords' OR ...)
ORDER BY ...

Is this possible at all to build a filter like this?

I try to find a way to build an advanced search and I first tried Views using the filter criteria but I can not build an exposed form like I want. Also as a next step I need to integrate a proximity search on the postal code field. After some reading and hours of using google I thought the search API would give me a go to get a solution on that problem.

To completely understand my problem please refer to this question I asked yesterday: Views 3 Custom filter for Profile2 data

I would really appreciate some hints if I am on the right track or if I have to code a completely distinct module to build that kind of search engine.

Thanks to you all for your help!


texts:
I'm new to Drupal and have a basic question which I cannot find a good answer to. I have already posted this at Stack Overflow but still am hopeless. I am trying to dynamicly determine the contents of my website based on a selection made by the user and keep the selection displayed in the routing for SEO purposes.

In other words I want to a path prefix which I can use as a variable to display nodes specifically for that franchise. My content types have multiple CCK references to content types Franchise and I want to base my selection on the location inside my content type franchise.

It's a website for a Restaurant with multiple franchises.

What i'm trying to do is the following:

The user visits my website and gets a splash screen presented with the available franchises or a textbox to enter his postalcode
Upon selecting he enters the main website with the navigational structure adapted to that particular franchise only. The selected Franchise city should remain inside of the url structure. Nodes should not be made available without the city inside of the url. For example: domain.com/city/, domain.com/city/menu, domain.com/city/menu/dishes, domain.com/city/contact, ...
The contents of all nodes are based upon the city the user selected. Some franchises have extra nodes which should be displayed in the main navigation aswell. The contents of the views and panels should automaticly be adjusted to that particular Franchise aswell.
Users can change the selected franchise by clicking on a main link which links back to the splash page.

What I have found so far which might be part of the solution is:

Purl
Context
Spaces

Parts of the nodes will be the same for all franchises other parts will be different. Menu item prices will also be different.

This is the first website i'm building using Drupal so any advice is welcome.

Thanks!


texts: Custom theme doesn't show up in Blocks section

texts:
I've looked through different threads about this issue and didn't see any answers. I have a fresh install of Drupal 7 with no extra modules enabled. I've started building a custom theme but it doesn't list itself in the blocks section even though it's enabled. It shows the original bartik theme and the admin seven theme. The odd part is I added a new block under Header which I have listed in my .info page and it showed up in my theme but I can't edit the block because the it only gives access to those two themes and not mine. How can I fix this?

I also have all of these error messages in the admin and I've barely added anything to my theme. Not sure what I'm missing.

  Notice: Undefined index: name in block_menu() (line 146 of /home/infanity/public_html/beta/modules/block/block.module).
  Notice: Undefined index: name in block_menu() (line 165 of /home/infanity/public_html/beta/modules/block/block.module).
  Notice: Undefined index: name in system_menu() (line 647 of /home/infanity/public_html/beta/modules/system/system.module).
  Notice: Undefined index: name in _ctools_list_themes() (line 574 of /home/infanity/public_html/beta/sites/all/modules/ctools/includes/plugins.inc).
  Notice: Undefined index: name in block_menu() (line 146 of /home/infanity/public_html/beta/modules/block/block.module).
  Notice: Undefined index: name in block_menu() (line 165 of /home/infanity/public_html/beta/modules/block/block.module).
  Notice: Undefined index: name in system_menu() (line 647 of /home/infanity/public_html/beta/modules/system/system.module).
  Notice: Undefined index: name in _ctools_list_themes() (line 574 of /home/infanity/public_html/beta/sites/all/modules/ctools/includes/plugins.inc).
  Notice: Undefined index: name in system_sort_modules_by_info_name() (line 944 of /home/infanity/public_html/beta/modules/system/system.admin.inc).
  Notice: Undefined index: name in system_sort_modules_by_info_name() (line 944 of /home/infanity/public_html/beta/modules/system/system.admin.inc).
  Warning: uasort() [function.uasort]: Array was modified by the user comparison function in system_themes_page() (line 139 of /home/infanity/public_html/beta/modules/system/system.admin.inc).
  Notice: Undefined index: name in system_themes_page() (line 148 of /home/infanity/public_html/beta/modules/system/system.admin.inc).
  Notice: Undefined index: name in system_themes_page() (line 190 of /home/infanity/public_html/beta/modules/system/system.admin.inc).
  Notice: Undefined index: name in theme_system_themes_page() (line 2728 of /home/infanity/public_html/beta/modules/system/system.admin.inc).

I've stripped my theme to just the .info file which the manual says is all that's required and I still get errors and although enabled still doesn't show up as the default theme in the block section. Here is my .info file labled fod.info in a folder labeled fod in the sites/all/themes folder.

name = fod
core = 7.x

stylesheets[all][] = css/style.css
regions[header] = Header
regions[highlighted] = Highlighted
regions[help] = Help
regions[content] = Content
regions[navigation] = Navigation
regions[sidebar_first] = Left sidebar
regions[sidebar_second] = Right sidebar
regions[footer] = Footer

And here are the errors I'm still getting in the admin.

  Notice: Undefined index: name in block_help() (line 69 of /home/infanity/public_html/betaD/modules/block/block.module).
  Notice: Undefined index: name in block_menu() (line 146 of /home/infanity/public_html/betaD/modules/block/block.module).
  Notice: Undefined index: name in block_menu() (line 165 of /home/infanity/public_html/betaD/modules/block/block.module).
  Notice: Undefined index: name in system_menu() (line 647 of /home/infanity/public_html/betaD/modules/system/system.module).


texts: How to use tokens in data selectors in Rules and how to get autocomplete to work?

texts:
In Drupal 7, the Rules module was quite simple to use. You create a rule, define it's action and done. In Drupal 8 version of Rules however, i.e the alfa1 version (which is what I'm using), I see some weird behavior.

I am not able to use tokens in data selectors (also autocomplete won't work).

What I want to accomplish:
I have two roles: admin and non-admin.

When a user assigned with the role as admin log in, he should be redirected to his dashboard (url: /admin/dashboard)
When a user assigned with the role of non-admin, he should be redirected to his particular page (url: /non-admin/dashboard)

There are 2 Rules Conditions related to User Roles:

one is under "Others" tab (= User Role).
one is under "User" tab (= User has role(s)).

Both are shown in the image below:

When I choose the 2nd one, I always get an php error (issue already posted on Rules on that).

When I choose the 1st one, no matter what I pass in the Rules Condition, it always returns true and performs the Rules Action.

Am I missing something?


texts: How to edit the Comment Administration Page

texts:
I've already edited my comment and comment-wrapper.tpl.php files for public consumption. But I'm finding I'd like to edit the administration page where our staff administers comments that are pending approval. Is it possible to wrap that page in a  tag or something so I can apply styles?

I'm talking about the pages at http://mysite/comment/1#comment-1 (for example, and so forth)...


texts:
I have two websites.
On website 1 I have a calendar showing upcoming events. Next to a regular views page I also created a views rest export page with 6, of the most near in the future, upcoming events.
On website 2 I created a rest import function with JavaScript. Getting the 6 events and showing them in a block.
Now my problem is that, when a day is passed and an event has taken place, the event is not removed from the block in website 2. I'm not caching anything on website 2 and it is just importing the rest export every time the page loads. And I turned the cache of the view on website 1 off.
It looks like the problem is with website 1 (because emptying the cache on website 1 fixes the problem on website 2 for some reason it is not updating the rest export when an event has passed.
The updating of the rest export on website 1 should take place because the filter of the view is set to only show the upcoming events.
I find it hard to explain what the problem really is hopefully my explanation makes sense (at least a little bit).
So what I'm wondering if this is a normal behavior? Did I miss a setting?


texts:
How do I get a list of all the content types defined in a Drupal 8 site?

In Drupal 7 it used to be node_type_get_types(), but it has been deprecated.

I tried Entity::loadMultiple() but it doesn't seem to work. I was thinking about making a custom query, but I don't know how it's stored in the database.


texts:
I'm noobing my way through countless websites trying to find an answer to accessing a value in a Commerce field array.

I somehow managed to throw together the following code to retrieve a value for a workflow rule I'm writing:

$product_id = $current_line_item->commerce_product;

The result is: array(1) { ["und"]=> array(1) { [0]=> array(1) { ["product_id"]=> string(2) "14" } } }

I can't figure out how to get any deeper into the array than that. I need to return the product_id value in this array.

Can anyone guide me on the best way to do this?


texts: How do I append a country to a views exposed filter field geofield proximity?

texts:
Using Geofield with Google's API, when a user enters "Vancouver", it assumes I mean "Vancouver, Washington", when I actually want "Vancouver, BC". Is there any way to append "Canada" to the location info submitted to google?

It would be nice if I could do this with some override but will accept a hack to the module and I will just keep track of the modified module.

Here is a link to Geofeild's code that covers this. http://pastebin.com/Diwj5deE

Note: That I just need the country appended to the info sent to google. I don't want the filter to have a default of "Canada" and it can't prefilter the view with "Canada". It is not until the user actually uses the exposed
filter.


texts: How to add a preview image to a content type?

texts: Is there a functionality in Drupal to add a preview image to a content type (for example in the info file). The idea is, that an editor who doesn't know which content type to choose for his content would see a 'preview image' in addition to the description text and then know what content type he would need to use. I can't find anything like this in the system and no module which would provide this functionality.


texts: Obtain CKEditor text field value with jQuery

texts:
Using a node--add .tpl.php file I can implement a jQuery javascript call such as

var fieldTitle = $('#edit-title');
function titleChange() {window.alert(fieldTitle.val());}
fieldTitle.change( titleChange );

which creates an alert each time the title value is changed.
As such, I know that I can obtain the form values from the edit form from where my script is being placed; however, I am unable to obtain the value from the text field which used CKEditor.

By using the #id for the text field, I can use .change() and have interactions occur as users type into the field. However, I'm unable to obtain the actual value from the text field. I've tried every ID of every tag  nested in the field's div and used console.log() to output the field instance, the .val(), and even .html() with no success in even finding the value of the text typed into the ckeditor text area.

The only information on the internet that I was able to find appears to involve obtaining the value from ckeditor using CKEDITOR.instances however the console log error that occurs for any script involving this is "CKEDITOR" is not defined.

Does anyone know how to obtain a value from the CKEditor text area in Drupal using jQuery?


texts: Page title block hidden on custom route, panel or view pages when content type is chosen in block visibility settings

texts:
I defined a custom route in a custom module:

mymodule.overviewpage:
  path: '/mymodule-overview'
  defaults:
    _controller: '\Drupal\mymodule\Controller\PageOverviewController::content'
    _title: 'Overview'
  requirements:
    _permission: 'access content'

Here is the controller:

class PageOverviewController  extends ControllerBase {
  public function content() {
    return array(
      '#markup' => 'hello'
    );
  }

}

This route is working fine, I see the "hello" text when entering this path in my project but I do not see the page title. The page title "Overview" is used in the title tag in head of the HTML page but there is no page title block - it is not even rendered. Changing to Bartik theme I see the page title "Overview".

I know found out that the visibility of this block was set: there was a checkbox checked which defined the block to be hidden when on a node page of a special content type/ node bundle:

My question: why is the page title block not visible on panel or view generated pages or on custom routes? What should I add to avoid such a behavior? Is there a way to hide the block for special contenty types without hiding it elsewhere?


texts: Display child count after each page in book navigation

texts:
I'm building a hierarchical site. and I'm using the Book module. The desired output for each listed node in the book navigation is "Page 1 (node count) (last comment date)."

The question was asked on Drupal.org back in 2006, and it got no answer. My client has strict requirements to display custom data beside each node (e.g. number of comments, date of most recent comment). If I can start with the node count, I'm one step closer.

Vocabulary Index includes node count but this is based on taxonomy.


texts: WYSIWYG do not make url when pasted in a hyperlink

texts:
When I paste a URL into a TinyMCE editor using WYWIWYG it converts the text into a  link.

So http://vimeo.com/18150336 would be come http://vimeo.com/18150336. I would like to keep the plain text. Is their a way to configure TinyMCE to keep the link as plain text.

I do not want to strip out  tags as adding a hyperlinks should be an option on the toolbar. It should just not happen by default.


texts: Use code to automatically fill the form of a content type

texts:
I have a content type called Event. I advertise events on my website using this form.
I want to advertise automatically using code.
I have this code which when I run automatically add content. But at the moment it adds the title and the body.

ini_set('display_errors','1');
ini_set('memory_limit', '512M');
define('DRUPAL_ROOT', getcwd());
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
module_load_include('inc', 'node', 'node.pages');
$node = new stdClass();
//print_r($node);
$title          =  "test post 3";// html_entity_decode($_POST['title']);
// $summary     =   "summarry";//$_POST['summary'];
$body           =  "This is testing of Automated Script";// $_POST['body'];
$node->uid      = '0'; //author
$node->type     = 'event';    //content type
// $node->created  = time() - (rand( 1,240) * 60);
$node->created  = strtotime("now");
$node->changed  = strtotime("now");
$node->field_location = 'Oxford';
$node->title    = $title;
$node->status   = 0;
$node->promote  = 0;
$node->sticky   = 0;
$node->language = 'und';
$node->body['und'][0]['value']   = $body;
// $node->body['und'][0]['summary'] = $summary;
$node->body['format']  = 'full_html';
node_submit($node);
node_save($node);
print "ok";

How do I add remaining inputs like City, Country, Event Date, Duration, Email Address using code?


texts:
I'm using Features to create a feature called foo which tracks content types and views so they can be described in code, committed to my repository and eventually pushed into the staging and production servers.

Some modules (e.g http://drupal.org/project/nodequeue, http://drupal.org/project/views_bulk_operations, http://drupal.org/project/admin_views) create some views as part of their functionality. The problem is that I can't include those views into my foo feature. So for those specific views I have to repeat (by hand) any customization I did locally to the staging and production servers.

Any ideas?

What I've tried:

1) I tried manually adding the view name in the foo_features.info file:

features[views_view][] = admin_content_node

but when I do drush fu foo_features -y that line is removed and the .info file and the view definition is not being included in the foo_features.views_default.inc file.

2) I had a look into the database:

mysql> select vid, id, display_title, display_plugin, position from views_display;
+-----+----------+---------------+----------------+----------+
| vid | id       | display_title | display_plugin | position |
+-----+----------+---------------+----------------+----------+
|   3 | default  | Master        | default        |        1 |
|   3 | page     | Page          | page           |        2 |
|  30 | block    | Block         | block          |        2 |
...
|  46 | default  | Defaults      | default        |        1 |
|  46 | system_1 | System        | system         |        2 |
+-----+----------+---------------+----------------+----------+

That last row (vid: 46, display_plugin: system) seemed suspicious so I've changed (directly via SQL) system to page. I then did drush cc all and retried the process at [1] for including the view into the feature but without luck. I tried this because I thought that "system view displays" (whatever that means) cannot be included in features.


texts: Administer Users permission too vague. How can I restrict functionality for this permission?

texts:
Is there a way to allow some admin users (with administer role) to create other users but limit their access to 'people' related admin area? It seems there's only one option under permissions - Administer users - which seems to dictate either full package (create all different profile2 users, access admin people list view etc) or nothing.

I have a 'sales person' role on the system. This user has to be able to create other profile2 based users but not to access user configuration or even general listing (not to mention that depending on number of profile2 profiles, multiple Add People links appear)