texts: Setting default image style to 'original image' in formatter

texts:
In a custom formatter that I'm writing, I have a problem with default_value for an image style.

function MYMODULE_field_formatter_info() {
  return array(
    'MYMODULE_formatter' => array(
      'label' => t('My Custom Formatter'),
      'field types' => array('image'),
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
      'settings' => array(
        'trigger_image_style' => '',
      )
    ),
  );
}

function MYMODULE_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state){
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];

  $element = array();

  $image_styles = image_style_options(FALSE);
  $element['trigger_image_style'] =  array(
    '#type' => 'select',
    '#title' => t('Trigger image style:'),
    '#description' => t('Image style to be used for trigger'),
    '#default_value' => $settings['trigger_image_style'],
    '#options' => $image_styles,
  );

  return $element;
}

function MYMODULE_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $elements = array();
  $html = "";
  $settings = $display['settings'];

  // ensure deaults?
  if (!isset($settings['trigger_image_style'])) $settings['trigger_image_style'] = '';
  //.....
}

Seems that Drupal will return incorrect path:

image_style_url($settings['trigger_image_style'], $item['uri']);

until I explicitly set a style of my choice. The incorrect path will have double slash, as in:

http://example.com/sites/default/files/styles//public/trigger-images/test1.jpg

I thought that empty string simply means 'use original image'... How should I tell Drupal to use original image if the style is not set or is an empty string?


texts: How can I setup automatic subpages for existing pages using a view with a contextual filter that uses the URL to determine the filter value?

texts:
I have two content types that are being linked via entity references.

Area of Expertise [Existing URL: /expertise/specific-area-here]
Employee [Desired URL: /expertise/specific-area-here/staff/specific-employee-here]

Employee has an entity reference field that contains all of the areas of expertise and only one value is allowed to be selected.
For example:
I have an area of expertise called "Pathology" and an employee named "John Doe". In John Doe, I select that the area of expertise is "Pathology".
When I'm on the area of expertise page for a particular area of expertise, I am showing all of the employees that specialize in that area of expertise in the sidebar second region. To do that I'm using a view that generates a block. Within the view I have a contextual filter using the following chunk of PHP code to provide the default filter value:
$filterValue = -1;

$node = menu_get_object();

if(!empty($node))
{
    switch($node->type)
    {
        case 'area_of_expertise':
            $filterValue = $node->nid;
            break;
    }
}

return $filterValue;

All of that is working properly.
What I want to do now is have a staff page that shows all of the staff associated with a particular area of expertise. I want the URL to be /expertise/specific-area-here/staff.
For example, if I want to see all of the staff that are associated with the area of expertise called "Pathology" (located at /expertise/pathology) then I would want the staff page to be available at /expertise/pathology/staff.
The issue I'm having is figuring out how to set up the contextual filter such that the "/expertise/pathology" piece of the URL of /expertise/pathology/staff can be processed so that Drupal knows which area of expertise to use to filter.
Also, the breadcrumbs should work as follows:
If I'm on the Pathology area of expertise page, the breadcrumbs should show:
Home > Pathology

If I'm on the Pathology staff page, the breadcrumbs should show:
Home > Pathology > Staff

If I've drilled down into John Doe's page, the breadcrumbs should show:
Home > Pathology > Staff > John Doe

How should I setup the contextual filter to allow this behavior and how should I configure the "Path" under "Page Settings" in the view?


texts: Only the first day is highlighted in Calendar, even if Event lasts for more than one day?

texts:
I am using Pretty Calendar module for the mini Calendar on my website. The problem is, it highlights only the first date of the event even if the event lasts for more than a day. For example, if you click on 5th May, you can see that it's a two days event and will finish on 6th May, but in the calendar, it highlights only 5th May.

Is there any way to solve this problem?

Thanks.


texts:
I want to render as HTML not string on Twig. I have a variable that hold form HTML but after putting on Twig template it's render as string like given below:

1) Set loginpopup variable in preprocess hook.

function MYTHEMENAME_preprocess_page(&$variables) {
    $variables['loginpopup'] = array(
   '#plain_text' => "

".drupal_render($form)."

"
    );
   }

2) Render on Twig template file as :

 {{ loginpopup }}

But it's visible as string (i.e. double-escaped).. What's the problem and how do I fix it?


texts: Drupal 7 Form AJAX button to return javascript script

texts:
I am trying to create a form that allows a user to type in an address and click submit. In return the button makes an AJAX callback that builds the javascript link for a user to copy and paste into their site. Once a user inserts the javascript into their site it will display a map from my site. The problem I am having is when the user creates their custom map using my form I want to return a sample map of what it should look like. I need this javascript to be printed to the browser.

But when it is returned nothing is displayed. Here is my form & callback function.

