texts: Constructing array of term reference labels in php template?

texts:
I'm currently trying to set up a simple LMS and have already defined a content type course that contains a term reference field accesstags, which I would like to use for defining view permissions. I.e. the field accesstags will contain multiple terms that will be linked to roles that should have access to the node in question.

To make a long story short: I have created a custom module that contains the function hook_entity_view_mode_alter and I would like to check, whether the term reference field accesstags contains the term "subscription":

function hook_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) {
  ...
  if (in_array('subscription', ?????)) {
    ... allow access ...
  }
  ...
}

However, I'm not sure what to put at the spot that I marked with "?????". I know that I can construct the array of referenced terms by using $entity->get('field_accesstags')->referencedEntities()... but this array then contains the whole structure, whereas I only need the array of labels.

Is there an easy way for getting this array? Maybe even a built-in function?

Any help would be much appreciated.


texts: How to replace "default" with website domain name during drush user-login

texts: When I run drush user-login username, drush prints a url like http://default/user/reset/1/32323933.... How do I replace default with the actual website name?


texts:
Considering login security for user logins, I would like an additional option such as a PIN option for all aspects of user login. This seems quite common now across a number of portals out there such as personal banking, social security/gov. tax sites and I would like possibly to offer this as an option to those who do not want to use Facebook, Twitter etc logins which I use on my projects. I appreciate it could simply be an additional field in the system config, but I would be keen to hear any comments on such features, or possibily a popular D7 module which most people use which for me as a Drupal 'plumber' can just drop in for easy of setup, or a generalistic 'how-to'.

Thanks in advance.


texts:
Possible Duplicate:
  Programmatically create a token

How do I create custom tokens?  Also, is it possible to attach a token to a callback function?  For example: If my string is 'this is my [name]', can I somehow make it so that [name] will be replaced with the return value of a function?


texts: I have a content type that has a unique field.  How can I load a specific node based on this?  node_load() only takes the nid.  I am using Drupal 7.


texts: Improve extremely slow 'drupal_process_form'

texts:
I am having problem investigating why our profile edit page is damn slow.

Call Stack
#   Time    Memory  Function    Location
1   0.0003  276344  {main}( )   ...\index.php:0
2   1.6889  39666816    menu_execute_active_handler( )  ...\index.php:21
3   1.6899  39668968    call_user_func_array:{C:\wamp\www\hyperDrupal\includes\menu.inc:527} ( )    ...\menu.inc:527
4   1.6899  39669448    entity_ui_get_form( )   ...\menu.inc:527
5   1.6901  39696720    drupal_build_form( )    ...\entity.module:1282
6   1.7842  40984120    drupal_process_form( )  ...\form.inc:385
(7) 17.3247 58502824    form_execute_handlers( )    ...\form.inc:903
8   17.3247 58503344    profile2_form_submit_handler( ) ...\form.inc:1519
9   17.3265 58492400    profile2_save( )    ...\profile2.module:621
10  17.3265 58492528    Profile->save( )    ...\profile2.module:311
11  17.3265 58491736    Entity->save( ) ...\profile2.module:918
12  17.3265 58492096    EntityAPIController->save( )    ...\entity.inc:333
13  17.3737 58517352    EntityAPIController->invoke( )  ...\entity.controller.inc:462
(14)    23.5502 90243232    module_invoke_all( )    ...\entity.controller.inc:355
15  23.5511 90247648    call_user_func_array:{C:\wamp\www\hyperDrupal\includes\module.inc:951} ( )  ...\module.inc:951
16  23.5511 90248096    bdEvent_entity_update( )    ...\module.inc:951
17  23.5511 90248832    bdE\bdEvent->dispatch( )    ...\bdEvent.module:44
18  23.5567 90332840    bdE\Services\profileService->run( ) ...\bdEvent.php:38
19  23.5568 90333120    bdE\Services\profileService->entity_get_values( )   ...\profileService.php:24

I created a stack trace in a new module and times are huge. Check step 7 and 14 both are after long operations.

What could be taking so much between

6   1.7842  40984120    drupal_process_form( )  ...\form.inc:385
7   17.3247 58502824    form_execute_handlers( )    ...\form.inc:903

and between

13  17.3737 58517352    EntityAPIController->invoke( )  ...\entity.controller.inc:462
14  23.5502 90243232    module_invoke_all( )    ...\entity.controller.inc:355


texts:
I am building an entity reference widget, which displays the reference link, next to the input field, to the target entity's edit form.
I make it to open in a modal, with the following attributes on the link:

 'class' => ['use-ajax'],
          'data-dialog-type' => 'modal',
          'data-dialog-options' => json_encode([
            'height' => 700,
            'width' => 900,
          ]),

That works perfectly. However when I click submit on the modal form, I got redirected to the referenced entity view page, instead of the modal being closed and stay on the original form, where this widget is being used.

Is there any special attributes (like "data-dialog-type") which tells to the modal form's submit button to close the modal instead of redirecting to the original view?

UPDATE

Adding this to the URL actually pretty much solves the problem:

    'query' => [
      'destination' => $this->requestStack->getCurrentRequest()->getRequestUri(),
    ],

This redirects the to the original page, with the potential values being updated (referenced item title), which is actually a pretty good thing!

That being said, I am still interested in the "ajax submit" version!


texts:
Is is possible to insert user-editable text as a form component?

I would need some custom text between the "email" and "name" fields. How do I achieve this?


texts: Get the default image for a profile2 image field with code

texts:
I need to get the fid of the image specified as the default for an image field in a profile2 profile.

There is a field_get_default_value function, but it is not clear to me how to use it.

I'm using Drupal 7.


texts: Drupal custom page template based on the title of the page

texts:
I have the following page:

About us

Whose path is:

site.com/node/6

Theme suggestions for the template files are:

page--node--6.tpl.php
page--node.tpl.php

You should already know that it is too weird to create custom template files based on the node's id, thus I like to have my custom page template based on the page's title (of course, converted to machine name, for instance "About us" to be "about-s"). What should I do?


texts:
I'm using drupal_mail() to send mails from the HTML formatted content.

It takes more time to send mails. Actually, Mail is triggered while the form submission after the save logic.

To save the page loading time, how can I send emails in an asynchronous process?


texts: Bullets and numbers not visible in CKeditor

texts:
When I edit something in CKeditor and insert a list, the bullets or numbers are not rendered in the result.
Is it possible to correct it?


texts: How do I get a list of two different categories of vocabulary in drupal7?

texts:
I have a content type, there are two terms Term reference in different categories,I would like to have a related post block and the relevant posts of the two term references are the same.

I use views, can only be related to a classification, another classification using conditional filtering, but the conditions can not be filtered dynamic call, this is not what I want!

What should I do, please help me, thank you very much!


texts:
I have a view which has 2 displays i.e 'page' and 'attachment'.

I am trying to fetch the id from the url and want to display it on 'attachment' display but having difficulty.

On the 'attachment' display, I want to display a text with link to another page alongwith the url id.

If I use 'Contextual filters' then what is the next step to display above text alongwith this id as  tag? or perhaps any other solution.


texts: Need of re-indexing on search on Drupal site?

texts:
My client site has a table whose data is coming from Indexed view, sometimes updates made to the data wont reflect in the view table. Elysia cron is installed and up running, which should update the content when changes are made.

Then what is need of re-indexing the search index?

I could see my index only 1% indexed even though I ran the cron 2-3 times.
Can anyone help in this?

Thanks in advance


texts: How to set default body message for Privatemsg embedded on page?

texts:
This is the code I used on the node template and block, I just tried it both
module_load_include('pages.inc','privatemsg');
$recipients = array(user_load(arg(1)));
$subject = 'This is just a default that can be changed';
$body = 'Again, this is just a default that can be changed';
print drupal_render(drupal_get_form('privatemsg_new', $recipients, $subject, $body));
The Bold ones are the codes I added from the orginal code I got from here: https://www.drupal.org/node/624528
But I'm getting this message when I added the $body:

You can not reply to this conversation because all recipients are
blocked.

I've looked into the parameter of privatemsg and it says that the $body is the body text of the new message.
I would like to put some default body message on the embedded privatemsg.
I tried to edit the body via custom module, still no luck for me. I'm not sure where I went wrong.. here's the code on the custom module
function sassy_hook_form_privatemsg_new_alter(&$form, &$form_state, $form_id) {
   $form['privatemsg_new']['body'] = array(
    '#type' => 'textarea',
    '#title' => t('Message'),
    '#rows' => 6,
    '#weight' => 0,
    '#default_value' =>  t('Message'),
    '#resizable' => TRUE,   );
}

I also tried $form_state['values']['body'] = 'Hello World';
Is there any way to do this?
What am I missing?


texts: Drupal 7 : How to align image uploaded through Image-Field

texts:
I have an Image-Field in one of my content-types, How do I align (just that) image to the center of the content?

Appreciated.


texts: I'm trying to display an embedded video in a popup window using the Magnific Popup Module. For the video field, I'm using Video Embed Field.The popup window works with images trouble-free. However when I try to set up the display with the video field (Magnific Popup formatter), the throbber keeps turning and I'm not able to save this configuration. Any ideas on that?


texts:
I imported 500+ users into Drupal 7 by Feeds module. However, 1 of the user has 2 accounts. I got a error message "This name has already been taken by another user." when chaning their roles. Their username is different, but account A user name is same as account B email address. I think they have user name and user email conflict. Is it possible to fix this without changing username and user email?

User account A:
Username - usernameX
user email - usernameX@gmail.com

User account B:
username - usernameX@gmail.com
user email - usernameB@gmail.com


texts: How to include media documents in search

texts: Is there any way to include documents I created with the media core module into the search form of the page? I only found the categories "users" and "nodes".


texts: Search API: sorting with Scandinavian alphabet

texts:
We're using the search API something like this, and returning results in alphabetical order:

// Set up
$search_api_index = $this->entityTypeManager->getStorage('search_api_index');
$index = $search_api_index->load($name);
$search_id = 'restful_search_' . uniqid();
$query = $index->query([
  'limit' => $limit,
  'offset' => $offset,
  'search id' => $search_id
]);

// Add some conditions
$query->addConditionGroup($conditionGroup);

// Add sort directive
$query->sort('title', SORT_ASC);

This is working, and the results are coming back in alphabetical order. However, we'd like the sort according to the Finnish/Swedish alphabet.

So instead of things being sorted like "ÄBC", we'd like them sorted like "BCÄ". That is, those beginning with Å, Ä and Ö etc. should come last, not first.

