texts: Drupal 7: Modifying the view page and edit form of a content type programmatically

texts:
a Drupal newbie here trying to create his first module for Drupal 7.

In my site I've created a new content type (machine name: abstract) from the site's admin's front-end. A user can add a new instance of this content type by using a form I've defined using the FAPI. In this form's submit function I do the following:

function form_add_abstract_submit($form, &$form_state) {

  global $user;

  $node = new stdClass();
  $node->type = 'abstract';
  node_object_prepare($node);

  $node->title = $form_state['values']['abstract_title'];
  $node->language = LANGUAGE_NONE;
  $node->uid = $user->uid;

  // ... fill the rest of the node's fields here [...]

  if($node = node_submit($node)) {
    node_save($node);
    // Not sure about this way of defining the path to the created node
    $path = 'abstract/' . $node->nid;
    $node->path = array('alias' => $path);
    node_save($node);
    drupal_set_message(t('Abstract submitted');
  } else {
    form_set_error('description', t('ERROR'));
  }

  $form_state['redirect'] = 'index.php';
}

As shown above, I define the path to these nodes to be 'abstract/[its-node-id]'. Then, when a user visits this URL I'd like to show two tabs, one allowing the user to see the node's fields and another linking to a form to edit it. I've tried to implement it by adding the following three menu items in my hook_menu function:

$items['abstract/%'] = array(
      'title callback' => 'abstract_page_title',
      'title arguments' => array(1),
      'page callback' => 'abstract_page_view',
      'page arguments' => array(1),
      'access callback' => TRUE,
      'type' => MENU_CALLBACK,
  );

  $items['abstract/%/view'] = array(
      'title' => 'View',
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -10,
  );

  $items['abstract/%/edit'] = array(
      'title' => 'Edit',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('my_module_form_abstract_edit', 1),
      'access callback' => TRUE,
      'file' => 'my_module_forms.inc',
      'type' => MENU_LOCAL_TASK,
  );

However, if I visit abstract/[a-node's-id], my abstract_page_view function is not being called and the default view for rendering my content type is displayed. The 'Edit' tab on this view also links to abstract/[the-node's-id]#overlay=node/[the-node's-id]/edit, not to abstract/[the-node's-id]/edit, as I'd like to.

What am I doing wrong? Should I programmatically define my content type instead of doing it from the admin's backend or is my problem somewhere else?


texts: duplicate terms added by taxonomy_term_save

texts:
Doesn't taxonomy_term_save() check if terms are being added in duplicate ? I have the following code -

function custom_create_taxonomy_term($name, $vid) {
  $term = new stdClass();
  $term->name = $name;
  $term->vid = $vid;
  taxonomy_term_save($term);
  return $term->tid;
}

But whenever I pass it a $name- which already exists in that vocabulary, then also a new entry is made in the database and there are 2 tids for the same term.


texts: How to find out a node's comment status (open, closed) from node ID?

texts:
Having a view of comment fields here that is embedded into another view via Views Field View module. The comment view has a contextual filter: the nid. Works quite nice.

Now I want to hide the view if comments ain't allowed (per node). Of course I have the node's ID as $argument. How can I check the comment status from that to specify the validate criteria?


texts:
I've created a custom formatter (display) for filefield but I'd like to add a settings page per field for width and height.

Currently my code only consists of the bare minimum to get the formatter to work (which it does). However I'm currently hardcoding width and height at the hook_theme() level.

I've not found any examples of setting pages for formatters only for custom fields. I suspect that it's not possible to do this for a formatter and I'd have to define my own field rather than formatter. I could create a global admin page and loop through all fields and set the settings as a variable but that might become an issue when upgrading it to 7.

Any feedback or ideas would be great.


texts: I have created a product teaser using views and included images as one of the fields (by including  *(Products referenced by field_product) Field: Images* ). In the settings for  " (Products referenced by field_product) Field: Images " I linked the image to "content". But the result is something different. Instead of linking the image to "original content", Drupal is linking it to the edit page of that content. Please help me fix this problem. I want my "product Image" to link to its "original content(the product itself)".I Followed this procdure to create product teaser (Advanced Product Display Listing using Views).


texts: Drupal Commerce: Prices on Variations not displayed when selecting a variation

texts:
I am using Drupal Commerce Kickstart 2.

When a user selects a value from the size drop down (variation), the price and other attributes do not update on the product display. I need to have something similar to this -> http://demo.commerceguys.com/ck/storage-devices/commerce-guys-usb-key. You'll see that when you select a memory size for the USB product the price will change.

Is this a built in feature for Drupal Kickstart or something they built through a custom module?

I have a product variation with a product attribute of Size (a user can select which size they want). I have product details such as SKU, Price, and Package.

I also have a product display set up by default, which displays my product variations as my Add to Cart form.

In the following picture you will see that even though I have 5 oz. selected all the details displayed are for the 10 oz. variation.

I need to know how to update these details based on which variation the user selects.

Any help on this is appreciated


texts: How to get Panelizer to only affect a specific node

texts:
I have Panelizer installed on my Drupal 7 site. I would like to use Panelizer for only specific nodes and not have it apply on all my nodes (as it currently is). Reading the documentation it seems it is possible to do this but I can't get it to work.

In Admin->Structure->Pages I have the node_view enabled, and I see an entry for my particular node there as well (page-videos_view with the correct url path). If I disable the node_view, then Panelizer is effectively disabled as it doesn't apply any panels even though the view I want is still active.

I assume I am missing a setting somewhere but don't know what it is. Can anyone help out?


texts: Removing orphaned entries in DB from deleting modules

texts:
I made a custom module for drupal 8 and ended up just deleting the folder completely. Now when I try to enable other modules I'm getting a warning message that I'm missing that module.

How can I remove these orphaned entries in the database? Which table contains the module data that drupal checks upon initializing?


texts: When an administrator (except user 1) editing a user how to hide "administrator" under role in a user edit page in D7 site? or how to prevent assign a role of administrator while editing a user?


texts:
I have Drupal 8 website created with composer. I put all files to my remote server in the sitename/www/ but my page won't load. I receive such an error:

  Fatal error: Class 'Drupal\Core\DrupalKernel' not found in /home/bx273629/drupal8.com.ua/www/index.php on line 16

I think it is because I created that website with the Composer. Does any body know how to deploy correctly such a websites?

Website perfectly works locally!

I have such an error:

  'Fatal error: require(): Failed opening required '/home/bx273629/drupal8.com.ua/www/../vendor/autoload.php' (include_path='.:/usr/local/pear/php56') in /home/bx273629/drupal8.com.ua/www/autoload.php on line 17'

And on the line 17 of these file I have such a string:

return require DIR . '/../vendor/autoload.php';

It is from the outer folder which was installed with composer.


texts:
I have a taxonomy called services and want to list out all the terms. I can load the vocab with

 $vocabulary = taxonomy_vocabulary_machine_name_load('Services')

but cannot seen to get all the terms out.


texts: What could cause remote drush commands to fail with ssh errors when ssh works in all other cases?

texts:
I have public and private ssh keys on all of my three servers (dev, UAT, & production) so I can log in remotely, or from one to another.  Everything is working perfectly for the ssh and scp commands.

It does not work, however, for Drush.  If I execute drush @dev status from UAT, for example, I get the server's banner saying the system is "to be used by authorized users only blah blah blah", and then I get

  Permission denied (publickey,password,keyboard-interactive).

My ~/.drush/aliases.drushrc.php file contains:

# Development #
$aliases['dev'] = array(
  'uri' => 'http://default',
  'root' => '/var/www/vhosts/dev.www.company.com/current/',
  'remote-host' => 'companya0.company.com',
  'remote-user' => 'myusername'
);

# UAT #
$aliases['uat'] = array(
  'uri' => 'http://default',
  'root' => '/var/www/vhosts/uat.www.company.com/current/',
  'remote-host' => 'companyc6.company.com',
  'remote-user' => 'myusername'
);

# Production #
$aliases['prod'] = array(
  'uri' => 'http://default',
  'root' => '/var/www/vhosts/www.company.com/current/',
  'remote-host' => 'companyc1.company.com',
  'remote-user' => 'myusername'
);

ONLY Drush has any problem using my ssh keys.
What could be preventing it from working?


texts: How to show a map of the User's Location in the User's profile with Address Field and Geofield

texts: So, the location + Gmap module showed a map of the User's address in the user's profile once it was geocoded. Is there an equivalent widget that will show a map of the user's address in the profile itself?


texts: How to check spelling of user typed text in a form textbox

texts:
I built a form which have a text field for take input from user.

Now I want to implement a spell check module or something which can check spell when user type some word or sentence in the text field. I Googled a lot but didn't find any result for my search. Find spell checker for WYSIWYG editor but not for my search.

How can I implement spell checker for text field in a form.


texts: How do I require the user submitted content to be approved before it is published?

texts: I need to have content that is submitted by users of a certain role to be approved by an administrator before it is published. I thought this functionality was build in already, but I just can't seem to find where it is.


texts: Display node author picture through tpl file

texts:
I am writing my custom node--blog.tpl.php for my Drupal7 based site. I want to print the author image of the blog so in my tpl file i include the following:

$user = user_load($user->uid);
  print theme_image_style(
                array(

                    'path' => $user->picture->uri,
                    'attributes' => array(
                        'class' => 'in-blog-user'
                    )
                )
            );

However, it does not display any image and i get a error as :

The requested page "/sites/default/files/styles//public" could not be found

What am i doing wrong?

Regards

PS: my pictures directory is "pictures"


texts: Webform component weight within a Fieldset

texts:
I am creating a settings page for a specific Webform in version 6.x-3.x which finds all select option components in the form and creates a numeric textfield setting correlating to each select option. The Select Options are in fieldsets. On the settings page, I want the numeric textfields to show up in the same order that the select options show up in the form.

db_querying the right select options in the webform_component table is working fine, but the select options show up out of order when ordering by weight.

For example:

The Webform

Fieldset 1
- Textfield 1
- Select Option 1
- Select Option 2
Fieldset 2
- Select Option 3
- Select Option 4

db_query('SELECT * FROM drupal_webform_component WHERE TYPE = "select" AND nid=123 ORDER BY weight'); generates results like this:

Select Option 1
Select Option 3
Select Option 4
Select Option 2

How do I order Webform results of components within fieldsets to reflect the order they appear on the form? What would the db_query look like?


texts: How do I exclude the current user from the search?

texts:
In a normal Views user search, you can simply add a User: Current filter to remove the logged-in user from the search results.

I have a Search API Views search of a Solr index of users, and I want to do the same thing.  However, the User:Current filter is not available.  How can I achieve the same function?


texts:
I am trying to display thumbnails of uploaded images in a custom form. While I can see the images in my form array after uploading them to the tmp directory in Drupal, here is what I am trying to use to display them:

$url = file_create_url($form_object->uploads[$key]->uri);
$output .= '
'.theme_image_style(array('style' => 'form-preview', 'path' => $url)).'
';

While $url points to the file resource, I cannot show a resized image for the life of me. If I use an img tag and put $url as its source, the images do show up, but they are huge.

Can I not call theme_image_style() because these are just temp images and not permanent? I can make them appear with theme_image().


texts:
How is field collection an advantage? You can do the same thing with a new content type pointing to the parent with an Entity Reference.

Maybe someone can break down some situations where each one would be better.

Say for Task -> Files, would field collection be better or a new content type with an Entity Reference?

Say for each file you needed more some other data about that file, sounds like a plan for a new type with an Entity Reference, but you can embed a field collection inside of a field collection.

I enjoy how Drupal has many ways of doing the same things, but I can't find much on how different or similar these two solutions are.

Maybe someone can help explain?


texts:
Zen is a great theme and comes by 3 columns gris as default and even when i read the documentation i don't know how to change the grid system to 2 columns 30%- 70% for ex..
Can you help me please.


texts: Can't see the "help" hook on the Modules admin panel

texts:
I'm reading Drupal 7 Module Development and trying to learn module development. I've created their example module 'first' and I'm not seeing the 'help' link.

Here is what I have so far...

/sites/all/modules/first/first.info

name = First
description = A first module.
package = Drupal 7 Development
core = 7.x

/sites/all/modules/first/first.module

<?php

/**
 * @file
 * A module exemplifying Drupal coding practices and APIs.
 *
 * This module provides a block that lists all of the
 * installed modules. It illustrates coding standards,
 * practices, and API use for Drupal 7.
 */

/**
 * Implements hook_help().
 */

function first_help($path, $arg) {
  if ($path == 'admin/help#first.') {
    return t('A demonstration module.');
  }
}

Now then... according to this book, when I install/activate the first module, I should see a () Help link to the right of my module name in the Modules admin panel.

I don't. What could be stopping this link from populating this screen. I get () Help links for all of the other modules. But not mine.

I created a subdomain on my server and installed Drupal to test with a fresh Drupal install. The help link shows up and works on the new install. So now I'm trying to wrap my head around what could be killing it on my other Drupal site? Could Devel? Coder? This is very weird.


texts: Styling first results from a View differently from the rest

texts:
We have a page that needs to render an unspecified number of nodes, newest one first. The first result needs to be displayed as a very large "hero unit", the next 4 results as a group of four large results and the rest in a more compact form.

#########################
#                       #
#       Result 1        #
#                       #
#########################

############ ############
#          # #          #
# Result 2 # # Result 3 #
#          # #          #
############ ############

############ ############
#          # #          #
# Result 4 # # Result 5 #
#          # #          #
############ ############

Result 6      Result 7
Result 8      Result 9
Result 10     Result 11

I've been trying to style this by displaying the View as unformatted fields, but the nodes are still rendered separately from the structure, making it hard (or impossible?) to specify how we need them rendered.

Is there some module that will help us style the View with more precision or is there some feature in Views that I have overlooked?


texts: Programmatically update remote video thumbnail

texts:
Scenario: YouTube video was previously unlisted, so thumbnail not retrieved and now needs to be, or chosen thumbnail has been changed and needs updating.

There are a couple of core issues open on this - see below (e.g. adding an 'Update Metadata' button to the Media view), but they're dependent on other open issues such as batch API/bulk operations and neither is at all close to completion.

In the meantime, is there a simple way to do it in code, given updateThumbnail() is a protected method?

#2983456 - Expose triggering update of media metadata + thumbnail to end users

#2878119 - Whether queued or not, update the media thumbnail and metadata before beginning the entity save database transaction


texts: Send Notification to users with username and password

texts:
I have imported a set of user information into drupal website and all the users are active.

Now I need to generate the password for each user and send an email to them to notify them that the account has been created.

I found the code here which shows how to update the password of the user by code.

$account = user_load(array('uid' => $userdata['uid']));
$password = user_password();
$username = $userdata['username'];
$updates = array(
  'pass' => $password,
   'roles' => array(
    <rid> => '<role title>';
 ),
);

user_save($account, $updates);

Now how can I notify the users of their new username and password.


texts: best practice: what directory should the theme be located for a site install profile

texts:
I am building a site install profile. Trying to wrap my head around the file structure.
I am creating a Drupal 7 install profile with a sub theme off of omega.

Is it better practice to put the theme in the

profile/themes

or

sites/all/themes


texts:
I would like to modify the date popup structure, in the image below you can see how date module builds the element. Drupal's default label is hidden, and it generates other to display the title. I want to show that label, and hide the date module label. Where should i modify this? Using some hooks in a .module, create a custom template or just overwrite it with css? Thanks all for help!

PD: This change must concern to every page in my site.


texts: How to create a chart about the number of node views per day (since last week)?

texts:
I want to show my users a chart that lists the node views hit for that day (Content statistics: Views today), something like this:

So the user can see how many views each node of his had in each day of last week!

I'm using the Charts module for making the charts, using the Google charts API as the charting engine (library) and it works just fine.

Issue is, that I have no idea if it's possible to list last 7 days date in Views at all or not, let alone integrating it with Charts.

Any suggestions about how to do so?


texts: Commerce - check if this very product in presented in user's previous orders

texts:
I use drupal commerce trying to build a website which sells content (nodes with restricted access). The thing is that, if user have bought the product once, he shouldn't have a possibility to do it again.

Currently i'm using form_commerce_add_to_cart_form_alter to check if user has already added this product to cart and if yes - hide "Add to Cart" button to prevent doing it twice and set a text that this very product is already in the cart. It works totally fine.

What I want to do next are two things:

1) to check if this current user has this product under active (not canceled and not complete) order, and if yes - hide "Add to cart button" and set a text that this product is under order processing at now.