function d3vo_widget_builder_form($form, &$form_state) {
    $form['city'] = array(
      '#title' =>   t('City'),
      '#type' =>    'textfield',
      '#required' => TRUE,
      '#description' => t('Find your city'),
    );

    $form['height'] = array(
      '#title' =>   t('Widget Height'),
      '#type' =>    'textfield',
      '#size' => 5,
      '#description' => t('Set the widget height'),
      '#element_validate' => array('_validate_field_is_numeric'),
    );

    $form['map-area'] = array(
      '#type' => 'markup',
      '#prefix' => '
',
      '#suffix' => '
',
      );

    $form['submit'] = array(
      '#type' =>    'button',
      '#value' =>   'Get Widget',
      '#ajax' => array(
        'callback' => 'd3vo_widget_map_ajax_callback',
        'wrapper' => 'mapsample-div',
        'method' => 'html',
        'effect' => 'fade',
        //'progress' => array('type' => 'none'),
    ),
    );

    return $form;

function d3vo_widget_map_ajax_callback($form, $form_state){
       $point = geocoder('google',$form_state['values']['city']);
       $lng = $point->coords[0];
       $lat = $point->coords[1];
       if($form_state['values']['height'] == NULL){
           $height = 500;
       } else {
       $height = $form_state['values']['height'];
       }
       $widgetScript = '';

        $form['script'] = array(
         '#value' => $widgetScript,
         '#type' => 'textfield',
         '#attributes' => array('readonly' => 'readonly'),
         );

        $form['map'] = array(
          '#type' => 'markup',
          '#markup' => $widgetScript,
        );

        return array($form['script'], $form['map']);
    }

Im not very familiar with using Javascript in Drupal. I have searched and tried many different ways but I can not get the map area to show. Any help would be greatly appreciated.


texts: Autoincrement class for field collection items in template

texts:
I have a field collection, which contains another field collection and a field.

Right now I'm using a .tpl file to theme this collection and I'm wrapping content inside a div.

I want every item to have an auto-increment ID. For example: row-1, row-2, row-3 etc.

I've tried for, foreach and the serial module and nothing works.

How can I achieve this?

Thanks.


texts:
I have a boolean for the status of a page on whether it is new or not. If it's selected, I want the following code to take effect.

{% if fields.field_new.content %}
  <div class="info--details__new">
    {{ fields.field_new.content }}
  </div>
{% endif %}

This works fine for when it's selected. However, if I unselect it, it still displays the div with the info--details__new class only empty.

I'd like for this div to not be displayed when this boolean isn't selected but can't seem to figure out how to do this in my twig template.

What's the best way to go about doing this so that my empty div doesn't show up when the boolean is unselected?

This is in my views-view-fields--VIEW-NAME.html.twig file.


texts: How we can define constant in template.php for our theme

texts:
I want to define some constant for my theme like theme path etc. How i can achieve that.

For module we can define like this

define(THEME_PATH, drupal_get_path('theme', 'xyz'));

But it is undefined in theme. Any suggestion would be appreciated.


texts: How to access a node's menu link title in Views?

texts:
I'm surprised to not be able to find anything about this seemingly simple or routine request.

Suppose I have nodes that have long titles. They have menu items created the usual way, with short form titles.

I want to make a view of nodes that uses the menu item title of the nodes instead of the full title. However:

There are no fields I can see that relate to the menu item,
I can't see any available relationships that would access the menu item and make it available.

As a workaround I'm creating a custom field "subtitle" specifically for the views titles, but it's a bad workaround. Is there no way for Views to see the menu item of a node?


texts: Fatal error: Allowed Memory Size of (X Size) when running drush migrate-upgrade

texts:
I'm trying to use drupal migration module with drush to migrate a database. I'm getting this error below.
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /Applications/XAMPP/xamppfiles/htdocs/drupal-eight-iom/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php on line 76

I have already tried editing the memory_limit on php.ini file

memory_limit=5024MB

Not sure what else I need to do in order to make it work. I'm using Drupal 8.4.4

$databases['default']['default'] = array (
  'database' => 'drupal-eight-iom',
  'username' => 'root',
  'password' => '',
  'prefix' => '',
  'host' => '127.0.0.1',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);

$databases['upgrade']['default'] = array (
    'database' => 'drupal-seven-iom',
    'username' => 'root',
    'password' => '',
    'prefix' => '',
    'host' => '127.0.0.1',
    'port' => '3306',
    'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
    'driver' => 'mysql',
  );

$settings['install_profile'] = 'standard';
$config_directories['staging'] = 'sites/default/config';
$config_directories['sync'] = 'sites/default/files/config_zB_DnNUK68i5Owp5a8FzTiClQfp3d3jrwcy0_HuS1hNCGv9Y_Iva2Ahm8LCH-P0j0M2jwmQAsA/sync';


texts: How to redirect user "back two pages" after login

texts:
My users are only able to log in on the mysite.com/user page (I don't use any of the login blocks). How can I redirect those users to their location "two pages ago"? For example, they might visit the about us page, then click login (taking them to the /user page). After they complete their login, I would like for them to be redirected back to the about us page.

I currently have it set to redirect to the previous page after login, but that will always be the "user" page, which is not particularly useful in this instance.

Thanks!


texts: How to find out what views page you're looking at

texts:
I have the $is_portfolio variable in my "template.php" file that lets me easily check what content type is being displayed, so I can do freaky and awesome stuff with it:

function mycooltheme_preprocess(&$variables, $hook) {
  if ($hook == 'page' ) {
    if ($variables['node']->type == 'portfolio') {
      $variables['is_portfolio'] = TRUE;
    }
    else {
      $variables['is_portfolio'] = FALSE;
    }
  }
}

In my "page.tpl.php" file, I use it through a conditional which lets me change the markup depending on the content type:

<?php if ($is_portfolio) : ?>
  // Use this layout
<?php elseif (!$is_portfolio) : ?>
  // Boo, use this layout instead :-(
<?php endif; ?>

How can my code in "template.php" be customized so it can also check which Views page is being displayed, so I can target those as well?


texts: How to implement template_preprocess_page and template_preprocess_taxonomy_term?

texts:
I am trying to implement
template_preprocess_page and template_preprocess_taxonomy_term.

I implement them in my template.php file after having replaced template by my theme name, but the functions are not called. What am I doing wrong?


texts:
I created a module which creates a content type called equipment. Which includes multiple fields and a field collection. But now I want to style the template with those fields. As suggested from the HTML comments thanks to the Twig debugging, I created a file called node--equipment.html.twig which is located inside the templates folder of the module. Unfortunately this template won't show up, so it shows the default template.

Doesn't Drupal 8 recognize the Twig file? What is the reason for not showing the wanted template? How can I fix this?


texts:
I am currently building an intranet site with drupal 7. It is hosted on a Windows 2012 Server R2 with IIS and I am using MSSQL 2012 as a database system. Moreover I have integrated the intranet site with Active Directory 2012 R2 and I can login with my ldap credentials.

Now I am trying to manage the following: I want a user to be already logged in to the intranet portal when he opens his web browser and not asking for his credentials again. For that reason I installed ldap_sso module. When I try to open the browser, I get a 500 error as the system tries to insert a NULL value to uid in the sessions table and this is not permitted.

Any ideas?


texts: I want to get total revenue from a productId on Drupal commerce. How can I do that? I found in drupal commerce's table but didn't see any relationship to get that info.


texts: Drupal Commerce order completes but reverts from pending to billing

texts:
We are having issues where a Commerce Order will complete checkout, but once marked Paid in Full and set as Pending, it bounces back to Billing and Shipping (Shipping checkout page, name changed.)

Edit: We are using Authorize.net, no IPN.

Our checkout settings:

Checkout

Shopping cart contents
Coupons
Account Information

Billing and Shipping (default Shipping page, name changed)

Billing information
Shipping information
Shipping Service

Billing (empty, moved into previous page)
Review and Payment

Review
Payment


texts: Retriving nodes by content type using Drupal::entityQuery

texts:
I created a content type named product. How can I retrive all node of such content type using the entityQuery method?

I tried with this, but it doesn't works:

$ids = \Drupal::entityQuery('product')
  ->execute();

$products = \Drupal::entityManager()
  ->getStorage('node')
  ->loadMultiple($ids);


texts: Change the the title on the `?q=user` page

texts:
I want to change the the title on the ?q=user page to something generic e.g. "My Home", and not user name.

So far, I have tried using the string override module with little success. Is it possible to do this with a custom module that I can just drop into the page with some PHP code? If not, how can it be done?


texts: I have a view, and i filter the nodes based on a list of tags. If one node has more than one matching tag, it's displayed more than once. Can you filter those out? Want to display them only once...


texts: How do I get settings in admin/config/people/accounts/fields and admin/config/people/accounts/display into a Feature

texts: How I would get admin/config/people/accounts/fields and admin/config/people/accounts/display into a Feature. I have been looking everywhere...


texts: EntityFieldQuery for getting the count of a user blog. Blog is a content type.


texts: Load menu items from one menu in other menu

texts:
I want to load the menu items from the main menu in a other menu. I've read a dozen examples but I can't get it to render the items at all.

Here's my code from my_theme.theme

function my_theme_menu__secondary(&$menu, &$menu_name, &$suggestions) {
  $menu_name = 'main';
  $menu_tree = \Drupal::menuTree();
  $parameters = new \Drupal\Core\Menu\MenuTreeParameters();
  $parameters->onlyEnabledLinks();
//  $parameters->setMinDepth(2)();
//  $parameters->setMaxDepth(2)();

  $tree = $menu_tree->load($menu_name, $parameters);
  $manipulators = array(
    array('callable' => 'menu.default_tree_manipulators:checkAccess'),
    array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
  );

  $tree = $menu_tree->transform($tree, $manipulators);

  $list = [];

  foreach ($tree as $item) {
    $title = $item->link->getTitle();
    $url = $item->link->getUrlObject();
    $list[] = Drupal\Core\Link::fromTextAndUrl($title, $url);
  }

  return $list;
}

Heres my menu--secondary.html.twig

{% import _self as menus %}

{{ menus.menu_links(items, attributes, 0) }}

{% macro menu_links(items, attributes, menu_level) %}
  {% import _self as menus %}
  {% if list %}
    {% for item in list %}
      {%
        set item_classes = [
          'expanded',
          'dropdown',
          item.in_active_trail ? 'active',
        ]
      %}
      {% if menu_level == 0  %}

        {{ item.title }}

      {% endif %}
    {% endfor %}
  {% endif %}
{% endmacro %}

Any help is appreciated :)


texts:
What are all those junk CSS files in site/files/css with names like css_ZFCUUB6IIfaVQ-erWDr0M0Na1JbxEsU-8zjQrWAtrbU.css? There are hundreds of them.

How do these get generated over time? What do they do?


texts:
I am trying to read a field collection and build an array in PHP.

The array I want to build goes like this:(it's in JS notation but you can easily imagine the equivalent in PHP)

highlights = [
{highlightTitle:A sample test title,
 highlightImage: a sample img url,
 highlightBody: a sample text body},
{highlightTitle:A sample test title,
 highlightImage: a sample img url,
 highlightBody: a sample text body}
]

As you can see it is just an array with objects inside, where each object represents a field collection entry. That field collection entry has 3 fields obviously, highlightTitle,highlightImage & highlightBody.

Now I want to read that field collection and build the array I described above.

  The thing I care about is best practises. What is the best possible
  way to do this?

Currently I use the following code dumped in <?php ?> brackets on the top of my layout's tpl files:
(I use Omega 4, and I have different layouts for different content types)

This is the code I use now:

  $highlightsArr; //this is the result array
  $highlightsCounter = 0;
  $highlights = field_get_items('node', $node, 'field_highlights');

  foreach ($highlights as $item) {

    $fc = field_collection_field_get_entity($item);
    $highlightSnippet = $fc->field_highlight_snippet["und"][0]["value"];

    $arr = $fc->field_highlight_snippet["und"][$i]["value"];
    $innerArray = entity_load('field_collection_item', array($arr));

    $innerCounter = 0;
    foreach ($innerArray as $item) {

      $highlightsArr[$innerCounter]["sectionItemTitle"] = $item->field_highlights_title["und"][0]["value"];
      $highlightsArr[$innerCounter]["highlightsImage"] = file_create_url($item->field_highlights_image["und"][0]["uri"]);
      $highlightsArr[$innerCounter]["sectionItemPrice"] = $item->field_highlights_body["und"][0]["value"];

      $innerCounter++;
    }
  }

The issue with the above code:

The code above returns undefined variables/indexes on things that are obviously defined. When I first create a content type and want to view it's node, it returns errors. But as soon as I refresh the page the errors go away which seems rather strange to me.

In any case I would like to know best practises for doing this kind of stuff.
Unfortunately I come from a strictly JS background (I'm a front-end dev), so Drupal and PHP is something new for me.

Many thanks in advance.


texts:
I am thinking of the best approach for a small website selling only two products - two sets of coin printings - one gold, and one silver. There are only 100 products of each set made, all gold are the same price, all silver too.

I need to create a system of 10 x 10 table (100 items) containing numbers, each one cell can be clicked and "reserved" (by ordering) - then administrator will ship the product and mark the cell as "sold", so each number can be bought only one time.

Now I was thinking of several methods to achieve this:

Using Drupal Commerce, which is quite robust for only two products.
And I do not really want to have 200 same products on site differing
only by ID and cell number.  Maybe having only two products, adding
some kind of field in this product with data of which numbers were
already sold and then providing this field in product display would
do the trick.
Using Webform, products can be nodes, there is no need
for checkout, webform components should contain things like shipping
and billing information and product nodes can have the same field
with table as specified upper. Order mails can also be provided by
webform.
Some other already made system for things like this, I was
thinking about booking systems, but most of them are locked on dates
I guess.
Other ideas?

Also the only payment method will be paying directly to bank account, nothing else. Back account creditials will be mailed to customer, they only need to contain order number or something because if all the orders are mostly the same amount, it would be hard to recognize which payment belongs to which order.
Shipping method will again be only one, customer only need to be informed.

Thanks in advance.


texts: Problem with mobile_theme theme switcher module

texts:
I've tried using mobile_theme to switch to a selected mobile theme when a mobile visitor browses. But using online mobile emulators: mobilephoneemulator.com and transmog.net I found that half of pages get shown as Desktop version pages.

I thought of using ThemeKey but I'll need to use  browser version, operating system to serve mobile content. But it could fail for Googlebot, Bingbot etc, they also need to see my mobile pages.

Is there any alternative auto theme switcher for mobile? I'm on shared hosting and can't use Browscap etc php modules.


texts: Downloading a feed's embedded images to server and rewriting paths in html automatically

texts:
I'm scraping a some sites into a csv which is then used by feeds importer module to create Drupal content.

Some of the content are html chunks containing html+images in them which go into "body"/textarea kind of fields to be displayed.

How do I use feeds tamper or some other method to

Download these embedded images to server and
Rewrite the image paths in the HTML chunks to point to server paths

Possible solution:

Rewrite the paths in the html to internal paths registered via "hook_menu". When the path is called, if the image is not there, use "system_retrieve_file" to download the file and serve it .. Example hook_menu() implemented at image_menu. {Thanks Ciss @ drupal-support irc channel} Rewriting would be taken care of by feed_tamper that I have already.

To clarify - I know that if I use image urls with image fields, the images will be downloaded automatically. However I don't know how to download images that are within a HTML chunk.. thanks.


texts:
The site I'm working on has a issue where some some drop-downs are un-clickable only when anonymous (not logged in).

It was also pointed out that it works fine on Firefox, IE and Opera, while I was using Chrome.

Has anyone else experience anything similar?


texts: How to create a view with aggregate Drupal 7

texts:
I am creating a view about quantity of articles sold and I would like aggregate by years and month for each article.

An example

|............|..........Year..........|..........Year..........|
|............|Jan|Feb|.....|Dec|.............................|
|Article..|Σquantity|Σ(price*quantity)
|Article..|Σquantity|Σ(price*quantity)

For each order I have the quantity of article sold and the order date.

But I don't know how I can do that.

Thanks for your help.


texts: How to store data in database with Form API?

texts:
I'm new to developing Drupal 7 modules, and I can't figure out why my custom module's form data is not stored in my database's table called 'media_skins'.

I followed the info explained in Creating modules - a tutorial: Drupal 7.x but I can't get it working. What's wrong with my code?

Here's my code:

function media_skins_menu() {
  $items = array();
  $items['admin/config/content/media_skins'] = array(
    'title' => 'Media Skins',
    'description' => 'Configuration for Skins module',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('media_skins_form'),
    'access arguments' => array('access administration pages'),
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

function media_skins_form($form, &$form_state) {

  $form['media_skins_test'] = array(
    '#type' => 'textfield',
    '#title' => t('Test field'),
    '#size' => 20,
    '#maxlength' => 20,
    '#description' => t('Test info for the field.'),
    '#required' => FALSE,
  );
  return system_settings_form($form);
}

function media_skins_form_validate($form, &$form_state) {
    // For now, I will no validate anything
}

function media_skins_form_submit($form, &$form_state) {
  $form = db_insert('media_skins')->fields(
    array(
      'start_date' => $form_state['values']['media_skins_test'],
    )
  )
  ->execute();
  drupal_set_message('Data stored in database successfully');
}

Any help will be very appreciated.

EDITING THE SCENARIO

After reading your comments, I tried the following, but I get "Unexpected error, try it again":

function media_skins_form($form, &$form_state) {
  $form['media_skins_test'] = array(
    '#type' => 'textfield',
    '#title' => t('Test field'),
    '#size' => 20,
    '#maxlength' => 20,
    '#description' => t('Test info for the field.'),
    '#required' => FALSE,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Enviar'),
  );
  return $form;
}


texts: Ajax enabled form stopped working - Ajax callback never called

texts:
I have the weird problem that an Ajax enabled form that just worked stopped working - and I have not a clue what is causing this and when it stopped to work. The form itself has no changes for months now and I did not find any code updates which may interfere with this form.
The form is defined in its own form class which extends FormBase. The Ajax functionality is added with the following code in buildForm() method:
$form['form_container']['actions']['submit'] = [
  '#type' => 'submit',
  '#value' => 'Submit',
  '#ajax' => [
    'callback' => '::ajaxResponse'
  ],
  '#attributes' => [
    'class' => ['js-show-throbber']
  ],
  '#weight' => -45,
];

In the form class the method is defined:
public function ajaxResponse(array $form, FormStateInterface $form_state)

When I set a breakpoint within this method for XDebug the script never stops, the process within this methods are not running.
There is no info in browser's console, it is not working in any browser and in watchdog of Drupal are no entries. For me it seems that somehow the bridge between browser / JavaScript world and the form PHP class is broken. I use the exact same PHP code for many other forms without any problem.
My question: can anybody give me a hint how exactly the bridge between browser and form class is created when the form gets rendered? How can I find out if there is a problem in the PHP form class or somewhere in JavaScript?


texts: Limited permissions for users logged in with facebook and twitter

texts:
I would like to know if there's a way to allow people to log in into my Drupal site with limited permissions with their Facebook or Twitter account.

I have created a website which allows authenticated users to upload images. I have added a voting option which can be used by the authenticated users. I want to allow the people logged in with facebook or twitter to be only able to vote and not upload images.

I am using Social Login to allows users to login users with their facebook and twitter. Is there a way to set this limitation?


texts:
I'm new to Drupal and I've very excited about the possibly of headless as it will align with my current skillset and let me be productive more quicly while I continue to learn Drupal. (I come from a full stack .NET background using consuming REST services on the frontend).

I'm having some trouble with the JSON format.

I've set up a REST Export view in Drupal 8.3 that returns a custom content type. It includes a three fields: title, body(plain text), and an image.

The result that I get has a lot of escape characters and I'm not sure how to get it to just return the plain text data.

Here is the result that I get:

[{"title":"A test for the json api","field_body":"This is a test. It\u0026#039;s pretty awesome and I love you.","field_test_image":"\/drupal\/sites\/default\/files\/2017-04\/Adam_Dickison_1.png"}]

What I'd like to get back is this:

[{"title":"A test for the json api","field_body":"This is a test. It's pretty awesome and I love you.","field_test_image":"/drupal/sites/default/files/2017-04/Adam_Dickinson_1.png"}]

I've checked my php.ini and magic_quotes_gpc is set to 'Off'.

Can anybody help me figure this out. I didn't see any general settings. I've changed all of the field settings to remove html and to give me just the plain text.

Thanks in advance.


texts: Move required span of fields outside the label

texts:
Normally in Drupal if a field is required, the Asterisk sign would render inside the <label> tag in a <span>. for some reasons I'd like to move the span outside the <label> and beside the label tag.

thanks.


texts: loop through paragraphs ID's in node template

texts:
In a custom twig template for content type "legal", I'm trying to loop through a 3-field paragraph called "legal_section." It's referenced by my content type, using an entity reference field called "field_legal_section" - set to allow unlimited entries. For each, I want to print the paragraph id. I'm not quite sure how, in this scenario. Maybe there's a little more involved than I thought?

I'm currently trying something like this, in the twig template:

{% if content.field_legal_section %}
 {% for item in content.field_legal_section %}
  id: {{ content.field_legal_section.id }}<br/>
  show the 3 fields: {{ content.field_legal_section }}
 {% endfor %}
{% endif %}

If relevant, the individual fields within the paragraph called legal_section are:

 field_legal_section_title
 field_legal_section_subtitle
 field_legal_section_body


texts:
i have a view  with lot of exposed fields for searching  ... (50 +)

i am looking for some thing like this.

with  "add more " button you can add only the fields you want to search in ..
possible ?

thanks


texts: Show all group content of a specific group type

texts:
I'm having a very difficult time figuring this out, and I'm wondering if it's even possible. I'm using organic groups 7.x-2.x, and I have two "group" types: a student group type and a faculty group type. I also have a "group content" type called blog posts which can post in either group type. What I would like to do is create two views, one to show all blog posts that got posted in all student groups, and another to show the same for faculty groups.

Can anyone provide me insight into how to do this?

Side note: Since OG has switched to using entity reference to assign group membership, I thought it would easy to use this relationship in views to accomplish this, but it looks like it is only using entity reference for the widget, and does not store the data as a normal entity reference field would. Everything I tried with the og_membership relationship seemed to fail, so I'm at a loss here. Any help would be appreciated!


texts: Drupal installation not working/ what is .htaccess

texts:
I have a lamp server and using drupal. The is on Ubuntu server 14.04. My drupal version is drupal 8.0.0 alpha 15. I followed this guide to install both: http://youtube.com/watch?v=zsPc_Tb8bI8

The problem is that I am running it on a server version, so there is no ui. No browser access in Ubuntu server. I can access my webserver via my host machine of the VM, by typing: 192.168.1.5
This bring up the default apache page of Ubuntu. When I do 192.168.1.5/drupal, I gives me an error (404 error). I already tried to set the www-data:www-data permission via chown, but this didn't work. Also, while browsing for answers I came across .htaccess file. I remember copying it somewhere, shown in the video. Where should I have copied it and what does it do?

My final(real) question: how do I access the drupal installation from another computer(not localhost). Do I need to set somethi ng in the apche conf? Also, what is .htaccess


texts:
I am new to Drupal world and creating a site in Urdu language in Drupal 8. I have enabled its multilingual support and set default language to Urdu (in fact, this is the only language of the site).

I have created a content type and enabled to show Display author and date information. I have also added some contents for this content type. When I go to view some content, its author and date information is displayed as below.

Submitted by mabilalmirza on Fri, 02/09/2018 - 23:33

I know I can translate the string using translation interface but I want the day name to be shown in Urdu. I want to translate month names as well for long date format.

Can anyone guide me to accomplish this?


texts: What we need is essentially a free product order. We need viewers to be able to sign up for free classes where there is a limit on the number of students. The registration requirement and the inventory limit indicate that it should be a shopping cart function, but the module that allows for free orders is only available in a Drupal 6 module. Is there such a function for Drupal 7?


texts: How to set permissions of creating content only for referenced users

texts:
I have 2 content types: Courses and Documents. In Documents there is a node reference field which connects it to Courses (actually with a Node Reference URL Widget). In Courses there is a user reference field.

I'd like to add permission of Document content creation only the user who is referenced in Courses. Is it possible somehow? I tried it with Node access user reference modul (it has a "Grants for referenced users to create content" option) but it adds the create permission in every Course content, not only in that he/she is referenced.


texts: How do I add an additional “Cancel account” operation link?

texts:
On Drupal 8, I'm trying to modify /admin/people to have the cancel button appears under Edit link in operations.

What's the easiest way to do this?


texts: nodeapi with op = load being ran multiple times

texts:
I am currently creating a custom module. I am trying to alter a node's body before it is displayed to the user. So I used hook_nodeapi();

I did something like

function hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL){
  if($node->type=='page' && $op =='load'){
    dsm($op);
    //the rest of my code goes here
  }
}

When ran, this displays  8 "load"s when viewing a page.

Why is that? I think it is because of the other modules I have that may be calling node_load, but I am not really sure.

Can anyone shed a light here? And how do I make it possible so that my code is not ran multiple times (in this case, 8 times)?

Thanks.

UPDATE:
I forgot to mention a couple of key things.

I am using the revisioning module. The page I am viewing is an unpublished revision. I tried this:

function hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL){
  if($node->type=='page' && $op =='load'){
    dsm($node->nid);
   dsm($node->vid);
   //the rest of my code goes here
  }
}

I get 8 similar nids, and then 7 similar vids (the unpublished revision), and then 1 vid (the currently published revision)

916
4544

916
3740

916
4544

916
4544

.. and so on


texts:
Is there any way I can count unique visits to my Drupal Site. I have a customized reporting module for the Drupal within which I want to put the unique visits to the site based on date.

I am using this query:-

SELECT
  n.title, n.nid, a.timestamp AS visited,
  COUNT(*) AS times
FROM
  {node_view_count} a, {node} n where a.nid = n.nid AND a.uid = :uid AND n.nid <> 2120
GROUP BY
  n.title
ORDER BY
  times desc,
array(':uid'=>$_GET['uid'])) -> fetchAll();

Do you think there is any way?

Thanks.


texts: How to update cart after deleting line items?

texts:
I have an Application (app) node that when it gets created (hook_node_insert) I add line items (based on info in the app) to my cart. This works great.

Step 2 now is that when I add a new app, I would like to empty the cart (or remove the line items) before adding the new line item (so there is effectively only ever 1 item in the cart).

If I try to do $item->delete() or $cart->delete() before I add the new line item (in my node insert hook) then I get this error:

  Drupal\Core\Entity\EntityStorageException: A cart order for type
  default, store 1 and account 1 already exists. in
  Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 847 of
  core\lib\Drupal\Core\Entity\Sql\SqlContentEntityStorage.php).

If I delete the line items after I add the new line item; then the cart almost looks correct. It shows only my new line item and the subtotal is the amount of my new line item; but the Total shown is the combined Total of the new line item added to the old line items (which have been successfully deleted).

My guess is there is something I need to do to "refresh" the cart after adding and then deleting line items?


texts: How to display eck edit form in ctools modal or in other page?

texts:
I need to display my custom eck edit form in ctools modal. How can I load the form I need in ctools modal or other page?

function edit_education_form_callback($ajax){
  if ($ajax) {
    ctools_include('ajax');
    ctools_include('modal');

    $form_state = array(
      'ajax' => TRUE,
      'title' => t('Education'),
    );

    $output = ctools_modal_form_wrapper('resume_education_edit_form', $form_state);

    if (!empty($form_state['executed'])) {
      // We'll just overwrite the form output if it was successful.
      $output = array();
      ctools_add_js('ajax-responder');
      if (isset($_GET['destination'])) {
        $output[] = ctools_modal_command_dismiss();
      }
      else {
        $output[] = ctools_ajax_command_redirect('my-account');
        drupal_set_message(t('successfully added.'));
        $output[] = ajax_command_after('.modal-title',theme('status_messages'));
      }
    }

    print ajax_render($output);
    drupal_exit();
  }
  else {
    return drupal_get_form('resume_education_edit_form');
  }
}

function resume_education_edit_form($form, &$form_state){
  // How can I call the eck edit form I created?
  // $output = ctools_modal_form_wrapper('eck_edit_form', $form_state)
  // Should I use drupal_get_form('eck__entity__edit')?
}


texts: I am using the Flag module on my site. In which function should I add my custom code that is executed when users click on the flag button?


texts: Feed import of 20,000 nodes. How to batch up 1000 at a time?

texts:
I setup my Drupal 7 feed importer to import from a csv file with 20,000 nodes. I'm able to get it working with 20 nodes just to test to make sure everything is working. But is there a setting to be able to process X amount of nodes at once? My csv file is 12MB and I'd like to just do 300 at a time, but I don't see an option for this anywhere.

How would I make it process a set amount?


texts: Main Menu Display Description as span Tag

texts:
I modifed my main menu using the following code, but I need the  elements only for the first level menu items, not for the sub-menu items.

How can I achieve this?

function neofelis_menu_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';
  $element['#localized_options']['html'] = TRUE;

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }

  if ($element['#original_link']['menu_name'] == "main-menu" && isset($element['#localized_options']['attributes']['title'])){
    $element['#title'] .= '' . $element['#localized_options']['attributes']['title'] . '';
  }

  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '
' . $output . $sub_menu . "
\n";
}


texts:
I tried to make auto confirm authenticated user to Drupal Newsletter Module but i failed. in other words... is it possible that users do not receive a verification email and immediately confirmed?

I un-tick this option:

Send confirmation email
Attention: If you disable confirmation e-mails, users will be able to subscribe others without their permission.

But still find that all the subscribers in my list are unconfirmed.

Please help..


texts: How exactly do I package latest dev snapshot of Commons locally?

texts:
I am trying to build up-to-date instance of Drupal Commons 7.x-3.x-dev. Release notes say to use command: "drush make build-commons-dev.make". I am totally new to drush and am trying to follow that instruction.

Can anyone provide more detailed instructions? That is my basic question.

Thanks, and more details below:

I thought I had figured it out. I can now go to root folder of site and run "drush profiles/commons/build-commons-dev.make" and I get what appears to be current Drupal Commons 7.x.-3.x-dev. However, as I test my instance, I am reporting bugs that Drupal coders say are already fixed and committed to github. So it seems that I am not properly synched.

Maybe I have wrong makefile? I got it from http://drupalcode.org/project/commons.git/tree/1228f4b

When I run "drush update" it says I am using all sorts of dev modules and that my site is 100% current. But I am clearly not current, because I am finding bugs that have already been fixed. Thanks for your help so I can test and contribute to Drupal Commons.