Is it possible to tell the Search API to return results which meet this order?


texts:
salute you. I have one problem need your help. I want to create 2 menu list of product categories and product prices. there should be a link between two product categories menu to the product menu to display the products desired by the user. for example i have 2 menu after

categories:

dell servers
ibm server
hp server

price:
$ 100 to $ 500
$ 500 to $ 1000
$ 1000 to $ 2000

When I click on dell server it will display all the products dell server and when I continued to click $ 100 to $ 500 it will display the products of dell servers have priced 100 $ to 500 $. thank you


texts: Date Repeat: Display only the first and last instances of a series?

texts:
I have been going crazy trying to find a way to display only the first and last dates of a series using Date Repeat, either in a view or the node itself, of repeating events.  For example, there is a course that starts on January 16, and repeats every Monday until March 5.  I would like to be able to display something like "Every Monday from January 16 until March 5" or something to that effect.  Does anyone have any advice, can anyone point me in the right direction?

Thanks in advance!!


texts: Display content between squares with links

texts:
I want to build a Drupal 7 website with big squares which contain a title and some text. In a desktop layout there will be 3 rows of 3 squares. Each square is a link to one or more underlaying pages. I am thinking of using the views module to make this work.

After clicking on a square, the content of the underlaying page has to be displayed right under the row of this square. So, if a visitor clicks on a square in the first row, content should be displayed between row 1 and row 2. By clicking on a square in the second row, content should be displayed between row 2 and 3. I have no idea how to do this. Any suggestions would be welcome.

Thanks,
Steven


texts: Can menuTree load a menu's items including children

texts:
From what I understand I should be able to retrieve all the items in a menu using menuTree. However I only get one level/depth no matter what I try.

My Menu Looks Like:

  Imported Content
  --Products
  ----A Child
  ------Grand Child
  --------Great Grandchild
  ------Grand Child 2
  ----Child 2
  --A Sibling
  Screenshot from Drupal: https://www.evernote.com/l/AAKdnwekb7BM87AFANo1z2XjCdEvR8HgDEI

This is my code:

$menu_name = 'imported-content-menu';
  $menu_tree = \Drupal::menuTree();
  $parameters = $menu_tree->getCurrentRouteMenuTreeParameters($menu_name);
  $parameters->setMaxDepth(100);
  $parameters->setMinDepth(0);
  $tree = $menu_tree->load($menu_name, $parameters);

When I inspect $tree, it is an array of two items "Products" and "A Sibling".

I inspected these two items to see if there were nested items (the children) but there were not.

The "Products" item has 'hasChildren' set to TRUE. But I don't see those children.


texts: Views Pager, Can I change Items per page dynamically as provided input?

texts: Is it possible to send Items per page limit in query string of view page url and get records according to that?


texts: Location province views exposed filter as a select list or checkboxes?

texts:
I'm displaying google map using gmap and location module through views.

I want to add a province exposed filter to the view as a select list or checkboxes but I'm unable to do this.

When I add the province filter, it displays as a simple textfield.

Any option or some kind of small code to accomplish this functionality.

I also tried better exposed filter but nothing change.


texts:
Is there a way to manage stock levels with Drupal 8 Commerce?

I am not sure, but I believe Configure product attributes refers to product attributes, but it doesn't outline how to create stock management.


texts: How to filter nodes on a view based on user role shared by both nodes authors and current user?

texts:
Working on Drupal 8.9.1
I need to list nodes with Views and filter them based on user role shared by both nodes authors and current user.
If I add a relationship to content author and a contextual filter on (author)User ID with default provided by logged user ID, I only get nodes authored by the current user.
Let's say we have a role "Staff A", I need any user with this role to be able to see any nodes from any users with the same role "Staff A".
Thanks for any tip here.


texts: How do I change the position of "sidebar first" for the Arabic version of website?

texts:
Can I change the position of the "sidebar first" if I change the website language?

More Details: My default website language is now English, and my "sidebar first" is in left position. This is what I want: to change the position of the "sidebar first" if I make the website in the Arabic language.


texts: Not getting along with the form API tutorial

texts:
I am using Drupal 7, and I want to build a form. I tried to follow the tutorial in "Pro Drupal 7 Development"; I created a .module and .info file, which are supposed to work, I activated the module, and now I don't find the form.

How can I see the form in the front end, or at least at the back end? Is there a URL Drupal is giving to this module? How can I see it?


texts: The dynamic value of the field, depending on the authorized user

texts: Friends, hello. I ask for help, I can’t figure it out. I have the following task: There is a node type "product", it has a field "field_product_url". A link is imported into this field using the Feeds module. The link is usually of the form ad.admitad.com/blabla/blabla/subid1=userid. I need that after the user logs in, userid changes to the id of the user who logged into the site. For example, for a user with uid 2, the link should be like this: ad.admitad.com/blabla/blabla/subid1=2. That is, the value of this field must be dynamic, and change for each user. I was advised by hook_node_view, but I still did not understand how to do this. Please advise how I can solve this problem. I will be grateful).


texts: Drupal commerce - same product with different formats that determine price and get added to line item titles

texts:
I have a taxonomy term select list where the administrator can add one or more formats to a product entity. The term itself has a price coefficient field that should be used to determine the price of the product in that format. On the product display page there should be a 'add to cart' button for every format of that product. The title of the product in the cart/order views should display the format and the price should be according to what was calculated using the product base price and the format coefficient.

Any generic ideas how I could implement this with the Drupal Commerce module or good alternatives that accomplish the same thing? It could be assumed that every product display has only one product entity associated with it if this makes things easier.


texts: Large, regular product import for Commerce

texts:
I am in the process of developing a new site using Commerce Kickstart.

The site needs to import a fairly large amount of data from a CSV on a regular basis - perhaps 50,000 to 100,000 products at a time, at least every week. (And maybe more often than that.)

I have tried to use Feeds to do a test import of around 30,000 products. (So this creates 30,000 product variations and 30,000 display nodes.) This has proved to be far too slow for my purposes, taking around 18 hours.

So I see my options as follows:

Run some profiling to attempt to see why the import is slowing down
so much (It starts off at around 200 products / minute and slows
down to 10-20 by the end of the import run.)
Following the strategy here, import into a single table, and use entities to do what I need to do. With this approach, I am concerned about losing or having to re-implement the functionality I need to make the site work - namely faceted search / unknown regular commerce functionality. Each product - each line of the CSV - has numerous fields of data that would have to be stored, so I'm not even sure if this approach would work.

Does anyone have any advice on the best way to progress? Or any hints about the above? Or strategies to import the data that I might not have considered?

Thanks in advance.

EDIT:-
Looking at the Feeds log, it looks like the product variations imported in 1 hour 20 mins, whereas the product display nodes took 17 hours to create.


texts:
I have a few node titles that are being saved with & and displaying that way too.

Is there any way to not encode them while being saved? I tried:

$node = node_load(727);
$node->title = html_entity_decode($node->title);
node_save($node);

I dump out the node and the title is corrected, but is not saved that way. Should I only try to correct the display using the same function?


texts:
I am making a book rental cum selling site. I have planned to use Drupal Commerce for it. But tracking the item is simply not possible & so that I am trying to find the solution for assigning serial number for each number of items(attributes) for drupal commerce product.

Like I am having a BOOK & it has 10 copy, so I want to keep one unique serial number for each copy.

If somebody have any idea about this then please help.


texts:
Actually, I am looking for a solution of entity reference module, I don't know whether its possible or not. Please let me know if its possible.

Example:

Content Type : A
Content Type : B

Content type B  (a field) referencing Content Type A,

So, if I want to make a list of content of content type A, which is referencing in content type B, I can do it with views and entity relationship.

But I am looking for a solution where I want to make a list of content of Content type A, which is not referencing in content type B yet.

Is it possible, if yes then how?


texts: Views data export remove tags from xml output

texts:
I want to remove <no-name> tag generated by views data export on xml output
Any ideas please?

