texts: Multililingual views displaying wrong content

texts:
I have created a view which lists a bunch of nodes. This works fine when the site is in the default language of English. I have cloned that view and made sure it only displays the French version of those nodes and changed the path where it should be displayed. This all works as it should in the view's preview area. However when I go the French url for that page, I only see the English version of the listed nodes and not the French ones as defined in the view.

I am confused as to why this would be. Different urls should display different content but it is not. What could be causing this issue? I am completely stumped and this is an urgent issue for a client.


texts: How to upload file in Webform content type

texts: I want to be able to upload a file with Webform, is their any way to do this?


texts: How to un-cache a specific node field (also for anonymous)

texts:
My goal is to replace (by a custom markup) the render array of field_product when some conditions are met. (in a ecommerce site)

Ex: If this is the weekend or if it is after 12pm the field_product must not be rendered (but a markup like "the webshop is closed")

In mymodule_preprocess_node(&$vars) I have tried without success:

$vars['content']['field_product']['#cache']['max-age']=0;

or

$vars['content']['field_product']['#cache']['contexts'][] = 'session';

Unfortunately, it is not working for anonymous users

The only solution I found is:

$vars['#cache']['max-age']=0;

But as you can see, all the node is un-cached... not the field_product

What is wrong with my code?

Again: this should be uncached for anonymous users


texts: How can I load a theme template to render $submitted

texts:
I'm trying to replace the output of $submitted in my nodes. I have found how to replace the value which is fine. The problem I'm facing is how to load a template file properly.

function pod_preprocess_node(&$vars) {
  $vars['submitted'] =  t('!datetime ', array(
    '!datetime' => include_once(__DIR__.'/system/submitted.tpl.php')
  ));
}

As you can see above, I've just included a template file and in there I can use $vars but this is clearly sub optimal. What I'd like to do is just load a template file from my theme which has some sensibly named variables in.

I've looked at hook_theme() which now allows me to call theme('pod_submitted', $vars) but I don't know how to make pod_submitted() include the right file etc.

I assume that somewhere I need to do the following

$vars['theme_hook_suggestions'][] = 'system__submitted';

But I'm not sure how my template function relates to/knows which template to call.


texts: Drupal 7.13 and Services 3.5 XML Payload schema to Update Node?

texts:
I have finally got Services up and running and setup an endpoint to nodes but can't work out how to update custom fields from a POST or PUT.

Been trawling through the docs, examples, and tutorials but none seem to offer a simple explanation of the XML payload schema to update custom fields of nodes (Using REST).

Below is an example of what I'm putting into by test client (Using REST console for Chrome plugin)

URL: http://example.com/task/node/65
Encoding: application/x-www-form-urlencoded
METHOD: PUT

Payload:-

<title>New Title</title>
<body>New Body Content</body>

However this doesn't update anything, I just get the following response:-

<?xml version="1.0" encoding="utf-8"?>
<result>
    <nid>65</nid>
    <uri>http://example.com/task/node/65</uri>
</result>

It seems to create a revision and logs the update, but no fields are updated.

Can anyone advise the schema I need to follow for the payload? Thanks for any help or pointers!

EDIT: Thanks to Clive for a key pointer: Sticking ".xml" on the end of the URL seemed to make it update the body field, and then changing the content-type header to application/xml seemed to help as well.

So the following REST client config is now working:-

URL: http://example.com/service_endpoint/node/nid.xml

REQUEST METHOD: PUT

CONTENT-TYPE: application/xml

RAW PAYLOAD:-

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <name>user</name>
    <title>Change this owner!</title>
    <body>
        <und is_array="true">
               <item>
                <value>Another owner test</value>
            </item>
        </und>
    </body>
</data>

Screenshot to help anyone else using the Chrome REST Console plugin:-

NOTE: I removed all security for the service and content type to make testing it easier but wouldn't recommend this on a public server!


texts: How to do (unit) testing of Drupal specific JavaScript code?

texts:
For PHP code in custom module, we use SimpleTest. But how do you test the JavaScript code in a module or a theme?

I known about JavaScript testing frameworks like Jasmine or QUnit, but I'm curious to known if and how they are used to test Drupal specific JavaScript code.


texts:
I am using Webform 7.x-4.0-alpha6.

I have configured a number of radio options in a "parent" component. When each of the radio buttons are selected, different "child" components showup. Each child is unique to each radio button in the parent. Like the following:

parent =>
radio#1
radio#2
radio#3