texts: Automatically inheriting title for image

texts:
Is there a way to inherit the title or copyright field in the properties of a picture on your pc to the title or alt field of an image in drupal?

What I want to achieve is the following:

I want other people to be able to write things on my website, and include a picture to the text. However due to copyrights, I don't want them to be able to upload images. They can only use the images which I have paid for.

This works perfectly, I am using a combination of the following modules:

FileField Sources
IMCE
IMCE for FileField

So far so good, but I also want to be sure that the credits are given to the original authors of the images. I know for sure that people will forget to write that in their text, so I was wondering if it was possible to do this automatically.

If the copyright or title field of the image properties would automatically be added to the picture's title in drupal, I could disable the title field & the credits will always be correctly showed. That is, if I add them to the pictures before uploading :)


texts: I am trying to insert a image using Postman

texts:
Good afternoon,
I am trying to insert a image in Drupal from Postman.
The request URL is http://<urldrupal>/drupal/node?_format=hal_json.
The JSON structure inserted in the body is the following.
{
  "url": "http://<urldrupal>/drupal/rest/type/file/image",
  "type": "POST",
  "data": {
    "_links": {"type": {"href": "http://<urldrupal>/drupal/rest/type/file/image"}},
    "filename": [{"value": "test.jpg"}],
    "filemime": [{"value": "image / jpeg"}],
    "type": [{"target_id": "image"}],
    "data": [{"value": "BASE64_VERSION_OF_THE_IMAGE_HERE"}]
  }
}

I get the following error.
{
    "message": "The type link relation must be specified."
}

I cannot understand what I am doing wrong. Can anybody help me?


texts: How to enable comments on custom entities

texts:
I'm using a contributed module that provides a custom entity. I would like to modify that entity and want to enable comments for this entity.

Does anybody know how to enable commens for custom entities?


texts:
I am writing a module which uses a template to output results from a database; these results can be edited. I use a form with a fieldset of submit buttons. Each result has an edit button. I get the buttons rendered but there is no <form> tag so nothing happens when the buttons are hit.
Below is my code. I believe I am missing something fundamental, or there is a better way to do it.

  function eventhistory_menu() {
    $items['personal-history'] = array(
      'title' => 'Event history',
      'page callback' => 'historypage_rendered',
      'access callback' => TRUE,
    );

    return $items;
  }

  function eventhistory_theme() {
    return array(
      'eventhistory_template' => array(
        'variables' => array('output' => NULL, 'hist_form' => NULL),
        'template' => 'eventhistory_template',
      ),
    );
  }

  function historypage_rendered() {
    $output = array(
      '#theme' => 'eventhistory_template',
      '#type' => 'markup',
      '#hist_form' => drupal_get_form('historyEdit_form'),
      '#output' => getHistory(),
    );

    return $output;
  }

 function historyEdit_form($form, &$form_state) {
   $form['#tree'] = TRUE;
   $num_hist = 0;

   $form['history']  = array(
     '#type' => 'fieldset',
   );

   if ($form_state['hist_num']) {
     for ($i = 1; $i <= $form_state['hist_num']; $i++) {
       $form['history']['num' . $i] = array(
         '#value' => 'Edit',
         '#type' => 'submit',
       );
     }
   }

   return $form;
 }

In the template I have print drupal_render($hist_form['history']['num' . $count]);. The buttons show, but they are not surrounded by any <form> tag.

What am I doing wrong?


texts: domain access: Alias of a main domain to point to subdomain

texts:
I´ve got an domain-access installation with the default domain "capital.com" and a subdomain "country.capital.com".

I´m struggling now with pointing from a main domain to this subdomain.
Like so:

country.com/travel should lead to country.capital.com/travel but keeps country.com as domain name: country.com/travel

I can´t get it to work with "keeping domain name".
Simple redirect works to load the subdomain, but displays sub.domain.com/.
I can set an alias to point to default domain, which keeps the alias.
How can I point from ALIAS to the SUBDOMAIN?

Any suggestion welcome!

I thought that´s a main feature of domain-access module.
I´m in trouble now - havn´t been aware of this complication!

regards
Vincent


texts: Display webservice response in a paged table

texts: I have data I am receiving from a webservice call that I would like to display in a paged Drupal table. How can I do this? Can I use theme('table') and attach a pager to it somehow?


texts:
I am trying to pass an object from a function to the menu item (Not sure if drupal allows that), I get the following error 'Recoverable fatal error:Object of class stdClass could not be converted to string'. The following is my function and the menu item.

function add2basket_link($val) {
  $build = array();
  $build['add2basket_link'] = array(
  '#type' => 'link',
  '#title' => t('Bucket'),
   '#href' => 'basket/add/'.$val. '/nojs/',
  );
  return render($build);
  }

 function bucket_menu(){
   $items['basket/add/%'] = array(
   'page callback' => 'data_add2basket',
   'page arguments' => array(2),
   'access arguments' => array('use basket'),
   'type' => MENU_CALLBACK,
   'file' => 'data.inc',
   );
  return $items;
 }

The error points to the line of " '#href' => 'basket/add/'.$val. '/nojs/', " from the add2basket_link function


texts: {{ drupal_view('view1', 'block_2') }} renders only when cache is cleared

texts:
I like to output 2 block-views in a template called "block--bar.html.twig", but only when i clear the cache they are printed.

(i installed Twig Tweak 8.x-2.x)

This is the template:

{{ drupal_view('view1', 'block_2') }}

{{ drupal_view('view2', 'block_1') }}

Any help is appreciated.


texts: How to organise children menu links as tabs in D7?

texts:
I'm using Drupal 7 and now I have a regular dropdown menu like this:

Link 1

sub-link 1
sub-link 2

Link 2

But I would like to organize my sub-links as tabs where sub-link 1 and sub-link 2 would  be a content tabs that contain a block content. I tried to use OM Maximenu Modul, it helps to organise parent links as tabs but not sub-links. Could anybody help me in this question?


texts: Change node display for purchased products

texts:
I am using Drupal 7 and Drupal Commerce, and i want to change the appearance of product display node when a user bought the product which he references.

For example :

1/ Product display before having been bought : title, teaser, price, add to cart form

2/ Product display having been bought : title, teaser, body

I try the solution giving by Commerce Guys, but I don't want to create two nodes (product display and paid content).

Would you have a solution?


texts: Are there any advantages or issues with using a Google Analytics CDN app with the GA module?