I have already tried to override template output for the field but no results :(


texts: Drupal 7 permission to editor type user showing certain admin menus

texts:
I have created the editor type user and now I would like to show only content menu and block menu to show in administrator area. But even I have change the permssion but top admin menu is not showing. if i assigned the admistrator role to editor user whole administrator menu showes up. but I only want to show certain options in top menu.

How can I do this.


texts: What Drupal module that usually handle this kind of variable format [field_box_image_fid]

texts:
Hi guys I badly need your help. I am new at Drupal, our site is doing fine a while ago. Until my supervisor told me to modify a job posting posted from our drupal site.
I cannot find the source page which I need to edit, so I use THEME DEVELOPER plugin to find out if the content I am searching is can be found in .TPL files. Upon activating the THEME DEVELOPER theme, theres a prompt that told me that activating this module might cause problem. I ignore the warning message and thought that if an error occur it can be solve immediately upon disabling the module.
I already disabled the THEME DEVELOPER module, but our site is completely malfunctioning. It displays  [field_box_image_fid] [field_box_image_fid] [field_box_image_fid] [field_box_image_fid] [field_box_image_fid] [field_box_image_fid] [field_box_image_fid] [field_box_image_fid] from our site homepage.
I don't know what modules I need to turn off or turn on to put this down.
NOTE: We are using DRUPAL 6


texts:
Here is what I am trying to achieve.
I have two roles Teachers and Students.

Each teacher has images of answers written by the students in an exam. After checking these papers, teacher takes an image of each answer-sheet. He names it in a certain pattern using student-id. Thus, teacher has many images (like sid-1-im1.jpg, sid-1-im2.jpg, sid-2-im1.jpg). A student can have multiple images on his name depending on how many sheets he had submitted.

I want to create a website where a teacher can create a folder for this exam, say, Economics-2017-2018. Within this folder, he can upload all images.
What would be the best way to achive this folder+multi-file upload?

Next I want to programmatically assign permissions to these uploaded images based on student id of the file name. So that, a student can view only his files.

How can this programmatic feature be achieved.

There are more features such as notifying students, ability to comment on files etc. But, I think drupal can handle them easily.

I intend to use Drupal 7 or 8 for the purpose.


texts: How to retrieve data from set with drush_set_option() from within install profile

texts: I've been messing around with trying to pass varabiles to an install profile based on a signup form, as descripbed in this post. I'm able to get the data out of the form and into drush using hook_pre_provision_install(), but I'm not sure how to grab that data from within the install profile that was set with drush_set_option().


texts: Get programmatically value of sub field collection item of a field collection

texts:
I have a field collection

field library

and a sub field collection

field book

which has a  field collection item field title.

to get the first field collection I use a wrapper:

$node_wrapper = entity_metadata_wrapper('node', $node);

foreach ($node_wrapper->field_library->value() as $key =>
$field_collection_wrapper) {
$ffp = $field_collection_wrapper->field_title[LANGUAGE_NONE][0]['value'];
}

but I need another for each inside the first foreach to get the item of the sub collection.
How should I do it?


texts: On the profile page that is /user/1 for e.g how to add tab MY ADS to be /user/1/myads?


texts: Custom entity, cant't display entity reference as a link

texts:
I created my custom entity named: image_gallery_basic and I am trying to use it in my new project. As it was my first ever created entity, it has a lot of things missing I guess. I created a content type named review, where user is able to write his review and image gallery is created with the same name as review title. Everything works and it is being created, although when I tried to change it display to link, it doesn't work. I am pretty sure something is missing from my hook_entity_info, but I am not sure what, can some one please put me on the right track? I add my hook_entity_info function.

function image_gallery_entity_info() {
  $image_gallery_info['image_gallery_basic'] = array(
      'label' => t('gallery'),
      'label callback' => 'image_gallery_label_callback',
      'base table' => 'image_gallery_gallery',
      'uri callback' => 'image_gallery_uri',
      'fieldable' => TRUE,
      'entity class' => 'Entity',
      'controller class' => 'ImageGalleryController',
      'access callback' => 'user_is_logged_in',
      'view modes' => array(
        'image_gallery' => array(
          'label' => t('image_gallery'),
          'custom settings' => FALSE,
        ),
      ),
      'entity keys' => array(
        'id' => 'id',
        'uid' => 'uid',
        'title' => 'title',
        'created' => 'created',
        'changed' => 'changed',
        'gall_description' => 'gall_description',
      ),
      'static cache' => TRUE,
      'bundles' => array(
        'postit' => array(
          'label' => 'ImageGallery',
        'admin' => array(
          'path' => 'admin/structure/image_gallery/manage',
          'access arguments' => array('administer image gallery'),
        ),
      ),
    ),
      'view modes' => array(
      'full' => array(
        'label' => t('Full ImageGallery'),
        'custom settings' =>  FALSE,
        ),
    )
  );
  return $image_gallery_info;
}

This is how it is in the Manage display settings:

And this is how my created review looks like. Under Gallery it should show link not a plain text.


texts: Page not Found error when Views block containing node titles links placed on a specific content type

texts:
I have a content type News whose nodes are used to generate two blocks using views "Most read news articles" and "Latest news articles". These blocks are printed through node--news.tpl.php tpl file when news is displayed in full view mode.

Problem is that that all the title links in blocks lead to "Page not found" due to URLs overridden as http://example.com/news/node/49610 while actually they should be like http://example.com/node/49610

When checking through firebug I can see that links are correct:

Popular product taken down

All links work perfectly When same blocks are placed on the <front>.

Any help to resolve this is highly appreciated.


texts:
I would like to know what is the correct version format for custom modules in Drupal 7.
I see some contributed modules come with 7.x-1.2-rc1. I don't know what is rc1.
When I name my custom module with version 7.x, my module didn't work in module installation and it wasn't enabled. When I name the version 7.x-1.2, it works fine.

Is there any documentation for Drupal module version format?


texts: I know the shopping cart is generated by the view shopping cart form. But how do I remove the shopping cart block on left sidebar of the home page and still maintain the the view on /cart page? I have tried disabling the view entirely, that didn't work as it seems the block is hardcoded.


texts: How can I hide the primary menu block to certain pages using PHP?

texts:
I tried this code to hide the primary menu block from certain pages using the following code:

// Only show block from types array and nodes array
$match = FALSE;
// Which node types
$types = array('page' => 1);
// Which nodes (by nid)
$nodes = array(1, 13);
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load(array('nid' => $nid));
  $type = $node->type;
  if (isset($types[$type]) && in_array($nid, $nodes)) {
        $match = TRUE;
  }
}
return $match;

Currently, the block is set to visible in the header section of the site; the theme being used  is the Bluemarine theme.

Is there anything else that needs to be done?

Print Screen

http://i.stack.imgur.com/m6y4I.jpg

Menu Print Screem

http://i.stack.imgur.com/yUBD2.jpg


texts: Render admin pages (forms) alongwith their admin theme from within a custom theme

texts:
I am working on an already set up site where the custom theme was created very much manually and the head-region markup, incl. logo, main menu, user menu, etc. are manually rendered with a particular set of CSS based on twitter bootstrap. The admin theme was left alone, so it doesn´t have those head-region markup. But I do want admin pages/forms to seamlessly be rendered with the custom styled head-region. I tried isolating the css used in the head and added it to the admin theme´s page.tpl. This proves quite disastrous, since a hell lotta css conflicts come up, esp. because of bootstrap.css.

One lousy way would be to add element specific resets. But perhaps there´s a way to shield/wrap the head and the form so that they can still coexist on the same page with their own baggages of css+js?


texts: How to list all nodes with alphabetical headings?

texts:
I want to list all nodes with alphabetical headings like this example http://www.animeseason.com/anime-list/
How can I do this?


texts:
I'm very new to Drupal 8 theming and I'm trying to replicate a random website to practice.

I have a problem recreating this part though:

I have a block with the latest news articles and a block with most popular.

I wonder if I could put unique classes on each item in the list (of latest news), that way I can make the widths different and make the floats work.

Is there anyway to do this? If I'm doing this wrong and there's a better way, feel free to tell me!


texts: Programatically Create Nodes with Body and Custom Fields

texts:
I need to write a module that will fetch remote content via an API and store it as nodes. These nodes have custom fields defined within the module. I have already accomplished this by modifying the Node Example Module.

I can add nodes via the admin end with all the custom fields, but when I'm trying to programatically create the nodes from hook_install(), the body and custom fields are not saving.

The code for creating the fields is largely the same as the example I linked. Here's the function i'm using to create the nodes:

function sm_add_mashup_item_node($remoteId, $site, $text, $image, $time){

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

    $node->title = "My Awesome Title";
    $node->language = LANGUAGE_NONE;
    $node->created   = time();
    $node->timestamp = time();
    $node->changed   = time();

    $node->status = 1;
    //$node->uid = 1;
    $node->promote = 1;
    $node->sticky = 0;
    $node->format = 3;
    $node->language = 'en';
    $node->revision = 0;

    $node->body[$node->language][0]['format'] = 3;
    $node->body[$node->language][0]['summary'] = 'summary';
    $node->body[$node->language][0]['value'] = 'dfg sdgdfs gsdg sdfg sdfg sdfg sdfg sdfg sdfg sdgsdf';

    // Try to set your custom field
    $node->rscg_mashup_image_url[$node->language][0]['value'] = "Too many to count...";

    echo "\n Edited: \n";
    print_r(node_load(526));

    echo "\n Pre-Save: \n";
    print_r($node);

    $node = node_submit( $node );
    node_save($node);

    echo "\n Loaded: \n";
    print_r(node_load($node->nid));

    return;

I've tried countless variations of the above.

Here is the debug output from the function:

https://gist.github.com/agroff/1c2c22920c20e3775b0d

This is a screenshot of the field list.


texts:
I have a custom content type named "My content type".

I want to use a custom view to render a full content page for that content type. Currently I can only use a Default view that can be found in "Structure > Content types > My content type > manage display" but that is not what I want. I want to get rid of that and be able to use a custom view (from Views module).

How can I achieve that?


texts: How to use .schema.yml definition for two entities avoiding duplicated code

texts:
What is the yml syntax in drupal .schema.yml files for specifying the same config for two entities? Something like this is what I need:
node.type.*.third_party.my_module:
media.type.*.third_party.my_module:
  type: mapping
  label: 'My Module'
  mapping:
    lots more lines here ...
    which I do not want to duplicate ...

I want the same settings for both node.type.* and media.type.* and there should be a way to avoid repeating all the definition and just having those two rows at the top.


texts: How to exclude fields from print page version (html, pdf)?

texts: As in question, excluding node fields from HTML print page is easy via CSS, but what about PDF version (PDF version module)?


texts: How to get a count of number of nodes created per month in views

texts:
I have created a view using aggregation which counts the number of nodes created of a certain content type.  I want to be able to group these by month i.e. Jan - 10, Feb - 15, Mar, 20 and so on.  At present it is just a count of all nodes created.

How do I do this with views?  I've looked around and cant seem to find any information how to do this.  Any help would be appreciated. thanks


texts:
I am using Media 2.0 and a media field in a custom admin form.

I am trying to set the default value as described on
https://www.drupal.org/project/media/issues/1158760#comment-12656764, but `#default_value = array('fid' => 1234); doesn't work.

How can I set the default value for a Media form element?


texts: Using variable_get from DrupalWebTestCase

texts:
I would like to pull certain configuration items from settings.php from a DrupalWebTestCase in order to test my module (in this case, a SFTP module).
I want to do it this way so that I don't hardcode my SFTP credentials.

For example, in my DrupalWebTestCase, I have:

  public function test_sftp()
  {
    $this->assertTrue(variable_get('mymodule_test_sftp'));
    // then I would try to connect, etc....
  }

In settings.php:

$conf['mymodule_test_sftp'] = array(
 'host' => 'example.com',
 // etc...
);

When I run the unit testing suite, this unit test fails, the value returned by variable_get is NULL.

Edit:

Running the code below, returns the correct database settings, but I get "Undefined index: mymodule_test_sftp":

  public function test_sftp()
  {
    global $databases, $conf;
    $this->assertTrue($databases);
    $this->assertTrue($conf['mymodule_test_sftp']);
  }


texts:
I have created a node entering content for its body field; when I return to the node edit form, the body field is empty.

What may cause this problem?


texts:
In Drupal 7, to get all fields used in a content type, I use the following code.
$fields = field_info_instances('node', 'article');

What is the equivalent for Drupal 8?


texts: Create view of child terms below parent term and how many nodes are tagged with those child terms

texts:
I have a content type called 'schools' and I have a vocabulary called "destinations" that contains:

-USA
-- New York
-- Miami
-UK
--London
--Manchester

I have 2 school nodes that are tagged with "New York" and "Miami", respectively. So:

School 1: Terms tagged with from "Destinations" vocabulary: "USA",  "Miami"
School 2: Terms tagged with from "Destinations" vocabulary: "USA",  "Miami"
School 3: Terms tagged with from "Destinations" vocabulary: "USA",  "New York"

I want to show a view on the top country level page. So on the USA page I want to show:

City: New York
No of Schools: 1
Name of School: School 3

City: Miami
No of Schools: 2
Name of School: School 1, School 2

I know how to create a view to show me the city name using a contextual filter: Taxonomy term: Parent term. But is there a way I can get the other two things to show: count of schools and name of schools? In the same view..


texts:
In terms of standards, is it okay to use a constant in a template file, or should its value be passed in via the variables?

E.g

Template:

<?php print MY_CONSTANT; ?>

Versus

Preprocess:

$variables['my_string'] = MY_CONSTANT;

Template:

<?php print $my_string; ?>


texts:
I am using profile2 module for my User profiles.

Now breadcrumbs on user profile pages are:

  Home > Username

I need breadcrumbs to be like this:

  Home > Custom page > Custom profile2 field

How can I change it? Thanks for your replies.


texts:
How to create review site with Drupal 7.7, FiveStar 2.x-dev, Node Reference URL, and Unique field?

Configuration:

Drupal 7.7
FiveStar 2.x-dev
Node Reference URL Widget
Unique field
Bartik theme

What I have now are:

Product node
User can write a review and rate each product node with multiaxis fivestar (value, price, and reliability).
User can create only one review per product (unique field module).
Rating is available when User create a Review node (Node Reference URL).

Questions:

How to embedded product node on the top of the review node? I want user to see what they are voting for without going back to the product node page.
How to create average rate of each category (value, price, and reliability) using Views?
How to compute average of all rating categories values? It means to create one number computed from average rating of value, price, and reliability.

Thanks for helping.


texts: How to create form on users account page?

texts:
I used hook_user_view_aler() to add some info to user's page.

 $account['summary']['member_five'] = array(
    '#type' => 'user_profile_item',
    '#title' => t('I do'),
    '#markup' => 'Real magic',
  );

  $account['summary']['member_six'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#default_value' => '',
    '#size' => 30,
    '#maxlength' => 60,
    '#required' => TRUE,
  );

  $account['summary']['member_seven'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );

Also I added form elements and they do appear but I couldn't submit it. hook_user_view_aler_submit() obviously is too much and it doesn't work. Is there any way to create form on user's page?


texts: What is cache_menu in Drupal 7 DB? Safe to empty?

texts:
What exactly is doing this cache_menu table in MySQL Database of my Drupal 7?

It is the hugest table of all = currently 308 mb.... (and I have disabled search term indexing, so this is absolutely the biggest now...)

Is it necessaru so huge?!
I assume it is so huge, because I it includes a few of my Book - menus as well, but still...

If it is just a Cache - would it be safe to empty / disable somehow?


texts: Apply a ranged contextual filter to a date in Views

texts:
I have an entity with a timestamp field that I would like to filter based on date. I can add a standard filter "between two date", type in two dates, and everything works great. However, contextual ranges do not work. I've read online that Drupal 7 allowed 2016-01-10--2017-01-01 or 20160101--20170101 as input and would display all results in 2016. These do not seem to work in Drupal 8. Is there a way to do range contextual filters in D8?

I've tried using a datetime field instead of a timestamp, and I am unable to filter this either.


texts: How to get date value from Smart Date field

texts:
What is the method for getting the start date value from a Smart Date field?
$s_dates = $service->get('field_date')->getValue();
dpm($s_dates);

gives me the output:
array:6 [▼
  "value" => "1612688400"
  "end_value" => "1612688400"
  "duration" => "0"
  "rrule" => "4"
  "rrule_index" => "1"
  "timezone" => ""
]

However $s_dates = $service->get('field_date')->getValue()['value']  gives me an 'undefined index' error.


texts: Handle an incoming POST in Drupal (not a form, an incoming external request)

texts:
I'm trying to get a handle on the best way to handle Mandrill incoming webhook requests, which are externally defined and not in a format that would normally be handled by the Services module or other API handlers I'm familiar with in Drupal. This is not a form, not not appropriate for the Form API. All I really know to do is to set up a menu router entry with hook_menu() and then process the $_POST. But it seems like there ought to be a better way.

It seems like most analogs of this are GET requests (like the Paypal IPN), which are a little more straightforward.

Suggestions?

BTW: The idea here is to have Mandrill handle incoming email and hit the Drupal site with a webhook request with the information from the incoming email already parsed out, so the Drupal site can take action, like posting a private message or replying to a comment thread.


texts: Display the taxonomy terms hierarchy with count of reference nodes added to it

texts:
I am displaying taxonomy terms in a hierarchical way in a view, I am facing an issue here the parent taxonomy is getting associated with each child terms separately, please find the screenshot.

I want it to be displayed like this

Electronics

--computers

--mobiles

--tablets

Fashion

--mens

--womens

--kids

This is my view, basically I am displaying the count of nodes added to the taxonomy term of another content type.


texts: How to update the current page to show new content?

texts:
I am currently displaying a list of MySQL database table names, such as table1, table2, table3.

Each table name will be a link; if users click on it, it will display them the data contained in that table.

One way I know I can do this is to create a Drupal page that contains the content of "table1", so that when a user clicks on "table1", they are taken to this page and can see the data of "table1".

However, this soon becomes un-manageable if I have a large databases with many tables.

I'm not quite sure if Drupal can work in this way, but I would like it so that when a user clicks on a table link (either table1 or table2 and so on), the current or a generic page will then be updated with the content of the table chosen and be updated with its content.


texts: How to implement properly a view of nodes displaying other referenced nodes with no duplications?

texts:
I know that this has been asked several times with different variations, but I cannot seem to find an optimal solution, so here we go again:

I have a content type 'Parent' and a content type 'Child'. The relation between the two is one-to-many i.e. there is a field within the 'Parent' CT called 'children' which is of type 'Entity Reference' and allows for multiple values. Now, I want to create a view that will fetch 'Parent' nodes and for each resulting row I want to display the respective children nodes. Something like this:

    -----------
    Parent 1
    - Child 1
    - Child 2
    -----------
    Parent 2
    - Child 3
    - Child 4
    ----------

Solutions I have found and explored so far:

1. Use a Relationship for the 'Child' nodes within the 'Parent' view

OK, I can now use the 'Child' node fields, but instead of having them grouped within the 'Parent' node row, I end up with one row per relationship and duplicate content

    -----------
    Parent 1
    - Child 1
    -----------
    Parent 1
    - Child 2
    ----------

How should I remove the duplicate content?

1.1 Use a 'distinct' in query options. Naturally, it does not work, because distinct is applied to the whole row and since parent-child field tables are joined, each row IS actually distinct

1.2 Use aggregation. Again the desired result cannot be achieved, since by grouping by Parent nid I will only get the first Child node reference

1.3 Use module views_distinct. OK, this seems to do the job, but it breaks the pager and the results counter as processing is done after the respective view queries have been executed

2. Use a views_field_view, so that respective 'Child' nodes are fetched by a separate view (via Contexual filter) and embedded gracefully within the 'Parent' node row.

OK, this definitely does the job, and I get no duplicates since the child field tables no longer participate in the Parent view query, BUT:

it is not performance optimal
performance gets worse considering that my project has 30 different views (for different content types) that need to function similar to the 'Parent' view in this example
since I already have 30 "main" views, I would hate to create another 30 ones only to be used as field views for the "main" ones

3. Do the job manually: use a 'Global: Custom text' field, use the template "views-view-field--parents--nothing-1.tpl.php" and implement the whole logic there i.e. re-load the Parent node, get the Child node ids, load the Child nodes and print their desired fields. OK, this does the job too, BUT:

it is not exactly the "Drupal way" of coding against views
once again, there are performance issues since I bypass Drupal and load stuff on my own
once again, I will have to implement 30 template files named like "*nothing_1" for each of my views

So, my question is the following:

Is there a solution for this issue other than the ones that I mention here? If not, then which one should I choose and how to overcome its disadvantages?


texts: Redirecting user-login-form on certain page

texts:
The scenario is :

I've implemented a menu using hook_menu and in that page it checks if user have access to creating certain content type (called request) if he/she does have access it will load content creation page using drupal_get_form else it checks if user is not logged in, in this case it loads user_login_block, again with drupal_get_form function, finally if user is logged in and still does not have access to create content type, it shows a message about that.

the problem is :
I want user redirect to this same page after login, it redirects to user/uid by default.

This is the code for my page provider function :

Global $user;
$content = "";
if(user_access('create request content')){
module_load_include('inc', 'node', 'node.pages');
$node_form = new stdClass;
$node_form->type = 'request';
$node_form->language = LANGUAGE_NONE;
$form = drupal_get_form("request_node_form", $node_form);
$content .= drupal_render($form);
}
else
if($user->uid == 0) {
  $login_form = drupal_get_form('user_login_block');
  $login_form['redirect'] = drupal_get_destination();//What I did to get form redirected, but no chance
  $content = '
For better controlling on your project flow consider signing in before submitting your file.
';
  $content .= drupal_render($login_form);
}
else
  $content = "Unfortunately only user of role customer can submit a request.report any problem by sending email to --------";
return $content;

I also tried Login Destination but it neither worked.


texts: Save value in form with multiple instances in same page

texts:
This is my buildForm function:

class NewsletterForm extends FormBase {
  // ...
  public function buildForm(array $form, FormStateInterface $form_state, $newsletter_list = NULL) {
    $form_state->set('newsletter_list', $newsletter_list);
    // ...
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    $newsletter_list = $form_state->get('newsletter_list');
    // I save $newsletter_list and others values.
    // ...
  }
}

I pass this form to template, specifically in hook_preprocess_alter():

function MYMODULE_preprocess_block(&$variables) {
  if ($route != 'layout_builder.overrides.node.view') {
    $newsletter_list = $block->field_newsletter->value;
    $form = Drupal::formBuilder()->getForm('Drupal\MYMODULE\Form\NewsletterForm', $newsletter_list);
    $variables['newsletter_form'] = $form;
  }
}

When my template show me two same form (but two different value in newsletter_list) and I fill the second one, the line $newsletter_list = $block->field_newsletter->value takes the value of first form. Why does it that? What am I doing wrong?

EDIT:
I use ajax submission.


texts: How do I assign a view to a panel node in drupal

texts:
I have a panel that shows a teaser of a bunch of nodes of a certain content type. I am attempting to replicate this for a new content type.

I have created a similar content type with the exact same fields. I have cloned the view(type = content pane) and changed the filter to the correct content type. I have now created a page of content type panel.

Question: How do I assign the view to that page(node)? Does it have something to do with display suite and the layout?

I am using Drupal 6.

EDIT: To put the above in another way:

I have a panel and I don't know how to apply a view to it. So I have my view that basically aggregates a bunch of nodes based on content type. I'm not sure how to add panel content to the panel. But the panel content being the query the view execute


texts: Send mail to product owner only when the email adress is available

texts:
As a follow up to previous questions asked by me:
Send mail to product owner with Rules and Fetch Customer Profile from Line Items. I have the following question.

I created a rule to send an e-mail to the product owner of a product in my commerce webshop. The email address is added to the product by hand in a custom field. The rule is working when the email address is available but when not available it sends out an error. How can I check to see if the e-mail address is there and only then send the e-mail.

This is my rule:

{ "rules_svds_send_mail_to_product_owner" : {
"LABEL" : "SVDS: Send mail to product owner",
"PLUGIN" : "reaction rule",
"ACTIVE" : false,
"OWNER" : "rules",
"TAGS" : [ "SVDS" ],
"REQUIRES" : [ "rules", "commerce_payment" ],
"ON" : { "commerce_payment_order_paid_in_full" : [] },
"DO" : [
  { "variable_add" : {
      "USING" : { "type" : "commerce_order", "value" : [ "commerce-order" ] },
      "PROVIDE" : { "variable_added" : { "commerce_order_value" : "Commerce Order" } }
    }
  },
  { "LOOP" : {
      "USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
      "ITEM" : { "line_items" : "Commerce Line Items" },
      "DO" : [
        { "component_rules_perform_an_action_on_a_selected_line_item" : { "selected_line_item" : [ "line-items" ] } }
      ]
    }
  }
]
}
}

The component I use in the loop is like this:

{ "rules_perform_an_action_on_a_selected_line_item" : {
"LABEL" : "Perform an action on a selected line item",
"PLUGIN" : "rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "mimemail" ],
"USES VARIABLES" : {
  "selected_line_item" : { "label" : "Selected Line Item", "type" : "commerce_line_item" },
  "commerce_order" : { "label" : "Commerce Order", "type" : "commerce_order" }
},
"IF" : [
  { "entity_has_field" : { "entity" : [ "selected-line-item" ], "field" : "commerce_product" } }
],
"DO" : [
  { "entity_fetch" : {
      "USING" : {
        "type" : "commerce_product",
        "id" : [ "selected-line-item:commerce-product:product-id" ]
      },
      "PROVIDE" : { "entity_fetched" : { "product_fetched" : "Fetched Product" } }
    }
  },
  { "entity_fetch" : {
      "USING" : { "type" : "commerce_order", "id" : [ "commerce-order:order-id" ] },
      "PROVIDE" : { "entity_fetched" : { "fetched_customer" : "Fetched user" } }
    }
  },
  { "mimemail" : {
      "USING" : {
        "key" : "[commerce-order:order-id]",
        "to" : "[product-fetched:field-e-mailadres-product]",
        "subject" : "Product ordered",
        "body" : "E-mail body text",
        "language" : [ "" ]
      },
      "PROVIDE" : { "send_status" : { "send_status" : "Send status" } }
    }
  }
]
}}

Thanks in advance


texts: Drupal 8 CKEditor dynamic internal links plugin?

texts:
In Drupal 8 CKEditor WYSIWYG editor when I create a link to an internal page I use this URL path which I type manually: /parent/child/pagename

I then found a few buttons that can be added to the CKEditor interface that allow you to search for existing pages and it autoatically creates these paths.

e.g. These seem to be the best options:

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

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

The problem I have is that it inserts the link into the HTML like so which is static:

test

When I then change that page name or location to someting else the link breaks.

What I'm looking for is a plugin that inserts dynamic links, similar to this concept using that the page node ID or whatever uniquie identifier Drupal uses never changes:

test

so no matter what the page name/path/url is it will always link to the same page.

I know there is the option of setting up page redirects for old URL alias though without going into detail why that is not a solution for me in my case please leave that suggestion aside I already know of that. :)