2) to check if this current user has purchased this very product ever before and if he has, do the same trick - hide "Add to cart button" and set a text that User already owns this product.

My problem is that I'm very new to commerce and unfortunately totally don't understand how can I get all orders for the current user and check for some product IDs there... Will be very appreciated for any advice or a tip. Thanks a lot!


texts: Updates: keep panels pages, views, etc.. updated via hook_update_n?

texts:
im having a little trouble keeping a project update.

I track the code via a private git repo, and for each update I follow those steps (first on stagin, then on production):

update all the 3rd pars modules (from drupal.org)
Update database (via drush updb)

Then if everything is ok:

update my modules (via git repo)
update database (drush again)

All works perfectly, except for pages/views exported via Features module: in my module i hav a function like this:

/**
 * Implements hook_default_page_manager_pages().
 */
function mymodule_default_page_manager_pages() {
    // Second page...
    $page = new stdClass();
    // page definition, display, etc..
    $pages['page_machine_name'] = $page;

    // Second page...
    $page = new stdClass();
    // page definition, display, etc..
    $pages['page_machine_name'] = $page;

    return $pages;
}

The structure is the same for views.

I noticed that if i update that function changing something in a previous declared (and imported) page (add a pane, change a configuration on a content, etc..), this one wont get updated! (yeah, i flushed the cache different times both via UI and via drush)

Am I doing something wrong? There is a specific way to update those elements?


texts: Show latest changes in node "View" tab while using Content Moderation

texts:
I had been trying a lot to display latest revision into view tab irrespective of its state, so if a node is in "Draft" state I still want it to be displayed under "View" Tab rather than "Latest version". I had tried using hook_ENTITY_TYPE_view, hook_ENTITY_TYPE_view_alter and even tried in template_preprocess_node hook but no luck. I was able to load latest revision but not able to set it using below code in preprocess,
function mytheme_preprocess_node(&$variables) {
  if ($variables['node']->getType() == 'news' && $variables['elements']['#view_mode'] = 'full') {
    $node = $variables['elements']['#node'];
    $vid = \Drupal::entityTypeManager()->getStorage('node')->getLatestRevisionId($node->id());
    $node = \Drupal::entityTypeManager()->getStorage('node')->loadRevision($vid);
    $variables['elements']['#node']  = $node;
  }
}

Also tried with below code from a custom module,
function mymodule_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {

  $node = Node::load($build['#node']->id());

  if ($entity->bundle() == 'article' && $view_mode = 'full') {
    $revision_ids = \Drupal::entityTypeManager()->getStorage('node')->revisionIds($node);
    $latest_rev_id  =  end($revision_ids);
    $node_new = node_revision_load($latest_rev_id);

    $view_builder = \Drupal::entityTypeManager()->getViewBuilder($entity->getEntityTypeId());
    $storage = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId());
    //$node = $storage->load($build['#node']->id());
    $build_new = $view_builder->view($node_new, $view_mode);
    //$output = render($build);

    $build['#node'] =  $build_new['#node'];
  }

}

Please if anyone can point me in a right direction it will be very helpful.
Thanks in advance.


texts:
I followed a tutorial to create an admin menu: Adding sub menu to Management menu. However I still cannot see my new menu on my page. Then I download a module named Administration menu. I found my new menu item on the navbar when I use this module. Here is the screenshot:

All the menu in pink circle are old, the only new menu item is called "Product Substitue." But I cannot find on the page.

Does anyone know how to fix this? Or any tutorial? Thank you~


texts:
On my site, the visitors can download whitepapers as pdf. I would like to gather some information before handing over the file.
Updates: the downloads should be open to unregistered users

What I tried:
I looked around for modules. Some of them seemed to do something like this but were Drupal 7 only, like Webform Protected Downloads.
On the site I can make use of the Webform module as per this question. I could make a form with a redirect page where the file can be downloaded. However, as there are many whitepapers, for each one there should be made a separate form and download page.
Update: in Webform it is possible to stay on the same page and output a thank you message with download link, so that will limit the effort somewhat.

Is there a simpler way to solve this?


texts:
I have a client that is looking to measure how their drupal user accounts grow over time.