texts:
I'm considering using Cloudflare with my Drupal 7 site.

I see that Cloudflare offers a Google Analytics app:
https://www.cloudflare.com/apps/google_analytics

I already have the Google Analytics module installed and configured on my site.

Are there any advantages to using both a CDN Google Analytics app and the drupal module at the same time?


texts: Get Webform submission count using custom module

texts:
I would like to get the submission count of a user using custom code in my module. Which variable stores this?

I tried to do dsm on $node and there was an array for webform inside the $node object but in that array I couldn't find the submission count for the current user. But then, $node shouldn't contain that value, of course. So how do I get this value?


texts: How to check if a database is set up in settings.php?

texts:
I am creating a module for Drupal 8. One of the requirements is that you first add a new database in settings.php. On the admin page, I want to check if the user did this step and show a warning if he didn't. I tried this:

global $databases;

But doing a var_dump shows nothing.

How do I access the databases variable so I can check if the database is setup?


texts: Overriding admin settings form from bootstrap sub theme

texts:
I need a little help here. I am creating a sub theme of bootstrap theme and I need to add an additional fieldset under "Bootstrap Settings" form (similar to Components, Advanced etc which are currently present) which appears under Appearance->Settings-><THEME NAME> page. I think we can use hook_form_alter() for this but the problem is that hook_form_alter() is being always invoked with $form_id set to "search_form" and never "system_theme_settings". Thus any form updates I am making under this hook are getting applied to search box instead of admin settings form.

I referred code under bootstrap_form_alter() in alter.inc file in bootstrap theme and tried to replicate it in sub theme but it doesn't seem to work. In order to ensure that I am not making any mistakes while creating subtheme I also tried using other available subtheme such as one created by Adam Balsam (he has provided details on this in response to a question here.

Any help/pointers would be greatly appreciated.

I am listing below my code from template.php file of the bootstrap_ignitor sub theme

function bootstrap_ignitor_form_alter(&$form, &$form_state, $form_id) {
  drupal_set_message('<pre>'.print_r($form_id,TRUE).'</pre>'); ***<= this always prints as search_block_form***
  $form['actions']['submit']['#attributes']['class'][] = 'btn';
  _bootstrap_ignitor_settings_form($form, $form_state);
}

function _bootstrap_ignitor_settings_form(&$form, $form_state) {

  // Advanced settings.
  $form['themealter'] = array(
    '#type' => 'fieldset',
    '#title' => t('Theme Alter'),
    '#group' => 'bootstrap',
  );

  $form['themealter']['local_cdn'] = array(
    '#type' => 'fieldset',
    '#title' => t('NewBootstrapCDN'),
    '#description' => t('Testing...'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );

}


texts: Reset Drupal 7 Site: NIDs, Revision VIDs, Taxonomy Term and Categories, etc

texts:
Is there a way to keep an entire Drupal 7 site intact, excluding content?

Basically after creating a test environment with many nodes, terms, revisions, etc, I would love to be able to delete all the content/taxonomy and have the IDs reset as well.

Thanks in advance for any help.


texts: how to save the operations(add/update) done by authenticated user into a log file

texts:
I need to write the sql operations(update/add) performed by an authenticated user of my drupal site into a log file/database table. I simply need the query executed, uid, timestamp of that operation done.

For example if a user named "XYZ" logged into my site and updated his firstname at 12/12/12 12:12:12. while he updated the query run in the backend would be "UPDATE  db_name.table_name SET  firstname =  'ABC' WHERE  table_name.firstname =XYZ;"

I need to store it into my database custom table which has the three fields uid, sql, timestamp


texts: Update all nodes with a default field after adding a new field to the content type

texts:
I have an existing content type with a number of nodes. I have just added a new boolean field with a default value of "off."

However, until I re-save each node the default value is not set, so a view that should shown only those nodes where the new field is using the default value is currently empty.

How can I update the existing nodes, created before the field has been added, to set that field to its default value?


texts: How do I strip spaces from a Twig variable?

texts:
Example code I'm working with:

<a{{ attributes.addClass(classes, 'field__item') }} name="{{ item.content }}">{{ item.content }}</a>

In this example, I have created a Brick with a field called anchor_id. The idea is that content creators can name an anchor whatever they want, and then add that brick to a page.

I can get the field to show up fine. But, I'd like to strip out spaces so if they enter "my awesome tag" it instead gets rendered as name="myawesometag.

I've tried a few methods, but can't seem to figure it out. Seems like it would be some simple filter, but if it is I'm not seeing it.

Thanks in advance!


texts:
I have a date time field to input working hours and then I need calculate total work hours. I was try using Global math expression in views, but the results is 0, although I was try to change views formmater from date and time, ago and plain.

This is the condition, lets say the rule in office is:

Employee In 1: 08.00
Employee Out 1: 12.00
Employee In 2 : 13.00
Employee Out 2 : 17.00

It's mean that employees must have 8 hours a day.

The question is, how can I calculate that employee is late in 2 hours if the field value like this:

filed Employee In 1: 09.00 <- late
field Employee Out 1: 12.00
field Employee In 2 : 13.00
field Employee Out 2 : 16.00 <- earlier out

Is there any module date related or some one chould assist me ho to solve my problem?


texts: Clean URL test fails, but its not a mod_rewrite problem

texts:
I am migrating my Drupal 7 instance to a new server running php 5.6 and Drupal 7.39 and Debian 8. I cannot get it to pass the clean url test. I belive clean urls do in fact work. If I call a "clean" path it loads just fine. However if I force clean urls on with Drush no users can log in.

mod_rewrite is enabled, and a call to "https://test.cgps.org/?q=/admin/config/search/clean-urls/check" returns {"status":true}. It appears to be failing when the clean url check calls drupal_http_request() to get this test page. That function returns "Error opening socket ssl://test.cgps.org:443". When I call openssl directly it connects but appears unhappy with my certificate chain.

root@drupal7 drupal7/includes# openssl s_client -connect test.cgps.org:443
CONNECTED(00000003)
Verify return code: 21 (unable to verify the first certificate)

Same with curl

curl https://test.cgps.org/?q=/admin/config/search/clean-urls/check
curl: (60) SSL certificate problem: unable to get local issuer certificate

My certificate is issued by GeoTrust and loads just fine in a browser:

drupal_http_request() calls stream_socket_client(). Does this use openssl, curl or something else?

So I figured I needed to install the intermediate cert into Linux which I did by placing the same intermediate cert Apache uses into  /usr/local/share/ca-certificates and running update-ca-certificates. Still no luck...

conf file:

<Directory /media/www_drive/drupal7>
Require all granted

RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]
</Directory>


texts: How do I inherit images in sub-theme from base theme?

texts:
We built a drupal theme "Theme A" from scratch for our project. Later , for the new releases , we wanted to modify the newly developed pages which were slightly enhanced versions of previous pages. In order to retain most of the css and js , we created a sub theme "Theme B" from "Theme A" . Now most of the images which we had used earlier are in Theme A's image folder. How do we reuse Theme A's images in Theme B without copying them ? The current default theme is set to "Theme B".

We used base_path().path_to_theme() to refer images. I guess we must now change it to drupal_get_path('theme','themeA').


texts:
on D7 and I've made this:

function project() {
  global $user;
  $uid = $user->uid;
  $name = $user->name;

  $teaser = 0;
  $page = 1;
  $type = 'page';
  $status = 1;
  $format = 3;

  $body = " ".
                "

Projects from user ".$name."

";
}
?>

And I need to print the result on the main content of my theme, how can I do it?
If I do echo "$body";I view the result not in the main content but as a single page. Thanks a lot.


texts: How can menu tabs be relocated to another region?

texts: I want to move menu tabs to occur in the main menu region instead of immediately above the content.  I cannot identify a block that contains them.  Is there a module, template location or a hook for controlling their display?


texts: Getting rid of password_confirm labels in module

texts:
In a module, the following generates unwanted labels for 'Password' and 'Password confirm':

$form['password'] = array(
  '#type' => 'password_confirm',
  '#maxlength' => 20,
  '#size' => 10,
);

It produces the following HTML:

  Password
  <input class="password-field form-text" type="password" id="edit-password-pass1" name="password[pass1]" size="10" maxlength="128" />

  Confirm password
  <input class="password-confirm form-text" type="password" id="edit-password-pass2" name="password[pass2]" size="10" maxlength="128" />

The object is to get rid of the text labels and replace them with images.  I have tried toggling '#title', '#title_display' and '#label_display' but nothing works.

Any ideas?


texts: Content Type with Tabular Data to be Input

texts:
I'm building a content type that is going to require tabular data to be input. Here's a mockup of what the table should look like:

Rows 1 and 2 are fixed headers, 3-6 are data.

I am at a total loss as to how I should build this. I've experiemented with a few modules (like TableField... which is not really what I'm looking for).

Am I approaching this the wrong way? Is there a module that I'm not aware of that can do this?


texts: Display name of Content Type instead of node Title in Views

texts:
I have multiple different content types: Part A, Part B, Part C, etc.

What I need, is to display "Part A" in Views, instead of the title of the content. I also need to link to the content.

Is there an easy way to do this? It seems like such a simple thing, but I've found nothing on Google.

I'm thinking of using the Automatic Node Titles module to replace the title with "Part A (username - date)", so is this the best way?


texts: Correct way to render fields from query in tpl?

texts:
I'm here again to ask for some help, I'm running a query in a custom module to get contents of a node type, with this:

$node_type = "mynodetype";
  $nids = db_query("SELECT * FROM {node} WHERE type = :type", array(':type' => $node_type))->fetchCol();
  $nodes = node_load_multiple($nids);

And returning $nodes to the template, I'm using a foreach for $nodes array and I get something like this when I print_r() an element of $nids array.