Thank you


texts:
I use vocabulary with following term structure (more/deeper structure in real):

Fruits
-apples
--red apples
--green apples
-bananas

I want to create:

List of all nodes belonging to Fruits term (excluding green apples for some reason)
List of all nodes belonging to Apples (having both red and green apples)

I need to display all nodes related to term Fruits (as well as all nodes related to all children terms of term "fruits" AND exclude term "green apples").
Is it possible to dynamically exclude certain terms when creating such lists? I could not find any way to do it using views. Probably some coding is necessary?

Thank you


texts: Unable to run drush via php's `exec` command

texts:
I'm creating an admin page for my module that will allow an admin to trigger scripts from within the module configurations.
So far, I've created these routes:
my_module.scripts.home:
  path: "/admin/config/development/my_module/scripts"
  defaults:
    _title: "Scripts"
    _controller: '\Drupal\my_module\Controller\ScriptsController::home'
  requirements:
    _permission: "administer site configuration"
my_module.scripts.run:
  path: "/admin/config/development/my_module/scripts/run/{script}"
  defaults:
    _title: "Run Script"
'\Drupal\ytp_integrations\Controller\ScriptsController::runScript'
    name: "none"
  requirements:
    _permission: "administer site configuration"

And then my Scripts Controller looks like so:
<?php

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Yaml\Yaml;
use Drupal\Core\Url;

/**
 * Defines Configurations Controller class.
 *
 * This class controller i
 */
class ScriptsController extends ControllerBase {

  /**
   * Home
   */
  function home() {
    $build['table'] = [
      '#type' => 'table',
      '#header' => [
        'Title',
        'Description',
        'Path',
        'Status',
      ],
    ];

    // Retrieve all scripts
    $scripts_config_file = file_get_contents(drupal_get_path('module', 'my_module') . '/my_module.scripts.yml');
    $script_config = Yaml::parse($scripts_config_file);

    // Create Table Rows and add to table
    $rows = [];
    foreach($script_config as $key => $script) {
      $rows[] = [
        'title' => $script['title'],
        'description' => $script['description'],
        'path' => $script['path'],
        'operations' => [
          'data' => [
            '#type' => 'link',
            '#title' => 'Run',
            '#url' => Url::fromRoute('my_module.scripts.run', ['script' => $key])
          ],
        ],
      ];
    }
    $build['table']['#rows'] = $rows;

    return [
      '#type' => '#markup',
      '#markup' => render($build),
    ];
  }

  /**
   * Run Script
   *
   *
   */
  function runScript($script) {
    // Retrieve the script
    $module_path = drupal_get_path('module', 'my_module');
    $script_config = Yaml::parse(file_get_contents("$module_path/my_module.scripts.yml"));
    $script_data = $script_config[$script];

    $script_path = $module_path . '/' . $script_data['path'];

    $execute = exec("drush scr $script_path > /dev/null &");

    \Drupal::logger('ytp')->notice('
' . print_r($execute, TRUE) . '
');

    return new RedirectResponse(Url::fromRoute('ytp_integrations.scripts.home')->toString());
  }
}

Structurally, this seems to all work, but when I print out the execute variable after running the drush command via exec, I get nothing and the code in my script isn't executed. I changed the command to pwd and it printed out the path like expected, but exec doesn't seem to know what drush is...
I would use drush_invoke_process, but I would like my drush command to be executed in the background. I'm expecting to get a pid back so that I am able to determine which scripts should have their run button disabled if the pid is running in the background.
Any reason why exec doesn't know what drush is or how I could kick off my drush script in the background running via Drush?


texts:
I have a custom module, saidbakr_tools and I want to apply permissions to access its administration page found admin/config/administration/saidbakr_tools. All what I have to got from the official module tutorial is to prevent access to it by preventing access to the admin pages.

The code I am using is the following one.

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