I currently have the http://drupal.org/project/chart module with the System Charts sub module enabled and this does provide a nice pie graph of the users as the system currently stands.

Has anyone found a solution for this? Integration with the charting API would be nice too ;)


texts: I'm creating a community site where users should be able to create events and participate in other users events. I guess there are some options, but which modules do you think would work as candidates for building such a site?


texts: Not sure if this is the correct terminology to explain my question, but I have a client on Drupal 7. My client organization is related to another organization that possibly has a Drupal 8 site. There is a content type that is very similar to both organizations, but the other organization has what seems to be a field group of two fields that allows for multiples in the group, as opposed to the fields. I have used field grouping quite frequently in Drupal 7, but can I duplicate that function?


texts: Drush site install break when a custom commerce feature is enabled, why?

texts:
The D7 site i'm working has a feature that includes two custom product types, amongst other things.  A custom feature gets auto-detected and added as a dependency because it contains a rule on one of the product types.  Another feature added to the site install profile contains the permissions to those types.

After i exported the features and tried to install the site again, it breaks because:

the product types are do not get created, i expect this log entry to show but does not:
WD features: Rebuilding feature_name / commerce_product_type
Which, i'm guessing, is when the types get created from the feature.  That log entry shows on a successful build (see below).
consequently, the permissions feature causes a fatal error when trying to insert the types permissions into the db, since they don't exist and not defined by a module (from commerce_entity_access_permissions).

The solution for the fix is to manually remove the auto-detected feature with the rules.

I assumed that there's something wrong with that feature but can't think of what.  Has anyone experienced something like that?


texts: Insert 'select all' choice in a particular level in Taxonomy Term Reference Tree Widget

texts:
I'm using D7. And I have a big term reference tree with Term Reference Tree. There are so many terms in the tree that I'd like to put 'select all' choice in it for usability.
Is it possible to put 'select all' choice in some level?

Let me show you the example of what I want to do below...

(Ex)
Let's say there is a vocabulary whose name is 'Food'

[Food]
-Vegetable
--Select All
--Pumpkin
--Carrot
--Radish
--Potato
-Fruit
-Fish

So, what I want to do is...if you check the 'Select All' under the Vegetable level, the all of choices(Pumpkin, Carrot, Radish, Potato) will be checked.

I searched the way to do that but couldn't find the answer. Any tips would be appreciated. Thank you.

Added:
I found you can do something like I want to do by the setting below...
-Start minimized =>Whichever
-Leaves only =>Off
-Select parents automatically =>On
-Cascading selection =>On

With the setting above, you can chose all choices by checking the parent level.
But, I also wanted to enforce users to chose the deepest level.
With the setting above, users don't always have to chose the deepest level...
So, correctly, I'd like to say I want to put 'select all' and enforce users chose the deepest level.
I still need your help. Thank you.


texts:
After a few attempts browsing the web, I don't figure out how to download HTML from a given url, and create node content from it.

What I would achieve is quite simple :