child=> [radio#1]
radio#1-option#1
radio#1-option#2
radio#1-option#3

child=> [radio#2]
radio#2-option#1
radio#2-option#2

child=> [radio#3]
radio#3-option#1
radio#3-option#2
radio#3-option#3
radio#3-option#4

What I am trying to achieve is allowing no more than one option to be selected across all the lists of radio buttons.

So, if I select radio#1-option#1 under parent=>radio#1 and I happen to change my mind and select radio#3=>option#4 under parent=>radio#3, I want radio#1-option#1 to be automatically deselected/unset.


texts: How do i create node directly from my own module with data of my tables

texts:
I need create a node from one table of my Database of drupal with all rows that it have.

That is, I need to extract data from my table and insert them automatically and make it appear as a node. Everything from my own module (That is, when I turn on my module see my table data were converted to node).

I thought of 2 solutions for this. The first is to create the content type in my drupal site and from my module implement "form_submit". (Can you do this?).
The second (which I am trying to do) is to create my type of content and form from my module. And since I can do the integration and transformation node me on my table.

Does anyone can help me on how I can do this? A code example of how to extract data and insert them into my form and make a submit directly?

thanks


texts: hook_block_view_MODULE_DELTA_alter gets fired twice

texts:
I'm trying to change the content of a block when a specific node is displayed. The code works fine.
BUT
the hook custom_block_view_block_1_alter gets called twice.
that is GOT MY NODE is displayed twice.
How come?

<?php
/**
* Implementation of custom hook_node_load
*/

$count=0;
function custom_node_load($nodes,$types){
  foreach($nodes as $key =>$node){
    if($node->type=="person"){
      drupal_set_message("Person Node loaded");
      $customised_value="WAHAHAHAHAHAHAHAHAHAHAHA";
      $node->customised = $customised_value;
      variable_set('my_person_node',$node);
      drupal_set_message("WAHAHA");
    }
  }
}

/**
* Implementation of hook_block_view_MODULE_DELTA_alter
*/
function custom_block_view_block_1_alter(&$data, $block) {
  global $count;
  if($block->delta=="1"){
    ++ $count;
    $block->title="HERHE";
    $my_nodes=variable_get('my_person_node');
    dpm($block);
    $data['subject']="HEHE";
    $data['content']="<strong>".$my_nodes->customised."</strong>";
    drupal_set_message("GOT MY NODE".$count);
  }
}


texts:
I am checking for a specific block in a specific theme region.

{% if page.header_first.blockmachinename %}
   // Show stuff
{% endif %}

This works when I have the right machine name. But I want to be able to use a variable in place of blockmachinename.

Something like this, which of course doesn't work.

{% if page.header_first.{{ the_variable }} %}

This also didn't work, as expected

{% set block_name = 'page.header_first.' ~ the_variable %}
{% if block_name %}

Any clues?


texts: Date with an option for end date being either a date or "ongoing"

texts: I have a content type that contains relevant information of a project. It should hold the projects start date and the end date OR the status "ongoing". How do I make this happen? With the date field type I can only specify the starting and ending dates.


texts: Is there a way to access pane settings from the view pre build hook? I have a view being rendered inside a content pane. I have altered the pane's settings form and added a setting field. Now I need to access this field in the hook_views_pre_build in order to change something in the view. Is there a way for me to access that value?


texts: Commerce module "Add to cart" is displayed as "Product not available"

texts:
I am n newbie into Drupal.
I've added new Product and in the store for this product it shows PRODUCT NOT AVAILABLE and the button is disabled.(there is no Add to cart).
Product is active and is displayed in catalogue.


texts: Clear Example for drush rsync exclude paths

texts:
I've seen many exclude path examples here on stack exchange. But I can't figure out the way to make it work.

To keep it simple :

We have two aliases @self  and @live

we have a theme called themename in /sites/all/themes/themename

in the theme folder we have a subdirectory called node_modules because of the use of gulp in our development workflow.

How can we make sure to exclude /sites/all/thems/themename/node_modules/ when syncing with drush rsync @self @live ?


texts: Way to modify rule created by Commerce Fixed amount coupon

texts:
Currently Fixed amount coupon will be applied to the cart irrespective of number of items present in a cart, I need to modify its rule so that it will be applied to each item present in the cart and total amount deducted should be according to the number of items present. For example- I have Fixed amount coupon "TEST" with amount $100, no. of items in my cart are 3, then total amount deducted after applying coupon should be $300, currently amount deducted is $100.
Anyone can help on this?

Thanks in advance.


texts:
What's the best module for a session timeout?

I simply want users to be automatically timed out after a period of inactivity.

The Automated Logout module looked like it could to the trick, but it seems like it does a lot more too.  Also, I am using Drupal 7 and it's still in dev.


texts: How to update field after ubercart checkout completion?

texts:
I have created a field (checkbox) in user profile edit form that is only visible to admin.

When the user completed their checkout process (after payment) that field which I created previously must be updated (I.e: checked).

I want to implement this functionality for letting admin know about who has purchased the subscription plan .

How could I do it by using rule or something else?


texts: Override entire user login / register page

texts:
I am trying to figure out a way to override the entire /user page in D7.
There is a lot of articles out there that goes about altering the form, but I want to be able to rework the entire page (forms included) to get them into a nice bootstrap layout.

A lot of the information on the web is talking about page--user--login.tpl.php, but this does not work at all.

When using page--user.tpl.php, it seems to render my template file, but I cannot re-render the form.

When using

<?php
  $form = drupal_get_form('user_login');
  print drupal_render($form);
?>
My HTML goes here
<?php
  // Render any remaining elements, such as hidden inputs (token, form_id, etc).
  print drupal_render_children($form);
?>

I keep getting an infinite redirect loop. My best guess is because of a problem with the form_id that does not match.

Ps: I am using a bootstrap subtheme.

All information about this would be greatly appreciated.


texts: what is the difference between a load callback and list callback in the i18n hook_i18n_object_info() function?

texts:
I am learning how to use the i18n module to translate a module. In hook_i18n_object_info() implementations, I have noticed other modules using list callback or load callback.

What is the difference?


texts: Imagefield Crop - Cannot read property 'substring' of undefined

texts:
I'm using Imagefield Crop to resize images in my site after upload.

I have this JS error in the console after uploading my image :

  Uncaught TypeError: Cannot read property 'substring' of undefined

This line causes the error code in imagefield_crop.js :

var id = self_id.substring(0, self_id.indexOf('-cropbox'));

Can anyone confirm that this is a bug in the module ?

Thanks.


texts:
First up I'm very new to the Drupal way of things but have jumped on board with Drupal 8 and quite excited about the possibilities.

What I'm trying to do is redirect the default node view route (i.e. /node/12345/), for a specific content type, to a route I've setup in my module i.e. /module_name/view/12345/

Currently I've done this via a hook which I'm 99.9% is the wrong way to do it but it does work. However I'm getting warnings in my log file as other Drupal commands (including drush) occasionally trigger the hook.

Here is my code so far:

function gst_return_entity_view_alter(array &$build, Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display) {
    if($entity->bundle() == 'gst_return') {
        header('Location: /gst_return/view/' . $entity->id());
        exit;
    }
}

Two questions really:

Is there a better way to be doing this? I'm sure there is.
If the above is acceptable then what can I add to it so that the header redirect (which probably should be a Drupal core redirect?) so that it is only triggered in the context of someone viewing the site.

Thanks for any assistance.


texts: Two different sites, two installations, no database or core sharing

texts:
I've finished configuring a Drupal site using localhost (Mamp) but I have to wait some weeks until it gets uploaded to external host.

Now in the meantime I'd like to start developing another site that has nothing to do with the first one (different database, users, modules, etc). That is: I'd like to 'park' the old site and start creating the new one (new Drupal 7 installation) without affecting the first one.

I'm using Mamp 3.0.7.2 and the server route is default (Mamp--- htdocs)

Any hint on what to begin with?

Thank you


texts:
I'm running a system where has a view with export functionality in order to export results in xls format.

Is there anyway I can automate it so every week it auto generates a report and email it.

I'm guessing I can use rules to do it but dont know how.

Thanks


texts: I need a module which can fetch rss titles + publish dates and show them in a block/teaser. I tried aggregator and it does some of the job, but you cannot show publish dates in the list. The "read more" link should go to the original RSS or custom URL. It is important that all links link to the original url in the RSS and not to any view in drupal. Any suggestions for modules or other solutions?


texts: Trouble adding conditional to page-title.html.twig

texts:
I am building my first D8 theme and I am new to Twig. I am trying to add a class to the h1 title tag on the home by editing page-title.html.twig, but I can't get it to take. Here is my code

{% set body_class = '' %}
{% if title == 'Welcome to My Website' %}
    {% set body_class = 'home-page-title' %}
{% endif %}

{{ title_prefix }}
    <h1{{ title_attributes.addClass(body_class) }}>{{ title }}</h1>
{{ title_suffix }}


texts: How to use Rules to send separate email to every user referenced in user reference field?

texts:
I have a node with a user reference field, in which a user can select unlimited users who they have a relationship with. I'd like for the saving of this node to trigger a separate email to be sent (via Rules) to each user chosen in that reference field, or a single email with all of those users BCC'ed. Currently, the "send mail" action with "node:field-friends-you-wish-to-invite:0:mail" selected in the "To" field of the Rule only sends an email to the first user selected in the list, no matter how many other users have been selected.

How can this be accomplished?


texts: How to get product variation of a single product in view

texts:
Let's assume I have a product named A, B, C and each of those products have variations.

Now, when I am making a block in views, when I only have the option to select product variations as seen in this image:

After this, there seems to be no way to select a product variation of say product A.

All the variations are there by default.


texts: How to override the inner contact template?

texts:
All I can seem to find is page--contact.tpl.php, which allows you to modify the overall layout. But inside this template it just calls

print render($page['content']);

For nodes, $page['content'] could be overwritten in node.tpl.php but I don't see any sort of template files inside the contact module folder, or anything else to adjust the inner layout.


texts: How to apply some rules to fields in native contact form?

texts:
I use the native Drupal 8 contact form with different custom fields.

I need to apply some rules more precise than the classic "required". For example, telephone number accepts only numeric characters and needs to be filled with 10 characters.

What is the best approach to do that with Drupal in a native way ? Is there a module that can do it ?

I can do it with jQuery but i would like to do it on a server side way.


texts: Flush cache on specific drupal 8 page/route

texts:
I am building a CRUD form in Drupal 8. Users get navigated to it from a list that shows the entities they are editing. After an edit or add they get redirected to the list again. The list is generated in a twig template that is being cached. It's a custom route/controller.

How do i invalidate/delete the cache on that specific list page/route after an edit/add of an entity?

The data in the list is build in custom action, it's no view, and as far as drupal knows, there are no nodes shown in the template. So no default cache functions are triggered.


texts: Left join query between two custom tables

texts:
Hi I'm trying to create a join query between two custom tables. One is publish_options with a pubid as the primary key. The other is publish_options_bundles with a referring field pubid to the first table.

The problem I'm having is that the results returned are as such:

Array
(
    [0] => stdClass Object
        (
            [__CLASS__] => stdClass
            [pubid] => 51
            [title] => Promote to blog
            [created] => 1549262900
            [modified] => 1549262900
            [bundle] => article
        )

    [1] => stdClass Object
        (
            [__CLASS__] => stdClass
            [pubid] => 51
            [title] => Promote to blog
            [created] => 1549262900
            [modified] => 1549262900
            [bundle] => gallery
        )

    [2] => stdClass Object
        (
            [__CLASS__] => stdClass
            [pubid] => 51
            [title] => Promote to blog
            [created] => 1549262900
            [modified] => 1549262900
            [bundle] => page
        )

)

I would like it to return like:

(
  [__CLASS__] => stdClass
  [pubid] => 51
  [title] => Promote to blog
  [created] => 1549262900
  [modified] => 1549262900
  [bundles] => [
    page,
    article,
    gallery,
  ]
)

The code I've come with is below.

$query = $this->connection->select('publishing_options', 'po')
      ->fields('po')
      ->condition('po.pubid', $id);
    $query->leftJoin('publishing_options_bundles', 'pob', 'po.pubid = pob.pubid');
    $query->fields('pob', ['bundle']);

    $result = $query->execute()->fetchAll();

Any help would be greatly appreciated as I am completely stumped now.

Thank you in advance.


texts: How to capture bank payment info to store for payment processing using Drupal Commerce?

texts: I'm using Drupal Commerce. Is there any way to capture bank payment info to store for payment processing? So that a customer doesn't need to enter details on each transaction.


texts: How to get a parameter value from the current URL in views-view-fields.html.twig?

texts:
I need the argument value in the theme templates and using the views-views-fields--view_name--block_1.jhtml.twig.

I'm current getting the current URL like that:

{% set url = url('current')%}

Which outputs:

https://example.com/questions/12225

But I need only the 12225 value from the current url. How can I get the last parameter from the current URL in Twig?


texts: Next/Prev buttons for nodes based on nodereference field

texts:
By using this tutorial http://blog.urbaninsight.com/2011/09/12/adding-pager-navigation-nodes-drupal-7 I have created next/prev buttons for my images.

But as I have a lot of galleries and I need to filter images not only by node type but also by node reference field value.

The machine name of my field is field_pers_gallery and in phpmyadmin it is assigned to a particular gallery by field_pers_gallery_nid.

I'm note good at creating db query, could anybody help with any advices?


texts:
I'm currently using the preprocess_breadcrumb hook in my .theme file to customize the output of my breadcrumbs like so:

function mytheme_preprocess_breadcrumb(&$variables){
    $node = \Drupal::routeMatch()->getParameter('node');
    $current_path = \Drupal::service('path.current')->getPath();
    $result = \Drupal::service('path.alias_manager')->getAliasByPath($current_path);
    $crumbs = explode("/", $result);
    if($node){
        $variables['current_title'] = $node->getTitle();
        $variables['crumbs'] = $crumbs;
    }
}

I then use breadcrumb.html.twig to use these new variables like so

{{ 'You are here'|t }}

        {% for crumb in crumbs %}
            {% if loop.first %}

Home

        {% elseif loop.last %}

{{ current_title }}

        {% elseif crumb == 'node' %}
        {% else %}

 {{ crumb }}

        {% endif %}
        {% endfor %}

{% endif %}

However I'd like it more if all this was encapsulated in a module. In mymodule.module file I have

function mymodule_preprocess_breadcrumb(&$variables){
$node = \Drupal::routeMatch()->getParameter('node');
$current_path = \Drupal::service('path.current')->getPath();
$result = \Drupal::service('path.alias_manager')->getAliasByPath($current_path);
$crumbs = explode("/", $result);
if($node){
    $variables['current_title'] = $node->getTitle();
    $variables['crumbs'] = $crumbs;
}

}

But this function never fires. Is there a way to use the preprocess_breadcrumb hook from a module?


texts: How can I add a link to show/hide threaded comments?

texts: I've enabled threaded comments in the comment settings on my Drupal 7 site. Now, on every comment that has threaded comments beneath it, I'd like to add a link (in the same place as the reply/edit/delete links) that enables users to toggle the display of the threaded comments beneath it -- a show/hide replies link.


texts: How can I link one drupal View field (an image) to a QuickTab?

texts:
Im trying to link each image field of my view to a quicktab that I created. This is my view

and this is how it looks

As you see I already tried to put the url link and rewrite the stuff, I put content and nothing to the image (the part of the landing), I even tried to put it as an external link, but it never recognize it as a link.


texts: Relation between User field and current user

texts:
I have created a view for particular user role (i.e: Agent) that manage some user (for example, users with id: 1, 2, 3).

I've created a custom field for this user for associate this agent with some users.

It's possible create view who allow of this agent view, edit, ecc only content created by users who managed by him?


texts: Why my taxonomy term list in content is not using node languages prefererence

texts:
I have a multilingual website, in which I activated the i18n module and every related modules.

I have a taxonomy vocabulary Colors.

When I create or edit a content, all my colors are displayed. What I mean is, even if my node are in English, I saw every colors (English and French).

Is there a way to displayed my color based on node languages preference?


texts:
Where can i find the core theme function code (D7)? I would like to use the table theme function as a template for a new theme function I'm writing.

Arnold


texts: how to give the id of image in drupal 7 views?

texts:
I have a view in drupal 7 and I am displaying node title and node image .
I need to give id for a image.
Now I am getting:

But I need Id .Means I need


texts: I have a Drupal 7 site. This is a live site with both legitimate comments and spam comments. From what I can tell, most of the spam modules work when a comment is submitted, but don't go back and look at existing comments, comments added prior to the module being installed. I'm looking for a way to do this programmatically.


texts: Hide Profile2 fields depending on it's value when viewing user profile

texts:
I am relatively new to drupal and for days I'm stuck.

I need to hide fields from the user profile page when they have a specific value. Adding a CSS class would also do it. But I prefer deleting the array element.

I try to use the hook_profile2_view_alter() function in my template php. Sure I can access the field options but not it's value directly.

Perhaps I'm digging in the wrong hole and there is a smooth "Drupal way" to do it.


texts: Drupal commerce order total ignore changed unit price

texts:
I have problem with commerce order total counting.

Every product has two prices (two fields). One price for everybody and second for exact role. I have rule which change prices if user with exact role is logged in.

When i browse product with exact role all prices are ok. If i add some product to cart a go to my cart product prices and total price is still good. But when i go to checkout total price is set to 0.

In checkout are all products with good price but total price is 0.

Rule for changing price is simple:

event: calculate product price
condition: user role
action: set a data value (commerce-line-item:commerce-unit-price -> second price field)

Do anybody know what could be wrong? Thanks for every advice.


texts: Adding Rules to Canada Post and UPS (Ship-by-weight)

texts:
I've a site with Drupal Commerce. I'm utilizing both the Commerce UPS and Commerce Canada Post modules. However, these modules are pulling the shipping cost directly from Canada Post and UPS using their API's.

I want to implement a rule that does the following:

Per Ounce
Base Charge: $13.35
Minimum Amount: $0.00
+  $0.00  per ounce on weight less than  21 oz (pivot-weight)
+  $0.30  per ounce on weight greater than 21.00 oz

How do I do this within the Commerce Canada Post and Commerce UPS modules?


texts: What's the purpose of $item in taxonomy_field_is_empty($item, $field)?

texts:
Please explain:

taxonomy_field_is_empty($item, $field)

$field - this is name of field

$item - what is it ???

I want to use on my function for check if tags field empty in node we don't show other articles, show otherwise.


texts: urol executed via bash throws exception error if role has a space in it

texts:
Role name "teaching assistant"

command executed is:

drush @comply-all urol "teaching assistant" sdf --y

if I copy and paste this it works fine. if the following command is called from a bash script it bricks every time when encapsulating the role name (which is needed otherwise it's evaluated by drush as two different arguments). Anyone experience anything similar?

[ulmusdrush@localhost ~]$ exception 'Drush\Role\RoleException' with message 'Could not find the role: "teaching' in          [error]
/home/ulmusdrush/.composer/vendor/drush/drush/lib/Drush/Role/RoleBase.php:46
Stack trace:
#0 [internal function]: Drush\Role\RoleBase->__construct('"teaching')
#1 /home/ulmusdrush/.composer/vendor/drush/drush/includes/drush.inc(113):
ReflectionClass->newInstanceArgs(Array)
#2 /home/ulmusdrush/.composer/vendor/drush/drush/commands/core/role.drush.inc(273):
drush_get_class('Drush\\Role\\Role', Array)
#3 /home/ulmusdrush/.composer/vendor/drush/drush/commands/user/user.drush.inc(281):
drush_role_get_class('"teaching')
#4 [internal function]: drush_user_add_role('"teaching', 'assistant"', 'qwe')
#5 /home/ulmusdrush/.composer/vendor/drush/drush/includes/command.inc(359):
call_user_func_array('drush_user_add_...', Array)
#6 /home/ulmusdrush/.composer/vendor/drush/drush/includes/command.inc(210):
_drush_invoke_hooks(Array, Array)
#7 [internal function]: drush_command('"teaching', 'assistant"', 'qwe')
#8 /home/ulmusdrush/.composer/vendor/drush/drush/includes/command.inc(178):
call_user_func_array('drush_command', Array)
#9 /home/ulmusdrush/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(62):
drush_dispatch(Array)
#10 /home/ulmusdrush/.composer/vendor/drush/drush/drush.php(70):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#11 /home/ulmusdrush/.composer/vendor/drush/drush/drush.php(11): drush_main()
#12 {main}


texts: Adding html subsites to Drupal 7 installation

texts:
Newbie here, and would appreciate any insight.  I have a Drupal 7 site and am looking to create a few small HTML subsites (e.g., Drupal site www.mykittenmittons.com, html subsite cats.mykittenmittons.com).

After creating my Drupal site on BlueHost I used their "subsite" tool. The subsite folder is automatically generated in public_html. I gave it a whirl and added my html files to the subsite folder and it seems to work. Are there any reasons to not handle html subsites in this way, or problems I could encounter? Thanks.


texts:
I am trying to create a custom page that display my resuslts which I receive after I search for a post.

I am having no luck, I am a total begginer in drupal 7, I googled and looked around here but I did not quite understood what I have to do.

What I tried:

function **themename**_preprocess_search_results(&$variables) {
  $variables['search_results'] = '';
  if (!empty($variables['module'])) {
    $variables['module'] = check_plain($variables['module']);
  }
  foreach ($variables['results'] as $result) {
    $variables['search_results'] .= theme('search_result', array('result' => $result, 'module' => $variables['module']));
  }
  $variables['pager'] = theme('pager', array('tags' => NULL));
  $variables['theme_hook_suggestions'][] = 'search_results__' . $variables['module'];
}

Creating a search-results.tpl.php ( did not work )
The only module I have installed for search is the default search module.

Nothing seems to work. Thanks in advance


texts: How to populate DB values in content type field, drupal 7

texts: I have created a content type with 4 field in Drupal 7. One field is of list type, say for listing countries. I have tables in DB for saving country_id and country_name. Is there any way to connect the DB table and content type field? I want to list all these countries in the content type's country field.


texts: How can I add help tips on each page, like a sliding panel?

texts:
Is there any module I can use to insert in every page info about the specific page. I could use something like a sliding panel, or a popup. I need the content of that, block or popup or whatever it is, to be translatable.
I found this link, but it needs much custom code, which I would like to avoid.


texts: How to provide a translation for a string used within t()?

texts: On my site I use a module which creates text using t('text from module'). How can I tell drupal that I have a translation for that, and of course, that my translated text is being displayed?


texts: How to access custom global using menu token module?

texts:
In a project I'm working on, there's a global variable called School Year. There's a page where the user selects the school year to be used throughout the session or until they change it. According to the page, it's stored as "field_school_year_term_". The School Year was created via taxonomy, and what I need is to make it so that the selected school year is made a part of a set of urls.

To do this, we're using the Menu Tokens module. We've tried a large amount of available tokens for it, such as:

/foo/[school-year:id]/bar
/foo/[school-year:school_year]/bar
/foo/[current-user:field_school_year_term]/bar
/foo/[user:field_school_year_term]/bar

Each of these has failed to replace the token, even while switching around the methods to replace the tokens. I do have Use tokens in title and in path checked, as well as [site:url] before the path we want to make.

Basically, how can I access the global field using menu tokens, and what other suggestions do you have? I'd like to avoid having to code in a redirect (though that solution may prove handy to resolve this issue).


texts: How to create nested paragraphs items programmatically?

texts:
Basically, i am programmatically generating a node. Those nodes have several anidated paragraphs like this:

-title parent
 -body parent
 -links parent
 -title child
   -body child
   -links child

-another parent
 ..etc..

I'm doing this with paragraphs, i have a parent paragraph that includes another.
At the time of generating the node i'm generating in a sufficient manner the parent paragraph with the following code:
('field_contenido_padre' is the field that contains the parent paragraph)

$paragraph = new ParagraphsItemEntity(
      array(
        'field_name' => 'field_contenido_padre',
        'bundle' => 'acordeon'));
$paragraph->is_new = TRUE;
$paragraph->setHostEntity('node', $parent);
$paragraph->field_titulo_acordeon[LANGUAGE_NONE][0]['value'] = $value["title"];
$paragraph->field_body[LANGUAGE_NONE][0]['value'] = "jajaja";

$ia = 0;
foreach ($value["items"] as $k => $item){
    $paragraph->field_link_archivo[LANGUAGE_NONE][$ia]['title'] = $item;
    $paragraph->field_link_archivo[LANGUAGE_NONE][$ia]['url'] = $value["items"][((int) $k + 1)];
}
$paragraph->save();

OK. this works.
Following further from here is my problem.
Now i would like to attach a child paragraph to this recently generated parent paragraph.
I've tried the following with no success:

first, generate the child paragraph
('field_acordeon_hijo' is the field in parent paragraph that contains the child)

$paragraph = new ParagraphsItemEntity(
    array(
      'field_name' => 'field_acordeon_hijo',
      'bundle' => 'acordeon-hijo'));
$paragraph->is_new = TRUE;
$paragraph->setHostEntity('paragraphs_item', $parent);
$paragraph->field_titulo_acordeon_hijo[LANGUAGE_NONE][0]['value'] ='TITULAko Hijo';
$paragraph->body[LANGUAGE_NONE][0]['value'] = 'jajaja';
$paragraph->save();

Now i try to save the recent child into the parent's container field:

 $entity = entity_load('paragraphs_item', array($parent->item_id));
 $entity = reset($entity);
 $entity->field_acordeon_hijo[LANGUAGE_NONE] = array(
     0 => array(
       'value' => $id_child,
       'safe_value' => $id_child,
       'format ' => NULL));
 $entity->revision = TRUE;
 $entity->save(FALSE);

I get no errors, the parent paragraph is generated fine, but i don't see the children paragraphs :-/

I guess it's because I'm attaching the child to the parent, while maybe I must attach it to the node; but in that case, how to point the child to the parent?


texts: Better exposed filters allows only one checkbox at a time

texts:
Im using a exposed filter in views. That filter is displayed as a checkbox using the BEF module.
Im allowing multiple selection on that filter.

The problem is that when a user click on multiple checkboxes at once it only selects one. Its like refreshing after you check one selection and then it scrols up the list. You can select more then one option, but not at once.

And yea, Ajax is enebled.

Anyone else has this kind of a problem?


texts: Create Node and related Node at the same time?

texts:
I have a content-type (Recipe) that is created by anonymous users and can be rated/reviewed with another content-type (Review).

Users should be able to write a Recipe and a Review related to that Recipe at the same time on the same Page. I think I'm searching for the wrong things but I can't find a solution for this Problem without the need to write a new module.

Thanks in advance.


texts: Loading bootstrap.inc in external PHP file in a subdirectory

texts:
I'm trying to check if there is a user logged into drupal in a PHP script that resides within a subdirectory of the drupal root. I know that there can be issues with calling the bootstrap anywhere apart from in the drupal root, so I've created a drupal_bridge.inc.php file inside the root containing the following code, which I then call in the PHP script using include.

<?php

define("DRUPAL_ROOT",     "/var/www/vhosts/mysite.com/httpdocs/");

$current_wd = getcwd();

chdir(DRUPAL_ROOT);

print getcwd();

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

global $base_url;

$base_url = (array_key_exists('HTTPS', $_SERVER) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'];

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

chdir($current_wd);

global $user;

if ($user->uid) {
    print "Logged in";
} else {
   print "Logged out";
}

echo 'INCLUDED';

?>

However, when I visit the PHP script in the browser it says I am logged out. Strangely though if I visit the drupal_bridge.inc.php file directly it can access the user information and it says that I am logged in.

I have set $cookie_domain = .mysite.com in the settings file as well. I have password protected the directory containing the PHP script but I didn't think that made a difference at this level.

Any ideas?

Also, I have looked into turning this in a module but it is not really practical so I would appreciate it if you did not advise doing so.

UPDATE: I just did a print_r($GLOBALS); to see if I could find out what was actually available and I found the following errors, if that helps.
http://pastebin.com/YtHPGD75 (too long to post here)


texts:
How do I add target='blank' to a href in a Drupal 8 custom module? Below I have the image being wrapped by the uri. I don't know how to add target='blank'

  $element[$delta] = array(
        '#theme' => 'image_formatter',
        '#item' => $item,
        '#image_style' => '',
        '#url' => $uri,
      );


texts: How to pass seperate contextual filter values to a view and get results programatically?

texts:
I've a view having two (separate) contextual filters, say node id and taxonomy id. We can pass separate contextual filter values with a "/". example: 12,13,14/8,9 as URL arguments.

But how can we get the view results by passing the dynamic contextual filter values to the view?


texts: Get readable content array keys when using Layout Discovery and layouts templates

texts:
I noticed when using Layout Discovery on nodes display modes, the content array looks like this.

Compared to the content array without using Layout Discovery which looks like this :

A counterpart of this is that it makes it harder to alter fields inside templates.
I understand this is because fields are wrapped inside blocks, and those blocks are giving their id as keys.
I kind of fixed it this way

function theme_preprocess_layout(&$variables) {
  // Replace complicated hashes keys by field names
  // to allow customization under layout templates.
  // Applied to fields as blocks only (not views, custom blocks, etc.).
  foreach (Element::children($variables['content']) as $name) {
    foreach ($variables['content'][$name] as $key => $value) {
      if (substr( $key, 0, 1 ) !== "#" && isset($value['content']['#field_name'])) {
        $newkey = $value['content']['#field_name'];
        $variables['content'][$name][$newkey] = $variables['content'][$name][$key];
        unset($variables['content'][$name][$key]);
      }
    }
  }
}

Which render this content array afterwards (I did not test on display modes for other entity types):

And allows doing that kind of things under e.g. layout.html.twig :

{% if content.header['field_video'] %}
  {{ content.header|without('field_image') }}
{% else %}
  {{ content.header }}
{% endif %}

I have the feeling that we are losing the great feature of twig filters on fields that are part of node templates here.

So, did someone came into the same issue and did you find another way to bypass this?


texts: need to show user firstname and lastname in search result page

texts:
I'm very new in drupal, and I have a custom user module where I need to show the user's first name and last name in the search result page. I used some of my code which is throwing a fatal error.

What is wrong with the code I am using?

function somik_user_byline($uid) {
  $cache = &drupal_static(__FUNCTION__, array());
  if (isset($cache[$uid])) {
    return $cache[$uid];
  }

  $account = user_load($uid);
  $byline = $account->name;

  $first_name = somik_user_profile_field_value($uid, 'field_firstname');
  $last_name = somik_user_profile_field_value($uid, 'field_lastname');

  if ($first_name && $last_name) {
    $byline = $first_name . ' ' . $last_name;
  }

  $cache[$uid] = $byline;

  return $byline;
}


texts:
How do I modify the teaser products display page in Kickstart Commerce?

I would like to display smaller product teasers with a "four column" layout versus the default "three column" layout. Is this a task for "views"? Modifying some "css" file? Both?!

Any direction on this would be huge help.

Thank you!

Tom


texts: Using webform-form-[nid].tpl.php to change default template

texts:
On drupal 7, using webform 7.x-4.11, I am trying to modify the template of a specific webform.

So, in /web/themes/bartik/templates (I am using bartik theme) I created a file named webform-form-23.tpl.php

As "23" is the nid of my webform. But the template is not applying at all...

If a create a file webform-form.tpl.php it is well applying to all my webforms...

This is not a matter of caches as it is well applying when using a file named "webform-form.tpl.php" (with no ID) and despite of that the cache has been cleared at every changes.

Can someone help me on this one?


texts: Problems with Workbech Moderation states

texts:
I'm using Workbech Moderation module. I need to moderate some types of content.
The problem that I've is that after change the moderation state to Publicate ("Publicado"), it doesn't change the state.

This are the transitions that I've:

I need 3 states, Publicate("publicado"), Needs Revision ("Necesita revisión") and Archivado Legal.

I've a menu link to see all the nodes that needs revision. With a menu badged, that counts the nodes that needs revision.

After moderate the node and change the state to "Publicado" the menu badged decreases, but if I go to "find content" menu link, I can see that is not publicated.

If I edit the node I can see that the moderation state is "Draft".

If I delete Draft state from the Workbench moderation state configuration, I can see that the nodes moderation state is empty.

This is a bug? If it isn't, what can I do?

I hope somebody can help me.

Thank you in advance.


texts: Add PayPal WPS payment payload information to Commerce admin e-mail

texts:
I'm using Commerce with the Commerce E-mail module to customize the e-mail sent to admins whenever there is an order (a payment is received) at the store.  Payment is handled using PayPal WPS through the Commerce PayPal module.

On my site, buyers must input their e-mail addresses before moving on to PayPal, but these e-mail addresses (on my site) sometimes differ from the e-mail addresses registered on buyers' PayPal accounts.

For this reason, I want the admin e-mail (sent when an order is paid for) to include both the e-mail address that the buyer input on my Drupal site as well as their PayPal e-mail address.

Commerce E-mail provides a [commerce-email:order-items] token, but there is no token for the PayPal WPS information.  This information is stored within Drupal; in the Order Admin UI, if you click on the payment details of the transaction, under Payload there is a printout of an Array that includes [payer_email] => thepayeremail@example.com.

Payload array:

Array (
    [13775355555-ipn] => Array
        (
            [mc_gross] => 17.00
            [invoice] => 555-1377531555
            [protection_eligibility] => Eligible
            [payer_email] => thepayeremail@example.com

How can I add the buyer's PayPal registered e-mail address ([payer_email]) into the admin e-mail sent by Commerce?  It would be great if the solution would also allow use of other information in the payload array, such as the buyer's physical address.


texts: How to add a theme suggestion to the textfield input based on the name of the view?

texts:
I am using the following hook in a custom module:

MY_MODULE_theme_suggestions_input_alter(&$suggestions, array $variables) {

  $suggestions[] = 'input_'. $element['#type']. '__'. 'form_id__' $element ['#form_id']. '__'. $element['#name'];
}

With which I get something similar (In my case I have an exposed filter using search api):

input-textfield-form-id-views-exposed-form-search-api-fulltext.html.twig

How can I get the suggestion in the following way?

input-textfiel--viewName--search-api-fulltext.html.twig

Where viewName is the name of the view from which the field is exported.

How can I access the view information from this hook?


texts: Commerce Products Display Page Using Views

texts:
The usual way to display Commerce products is

1. Create Products using Commerce Module Interface

2. Create a Content  Type for Products Line Items by referencing the products

But I have too many different products... should I have to create contents after adding each commerce Products??

I used two views for each products one to create a products listing and other for product display page using contextual filters and by passing the Product ID

Product Listing Page path : /products-list

Product Display Page      : /products/product1

By passing the product ID via URL.

Is this a write way to do it... Or is there anything efficient and meaningful than this method?


texts:
I'm using the Recruiter Distribution want to enable breadcrumbs. I try the module  Path breadcrumbs or Custom breadcrumbs. Still they are not visible.
I also copied this code to the page.tpl.php of Cloudy theme.

<?php
 print $breadcrumb
?>

The Recruiter Distribution is using the Cloudy theme.

Am I  missing something?


texts: Drupal 7 and views: Get results from two content types and their own individual terms

texts:
Drupal 7 and views

My issue might be hard to explain but here goes:

What I want:

show all nodes from two content types, that is tagged with their own individual terms.

What I have done so far:

I created a view that should display nodes from content type"names", and content type "name_auto" that is tagged with "job" the two content types, has its own term but the name is the same. (so job and job, could be different, like: bike and carpet)

My filter looks like this:
is published AND
content type is names, name_auto AND
term is job OR
term is job

What the issue is now:

the view give me zero results, but, if I remove one of the terms in filter, I get results but only from one of the content types.

I need to get results from both tagged with job from names, and job from names_auto.

Issue simplyfed (bottomline):

This scenario could just as well be content type shoe, tagged with bike, and content type house, tagged with carpet. and then I need all nodes of bike and house, tagged with their own terms.

What i think is wrong:

I think the view looks for the term in both content types, and then when it only find it in the one, it dont display any of them at all. But why does it do that? I have tried to change the order of the filters and nothing works.

I know it would be easier if you could just see the view, but its on a local site, if the view query, or an export dump would help, please let me know :)

I hope I have explained this well and that you understand my problem.


texts: How to know which name will have my view tpl file?

texts:
Currently i have a view with the name:

name (String, 21 characters ) home_slideshow_mobile

At the same time this view content is displayed inside a block, which filename (tpl.php) should it have my template file to rewrite the content of this view?

Thanks a lot :)


texts: How can I make the label text on a Views Exposed Filter inline?

texts:
In Views 3, it's easy to make the labels of fields appear inline by adjusting the settings at Format: Show: Settings.

However, there appears to be no corresponding setting for Exposed Filters.  I tried to do it myself in CSS,  but adding:

#edit-field-acc-gender-value-wrapper label

gives me the horizontal alignment but not the vertical alignment, as you can see below:

How can I fix my CSS, or is there a better way to make the labels for Exposed Filters inline?


texts: Why does the selected payment method comparison always fail?

texts:
I'm trying with following simplified rule but nothing happens if using maro_credits as payment method!?

{ "rules_pay_with_maro_credits" : {
"LABEL" : "pay with maro credits",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules_conditional", "rules", "commerce_payment", "commerce_pos" ],
"ON" : { "commerce_pos_transaction_completed" : [] },
"DO" : [
{ "CONDITIONAL" : [
{
"IF" : { "commerce_payment_selected_payment_method" : { "commerce_order" : [ "order" ], "method_id" : "maro_credits" } },
"DO" : [ { "drupal_message" : { "message" : "aklfjaipwoejfipasjfijasdfas" } } ]
}
]
},
{ "LOOP" : {
"USING" : { "list" : [ "order:commerce-line-items" ] },
"ITEM" : { "list_item" : "Current list item" },
"DO" : []
}
},
{ "drupal_message" : { "message" : "test pos event" } }
]
}
}

However the orders in admin - store - orders show up with the payment method, as shown in this screenprint:

http://imgur.com/a/XZeHy

Anyhelp?

Edit:
I used the mentioned selected_payment_method comparison method that pierre referenced below from start on.

cant add more than 2 links, so i have to add multiple pictures like this i guess:
first you see the selected_payment_method input for the version in the actions with conditional and the rule in the view also with what happens

i after changed the rule to use the conditions directly to show that also there it does not work

http://imgur.com/a/5Ekiu

is this more clear now? or you need more specification?

edit2: in the end i added some screens showing the fields that could be found (nothing with payment method)

Edit3:
Ok I added some descriptions in the pictures on imgur to clarify a bit.
In the end I want to be able to subtract user points form users that pay with "maro credits" (that part already works)

As you see in the screenshots I changed the rule having only the event pos transaction completed (that works!)

then condition selected payment method as shown

and action post a message

as you see in following screenshot that does not work (in the orders list you see there is the order with the payment method maro credits

I hope its clear now?

Ah forgot: in the last screenshots you see all the fields I would be able to chose from and there is none with payment method (and i think that is the problem...?)


texts: How to enforce role selection on the user's create, so they can edit other certain users?

texts:
I have three roles.

registry
teachers
students

How do I enforce role selection on user's creation?

I want the registry role to create and edit users (ONLY teachers or students role).


texts: How do I avoid hard coding the links in a custom made navigation bar?

texts:
I'm creating a custom navigation bar in drupal. I went ahead about this by creating it as a block and gave it all the neceassary CSS, but something that is not quit clear to me is how can I avoid the hard coding for the links?
or any other ways that I can achieve the same result?


texts: Custom template file to use themes html/page.tpl

texts:
I have a custom module (using Drupal 7) that adds a page using hook_menu(). Its callback just prints the value returned from theme('mytheme_hook').

If the content of my template file is simply 'hello world' I get only a white screen with the text output.

Is it possible for this page to extend the theme's html.tpl (and even page.tpl) with 'hello world' inserted in the 'content section' of the page?

This looks like a similar thing I am trying to achieve, but it doesn't offer a solution.


texts: How can I configure the User Points module so that if I open a forum that you can deduct 50 points? And if you can give a comment for 25 points.


texts:
What is the best way to do a db query for fields in a content type?

I need to get specific fields from a content type, but only where the 'featured' field value is 1.

<?php
        $query = new EntityFieldQuery();

        $query->entityCondition('entity_type', 'node')
          ->entityCondition('bundle', 'mycontenttype')
          ->propertyCondition('status', NODE_PUBLISHED)
          ->fieldCondition('field_mypdf', 'value', 'NULL', '!=')
          ->fieldCondition('field_mypdf', 'fid', 'NULL', '!=')
          ->fieldCondition('field_mypdf_image', 'fid', 'NULL', '!=')
    ?>

Originally, I was doing something along the lines of:

<?php
$query = "SELECT node.nid AS nid, 'node' AS field_data_field_news_node_entity_type, 'node' AS field_data_field_news_date_text_node_entity_type, 'node' AS field_data_field_news_teaser_node_entity_type, 'node' AS field_data_field_news_body_node_entity_type, 'node' AS field_data_field_news_video_node_entity_type, 'node' AS field_data_field_news_video_image_node_entity_type, 'node' AS field_data_field_mypdf_node_entity_type
    FROM node
    INNER JOIN field_data_field_news_is_featured ON node.nid = field_data_field_news_is_featured.entity_id AND (field_data_field_news_is_featured.entity_type = 'node' AND field_data_field_news_is_featured.deleted = '0')";
?>

$result = db_query($query);

<?php foreach ($result as $row) : ?>

    <div class="featuredArticle">
        <?php print $row->field_mypdf_value; ?>
        <?php print $row->field_mypdf_fid; ?>
    </div>

<?php endforeach; ?>


texts: content profile title token issue (trying to write own module)

texts:
/**
* Implementation of hook_token_values().
*/
function content_profile_token_token_values($type, $object = NULL, $options = array()) {
  $values = array();
  switch ($type) {
    case 'user':
      if (isset($object)) {
        $account = user_load(array('uid' => $object->uid));
      }
      else {
        global $user;
        $account = user_load(array('uid' => $user->uid));
      }

      $node_profile = content_profile_load('profile', $account->uid);
      $values['profile'] = ($node_profile->title) ? $node_profile->title : '';

      break;
  }
  return $values;
}

/**
* Implementation of hook_token_list().
*/
function content_profile_token_token_list($type = 'all') {
  if ($type == 'user' || $type == 'all') {
    $tokens = array();
    $tokens['user']['profile'] = t('Profile title of authors content profile');

    return $tokens;
  }
}

I have created a module, and added a .info file as intended, but when I check the token list for a image field title I don't see any of the tokens implemented by my module.
What am I doing wrong?

UPDATED!!!

Now i see my token in imagefield token list, but it doesnt works == doesnt add content profile title for img...


texts: How to add a custom icon or symbol to a flag link?

texts:
I'm working on a 'sample request' implementation for a commerce site using Flag, Views, sessions and a little custom code.

I'd like to add an icon or a symbol to let people know that an item they are viewing has been flagged.

I'm not sure exactly how to approach this, I can imagine perhaps adding a conditional field that displays an image or check box that is then changed by Rules or ajax, or perhaps something more complicated in JavaScript?

It could really be as simple as adding a checkbox that is checked or unchecked as the flag link is clicked or maybe even changing the css/html on click to be identified as marked.

Anyway, grateful for any advice here.


texts: Feeds creates duplicate content each time cron runs

texts: I have created a custom feed importer but each time it runs it creates the same content again. How can I make it only create the content once?


texts: Create a new revision automatically on edit

texts: When a node is edited I want to always create a new revision. I do not want people to be able to turn this off. How can I do this?


texts: I'm trying to locally host an already working/hosted website using wampp to try and edit it without messing up the site. But every time I try to open the site using localhost/example, it automatically redirects to the hosted domain(https://www.example.com). Can someone help me solve this issue?


texts: I want to specify a different file system remote server path. So that if I upload a file then this should be served from different remote server. I am using Drupal version 8.


texts: Show Views exposed filter user adjustment

texts:
I have a view where I show a table of some data. In that view I have a exposed form with some default filter values and the setting of remembering the input.

Now my question is, how can I check if the current filter values are not the default filter values?

I use Drupal 8.


texts: How to get a list of users based on the radius?

texts:
I want to allow users (workers) to give their address using addressfield and also give a distance or radius they are prepared to travel. It is a job site. When a client posts a job (node) and provides address, the clients must see a list of users (workers) who might be the potential candidates.

Obviously there will be taxonomy terms as well like interest, experience etc, but my question is about allowing a user to provide address and radius and then matching them with the node posted by the client and if the user falls within the address provided by the client, the client must see a list of users who will be available for the job in the area.

How should I go about it? What should be my approach?

Please clarify if there is confusion.


texts: Is there any way to disabling caching for a single field for anonymous users?

texts:
I ran into an interesting, but probably a common, problem. With caching turned on, stock is not updated immediately for anonymous users (which makes sense as that's the point of caching). However this results in a little bit of a UXWTF. When a product is out of stock, users are still shown that '1' is still available. It's only when they try to add it to the cart, they are met with a notice

The maximum quantity of 'product name' that can be purchased is 0.

I would still like to keep cache pretty much for everything else, but is there a way to disable caching of the available stock count?


texts: Gather all broken links (Link-checker) in view

texts:
I just installed the Link-checker module which seems nice for my needs. But I don't see a way to gather all the nodes with broken links, for example a view or block.

Is there any way to collect all these nodes with broken links in a view/block?


texts: Using Rules and Content access to restrict node access after date

texts:
The Goal

I am working on a way to shut off access to all nodes of a given type by setting their Content Access permissions to off, after a certain date has passed (and presuming that their access levels are not presently set to not allow anyone to see them, as I don't want this to trigger every time the rules run in a date range). Rules + Content Access was suggested to me in the #drupal IRC channel, but I'm not totally sure it is going to work.

What I've done so far

I have added a rule to be triggered when Cron Maintenance tasks run.
I added a "Data Comparison" rule to check site:current-date and see if it is past a certain value.

The Issue

When I go in to add the action of "Revoke Access By Role", I do not have the option to set on which content types I want the access revoked by. In fact, the only option in the selector is site:.

I have also attempted to add a node condition, but there is also no way to select any node fields, presumably because it's wanting to act on whatever triggered the event (i.e. Content Updated in the case of nodes), and since I've selected a cron I only have access to the site: parameters.

My Question

Is there a way to tell rules to change the content permissions for all nodes of a content type via a cron maintenance run, or will I need to write a custom method to be triggered via the rules condition? (Or a completely separate module for that matter).


texts:
Update#2

Actual user name is superuser but with kint, its still reading the admin id and displayname. This also happens to the URL, its reading the admin's profile link profile/1

I tried to dig into {{ content }} but cannot find tag with value superuser.

Update:

I noticed that in my twig template, {{ content.user_id }} would link into user's profile page(user/1), so the main question I think is what is the correct profile id of user in twig. I tried using content.profile_id but doesn't work.

I have this simple site that a user can post a simple content in the site. I also have a custom Profile type enabled from Profile module. I noticed that when I click on the photo, it is directed to the profile page profile/1(which is my expected result) but when the author name is clicked, it is directed into the user's profile page user/1. How can I change the author's name link to be directed into profile pageprofile/1?


texts: Views_view_result and Devel possible incompatibility

texts:
I have experienced a very strange behaviour of Drupal 7. I had Devel module activated, and a View which made the sql logs to disappear from screen. The view was used by views_get_view_result(). When I have changed the exact code to use views_embed_view(), with the same and exact rendering, the SQL logs started to appear again.

Is there some Drupal 7 expert (ninja level suspected) out there that can understand what could happen? The bug was consistent, it always happened in the same View config (I replicated different Views with different names and the behaviour always appeared at the same point).

The configuration that caused the problem was:

Field collection
View with field collection
Contextual filter (here it started to ignore sql log output)
Call to the function views_view_result. Even the call itself, without using the value, caused the problem.

Solution: Call views_view_embed() instead. No problem anymore. Same contextual filters, and blocks used. Exact configuration and exact output than views_view_result().

Note: I need an explanation of why this is happening, and a possible solution. The output of the SQL logging is not sent to the HTML source output of the page.

Code used. The commented lines do not work, and are substituted by the non-commented lines above them. The function is supossed to return an integer.

 function sacar_numero_productos($id_categorias, $marca){
     $marca = str_replace("/", "", $marca);
     $a = views_embed_view("numero_productos", "block_1", $id_categorias, $marca);
    // LINE BELOW DOES WORK BUT DESTROYS THE OUPUT OF SQL QUERIES
    //$a = views_get_view_result("numero_productos", "block_1", $id_categorias, $marca);

return (int)(trim(strip_tags($a)));

   // IF I USE views_get_view_result, this is the return value instead.
   /*if(isset($a[0]->field_data_field_id_unico_oem_field_id_unico_oem_value) && (int)$a[0]->field_data_field_id_unico_oem_field_id_unico_oem_value > 0){
       return (int)$a[0]->field_data_field_id_unico_oem_field_id_unico_oem_value;
    } // if*/
    return 0;
} // function


texts: What module or views recipe can display a featured node with different layouts from the rest?

texts:
I'm building out a views layout where I need to display a featured node with a different layout from the rest of the nodes being displayed. It looks something like this:

As you can see the middle node is larger than the rest and has body content displayed. What methods are there to output a custom views layout like this?


texts: Commerce / Rules - commerce-order:mail is empty for anonymous users

texts:
I'm having trouble sending order notification emails to anonymous users. As a bare-bones test I have created a new rule which triggers on 'Completing the checkout process', checks if the current user is authenticated, and if not sends an email to [commerce-order:mail]. When it's triggered I get the following error message, suggesting it is not able to get the email address from the order.

Error sending e-mail (from admin@ourwebsite.com to ).

I'm fairly sure the problem isn't to do with Rules config as it's so simple, but here is the export anyway:

{ "rules_anonymous_order_notification" : {
"LABEL" : "Anonymous Order Notification",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "Commerce Checkout" ],
"REQUIRES" : [ "rules", "commerce_checkout" ],
"ON" : { "commerce_checkout_complete" : [] },
"IF" : [
  { "NOT user_has_role" : {
      "account" : [ "site:current-user" ],
      "roles" : { "value" : { "2" : "2" } }
    }
  }
],
"DO" : [
  { "mail" : {
      "to" : [ "commerce-order:mail" ],
      "subject" : "Order received!",
      "message" : "This is to tell you the order has been received.",
      "language" : [ "commerce-order:state" ]
    }
  }
]

}
}

What else could be causing this?

EDIT: I've just noticed in the db the mail column is empty for anonymous orders in 'commerce_order' - is this normal?


texts: How to create and login external users authenticated against a third-party Oauth2 server?

texts:
I'm working on an SSO implementation where I have to give access to a Drupal 7 site to external users authorized/authenticated by Oauth2. I'm struggling with the process of taking the supplied user information from the Oauth2 server and creating a drupal user from that.

As I understand the application flow

Using an authorization grant flow, users are redirected to external oauth2 server for authentication, server responds with authorization code and scope
Drupal 7 site takes authorization code and forms post for authorization token.
Auth token is used to get user info.
User info is processed from JSON, formatted to array, and then fed into user_external_login_register, success!

Looking at the documentation the user_external_login_register page it looks like the user object needs to be provided a password. What should that be since in an Oauth2 scenario the D7 client site shouldn't have access to the user's password?

It also looks like the two examples assume that some of the credentials are being supplied and processed by the user login form. In my case all of the credentials are being supplied by an API and no drupal form is being submitted. How do I shape this to my use needs? Or, do I need to create a second form that gets submitted programmatically?

Finally, the native user base has many required fields to register and required admin approval on registration. I don't need that info for the external users, and the users don't need to be approved, they should just get logged in.

In theory, there are two general login flows. The first is a self-initiated authentication against the Oauth2 server; the second the user is redirected and authenticated from the partner organization site. Either way, my logic begins when the auth code get provided to the site.


texts: Link product variations to its own pages (e.g. blue hat to blue hat variation, etc.)

texts:
I have a product display of two t-shirts variations, one is blue color and one is black. I also use it in Views Slideshow, to show it in front page.

The problem is that both variations link to the default one only. If default product display t-shirt is black, but also has a variation of blue, when clicked on blue t-shirt in homepage, it redirects you to the black version. How do I make it link all variations to it's own versions/pages? Is this even possible? Because when filtering variations on product display node, the page path is same and doesn't change.


texts: Changing block content based on user input

texts:
I need to change the content of a block on the landing page based on user input.
Basically, I have a few links and a search form; if the user clicks on a link, I want the block to display some text, based on which link was clicked, and if the user uses the search form then to display information from an external database.

Edit
I left this site for a while & now am coming back to it.
I thought about it and if it's too hard to do in a module, then I could just make different pages for the texts & link them. And displaying data from the database is trivial.


texts:
I'm currently busy with a website for a costumer. This website has to be W3C validated. There was a problem on the search page of the site with a double ID:

  Enter your keywords:

  <input type="text" maxlength="255" name="keys" id="edit-keys" size="40" value="" class="form-text" />

The ID: id="edit-keys-wrapper" comes up two times! This is not W3C allowed.

I've downloaded and installed a clean Drupal 6.28 to be sure it's not a theme error.

Is there a patch for this "problem"? If not, what is the best option to fix this without ruining core?


texts: Putting additional functionality for Commerce Files/License

texts:
I am making a files selling website with Drupal 7.41. Using the Commerce Files / Commerce License Modules, I have been able to setup the after payment completes, allow file download functionality.

However the files that becomes available to download is just the raw file.
I want the file, which becomes available for download to be a zip/tar file which consists the

File sold
A simple readme.txt
A pdf file consisting license information, made for that particular user transaction. Like Envato!

Is this automation possible?
Can anybody please guide me on how I may be able to achieve this? Even pointing out the path would be helpful!


texts:
I need to set a value for a date field with type datetime in hook_form_alter. I tried with below codes. But it is not working.

$form["field_event_date"]["und"][0]['#default_value']['value'] = $new_date;
$form_state['values']['field_event_date']['und'][0]['value']['date'] = $new_date;
$form['field_event_date'][LANGUAGE_NONE][0]['#default_value']['value'] = $new_date;

This $new_date will be a value from another field in this form and it should be in '2014-09-23 00:00:00' format. And 'field_event_date' will be a hidden field.

I can save the value to this field using the node_presave function. Please see the below code. If anyone trying to save a value to a date field with a static value, you can use this method.

function MY_MODULE_node_presave($node) {
     $node->field_event_date['und'][0]['value'] =  '2014-09-23 00:00:00';
}

But in my case, I need to get the value from a field that defined in the form alter. And need to set this value to the field_event_date. Can anyone help me on this? Is there any way to get a custom field value in node_presave function?


texts: Drupal_add_css drupal_add_js not working dynamically

texts:
I am working on a drupal-7 project that have many CSS/JS files that need to be added dynamically.
This is the code which i am using in mymodule_init()

function doLookup($baseRootDir)
    {
    if (variable_get('xmldata')) {
        $xmldata = variable_get('xmldata');
    } else {
        $xmldata = '';
    }
    $rootDir = realpath($baseRootDir . DIRECTORY_SEPARATOR . $xmldata);
    $di = new RecursiveDirectoryIterator($rootDir);
    foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
        $fileInfo = new SplFileInfo($filename);
        if (strtolower($fileInfo->getExtension()) == "css") {
            // Include this CSS file in drupal
            drupal_add_css($cssFileName, array('type' => "file", 'group' => CSS_DEFAULT, 'every_page' => TRUE));
        } elseif (strtolower($fileInfo->getExtension()) == "js") {
            // Include this JS file in drupal
        }
    }
}

I am calling this function in hook_init() which doesn't seem to be working. I have tried clearing drupal cache as well.
Please help me out i need to complete this asap :(


texts:
When I go and export my rule, I get the following:

{ "rules_vote_points" : {
    "LABEL" : "Vote points",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "userpoints_rules", "voting_rules" ],
    "ON" : [ "voting_rules_insert_node" ],
    "DO" : [
      { "userpoints_action_grant_points" : {
          "user" : [ "node:author" ],
          "points" : "3",
          "tid" : "0",
          "entity" : [ "node" ],
          "operation" : "Insert",
          "display" : 1,
          "moderate" : "approved"
        }
      }
    ]
  }
}

Where could I put this to import it in the site install? E.g. I am importing views with a hook_views_api hook in my module and a module.views_default.inc file that searches through the views folder and imports the views, and content types are created with hook_install in .install files in my modules. But how do I import the following?


texts: Check when the last time someone visited a specific node

texts:
I need to make sure my users are visiting a specific node. What could I accomplish this?

A counter would be nice (e.g. "viewed three times by User234 in the past week"). Would that be hard to implement?


texts: Drupal 7 hook_block_info and hook_block_view permission wise display

texts:
I have a module that has permission hook for normal access and for administrative access. I want to display two different blocks to different set of users. Say,
the "admin" will only get to view one block and a "site owner" will see the other display.

So, till now what I have done is, declared 2 hook_block_info() as,

    $blocks = array();
//Block for the Normal Site Owners
$blocks['payouts'] = array(
    'info' => t('Listing of Payouts'),
    'cache' => DRUPAL_NO_CACHE,

);
//Block for the Administrators
$blocks['commission_payments'] = array(
    .....
            .....
);

When I declare the hook_block_view() I use user_access() to restrict the user's to see it.
But is there any way I can restrict the user's to view the block infos in the region settings ? Is there any array parameter for hook_block_info that can achieve this? I suppose the 'page' parameter will only handle the page where to display the block.


texts: Displaying parse errors in module development on the browser

texts:
I am currently trying to learn Drupal Module development.

As one might guess, many errors get created in the process. But, all i can see is WSOD on the browser.

For the same errors, most of the Module development videos on youtube show display the errors on the browser itself in an easy to understand format with specific details on the parse error(attached image).

I have tried some solutions on configuring on index.php, but in vain. Also, I can see the errors on Drush, but that doesn't satiate

Could anyone please tell me on how i can have this in my environment?

I'm running Drupal 7 on Windows 8 using Bitnami WAMP Stack.


texts:
I have imagecache, imageapi and imageapigd enabled on my drupal 6 site. When I visit imagecache presets no actions (crop / resize et al) are available. This all seemed to work fne with the same configuration on my MAMP home box, however, this fails in production. Some other info:

PHP Version: 5.2.17
GD Support  enabled
GD Version  bundled (2.0.34 compatible)
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.3.11
GIF Read Support    enabled
GIF Create Support  enabled
JPG Support enabled
PNG Support enabled
WBMP Support    enabled
XBM Support enabled

I'm stumped - any help is greatly appreciated..


texts: Get Field Name Being Deleted From Configuration Updates/Delete Form

texts:
Trying to get the field_name being deleted when viewing a route like entity.field_config.user_field_delete_form.

Example path: /admin/config/people/accounts/fields/user.user.field_name/delete

Some Hooks I've tried:

hook_preprocess_html()
hook_preprocess_page()
hook_preprocess_page_title()
hook_preprocess_form_field_config_delete_form_alter()

But the best I have found is an argument [%label] => Field Label.

I have an array of field_names and want to check if the field_name being deleted matches one of the values.

The goal is to add a custom \Drupal::messenger()->addWanrning($warning);.

This would be altering an existing delete form/page.


texts: Behavior for #datepicker onselect not working

texts:
i have a datepicker in a webform. I want to be notified when a date is selected in the datepicker. In my form template i drupal_add_js a js starting with :

Drupal.behaviors.booking_form_tma = {
    attach: function (context, settings) {
        for (var id in Drupal.settings.date_popup) {
            alert('found');
            var datepicker_settings = Drupal.settings.date_popup[id].settings;
            datepicker_settings.onSelect = function(dataText) {
                alert('selected: ' + dataText);
            };
            $('#' + id).datepicker(datepicker_settings);
        }
    }
};

The behavior attach code gets called only once, after the page gets loaded and never reach the alert: i guess the datepicker is not present in the div at this time. When the datepicker icon is clicked, the datepicker gets injected in a div but the behavior is not called and so nothing happen. None of the alert in the code above are shown.

Why doesn't it work?


texts: Date Time field machine name/view mode for theming using paragraphs

texts:
I am using Drupal 8 core DateTime Range module and Date module in core to list date start and end date.

I have set various criteria and allowed content editors to set date/time under certain ranges with paragraphs module for events.

Event only has date.
Created a date field using paragraphs module.
Event has date with start and end time.
Created a date field and datetime range field with only time ranges using paragraphs module.
Event has start and end date.
Created a datetime range fields using paragraphs with date ranges using paragraphs m.
Event has start and end date with time.
Created two datetime field one with date ranges and another with time ranges using paragraphs.

Now for theming I need to target each field separately as each field represents different format and style. However while using paragraphs inside node and adding any one of datetime field to node using paragraphs does not allow me to determine which field it is or what view mode that datetime field is using.

This makes it difficult to theme those fields individually/seperately.

Also, while using views pages and rendering those datetime field on a pager based page view, same, it does not show what machine name/view mode its using for paragraphs.

I implemented hook_theme_suggestions_time_alter function to determine the machine name and view mode, but no information was available for said field.

I would like to each part of field in datetime field separately and differently while rendering using views and differently while rendering in full view mode of node.


texts:
how do I add the order date after the order ID ?

Here is the contents of my file "commerce_order--commerce_order--pdf.tpl.php" :

<?php

/**
 * @file
 * Template for invoiced orders.
 */

?>

<?php
//The code to get payment type

$order_id = $content['commerce_customer_billing']['#object']->order_id;

$payment_method = '';
$order = commerce_order_load($order_id);
$r = explode('|', $order->data['payment_method']);

if (count($r) > 1){
  $rule = rules_config_load($r[1]);
  $payment_method = $rule->label;
}
?>

    <img src="<?php print $content['invoice_logo']['#value']; ?>"/>

<?php print render($content['invoice_header']); ?>

<?php print render($content['commerce_customer_billing']); ?>

<?php print render($content['commerce_customer_shipping']); ?>

<?php print render($content['order_number']); ?>

<?php print render($content['invoice_header_date']); ?>

<?php print render($content['order_id']); ?>

<?php print render($content['invoice_header_date']); ?>

<?php print render($content['commerce_line_items']); ?>

<?php print render($content['commerce_order_total']); ?>

<?php print render($content['invoice_text']); ?>

  <?php print("Mode de règlement : " .$payment_method); ?>

<?php print render($content['invoice_footer']); ?>


texts: How do I hide the link to the RSS feed on the term page?

texts: I want to keep the feed functionality, but I want to hide the "Subscribe to [term name]" link on the term page.


texts:
I've recently had a lot of trouble, self-inflicted I will admit, with my Drupal 7 website and as a result have had to restore my database from a backup several times. In doing so, the structure of most of the tables does not seem to have restored quite correctly for some reason and I'm getting a lot of errors to say that there are no default values for fields (that are always primary keys). The solution to this has been to make the field auto increment, but is there a way to do this without looking at the structure of each table one by one.

Is there some kind of script that looks at the structure of the tables and repairs them automatically as my website is considerably large and has many tables so going through them by hand would be a lengthy process.

Thanks in advance


texts:
I have some breadcrumbs created with Path Breadcrumbs, and they used to work on an old site. I transfered them over (using the Configuration Manager module) and now they don't show and instead print out the following error:

  Warning: implode(): Invalid arguments passed in _path_breadcrumbs_build_breadcrumbs() (line 107 of /var/www/mca-marines.org/htdocs/sites/all/modules/path_breadcrumbs/path_breadcrumbs.module).

Why should have happened?

EDIT:
I just tried to create a new one, that didn't work either, so its not as if the other ones got corrupted.


texts: How can I make a condition for currently viewed language on a template file?

texts:
I have a template called page-my-view.tpl.php that overrides a view page my-view.

I have directly put the title tags, description and h1 on this template file.

However I need different texts for these tags per language to avoid duplicated tags.

I have 2 languages on my site English and Japanese.
Japanese is the default one with no prefix and English is with prefix "en".

So how can I make a condition on this template for currently viewed language?


texts: "Link this field" the Entity API problem?

texts:
I am  not sure from where the problem comes, but I am using Entity API and Views integration with Field collection module.

The option Link to entity is not working. Check the images below.

Here is a image of the entities I have created and field collections :

Anyone facing the same issue?


texts: redirect based on content type using rules

texts:
my problem is really silly and i know I must be missing something. All I want to do is redirect a user based on the type of node being viewed.

Here is what I tried with rules:
Event: content is viewed

Condition: Content is of type: my desired type

Action: Path redirect: my desired url

Problem: when i search for anything using the search form, I always get redirected to the url I specified in the Action part of the rule.

Please let me know how to get around this


texts: How do I add a custom class to a field based on another field value(boolean)?

texts:
I have a Commerce product and there are two price fields. (Original price and Sale price). I would like to display original price as line-through text when sale price is available. Therefore I would like to add a custom class to a field based on another field value(boolean), I looked at this function, hook_entity_view_alter, but I don't know whether it will be good.

Anyone has idea how do I solve this?


texts: How to build select lists for search_api views

texts:
I am building a small website for a charity and am trying to integrate search_api to search the list of projects.

I have a content type named "Project" with the following fields:

Title ( Project Name )
Body
Project Image ( Image field )
Project Countries ( Multi valued taxonomy of all Countries this project operates in )

I need to build a search page that has:

A free text search box that will search Title/Body as a fulltext search
A select list or autocomplete field that allows you to select the country you are searching

So far I have:

Created a new solr search server using search_api
Indexed the Project content type in a new search index
Added all taxonomy values and fields to the search index ( in the hope one would work )
Created a view linked to this index
Added all of the above taxonomy fields as exposed group search filters but none of them pick up the values of the taxonomy.

I can happily freetext search on the indexed fields but if I want to use dropdown filters or even checkboxes to filter the results it just doesn't work.

Clearly I am doing something wrong here, what is the best way to achieve what I am trying to do?


texts: How can I rearrange a menu link programmatically?

texts:
I created Menu Link Content entities and saved them in a menu.

$menu_link = MenuLinkContent::create([
  'title' => 'Menu item',
  'bundle' => 'menu_link_content',
  'link' => [['uri' => 'internal:/']],
  'menu_name' => 'testing',
])->save();

$menu_link_2 = MenuLinkContent::create([
  'title' => 'Menu item',
  'bundle' => 'menu_link_content',
  'link' => [['uri' => 'internal:/']],
  'menu_name' => 'testing',
])->save();

How can I rearrange $menu_link_2 to be a child of $menu_link?

Looking at menu_ui, they seem to update Menu Link Content in a given order, and then rebuild the menu tree; finally, the Menu entity is saved.

$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
$menu_link_manager->updateDefinition($menu_link_2->getPluginId(), [
  'parent' => $menu_link->getPluginId(),
]);

How can I rebuild the menu tree and save the menu?

Why? I'm writing a Kernel test for a module that fires when the menu link content has been saved AND then when the Menu itself has been saved.


texts:
I've been receiving the following error message when trying to do a drush config-export command.
However, I am able to successfully do the configuration export from the Drupal admin page (admin/config/development/configuration/full/export).

TypeError: Argument 2 passed to [error] Drupal\Core\Config\FileStorage::write() must be of the type array, boolean given, called in /vendor/drush/drush/commands/core/config.drush.inc on line 519 in Drupal\Core\Config\FileStorage->write() (line 140 of /web/core/lib/Drupal/Core/Config/FileStorage.php)
#0
/vendor/drush/drush/commands/core/config.drush.inc(519): Drupal\Core\Config\FileStorage->write('field.field.nod...', false)
#1
/vendor/drush/drush/commands/core/config.drush.inc(448): _drush_config_export('sync', '../data/sync', false)
#2
/vendor/drush/drush/includes/command.inc(422): drush_config_export()
#3
/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#4
/vendor/drush/drush/includes/command.inc(199): drush_command()
#5
/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#6
/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot-bootstrap_and_dispatch()
#7 /Users/Bcorrigan/sites/flowrite8/vendor/drush/drush/drush.php(12):
drush_main()
#8
{main}.

The only reference I can find to something similar is here: https://www.drupal.org/node/2830047

But I did not have that module installed when I started getting the error. It's installed now, but still getting the error and will probably remove it soon.

I started receiving the error yesterday, reverting to previous version of Git have made no difference in receiving the error.

Anyone else run into this? Know how to fix? Thanks for any help you can provide.


texts: Best practice for using location names as part of taxonomy?

texts:
I'm setting up my taxonomy vocabularies for describing my node content. Most of it's fairly straight-forward, but I'm stuck on how to describe the location data for my nodes.

I have a small hierarchy of place names for a limited geographic region that my site covers. Should I continue to use taxonomy to create a vocabulary, or should I be using the location module? I will be having location-specific content in the node, such as a Google Map to show the location of venues etc. Can location module content be tied up to a taxonomy vocabulary?


texts:
I'm trying to setup a development environment for Drupal using docker.

I've already succeeded on creating a PostgreSQL container and a Drupal container using official images for both, and I can replicate the production environment.

How do I get drush to detect my Drupal install?

I've tried both https://hub.docker.com/r/drush/drush/ and https://github.com/DockerDemos/appstack-drush (had to build that last one) but when I run drush inside the containers they don't see the Drupal install.

I run "docker run --volumes-from <my-drupal-container> --link <my-db-container>:postgres -it drush/drush dd" and it shows nothing, "drush cc" finds no caches.


texts: Including a large amount of raw data with a module

texts:
I have a module that demonstrates how to use another module (a graphing library). One of my controllers uses a large dataset to generate one of the example graphs. I currently have this data assigned to a variable in the controller. However, this takes up a large amount of space in the file. If I want to meet Drupal code style guidelines, I would have to break up the array after every [x,y] pair, making it even more difficult to review.

Should I move this data into some sort of include file, and read the text file into my controller? What's the "Drupal Way"?


texts:
My content type has a field call tracking code, I have granted permission for users are able to create content. When they create content, they cannot see tracking code field but after they submit the content, they will see a tracking code string in message area.

In that node I also have reference field with other content type, so the string that I expect to show must include the id of reference node and id of the node being created.

EX: P1C2 (1 is id of reference node, 2 is id of node being created)

Does drupal have any modules support to do that or I must do it programmatically and how can I build the coding for that? Thank you all!


texts: Trying to get fullPage.js implemented, but how to add data-attributes?

texts:
This is such a great script called fullPage.js

I managed to load the js file and css file and even with the Void Menu Module, managed to call anchor links, but I'm struggling with the data attributes part of the implementation of this cool code!  Any help is greatly appreciated!  How do I get data-attributes to work in Drupal 7.25?  I mean, I need to add them to the menu, so that the html looks something like this:

First slide

Second slide

Third slide

Fourth slide

Just want to add it to the Main Menu in Drupal.  Any idea how?  Am trying to implement this on my homepage and using the Adaptive Sub-Theme with Display Suite Module installed, if that helps any.

Have added the following to template.php, but it makes no difference at all:

function MY_THEME_NAME_menu_link(&$variables) {
  $variables['element']['#attributes']['data-menuanchor'] = substr($variables['element']['href'], 1);
  return theme_menu_link($variables);
}

What am I doing wrong here?


texts: AJAX calls fail when the base URL is set

texts:
I have installed the Drupal 7.17 security update, and I am having some issues with my site.

If I comment out the $base_url ='www.xxx.com'; line in the setting.php file, the AJAX calls work; when I uncomment that line, the AJAX calls fail.

What could be the reason behind this? how can I get my base_url working again?


texts: How do I use '#attached' to attach a style sheet?

texts:
I know that drupal_add_css is depreciated, and that we should use #attached instead to attach a css style sheet to a module.

I am trying to replace the following (which works):

drupal_add_css(drupal_get_path('module', 'mymodule') .'/mymodule.css');

with #attached.  But haven't found exactly where and how to add it.

Here is my second attempt (it still does not work):

/**
 * Implementation of hook_block_view()
 */
function mymodule_block_view($delta = '') {
  if ('mymodule' == $delta) {
    $render = array();
    $list = mymodule_fetch_from_info();
    foreach ($list as $element) {
      $render[] = array(
        '#type' => 'markup',
        '#markup' => $element[0],
        '#weight' => $element[1],
      );
    }
    $blocks['subject'] = t('Mymodule');
    $blocks['content'] = $render;
    $blocks['#attached'] = array (
      'css' => array(
        drupal_get_path('module', 'mymodule') . '/mymodule.css',
       ),
    );
    return $blocks;
  }
}


texts:
I have 3 different roles: Patient, Operator, Nurse. I have one registration form for all my users with basic information (applied via 'Account Settings'). I've been messing around with Profile2 to give each of roles a unique profile.

My problem is that I can't seem to stop Patients from having an Operator Profile and Nurses from having a Patient Profile. Is there a way for me to make the profiles unique to the roles?

I've also considered doing it exclusively in 'Account Settings' and restricting fields using Field Permissions?

I would like to do this so that alternations to the profiles is quick and easy to do.


texts: How do I execute functions on a custom module?

texts: I am writing my first custom module and would like to test its functionality, but am not certain how to call functions to run them from within Drupal.  The module is installed.


texts: How to output content use my custom way?

texts:
For example, I have two site (A & B), A is built by drupal. On site B, I wanna display a list of news from site A. I choose to add such code to B's page

and in this script will use document.write to output content's on Site A

So how can I change A site's output, such as

...

to js output style

document.write('
');
document.write('
...');
document.write('
');


texts: Tracking User's Location at a certain point

texts:
I've installed the Time Tracker module.

I need to track user's location when the user clicks on "Start Timer" AND when the user clicks "Stop Timer". Please help or point me in the right direction. I tried to use rules but I didn't know where to begin.


texts:
Although there are many answers for earlier versions of Drupal 8, I could not find a way to remove 'Submitted by' information displayed with Articles.

How can one achieve this with Drupal 8?


texts: How to select all the field in content type

texts:
How to select all the fields created in custom content type using select query.

$query = new EntityFieldQuery();
$result = $query->entityCondition('entity_type', 'node', '=') // select nodes
 ->propertyCondition('type', 'testimonials', '=') //type testimonials
 ->propertyOrderBy('created', 'desc') //most recent first
 ->range(0,2) // limit
 ->execute();
$testimonials = node_load_multiple(array_keys($result['node']));


texts: dynamically fill a field with the value of a field in another node referenced with an entity reference field

texts:
Referencing entities is a great capability of Drupal but gives me headaches.

I have three content types: Client, Contact and Job ticket.

Clients are companies with whom I conduct business. Contacts are contact persons within these companies. The Contact content type has a reference field referencing their company's node. Job tickets are tickets for jobs these companies hire me to do for them. In this content type I have two reference fields: one for the Client and one for the Contact.

This is my problem: In the Job Ticket I have a select list field that needs to be populated with the address (or addresses, since there can be multiple values for the Address field in the Client content type) of the client when I select the client in the reference field select list. How can I do this automatically.

I tried the Field Reference module but I can't get it to work, and it would give me ALL the addresses from ALL the client nodes. I only need the one(s) from the previously selected client.

Thanks in advance.


texts: How can I add a (very) simple "Insert dialog" link?

texts:
I'm currently developing a social networking website and need a clean and simple editor for user content creation. I've choosen CKEditor (https://www.drupal.org/project/ckeditor) as it is integrated in Drupal 8 and seems reliable. I know that one can also integrate it with Wysiwyg module, but I don't see any advantage in this approach and 1 module is better than 2 IMHO.

The problem is that all plugins offering "insert link" functionality that I have tested (original one, Linkit) are anything but simple. I understand that in many cases this rich functionality is good, but not in my case.

What I want to achieve is super-simple button like we have here on Stackexchange. Just link, it's title and nothing more. I tried to integrate http://ckeditor.com/addon/SimpleLink plugin but it doesn't work with my version of CKEditor.

Are there ways to simplify existing widgets?


texts: How do I convert special characters into html in twig

texts:
I have some list items in drupal 8 which created by item_list template.I am sending some  tagged data to the item_list template. My idea was to get the output as This is new page.

But it returns the output as
&lt;a href="/this-is-new.html"&gt;This is new page&lt;/a&gt;
.

I need to print this in a twig template. But with the output I had it renders as a string in the template not as a html anchor tag. I needed to view a link to another page in template. But all I am getting is a string with the This is new page. What should I do?