  $items['admin/config/administration/saidbakr_tools'] = array(
    'title' => 'SaidBakr Tools',
    'description' => 'Settings for SaidBakr Tools!',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('saidbakr_tools_form'),
    'access arguments' => array('administer saidbakr_tools'),
    'type' => MENU_NORMAL_ITEM,
  );

/**
 * Implements hook_permission().
 */
function saidbakr_tools_permission() {
  return array(
    'administer saidbakr_tools' => array(
      'title' => t('Access content for the SaidBakr Tools module'),
    )
  );

I cannot prevent other users with access to administrative pages to access the configuration form for my module.

Is there any error in my code? How can I achieve what I am trying to do?


texts: Identifying the level of menu items in the item array?

texts:
I have a D7 menu of nearly 300 terms in a 3-level hierarchy.  Rather than generate them one at a time in the UI, I would like to generate them using code.  I am using the book 'Pro Drupal Development' and the Drupal API documentation for menus and the menus.module to attempt this, but am confused about how to establish the structure of the three tiers.

Creating a menu item appears to be fairly simple, implementing hook menu and creating item arrays  with values assigned to 'title', 'page callback', 'access callback', and 'type'.  My problem is that I must define the hierarchy and I am not clear on how that is done.  How do I identify the parent in the array structure?

EDIT - additional information

The menu items, at all levels must have a callback to a view definition following the pattern View_Name/tid/display_type.  The first level of the URL will be a unique label for the View being called. The next level is a term id identifying the specific term from a vocabulary that defines the relationships of the menu options.  The third level determines which view page in the definition provides the view output for display. My question is addressing how to duplicate the taxonomy hierarchy in a code generated menu? How do I tell the Drupal the relationships between the links to duplicate the three tier menu system when the links are created? I can provide my customized callbacks but haven't found the correct array key-value settings to generate the menu correctly.

I have experimented using the Taxonomy_Menu module to generate the menu directly, but I cannot find a way to generate different third level URL values within the module.  The module generates a menu of taxonomy links and Drupal does not expose the links for editing.


texts: Display Suite Extra options not showing up

texts:
I installed and activated the "Display Suite Extra" module. But the menu point "Custom CSS classes" under "Manage display" of any content type is missing.

What else do I need to activate the Display Suite Extra features in Drupal 8? I already uninstalled and activated the module but the features of the Extra module are still missing.


texts: How can I restrict user access to view nodes based on field value?

texts:
I am setting up a relatively simple website using Drupal 8.  There are several different content types.  Within each content type I would like some content to be available to anonymous users and some only available to authenticated users (i.e. 'member only' content).

I would like to add a simple tick box field that would control whether the content was publicly available or not.  i.e. if the field is ticked then it is available to anyone but if it isn't ticked then it is only available to members.

I have managed to get some way to achieving this by using Node View Permissions and creating a duplicate of each content type - both have the same fields but one is visible to anonymous users and the other is only visible to authenticated users.  This works, but isn't very satisfactory because it requires duplicate content types.  I would prefer to have a single content type with a field that controls view permissions.

Do you have any suggestions?


texts: Fatal Error - Fatal error: Unsupported operand types in public_html/includes/common.inc on line 2999

texts:
The page of my work is not loading anymore!
And Im not used to deal with drupal!
What I have to do to the page load properly! I even cant login as user or see any page of the site!
PLZ im really desesperated!

this error show when i try to enter in the page:
Fatal error: Unsupported operand types in /home/storage/2/58/58/xxxxx/public_html/includes/common.inc on line 2999
the page i wanna to work is that: www.meddco.com.br!


texts: How to link different contents together and display the linked content on the same page?

texts:
I am fairly new to Drupal and would need some help.

on my site I have to show a few images (A - B - C - D ) created by a content type X.

Each of these images will link to a different content Type Y ( 1 - 2 - 3 - 4 ).

So when I click on A , the content 1 should show below it. Same for content B -2 , C -3, D-4.

I am not sure how to achieve such a result and what are the tools to use.

Thank you for your help.


texts: How to create a $navigation main menu with target="_blank" on specific page.tpl.php pages

texts:
I have a Drupal 7 site using the main menu for all pages. However, I've just added some unique landing pages for some advertising campaigns which all come from 'page--landing.tpl.php'

Oddly, my client wants just the 'page--landing.tpl.php' pages to have the main menu for these pages only work in such a way that the links all open in new windows (like target="_blank").

Does anyone know how to achieve this?

In the 'page--landing.tpl.php' file, the menu is created with:

<div id="menu">
<?php print $navigation; ?>
</div>

Thanks for any and all help given.


texts:
Admin or normal user can not logout using www.myswebsite.com/user/logout

An access denied page is displayed and the user is still logged.

using ?q=user/logout works.

It is not a rewrite problem, all other url are ok.

I have cleared the cache and deleted the cookies, tried on FF, IE & Chrome.

Any idea to investigate ?


texts:
I have installed the Internalization module and after that edit the Main menu setting and select the translate and locale.

and add translate as per menu item. But when I switch the language its all the menu item still shows in english

Have a look I have only these options:


texts: drupal_set_message is visible only to those with permissions for the operation?

texts:
API about drupal_set_message read:
"Set a message which reflects the status of the performed operation.
If the function is called with no arguments, this function returns all set messages without clearing them."

Does that mean, if the operation is not permitted for authenticated user or anonymous, then they cannot see the message but only visible to who has the permission to perform the operation?


texts:
I have site http://diamant-group.com/. It has two languages RU and EN, I want that it will monolingual, with Russian default language. I turn off EN language in Configuration, turn on RU as default, but problem is still exist http://diamant-group.com/ru/catalog. When I begin to research I have opened that many code for multilingual function was added inside theme template. When I turn off module Content translate i have error of function diamant_link_lang.

How to correct this code, that links do not consist /ru/ (for example site/ru/catalog/watches/mechanical/omega/ - > site/catalog/watches/mechanical/omega/), but language of the result pages must be Russian:

function diamant_link_lang($language, $path, $path_alt) {
    $path_lang = translation_path_get_translations($path_alt[0] . '/' . $path_alt[1], $language);
    file_put_contents(DRUPAL_ROOT . '/sites/default/files/text.txt', 'path_lang: ' . print_r($path_lang, true) . "\n");
    if ($language == 'ru' && isset($path_lang['en']))
 {
        return 'en/' . drupal_get_path_alias($path_lang['en'], 'en');
    }
    if ($language == 'en' && isset($path_lang['ru'])) {
        return drupal_get_path_alias($path_lang['ru'], 'ru');
    }
    return $language == 'ru' ? 'en' : 'ru';
}


texts: Show whole taxonomy tree starting from current term

texts:
I'm trying to show taxonomy tree starting from current term.
Like this when you are in taxonomy term1 page.

  -term1 (this is the term1 page where we are now)
  --term2
  --term3
  ---term4
  ----term5
  ----term6
  -----term7
  -----term8

And if we are for example term4 page then it will show starting from term4:

  ---term4
  ----term5
  ----term6
  -----term7
  -----term8

I have used Views Tree to but I have not found proper way to "filter" to show right terms when you are for example in term4 page.

All I can get is to show first child level like:

  --term1
  ---term2
  ---term3

It should show whole tree starting from current term - as deep as the tree goes.


texts: Drupal + XDebug + VSCode = can't break on PHP notice or warning

texts:
Using Drupal (8.9), PHP (7.2.34) with xdebug, and VSCode (1.50.1) with PHP Debug (1.13.0), the debugger will no longer break on PHP notices and warnings, even if those option checkboxes are set.
The behavior starts as soon as Drupal installs its error handler in Drupal\Core\DrupalKernal::bootEnvironment().
As an example, if I insert strlen();, a function call which triggers a PHP Warning (error type 4), immediately before set_error_handler('_drupal_error_handler');, execution will stop and the VSCode debugger will display the offending line. As soon as the error handler is installed, VSCode will no longer stop.
The same behavior is true of PHP Notices. Execeptions and regular breakpoints work as expected.
Turnning on logging shows that the debugger is sending the command to break on notice and warnings:
> setExceptionBreakpointsRequest
{
  command: 'setExceptionBreakpoints',
  arguments: { filters: [ 'Notice', 'Warning' ] },
  type: 'request',
  seq: 4
}

<- setExceptionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 4,
  command: 'setExceptionBreakpoints',
  success: true
}

... but then there's nothing further in the log about the notice or warning exceptions.
Now I can believe this is simply a limitation of xdebug -- that the use of the drupal error handler (which does NOT return FALSE to trigger default error handling), except that I know that at some very distant time in the past, using different tools, I could break on notices and warnings. For example, using Drupal 6, PHP 5.3, KomodoEdit (unknown version), this used to work.
If anyone is successfully getting the debugger to stop on PHP notices and warnings using tools similar to what I'm using, I'd love some details. I've looked over the xdebug and php configuration settings and I don't see anything that be relevant. Note: I'm not trying to display the warnings/notices -- that is working according to the Drupal configuration. And I'm not trying to halt on warnings/notices. I'm trying to get xdebug to break execution.


texts:
I have the following code. I am able to load the field collection item using entity_load_single. I want to be able to get the node id for a given field collection item. How can I achieve this?

function dc_car_guide_model($model_id)
{
    $model = entity_load_single('field_collection_item', $model_id);
    //How can I get nid?
}


texts: Make Flippy links available in page.html.twig

texts:
Using the Flippy Module I would like to make the links that it prints in its theme file available in page.html.twig because I want to print them in a different region from where the node content gets printed.

The module states: "If you turn on Flippy for a content type, but hide the pager in the Manage Display page, its links will still be available in the theme layer when it comes time to output node.tpl.php"

That's correct, using Devel Module enter link description here I used dpm(content) on my node.html.twigtemplate.

Doing {{ content.flippy_pager}} allows me to print the links, but it's all within node.html.twig.

How could I possible pass that information on to page.html.twig since my goal is to print it in a different region from where the node's main content gets printed.


texts: Views - alter date field granularity on exposed filter mid-request?

texts:
I have an exposed filter on a date value that has it's granularity set to month, so it shows possible year and month values in the form.  If I select just a year, no results are returned, even though I know there are posts that should be retrieved based on the year.  If I then specify a month, all posts from that month and year are returned.

I need to be able to return results from the entire year when just year is selected.  I'm thinking there might be a way to alter the granularity somehow during the request based on whether or not the month was specified?  Any thoughts?


texts: In what order are 0-priority event subscribers called?

texts:
The Symfony docs at https://symfony.com/doc/3.2/components/event_dispatcher.html say:

If two listeners have the same priority, they are executed in the order that they were added to the dispatcher.

But in what order do EventSubscriberInterface services get added to the container? I'm guess this is module weight? Can anyone confirm?


texts: Is there any drupal module to export/import all ubercart products with product details(attributes)

texts:
I am looking for the module which having the option to import all ubercart products including all information like product images, price, sale price and other attributes. After exporting the information how we can import these to other drupal setup.

If there is no single module to do this then what will be the right approach to do the same.


texts: How to make sure simpleSamlAuth module is working as intended?

texts:
I'm working on a Drupal site which is utilizing the simpleSAMLphp_auth module. We want users to be able to log in using their Gmail accounts, so long as they have an pre-existing Drupal account to match. If it turns out they do not, I don't want them being authenticated.

As of now, when I attempt to use the federated login through Gmail, it seems to authenticate me because it doesn't complain at all about access being denied. It simply takes me back to the homepage of our Drupal website.

How can I check if I am actually being authenticated, even though the email I am testing with the federated login does not have a pre-existing Drupal account associated with it?

Also, I am using the email as the simpleSAML attribute for the users unique identifier and for their email as well.


texts:
I am hosting a Drupal 7 Instant on Amazon Ec2 and have database on RDS.
The site loads and works pretty fast. But admin side, when articles are posted its dead slow.

In the MySql Log I found error like this:

  130912 11:57:39 [ERROR] /rdsdbbin/mysql/bin/mysqld: Out of memory
  (Needed 26843536 bytes) 130912 11:57:39 [ERROR]
  /rdsdbbin/mysql/bin/mysqld: Out of memory (Needed 26843536 bytes)

Mysql Myconf

default_storage_engine  = innoDb
innodb_additional_mem_pool_size  =  52428800
innodb_io_capacity = 10000
innodb_open_files = 120
max_allowed_packet = 33554432
max_connections = 3000
max_heap_table_size = 134217728
query_cache_size = 2147483648
read_buffer_size = 52428800
slow_query_log = 1
tmp_table_size = 134217728
binlog_cache_size  =  32768
innodb_buffer_pool_size  = {DBInstanceClassMemory*3/4}
innodb_file_per_table = 1
innodb_io_capacity = 10000
innodb_log_buffer_size = 8388608
innodb_log_file_size  =  134217728
key_buffer_size      = 16777216
log_output  =  TABLE
max_binlog_size  =  134217728
read_rnd_buffer_size  =  524288
thread_stack =  262144
read_only = {TrueIfReplica}

I am having very good configuration for both Ec2 Server & RDS (MySql).

Ec2 Server Spec

m3.xlarge
15 GB Ram
4 Dual Core Processor
20 ECU

Rds Server Spec

M1.Medium.
HDD Size: 10GB
Memory : 4 GB
CPU : 2 Compute Unit`

Traffic to site is around 2000 visits per day. The content of site is pretty much articles and few youtube videos.


texts:
I have a migration and it is very simple. I have a CSV file of employee number and years of service. I have added the two fields to the users in the system and populate them when the users have been added. I now I have a yearly file to update the years of service value. I created the below Migration to import/update the seniority:

id: seniority_import
label: Seniority CSV file import
description: Seniority CSV file import
migration_group: timeoff
migration_tags:
  - seniority_timeoff
langcode: en
status: true
dependencies:
  enforced:
    module:
    - timeoff_seniority
source:
  plugin: csv
  track_changes: true
  path: "/Users/rfulcher/Downloads/Seniority2017-2.csv"
  keys:
    - EMPNO
  column_names:
    0:
      EMPNO: "Employee Number"
    1:
      SENIORITY: "Employee Seniority"
process:
  uid:
    -
      plugin: user_lookup
      source: EMPNO
      value_key: field_employee_id
      entity_type: user
      bundle: 1
      bundle_key: status
      ignore_case: true
    -
      plugin: skip_on_empty
      method: row
      source: uid
      message: 'no empno found'
  field_employee_id: {}
  field_seniority: SENIORITY
destination:
  plugin: entity:user
  overwrite_properties:
    - field_seniority

I also create the custom process plugin to lookup the uid of the user using the employee number

   <?php

namespace Drupal\timeoff_seniority\Plugin\migrate\process;

use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;

/**
 * Returns a user if exists.
 *
 * Example:
 *
 * @code
 * process:
 *   field_your_field_name:
 *     -
 *       plugin: your_plugin_name
 *       source: some_source_value
 * @endcode
 *
 *
 * @see \Drupal\migrate\Plugin\MigrateProcessInterface
 *
 * @MigrateProcessPlugin(
 *   id = "user_lookup"
 * )
 */
class UserLookup extends ProcessPluginBase {
  /**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {

    $user_uid = $this->getUserByEmpNo($value);

    if ($user_uid == FALSE){
      drush_print('usernotfound for ' . $value . ' returning 0');
      return 0;
    } else {
      drush_print('userfound:'.$user_uid.': for ' . $value);
      return $user_uid;
    }
  }

  protected function getUserByEmpNo($employeenumber) {

    $id = \Drupal::entityQuery('user')
                  ->condition('field_employee_id', $employeenumber)
                  ->execute();
    $users =  \Drupal\user\Entity\User::loadMultiple($id);

    if (!empty($users)) {
      foreach ($users as $user) {
        $update_id = $user->id();
        return $update_id;
      }
    } else {
      return FALSE;
    }
  }

  public function prepareRow($row) {

  }
}

The import runs and I find the uid and return the value but it is like the migration ignores it and skips the row.

Am I missing something. I have worked on this way too long and this should be simple but I must not be understanding how this is supposed to work or something. I am totally at a loss.

Simple csv file with just two fields empno, seniority. Nothing fancy. Any help with this would be appreciated, thanks very much.

Thanks


texts: I have a view with an exposed filter that searches nodes for taxonomy terms. For example there are 10 terms but the nodes only use 7 of them. When the view is shown on a page the 10 terms show in the filter. 3 of the terms in the filter will yield zero results. I want to hide those terms (because they have zero results) and not make them available in the filter.


texts: Search API Saved Search tokens output [search-api-saved-search-result:url] has cron.php in urls

texts:
I'm using Drupal 7 : with Search API

In this I'm using the token [search-api-saved-search-result:url] which I take it should output the Url of the relevant nodes.  The Urls are correct except the have 'cron.php' text in them .  ie 'www.example.com/cron.php/node/1234' ; making them not work.

this is the code in the Search API module.

case 'search-api-saved-search-result':
  $d = $data['search_api_saved_search_result_info'];
  if (!empty($d['search']) && !empty($d['entity'])) {
    $search = $d['search'];
    $index = $search->index();
    $item = $d['entity'];
    foreach ($tokens as $name => $original) {
      if ($name == 'id' && ($id = $index->datasource()->getItemId($item))) {
        $replacements[$original] = $id;
      }
      elseif ($name == 'label' && ($label = $index->datasource()->getItemLabel($item))) {
        $replacements[$original] = $label;
      }
      elseif ($name == 'url' && ($url = $index->datasource()->getItemUrl($item))) {
        $url['options'] += $url_options;
       $replacements[$original] = url($url['path'], $url['options']); // $replacements[$original] = url('http://www.rcnbulletins.com/', $url['options']);
      }
    }
    if (($url_tokens = token_find_with_prefix($tokens, 'url')) && ($url = $index->datasource()->getItemUrl($item))) {
      $replacements += token_generate('url', $url_tokens, $url, $options);
              }
  }
  break;

I'm wondering if this is a bug or something i've missed in admin.


texts: I'm trying to figure out how to alter the output of a Views Block. The first image shows the situation that I'm stuck in, which obviously looks horrible, and the bottom two images are of what I would like to see, as well as the likely div plan. This is my first time working on this type of issue, so if someone has an idea of where to go, or if there is a module available for me to work with. I'm just looking for the cleanest way of getting to the output goal. Thanks!


texts: Generate google search result for my website like that of flipkart

texts: I have my website which i can search in google and it comes up. But if i see flipkart search result on google, it is structured very well. Is there any module to do that in drupal?


texts: how to put a submit button with a pre-defined submit function by calling drupal_render?

texts:
I've been search results for hours but cannot find an answer to my problem.

I want to show a list using theme("table",...); inside my table, there's a column of buttons, which each functions as deleting the record for this row. Therefore, I did something like this:

foreach($person_list as $pyid => $record){
  $render_ele = array('remove'.$pyid => array(
      '#type' => "submit",
      "#value"=> "remove",
      '#submit' => array('shms_cca_form_remove_person_from_group'),
      "#limit_validation_errors"  => array(),
      "#attributes" => array("pyid" => $pyid,'action' => "remove"),
    ));
  $rows[] = array(
    $record['full_name'], // full name
    $record['matric_no'],  // matric no
    $record['room_number'], // room number
    $record['position_name'],
    is_numeric($record['cca_points'])?$record['cca_points']:"Not Assigned Yet",
    drupal_render_children($render_ele),
  );
};

However, when I clicked on the button, the submit function I've defined is not called (it called the default submit function instead).

When I try to add another default button into my form like this:

$form += array(
  'nani' => array(
    '#type' => "submit",
      "#value"=> "remove",
      '#submit' => array('shms_cca_form_remove_person_from_group'),
      "#limit_validation_errors"  => array(),
  ),

Both this button and my old-not-functioning submit button works.

I therefore conclude that it's a JavaScript problem... possibly some JavaScript is not included when I call the drupal_render by myself.

Could anyone help on how to solve this problem?
Thanks a lot.

Update:
I called drupal_render, because I want to pass the rendered result to rows[] so that I can put these elements inside a table, like this:

$render_ele = array('remove'.$pyid => array(
      '#type' => "submit",
      "#value"=> "remove",
      '#submit' => array('shms_cca_form_remove_person_from_group'),
      "#limit_validation_errors"  => array(),
      "#attributes" => array("pyid" => $pyid,'action' => "remove"),
    ));

$rows[] = array(
  $record['full_name'], // full name
  $record['matric_no'],  // matric no
  $record['room_number'], // room number
  drupal_render($option),
);
return array(
"person_list" => array(
  '#type' => 'fieldset',
  "#title"=> t("Group Members"),
  '#collapsible'  => TRUE,
  "#collapsed"  => FALSE,
  "#children"   => theme("table",array('header'=>$header,"rows"=>$rows)).$add_member_str,
  '#weight'     => 10,
),

);


texts: Stop registration form from sending mails

texts: I want to stop the registration form from sending "email activated" email to users, is there a way to stop them?


texts: Views: combining fields of one content type with another

texts:
Let's say I have Content Type A and Content Type B.
Both A and B share a taxonomy vocabulary C.
C terms are C:x, C:y, C:z

I want to create a page View of Content Type A which lists every node of Content Type A.
Within the physical layout of each A, I want to also show B, but only if it share's C with A.

The page generated by the View should look like something like this

1st CONTENT TYPE A with taxonomy C:x
=====================
Content Type A field 1
Content Type A field 2
Content Type A field 3
Content Type B with taxonomy C:x
=====================

2nd CONTENT TYPE A with Taxonomy C:y
=====================
Content Type A field 1
Content Type A field 2
Content Type A field 3
Content Type B with taxonomy C:y
=====================

I have everything working except for the Conent Type B with taxonomy C:foo working.
What do I need to do to get this part working?


texts: What other PHP memory_limit restrictions could there be besides php.ini?

texts:
I have been facing some weird memory limit issues on a managed dedicated server and spent alot of time trying to fix this other with the server admin. phpinfo() is showing the correct overridden memory_limit values.
Everything is cool, except when I use drush to do drush en module or Views Bulk Operation execution. If anyone has experienced this before, I will really appreciate if you can share with us the steps needed to fix this.

In my php.ini :memory_limit = 256M ;

In sites/default/settings.php: ini_set('memory_limit', '256M');

The WSOD message after executing a Views Bulkd Operations on ONE entry:
Fatal error: Out of memory (allocated 131334144) (tried to allocate 5 bytes) in /public_html/includes/cache.inc on line 401
Memory used at: devel_boot()=5.02 MB, devel_shutdown()=82.06 MB, PHP peak=82.25 MB.

In SSH, using drush cli. After running drush en languageassign:
The following extensions will be enabled: languageassign
Do you really want to continue? (y/n): y

Fatal error: Out of memory (allocated 76021760) (tried to allocate 72 bytes) in /public_html/sites/all/modules/views/includes/base.inc on line 84

Drush command terminated abnormally due to an unrecoverable error.                      [error]

Error: Out of memory (allocated 76021760) (tried to allocate 72 bytes) in
/public_html/sites/all/modules/views/includes/base.inc, line 84


texts: How do I filter a view by the results of hook_node_access?

texts:
I have been trying to wrap my head around a specific problem for a few days now and have been unable to find a solution. Here's my problem:

In my LMS I'm performing pretty complex access checks. (In particular, I need to check permissions over references: A lesson should be accessible, if it's part of some course that's marked accessible for that specific user.) I have already written a module implementing hook_node_access and, so far, everything is working fine. Here's part of the code:

function mymodule_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Session\AccountInterface $account){
  $type = $node->bundle();
  $user = $account->getAccount();
  $uid = $user->id();

  // only handle the lesson content type
  if ($type === 'lesson') {

    if ($account->id() !== 1) {

      // first, check the user's access to the lesson itself
      $lessonaccess = ...

      // then, check the user's access to the referring courses
      $courseaccess = FALSE;
      if ($node->hasField('reverse_entity_reference')) {
        $parentcourses = $node->get('reverse_entity_reference')->getValue();

        foreach ($parentcourses as $course) {
          $coursenode = \Drupal\node\Entity\Node::load($course['target_id']);
          // perform access checks for the referring course
          $courseaccess = $courseaccess || ...
        }
      }

      // combine the results; teasers should always be accessible
      if ($lessonisteaser || ($lessonaccess && $courseaccess)) {
        return AccessResult::allowed();
      } else {
        return AccessResult::forbidden();
      }
    }
  }

  else {
    return AccessResult::neutral();
  }
}

The problem is that I would now like to create a view listing all lessons that are accessible to the current user. So, simply filtering by node access -- as is straightforward to achieve in Views -- is not sufficient, as I need to filter by what is returned from the access checks in hook_node_access.

Can anybody think of a way to make that possible? Maybe storing the result somewhere?


texts: Status message appears multiple times on status stream

texts:
I have user relationship and Status modules installed. Each time a user posts a message on his/her profile it appears 12 times in his/her status stream while it appears once in other users stream.

Please does anyone know what can be wrong?


texts: Seeking iPhone/iPad JavaScript/jQuery libs, techniques & tutorials

texts:
Client wants iPad & iPhone support for a webapp that has at least one form where DOM elements are dragged around on a (Raphael) Canvas (JavaScript rendered graphic).

Currently, the touch-unfriendly interface to drag items around uses mouse-hover and other mouse states to handle the drag-items interface. I know I'll need a completely different approach for touch screen devices, and am wondering if any fellow Drupal developers have posted their breadcrumbs as they faced this.

Drupal 6 or Drupal 7 does not matter, since this is at the JavaScript layer unless the possible solution requires jQuery only available in Drupal 7.


texts: how to use EntityFieldQuery by language?

texts:
global $language;

$query = new EntityFieldQuery();
$result = $query->entityCondition('entity_type', 'node')
->propertyCondition('type', 'events')
->propertyCondition('language', $language->language)
->propertyCondition('tnid', $output)
->execute();

I tried using this code and it is showing me empty page, any help on using EntityFieldQuery?


texts: Does View UI restrict fields based on filters, etc

texts: In the Views UI, are the fields that you can add restricted by whats possible due to the filters, contextual filters, relationships etc? Eg if I set a filter to node type A, will the ui allow me to add fields that only exist in node type B?


texts: How to apply css to all pages in custom module

texts:
I have created one custom module in drupal-7. I want to apply same css to all pages belonging to that module.

I am able to apply css to one page by using drupal_add_css() but not able to do for all pages.


texts:
Ctools Multi step form throws error when form_validate is from another file even I had included the file using module_load_include.

As per this example I used a function not from the current file but by using module_load_include this is working fine. But when it comes to form_validate it is throwing an error.

Any suggestions?


texts: How to execute request-specific tasks after page response is returned. Does hook_exit() actaully do this?

texts:
I'm trying to figure out if it's possible to "hide" the perceived execution time of some end-of-request logging tasks that are page specific and depend on the availability of the Drupal DB API. Essentially I'd like to run these tasks after the page response is returned in full to the browser. I've always just assumed that hook_exit() was the right choice for this kind of thing but after looking at its invocation within drupal_page_footer() in some detail, I'm not so sure. Here's the notable snippet from drupal_page_footer():

module_invoke_all('exit');

// Commit the user session, if needed.
drupal_session_commit();

if (variable_get('cache', 0) && ($cache = drupal_page_set_cache())) {
drupal_serve_page_from_cache($cache);
}
else {
  ob_flush();
}

So it looks like both cached and un-cached responses are not sent to the browser until after all hook_exit() implementations run (flushing the buffer and executing drupal_serve_page_from_cache() both happen after module_invoke_all('exit')). This seems a bit contrary to the hook_exit() documentation which states that, "This hook MUST NOT print anything because by the time it runs the response is already sent to the browser."

Am I perhaps misinterpreting the way hook_exit() implementations work in relation to the response delivery? If not, is there some alternative way to trigger custom logging logic later in the response (while DB access is still available)? Perhaps by registering a shutdown function or something to that effect?


texts: Date module shows time field +5:30 ahead from input

texts:
I am using Date module with date popup . And I am creating these node pro grammatically and saving dates to them like:

$node->field_task_time[LANGUAGE_NONE][0]['value'] = "2014-12-18 23:15:00";
$node->field_task_time[LANGUAGE_NONE][0]['timezone'] = "Asia/Kolkata";
$node->field_task_time[LANGUAGE_NONE][0]['timezone_db'] = "UTC/GMT";
$node->field_task_time[LANGUAGE_NONE][0]['date_type'] = "datetime";

The values in db are stored correctly but when I edit this node form the values in the date field shows 2014/12/18 and in time field it shows 4:15. i Don't know what's happening .


texts: How to set a banner slideshow to run if images are only fully loaded

texts:
I am new to Drupal, and not that good in Jquery. I just created a Drupal animated banner in Jquery. Each banner image is kinda large about 500kb each jpeg. My problem is, the banner images starts to run even the banner images are not yet fully loaded. Heres the code:

(function ($) {
  // Original JavaScript code.
var currentBackground = 0;
var backgrounds = [];
backgrounds[0] = 'http://www.site.com/sites/all/themes/layoutph/images/bg01.jpg';
backgrounds[1] = 'http://www.site.com/sites/all/themes/layoutph/images/bg02.jpg';
backgrounds[2] = 'http://www.site.com/sites/all/themes/layoutph/images/bg03.jpg';
backgrounds[3] = 'http://www.site.com/sites/all/themes/layoutph/images/bg04.jpg';

var customtitle = [];
customtitle[0] = "Welcome to Site";
customtitle[1] = "Site joined force with Site Foundation";
customtitle[2] = "Site Foundation school campaigns for 2014";
customtitle[3] = "New York visited by Site Foundation";

function changeBackground() {
    if(currentBackground > 3 ) currentBackground = 0;
    currentBackground++;
    $('.masterbg').fadeOut(1000,function() {
         $('div.slogan').text( customtitle[currentBackground] );
        $('.masterbg').css({
            'background-image' : "url('" + backgrounds[currentBackground] + "')"
        });
        $('.masterbg').fadeIn(1000);
    });
    setTimeout(changeBackground, 4000);

}
     setTimeout(changeBackground, 4000);

})(jQuery);

Can you give me a modification to my code, or theres a function I need to add my code to let the banner images load first before banner slideshow start.

Thank you in advance.

Note: This jquery code is for Drupal.


texts: Instantiate Controller with Interface not concrete class

texts:
As background, I am rebuilding some old code and want to wrap all the curl based requests in an interface (HttpRequestInterface) so I can swap that out later without having to write all the api calls right now.

I am trying to pass the HttpRequestInterface into controller, but it keeps saying `