stdClass Object ( [vid] => 12658 [uid] => 1 [title] => Node title [log]
=> [status] => 1 [comment] => 0 [promote] => 0 [sticky] => 0 [nid] =>
12658 [type] => mynodetype [language] => es [created] => 2017
[changed] => 1502159375 [tnid] => 0 [translate] => 0
[revision_timestamp] => 1502159375 [revision_uid] => 1 [mp_idmod]
=> Array ( [und] => Array ( [0] => Array ( [value] => 1 ) ) )
[mp_nmod] => Array ( [und] => Array ( [0] => Array ( [value]
=> Myvalue [format] => [safe_value] => Myvalue ) ) ) [rdf_mapping]
=> Array ( [rdftype] => Array ( [0] => sioc:Item [1] => foaf:Document )
[title] => Array ( [predicates] => Array ( [0] => dc:title ) ) [created]
=> Array ( [predicates] => Array ( [0] => dc:date [1] => dc:created )
[datatype] => xsd:dateTime [callback] => date_iso8601 ) [changed] =>
Array ( [predicates] => Array ( [0] => dc:modified ) [datatype] =>
xsd:dateTime [callback] => date_iso8601 ) [body] => Array ( [predicates]
=> Array ( [0] => content:encoded ) ) [uid] => Array ( [predicates] =>
Array ( [0] => sioc:has_creator ) [type] => rel ) [name] => Array (
[predicates] => Array ( [0] => foaf:name ) ) [comment_count] => Array (
[predicates] => Array ( [0] => sioc:num_replies ) [datatype] =>
xsd:integer ) [last_activity] => Array ( [predicates] => Array ( [0] =>
sioc:last_activity_date ) [datatype] => xsd:dateTime [callback] =>
date_iso8601 ) ) [cid] => 0 [last_comment_timestamp] => 2017
[last_comment_name] => [last_comment_uid] => 1 [comment_count] => 0
[name] => admin [picture] => 0 [data] => b:0; )

And inside the foreach, to render the fields I do it this way:

<?php print $nid->mp_idmod[LANGUAGE_NONE][0]['value'];  ?>

My question is, this is the right way to render the fields value of each node content type loaded? Or I should do it other way?


texts: Override a custom theme template for a specific node

texts: I have a custom tpl file (node--product.tpl.php) for my product node types. I'm creating a special featured page (Also a product node) but I want to create a different layout for this one node. I created another tpl file (node--58.tpl.php) but it wont override my product template. What I'm I doing wrong?


texts:
I'm looking for a module for an event website which calls for volunteers to register by sending name/email.

Ideally, it would allow some users to access the registered volunteers database in some downloadable format (CSV for instance).

Is there something like this for D7? I've been googling but found nothing.


texts: commerce userpoints discount is not working

texts:
I'm using drupal commerce userpoints module for discount using userpoints on checkout page but that is not working when I click on 'Apply Credits'.

Can you please guide me in this, how to configure properly from admin, I followed directions but maybe I did something wrong.

Thanks


texts: How can I override the fivestar title attribute without hacking the module?

texts:
It's line 4 of this part of fivestar.module:

$options = array('-' => t('Select rating'));
for ($i = 1; $i <= $element['#stars']; $i++) {
$this_value = ceil($i * 100/$element['#stars']);
$options[$this_value] = t('Give @title @star/@count', array('@title' => $title, '@star' => $i, '@count' => $element['#stars']));}

It creates a verbose title on every star. I tried this javascript

var elements = document.getElementsByTagName('a');

for (var i = 0, len = elements.length; i < len; i++)
{
  elements[i].removeAttribute('title');
}

but it doesn't affect these links. I even tried doing it inline at the bottom of html.tpl. Is there a function I can use in template.php? Full file if it helps.


texts: Form field name not rendered after submit the form

texts:
I created a form and designed it by referred this link. It worked fine. I used the following code to display a textbox in my form

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['searchtext'] = array(
          '#type' => 'textfield',
          '#title' => t('Keyword Search:'),
          //'#default_value' => (isset($record['searchtext'])) ? $record['searchtext']:'',
          '#attributes' => array('placeholder' => t('Enter keyword to assist locating notices relevant to your vehicle')),
        );
    $form['#theme'] = ['notices_search_form'];
    //echo "before submit: <pre>";print_r($form);echo "</pre>";
    return $form;
}

and it is rendered correctly as i expected as below (it has name, id and everything)

<input placeholder="Enter keyword to assist locating notices relevant to your vehicle" data-drupal-selector="edit-searchtext" type="text" id="edit-searchtext" name="searchtext" value="" size="60" maxlength="128" class="form-text">

But after submitting the form, I stop the redirection and load the form with the value entered while submitting form using following code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $fieldvalues=$form_state->getValues();
    $form['searchtext']['#value'] = (isset($fieldvalues['searchtext'])) ? $fieldvalues['searchtext']:'';
    $form_state->disableRedirect();
    return $form;
  }

But this time form loads without name or id as below

<input placeholder="Enter keyword to assist locating notices relevant to your vehicle" type="text" value="sdfdf" size="60" maxlength="128" class="form-text">

I am new to drupal. Someone suggest me what am i missing?

Edit 1

I tried to place the name in the array like below and it is worked fine.

$form['searchtext'] = array(
      '#name' => 'searchtext',
      '#type' => 'textfield',
      '#title' => t('Keyword Search:'),
      //'#default_value' => (isset($record['searchtext'])) ? $record['searchtext']:'',
      '#attributes' => array('placeholder' => t('Enter keyword to assist locating notices relevant to your vehicle')),
    );

But setting 'true' to  "#default_value" for checkbox field is not checking while rendering it.


texts: How to send mail with multiple images from node using Rules module?

texts:
$language = field_language('node', $node, 'YOUR _FIELD_NAME');
foreach($node->YOUR_FIELD_NAME[$language] as $file) {
  echo drupal_realpath(file_load($file['fid'])->uri);
}

I used this code to send mail in attachments but image file does not work


texts: Where are css injector files stored on the server?

texts:
I'm using this module:

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

In the backent, the files show up at this path:

public://css_injector/css_injector_20.css

But in FTP I look in public.html and I can't find theme

They are not in here either:

/home/vincoixt/public_html/xuzo.com/sites/all/modules/css_injector

So where are they?


texts: How do I display information about a node's author on the full node and not the teaser view?

texts:
I have added the following to my node.tpl

<?php if ($display_submitted): ?>
 <?php print $user_picture; ?><?php print $name; ?>
<?php endif; ?>

This displays the authors info on the node itself, but also the teaser. How do I change the code to remove it from the teaser, but still keep it on the node?


texts: Views_pre_render How do I get a file's path url if I only have the file name?

texts:
I have a dynamically created Views listing page where I display fields from "Collection Items" node type in this order:

Item Title
Item Status
Date Stamp
Document (uploaded file. I'm only getting the filename here)

My goal right now is to take the path of the uploaded document and use it as a link in the title. Like so
<a href="path/to/file"> Item Title </a>

I'm trying to achieve this with hook_views_pre_render(), but am stuck just testing out some code I found from here.
Here is my code:
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\collections\Entity\CollectionsEntityInterface;
use Drupal\collections\Entity\CollectionsEntityType;

function collections_views_pre_render(&$view){
  $results = $view->result;
  $view_id = $view->storage->id();
  $current_display = $view->current_display;

  if(strpos($view_id,"collection__" ) > -1 && $current_display == "default_page"){
  foreach ($results as $key => $result){

    //prints 0123456
      echo $key;

      //breaks the site. Gets message "The website encountered an unexpected error. Please try again later."
      $parent_id_value =  $result->_entity->parent_id->getValue()[0]['value'];
      $parent_type_value =  $result->_entity->parent_type->getValue()[0]['value'];
      $media_field= $result->_entity->field_media_field->getValue()[0]['value'];

    }
  }
}

Once I got the file's path, I would then be trying the solution offered here:
https://www.drupal.org/forum/support/module-development-and-code-questions/2020-01-12/use-hook_views_pre_render-to-change
$link = Drupal\Core\Link::createFromRoute($parent_id_value, 'entity.node.canonical', ['node' => $parent_id_value]);


texts: Add a checkbox on registration page for subscription newsletter with Simplenews

texts:
I'd like to add a checkbox for subscription to a newsletter on the user registration page.

I'm using Simplenews.

How could I do that?


texts: Hierarchical select ajax conflict in custom bootstrap theme

texts:
I have created a custom theme from scratch using twitter Bootstrap. In my content type there is Taxonomy term Hierarchical Select (HS) list.

Problem: When authenticated user try to select any term from first level, HS keeps on loading...for ever.

Note: Hierarchical select is working fine for admin with core Seven theme enabled and with jQuery update version 7.

Please help.


texts:
I have two block views in my Drupal 7 site dashboard: One is a custom module and one is a normal views block. Both are assigned to the dashboard.

The custom module has a table in the block_view hook. It also has a pagination in it. The second one is generated via the Views module, and also has a table with pagination.

When I go to the second page or to any page of the first table, the second table is updated too.

I made the view based table's pagination AJAX based, but I suppose it is not to right way.

How do I solve this problem?


texts:
I have a content type containing many fields. I want to attach H1, h2, h3, tags to the field_labels of the fields.

Is this possible?
How can I do this?

I am relatively new to Drupal. Thanks.


texts: How to calculate the average Fivestar rating correctly?

texts:
The anonymous visitors and registered users on my website can rate nodes through a comment with a Fivestar field. I display the average rating on the node's page. While testing this mechanism, I found out that the average isn't calculated correctly when multiple anonymous users vote with a comment. I suspect that only the last vote of a certain uid is taken into account: since all anonymous users have a uid equal to 0 - even if their name in the comment is different - they are considered as the same person.

In order to solve this problem, I did some research to how Fivestar calculates averages. All comments and corresponding votes of anonymous users are stored seperately in the database, so I can certainly use all the available information. I think that I also located the function in fivestar.module (lines 45-59) that calculates the average:

function fivestar_microdata_suggestions() {
  $mappings = array();

  // Add the review mapping for Schema.org
  $mappings['fields']['fivestar']['schema.org'] = array(
    '#itemprop' => array('aggregateRating'),
    '#is_item' => TRUE,
    '#itemtype' => array('http://schema.org/AggregateRating'),
    'average_rating' => array(
      '#itemprop' => array('ratingValue'),
    ),
    'rating_count' => array(
      '#itemprop' => array('ratingCount'),
    ),
  );

  return $mappings;
}

My situation is as follows: I use the average rating of a node in Rules and Views too, so I'm looking for an easy solution. Surely, I expect that I can calculate the correct average with Views or Computed Field, but implementing the usage of this average elsewhere could require quite a lot of adaptations.

Therefore, I would first like to ask you whether you have faced this problem as well. If so, how did you solve it? Is it possible to somehow "overwrite" the way Fivestar calculates averages programatically? I'm not familiar with how one uses schema.org or what information that website provides...


texts: Right now I only see a way to list all the terms of a particular taxonomy in the admin panel. I have to go through pages of terms if I want to locate a term I want to edit. How can I search by a term's name?


texts: Feeds Module Periodic Import not working

texts: I created a Job portal using the feeds module. I have the Periodic Import on every 3 hours. It says you have to configure your cron. I have read where there are others having issues a few years ago and they say to use Ultimate cron or Elysia Cron. I tried both and am not sure what/ where I am suppose to set and still isn't working.


texts: Which method is more efficient, database query or taxonomy term controller?

texts:
I tried to find a method to verify if the current taxonomy item page has a parent or children, now I get two but I don't know which one is better for the efficiency.

approach I: use taxonomy item controller

$tid = \Drupal::routeMatch()->getRawParameters('taxonomy_term');
$term = taxonomy_term_load($tid);
$items = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadChildren($tid,$term->getVocabularyId());

approach II: database query

$db = \Drupal::database();
$query = $db->select('taxonomy_term__parent','ttp')->condition('ttp.parent_target_id',$tid)->fields('ttp',['entity_id']);
$result = $query->execute()->fetchAll();

Both method can satisfy my initial demand, but which one is better in
efficiency? And what about the general case, when we need to check
some data, using the data object method or database query, which is
better?


texts: Someone told me that most of the time I will probably want to use the field API (CCK module in D6), rather than adding custom tables or modifying nodes by myself. How do I use the field API? Could anyone can make me an example?


texts: ERROR:Cron run exceeded the time limit and was aborted. why?

texts:
My Drupal installation's cron runs fail when run manually or by cron script.

I thought it might be the Simple News module, but I've disabled then uninstalled that and the problem is still present.

My PHP max_execution_time is set to 120 seconds, but only takes 2 seconds before I'm redirected to domain.com/user/1/edit with no error message is displayed.

When I look in the dblogs I can see:

  Message:    Cron run exceeded the time limit and was aborted.
    Severity:   warning

I have looked in the Apache logs and no PHP error is given. How can I debug in fix this?


texts: Do I need to download migrate upgrade module if use drush command?

texts:
Migration Drupal 6 to Drupal 8.

My Drupal 8 site is located at /domains/example.com/public_html/drupal8site

Step 1: Install Drush

Step 2: Browse my drupal site cd /domains/example.com/public_html/drupal8site

Step 3: Use drush command drush migrate-upgrade --legacy-db-url=mysql://user:pass@12.34.56.78/d6db --legacy-root=http://example.com

If I using Drush migrate command above, do I still need to download the Migrate Upgrade module? If yes, where should the module file located?


texts:
Site: Drupal 7 with a responsive theme.

I need to display some dynamic content in a block based on the results of a form.

For discussion pursoses.

Field 1 is a drop down of states [NJ, PA, NY]

Field 2 is drop down based on the state of counties and rate. Rates do not have to be shown.

NJ - Middlesex (12), Union(9), Warren(14)

PA - Pike(9), Monroe(8.5), Potter(8)

NY - Essex(9), Lewis(10), Broome(12)

Field three is text box for Total.

Results returned would be new total = total * rate.

If a user selects NJ, Union and Enters a Total of 100, the results returned woulds be 900 (9*100)

It would look something like this:
State [select state]
County [select county based on state]
Total [eneter total]
Amount = rate * total
{Submit}{Reset}

I just have no idea how to do this in Drupal. I do not need to save this data. Just display it to the user.

Any help would be greately appreciated.

Glen


texts: Difference between using features, strongarm & ctools exportable api

texts:
Whats the difference between using features, strongarm or the ctools export api to export config settings?
I cannot use the features modules so I need to find an alternative because its not part of the development process we use. What are the limitations with exporting config in general?


texts: How to add a new CSS class to a Drupal7 ?

texts:
Hello I created the following form iterating for each node:

...
$render['my_list'][] = drupal_get_form('shop_form_item_'.$node->nid, $node->nid);
...

$render will output the form on the page. The forms will be shop-form-item-20, shop-form-item-21 etc...

function shop_forms($form_id, $args) {
  $forms = array();
      if(strpos($form_id, 'shop_form_item_') === 0) {
        $forms[$form_id] = array('callback' => 'shop_form',);
      }
  return $forms;
}

function shop_form($form, &$form_state, $nid) {
  $form = array();

    $form['my-item-name'] = array(
    '#type' => 'hidden',
    '#title' => t('Name'),
    '#value' => isset($node->title) ? $node->title : '',

  );

  return $form;
}

Now I need to add a class: <form method="post" action="" class="cart">
How do I insert it?

Thanks


texts: How to change 'upload' and 'choose file' text that generates form type managed_file

texts:
$form['cv'] = array(
    '#type' => 'managed_file',
    '#title' => t('Vaš CV'),
    '#default_value' => '',
    '#progress_message' => t('Molimo Vas sačekajte...'),
    '#upload_validators' => array(
        'file_validate_extensions' => array('pdf doc docx'),
        'file_validate_size' => array(5*1024*1024),
    ),
    '#description' => t('Dozvoljeni formati: pdf, doc, docx. Max 5MB'),
);


texts:
Old multisite subsite relative path to image (in block/Full HTML with CKeditor and on localhost/XAMPP):

/sites/site1.localhost/files/image.png

New multisite path (what I'm trying to achieve):

/sites/site2.localhost/files/image.png

So, in Full HTML input settings for Pathologic, we select the 3rd option Relative path and add lines:

/sites/site1.localhost/
/sites/site2.localhost/

And nothing happpens, it just strips the /sites/site1.localhost/ from path and now the path to image is just:

/files/image.png

How do I make it the /sites/site2.localhost/?


texts: Hide certain field on form alter using AJAX

texts:
I have a webform created using interface, and need to hide some fields through button. Using form_alter I have added that button added AJAX call with it. Now I want to remove/hide certain element using that button and AJAX.

Below is the sample code

function xyz_user_signup_form_webform_submission_form1_form_alter(array &$form, FormStateInterface $form_state, $form_id) {

  $form['#attached']['library'][] = 'xyz/xyz.global';

  $form['start'] = [
      '#type' => 'button',

      '#ajax' => [
        'callback' => 'xyz_user_signup',
       ],
      '#value' => t('START >>'),
  ];

}

function xyz_user_signup(array &$form, FormStateInterface $form_state) {

    $elements = &WebformFormHelper::flattenElements($form['elements']);

    $elements['field1']['#access'] = FALSE;

    return $elements;
}

On clicking start button I want to hide field1.


texts:
I saw many personal or company websites with one-page website style. the one-page design is very good for giving as quick as possible all information that you have without letting users click around to find out who are you and I really want to apply them in Drupal.
I also tried to implement one-page website by using the single page website module (http://drupal.org/project/single_page_website) and it's quite nice for the simple pages.
So my questions are:

Which is the best way for making one-page design: create one-page templates or using contributed modules?
The advantages and disadvantages for Drupal to make one-page design?

I haven't done any one-page design before so can someone give me the right direction for that.


texts:
Hi!
Again, I apologize for writing bad English.

Put into context my problem: when you install Display Suite, the Select Layout option appears in Manage Display within each type of content created. When selecting a layout we can have control over where and how to display the title field.

This worked fine until I installed a module called: Field Group. After installing this module, I have experienced two problems with Display Suite. One is as follows:

I set my_content_type to show the title field in full-content view. But it never appears in the frontend.

I deleted the Drupal cache. I cleaned the Drupal database with Optimize DB. I uninstalled the Field Group module. Nothing works.

Any idea how to fix this?


texts: Create container.html.twig template for specific page

texts:
I'm attempting to edit the search page.
I've edited container.html.twig to contain

{%
  set classes = [
    has_parent ? 'js-form-wrapper',
    has_parent ? 'form-wrapper',
  ]
%}

Search Results

{{ children }}

It works fine when I leave the file name as container.html.twig. But I'd like for it to only apply to the search page. I've tried naming it container--search-results.html.twig but that did not work.

How do I rename container.twig.html to only apply to my search page?


texts:
I created a content type called successful story.

In user profile page user-profile.tpl.php, I have inserted a link to create a successful story

<?php print l(t('Add a successful story'), "node/add/successful-story"); ?>

For example, an user called user1 clicks on the link, and creates a successful story.
I want to display the successful story the user created into their respective profile page

I add this code into template.php

<?php

function mytheme_preprocess_page(&$variables, $hook) {
  global $user;
  $uid = $user->uid;
  $nid = db_query("SELECT nid FROM {node} WHERE uid = :uid AND type = :type", array(":uid" => $uid, ":type" => 'successful story'))->fetchCol();
  $variables['ss_node'] = drupal_render(node_view(node_load($nid)));
}

?>

Then I add this code into user-profile.tpl.php

<?php

  global $user;
  $user_id = arg(1);

print $ss_node;

?>

I hope I'm clear. Thanks for your help !


texts: Formatting labels of Webform2PDF for submissions

texts:
How would I go about changing style for all the labels for pdf generated from submissions to a webform.
I could explicitly state each [submission:values:email:label] and then provide values with separate tokens but this would be laborious for a big webform and I have several big webforms.
Is there a way to make it that labels are for example bold and values are not?


texts: Custom price in case of selecting PayPal payment method

texts:
There is a site with goods on Drupal Commerce.

The client asked him to make special arrangements for visitors of the site, who pay for goods through PayPal. Because there're commissions of PayPal and the client does not want to loose money because of them, but wants when choosing Paypal as a method of payment the price to be increased by 4%.

How to make price variations depending on the choice of method or do I need to try to make it with the Rules module?

There are 3 payment methods on the website:

Bank Transfer
Pay in Person
Paypal

What I did by now:

I created a TAX that adds to a price by 0.04%.

I created a rule:

Event
Calculating the sell price of a product

Conditions

Selected payment method comparison
Parameter: Order: [site:current-cart-order], Payment method: PayPal WPS

NOT Selected payment method comparison
Parameter: Order: [site:current-cart-order], Payment method: Bank Transfer

NOT Selected payment method comparison
Parameter: Order: [site:current-cart-order], Payment method: Pay in person

Actions

Apply a tax rate to a line item
Parameter: Line item: [commerce_line_item], Tax rate: PayPal tax
Provides variables: Applied tax (applied_tax)

In Checkout settings (admin/commerce/config/checkout) I moved admin/commerce/config/checkout

to the checkout pane.

But the commission is added to all products. No matter what payment method is chosen. Do you have any idea how to make it work?


texts:
Back in Drupal 7 I never needed the main_page_content to be a block. Now that I am Working with Drupal 8 I need such a logic for the first time.

Is there a way to wrap the main_page_content into a block or any wrapper without wrapping the whole content region?


texts: How to migrate Drupal Commerce configuration between environments

texts:
I'd normally use features to migrate changes from a dev server to a live one, however it seems drupal commerce doesn't fully support features, which leaves me in a tight spot.

How would you suggest to migrate the changes over without causing disruption? The live site is updated constantly.

Any help would be much appreciated.


texts: How to export content type with scheduler's settings using features

texts:
In my dev environnement, I've installed Features module for exporting the content types of my site. I've also installed Scheduler module to schedule for publishing my contents.
On the admin page of my content type, I enabled scheduled publishing for my content type. Then I created the features of the content type. However after importing of features to the prod, I've found that the scheduler's settings to content type were not imported.

Does anybody know why? Is there any module supporting to resolve this problem?
Thanks in advance.


texts: How to add nodes inside admin area, e.g. for admin documentation

texts:
I have an admin theme set. When I create a page in my custom module with an admin/... path it is rendered with the admin theme.

I've set up a node type for documentation and I'd like these to be inside the admin area. I've set the default menu to Management and I've given the page an alias that begins with admin/ but it's rendered in the normal (non-admin) theme.

How can I add nodes that will be considered part of the admin area, and rendered with the admin theme?


texts: How to abort the ajax request and redirect in the ajax callback of form element

texts: I want to redirect the page in the ajax callback function, and nothing (like "header", "drupal_goto" etc.) works for redirect in the ajax callback function.


texts:
I'm quite new to Drupal, and I'm still in learning process. I've installed a pure Drupal 8, and installed a the YG Agency theme. Right now the theme is only blank. Is it possible to load some test data into the theme, as it is displayed in the Demo?

http://demo.drupalfreethemes.com/drupal/free-themes/yg_agency/

I know this can be done is many WordPress themes? Does Drupal support importing test data to themes as well?


texts:
I have an endpoint, which is active and working for more than a year, and I recently had the need to add a new endpoint, which obviously has a different url ("Path to endpoint").

For both, however, I need to use the login functionality, and other custom actions (each one has its own url, callback and access callback, in two separated custom modules).

But on every call, i can see that both endpoints are being requested, all arguments are being doubled etc. Here's the $controller as seen from hook_services_request_preprocess_alter:

Array
(
    [help] => Array
        (
            [0] => Description from endpoint 1
            [1] => Description from endpoint 2
        )

    [callback] => Array
        (
            [0] => MY_FIRST_MODULE_callback_function
            [1] => MY_SECOND_MODULE_callback_function
        )

    [access callback] => Array
        (
            [0] => MY_FIRST_MODULE_access_callback_function
            [1] => MY_SECOND_MODULE_access_callback_function
        )

    [args] => Array
        (
            [0] => Array
                (
                    [name] => email
                    [type] => string
                    [description] => Email
                    [source] => Array
                        (
                            [data] => email
                        )

                    [optional] => 1
                )

            [1] => Array
                (
                    [name] => email
                    [type] => string
                    [description] => Email
                    [source] => Array
                        (
                            [data] => email
                        )

                    [optional] => 1
                )

        )

    [etc] => ....

)

This happens whichever url is requested, it's causing both the iOS and Android apps to crash, and i couldn't find a way around it.

What should / can I do to run both endpoint independently, and why are both getting invoked even if the url ("Path to endpoint") is different?


texts: Is it better to start a Drupal theme from scratch or extend an existing one?

texts:
I am new to Drupal and am curious if it is better to start a theme from scratch, or extend one that is already out there. Also, are there any resources out there that someone could point me towards?

I am using Drupal 7.8.


texts: What is the syntax for using a token on webform confirmation page for Drupal 7 Webform 4

texts:
I have an Email field on my webform with the key email_address. On successful webform submission, I would like to display the confirmation message as.

Further instructions have been sent to xyz@yahoo.com [Email Address which is submitted on the webform]

I tried using

  [webform:val-email_address]
  [submission:values:email_adddress]

With no luck. The text format is Safe HTML. Not sure if this is causing that
This is on Drupal 7 - Webform version 4.1

Thanks.


texts:
Please help me.I am searching for a content slider in Drupal 7 .

I have created a view for displaying products.A block is created for this view.

My requirement:

I need a content slider with 2 columns and two rows.All the view items should be displayed in the slider.There will be four node contents in each slider.

eg:    row1   row1
       row2   row2

Please find the attached screen shot .I hope this may help more.


texts:
I am building a web application (for trusted users), so the logged in user will have the ability to add content. However currently, when the user wants to add a record, they move from the frontend theme to the Admin UI, (the "Content > Add Content > Article" page).

This looks unprofessional, and I don't really want non-technical users let loose on the Admin UI.

How can I create "frontend" pages to let the user Add New Nodes or Edit Nodes?

(Essentially, I want to mimic the Add Article and Edit Article screens, but on the frontend of the site).

I'm not afraid of a bit of custom coding if necessary, but need to be pointed in the right direction!


texts: Facing trouble in insertion of data in to table after creating table by using hook_update_N function

texts: I have created a table by using hook_update_N() function. After creation, if i am trying to insert data into table but it is not storing. Is there any thing else is there to do after creating table by using hook_update_N()..?


texts: How do I programmatically retrieve the inputs from a form?

texts:
I am implementing a hook_form_alter in my custom module and I want to get all the inputs from the $form variable.

So, if for example there is a textarea, a radio button and a checkbox, I want to grab these elements and put them in a clean array for later use. What I basically want to do down the road is create a dropdown list and have these inputs as the options in the list.

Is this a clean way to do that through the FAPI?


texts:
Is it possible to get the menu item of a certain content type through the API?

The idea is to improve Markus Orenstrat solution to set the active trail based on the content type. As it stands it requires hardcoding the menu_tree id in the service.

 if ($bundle == 'blog') {
   $plugin_id = 'menu_link_content:a00a209d-075e-46a2-b200-e2d439d92228b';
 }

I figured this could be avoided since the administration area allows to assign a menu item to a content type.


texts:
I am writing 2 modules, one dependent on the other and both extend the user profile page. The first one is order_history and the other one order_details. The concept is order_history pulls out a list of all orders and order_details displays only 1 order but with details.

Now the problems are:

I am able to access http://localhost/drupal/user/1/order_history
and I get the table. But when I click on the link, I am taken to
http://localhost/drupal/user/1/1001.
When I directly put the url http://localhost/drupal/user/1/order_history/1001, I see the order_history table but not the message.

Can't figure out what's wrong with the code. Please point to the right direction.

So here is the code for both:

order_history.module

function order_history_menu(){
    $items = array();
    $items['user/%user/order_history'] = array(
        'title'             =>  'Order History',
        'page callback'     =>  'drupal_get_form',
        'page arguments'    =>  array('order_history_form'),
        'access arguments'  =>  array('access order history'),
        'type'              =>  MENU_LOCAL_TASK,
        );
    return $items;
}

function order_history_form($form) {
    $output_form='

            Order Number
            Order Date
            Order Status
            Amount

                1001

            2014-04-01
            Shipped by seller
            $468.89

';

    $form['order_history'] = array(
                    '#type' => 'markup',
                    '#title' => t('Order History'),
                    '#markup' => drupal_render($output_form),
            );
    return $form;
}

order_details.module :

function order_details_menu(){
    $items = array();
    $items['user/%user/order_history/%order_number'] = array(
        'title'             =>  'Order Details',
        'page callback'     =>  'order_details',
        'page arguments'    =>  array('%user','%order_number'),
        'access arguments'  =>  array('access order details'),
        'type'              =>  MENU_LOCAL_TASK,
        );
    return $items;
}

function order_details($user, $order_number){
    drupal_set_message('Response from order details.');
}


texts:
I want to add some custom checks to all of my Drupal pages (except the administration pages).

I am using Bartik theme that comes with Drupal 7.26

I added the custom check in node.tpl.php and the check worked for all urls of type /node/%

However, I also want to add this check for node add, edit and delete pages.
I cannot do this.

What I have already tried:
-> Creating a node--add.tpl.php in bartik folder and adding check there.
-> Creating a custom module, and using hook_menu to route /node/%/id to a custom page.
-> Adding this function

function bartik_preprocess_page(&$vars, $hook) {
  if ((arg(0) == 'node') && (arg(1) == 'add' && arg(2) == 'product')) {
    $vars['template_files'][] =  'node-add-product';
  }
}

in my bartik template.php file. After adding this function I created node-add-product.tpl.php file and added check there.

For all the methods I have tried, the node creation page does not change at all.

I also tried creating page--node--add.tpl.php. Then the custom check works. But the header, footer, and sidebars disappears. (Only node creation template is rendered)


texts: How to deal with exploding node_access queries?

texts:
I'm working on a pretty complex workflow site, which has a number of interlocking levels of components (content types, really).  To summarize and simplify a bit:

Users can create Companies.
Companies can have Projects and Members (other users affiliated with
the companies).
Projects can have tasks.

Each of these things have access controls::

Companies can be public, private, or member-only
Projects can be public, private, or member-only (but limited by the
company specification)
Tasks are member-only

This gets (more) complicated in a couple of ways:

Users can have different roles in Companies and Projects (admin,
user, visitor, and such)
The access rights of the higher-level thing can determine and even override the rights of the lower-level things: If a Project is marked member-only, that Project's tasks can only be seen by other members of the Company that owns the Project.  In the same way, changes to Company access rights determine the actual access rights of Projects and Tasks.  For instance, if a Company's status is changed from public to private, access to all its Projects and Tasks are blocked to everyone but the company's owner, even if they're marked Public.

I've gotten this working by setting up a collection of node_access functions for the various components.  These install appropriate access rights into the node_access table based on the components' access settings.  A parallel set of node_grants functions then build up comparable sets of grants for each of the users, based on their roles in the organization.

The good news is that this actually works.  The bad news is that the queries being run against the database are getting huge, as the node_access mechanism produces a very large number of query clauses, each looking to see how the user's roles line up against the various kinds of access rights.  For instance, there's a whole string of clauses testing, for each task, whether the user is a member of the project that contains that task.  There's then another string of clauses testing whether the user is an admin of the project, and another string testing whether the user is a visitor to the project.  And so on, leading to a future where these queries become larger and larger and worse and worse as the site becomes more successful and people put more projects and tasks into it.  Blurgh.

So (finally), my question: Is this just the inevitable cost of living with Drupal and its node_access architecture?  Is there another way I can control access to all these pieces of stuff without having the database calls explode on me the way they seem to be?  I'm not looking for a free lunch, but I'm getting more and more worried about the complexity of these access routines and the amount of money I'm likely to have to pour into database servers to keep things running.  Any advice out there?