Have a link-like field in my content type
The source code of this page is downloaded either in the Body of the content, either in a MHT-like file
Viewing the node displays it either in the bodyeither` in an IFrame.

The content creation would happen mostly from a dedicated script creating a new content through Drush, filling only the Title and the link field.

The main goal of this is to save short-lived webpages in a drupal website, and ideally being able to index them.

I'm open to any ideas : module, coding, whatever.
Don't hesitate to give me advice !

Thanks


texts: Understanding the source of a 'Failed to get available update data' errors

texts:
When manually checking module updates for a customer site all modules update OK (and are updating fine) but there is an error saying "Failed to get available update data for 2 projects."

I suspect this is due to a custom theme and/or module that cannot update but with quite a few modules on this site. How can I identify what these "2 projects" are? I can't see anything on the admin site. I tried drush with pm-update with verbose and debug but can't see anything.

I'm assuming once identified that the next step would be to lock those modules.


texts: How to add a menu tab to a user profile?

texts:
I want to create an additional tab (dashboard) on my site's user profile page. There is a Homebox module installed and a dashboard was created for users. The dashboard is accessible by user/dashboard. How can I do this? I tried doing it as below:

New module created with name add_menu_tab
In add_menu_tab.module file I wrote as below
I want to create an additional tab (dashboard) on my site's user profile page. There is a homebox module installed and a dashboard was created for users. The dashboard is accessible by user/dashboard. How can I do this? I tried doing it as below:
New module created with name add_menu_tab
In add_menu_tab.module file I wrote as below:

code :

function add_menu_tab_menu() {
     $items['user/dashboard'] = array(
    'title' => 'Dashboard',
      'type' => MENU_LOCAL_TASK,
      'weight' => 7
    );
    return $items;
  }

The menu is still not visible in user profile
What should I do?


texts:
I am creating an install profile that requires, among other things, a slew of Features. Because of the intricacies of the project, which is a multi-site, I have in sites/mysite.com/modules/custom_features 3 different categories of features, each in its own folder: my_install_profile/, my_other_install_profile/, and common/.

Drupal seems to be finding all of the modules that my install profile requires just fine, except one. It's expecting to find it in sites/mysite.com/modules/custom_features/my_install_profile/ but the module actually lives in sites/mysite.com/modules/custom_features/common/.

I've triple-checked the install profile, and any dependent modules. I can't find anything path-specific, or specific to this module, that might be causing the confusion.

It doesn't report that the module is missing at the beginning of installation, but partway through I get this:

Warning: include_once(umn_import_content_type.features.inc) [function.include-once]:
      failed to open stream: No such file or directory in include_once()
      (line 7 of /www/sites/mysite.com/modules/custom_features/my_install_profile/my_feature/my_feature.module).

Warning: include_once() [function.include]:
      Failed opening 'my_feature.features.inc' for inclusion
      (include_path='.:/Applications/MAMP/bin/php/php5.3.14/lib/php') in include_once()
      (line 7 of /www/sites/mysite.com/modules/custom_features/my_install_profile/my_feature/my_feature.module).

Why is Drupal looking for this in the wrong folder?


texts: How to integrate track field changes with views

texts:
I have enabled [Track Field Changes][1] module and walk through

admin->system->field changes here I have check the field for which I want to track....and I created view for that but I don't see anywhere changes I made for that particular field....can anyone know this where I am going wrong?


texts: How to create a filter condition autocomplete for entity reference field or normal?

texts:
I am trying to create a filter condition for entity reference field in views, i tried by using rendered entity option it is showing dropdown for filter condition. I need autocomplete or it should be without dropdown and autocomplete (plain filter field).

It should apply after giving full value in filtercondition?

Any suggestions..

/* Filter criterion: Content: Cage ID_VBC (field_cage_id_vbc) */
$handler->display->display_options['filters']['field_cage_id_vbc_target_id']['id'] = 'field_cage_id_vbc_target_id';
$handler->display->display_options['filters']['field_cage_id_vbc_target_id']['table'] = 'field_data_field_cage_id_vbc';
$handler->display->display_options['filters']['field_cage_id_vbc_target_id']['field'] = 'field_cage_id_vbc_target_id';
$handler->display->display_options['filters']['field_cage_id_vbc_target_id']['group'] = 1;
$handler->display->display_options['filters']['field_cage_id_vbc_target_id']['exposed'] = TRUE;
$handler->display->display_options['filters']['field_cage_id_vbc_target_id']['expose']['operator_id'] = 'field_cage_id_vbc_target_id_op';
$handler->display->display_options['filters']['field_cage_id_vbc_target_id']['expose']['label'] = 'Cage ID';
$handler->display->display_options['filters']['field_cage_id_vbc_target_id']['expose']['operator'] = 'field_cage_id_vbc_target_id_op';
$handler->display->display_options['filters']['field_cage_id_vbc_target_id']['expose']['identifier'] = 'field_cage_id_vbc_target_id';
$handler->display->display_options['filters']['field_cage_id_vbc_target_id']['expose']['remember_roles'] = array(


texts: Get default min and max default values in views exposed filter form element

texts:
I have a views display that lists out content that meets a criteria defined by an exposed form. One of the filters is 2 values which a content attribute must be between. In views, I can define this as a default min and max value.

I would like to get these default values out as data attributes on the form fields for some javascript validation, and therefore will need to be able to get these as twig variables in the form element template, or set these as attributes in the form element preprocess.

The inputs initially have the value of the default min and max, but as soon as these are changed there is no way I can see to access the defaults.

How can I do this?


texts:
This error showing when I tried to import a CSV file on my live site. Same file I tried in local site working fine.

  Cannot acquire lock for source node / 0.

The modules I am using are the following:

Feeds
Feed Excel
Libraries (PHP Excel)

I examine the issue and found that the error occurred when I tried to import an image. Have anyone faced this issue?


texts: Get selected views rows in custom bulk webform operation

texts:
I created a custom module for bulk update of specific field of webform submissions. However before the action is executed I need to retrieve which rows are selected. I created my action file and I inserted a hook_form_alter in my module where I print the $form_state but I do not see the values. Ideally I would need the selected rows inside my execute function but also any other way is welcomed. I paste below the code so far:
<?php

namespace Drupal\webformbulk\Plugin\Action;

use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;

/**
 * Push term in front.
 *
 * @Action(
 *   id = "approve_submission",
 *   label = @Translation("Mark submissions as approved"),
 *   type = "webform_submission"
 * )
 */
class ApproveSubmission extends ActionBase {

  /**
   * {@inheritdoc}
   */
  public function execute($entity = NULL) {
    /** @var \Drupal\webform\WebformSubmissionInterface  $entity */

    $init_hours = $entity->getElementData('hours_sep');

    $rows = count($init_hours);

    for ($i = 0; $i < $rows; $i++) {
      $hours['hour_status'] = 'Approved';
      // If ()
      $init_hours[$i]['hour_status'] = 'Approved';
    }

    $entity->setElementData('hours_sep', $init_hours)->save();

  }

  /**
   * {@inheritdoc}
   */
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
    /** @var \Drupal\webform\WebformSubmissionInterface $object */
    $result = $object->locked->access('edit', $account, TRUE)
      ->andIf($object->access('update', $account, TRUE));

    return $return_as_object ? $result : $result->isAllowed();
  }

}

webformbulk.module:
/**
 *
 */
function webformbulk_form_alter(&$form, &$form_state, $form_id) {

  switch ($form_id) {

    // Check for bulk form id.
    case 'views_form_parliament_bookings_page_1':
      $form['actions']['submit']['#submit'][] = 'webformbulk_form_submit';
      break;

  }

}

/**
 *
 */
function webformbulk_form_submit($form, FormStateInterface $form_state) {

  kint($form_state);
  exit;
}


texts:
I have some experience with Drupal 7, but not that much. Now I'm working on my first Drupal 8 website and stumbled over the following situation:

In a first iteration, the website should use the default theme and should be as drupal-ish as possible in its solutions. One requirement is, that I have a list of 5 "sponsor logos" that should appear on the frontpage and the imprint. They should all appear in the same height and in one row (on a desktop browser and probably break on mobile).

Due to the fact that they should appear on different pages, I guess, I want to create a block for this. But what would be the most Drupal way, to add this row of logos to this block?

Just adding pictures in the editor feels a bit "undrupalish" and it seems to be meant for only one image. Adding code by hand and adding the addresses of the images feels a bit like "Why am I actually using a CMS?"

I hope my question is precise enough to get some input.


texts:
I have two content types

Program
Registration

and one taxonomy

Program type

Program content type having term reference with program type taxonomy
and registration having node reference with a program.

I am using views to list out all registrations.

How can I get the program type terms value in registration content type list?


texts: Node unpublishes and loses values after edit

texts:
I have a problem with a node.

I added fields to its node type and edited a node. After saving it, it unpublished AND lost values of its boolean fields. No matter how much I try to edit it again, it is never saved.

What is the problem here?


texts: I have made a new content type called wall and used user reference on it. Is there a way to auto create node whenever a new user is registered? I found the Autocreate Node Reference module but it doesn't have version 7 so I'm looking for an alternative.


texts: How can I create a view of child nodes based on the menu relationship?

texts:
Say you have the following pages in a menu tree:

Projects

Project One
Project Two
Project Three

I'm looking for a way to create a view that will be embedded in the Project (parent) page that will show a pic, title and text (summary) from the child pages.

The relationship between the parent and the children is defined in the menu tree.

I know I can use node reference, but that would mean every time someone creates a page they would have to define the menu relationship and then the node reference relationship.

Also I know that I could create another content-type but I think this is overkill as all content pages look the same.


texts:
I have a module that uses a button to load an embed view everytime the button is clicked.

// function to print builder view
    function workout_builder_template() {
        $viewName = 'builder_view';
        print views_embed_view($viewName);
    }

workout_builder_template();

However after the button is pressed a new view is loaded and the view is no long ajaxified. For example, if I click the apply button after changing the exposed forms, the form submits to a new page. Before clicking the button that loads an embed view via ajax, the exposed form altered the view content via ajax.

Here is example html from the ajaxified view

<form accept-charset="UTF-8" id="views-exposed-form-builder-view-default" method="get" action="/drupal7/builder-view" class="ctools-auto-submit-full-form ctools-auto-submit-processed jquery-once-1-processed">

Here is example html from the ajax less view

  <form accept-charset="UTF-8" id="views-exposed-form-builder-view-default" method="get" action="/drupal7/builder-view" class="ctools-auto-submit-full-form">

In the example the ajax less view does not have processed classes added to it. From this I suspect that the new view does not get javascript attached to it after the first ajax event. I have been researching drupal.behaviors and thought about printing

$vars['scripts'] = drupal_get_js();
print $vars['scripts'];

in the workout_builder_template() function displayed above, but I am not sure how this is done


texts:
I need to know how to add extra class to a perticular menu.For example i have custom menu "menu-header-let",This menu is rendering like below,

Help

Home

home2

Now i want add extra class to the ul like below

I used phptemplate_menu_tree(), but i need different class for each custom menu.If is override menu theme and adding same class for all custom menu.

I have no idea how to add different class when different custom menu renders in drupal.

please help me.


texts: Use computed fields as Apache solr facets

texts:
Today I wanted to add a computed field to my facet to make a faceted search using that field but when checking the facets page that field wasn't in the allowed field to make facets. When i realized none of my computed fields was in that list i came to the conclusion that you can't use computed fields as facets.
Looking on google didn't help me confirm my dobuts, there's actually no result that talks about solr facets and computed fields so i decided to ask here:

Can you use computed fields to make facets? If yes, is there something i have ti do (install a module, change a setting...) to enable this since at the moment i can't see them from the available facets?


texts: Drupal 7 adding rel to the href's of Login and Registration

texts:
I'm using Lightbox as a modal box solution and have been having
an issue trying to get modal windows for the default Login and
Registration links. I'm trying to access from inside a module that
I"m currently using to make all the changes. I've tried several
other "Box" solutions and Lightbox seems to be what I'm looking for,
but I cannot figure out the hook to add rel='lightbox' to login and
reg. Could someone point out what it is for me?

EDIT I tried using this in my base theme, which will give me a
modal on both reg and login, but shows an empty form?

function spti_base_preprocess_page(&$variables) {

/* .....stuff..... */

    // add the system user-menu into the page as its own thing
    $variables['platform_user_menu'] = menu_navigation_links('menu-platform-user-menu');

    foreach($variables['platform_user_menu'] as &$hijackLinks) { $hijackLinks['attributes']['rel'] = 'lightframe'; }

    $variables['page']['platform_user_menu'] = array(
      '#theme' => 'links__system_user_menu',
      '#links' =>   $variables['platform_user_menu'],
      '#attributes' => array(
        'id' => 'platform-user-menu',
        'class' => array('links', 'inline', 'clearfix'),
      ),
  );

/* .....stuff..... */

}


texts: How to show a block on the user profile page but not the user edit page?

texts:
I have added a block to a region and set it so that it shows on user profile pages.

However, I want the block to be displayed only on the profile pages, not on the profile edit pages.

Is that possible?


texts: Can i add a Slide show to my website in a block. Is it possible for my Theme

texts:
I would like to add  slide show to my website. How can i do that. And i would like to add it as a block in all the pages. What is the easy way to do that.

Please suggest.


texts: How to use node field tokens as a value in Metatags module?

texts:
I am trying to optimise SEO on my site by ensuring that each page has a unique value for descriptive metatags.

I am trying to achieve this using the Token and Metatags modules, and am using Drupal 8.

To do this, I have added a field called "Description" to both the basic page and article content types.

I would then like to use the [node:field_description] token as the value for any relevant metatags in the Metatags module.

However, when I view available tokens in the Metatags module the [node] token is not available and the [current-page] token doesn't appear to have any way to reference the main node displayed within that page.

I know this issue has been discussed extensively for D7 and this issue appears to provide what I'm looking for:

https://www.drupal.org/project/token/issues/919760

Is there an equivalent solution for D8? Alternatively, what's the best way of achieving this?


texts: How to display multiples jQueryUI progressbars in a page in Drupal 7?

texts:
I am developping my personnal website with Drupal 7. I would like to show a progressbar for each of my skills, but with differents values.

For exemple, I would like to see a progressbar under (or between if possible) a text, and (also if possible) with a percentage.

So I tried to use jQuery UI to solve my problem.

I want all my progressbars with a different value for each. Below, an exemple of the code of my website :

<?php
drupal_add_library('system', 'ui.accordion');
drupal_add_library('system', 'ui.progressbar');
drupal_add_js('jQuery(document).ready(function(){jQuery("#accordion").accordion();});', 'inline');
drupal_add_js('jQuery(document).ready(function() {jQuery(".progressbar").progressbar({ value: 37 });', 'inline');
?>

RÉSEAU

Windows Server 2008

50%

Ubuntu Server

50%

Virtualbox

90%

But it does not work.

To solve that problem, I tried that kind of code found on that website, but I does not work for me, when I include it in drupal like that :

<?php
drupal_add_js('jQuery("div.progressbar").each (function () {var element = this;jQuery(element).progressbar({value: parseInt(jQuery(element).attr("rel"))});});', 'inline');
?>

Perhaps, I am in wrong, but any answer would be so great. Thank you in advance. :)


texts: Can't save a node which has string cck fields

texts:
I want migrate our academic paper records from Drupal 6 to 8 manually.
Many nodes can be stored correctly if its type has not any string field.
I tried many ways but some nodes can't be stored if it has a string field.

An example of my code as follows:

<?php
  use \Drupal\node\Entity\Node;

  $db = mysqli_connect( 'localhost', 'user', 'pwd');
  mysqli_select_db($db, 'academic6');
  $result = mysqli_query($db, 'select * from other_paper');
  // We have many view tables in Drupal 6 database.
  // other_papers is a view table which connects many fields.
  $count=0;
  foreach ($result as $row) {
    $count++;

    $arr = [
      'type' => 'other_paper',
      'title' => $row['title'],
      'language' => LANGUAGE_NONE,
      'uid' => $row['user'],
      'status' => 1,
      'promote' => 0,
      'comment' => 0,
      'created' => $row['created'],
      'changed' => $row['changed'],

      'field_year' => ['value' => $row['year']],
      //string field address holds an url address or empty string
      'field_address' => ['value' => $row['address'] ],
      'field_old_id' => ['value' => $row['id']]
    ];
    $node = Node::create( $arr );

    $node->save();
  }
  echo $count.' saved.<br>';
?>


texts: Unable to save contents once a  tag is added

texts:
I try to add new contents and added a content with an image tag in it. It could be as simple as:

<img>
Hello

When I try to save, the page merely reloads and nothing is saved, no error messages and I am still at the same page.

Adding new contents without the  tag saves with no problem. Adding new contents with just the  tag also saves with no problem.

Only contents with an  tag AND some other contents not save.

This problem came up suddenly. I have not updated Drupal nor any of my modules. And I have confirmed that I have allowed  as a tag in my text format.

Would anyone know what problem this may be?


texts: Converting Simplenews Subscribers to Users

texts:
I was wondering if there is a way to convert SimpleNews subscribers into actual Drupal users?

Currently, I have something similar going on using custom fields in the user-register form, but wanted to know if I can leverage the Simplenews module for my needs.

I want to create a block where users can register to receive weekly e-mails in which they receive information about our weekly ad.

Cheers,

Elm


texts: Is there an event before and after form is submitted via ajax?

texts:
Currently if a form is submitted via ajax is will show the throbber and "please wait" message(which can be configured on the ajaxified button that submits the form.

I would like to perform some additional actions before and after the form is submitted via ajax so I am looking for events that are being triggered and on which elements they are being triggered.


texts:
I have view slideshow setup (with views slideshow module)  to display some fields (image, title, node teaser) on very top of content area on front page. Also i have drop-down menu setup (with nice menu module).
Now, when menu is expanded it goes over slideshow fields, but when slideshow auto-rotates it then position it self in front of menu and never go back again (until i reload page). I tried to solve this with z-index with no luck.

here is a screen shot when image go in front of menu.

Any one had same problem? Can any one point me in right direction?


texts: Custom block: How to know you're in an admin context?

texts:
I've developed a custom block which relies on a taxonomy term ID being present in the URL, otherwise it throws a 404.

I've placed this block in a panel page (ctools pages), but now when I try to edit the panel page, I get a 404 response, but only on the "Content" tab of the panel page variant.

What's the proper method for knowing you're on an admin page, or in the context of a panel edit, so that I can skip throwing a 404?


texts: How to set readonly or locked a select webform field?

texts:
I want to lock a prefilled select webform field but no option is provided by the UI.So I think to do that programmatically.

Actually I do in a hook_form_alter:

$form['submitted']['discipline_du_poste']['#attributes'] = array('readonly' => 'readonly');

and this doesn't effect...what's wrong ?


texts: Drupal Queue example : form_state->get('XXX') always empty

texts: In D8 Queue example (QueueExampleForm.php), why $form_state->get('insert_counter') is alway empty during insertion into queue (after submit)?


texts: Best way to achieve the following layout

texts:
I am pretty new to Drupal, I have a Content Type with a "Field Collection" say like below..

Title
Banner Image
Details - Field Collection Type (Short Title, Description, Links)

I would like to achieve the following style of output, basically upon "User Selection" in the LHS the RHS side should refresh and show the selected Field Collection item's Description. What is the best possible way to achieve this in Drupal 7 (Views with Contextual Filters?, Cycle? or Rotator components etc). Please advice.

Edit: It's only the Content area shown in the picture, there will be a Menu/navigation system wrapping this. Hence this actually becomes 2nd level navigation for that page/node.

thanks,
Vasanth.


texts: Add javascript to views exposed form after ajax submit

texts:
I've read millions of similar posts on this but I just can't get my head around it. So far I understand that I need to use Drupal.attachBehaviors, and I've tried so many different approaches that I've seen but nothing works.

Basically I have a jQuery plugin that is styling any select boxes on the site, which works great, apart from on my views exposed form with ajax enabled. The jQuery is literally as simple as $('select').styledSelect(); after including the plugin itself.

EDIT: this is almost there:

      Drupal.behaviors.styledSelect = {
        attach: function() {
          $("select").styledSelect();
        }
      };

But now the ajax call seems to be looping.

EDIT again:

Well it seems to be something to do with the actual plugin, as other Javascript seems to work fine. I'm so close! Here is the plugin:

jQuery.fn.styledSelect = function(options) {
var isFF2 = jQuery.browser.mozilla && jQuery.browser.version.indexOf('1.8.')==0;
var prefs = {
    coverClass : 'select-replace-cover',
    innerClass : 'select-replace',
    adjustPosition : { top:0, left:0 },
    selectOpacity : 0
    }
if (options) jQuery.extend(prefs,options);
return this.each( function() {
    if (isFF2) return false;
    var selElm = jQuery(this);
    selElm.wrap('<'+'/span>');
    selElm.after('<'+'/span>');
    var selReplace = selElm.next();
    var selCover = selElm.parent();
    selElm.css({
        'opacity':prefs.selectOpacity,
        'visibility':'visible',
        'position':'absolute',
        'top':0,
        'left':0,
        'display':'inline',
        'z-index':1
        });
    selCover.addClass(prefs.coverClass).css({
        'display':'inline-block',
        'position':'relative',
        'top':prefs.adjustPosition.top,
        'left':prefs.adjustPosition.left,
        'z-index':0,
        'vertical-align':'middle',
        'text-align':'left'
        });
    selReplace.addClass(prefs.innerClass).css({
        'display':'block',
        'white-space':'nowrap'
        });

    selElm.bind('change',function() {
        jQuery(this).next().text(this.options[this.selectedIndex].text);
        }).bind('resize',function() {
        jQuery(this).parent().width( jQuery(this).width()+'px' );
        });
    selElm.trigger('change').trigger('resize');
    });
}

EDIT again:

it was the trigger 'change' that was causing the problems - I've changed it to click, and it all seems good woohoo!

As ever, thanks for everyone's wonderful advice.


texts: How do I access the updated entity after saving with entity wrapper

texts:
When using entity wrapper to modify and save an entity, what is the preferred way of accessing the updated entity.

For example, after the following code saves the node:

$node = node_load(123);
$node_wrapper = entity_metadata_wrapper('node', $node);
$node_wrapper->field_textfield->set('New value');
$node_wrapper->save();

After that, what is the preferred way to access the updated node object (the full object, not just field values)?
Can it be accessed via the wrapper in some way or do you have to load the node again?


texts: Drupal 8 Views or Pixture Reloaded paging/formatting problem

texts:
Looks like I may have tripped over yet another bug in either Views or Pixture Reloaded in D8.

I created a view to show a simple content type I created called Newsletters. I can use the pager supplied by views to navigate to page 2 without a problem, but when I click page 3 or Next Page I get a screwed up display.

Excerpts from page 2 that displays properly.

Excerpts from page 3

View that I created.

Do you think this is a Views problem or a Pixture Reloaded problem?


texts: How to hide certain items in a term reference field?

texts:
I have the taxonomy 'Types' with terms A, B and C. I've added a term reference field 'Type' to the users with the 'Types' vocabulary. Now, when people register, they can choose between A, B and C in the 'Type' field, but I'd like them only to be able to choose between A and B.

How can I hide the third option?


texts: How to write a WHERE clause with the '=' operator using db_select()?

texts:
I have MySQL query as:

SELECT *
FROM `field_revision_field_innostream_state`
WHERE `field_innostream_state_tid` =187
LIMIT 0 , 30

How to write a WHERE condition within db_select?


texts: Output the field as $_rendered in the node page

texts:
When a CCK field is added, we get the rendered output in the node page as $<field_name>_rendered.
How can we get a variable in the same way when we alter the form and add new field?


texts:
according to this  I wrote below code to create temp user and login ,
, user create but it not logged in.
where is problem?

   $user_info = array(
  'name' => 'temp-payment-'.rand(1,999),
  'pass' => user_password(),
  'mail' => 'no@no.com',
  'init' => 'temp-user-'.rand(1,999),
  'status' => 1,
  'roles' => array(DRUPAL_AUTHENTICATED_RID => TRUE),
                    'access' => time(),
                    );
  $user = user_save('',$user_info);

  if($user) {
   $GLOBALS['user'] = $user;
    drupal_save_session(TRUE);
    ym($user);
  }
  drupal_goto('/user');


texts:
I am trying to make jCarousel work with Views in Drupal 7. I select the required fields and write in the footer part of the view like the following one:

 <?php
  jcarousel_add('slideshow-item-list', array('auto' => 2,'visible' => 3));
 ?>

It is not working properly. The next and previous buttons do not show up. Please tell me what I am doing wrong.


texts: How can I seperately display a view's exposed filter and its content in page.tpl?

texts:
Using <?php dpm($node) ?> I found the exposed filter, $...->view->exposed_widgets, however I'm not sure how to display it. I tried <?php echo $node->view->exposed_widgets; ?> but that returns nothing.

<?php dsm($form); ?> and <?php dpm($form); ?> both give

  Notice: Undefined variable: form in include() . . . page.tpl.php

Are those deprecated? I see them mentioned sometimes but they've never worked for me.

The only place I see the form in <?php dpm($page); ?> is ['content']['system_main']['main']['#markup'], and that can't be separated, obviously.


texts: Limit amount of content creation per anonymous user

texts:
In my site anonymous users has access to create one type of content and all data the site stores is user IP address.

How do I limit lets say e.g. 2 nodes creations per IP in 12 hours? And when limit is reached, they get some message instead of creating another node until 12 hour range pass?

Because now some of anonymous users are just abusing and spamming the node creation which is unlimited by default.

UPDATE: I tried using Node Limit, but it doesn't really work. When I load a page with the form which has the limit set, it doesn't load the page and that's a home-page of the site and form is displayed as Form Block via Panels. So instead of a home-page I get redirected to node/add/ and page not found.


texts: How to change the language of strings like "read more" and "submitted by"?

texts:
I've managed to create a website with Drupal 8.3.7.

How do I get Drupal to print things like "Read more" in views and "Submitted by", "Wednesday, August 23" in an article or t("something supposedly translated") in another language?

I'd like the administration interface to remain in English. I'd like to avoid a language prefix in URLs (yes: /mycurrenturlalias, no: /XX/mycurrenturlalias) but at this point I really don't even care anymore.

I've tried installing the Language module, adding a new language, setting it as the default and only language, installing some translation modules and fiddling with their settings. I've broken the site in some interesting ways but what I haven't gotten is a single translation of those strings anywhere. I must be doing something horribly wrong, but please ignore that and just tell me what should work.


texts: Diff module not tracking fields that existed before module was installed

texts:
I have a Drupal project in the final stages of development. It has quite a lot of content types and a lot of fields. I have recently enabled revisions and added the diff module (7.x-3.2). It isn't tracking changes on my existing fields. When I choose 'compare' it shows 'No visible changes' and the current revision area only shows the new fields.

If I add a new field diff starts working on it. If I remove a field and re-add it diff starts working on the new version of the field. Any idea why this is happening? Are there any ways I can get diff working on all my fields without removing an re-adding all of them?

I tried editing and saving a field without making any changes to it, but this did not make diff tracking start working on it. I have looked in the DB and both a field being tracked and a field that isn't being tracked have a revision_id.

I have tested in a sandbox server and the diff module works as expected. Therefore it must be a conflict or a bug that is being triggered by my install.


texts: How a media image entity_reference field in a custom content entity can be set to translatable?

texts:
I created a media image field in my custom entity content:

$fields['image'] = BaseFieldDefinition::create('entity_reference')
  ->setLabel(t('Promotion image'))
  ->setDescription(t('Recommended image size is 1600x900 pixels.'))
  ->setRevisionable(TRUE)
  ->setTranslatable(TRUE)
  ->setRequired(FALSE)
  ->setSetting('target_type', 'media')
  ->setSetting('handler', 'default:media')
  ->setSettings([
    'handler_settings' => [
      'target_bundles' => [
        'image' => 'image',
      ],
      'sort' => [
        'field' => '_none',
      ],
      'auto_create' => FALSE,
      'auto_create_bundle' => '',
    ],
  ])
  ->setCardinality(1)
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE)
  ->setDisplayOptions('form', [
    'settings' => [
      'entity_browser' => 'image_browser',
      'field_widget_display' => 'rendered_entity',
      'field_widget_edit' => TRUE,
      'field_widget_remove' => TRUE,
      'open' => TRUE,
      'selection_mode' => 'selection_append',
      'field_widget_display_settings' => [
        'view_mode' => 'default',
      ],
      'field_widget_replace' => FALSE,
    ],
    'type' => 'entity_browser_entity_reference',
    'weight' => 3,
  ])
  ->setDisplayOptions('view', [
    'label' => 'hidden',
    'settings' => [
      'target_type' => 'media',
    ],
    'weight' => 3,
  ]);

Even though the entity itself, and the field are set to translatable, the ALT and TITLE attributes of the image are not translated.

If I create this field manually in the UI, it works as intended, and gets translated. How could I define this field to be translatable programmatically?


texts: User name on blocked user account not visible in view for anonymous users

texts:
I have a D7 blog site that I've migrated from a D6 version, and one of the changes was to use an Entity Reference field (field_source referencing the user entity) for the author names so we could handle cases where one piece of content could have multiple authors. One of the nice things about D7 is that it is much easier to add custom content to user profiles, so we can just use and modify the core user profiles to display an author's content instead of having to create a separate author content type like we did in D6.

In order to keep all author names associated with their content, I migrated all of the user accounts for those that have written posts in the past and associated their content with the D7 user account (via field_source). However, I don't want some of the older user accounts to be active, so they are blocked.

This causes a problem for anon users (which are the vast majority of users that will be accessing the site), in two ways:

They can't see all the user's content on their profile page
Even weirder, when listing content in a generic views page display that
has the main image, title, author name, date, and summary, the
author name does not show for anonymous users, but it does for
admins. When looking at the view preview, the name is returned, so
there's obviously something after the view content is returned that
is filtering the display of blocked user account names. And yes, I have the relationship                   and field defined properly in the view.

I've looked at the permissions, and anon users have the "view user profiles" permission, so there's obviously something else blocking the display in both cases. I don't see any intermediate perms for viewing blocked accounts other than "Bypass content access control", and I obviously don't want to give that permission to anonymous users.

Is there anything I can do to address these display issues for anonymous users other than unblocking all of the user accounts?

Thanks.


texts: How to override node_search_execute() to implement partial matching search?

texts:
I would like to override node_search_execute, so the search query will find partial match of a word instead of full word match i.e coffee, I would like partial match coff should return coffee result.

How can I override node_search_execute() to implement partial matching search?


texts: A Rule component to change author on nodes?

texts: I am looking to create a rule's component to allow users to bulk modify the author value on nodes using VBO. Any insight on how I what this component part in rules would look like? The action must allow the user to define whatever author they wish either using a textfield or a list of available accounts on the site in VBO.


texts: How can I create a Link to an URL containing a fragment identifier?

texts:
Is it possible to create a Link to a node with a hash in url (for opening a special Tab).
I use:
Link::createFromRoute('Title', 'entity.node.canonical', ['node' => 77]);

And I want to link to: "/node/77#example"


texts: How to return a missing field as null with db_select union?

texts:
I have a db_select union of two tables where some of the columns are different. I would like to select a column that is only in one of the tables. The standard SQL way of doing this seems to set the column as null for the table where the field missing. Is there a way of doing this with db_select? db_query?

Standard SQL way:

select id, name, date, null as userid, 'A' as recordtype from table1
union all
select id, name, null /*as date*/, userid, 'B' as recordtype from table2

What I'm trying to do:

$table_one = db_select('t_one', 'to')->fields('to', array('ID', 'NAME'));
$table_two = db_select('t_two', 'tw')->fields('tw', array('ID', 'NAME', 'new_field_not_in_first_table'));
$s_query = Database::getConnection()
        ->select($table_one->union($table_two), 't')
        ->fields('t', array('ID', 'NAME', 'new_field_not_in_first_table'));

I tried adding 'NULL as new_field_not_in_first_table' in the first table but no luck.
Thanks for your time!


texts: Run a check on every page load programmatically

texts:
Drupal 7.

I have a site with Single Sign On (SSO) implemented. The implementation of the features is complete and the site is running perfectly.

Now, I have a requirement where I am supposed to check whether the session of the central server (on root of the domain and not using Drupal) is alive. I can do this by checking the availability of the session cookie on the root domain. And if the session is not active the user is logged out of Drupal.

I tried implementing it inside hook_init() but it only works for non-cached pages, whereas I want my code to be triggered on every page.

I also had a look at hook_boot() which runs even on cached pages. But, it is called while Drupal is still in bootstrap mode; even before themes and modules are loaded into memory. Which would mean that I would not be able to check the status of the user (whether the user is logged in?), because the user module and the included file session.inc would not be present in the memory while the execution of this hook.

So my question is which function (or hook) should I use which would execute on all pages(cached and non-cached) and which would give me access to common user properties (e.g. global $user object, user_is_logged_in() function etc)?


texts:
I am trying to display a custom form with Drupal 7.

Here is what I am trying:

function mymodule_menu() {
  $items = array();

  $items['pay-online'] = array(
    'title' => 'Pay Online',
    'description' => 'Pay Online',
    'type' => MENU_NORMAL_ITEM,
    'page callback' => 'drupal_get_form',
    'page arguments' => array('mymodule_form_generate'),
    'access arguments' => array('access content'),
  );

  return $items;
}

function mymodule_form_generate() {

  $form['first_name'] = array(
    '#type' => 'textfield',
    '#title' => 'First Name',
    '#attributes' => array('placeholder' => 'First Name'),
  );

// ... etc, more form code

return $form;

What I am getting on the screen is a form, but it is not a 'drupal' form. It's just an array of form fields. No form id, etc.

What do I have to do in Drupal 7 to accomplish this?


texts: How can I use WordPress-like short codes?

texts:
I am new to Drupal. Previously I was working with WordPress, where you can use short codes for getting plugin functionality for pages.

Is this possible in Drupal as well?

For example in WordPress when editing a blog post I can use this in the editor:

[foobar] // This is a short code.

And here's how it got defined in WordPress:

function foobar_func( $atts ) {
  return "foo and bar";
}
add_shortcode( 'foobar', 'foobar_func' );

How to do that in Drupal?


texts: I am noticing objectFit is not part of Drupal 8 core/modernizr library. How do I add objectFit detection without overriding core modernizr?


texts: How do I display highly customized content?

texts:
What is the correct way to display parts of a highly customized application? For example my website only consists of a friendlist with user name as well as images and a live chat frame.

Is this the right approach?

Create Theme with 2 regions (friend_list, chat_frame)
Develop custom Blocks for each feature (friend_list Block and chat_frame Block)
Assign Blocks to the regions
Style each Block individually to fit my requirements
Add javascript for each block for chat and asynchronous updating of the friendlist (ajax)

Is it better to place all features in one module? Can one module have multiple blocks?


texts: How do I get the public file URI for a media file from jsonapi?

texts:
I have an audio file that is stored as Media of type Audio.
Now I want to get the link to that file that is usually displayed to site users via jsonapi.
For example, when the media entity is rendered, this is the link:
<audio controls="" controlslist="nodownload"> <source src="/sites/default/files/coolstuff/audio/apples-bananas-pears.mp3" type="audio/mpeg"> </audio>

This /sites/default/files/coolstuff/audio/apples-bananas-pears.mp3 path is what I want to get from jsonapi.
However, when I look at the output of /jsonapi/media/audio, all the URLs look like this:
http://mysite.com/jsonapi/media/audio/d741b59c-9617-4a24-a2e8-99005a76507b?resourceVersion=id%3A31"

None of them have the public-facing URI.
The documentation gives this example for a "article media entity reference field_image url, uri by including references":
http://example.com/jsonapi/node/article/{{article_uuid}}?include=field_image&fields[file--file]=uri,url

I have media entity references, so I tried the same on my site:
http://mysite.com/jsonapi/node/MY_CONTENT_TYPE?include=field_ref_media_audio&fields[file--file]=uri,url

However, I do not get the regular media URI, just the jsonapi one.
How can I get the media public file URI (/sites/default/files/coolstuff/audio/apples-bananas-pears.mp3)?


texts: How can I write SelectQuery for SELECT LAST_INSERT_ID()?

texts:
Is it possible to run the following query with SelectQuery ?

SELECT LAST_INSERT_ID();

I would do this with db_query(), but I'm finding a way to use the query builder.

$last_id = db_query("SELECT LAST_INSERT_ID()")->fetchField();


texts: Column not found: 1054 Unknown column 'revision.revision_user' in 'field list': after Update from 8.2 to 8.4

texts:
I'm encountering an error when updating from 8.2 to 8.4, in my case it seems to be related to block_content and maybe also commerce. I've found others with similar issues, but no solid resolution. Has anyone experience this?

Here is the error in the error log:

Uncaught PHP Exception Drupal\Core\Database\DatabaseExceptionWrapper:
"SQLSTATE[42S22]: Column not found: 1054 Unknown column
'revision.revision_user' in 'field list': SELECT revision.revision_id
AS revision_id, revision.langcode AS langcode, revision.revision_user
AS revision_user, revision.revision_created AS revision_created,
revision.revision_log AS revision_log, base.id AS id, base.type AS
type, base.uuid AS uuid, CASE base.revision_id WHEN
revision.revision_id THEN 1 ELSE 0 END AS isDefaultRevision
FROM
{block_content} base
INNER JOIN {block_content_revision} revision ON revision.revision_id =
base.revision_id; Array
(
)
" at /core/lib/Drupal/Core/Database/Connection.php
line 686

When I try to run drush entity-updates, it errors out with this:

block_content entity type :
  The Revision create time field needs to be updated.
  The Revision user field needs to be updated.
Do you wish to run all pending updates? (y/n): y
Drupal\Core\Entity\EntityStorageException: Exception thrown while
performing a schema update. [error]
SQLSTATE[42S22]: Column not found: 1054 Unknown column
'revision_created' in 'where clause':
SELECT 1 AS expression
FROM
{block_content_revision} t
WHERE revision_created IS NOT NULL
LIMIT 1 OFFSET 0; Array
(
)
 in Drupal\Core\Entity\Sql\SqlContentEntityStorage-
>wrapSchemaException() (line 1513 of /core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Fatal error: Cannot use Drupal\entity\BundleFieldDefinition as
BundleFieldDefinition because the name is already in use in /modules/commerce/src/ConfigurableFieldManager.php on
line 8
Drush command terminated abnormally due to an unrecoverable error.
[error]
Error: Cannot use Drupal\entity\BundleFieldDefinition as
BundleFieldDefinition because the
name is already in use in
/modules/commerce/src/ConfigurableFieldManager.php,
line 8
The external command could not be executed due to an application
error.

Any help is appreciated, the site is down


texts: Programmatically added block does't appears in block admin page

texts:
I created a programmatically block in a custom module for Drupal 8.1. The custom module and the block plugin are created via Drupal Console.

I installed my module and I clear cache via drush cr, but when I go to the admin block page, my block does't appear.

For view an example, I installed the "examples module" and the "block example module". When I do that, there aren't blocks example" in a block admin page too.

I don't understand.

The content of my block class form my custom module is the following.

/**
 * @file
 * Contains \Drupal\nomads_pdf\Plugin\Block\nomads_pdf_block.
 */

namespace Drupal\nomads_pdf\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Provides a 'nomads_pdf_block' block.
 *
 * @Block(
 *  id = "nomads_pdf_block",
 *  admin_label = @Translation("Nomads_pdf_block"),
 * )
 */
class nomads_pdf_block extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    return array(
      '#type' => 'markup',
      '#markup' => $this->t('Hello, World!'),
    );
  }

}

My custom module structure is the following.


texts: Upload a folder full of files (static html and assets) to the private files folder when creating a node

texts:
I need to be able to upload a folder full of files (static html and assets) when creating a new node and then to output a link to the index.html file in the uploaded folder.

They files from a learning modules created by a third party tool and exported as static HTML so each new node is a listing for a new learning module.

Critically all of this needs to be uploaded to the private files directory so only logged in users can see the contents.

Currently when I manually upload to the private files and link to the static html at that location (displaying the page inside a lightbox) I get the following Apache error:

Any suggestions?

Note:  this is an Apache 500 error. I have uploaded the index.html file directly to the private files folder using sftp so I'm guessing when I load it up in a lightbox window as above apache isn't letting me access it.


texts: Add Taxonomy ID class to the body tag (D8)

texts:
I have a taxonomy vocabulary whose various parents and children need to have different styles. I would need the tid of the every taxonomy page to appear as a class in the body tag in order to make CSS selectors.

I tried using this to work out a solution, but it appears to work only for nodes. I get a class called path-taxonomy for every taxonomy term and that's it.

I would prefer not to install any modules. Thank you


texts: hook_image_effect_info_alter() doesn't change effect callback

texts:
I'm trying to patch the image effect from the Kraken module.
I'm doing so by using hook_image_effect_info_alter() to point the 'effect callback' to my patched function, like this:

function patch_image_effect_info_alter(&$effects) {
  $effects['kraken_optimize']['effect callback'] = 'patch_kraken_optimize';
  watchdog('patch_kraken', print_r($effects, TRUE)); // logging for debug
}

The problem is that this the hook doesn't seem to really change the effect defined on the Kraken module. Even though I'm getting the log message I defined in the hook with the updated effect callback, the original Kraken module effect is still being applied.

Am I using this hook the right way?


texts: how do you alter queries for node/# to select entity-referenced node titles instead of just target_id?

texts:
I am using Drupal 7 Services and the generic call of services/node/#. Unfortunately that only gives me the target_id as a property of every field with type entity reference; and my interface does need the node title at the least.

I have...

function  HOOK_query_alter(QueryAlterableInterface $query) {
    if ($query->hasTag('NODE RETRIEVE')) { // WHAT TAG SHOULD I USE?
        // ..TO ONLY ALTER (service)/NODE/# QUERIES?
    }
    $fields =& $query->getFields();
    ... // AND HOW DO I ALTER TO GET REFERENCED FIELD NODE TITLES?
}

All said, I do realize I might be able to use node_load and loop over the results to run subsequent queries for this data, but that seems kind of expensive, unless the resulting hook_alter_query would be too complicated. Please say so if you feel that's most likely the case.


texts: I set up a content type of example with custom fields. How can I get the field values to show in my twig template? I have tried {{ content.field_formattext }} and that doesn't display anything.


texts:
I'm trying to published revision for a node, while saving.
Currently D8 manage revisions, but the last revision is always the "published" revision.

I'm using hook_entity_presave, but I can't find a method to do this.

Some suggestions?


texts: Allow/restrict access based on privacy setting flags in profile

texts:
I have privacy profile type and flags with checkbox like "Keep all my friends private" and "Keep all my videos and channels private".These are in my privacy settings profile.Now i want  to allow or restrict the access based on my flagging (on/off checkbox) for the users.Here i have two content types videos & channels.By default other users can watch my videos & channels and i want to make it private when i click my checkbox on for "Keep all my videos and channels private" and once i uncheck this,it should become public.The same need to be done for "Keep all my friends private".I have used user relationship module for friends.How can i do this? Is it possible using php coding or is there any other solution.Please help.
Thank you.


texts: Query custom node by user Entity Reference

texts:
I am trying to build a query that finds all nodes of a custom type where one of the fields is a user Entity Reference.  I am trying to use EntityFieldQuery but just as open to db_select().  The following is just an example of one of the queries I have tried.

$query = new EntityFieldQuery();

$query
  ->entityCondition('entity_type', 'node', '=')
  ->propertyCondition('type', 'custom_node', '=')
  ->fieldCondition('field_marketer', 'value', $user->uid, '=');

$entities = $query->execute();

Thanks in advance for any help.


texts: How do I create product and product display once, like in Commerce Kickstart?

texts:
In Kickstart you just go Add Product and it creates both, the Product for admin area product list and the Product Display. How do I do that in regular Drupal install with regular Commerce module? Because now I have to go each time to create the actual product for admin product list and then go create a product display for users. Isn't that a bit annoying?

I cannot use Kickstart, it's too late already and it's too big and overcrowded with too much of not needed features.


texts: How do I create a rule that closes comments on node after 30 days?

texts:
I am on Drupal 7, and I am trying to make a rule that closes comments on a node 30 days after they have been created. I am assuming I need to make a component that has an action of "set data value:" to change the "node:comment" to 1. Where I am confused is how to schedule that component to fire 30 days after the node has been created.

Do you have any suggestion?


texts: Show table records in view via hook_form

texts:
I managed to get things looking a bit better, However I dont know why the checkbox below is showing like the picture. I want to select the checkbox and make it do something with the corresponding article. By the way I have it, will it work? Thanks in advance.

`function rss_list_form($form, &$form_state) {

$results = db_query("SELECT * FROM {rss_table}");
$i = 0;
foreach($results AS $result) {

    $form[$i] = array(
        '#type' => 'checkbox',
        '#prefix' => '
',
        '#suffix' => '
',
    );
    $form[$result->GUID] = array(
        '#type' => 'item',
        '#title' => $result->title,
        '#markup' => $result->description,
        '#prefix' => '
',
        '#suffix' => '
',
    );
    $i++;
}
$form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
);

