texts:
I am using Drupal 7, I am using form API to generate a table with select option filters. The data from the table is from an external API.

The table loads as it should, the drop down selection loads as should. When I select an option from the drop down section I am trying to pass the selected value into the URL of the external API and rebuild the table using the new URL but the table does not get rebuilt, instead the page just refreshes, the selected option is updated in the drop down selection. I have tested and think that the URL variable is updated to include the select option but the table does not get rebuilt.

This is the module

function mymodule_form($form, &$form_state) {

$form['type_options'] = array(
  '#type' => 'value',
  '#value' => $options
);

$form['Title'] = array(
  '#title' => $title,
  '#type' => 'select',
  '#options' => $form['type_options']['#value'],
  '#default_value' => isset($form_state['storage']['Title']) ? $form_state['storage']['Title'] : '',
);

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

//Get fromtable data from API
if (!empty($form_state['storage']['Title'])) {
 $filter = preg_replace('/\s+/', '+', $form_state['storage']['Title']);
  $url  = $api.'&filter='.$filter;
} else {
  $url = $api;
}
$json = file_get_contents($url);
$data = json_decode($json,true);
$rows = $data[data];

//Set paging items for formtable
$per_page = 30;
$current_page = pager_default_initialize(count($rows),$per_page);
$chunks = array_chunk($rows, $per_page, TRUE);
$form['table'] = array(
  '#theme' => 'table',
  '#header' => $header,
  '#rows' => $chunks[$current_page],
  '#empty' => $empty,
  '#pager' => array('quantity' => 12)
);

$form['pager'] = array(
  '#theme' => 'pager',
);

return $form;
}

function mymodule_form_submit($form, &$form_state) {
  $form_state['storage']['Title'] = $form_state['values']['Title'];
  $form_state['rebuild'] = TRUE;
}

Thanks for any help


texts:
I am trying to set up my first web site using Drupal 8 an Bootstrap. Unfortunately I wasn't able to show the site's slogan in Bootstrap theme. The slogan is set in /admin/config/system/site-information but is not shown.
So I thought by my self, it may not be printed in page.html.twig and tried to include it there. It's preamble says:

 * Available variables:
 * Site identity:
 * - front_page: The URL of the front page. Use this instead of base_path when
 *   linking to the front page. This includes the language domain or prefix.
 * - logo: The url of the logo image, as defined in theme settings.
 * - site_name: The name of the site. This is empty when displaying the site
 *   name has been disabled in the theme settings.
 * - site_slogan: The slogan of the site. This is empty when displaying the site
 *   slogan has been disabled in theme settings.

So I tried to print the slogan by including

{{ site_slogan }}

But this does not have any effect at all.

Can somebody please tell me, how to print the site slogan in Bootstrap?

[The lack of documentation and stable modules and themes should have been considered a release blocker for Drupal 8, but this is only my opinion and off topic here!]


texts:
Does anyone know of a module that allows to drag files from users computer into a target area in site (like in gmail or wordpress)?
ideally this would work with Image and other modules to insert the file "correctly" into drupal, save uploader info and allow adding meta data for file (like in the wordpress media area).


texts:
I want have a product that user can change the price of it to custom ,I want programmically change the price of product when user submit a custom form with entered price.

my require is I want to have product that according to entered value by user ,product price change and then add to his/her cart.
really I dont know how can I achieve it.
appreciate any urgency help


texts:
Im a trying to do a backup of my drupal site with:

drush -v sql dump --result-file=DrupalBackups/nameofsqldb5.sql

but it results in following error message:

The drush command 'sql dump' could not be found.  Run `drush cache-clear drush` to
[error] clear the commandfile cache if you have installed new extensions.

I ran drush cache-clear drush but without success.

Any ideas?


texts: Print object in template_preprocess_page

texts:
In template_preprocess_page() in my MYTHEME.theme file, I'm trying to validate if node has specific value.
When I dpm($variables) I get:

Array
(
    [node] => stdClass Object
    (
        [__CLASS__] => Drupal\node\Entity\Node
        [in_preview] =>
        [values] => Array
        (
            [vid] => Array
                (
                    [x-default] => 2
                )
...
    [page] => Array
    (
...

When I dpm($variables['node']) I get:

stdClass Object
(
    [__CLASS__] => Drupal\node\Entity\Node
    [in_preview] =>
    [values] => Array
        (
...

When I dpm($variables['node']->values) I get empty result.

Why so?


texts: Review your selections and rate them in Webform within Drupal 7

texts:
I have created a Form with the help of amazing Webform module in Drupal 7. It's a kind of various selections (through checkboxes) user makes.

This is all working fine but the problem is the last step.

I want user to review all the selections he made in the last page and give a priority to each selected option.

Now there are two things I want to do:-

Review the selections made in the Form at the end.
Prioritize them; by selecting a number 1-5 with each entry.

Please pardon my ignorance, but is it even possible with Webform?

Many Thanks.


texts: Im using Commerce for Drupal 8. When using Display Suite to create a two column display for Products, the Price and Attributes disappear. Is it possible to use Display Suite for Commerce Products to achieve a two column display?


texts:
I'm trying to attach a library in a custom shortcode but it doesn't show up neither using render array nor using attach_library twig function.

  class MyTimeline extends ShortcodeBase {
  public function process($attributes, $text, $langcode = Language::LANGCODE_NOT_SPECIFIED) {
    $output = [
      '#theme' => 'my_timeline_theme',
      '#attached' => array(
        'library' => array('my_timeline/timeline')
      ),
    ];
    return $this->render($output);
  }

mymodule/my_timeline_theme.html.twig

{{ attach_library('my_timeline/timeline') }}

The only way I can attach it is using this last line in the active theme,
ie node.html.twig


texts: Webform form results into same form in result page

texts:
I am trying to create webform with custom result page. In 'Form settings' page I set Confirmation page and in confirmation message insert my php code.
Here is code:

<?php
include_once(drupal_get_path('module', 'webform') .'/includes/webform.submissions.inc');
$nid = arg(1); // need to hard-code nid if this is a custom page
$sid = $_GET['sid'];
$submission = webform_get_submission($nid, $sid);

$get_type = $submission->data[2]['value'][0];

Everithing work fine with this. But also I enabled my form to be block and add it in result page.
My question is -> Is there any possabilities to show this webform into block with values right before i click submit on main form.


texts: How to append currency symbol as prefix to total sum in views calc?

texts: I have used Views Calc module to calculate sum of all column fields. How can I append currency symbol as prefix to Views Calc calculated total sum?


texts:
In Drupal 7 we have option to mark HTML=>TRUE.

How can i do it in Drupal 8

my code is

    $create_icon_path = 'my_icon.png'; //my icon path
    $create_icon = '';
    $create_earlywarning_url = Url::fromUserInput('/node/5');
    $create_earlywarning = \Drupal::l($create_icon, $create_earlywarning_url);
    return $create_earlywarning;

But its printing the

"" in  tag.


texts: Cart page content in simple block in ubercart 3

texts:
Can i use http://www.mysite.com/cart page content in simple block using ubercart 3 in drupal 7? I want same http://www.mysite.com/cart page content area ("cart form") in a simple block for show cart content in any region to authenticated user.

Thanks


texts:
I'm creating an e-commerce using drupal.

In this site I have several catalogs to distinguish between some products. Let's say I have url site_home/catalog/1 , site_home/catalog/2, site_home/catalog/3, and site_home/catalog/4`.

I need to disable view for /catalog/1 , /catalog/2 and /catalog/3, but everyone can view /catalog/4 and newly created catalog in the future which will have id > 4.

I've tried using Pages Module to disable those pages.

I've created new rule with this module which is called /catalog/%catalog with arguments for %catalog is string. And then for Access Rule I added a criteria String: URL path. Current path type is not one of "catalog/1, catalog/2, catalog/3" but when i enabled this rule I got:

/catalog/1 - /catalog/3 --> access denied
/catalog/4 --> page not found

Any ideas why this is happening, and which settings did I missed?


texts: How do I set the height and width for images that use a responsive images style?

texts:
When using the core Image module, the height and width of images are automatically set.  But when I use the Responsive Images module and a Responsive Image style, then no height or width is set.
Users don't like this because it makes the website look janky because images can pop into place and change the layout suddenly. Google doesn't like this because it slows down the page.  When testing with Lighthouse, it gives the following recommendation:

Set an explicit width and height on image elements to reduce layout
shifts and improve CLS. Learn more

There was also an article in Smashing Magazine this year about setting height and width.
How can I do this in the Responsive Image module?


texts:
Which Hook should I use to simply print a message if a configuration is not done yet?

The only idea i've got was hook_node_view, but maybe someone knows something better ?


texts: Drupal 7: Is hook_update_N() called when a module is updated between minor versions?

texts:
Say I'm trying to update a module from version 7.03 to 7.04, and version 7.04 has a function called mymodule_update_7704() which updates the module's schema.

If I go to the modules page and update mymodule, will the mymodule_update_7704() function run, and update the module's schema?

Also, if the above is correct and mymodule_update_7704() does run, will the user have to click to run the update, or is it silent?

Sorry if this question seems elementary, I just can't test this without releasing my module, and I'd rather know first before I do release.


texts: How to create a dynamic menu block system with 3-tier system?

texts:
I want to create a complex menu system as described in the following image:

It looks complex but logically it is simple.

I want to create a block containing Menu items.
Brief description of image for better understanding: There is a Standard main-menu as with all sites, under that, block is there as scenario-1 and scenario-2, I have just make two copy for better understanding. That block I want to keep in first sidebar. Block has three tier, it is just like M-item(main-menu) -> Its sub-menu items -> Its sub-menu items -> Its sub-menu items (So, it is like Parent -> child -> child -> child)
Logic: Hence, when user clicks M-item-1(parent, from main-menu) -> The block's first tier should show that main-menu item and its sub menu under that. Now suppose user clicks M-item-1-B(tier-1 item) hence in the tier-2 that item should display its sub-menu and M-item-1-B should be as title of tier-2 and same way if from tier-2 if user clicks M-item-1-B-b, its sub-menu should display as in the Tier-3. In short I want to display - 3-tier of menu items in one block only. Hence my purpose is to make the entire block dynamic. By default each tier's first menu item should show its sub-menu (as shown in the Scenario-1)
All the menu items which are active should show themselves highlighted (like what comes with any standard menu, when we click that item gets highlighted).
Path dynamics: Instead of click tier by tier if, I paste the path upto 3rd tier, the block should dynamically detect and show accordingly in the block.
This block or its all three sections are not drop-down type, it is just normal menu block.
The menu items is divided into two column as shown in the image block.

What I tried: I tried to achieve by this using the panels module(mini). I choose layout of 3 column and several row. And add the menu in the as content manually and set the visibility as per the path. But this is not a feasible. As you can see for the second tier I have to make the 6X2 panes and for 3rd tied 6X6X2 panes (2 is for 2 columns). This is not at all feasible. I did not try entirely, but i tried to see it, it is working with panel visibility setting.


texts: How to create a node revision view with a "Node" row style?

texts:
Is it possible to create a node revision view with a "Node" row style?

This does not seem to be an option in the Views interface. "Fields" is the only options presented for this type of view. Is there a reason why this is not technically possible or is it just not currently implemented?


texts: Can you make the hook_menu() item title different from the page title?

texts:
I'm building a menu with hook_menu().

When you're building the array for this you specify a title, which is then passed to the page you call and becomes the page title. It's also the menu item's displayed name.

$items['somewhere/something'] = array(
 'title' => 'Something',
 'description' => 'something else',
);

This would generate a menu link called "Something", and the page title would be the same.
Is there a way to make the menu item's name one thing, but pass along a different title for the page?

I know I can use drupal_set_title() in the actual hook_page() function, but I'd have to perform an additional database pull to make that happen in this case, and I'd rather not do that.


texts: Broken file derivatives when creating an article

texts:
I recently installed Drupal 8 to familiarize myself with this platform. I've noticed that, whenever I create an Article, and attempt to upload an image for that article, the styles created from that upload don't work and result in broken links.

The image uploads work just fine. Consider the image below:

In the Article view under Add Content, I have uploaded a small 312 KB file.

The thumbnail preview (red) does not work here, nor elsewhere, and attempting to visit the link generated for this thumbnail results in a 403 Forbidden result: mysiteurl.com/sites/default/files/styles/thumbnail/public/2015-12/Untitled.gif?itok=Y40Z0DEa
The link to the image uploaded (blue) works just fine. Clicking that link displays the image: mysiteurl.com/sites/default/files/2015-12/Untitled.gif
Last detail: I see that this error extends to the Styles configuration screens as well, where the default image on the left side displays fine whereas the right-hand, style-applied preview is broken (and attempting to display the image in a new browser tab, just like the preview in the Article screen, results in a 403 Forbidden result).

How would I go about resolving this? I don't think it's GD, following the directions outlined in a troubleshooting page on Drupal (I cannot post more than two links, due to reputation) I see in the Configuration area for my site that I have a writable file system, and GD installed - bundled (2.1.0 compatible).

I may be coming from left field here, but might the 'Styles' directory be the culprit? If there's some way I can have this folder get regenerated by Drupal, I wonder if that would resolve these errors.


texts: How to create a view with contextual filters and then make menus to filter it?

texts:
I have created a content type that I want to list and filter on taxonomy terms.
For example I want to show all posts of that content type on the frontpage. Then I want to be able to create menu items with name of all the existing taxonomy terms I have to choose from. Then i want those terms to link to a page with the filtered content for only that term.

I can create this by making a new view for every taxonomy term but it must be a better way to do this since if I have around 40 terms it's gonna get really messy.


texts:
I am using Drupalchat for my application. The issue is that my application getting very much slow down after put this chat system. I think the problem will be due to Ajax, it's keep on polling to the server for frequently to check the chat messages(incoming or outgoing). How to fix this issue to fasten my application ?

Also I am curious about how the facebook and gmail chat systems are working in general?


texts: Image uploading button is not appearing for authenticated users,only for admin

texts:
When using Filtered HTML on a body text, the image uploading button is only appearing for admin users under Tinymce, but not for authenticated users.

How can I fix that?


texts: In Drupal 7 how to expose TID (term id) as a selectable field on the manage display section of the taxonomy page?

texts: How can I expose the TID of a the term as a field via the manage display section of the taxonomy page?


texts: l() is not being called correctly in menu.inc

texts:
I had been getting this error message:

  PHP Fatal error:  Unsupported operand types in /var/www/www.ruv.is/pressflow/includes/common.inc on line 1588

So I did a backtrace and this is what it returned:

    array (
      'file' => 'pressflow/includes/menu.inc',
      'line' => 1614,
      'function' => 'l',
    )

It points to this function:

/**
 * Get the breadcrumb for the current page, as determined by the active trail.
 */
function menu_get_active_breadcrumb() {
  $breadcrumb = array();

  // No breadcrumb for the front page.
  if (drupal_is_front_page()) {
    return $breadcrumb;
  }

  $item = menu_get_item();
  if ($item && $item['access']) {
    $active_trail = menu_get_active_trail();

    foreach ($active_trail as $parent) {
      $breadcrumb[] = l($parent['title'], $parent['href'], $parent['localized_options']);  // line 1614
    }
    $end = end($active_trail);

    // Don't show a link to the current page in the breadcrumb trail.
    if ($item['href'] == $end['href'] || ($item['type'] == MENU_DEFAULT_LOCAL_TASK && $end['href'] != '<front>')) {
      array_pop($breadcrumb);
    }
  }
  return $breadcrumb;
}

Or more specifically, this line:

$breadcrumb[] = l($parent['title'], $parent['href'], $parent['localized_options']);

I'm assuming there is a contributed module that is causing this, but it is happening on several pages that don't use any menu altering module. Do you have any idea on how to troubleshoot this?

I can't reproduce this myself, so my only chance of debugging is on a hight traffic live site.


texts: Using base_url() in image paths without using PHP?

texts:
So normally I can do <img src="<?php base_url(); ?>/default/files/image.png" /> and that works just fine if I enable the php filter.

The trouble is that enabling the php filter disables all shortcodes. My drupal site is not installed in the root of the domain so  will not work.

Is it possible to have a relative path (this site will be moving once I'm finished) but have drupal know it's relative to the base url without using php? Maybe a setting?


texts: How to use hook_form_alter to hide a form field for certain users?

texts:
function custom_form_alter(&$form, &$form_state, $form_id) {

global $user;
$node = node_load(arg(1));
$num  = $node->field_node_reference['und'][0]['nid'];
$val  = node_load($num);
$event_noderef_uid = $val->uid;

if($form_id == 'regester_node_form'){

if($user->uid == $event_noderef_uid){
 $form['field_NAME']['#access'] = FALSE;
 }

I want to get ($user->uid == $val->uid) to Hide "field_NAME"


texts: how to automatically create other entities when creating an entity

texts:
I have 4 entity types. All types have a relation to each other. For now let's call them A, B, C and D. How can I allow a user (let's say userA) to create an entity of type A so that entities for B, C and D are also created at the same moment. UserA has the permission to create A entity types and is not the author of the automatically created entities of type B, C and D.
Is there a way to automatically create these related entities?


texts: Advanced Forum - how do I delete a forum?

texts: I'm using Advanced Forum - how can I remove the default forum created (General Discussion)?


texts: How to write paragraph template to add tags and css classes?

texts:
I have a paragraph bundle (pr_bnd1), which has several fields as below:

field_txt
field_bg_clr (list field whose key values are mapped to a css class)
field_font_clr (list field whose key values are mapped to a css class)

The an example output

 field_txt value

Desired output

.
    field_txt value

How would i achieve the desired results? I am having trouble getting the template file to work. Any thought?

My paragraph bundle name is "pr_bg_font_clr".

So i imagine i would have to write a template file with the name of "paragraph-items--pr-bg-font-clr", but i am not sure what the structure should be and which fields i can utilize.


texts:
I'm building a custom module so the editors at my company can select several nodes and spit them out as a newsletter. There are some modules that get me halfway, but due to some specific requirements, coupled with me really wanting to wrap my head around creating custom modules, I'm starting from scratch.

I understand the hooks, and have set up the menu, permissions, and most of the form fields where users can select a template and other options. I'm stuck at the part where they actually pick the nodes.

I was thinking I can probably create a View with some exposed filters and maybe hook into that, if it's possible. Ideally, I'd let them drag and drop the nodes, reorder them, etc.

I'm not looking for someone to code this out for me, would just like to be pointed in the right direction.


texts:
I'm trying to understand how to create content for a site and place it somewhere.  The two methods I want to compare are:

Content type

Create custom content type (with fields)
Create instances of content
Create view of this content type
Create block from view
Place block in region

Custom block type

Create Custom Block Type (with fields)
Create and place instance of custom block in region

Whats the pros and cons of each approach?

As an example scenario, lets say I have a home page with 4 sections of the same content type (for example product features).  These 4 sections need to be ordered down the page.  There will be other content on this page.

From what I have seen so far, the Custom Blocks require less effort up front to setup, I don't need a view, and I can arbitrarily order then in the block layout page (drag/drop).  However, I feel like I've now 'hidden' content somewhere else that doesnt appear in the main content summary page, and a content manager would need to know to look there, also the default view to manage Custom blocks has less options than the content filter (i know you can add some filters to that view though).  Also if I add each item as new instance of a custom block type to the block layout page, that list is going to start getting pretty long.

I guess adding the content as a content type means its created as node (and via the custom block type it isnt?)

Edit: The sites we build are big, and always multi language.  This might affect any answers.


texts: "Save draft" form button for anonymous users

texts: I am using the Webform module to create a form. I've only just realised that the "Save draft"button is available only for authenticated users, which is a shame! Is there an easy way of making the "Save draft" button available for anonymous users as well?


texts:
This question may be simple and I'm overlooking the answer, but I am trying to add routes that are front page aliases and there doesn't seem to be an obvious solution.

Basically what I want is to add more front pages, because I want to parse the values in JS, and not through php.

Example:

If the front is /node I also want /variable/value to go to the front.

Can I do this through my routing.yml?

Note: I'm not looking for a redirect to / or /node because I need the url values.


texts: Is it possible to bypass the admin approval step based on a particular condition?

texts:
Potential scenario:

Allow users with a particular email address or token to skip the admin approval step and have their account approved ie: it sends the password/login link out immediately and they don't receive the awaiting approval email.

All other users with other email addresses need to be approved by an admin.

One potential solution I've thought of is to act on hook_user_insert to unblock and send the password email the user hook_mail_alter to disable the initial awaiting approval email.

I just feel this option is a bit hacky and I'm wondering if there is a better way of doing things.


texts: How to remove user role using hook_user_update

texts:
I am having trouble trying to remove a role after user account submit.

I have used the following code:

function vdb_form_alter(&$form, $form_state,  $form_id) {
  global $user;

}
  if(($form_id === 'user_profile_form')and (isset($form['account']['pass'])) and (in_array('Hybridauth', array_values($user->roles))) ) {
      $form['#submit'][] = 'my_module_hook_user_update';

}
function my_module_hook_user_update($edit, $account, $category) {
  $role_position = array_search('Hybridauth', $account->roles);
  // Use !== or === here since $role_position may be zero or FALSE
  if ($role_position !== FALSE) {
    unset($account->roles[$role_position]);
  }
}

Resulting in the following errors:

Warning: Missing argument 3 for vdb_hook_user_update(), called in \includes\form.inc on line 1471 and defined in vdb_hook_user_update() (line 46
Notice: Trying to get property of non-object in vdb_hook_user_update() (line 47
Warning: array_search() expects parameter 2 to be array, null given in vdb_hook_user_update() (line 47
Warning: Attempt to modify property of non-object in vdb_hook_user_update() line 50

I have tried using hook_user_presave however using this hook hybridauth module gets stuck.


texts: Fallback value for contextual filter, in case the "provided default value" does not exist

texts:
I want to display a block on each page (nodes as well as pages created by Views) that displays links to nodes that are tagged with a certain taxonomy term.

How to decide which tag should be used:

{1} If the page is a node that references a taxonomy term:
use the referenced term
{2} If the page is a node that doesn’t reference a taxonomy term (= empty value):
use the term with ID 1
{3} If the page is not a node (= created by Views):
use the term with ID 1

I managed to get the links shown in case {1}, by using the relationship "Content: Taxonomy terms on node" and the contextual filter "Taxonomy term: Term ID" which uses the relationship.

I selected "Provide a default value" (Type: "Taxonomy term ID from URL" + "Load default filter from node page, that’s good for related taxonomy blocks"). So I can’t specify the default value here for case {2} and {3}.

Then I thought I could use the validation options somehow, but "Action to take if filter value does not validate" does not allow me to set a specific value in case the original default value does not exist.

How could I solve this?

tl;dr: I need something like: Take term ID from URL (via node ID), and if this gives no term ID, use term ID 1 instead.


texts: Form storage is cleared after ajax submission

texts:
I am creating a form with "add more" functionality. Form builder retrieves values according to  form built. keys are generated using uuid service. I also have to save them. So they are saved into form storage.

$form_state->get('links', $links)
...
$form_state->get('links')

On the next ajax submission storage is empty?!
Also I use a block configuration form. So it uses sub-forms. May be the problem is related with. This is related problem. How to prevent SubFormState storage leaking into parent?


texts: Hook form alter not firing on a custom form that does exist

texts:
I have a hook form alter function that is not recognizing or firing on a form that clearly does exist on the page. And i’ve tested this function against the Drupal built in form with the id of ‘search_block_form’.
In my template.php file i have this code.

function mytheme_form_alter(&$form, &$form_state, $form_id){
if($form_id == 'search_block_form'){

    echo '<script>alert("whatup?");</script>'; /* for testing purposes */
    drupal_add_library('system', 'ui.accordion');

    $form['search_block_form']['#attributes']['placeholder'] = t('enter burp search terms...');
    }

if($form_id == 'views-exposed-form-browse-albums-page') {
    echo '<script>alert("whatup beeatch?");</script>'; /* for testing purposes */
    drupal_add_library('system', 'ui.accordion');
}

}

As a test first IF statement alters the default Drupal search whose id is  ‘search_block_form’. This part does run and is working.

The second IF statement tests for my custom views form but does not run at all. The form does clearly exist (see attached). I’m stumped at this point and don’t know what to do next. Why is the second IF statement not running?


texts: How to list nodes with at least one field empty?

texts:
Is there any module or built-in function to check if all the node fields are filled with some values, and list nodes that fails this check?

EDIT: In short, I just want to get the list of nodes having any of their field empty.


texts: How can my module add xml sitemap entries?

texts:
I have a module with a page callback handler for the path "products". So if the user navigates to products/apples then the module presents a page about our apples, and if they go to products/oranges then etc. These pages include detail about the various products.

I would like XML Sitemap to be populated from my module. After all, it's my module that knows what products exist, their descriptions etc.

Any hook or anything I can use for that?


texts:
How can I add image dimension validation so that it accept only specific dimension of image?

For example I want to restrict to upload only 1200x650 dimension of image, so I have added same dimension in max and min upload dimension under image field settings. If I am uploading below 1200x650 it show validation error but not showing if image dimension is greater that 1200x650.


texts:
I have a movie site and I want users to be able to add movies (node) to their list by visiting the movie and it should have a link saying "Add to my list". When they are about to add to their list it should have a selection box with options like watching, completed, on-hold etc...

An example site http://myanimelist.net/anime.php?id=269 you can see when you click their "Add to my List" it gives some more options like status, eps seen, score

So how can I do this?


texts: How to get the Top Author of the week based on user points? I have tried http://drupal.org/project/userpoints_ranking but it has no such options. I am using drupal 7I have vote up/down module and user-points module enabled and a Rules to add user points for every vote automatically, based on that vote i want to have Top Author of the week.


texts: Field collection item table names in mysql

texts:
I am building a feature which will conditionally need to output entity data. The entity type is a custom one I created, which is complex and implements multiple nested field collections.

My issue is that looping through entities using Entity::loadMultiple() is very slow, as each entity needs to use FieldCollectionItem::load() multiple times to get to the data it needs to output. Over 1000 entity instances this uses up a lot of resources and takes a long time to load.

I am trying to circumvent this by retrieving the data via a SQL query and joining tables together. I'm hitting a road block when retrieving data from field collection items with long machine names, as the data appears to be stored in tables with names like field_collection_item__5d28be6634, basically just "field_collection_item__" with a 10-character hexadecimal hash added to it.

This would not theoretically be a big issue, except it looks like all records for the same field collection item seem to be split up across many of these tables with no pattern or connection that I can discern.

How do I know which tables to retrieve my data from for any given parent field collection instance?

Edit: I have revisited this recently and thought some of these tables might be revision tables, but none of them include the "_r_" in the table name. I still cannot determine which tables to use as there seem to be multiple tables (not including revision tables) for one field collection item. Looping through entities and loading nested field collections is taking upwards of 5 minutes which is just too long for my users.


texts: Add content type filter on taxonomy page

texts: I am new to drupal, i have created 2 different content types i.e. Online and Offline. I want to add content type filter dropdown on taxonomy page to select any one content type from online/ offline. Can anyone help?


texts:
I am trying to theme the user s profile edit form. I Have added a class to the form and the look changed. However i am still struggling to find out how to order the fields in the way i want directly in the template.php file.
Here is my code :

if ($form_id == 'user_profile_form') {
//dsm($form);
//kpr($form);
$form['#prefix'] = '

 Modifer vos informations

';
    $form['#suffix'] = '

';

    $form['field_civilite']['#prefix'] = '

Informations personnelles du membre

';

$form['field_nom'][und][0][value]['#attributes']['class'] = array("nui-input");
$form['field_prenom'][und][0][value]['#attributes']['class'] = array("nui-input");
$form['field_personne_morale'][und][0][value]['#attributes']['class'] = array("nui-input");

$form['locale']['#prefix'] = '

Preferences compte

';

$form['account']['current_pass']['#attributes']['class'] = array("nui-input");
$form['account']['mail']['#attributes']['class'] = array("nui-input");
//$form['field_civilite']['#suffix'] = '';
$form['field_pays_users'][und]['#attributes']['class'] = array("select");
$form['field_profession'][und]['#attributes']['class'] = array("select");
$form['field_conditions_enregistrement'][und][0][value]['#attributes']['class'] = array("dislaynone");
$form['field_conditions_enregistrement']['#prefix'] ='
';
$form['field_conditions_enregistrement']['#suffix'] = '
';

$form['actions']['submit']['#attributes']['class'][] = 'nui-button green';
$form['actions']['cancel']['#attributes']['class'][] = 'nui-button red';

}

Is there a way to override UI that manages the fields display for drupal users ?


texts: view list on user profile, to show content of that user

texts:
I currently have a view that shows on the user profile page (as a block). I got it to show results of the content for the current logged in user.

This works great for normal users as they will only be able to see their current profile page. However, I want it to show the content for the shown profile, not the current user, since admins that view other user profiles will not see that user's content.

Is there a way to set the view to get the uid of the profile page rather than the logged in user?

These are the view settings I have right now are:

CONTEXTUAL FILTERS
   Content: Author uid
      Provide default value: User ID from logged in user
RELATIONSHIPS
   Content: Author


texts: Using views to generate a summary view of nodes

texts:
I have been wrapping my head around this problem. Basically I have changed the post settings to teaser mode. And I have made views that filters node of certain type . To conclude, I want my nodes to be displayed like in this link http://asblab.mie.utoronto.ca/research
where the research links has a summary view with the read more.

Thanks in advance.


texts: How do I create a base content type and subtypes ("bundles")?

texts:
I've been trying to figure out how to create a base content type and subtypes (bundles) in Drupal 8, but haven't been able to figure it out.

For example:

Base Content Type

Base Event (fields: event name, start/end dates and times, location, etc.)

Subtypes (Bundles)

Seminar
Conference

I looked into:

ECK (Entity Construction Kit) module: didn't seem to be working 100% in Drupal 8.  Using their example, I was able to create a 'Vehicle' ECK base type and 'Car' and 'Truck' ECK subtypes, but wasn't able to define any fields for the 'Vehicle' base type that would be shared between 'Car' and 'Truck'.  Also, the types appeared under 'ECK Types' in 'Admin > Structure', so not sure if they would be usable throughout Drupal in the same way that regular Content Types are used/referenced?
Paragraphs module: doesn't seem to the right module for this

It looks as though I have to do this through code somehow, but couldn't find any clear documentation that explains step-by-step how to do this in Drupal 8.

Any help would be greatly appreciated.  Thank you.


texts:
In my pattern for pathauto I'm using [nodesymlink:menu-link:parent:url:path]/[nodesymlink:menu-link:title] and for menu items that are children of the front page it is prepending <front> to the beginning of the url instead of just leaving it blank.

Perhaps it's an issue with the nodesymlinks module. Has anyone had this issue before? The urls still work, but I don't want the text <front>/ in front of my urls.


texts: Include two Commerce Add to Cart forms on one page

texts:
With two forms on one page, I'm experiencing the error Error: Call to a member function id() on null in Drupal\commerce_product\Plugin\Field\FieldWidget\ProductVariationTitleWidget->formElement()

This is happening on two different types of pages, but both involve Commerce add to cart forms.

I have two different types of pages:

Commerce Product.  This has an optional Commerce Product entity reference field.
Landing page. This page is built using paragraphs and site builders have a paragraph which is a block containing an add to cart form for a product they select

On the Commerce Product page, clicking Add To Cart for the entity reference item results in the error.  On the Landing Page, clicking any of the Add to Cart buttons produces the error.

So far, I'm debugging the Commerce Product page.

AddToCartFormatter:viewElements is always getting the main entity of the page.

ProductLazyBuilders::addToCartForm receives a product_id as it's first argument.  The product ID comes from the entity and I've been tracing it up the stack to HTMLRenderer::prepare in which $main_content is the entity being viewed - this would explain why none of the Landing Page add to cart forms work and why only the Add To Cart form for the main entity on the Commerce Product page works.

EDIT: It might be important to note that all forms are built correctly.  If I watch ProductLazyBuilders::addToCartForm() it gets correct product id's and all the forms are correct insofar as they show the right variations.

EDIT 2: The entity is set in ContentEntityForm::form() using $this->entity which, apparently, is the entity being viewed.

EDIT 3: If I wanted to hack together a solution, it works to do something like this:
In Drupal\commerce_cart\Form\AddToCartForm::buildForm() I can add:

$form_state->addBuildInfo('entity', $this->entity);

And then, within Drupal\Core\Entity\Content\ContentEntityForm::form() add

if ($form_state->getBuildInfo()['entity']) {
  $this->entity = $form_state->getBuildInfo()['entity'];
}

This makes the Landing Page "work".

EDIT 4: #3 doesn't fix anything except the first product on the page, so now there is one that works.

So, I guess I have a couple questions:

At what point does a form decide which form is being submitted?
Am I missing something obvious that would allow for this setup to work?


texts: Change image styles based on selected theme

texts:
I have multiple themes under one installation and using SwitchTheme http://drupal.org/project/Switchtheme to switch between themes as selected by the user. My problem is I have a view displaying thumbnails that need to change color depending on current theme selected.

Anyone have any suggestions or know of a module out there to handle this?

Thanks


texts: search_update_totals() is not invoked / or search_cron() is not invoked

texts:
I don't know when, but this is new: in my Drupal 7 installation the indexing of search terms doesn't work anymore.

Here is a trace, but don't know how to solve it:
it seems that in /modules/search/search.module the search_cron() is not invoked anymore. And that is why necessary inserts in the database table search_total are ommitted.

Any ideas?

Thanks
Selim


texts:
How to change the label of title field bydefault its showing Title I need to change it to "Custom-title" of node edit form programatically.

I tried

 function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form_id =="slices_slices_cta_5_edit_form")
{
    kint($form[title][widget][0]['#title']);
    dpm($form[title][widget][0]['#title']->jsonSerialize());
   $form[title][widget][0]['#title']->jsonSerialize()==t("Custom-title");
     //dpm($form[title][widget][0]['#title']->getArguments());

}

I just want to change [string] property of class TranslatableMarkup's object of above screen shot.

How to access the value of a Drupal\Core\StringTranslation\TranslatableMarkup object within a form

I want to do something like below example:

$form[title][widget][0]['#title']->string = t('New-title');

Not working above solution.


texts:
I am using \Drupal::EntityTypeManager() in Drupal 8 to save data provided from a form into a content type. The following code saves the information in the content type news:

$data = [
  'type' => 'news',
  'title' => $title,
  'body' => ['value' => $content, 'format' => $format],
];

$node = \Drupal::EntityTypeManager()
  ->getStorage('node')
  ->create($data);
$node->save();

Now I need to get the nodeID of the node that was just saved. How do I do that ? Furthermore, I need to insert another set of data into a second content type that needs to store the nodeID I just mentioned.

$node2 = \Drupal::EntityTypeManager()
  ->getStorage('node')
  // $data2 contains the $node->id()
  ->create($data2);
$node2->save();

Outside of Drupal I am used to mysql transactions to make sure that both things only get stored together and get rolled back if there is an error with either of them. Is there a way to achieve this 'all-or-nothing' functionality with \Drupal::EntityTypeManager()?

Do I genrally need to put this in a try{}catch{} block in Drupal?


texts:
I make a content type that called "commission".
And also I have created a Taxonomy called "commission" too.
In the taxonomy we have some terms like "Fun" or "sports" and etc.
When the user want to create commission node, they should choose one of the taxonomy terms.
Now my question is this:
I want a module to make a subscribe link for people that they can subscribe on the content with the just "sport" taxonomy term or "fun" taxonomy term or something else.
It means I need a subscribe Newsletter module based on the Taxonomy terms.
What shall I do?


texts: Trying to override Drupal core 'find content' with a view and VBO

texts: I am trying to replace the core content admin area with a view and VBO. I managed to create the view and have it override admin/content/node without an issue. However the administer content area is also accessible by admin/content. I tried creating a second view to override it but it breaks the menu. It appears to be a menu router issue. Any thoughts on how to overcome this (other than adding a redirect)?


texts: How to index to multiple Solr cores with 'Apache Solr search' module?

texts:
I'm trying to set up a multisite search across several legacy Drupal 7 sites that use the Apache Solr search module.

I'm doing this by using a shared core that all the sites will index to, and a further site will be used for searching.

Some of these sites already use Solr for searching, so I figured I'd add the shared core as a second core, so that any site specific search configurations would not be disrupted, and I could index other content types that the existing config has excluded.

The problem I've hit is that content doesn't get sent to the second core. Deleting, queuing and reindexing content all apply to the first core only, and I haven't found a way to have both cores being indexed.

Is there a way I can do this?


texts: CKEditor4: the image disappear when I switch from Rich text View to source view

texts:
I am using the CKEditor4 module for Drupal7 (https://drupal.org/project/ckeditor) and I noticed that when I am in the "Rich Text" view and I upload an image using the Image button. Initially the image is there, but when I switch to the "source view" and go back to the "Rich Text" view the image disappears. Also when I save the page in the Admin and I come back to it the image disappears. The code for the image still exists in the source view and the image shows up in the Live post but NOT in the "Rich Text" view.

Any ideas what's the problem?

Thanks.


texts: Programmatically set the value of a date/Time field

texts:
I am trying to copy the value of a Date/Time Webform element to a Date/Time field set on the article node.

Below is the source code of the Date/Time Webform element:

expiry_date:
  '#type': datetime
  '#title': 'Expiry Date'
  '#title_display': before
  '#required': true
  '#required_error': 'You must add an expiry date'
  '#date_date_format': ''
  '#date_year_range': '2019:2100'
  '#date_time_format': ''

Below is my custom handler:

// Get an array of the values from the submission.
    $values = $webform_submission->getData();

    // Get 'Expiry Date' Value.
    $ExpiryDate = $values['expiry_date'];
    date_default_timezone_set('UTC');   // Sett the time to 'UTC' time zone.

    // Format the "Expiry Date" to return "Y-m-d\TH:i:s".
    //$FormattedExpiry = date('Y-m-d\TH:i:s', $ExpiryDate);

// Create a new "Article" node.
    $article = \Drupal\node\Entity\Node::create([
        'type' => 'article',
    // Set the node field values.
        'title' => $Title,
        'langcode' => 'en',
        'uid' => $CurrentUid,
        'status' => '1',
        'created' => $current_time,
        'field_expiry_date' => $ExpiryDate, // $FormattedExpiry,
        ]);

// Save the created node.
    $article->save()

But I am facing the below error:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'field_expiry_date_value' at row 1: INSERT INTO {node__field_expiry_date} (entity_id, revision_id, bundle, delta, langcode, field_expiry_date_value) VALUES (
:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5);
Array (
[:db_insert_placeholder_0] => 84
[:db_insert_placeholder_1] => 88
[:db_insert_placeholder_2] => article
[:db_insert_placeholder_3] => 0
[:db_insert_placeholder_4] => en
[:db_insert_placeholder_5] => 2021-05-25 11:26:02 +03:00
)
in Drupal\Core\Entity\Sql\SqlContentEntityStorage->saveToDedicatedTables() (line 1414 of /home/username/public_html/example.com/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).


texts: Placing a block next to the comments section

texts:
I have a problem that I have been working for hours now.  Basically, I would like to place a block next to the comments div.  So, in the footer of my page, I'd have all the user comments to the left and in the right side, I'd have my block.  I know I have to do some realignment in the page.tpl.php, but I just can't get the comments div and the block div to appear side by side.  Would appreciate any help on this.

Edit:

I added this in my template.php file:

/**
 * Custom function to render a block to manually position it in the node.tpl.php markup
 */
function mytheme_block_render($module, $block_id) {
  $block = block_load($module, $block_id);
  $block_content = _block_render_blocks(array($block));
  $build = _block_get_renderable_array($block_content);
  $block_rendered = drupal_render($build);
  return $block_rendered;
}

function mytheme_preprocess_node(&$vars) {
    //Add the related_by_term block to the variables array so that we can render it in our node.tpl.php file
    $vars['my_block'] = block_render('views', 'my_block-block_1');
}

And in my node.tpl.php, I added this after the comments section:

<?php print $my_block; ?>

But what I am getting is a memory limit exceeded error.  Basically, the block_render function is causing some problem. It's this line that is causing the problem:

_block_render_blocks(array($block));

Any input would be highly appreciated.  Spending hours on this issue.  Thank you...


texts:
I have a recent comments block; however, it does not auto-update the time of the comments: the time it shows is the age of the comment when I decided to include the block. The only way I can update it is to click Edit View and then clicking Save. This causes the recent comment's time to be correct for that brief moment in time only; but obviously as it still doesn't auto-update it is soon incorrect again. I must also re-iterate that refreshing the page does not cause it to update. Being new to Drupal I am not sure if this is standard behaviour; however, it would seem exceptionally odd if it was.

Edit: I gather it has something to do with using Time Ago rather than explicitly stating the date - obviously, the date it was created is fixed but Time Ago will increase every second. It would seem odd to offer a functionality like Time Ago if it did not update via some sort of median, e.g., Ajax, or at least as a minimum every time the page was refreshed. A fixed figure is absolutely pointless. Still holding out that I am missing some crucial bit of info.


texts: Load domain-specific CSS file on a multisite

texts:
I have a Multisite Drupal 7 install.

I use one theme for all sites, and it lives at sites/all/themes.

Each domain has its own settings for the theme where you specify classes so you can target each in the css.  This allows me to not have to copy over the theme to each sites/site1/themes, and to not have to create sub themes for each one.  Less overhead.

So I have 1 giant css file, that contains all the css tweaks for each sites look.

But I would like to separate each sites css into its own file.

So I can have site1.css, site2.css, site3.css, and so on.  They would all need to be located in the theme at sites/all/themes.

How would I tell Drupal to load site1.css when on site2.com...and so on?


texts: Is there a way on Drupal 8 to remove "Not specified" and "Not applicable" languages from list and to display only listed Languages?


texts: Getting a specific value from form api in theme-settings.php

texts:
In my custom theme I am developing, I have a form API setting in theme-settings.php that lets a user choose one of two options with a select menu as such:

 $form['txtr_settings']['general_settings']['choose_slideshow'] = array(
        '#type' => 'select',
        '#title' => t('Choose a slideshow'),
        '#default_value' => theme_get_setting('choose_slideshow'),
        '#options' => array(
            'basic' => t('Basic'),
            'fancy' => t('Fancy'),
        ),
    );

Then in my theme's page.tpl.php I want the value the user has selected to be part of an if else statement.

Right now I have this code which does not seem to work:

<?php if (theme_get_setting('choose_slideshow') == 'basic')
            include(dirname(__FILE__) . "/slideshow_alpha.inc");
        else
            include(dirname(__FILE__) . "/slideshow_beta.inc");
  ?>

I know if I have a simple single checkbox (checked = yes or '1' I can do something like this:

<?php if (theme_get_setting('choose_slideshow') == 1)

... but in this case I really want to show the user both options and have them choose one or the other in the select menu.

If I use either option on it's own without the if / else, each works fine so I think it's a question of my theme_get_setting value. I am not really sure if this is a Drupal question or a PHP question that I should ask over on Stack Exchange.


texts: Programmatic access to metatag module fields

texts:
I am wondering how to programmatically access metatag module data.  For example, my node has an entry for metatag description, and I see in the generated page the meta description tag, which is great.  However, it's not clear how I can access this programmatically.

Right now, I am trying the following:

$metatag_manager = \Drupal::service('metatag.manager');
$tags = $metatag_manager->tagsFromEntityWithDefaults($node);
$elements = $metatag_manager->generateRawElements($tags, $node);

Inspecting the data, I see that $tags includes a 'description' entry, but $elements does not.  Is there a better way of accessing this data?

The metatag module includes documentation for programmatically setting data, but unfortunately does not mention accessing the data.

Edit: Alas, it seems I was inspecting the wrong node -- one with the same title as a node with metadata entries.  Working now with the correct node, it seems all I need to use is:

$metatag_manager = \Drupal::service('metatag.manager');
$tags = $metatag_manager->tagsFromEntity($node);

Which returns an array with a description key and the description value entered for that node.


texts:
I have a site built with Drupal 8.3.7.
Modules 'Colorbox', 'Colorbox Load', 'Colorbox Inline' and 'NG Lightbox' are activated.
I can't make this kind of thing work:

giving that:

while it works perfectly in Drupal 7.
Any idea?


texts: Custom entity datetime field in calendar

texts:
I created an entity in a module, using code. I generated skeletons with drupal console generate:entity:content (without bundles), and then added a datetime field to my TestFieldEntityItem.php, in baseFieldDefinitions().

$fields['test_date'] = BaseFieldDefinition::create('datetime')
  ->setLabel(t('Test date'))
  ->setDescription(t('Test.'))
  ->setRevisionable(TRUE)
  ->setSettings([
    'datetime_type' => 'date'
  ])
  ->setDefaultValue('')
  ->setDisplayOptions('view', [
    'label' => 'above',
    'type' => 'datetime_default',
    'settings' => [
      'format_type' => 'medium',
    ],
    'weight' => 14,
  ])
  ->setDisplayOptions('form', [
    'type' => 'datetime_default',
    'weight' => 14,
  ])
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

I installed my module, cleared the cache, reinstalled calendar and calendar_datetime modules, but when I try to add a view from a template, like the calendar module suggests, I can't see any template matching my datetime field.

If I create a datetime field on this entity through the UI, it appears in view templates. What am I missing?

Inspecting the calendar code, I found the function that search datetime fields, in ViewsFieldTemplate.php.
This function finds my field, but the field_info does not match isDateField() because of the argument property.

isDateField() wants 'datetime' as argument ID.

protected function isDateField($field_info) {
  if (!empty($field_info['field']['id']) && $field_info['field']['id'] == 'field') {
    if (!empty($field_info['argument']['id']) && $field_info['argument']['id'] == 'date') {
      return TRUE;
    }
  }
  return FALSE;
}

My field_info argument is 'string'.

array (size=7)
  'title' => ...
  'help' => ...
  'field' =>
      'id' => string 'field' (length=5)
  'argument' =>
      'id' => string 'string' (length=6)
  'filter' =>
      'id' => string 'string' (length=6)
  'sort' =>
      'id' => string 'standard' (length=8)
  'entity field' => string 'test_date' (length=4)

So thanks to @4k4 answer, I tried to do the same as the working date field, and I created my own EntityViewsData (I tried hook_views_data_alter() first but the field was not present in input data)

namespace Drupal\kabukis_tests\Entity;
use Drupal\views\EntityViewsData;

class TestEntityViewsData extends EntityViewsData {
  public function getViewsData() {
    $additionalData = [
      'test_date' => [
        'title' => new TranslatableMarkup('Birth date'),
        'help' => new TranslatableMarkup('Birth date'),
        'field' => [ 'id' => 'field' ],
        'argument' => [ 'id' => 'date' ],
        'filter' => [ 'id' => 'date' ],
        'sort' => [ 'id' => 'date' ],
        'entity field' => 'test_date',
      ]
    ];
    $data['test_field_entity_field_data'] = array_merge($data['test_field_entity_field_data'], $additionalData);
    return $data;
  }
}

Now, the field appears in views template list ! However, the generated view is not working, I get the following error :

  \Drupal\calendar\Plugin\views\style\CalendarStyle: A calendar date argument is required when using the calendar style, but it is missing or is not using the default date.


texts:
I have a set of nodes, some of which are just a title, while others have body and other content.

I'm trying to create a view, which lists the node titles. If the body of the node contains content, the title should link to the node, but if the node body is empty, it should just display the title as plain text.

I think I can achieve this by rewriting the title field in the view with TWIG.

I've got it working so it detects the body and displays a link, but I'm not sure what to put for "url" in the link.

{% if body|render|trim is not empty %}
{{ title }}
{% else %}
{{ title }}
{% endif %}

How can the TWIG code get the url of the node to link to?


texts: Custom 'Who's Online' View - How to filter User View by whether logged in

texts:
I have a User View that is trying to replicate the 'who's online' block. It currently has 3 filters:

A custom user_profile field (Must be False)
User: Active (Yes)
User: Current (Yes)

For some reason the filter works on when using the first two but when I introduce the User: Current filter it filters the entire view by the active user.

What I need to do is be able to filter the view by all current logged in users.


texts: Show all content related to child taxonomy terms in parent

texts:
I don't think I could explain it any better here then I have in the title.

Basically if I have a taxonomy term call Parent and it has sub terms called Child 1 and Child 2. I'd like to be able to see any content related to Parent's sub terms (Child 1 & Child 2) appear on the Parent taxonomy page.

Thanks in advanced!


texts: I can find Deploy module for Drupal 7 that achieves full deployment. Also, I can find Incremental Deploy module for Drupal 6. Is there incremental deployment module for Drupal 7? or even work around that achieves incremental deployment for Drupal 7?


texts: How can I reference a field from a product display when calculating a price?

texts:
I am creating a product where you can buy a shirt in custom quantities (3 smalls, 1 large, 4 mediums). The user types in the quantity, as well as select various product variations. Then by rules I calculate the price based on a fields I made called small_price, medium_price etc. So it would pull the users quantity input for each field and multiply accordingly e.g. small_price*small_quantity + medium_price*medium_quanitity. This is all working well, however it is currently implemented on the product level and not product display.

What I am trying to do is have the rule multiply a field from the product display by a field in the product variation. However the product display field is not available to me in rules. I have seen a couple of short hand answers on here about writing a custom rule but is there anyone who could explain it to me a little more in depth?

Thanks!


texts:
I'm planning a huge site which in a couple of years should be hosting a million documents.

I thought of going for D7 but I found that most of the modules are in Beta or even Alpha releases.

D6 is pretty stable.

My main requirement is Taxonomy, CCK and Views since I'll have lot of inter-related nodes organized under different hierarchies(taxonomy) and will be shown using Views.

If I go for D7 then I'll have to regularly keep updating site with new releases and bug fixes.

I want some suggestion.


texts:
I'm using Panels to generate my front page. In one of the panes in my panel layout, I want to have an image which is linked to a given URL. The image and URL are going to be managed by my users.

I've been told that the Link module will give me a field type for URLs., and the Link Image Formatter module will let me link images to URLs; but I can't find any documentation on how to actually use the link image formatter. (EDIT: It turns out the Link Image Formatter wasn't about making href links, but just including images from a different domain.. or something, I'm confused.)

I've tried creating a content type with an image field, and a link field, but I can't find any way to connect them, or any way to associate an image with the link field.

EDIT: The URL may be internal to the drupal site or it may be external. These image/link combinations will be created and managed by the user through drupal. There may be 4 of them on the front page, but I may need to use them more later on throughout the site. They aren't unique to each user, I'll only have one admin user who will be posting all of the content on the site.

I want the user to add a piece of content. They'll upload an image and they'll define the URL they want that image to link to. Then in one of my Views/blocks, I can select that content type and show it in a certain region. It'll just show the image, but if a user clicks on the image, it'll take them to the specified URL which may be external to the site.

This seems like a wheel that should already have been invented, but I'm having trouble finding them.

How can I achieve this?

EDIT: I figured out what I was doing wrong... I think the person who suggested the Link Image Formatter module to me may have hastily picked the wrong url when they sent it to me and really meant to send the Link Image FIELD module which does exactly what I expected.


texts:
I created a view that list items from a content type. I have a block display for this view. I want to be able to put a different background image on each instances of this block.

Ideally, it could show up as an option in Block Settings > Allowed settings so this way every instance would have its own background image.

A second option would be that there is an other option in Block Settings below Block Name, something like Block Bakgorund. This time the same background image would be use as every instance of the block.

An other option would be to create a custom block that has 2 fields, a background image and a entity reference field on the content type my view was listing. Two problems with this, first this come to the same as re-write the functionality of Views, and second I am not sure if I would be able to create a field that is an entity reference on a block created programmatically (module plugin)

Any solution to this or thoughts?


texts: Really confused by Menu Access module in Drupal 6

texts:
I have created a new role named 'moderator' to give lower access than main admin to some persons. I have created a specific navigation menu for this role. This role needs to have permission to create menus but I don't want it sees the default drupal main navigation menu.

I searched for this issue and found the 'Menu Access' module to have more control on menus. I installed it but I am really confused by it. I have set create/edit/delete menu and item menu permission for moderator role in permission page.

I also set those permissions in build/menu page. Then I edited default site navigation and unchecked the permission for moderator role. But the moderator still see 'navigation' in the build/menu page.

I use Drupal 6 .

I don't know what the problem is.
Would you help me ?


texts: tell drush to update anything not part of a profile

texts: I'm using an installation profile (open-outreach) and additional modules / themes.  I don't want drush to update modules that are part of the profile, but would like to update everything else.  Is there a command to do this?


texts: Why doesn't "drush --debug en color" show any output?

texts: Running drush en color from the /xampp/htdocs/drupal directory doesn't output anything. The same happens with drush --debug en color. Why?


texts: How to define an entity type within entity_get_info()

texts: Is it possible to define your own entity type so that a call to entity_get_info() returns your new type?


texts:
I created a Drupal 8 site through the manual install process and configured the site through the admin UI for a while. However, I quickly discovered how critical it was to use Composer to add modules due to the prevalence of third-party libraries. But I am getting the following error whenever I try to add any new module, and I will use Drupal Commerce module as an example (note that my production site is currently housed in the /public_html/main directory):

username@mydomain.com [~/public_html/main]# php
/home3/username/public_html/composer require drupal/commerce
Using version ^2.7 for drupal/commerce
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 14 installs, 1 update, 0 removals
 - Installing drupal/coder (8.2.12): Cloning 984c54a7b1 from cache

[RuntimeException]
Failed to execute git clone --no-checkout
'/home3/username/.composer/cache/
vcs/https---git.drupal.org-project-coder.git/'
'/home3/username/public_html
/main/vendor/drupal/coder' --dissociate --reference
'/home3/username/.compo
ser/cache/vcs/https---git.drupal.org-project-coder.git/' && cd
'/home3/username/public_html/main/vendor/drupal/coder' && git remote
set-url origin
'https://git.drupal.org/project/coder.git' && git remote add composer
'https://git.drupal.org/project/coder.git'

Cloning into '/home3/username/public_html/main/vendor/drupal/coder'...
done.
fatal: unable to create thread: Resource temporarily unavailable
fatal: cannot repack to clean up

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--
no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-
with-dependencies] [--update-with-all-dependencies] [--ignore-platform-
reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--
optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader]
[--] [<packages>]...

Thanks for any help.


texts: The requested page "/http://.. could not be found. (puts slash in front of URL)

texts:
All of a sudden I cannot login because it says
The requested page "/http://testsite.com/user/login" could not be found.
It puts a slash before the URL

I have no idea where that comes from.


texts: Render paragraph reference field in page.html.twig

texts:
In page.html.twig I want to show a paragraph reference field which contains a left and right text_field.

The name of the reference field in the node is: field_intro. That field is linked to a paragraph type named: text_left_right

Using below code I can render the paragraphs, but if I add an extra field to the paragraph type, it is not updated. I would like to render all fields, even if I add a new field in the future.

That is not going to happen with this piece of code:

{% for item in node.field_intro %}
  {{ item.entity.field_left.value }}
{% endfor %}

I found a lot of answers for rendering in node.html.twig but not in page.html.twig.

UPDATE after below comments and answer:
It is not recommended to print fields in a page.html.twig page. Better use views or blocks to establish what you need. And if you want to use templates, use node.html.twig.


texts:
Im trying to add a button to the toolbar for my module. Now I know I can just it in the menu and blah blah but I want it to make it when the module is activated. I think im on the right track using hook_menu however it doesn't exactly specify the callback to do this.

This is what I have so far....

function mysite_form_menu() {
$items = array();
$items['admin/config/mysite_form/ads'] = array(
    'title' => 'mysite Ad\'s',
    'description' => 'Allows administrators to adjust ads.',
    'page callback' => 'ads_page_callback',
    'access callback' => 'current_user_hide_tabs',
    'page arguments' => array('ads'),
    'access arguments' => array('administer editor mysite settings'),
    'file' => 'thank_you_ads.inc',
    'file path' => drupal_get_path('module', 'mysite_form'),
);
}
function current_user_hide_tabs() {
  global $user;

  if (isset($user->roles['3']) || isset($user->roles['5'])) :
  return true;
  else :
  return false;
  endif;

}

This is a image of the toolbar I am talking about so there is not any confusion.


texts: Module: Extend "Authoring information"-tab and adding new field to it

texts:
I'm looking for a way to attach a custom field of my module to "Authoring information"-tab.

Thanks for any hint


texts: Is there a way to know the view type from PHP code?

texts:
Is there a way to know the view type (page or block) from PHP code?

if (views type is block) {
  echo "This is a block view.";
}
elseif (views type is page) {
  echo "This is a page view.";
}


texts: Show block on nodes and only for node author

texts:
I am building a simple classifieds style site. Instead of using straight email, I was thinking about creating a simple "make offer" node type. Create a few basic fields (reference to classified listing, message, will buy for X price, would trade, etc...).

Then create a view block and put the nid in to limit those "offer" nodes to only the node being viewed. However, I would like to do two things.

1) Limit the block to only be viewable to administrators and the node author themselves, other users should not be able to see the other offers.

2) Make it so going to /node/{nid} that is an offer content type is hidden from view so users can't just bypass the block and hit the nid of the offer node.

Any help on how to implement this? I am trying to do it with no added modules.

EDIT: The access to the block should be as follows:

Administrators: Should see all "offer" nodes in the block regardless of who they are from.

Listing Author: Should see all "offer" nodes in block.

Offer Author: Should only see "offer" nodes they have submitted to "listing" nodes. They shouldn't see any other "offer" nodes from any other user.


texts: Created custom entity with Entity Construction Kit but cannot filter in Views by taxonomy

texts:
I'm new to D7 but have extensive experience as a site builder in D6.

I created a custom entity type using the Entity Construction Kit(ECK) and then added a bundle with a term reference field using a hierarchical taxonomy and the Simple Hierarchical Select widget.  Everything works fine except when I try to build a view to display the fields and filter by the taxonomy terms selected using the SHS widget.

When you start building the view the preselector screen asks what to show; content, users, my custom entity/bundle, etc.  If I select my custom entity bundle, taxonomy terms don't show up as available for filtering.  If I select content, then my custom entity is not available presumably because content means nodes.

How do I build a view that displays fields from my custom entity and can be filtered using taxonomy?  If I create a custom content type instead of an entity, there's no problem filtering by terms, as expected.  What am I missing?

Tnx,

Jeff


texts: What's the best way to add a form in a node template?

texts:
I already have a node created with some custom fields, I would like to show a specific form in the detail page of the node that i created (using the node.tpl.php file)

Why? because I need to use some values of the node to custom parts of that form

What's the cleanest way to do this?


texts: Hide page title if the image field has a value

texts:
I have a image field (field_image) on my content type. I want to show the image below the header with the node title inside. I am successfully doing that in page.html.twig.

{% if node.field_image %}

{{ node.label }}

{% endif %}

However, the page title is also showing up in the page title block inside of the Header region. I'm trying to find a way to hide the second page title, on the full node view, if the field_image field has a value.

How can I achieve this?


texts: Comparing expired date with current date

texts:
I am trying to compare the current datetime with my duedate to check if the duedate has expired, and run some code if that is the case.
 $d = date(strtotime($deadline->get('field_date')->getString()));
      $duedate = date('c', $d);
 $timestamp = DrupalDateTime::createFromFormat('c', $duedate)->getTimestamp();
      $now = \Drupal::time()->getCurrentTime();
if ($timestamp > $now) {
...

Running this code throws the InvalidArgumentException: The date cannot be created from a format. in Drupal\Component\Datetime\DateTimePlus::createFromFormat()
Am I missing something?


texts: Adding an input filter to automatically replace text with HTML via a script

texts:
I am using Drupal 8 on Pantheon.

This is a website for an ebook.  The ebook HTML was generated using a Perl script that automatically replaces text like this:

APPLE -> HTML including an apple image
ORANGE -> HTML including an orange image

The list of these replacements is kept in a plain text file (there are about 200 replacements), and then there is a relatively short Perl script that does the actual replacing (for the ebook).

Now, I want to use these replacements in my Drupal site.

Following this lullabot tutorial, I created a custom input filter in a custom module.

But now I am wondering about how I should proceed.

In the future, the replacements for the ebook will be changed every month, so I need to make sure that it isn't too painful to keep the ebook replacements and Drupal replacements in sync (ideally, I would use the same files).

So,

Should I try to find a way to call the Perl script from within Drupal, and share the exact same code between Drupal and the ebook?
Or should I rewrite the Perl script in PHP and incorporate it into the custom input filter?
Or should I do something else entirely?


texts: Using commerce module for online payment for just 4 product/services?

texts:
I starting a website which is offering 4 Apartaments to rent. The visitor will be able to make online payments. My question: Should I use the  Drupal Commerce module for this ?

Will I be able to treat each Apartment as a product? I need to include a map and a calendar for each one. Can I accomplish this with the commerce module.

There is no much documentation about this module and it seems complicated....


texts: Wrap html in link based on uri component of other field

texts:
I need to wrap a div in a template file in an a tag whose href comes from a file field. My markup would be something like this:

Title

Sounds easy enough but the uri that I'm given looks like this "public://newsletter/downloads/Issue 95_0.pdf" which renders but when clicked doesn't go anywhere. How can I turn that link into a valid link?


texts: How to provide theme override for stylesheet conditionally included by a module

texts:
I have a module that conditionally includes a stylesheets using #attached on a render array it outputs. (By conditionally I'm meaning that sometimes the module adds the attached css, sometimes not; I'm not referring to conditional stylesheets as in "is it IE9".)

The render array the module outputs includes the following:

$output['#attached'] = array(
  'css' => array(
    'tiles-styles.css' => array(
      'data' => drupal_get_path('module', 'mymodule') . '/css/tiles-styles.css',
      'type' => 'file',
    ),
  ),
);

In my theme, I have css under a css/ directory. I want to override both these, but only when they are required.

It seems that by adding

css[tiles-styles.css][data] = 'tiles-styles.css'

to my theme.info file I can get my file included, and it overrides the
module-provided one. However, doing this also includes this stylesheet on
every page load, which is unnecessary.

Is there a way to override the stylesheet but only if the stylesheet was included in the first place?


texts: How to include fragment (#) in the URL computed by redirect?

texts:
I want to redirect the user to an internal path that includes a fragment (the part of the url that is introduced with a #), e.g.:

/comment/19#comment-19

I know how to build the path without the fragment portion. If $cid is the comment id, this will do it:

$this->redirect($comment->permalink()->getRouteName(), array('comment' => $cid));

But how can I add a fragment to the path?


texts: Drag & drop upload plugin, how to make it multiple

texts:
I am trying to use this module to upload multiple files into a schemma that I created (in a separated module),

https://www.drupal.org/project/dragndrop_upload

$form['file'] = array (
'#type' => 'dragndrop_upload',
'#title' => 'Test',
'#description' => 'Test',
// This settings allows to drop multiple files at once.
'#attributes' => array (
        'multiupload' => '1',
'cardinality' => '10')
);

Seems to work great but it seems to ignore the 'multiupload' and the 'cardinality' arguments,

Any idea what am I missing?


texts: How to implement a button with different redirections?

texts:
I'm setting up a job directory using Drupal 8, together with a team.
It is possible to see it here.

As you can see below, in a screenshot of the site, there's a button called "Add new job":

In a more visual way, this is what I would like to implement:

If the user doesn't have login:

User clicks button
User goes to create account

Else:

User clicks button
User goes to a specific / different page / view

Something is triggering me that we can achieve this like that using Rules, setting on action events, but I'm not sure how.

It can be that I am totally wrong and there's a more straightforward way to do this.

For example, if I was to implement this just with PHP, would redirect a button to one page and in that page, using user sessions sessions and if conditions, would define the content showing up.

I'm not an expert in Drupal neither I'm aware of all of its possibilities. So, any help is appreciated.


texts: Translation showing up in backend but not on display or user registration

texts:
I translated some fields, everything looks fine in the back end. String are successfully translated to French.

However they don't show up for user registration/profile modification, they don't show up on exposed filters or views.

Everything looks fine and translated, but not working...must be a setting? I have tried the language detection, views setting for user language, refreshed strings, updated, cleared cache...


texts: Implementation of hook_file_default_displays() {media module} makes it impossible to export image display settings via features

texts:
This is a issue I am dealing with for days.
It looks like is related to: https://drupal.org/node/1702700

I've created a feature relying on media, file_entity and media_youtube, vimeo... whose main purpose is to embed youtube, vimeo videos etc.

I've correctly set up the file_entity displays weights:
Structure » File types » Video » Manage file display
so that the thumbnails shows ok

    e.g
    "Large filetype icon"   weight: 50
    "Youtube Image Preview" weight: -40.
    {GOOD}

After complete feature export,
"Large filetype icon" weight: 0
"Youtube Image Preview" is set 2.
{WRONG}

I even edited manually the feature's .info and default_displays.inc file with no luck.

Secondly, there are also feature overrides unable to revert.
It looks like somethings alters the file display weights.


texts: How can I change a user's password from the command line using Drush?


texts: Allow editing of only a single field of a node in Panels or a block

texts:
I am working with drupal 7. I have organic groups and cck set up. I want users to be able to only edit the group audience field in an organic group but nothing else. Is there a way where I can only add a group audience edit field to a panel or a block ?

I looked at the form block module, but that provides access to the complete content edit page.

Thanks.


texts: In Drupal 7, What is a good approach to copy the image from one imagefield to another imagefield?

texts:
I'd like to allow the user to upload an image once, and have it apply to 3 other image fields on the same page without requiring the user to submit the form. Afterwards I intend to apply different croppings to each image but that may not be related to this question.

Is there an existing module or solution to this? If not, what is a good place to inject this behavior client side?


texts: When looking at a user's profile page, I'd like to be able to make a phone call to the user whose profile I'm viewing.  Is this possible in Drupal 7?


texts: How do you programmatically include an entity type to a workflow?

texts: I have a workflow to which I want to include entity/content types programmatically since these content types will be included to the system by the installation of the module to which they reside. I'm not sure how to load the specific workflow object and attach the entity type to that via code.


texts: I am using imagefield to make photo albums. Now I want to allow all registered users to upload new images to any photo albums and it should get added to the exisiting album. I do not want to give them permission to edit the node. How can I do this?


texts: Can multi-page webform submission be saved after each page?

texts:
We would like to implement a form on our site that consists of two pages. The first page is the bare minimum amount of information we need to save a valid submission.  The second page is some optional, additional information that supplements the basic information on the first page. If the user fills out the first page, we would like to save the submission, then, if the second page is filled out, update the submission with the additional information.

We are using the Webforms module to manage our forms. I noticed that it has an option to "Save draft" between pages but I don't think this is quite what I'm looking for. The first page should be saved as an actual submission even if they choose not to fill out the second page.

Is this possible with Drupal/Webforms?


texts:
I've installed WYSIWYG for my site editors, but it's also showing up in the comments field box. I don't want my anonymous users to be able to leave comments with the WYSIWYG (but I do want them to comment, with restrictions of course).

I tried looking in People > Permissions and found nothing. I looked through the settings also in Config > WYSIWYG and finally Modules > WYSIWYG.

Anyone know of a way to edit the WYSIWYG permissions?


texts: How to output $variables without loading everything?

texts: I'm trying to debug a drupal 7 site and print_r() the $variables variable, but its HUGE and crashes certain pages when there is alot of data in it. Is there a way to only output the first level of the array without outputting everything inside of it?


texts: Delete content in a user registration field after X number of days

texts:
I am looking for a way to delete the data in a custom registration field (field:transaction_code) after 30 days. How can this be achieved?

Let me explain better. I want users to get the registration code from me. When they have that registration code, their accounts will be valid for 30 days. Once those 30 days are over, the user will then be required to enter a new transaction code. Thus they will need to revisit the registration page


texts: I have a view with 5 results limit and a more link to show all nodes. The more link goes to xxx/yyy/123. Number 123 is the nid of node, that listed nodes are referencing to. On a current page, lets say- xxx/yyy/123 I would like to use another view that can print the name of node with 123 nid. I tried to set a view using default argument - node id from url and use a field with title but it seems that the number from such url it is not picked up as an argument. Can anybody give some advice? Thank you


texts: 128 character limit in Drupal text fields

texts:
I maintain a small module on Drupal.org and I'm having a few problems fixing this issue:

http://drupal.org/node/917340

Is this limit of 128 characters imposed by Drupal Core? Can I do anything in my module's code to work around this limit? Or is it best to suggest that users of my module use something like http://drupal.org/project/maxlength or http://drupal.org/project/skip_validation?


texts:
i have a service that return for me true in the node (article) successfully create and false if something wrong ,  but in the controller i am getting this error 'LogicException : The controller must return a response (success ! given). dans Symfony\Component\HttpKernel\HttpKernel->handleRaw() (ligne 169 de /var/www/html/vendor/symfony/http-kernel/HttpKernel.php).'
can anyone tell me where is the problem in the controller return of my code please ?

service

 public function createArticle()
  {
    $node = Node::create(array(
      'type' => 'article custom',
      'title' => 'article custom',
      'langcode' => 'fr',
      'uid' => '1',
      'status' => 1,
      'field_fields' => array(),
    ));
    $node->save();
    if($node)
      return true;
    else
      return false;
  }

the controller methode

 public function myPageCreate()
  {
    $service = \Drupal::service('mymodule.ran');
    $createnode = $service->createArticle();
    if($createnode)
      return 'success !';
    else
      return 'somthing wrong !';
  }


texts:
I am trying to override a service by using a ServiceProvider Class

class MyModuleServiceProvider extends ServiceProviderBase
{
    public function alter(ContainerBuilder $container)
    {
        // Overrides MessageNotifier class to add loggin facilities to each message.
        $definition = $container->getDefinition('message_notify.sender');
        $definition->setClass('Drupal\my_module\MyModuleMessageNotifier')->addArgument([
            new Reference('logger.channel.message_notify')
        ]);
    }
}

This is out of topic, but FYI, the overrode service "message_notify.sender" is created by the message_notify module pertaining to the message stack modules

As you can see, I am adding an argument (a logger) to my new service

Here is the __construct() method of the parent (overrode) class:

  public function __construct(Manager $notifier_manager) {
    $this->notifierManager = $notifier_manager;
  }

Here is the __construct() method of my new class:

    public function __construct(Manager $notifier_manager, LoggerChannelInterface $logger)
    {
        parent::__construct($notifier_manager);
        $this->logger = $logger;
    }

But for an unknown reason the $logger variable is not an object but an array with one item... and this item is the LoggerChannel object.

Thus this code is not working but the following does:

    public function __construct(Manager $notifier_manager, array $logger)
    {
        parent::__construct($notifier_manager);
        $this->logger = $logger[0];
    }

What am I doing wrong?


texts: Menus, drush uli link, and some images not working after moving site to localhost

texts:
I've just gotten a site I'm supposed to do some work on but I'm having trouble with migrating to a local development environment. I don't have admin access to the site itself, but I do have access to the server. I pulled the database down along with the code base, but I seem to have messed up the file permissions when moving the site because the site loads, but not all the functionality is present.

The site isn't accessible beyond the splash page, and none of the image assets load except the site logo. Accessing any menu links generates a 404. The image that loads has the same ownership and permissions as the image which loads which are myuser:www-data and 640. Initially, no images loaded, but following this post about securing file permissions got the logo loaded.

I am also having issues with accessing the site. Since, I can't access any menus beyond the root, it seems that I can't access the login page either. I've added a user for myself with Drush, and even run drush uli with the the URI provided as a parameter, but the link is inaccessible and returns a 404. I also used the File Permissions module, but it doesn't seem to have helped.

At this point, my next step is going to be setting up a clean install and importing the db through backup and migrate and moving the theme and modules manually, but I'd like to figure out what I did wrong and how to avoid this.


texts: Commerce kickstart related product based on taxonomy

texts: I like to add related products view block to a product. I like to show items what have the same category. I tried the "Content: Has taxonomy term ID" contextual filter, but it do not want to work for me.


texts: how to make node data available in the page.tpl.php

texts:
I want to be able to print the contents of my node tpl up into the outer page region, accessible via the page.tpl.php (or an override). How exactly can I do this?

I originally thought about doing a variable_set in the node.tpl and then getting it in the page.tpl. However, if this would work, I would need to be able to create a template. I tried page--node--gallery-photo.tpl.php, but it doesn't seem to be the correct override.

What this the best way to do what I need to do here?


texts:
The default robots.txt shipped with Drupal contains rules such as this:

Disallow: /user/register/

If I understand correctly, the leading slash means this really has to match the beginning of the path. E.g. a path like /xyz/user/register/ would not match the rule. (Please correct me if I'm wrong)

(For the ending slash I am not sure)

With the language path prefix option, Drupal will have urls like /fr/user/register etc.

It can be assumed that if we want to exclude /user/register, we also want to exclude /fr/user/register and other language versions.

However, a /*/user/register/ might be too generic, as it also would match other urls which we don't want to exclude.

Questions:

Will Drupal's default robots.txt also exclude language-specific versions of the targeted urls? (according to my own assumption it does not).
What would be the simplest / cleanest way to exclude all language versions for a given path?

I think this applies equally to Drupal 7 and Drupal 8.


texts: What does "Entity API" add to the Drupal API, and why would a module depend on it?

texts:
The Entity API module extends the entity API defined in Drupal. In which cases should a module use the API provided from that module? Are modules that implement new entities easier to be written if they depend on the Entity API module?

By "easier to be written" I mean that modules using Entity API would require less code to be written compared to a module that doesn't use Entity API.

I read the project page, but I still don't completely understand the reason to prefer creating a module that depends on the Entity API module, rather than a module depending only from Drupal core code. I understand that a module extending rules and implementing an entity should use the Entity API module; in the first case, the reason is also that the Rules module depends on the Entity API module.


texts: How to remove image script if it has no image?

texts:
I created a block using views.
The fields has image, title and body.

While the article has no image, it still render out the image script and it make a space before the title.

How do it make the image script disappear if there is no article in its.


texts: Admin account has it's own log in form and should not be able to log in in default log in form

texts:
I have this certain problem which I don't know how to start doing this thing.

In drupal we have a log in form (let's call it normal login form) which all users can log in including admin.

So what I want is, to create a log in form for admin only. Which I already made it.

But the problem lies here, the normal login form should not let the admin proceed if the admin log in at the normal log in form

Here's a screenshot for it.

As you can see, that's the normal log in form. If the admin logged in to that, it should not let them proceed since they have their own log in form. All I want is only normal users can access can log in in this form.

Any possible solution for this?


texts: error_get_last() returns NULL after valid error in Drush

texts:
I have the following command callback function defined in my .drush.inc file:

function drush_bv_ftp_products() {
  echo $aadfadf;
  var_dump(error_get_last());
}

Assume hook_drush_command() is properly implemented and has an alias of 'abc'.

When I run drush site.local abc I get NULL for output.  What I would expect to see is similar to:

Array
(
    [type] => 8
    [message] => Undefined variable: aadfadf
    [file] => ...
    [line] => ...
)

I'm running php 5.3.28 so error_get_last is there.  Any thoughts from the Drush masters out there as to what could be going wrong here?


texts: Why are there 2 ways to handle configuration?

texts:
In Drupal when we are working with read-only config we use

$page_cache = \Drupal::config('system.performance')->get('cache.page');

Why this static call for read-only object?

and when we use working with a config where both read and write is possible. we use this service 'config.factory'

$config = \Drupal::service('config.factory')->getEditable('system.performance');
$config->set('cache.page', ['enabled' => 1, 'max_age' => 5]);

what leads to this design?


texts: How do I validate form elements via onblur events?

texts:
I am trying to validate a form element when it loses focus. But I am having issues calling the validation script.
I have tried both:

drupal_add_js('(
    function ($)
        {
        $("#edit-field-organization-url").blur(
            function()
                {
                //alert(\'jQuery Exec!\');
                $(this).validate();
                }
        );
        }(jQuery));', 'inline');

and

$form['field_organization_url']=array(
    '#type' => 'textfield',
    '#title' => t('Website URL'),
    '#weight' => 2,
    '#size' => 60,
    '#maxlength' => 128,
    '#value' => 'www.google.com',
    '#description' => t('Enter website URL.'),
    '#element_validate' => array('hook_node_validate'),
    '#attributes' => array(
        //'onblur'=> '$(this).validate();'),
        //'onblur'=> 'alert(\'jQuery Exec!\');')
    '#required' => TRUE
    );

but neither work. I'm guessing this isnt the proper drupal way to call the validation functions.

#########################

UPDATE

#########################

I still cant seem to get it working. The validation code now runs every time the page is loaded and doesnt seem to be tide to the onblur event even though I have it set in the clientside_ validation module:

  file - template.php:

function THEME_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'custom_content_type_node_form':
$form['custom_content_type_node_form']=array(
'#type' => 'textfield',
'#title' => t('Website URL'),
'#value' => 'http://www.google.com',
'#description' => t('Enter website URL.'),
'#element_validate' => array('hook_clientside_validate_url'),
'#required' => TRUE);`

file - custom.module:
`function hook_clientside_validation_rule_alter(&$js_rules, $element, $context) {
switch($context['type']) {
case 'element_validate':
if (in_array('hook_clientside_validate_url', $context['functions'])) {
hook_clientside_validate_url($js_rules, $element);
}
function hook_clientside_validate_url($js_rules, $element) {
//validation code here
}`


texts: How to show Checkboxes with Fulltext Search Filter Exposed?

texts:
I have created a simple search with three filter options of "Contains any of the word", "all of the words" and "none of the word", as shown in the figure below.

I used Search API, and later created a view out of it.

For an exposed filter, I just chose "FullText Search" and exposed it as follows:-

It shows me a page likes this:-

Now, it works fine, but I want checkboxes instead of the dropdowns. For that I installed Better Exposed Filters, but it doesn't show me the option to show checkboxes ... as shown:

What am I missing that this is not allowing me to show Checkboxes :(. I will be very thankful for your help. I just need to convert them to checkboxes.


texts:
I have a views jump-menu of PDFs. I'd like the PDF to open in a new window when the user clicks the "go" button on the view.

I've tried using javascript to set the form's target attribute to _blank. It is showing in the markup, but it has no effect on the behavior of the form submission.

Any ideas on how to do this?


texts: A View for Referenced and Referencing Nodes

texts:
Possible Duplicate:
  How to implement two way node references?

I am working on an employee directory, with the data being imported from Active Directory.  I am creating profile content nodes, and using a node reference field to indicate who the employee's manager is.

I can create a view that will show me the emplyoee's manager, and information from the manager's node (through a relationship), but I do not seem to understand how to make a view that will display a manager's employee's.

Help, pointers, doc's or examples are greatly appreciated!


texts: Put node url in href to all img tags with jquery

texts:
I have a drupal site and i want to put all nodes url to all img tags! With bellow code can do this but all img linked to the same post url in the main pages, because take the link of the final post and put to all img. The Code i added to node.tpl.php file.

<script>
      jQuery(document).ready(function($) {
      $(document).ready(function() {
      $('img').wrap("<a href='<?php print $node_url; ?>' </a>");
    });
    });
</script>

Thank you


texts: How can I show an Ad popup after search form is submitted?

texts:
How can I place an Advertisement after clicking the search button and before showing the search results?
can anyone help me with this stuff?


texts: How to load a webform via ajax inside custom JS?

texts:
I'm trying to load a webform block via ajax.

Right now I have:

$.ajax({
    url: '/form/contact-us',
    success: function (response) {
        console.log(response);
    },
    error: function (error) {
        console.log(error);
    }
});

How do i get the form as a block and not by the full page/node?


texts: Display an Array as a List inside a Table

texts:
I have an array that have a created with items in it that I want to populate a cell in a table.  In my case this is a table of Orders in Ubercart and have created an array, called $models that is populated with the Model numbers of the line items in that order.  What would be the best way to display this array in my table?

Currently,

$rows[] = array(
  ...
  array('data' => $models),
  ...

display's nothing in the Model column.