  TypeError: Argument 1 passed to
  Drupal\my_api\Controller\MyController::__construct() must be
  an instance of Drupal\my_api\Controller\HttpRequestInterface,
  instance of Drupal\my_api\Services\HttpRequest\CurlRequest given

I am new to Drupal from the .Net world and love how this functionality is out of the box and it seems like I am following the examples and code I find in core, but obviously I am missing something.

***One thing that sticks out is that this error message has the wrong namespace for HttpRequestInterface.

Below are the relevant files, I have only included what I think is pertinent to the issue, more can be made available.

Controller:

<?php

namespace Drupal\my_api\Controller;

use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response;
use Drupal\my_api\Controller\BaseApiController;

/**
 * Controller routines for Api routes.
 */
class RallyBoundController extends BaseApiController {

`BaseController:

namespace Drupal\my_api\Controller;

use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\my_api\Services\HttpRequest\HttpRequestInterace;

/**
 * BaseApiController abstracts away common api concerns.
 */
abstract class BaseApiController extends ControllerBase {
  protected $httpService;

  /**
   * Contructor requires HttpRequest Service.
   *
   * @param HttpRequestInterface $httpService
   *   Implementation of HttpRequestInterface defined in services.yml.
   */
  public function __construct(HttpRequestInterface $httpService) {
    $this->httpService = $httpService;
  }

  /**
   * Get the HttpRequest implemention as interface so we can swap out as needed.
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('my_api.httprequest')
    );
  }

Service.yml:

services:
  my_api.httprequest:
    class: Drupal\my_api\Services\HttpRequest\CurlRequest

HttpRequestInterface:

namespace Drupal\my_api\Services\HttpRequest;

/**
 * HttpRequestInterace defines interface for making Http GET Requests.
 */
interface HttpRequestInterface {

CurlRequest:

namespace Drupal\my_api\Services\HttpRequest;

use Drupal\my_api\Services\HttpRequest\HttpRequestInterface;

/**
 * HttpRequest Implementation of HttpRequestInterface using CURL.
 */
class CurlRequest implements HttpRequestInterface {

Thanks for the help.


texts: Facebook scraper ignores default language

texts:
I have a Drupal 7 setup with an internationalized site. The default languages is English but the content is also available in German. However the site focuses on a German audience. As in Drupal you cannot switch the default languages without messing up all string translations, we have a custom language negotiation rule implemented (hook_language_negotiation_info()) that makes sure if no session or query parameter (like lang=en) is set, the site is shown in German. So, to make it short: If an user accesses our site like this:

http://www.example.com

it will be shown in German. Nevertheless Facebooks open graph scraper scraps the site always in English, as it would add programmatically lang=en to all URLs. How can that be? we have the following language specific meta tags:

<link href="https://www.example.com/node/581?lang=en" rel="alternate" hreflang="en" />
<link href="https://www.example.com/task/581" rel="alternate" hreflang="de" />
<meta property="og:locale" content="de_DE" />
<meta property="og:locale:alternate" content="en_US" />

Does anybody know, what I could do, to convince Facebook open graph scraper to scrape the German version as default?


texts: Only show the amount of views in Advanced Forum

texts:
I am using the 'Advanced Forum' module in Drupal 7 and I want to have a 'Views' column in the topic list. I have managed to do this using the Statistics module, but now at the bottom of every node it says '## reads', much to my dislike. Therefore, I would like to remove every visible view count; only leaving the views column in the 'Advanced Forum'.

Is this possible? If it is possible, how can I do it?