return $form;

}`


texts: Drupal 7, MySQL, InnoDB, and transactions

texts:
I was reading default.settings.php for Drupal 7.x this afternoon, and came across this comment:

/*
 * Some database engines support transactions.  In order to enable
 * transaction support for a given database, set the 'transactions' key
 * to TRUE.  To disable it, set it to FALSE.  Note that the default value
 * varies by driver.  For MySQL, the default is FALSE since MyISAM tables
 * do not support transactions.
 */

This is different in Drupal 8:

/*
 * Transaction support is enabled by default for all drivers that support it,
 * including MySQL. To explicitly disable it, set the 'transactions' key to
 * FALSE.
 * Note that some configurations of MySQL, such as the MyISAM engine, don't
 * support it and will proceed silently even if enabled. If you experience
 * transaction related crashes with such configuration, set the 'transactions'
 * key to FALSE.
 */

So, how does db_transaction() work then on MySQL in Drupal 7?

Is this comment outdated, or should I explicitly set

$databases['default']['default']['transactions'] = TRUE;

if I know everything is InnoDB (which is the default for Drupal 7.


texts: Get content of current user + Of the users that are flagged or followed

texts:
I have a site, where users can follow each other using Flag. Currently, I am able to create a view which shows content from all the user the currently logged in user is following. This is done adding a relationship to the flag.

What I am creating is a feed of posts, like in Facebook. So it should also show content posted by the current user along with user followed. But I am unable to do that unless the user follows himself.


texts: Ubercart: maintaining cart content after user login

texts:
I have a Ubercart site where the user can add items to cart even if it is not logged in: the problem is that when he logs in the cart is emptied and he has to refill it.

Is there a way to save the cart for the anonymous user and, when he logs in, to retrieve the cart content?


texts:
I have a form file:

namespace Drupal\h_scheduler\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use \Drupal\node\Entity\Node;

class DayAddEntries extends FormBase {

  public counter = 0;

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'hs_day_add_form';
  }

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

    $form_state->setCached(FALSE);

    $form['#attached']['library'][] = 'h_scheduler/form_actions';

    /*...More fields....*/

    /* Special */
    $form['specials'] = array(
      '#type' => 'fieldset',
      '#tree' => TRUE,
      '#title' => t('Specials'),
      '#prefix' => '
',
      '#suffix' => '
',
    );

    if ($this->counter) {
      for ($i = 1; $i <= $this->counter; $i++) {
        $form['specials']['special'.$i] = array(
          '#type' => 'fieldset',
          '#title' => t('Special ') . $i,
          '#tree' => TRUE,
        );
        $form['specials']['special'.$i]['field'] = array(
          '#type' => 'number',
          '#title' => t('Every'),
          '#title_display' => 'before',
        );
        $form['specials']['special'.$i]['field'] = array(
          '#type' => 'textfield',
          '#title' => t('Prefix'),
          '#title_display' => 'after',
        );
      }
    }
    $form['specials']['operations']['#type'] = 'actions';
    $form['specials']['operations']['add_special'] = array(
      '#type' => 'button',
      '#value' => $this->t('Add special'),
      '#ajax' => array(
        'callback' => '::ajaxAddSpecial',
        'wrapper' => 'specials',
      ),
    );

    /* Not working */
    $form['specials']['operations']['remove_special'] = array(
      '#type' => 'button',
      '#value' => $this->t('Remove special'),
      '#ajax' => array(
        'callback' => '::ajaxRemoveSpecial',
        'wrapper' => 'specials',
      ),
    );

    /* Submit */
    $form['actions']['#type'] = 'actions';
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => $this->t('Save'),
      '#button_type' => 'primary',
    );

    $this->counter++;

    return $form;
  }

  /**
   * Increments the number of specials to have
   */
  public function ajaxAddSpecial($form, FormStateInterface $form_state) {
    return $form['specials'];
  }

  /**
   * Decrements the number of specials to have
   */
  public function ajaxRemoveSpecial($form, $form_state) {
    $this->counter -= 2;
    return $form['specials'];
  }

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

    /* Do stuff */

  }
}

jQuery:

jQuery(function($) {
  $('#edit-specials .fieldset-wrapper .fieldset-wrapper, #edit-regular .fieldset-wrapper').addClass('entry-wrapper').each(addStyleClasses);

  function addStyleClasses() {
    console.log('hi');
    $(this).children('.form-item')
      .addClass(function() {
        var regex = /form-item-\S+-(\S+)/;
        return regex.exec($(this).attr('class'))[1];
      })
      .not('.every').wrapAll('
');
  }

});

I'm able to add a new "special" item, but when I do it appears wacky.

This is because I've styled the form using a jQuery function that adds classes and wraps elements. However, that function does not run when the form['specials'] is rebuilt.

My question, how do I run a JS function after an ajax call?


texts: Include multiple blocks in one responsive menu?

texts: It would be really handy to include not just one menu in a responsive dropdown menu, but also the user login block, the main menu etcetera. Is there a way to do that? I have tried several responsive menu modules, but it seems as though I always end up with several different dropdown menus. I only want one (for all).


texts: Different templates for generating different PDF files related to a single node

texts:
Im using PDF using mPDF to generate PDF files related to a node.
Inside the code of the module there is a preprocess function that add to theme_hook_suggestions a new pdf template that can be used when the view_mode is 'PDF' :

function pdf_using_mpdf_preprocess_node(&$vars) {
  if ($vars['view_mode'] == 'PDF') {
    $vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__pdf';
  }
}

this template works fine when I add inside my template directory a template file named like that : node--node_type--pdf.tpl.php.

The problem is that I need different PDF versions for the same node (one version with some fields, one with other fields, english version, french version)

how can I generate different templates for each PDF version knowing that this module use the view_mode 'PDF' to render the html content inside the PDF file :

$view = node_view($node, 'PDF');
$html = drupal_render($view);
// then generate the pdf using this rendered html
_pdf_using_mpdf_generator($html, $pdf_using_mpdf_pdf_filename);

So in this case I can't add new view modes for each version because the module will always generate the html according to the 'PDF' view mode.

These different files should be generated when the node is saved (hook_node_presave).

There is a function inside the api of this module to generate a pdf :
pdf_using_mpdf_api($html, $pdf_using_mpdf_pdf_filename = NULL). I will use it inside hook_node_presave

How can I assign to each PDF file a single template?


texts: Irreversible error when trying to upload image (too big) in a clone

texts:
In all of my node types I have several image fields. If I delete one image and then uploads a new one and then repeats this for a second and third image field, all works as expected.

BUT if I do this same thing in a clone of the node, WITHOUT saving the new node first, I get this message:

  Irreversible error, Uploaded file probably exceeds the maximum file
  size limit (2 mb), supported by this server

(something like that, translated from my language), directly when I hit the delete button for the second image. Before I even try to upload this second image.

The workaround for the time being is to save the clone first and then delete the old images and upload the new ones.

But what is this? I have never seen this behaviour before. My Drupal version is 7.52 and I use the Node clone module, version 7.x-1.0, together with the Node clone tab module, version 7.x-1.1.


texts: How to implement pager in custom page template?

texts:
in my theme I need a custom front page which displays a filtered set of news and paginated. The news are nodes with content type=news, and every one has a field "is topnews", so that only the freshest topnews is displayed at the top and all other news are displayed (with another layout) below the topnews.

So I created a page--node--9.tpl.php (which corresponds to the "empty" frontpage I created in the drupal backend), and used this code to get the topnews:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node');
$query->propertyCondition("type","news");
$query->fieldCondition("field_news_typ","value","Topnews","=");
$query->propertyOrderBy("created","DESC");
$query->range(0,1);
$result = $query->execute();

Then I output the topnews with its special HTML and use this code to get all other news:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node');
$query->propertyCondition("type","news");
$query->propertyOrderBy("created","DESC");
$result = $query->execute();

In the iterator loop I check the node-id against the topnews-node-id and output regular HTML for the news if they don't match. Now I want to add a pager to the mess so I can paginate the "normal news", but adding a ->pager(3) to the second query before the execute() call does not work and a var_dump(theme("pager")) returns NULL.

So there are two questions:

a) how do I make a pager (bonus points: the end result should be an AJAX pager which loads the HTML for ordinary news!) and

b) how do I move all that logic out of the .tpl.php and instead follow the "proper" drupal way? I imagine that having the "ordinary" and "topnews" HTML in separate .tpl.php files would be helpful in implementing said AJAX paging.


texts: Views Search Returning Unexpected Results

texts:
Problem:
Items are not grouping correctly.

The Setup:
I'm working in Views and trying to customize it to display items grouped by a taxonomy term field called 'Event Type'. Furthermore I'd like them to be grouped WITHIN each taxonomy term grouping by Category (in a specific order). Each resource has both an event type and category. There are three event types: timely event, quick study, and deep dive. There are 10 categories: webinar, conference, articles, etc. 3 of those categories are also in 'Timely Events'. 4 of them are in 'Quick study'. The other 3 are in 'deep dive'.

My categories are setup to be ordered. The category field is a field list and has key/value pairings to match what I want. So, for example:

1|Webinar
2|conference
3|Workshop
4|Articles
etc.

Note that webinar, conference, and workshop will the 3 under 'timely events' and that's why they're ordered that way. The next four starting with Articles are under 'Quick Study', etc.

So I have it structured the way I want it to appear in the view already. And I want the view to reflect this by displaying something like this:

Timely Events
All webinars listed
All workshops listed
All conferences listed

Quick Study
All Articles listed
All [other 3 categories in order as set in the key/value pair above]

Deep Dive
Same as the others

Then in the view itself I have set Format > Unformatted List > Settings (Grouping field Nr. 1: Content: All taxonomy terms).

In Fields I have 'all taxonomy terms' set as the first field, with the following settings: 'exclude from display' and 'limit terms by vocabulary' > set to 'event-type'.

Under 'Content: all taxonomy terms' in 'Fields' I'm displaying icon, price, title, event dates, and body.

My filter criteria is set to published, type=resource, search terms and other exposed filters.

My sort criteria is set to Category (asc), event-dates asc, content: title.

The Result:

    Timely Events (header)
    All webinars listed in the correct order.

    Deep Dive
    All certificates listed in the correct order.

    Timely Events (again - why?)
    All conferences listed in the correct order.

    Quick Study
    All articles listed in the correct order.

    Timely Events (yet again)
    All workshops listed in the correct order.

My Question for you:
How can I get my results to display so that the headers (event type) display ONLY ONCE followed by each of the categories in that header in the order in which I've set them in the key/value pairing in the field list?

It should be like this:

Timely events (header)
all webinars
all conferences
all workshops

Quick Study (header)
all articles
etc.

Deep Dive (header)
all certificates
etc.

And that's it.

Anyone have any idea how to correct my grouping here?


texts: I'm looking for a Drupal Commerce Shipping in-cart estimate

texts:
I am working on a Drupal Commerce site, we are trying to add a feature in the cart that would allow the user to input their zip/postal code or country and receive an estimate on shipping, before proceeding through the checkout. I'm new to Drupal Commerce, so maybe this functionality already exists?

a shove in the right direction would be greatly appreciated. Thanks.


texts: How to override title for exposed filter views under cache?

texts:
I want to override the title for Exposed Filter views.

I tried to use hook_views_pre_view hook_views_pre_render and hook_views_post_render and more. This doesn't help me because my views is under cache(if I clear cache then it works, but I have to do each and every time).

Is there any option to set title for cached views? I want searched field as page title.


texts: How to change link in a view depending on state of a certain field

texts:
I have a content type called conference, there are two types of conferences; supported and unsupported.

Supported have their own node inside Drupal, unsupported link out to external websites rather than having their own node. Supported also have the same external link.

There is a field selection for this in the conference content type so the user picks whether a conference is supported or unsupported.

Now I have a view of conferences and their title is a link. However I need to check whether each conference is supported or unsupported, as this link will either be a link to the node or a link externally.

Looking for any suggestions on how to achieve this, I'm guessing views PHP would achieve this, but is this the best option?


texts: Require visitor to fill a form to view contents

texts: How can I require visitors to fill in a form if they want to view certain pages?


texts:
I'm new to Drupal and I thought a lot about planing a column layout at my frontpage. In each column there is a teaser list of nodes. I have one row with 3 columns, the next with 2 columns... I can't upload the mockup, but I hope you imagine what I'm working on. The important thing is grouping the node lists to different columns.

So what should i use to code this? Blocks? Views? Something with panels? At the moment I'm a little bit confused about all these options...

Greetings


texts: How to make 'Views' consider contextual filter value to be 'all' automatically?

texts:
What I am trying achieve here(d7) is a bit cleaner URLs which is looking odd due to 8-12 contextual filters. Except 1 or 2 filters others will be /all most of the times.

Suppose I have 5 contextual filters. When only the first one has value, the URL becomes example.com/24/all/all/all/all. Is there a way we can avoid "/all/all/all/all" ?

I have also tried using query parameters through PHP CODE.

If I choose 'Provide default value' ->  'PHP code' and use

$query= $_GET['clr'];
return $query;

Is there a way we can tell views to consider "query=all" for other queries automatically if that part is omitted in URL?

For ex:
If URL is

  example.com?clr=1234

the view should assume it to be

  example.com?q1=all&q2=all&q3=all&q4=all&clr=1234