texts: What Hook to Use to Execute a PHP on Header and Footer in Every Page?

texts:
I have the following code that needs to be executed at the top of the page:

<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
?>

The code above should be used in my module:

<?php
/**
 * Implements hook_help.
 *
 * Displays help and module information.
 *
 * @param path
 *   Which path of the site we're using to display help
 * @param arg
 *   Array that holds the current path as returned from arg() function
 */
function site_visitors_help($path, $arg) {
    switch ($path) {
    case "admin/help#site_visitors":
        return '<p>' . t("Displays links to nodes created on this date") . '</p>';
        break;
    }
}

/**
 * Implements hook_init().
 */
function site_visitors_boot() {
    site_visitors_insert();
}

/**
 * Custom visitor function.
 *
 * Insert IP Address, URL to the database
 *
 * @return
 *   A result set of the targeted posts.
 */
function site_visitors_insert(){
    $tracker = array(
        'database' => 'c1tracker',
        'username' => 'c1tracker',
        'password' => 'mypass',
        'host' => 'localhost',
        'driver' => 'mysql',
    );

    Database::addConnectionInfo('tracker', 'default', $tracker);
    db_set_active('tracker');

    //This code requires the code above to compute the start time. This will compute the total page load.
    $time = microtime();
    $time = explode(' ', $time);
    $time = $time[1] + $time[0];
    $finish = $time;
    $total_time = round(($finish - $start), 4);
    $t = $total_time;
    //$url = $_GET['url'];
    $url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    $current_ip = $_SERVER['REMOTE_ADDR'];
    $user_agent = $_SERVER['HTTP_USER_AGENT'];
    $date = date("Y-m-d");
    $time =  date("h:i:s");

    function is_bot()
    {
        $botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi",
        "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory",
        "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot",
        "crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp",
        "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz",
        "Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot",
        "Mediapartners-Google", "Sogou web spider", "WebAlta Crawler","TweetmemeBot",
        "Butterfly","Twitturls","Me.dium","Twiceler");

        foreach($botlist as $bot)
        {
            if(strpos($_SERVER['HTTP_USER_AGENT'], $bot) !== false)
            return true;
        }
    return false;
    }

    if (is_bot())
        $isbot = 1;
    else
        $isbot = 0;

    db_insert('ap_visits')
        ->fields(array(
            'id' => NULL,
            'length' => $t,
            'url' => $url,
            'current_ip' => $current_ip,
            'user_agent' => $user_agent,
            'date_start' => date("Y-m-d H:i:s"),
            'is_bot' => $isbot,
            'is_logout' => 0
        ))
        ->execute();

    db_set_active();
}

I'm wondering how can I put the first code to be called at the very top of the page and the second code (module) to be called in the footer. My purpose here is to compute the page load and put it in length variable.

BTW, I'm using drupal 7.


texts: How to have #description in form to be below title and above field?

texts:
How can I place Description below Title and above field ?

 $form['term-selection']['autocomplete'] = array(
      '#title' => variable_get('autocomplete_sync_shs_autocomplete_headline',t('Type in directly')),
      '#description' => variable_get('autocomplete_sync_shs_autocomplete_info',t('')),
      '#type' => 'textfield',
      '#autocomplete_path' => 'third-level-auto-suggest/autocomplete-taxonomy-term/'.$field_name.'/'.$entity_type.'/' . $node_type ,
      '#states' => array(
         'disabled' => array(
           ':input[name="widget-selection"]' => array('value' => 1 ),
         ),
      ),
      '#default_value' => $default_autocomplete,
    );

The output I get is


texts: How to display nodes based on the taxonomy terms of the current logged in user, with multiple vocabularies?

texts:
Say I have 3 taxonomy vocabularies:

Products, Professions and Support

Each vocabulary has 2 terms:

Products -> product1, product2

Professions -> profession1, profession2

Support -> support1, support2

Users can be tagged with terms. User A is tagged with:

product1 and support1

Nodes can be tagged with terms. Node 1 is tagged with:

product1

Node 2 is tagged with:

support1

Node 3 is tagged with:

profession1

So when User A logs in and goes to the view, they should see Node 1 and Node 2 only. I can't seem to achieve this in views. It's possible when there is just one vocabulary, but i can't seem to get it done when there are multiple vocabularies involved. Can anyone help without coding? Or perhaps I need to use code?


texts: Is a module available that can add a particular field on the search page?  I'd like for user's to see an image-field if applicable.


texts: How to override the core function format_xml_elements()?

texts:
format_xml_elements() is defined in the core includes/common.inc file. I want to manipulate some parts of this code, but there is no way to hook into this.

How could I achieve this without hacking core?


texts: delete or disable service endpoints programmatically?

texts:
I am trying to programmatically disable a service endpoint, but I am not able to achieve it using the following code.

$endpoint = services_endpoint_load('my_service');
$endpoint->disabled = TRUE;
services_endpoint_save($endpoint);

Is there any other way to disable the service endpoint?
Is it possible to delete it?


texts:
Relevant modules & themes:

zurb_foundation-7.x-4.0
views-7.x-3.11
jquery_update-7.x-2.6 (front-end using 1.7 and backend using 1.5)

I have an exposed views filter on the front page that is auto-submitting when the dropdown field changes. I'm using Zurb Foundation base them (v4) along with the 'custom' field style. Here's what my view and filter looks like:

When I choose another option, I get this:

The weird thing is that watching views/ajax with a debugger, Drupal generates a proper response but jQuery presents the error alert even before the debugger acknowledges the debugging request. There is no "error" showing up in the Drupal or Apache logs. Once you click "OK" the page refreshes and the block shows the proper information based on the date selected.


texts:
I created a member directory using view and it works well but I tried enable "Exposed form". I changed "Exposed form in block" to Yes & also  "Use AJAX" to Yes.
I defined "Contextual filters" to " User: Name ". then I went to Blocks and Enabled the new block and edited Only the listed pages and put the path but nothing shows up there.
here's my View :
here's my block:
final demo:

ok, I created that with Filter Criteria, now the search fields show up at the top of the view, how can i put them in sidebar of this view?
final result:


texts:
I'm theming a view which name is testimonials, I would like to make the view block a slider, so I'm creating the twig file as views-view-unformatted--testimonials.html.twig.

When I inspect I'm getting {{ row.content }} from the default template. I would like to give div to each and every field I'm getting inside the twig.

How do I access the field contents in the twig.

I've a number of views for each view, I would like to theme it different ways, so can I created views-view-fields for each view?


texts: How to get Webform Field data for a custom module?

texts:
I'm trying to set up a view permission based on a webform field.  I've been able to get to my custom module using hook_webform_submission_access().

So I have an email field in the webform, and I want to check that based on the current user's email address.  Should be pretty simple, I just can't get the field data.  Anyone know?

Example:

if ($submission->data['field_email'] == $user->mail)

What is the correct syntax instead of $submission->data['field_email']

I'm on Drupal 7 and Webform 4.x branch.


texts: Enabling HTML in MENU_LOCAL_TASK titles (primary tabs)

texts:
I would like to place a <br /> tag in my MENU_LOCAL_TASK titles so that I can reduce the width of the primary tabs.

It seems that in theme_menu_local_task the link title is run through check_plain, but when I remark this line out only the link title of the active tab responds. All the inactive tab link title are still being sanitized.

Basically, I want to have HTML in my MENU_LOCAL_TASK titles - without using any contrib modules.

Any ideas? Thanks.


texts: Private fields not able to access in draft mode

texts:
Private fields attached to old revisions are not accessible to download when the new revision(Latest revision) of the node is in draft.

How to make it to download the files.


texts: 'default_value' plugin does not run if 'get' returns null or empty value

texts:
I’ve got a D7 to D8 migration where I’m trying to migrate a field with a null value in D7 to a default value in D8. Process pipeline is similar to this:

  field_privacy:
    -
      plugin: get
      source: field_office_privacy
    -
      plugin: default_value
      default_value: 'open’

It seems if the field value is null, the default_value plugin never runs.

When D7 has a non-null value, then the field migrates perfectly via the get plugin. The D8 API documentation gives this pipeline as an example of exactly what I'm trying to do, yet I cannot get it to work. When I should get a value for all 164 items selected by the migration source, I instead only get 132, which precisely matches the number of fields in D7 that have non-null values.

How can I set a default value when get doesn't find a value?


texts:
I have a view that includes a date field that only uses the year part.  I want provide a default filter value for this field based on the current date.  So far, I have this

function results_view_views_pre_view(&$view, &$display_id, &$args) {
  if($view->name == 'results_view') {
    $year = date("Y");
    $view->display['default']->handler->options['title'] = $year . ' Results';
    $view->display['page']->handler->options['filters']['field_season_value']['value']['value'] =  = $year;
  }
}

This doesn't throw any errors but the filter view isn't filtered

I'm not sure what I'm doing wrong here, or if I'm even going down the right path.  The value I assigned above is based on the fact that when I hard code the year into my view, the view object looks like this

[field_season_value] => Array
(
        [id] => field_season_value
        [table] => field_data_field_season
        [field] => field_season_value
        [relationship] => none
        [group_type] => group
        [ui_name] =>
        [operator] => =
        [value] => Array
                (
                        [min] =>
                        [max] =>
                        [value] => 2013
                        [type] => date
                )

Just to clarify, the date field is based on a fiscal year that runs September through August. So if its May 2013, the date would need to be 2012. My example above is just a simplified version if what I'm going to need to do in the final version.


texts: Invalidate cache on ConfigFormBase submit

texts:
I have a ConfigFormBase called TextConfiguration where I have defined several fields for the address, phone number, etc...

These variables are shown in the contact form on my website. When I modify them and enter as anonymous in /contact, the value is not updated.

I've tried this in my ConfigFormBase form submit, but it does not work.

// Additionally, clear cache to prevent mismatch data.
$tags = $this->config(static::COMPET_SETTINGS)->getCacheTags();
if ($tags) {
  Cache::invalidateTags($tags);
}

I'm doing something wrong? I need to configure or do something to get it to update the data when a value is changed? Thanks all!

Edit: Example of how I'm rendering the fields.


texts: How to fix the Feeds import error when trying to import a price field?

texts:
I have a little problem with Feeds module, I read a lot on forums how to fix this error but I can't find a fix...

I'm importing products to the shop, this module can import thing pretty well but when I add list_price or sell_price to the mapping the import is stuck.

I get this error:

  SQLSTATE[HY000]: General error: 1366 Incorrect decimal value: '' for
  column 'list_price' at row 1

Yes I use CSV files, with utf8 encoding.

Don't know why I get this error I just write into the column for the price: 20.10

array(
  'név' => '100% BEEF Concentrate 1000g',
  'cikkszám' => '1',
  'description' => 'Tartalom',
  'image' => 'scitec_100_beef_concentrate_1000g_caramel_vanilla.png',
  'catalog' => 'Proteíny',
  'gyártók' => 'Scitec Nutrition',
  'nyelv' => 'sk',
  'súly' => '1000',
  'mértékegység' => 'g',
  'listázási ár' => '21.00',
  'akció' => 'uncheck',
  'kiemelt' => 'uncheck',
  'újdonság' => 'check',
)

Is this possible to fix somehow?

Another small question is that how can I check and uncheck chechboxes with feeds? What should I write into the CSV column?


texts: I want to rewrite a hook comment_node_links_alter. How can I do it? I created a file THEME.theme in my theme, placed there THEME_comment_node_links_alter but it is not called. I cannot find any distinct information how to rewrite hooks. I observed bartik.theme and saw that all hooks are prepended with a theme name. I did the same. Did clear the cache. My funciton is included, I checked with xdebug. But it is never called.


texts: How to join values of multiple geofields in a view?

texts:
I have a content type in which the site of organizations are displayed in a leaflet map with the help of an addressfield. (And all organizations are displayed in a joint map.) But certain organizations don't have convertible postal address, therefore geocoding from addressfield doesn't work. For these organizations I created a second geofiled in which I add latitude/longitude values manually.

The problem is that the display of leaflet map in Views can handle only one field as the source of geodata. Is it possible to combine these two geofields into one?


texts: Custom submit handler: how to create node?

texts:
I created a form_node_alter for a content type called "banner" and I made a custom submit handler named "mymodule_check_submit_handler()".
Everything is ok, I can do what I want in the submit handler function but I don't know how to create the node of type "banner" once I executed my custom code.

Searching for a solution I found this code:

$values = $form_state->getValues();
$node = entity_create('node', $values);
$node->save();

But now I got this error: Error: Call to a member function getValues() on array in mymodule_check_submit_handler()

How can I create the node in my custom submit handler?


texts:
So I have a SWF file, the path is working fine, I have it displayed in the main node just fine.

However when I try to put it in the right side bar, it just does not display.

Could it be a height/width issue? What's the optimal way to display it? PHP code? filtered HTML?

Sorry if this question is a bit vague - I'm trying to understand more of what would cause a video to not display at all, even in the source.


texts: Turn location CCK 'city' field into taxonomy autocomplete field

texts:
I am using the "Taxonomize Location" module to automatically save all Location CCK Field submissions into the "location" taxonomy. Terms in the location taxonomy are saved in 3 layers: Country -> Province -> City.

The location CCK field offers Country and Province as select lists, and City merely as a text field. Is it possible to display the City field as an autocomplete field that pulls city suggestions from the third layer of my location taxonomy, depending on what Country and Province was selected?


texts: Why bootstrap sub-theme with sass starterkit is not working?

texts:
I am trying Bootstrap 7.x-3.6 theme.

But sub-theme for some reason is not working. I did follow the same procedure as described on the Documentation page for Drupal 7.

I am describing here, what I did,

1. Installed fresh drupal 7.50 on localhost.
2. Down loaded Bootsrtap 7.x-3.6 and enabled but not make is default.
3. Sub-theme: I did copy sass folder from the starterkits. Paste in /theme folder and rename with mysubtheme. Rename the file-name sass.starterkit with mysubtheme.info. And inside that changed the 'name'.

Final image of /theme folder

4. Downloding Bootstrap: Downloaded bootstrap file from here as decribed in following image. I did select Sass option. Pasted to /mysubtheme folder, rename with bootsrtap.(even to check, I did try all three options one by one, but same result)

5. Downloaded Jquery update module also and enabled, default version was 1.50.

Now, Till this stage the site shows content but not a basic theme formatting. Comparative image below.

What could be the reason or I am missing something.


texts: How to fix Drupal commons 7.x-3 OgException

texts:
Problem is fixed in new version commons 7.x-3.3-rc4
https://drupal.org/node/2067473

Modules:

Organic groups 7.x.2.3
Organic groups access control  7.x.2.3

The content access permissions have been rebuilt.

In OG field settings (as default)
User-User entity
Group visibility Determine access to the group
Group            Determine if this should be a group

I created a Private group with "Joining requires an invitation"
trying to add a post to the group I get following exception:

  OgException: Cannot set visibility of node ID 13 as the group node of
  type "user"  does not have the "Group visibility" field attached to
  it.  in _og_access_verify_access_field_existence()  (line 250 of
  srv/www/htdocs/commons7x33rc2/profiles/commons/modules/contrib/og/og_access/og_access.module).

The same happens with a Public group with "Any site member can contribute"

What is wrong and how do I fix this?


texts:
Currently if using media module and users can upload pictures, they are presented with modal window where they can select a file for upload. On the same page there is a dropdown for selecting folder (taxonomy) and on second page there are fields for adding alt aln title text. Which is quite complicated for uploading one picture.
Question:Is there any way of simplifying the process? Setting default upload directory for users and not to be asked to fill alt title fields?
Thank you.


texts: How can I tell Drush in which folder should a module be copied?

texts:
Is there a way to make Drush download modules into a specified folder besides sites/all/modules (e.g. sites/all/contrib, sites/all/core)?

If this makes a difference, I am using Drush 4.4.


texts: How to attach generated pdf only in email with webform?

texts:
On my application form, I have generated a pdf document with informations from the application.
On my application form there are other files and images, but I only want to send pdf attachment that I have generated with entity_print module and TCPDF.I don't want other files that have been uploaded when user complete the form.
I have made a screenshot of my parameters to do that, but in emails I receive all the time in attachment:

a generated pdf document with TCPDF from entity print module
a picture
additional document

How can I do only received a generated pdf document with TCPDF from entity print module?


texts: How to add incremental classes to an (Multiupload Filefield Widget) image field

texts:
I was hoping some one can help me to add class in to a field that is using the Multiupload (7.x.1.13), Multiupload Filefield Widget (7.x.13) as well as the Colorbox (7.x-2.5) module. I have a view which outputs the following markup:

I was trying to be able to add classes into the img tag and to do it using a loop so that you end up with myclass1, myclass2...myclass6...

However, there seems to be an issue with Views and Multiupload as Views Style Settings also appear to be disabled. By that I mean if you try to for example check the "Customize field HTML" check box, the settings are not saved. The same is true for the other style setting options.

I apologise for my original post, nooby mistake, please forgive me.


texts: No default selection in a select item on commerce checkout pages using hook_form_alter

texts:
Thanks to the help I received in my previous question, I was able to change the HTML of shipping service from radios to a select field. This was done, as suggested, by means of a custom module implementing hook_form_alter.

function MYMODULE_form_alter(&$form, &$form_state, $form_id){
    if ($form_id=='commerce_checkout_form_checkout') {
        $form['commerce_shipping']['shipping_service']['#type']='select';
    }
}

Now what i need is to have an empty option ("select the proper value") in it, so that the user would be forced to actively choose one of the shipping methods.
What I get from

print_r($form);

is

    [shipping_service] => Array
                (
                [#type] => radios
                [#options] => Array
                    (
                        [deli] => Delivery : 5,00
                        [pickup] => Pickup: 0,00
                    )
                [#ajax] => Array
                    (
                        [callback] => commerce_shipping_pane_service_details_refresh
                        [wrapper] => commerce-shipping-service-details
                    )

                [deli] => Array
                    (
                        [#description] =>
                    )

                [pickup] => Array
                    (
                        [#description] =>
                    )

                [#default_value] => deli
            )

        [service_details] => Array
            (
                [#type] => container
                [#prefix] =>

                [#suffix] =>

            )

I tried to tinker with dafault value, inserting another option, like

$form['commerce_shipping']['shipping_service']['#options']['_none']='['-select-']';
$form['commerce_shipping']['shipping_service']['#options']['#default_value']='['_none']';

(which was somewhat randomly inspired by the 'print_r' output from a taxonomy term field on the same form  but brought no results and did cause AJAX errors.
Any ideas?


texts: How to programmatically get webform drafts for a specific user?

texts:
How to fetch all the webform drafts saved based on user id?
I tried the below query and it gives me all submission id's but how do I get just the drafts
$query = \Drupal::entityQuery('webform_submission')
      ->condition('uid', 123)
      ->condition('webform_id','test_1');


texts: Field Max Size limited to 10 for Integer in Number Module

texts: I'm trying to add an Integer as a new field to Users. Have installed the Number module and added a field type 'Integer' with a maximum value of 999999999999999999. But when I edit a user the field has a max length of 10. Is there a way to edit this?


texts: Custom 500 Error page: Is there a way to theme a fatal error?

texts:
In /core/includes/errors.inc, when there is a fatal error it outputs a response with the message "The website encountered an unexpected error. Please try again later." and a back-trace, if error_level is set to verbose, and without the back-trace otherwise.

It seems like at this point, there's no way, with an event subscriber to capture the response and alter it.

Is that correct?

Or is there a way to wrap the output from line 268 of errors.inc in Drupal 8.4 with markup?

Note, there's another answer that works if it's not a fatal error, but that doesn't offer a complete solution.

Also, I looked into .htaccess and Apache ErrorDocument directive, but that was misguided. Once Apache passes off to PHP, it can no longer use that directive.  That's for real server errors.


texts: Getting a formatted address component in another field's template

texts:
I need to pull the administrative area component from an Address field and place the full text of it it in the template of another field on the content type. I've managed to accomplish this with the following code.

In preprocess:

function MYTHEME_preprocess_page_title(&$variables) {
$node = \Drupal::request()->attributes->get('node');
  $variables['content_type'] = $node->bundle();
  if ($node->bundle() == 'location') {
    $variables['address_state'] = $node->get('field_address')->getValue()[0]['administrative_area'];
  }
}

And in the twig template:

{% if content_type == 'location' %}
  <h1{{ title_attributes }}>{% spaceless %}{{ title }}{% endspaceless %}{% spaceless %},{% endspaceless %} {{ address_state }}</h1>
{% endif %}

This will produce, for example "Boston, MA". But what I want is "Boston, Massachusetts", using the full name of the administrative area rather than the code. According to Drupal Commerce Address docs, you can get the full name in a twig template using {{ administrative_area.name }}. But I couldn't get that to work. How can I render the full administrative area name in the template?


texts: Using Fieldgroups with Entity Registration Module

texts:
I'm using the Entity Registration module to create event signup forms.  I've got my first event registration form up and running and now want to group some of the fields into fieldsets.

I have the Field Group module installed, and have used it to group my fields into fieldsets (via Manage Display):

The effect I want to achieve is something like this:

However the fieldsets are not showing on the registration form or in the markup:

According to Field Group module, it should work with any entity:

  Fieldgroup will, as the name implies, group fields together.  All fieldable entities will have the possibility to add groups to wrap their fields together.

I've searched the Entity Registration issue queue, but can't find anything relating to this.  Has anyone managed to get fieldsets working with Entity Registration?


texts: How to return the whole entity referenced by a entity reference field with views

texts:
I have content type A with a entity reference field that references a user (let's name it field_user_reference). The user has field_b and field_c field.
I've created a rest export view to return all nodes of type A with it's field which includes field_user_reference. My problem now is that the field_user_reference exported by views only contains the user's name. How do i also include the user's id, field_b and field_c?

The view returning something like this would be optimal:

[{"nid":"1","title":"title","field_user_reference":[{"uid":"1","name":"username","field_b":"valueb","field_c":"valuec"}]}]


texts: I want the site's name\logo to appear in a column in a Panels pane (instead of it's regular appearance in the header region). is there any way to achieve this without programing?


texts:
I'm brand new at making custom forms and I'm having trouble getting the link field to save to the database.

The text body field saves fine but the link field object defined below it does not. I'm sure that this is an easy fix but I haven't been able to find proper documentation on adding the link field to custom forms.

Thanks in advance.

    /**
* Implements hook_block_configure().
*/

function My_Module_block_configure($delta='') {
$form = array();

switch($delta) {
case 'my_module' :
    // Text field form element
    $form['text_body'] = array(
        '#type' => 'text_format',
        '#title' => t('Enter your text here in WYSIWYG format'),
        '#default_value' => variable_get('text_variable', ''),
     );

     //link field
    $form['link'] = array(
        '#type' => 'link_field',
        '#size' => 20,
        '#field_name' => 'link',
    );

    break;
}
return $form;
}

/**
* Implements hook_block_save().
*/
function My_Module_block_save($delta = '', $edit = array()) {
    switch($delta) {
    case 'my_module' :
        // Saving the WYSIWYG text
        variable_set('text_variable', $edit['text_body']['value']);
        variable_set('link_variable', $edit['link']['value']);

        break;
    }
}


texts: Drupal redirect from https to http except some urls

texts:
I'm trying to redirect all https traffic to http except for a url. I wrote the redirection rule but I don't understand why for this url I want to exclude I'm redirected to index.php. For all the others the redirection is ok.

The .htaccess file is the one that comes by default with Drupal 7. Before the redirection to index.php I added the following rewriting rule (the first 3 lines of code):

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/custom-url
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]

So with the above rules I have:

https:// drupal.local/custom-url redirects to http:// drupal.local/index.php

https:// drupal.local/any/other-url redirects to http:// drupal.local/any/other-url

And I want that:

https:// drupal.local/custom-url to not redirect to anything and to remain like it is, on https.

Any help is appreciated.


texts:
I have a Drupal 8 site with a contact form that has a lot of fields. I need to duplicate these fields onto another Drupal 8 site but can't find where they are stored in the DB.

In the config table there is a row per field, but when I try to copy these across, I get this message:

  Drupal\Core\Field\FieldException: Attempt to create a field my_field_name that does not exist on entity type contact_message. in Drupal\field\Entity\FieldConfig->getFieldStorageDefinition() (line 286 of core/modules/field/src/Entity/FieldConfig.php).

Does anyone know if it's possible to copy the contact form fields to another site via the Database?


texts:
I've got a function that should generate a link as such Set Password, which does happen, but it is generating as plain text.

My guess is that this is due to my use of the t() and l() functions in the manner I'm using them.

Here's my code:

  global $user;
  $account = new stdClass();
  $account->uid = $user->uid;
  $account->login = $user->login;
  $account->pass = $user->pass;
  $link = l('Set Password', user_pass_reset_url($account));
  $token = t(token_replace(variable_get('listing_edit_free_activated_page', 'Your free content has been activated. Thanks! @link')), array('@link' => $link));

As you can tell, I'm attempting to generate a one-time user login link with the text, "Set Password". The token_replace() isn't really relevant to this problem.

Am I completely without options here? I want to use both t() and l() here - there's not really an easy way to not use both that I can see.

How do I use both while still maintaining the structure of $link as a link?


texts: User is notified when new content is created using Rules

texts:
I created two groups in one group type.

Job Post
Business

Each group has its own content type(same label) and group permissions.

User Story:

"As a user(Job Post) I would like to be able to create a job. A job should contain a description and a job type - for example, plumbing."

As a plumber(Business) I would like to be notified every time a new job is posted that is for plumbing, but not for any other types of work."

How specifically can this be achieve using Rules as I'm a newbie on this module and still trying hard to make setup on this problem.


texts:
Why should I use EntityFieldQuery when I can do the same work with Db_select() to fetch the value.

It would be better if someone can provide an example, not only a link.


texts: What is the SQL query to filter og Admin Accounts?

texts:
I currently have the following SQL statement that gives me a list of all of my og nodes and their associated owner. I am having trouble nesting my JOIN statements to add the name of the owner from the users table. Any hints? Thanks

SELECT
    label AS `Group Name`,
    gid AS `Group ID`,
    etid AS `Node ID`,
    type AS `Type`,
    b.nid AS `Owner ID`
    FROM `prefix_og` a
        LEFT JOIN `prefix_node` b
            ON a.etid=b.nid


texts: how to remove anonymous user role from list of profile members

texts: I want to remove anonymous role member from the public list of profile users because anonymous roles cannot join so it is confusing to see the anonymous user at top of public profile list.


texts: How can I get final URL of newly added node from hook_node_insert()?

texts:
I have installed pathauto and implemented hook_node_insert in my module, the problem is when I use entity_uri to get new node's URL I will get node/xxx instead of pathauto url alias.

How can I get final URL of the node, after ALL other modules had their manipulations?

function HOOK_node_insert($node) {
    $uri = entity_uri('node', $node);
    $uri['path']; // this should be the final path
}


texts: How to create a workflow state field programmatically?

texts:
I have my custom entity created, workflow module installed and now I would like to create a workflow state field on my entity. I know I have to do it in the src/Entity/MyEntity.php class in my module, but where do I get all those field settings for this particular field type for the BaseFieldDefinition::create method?

I have somehow managed to put this field definition in my entity class:

$field['workflow'] = BaseFieldDefinition::create('workflow')
  ->setLabel(t('Workflow'))
  ->setDescription('Workflow entity')
  ->setSetting('workflow_type', 'test_workflow');

But it does not add a field to my entity. Thanks.

EDIT: test_workflow is existing workflow.


texts: Plugin form block not displaying block title

texts:
I have a custom ctools plugin for D7, which displays a form inside of a block. But when I set the block's title, it doesn't display on the page with the block on it. However, if I set the block's title for the administration screen it does display there.

Here is my code:

function hobsons_interest_pane_custom_pane_render($subtype, $conf, $args, $contexts) {

$myform = drupal_get_form('hobsons_interest_form');

    if (!empty($contexts)) {
    $content = drupal_render($myform);
    }

    $block = new stdClass();

    //   var_dump($conf['override_title_text']); // THIS HOLDS THE PROPER TITLE

    $block->title = $conf['override_title_text']; // NO TITLE GETS RENDERED

    $block->content = $content;

  return $block;

}

/**
 * 'admin info' callback for panel pane.
 */
function hobsons_interest_pane_custom_pane_admin_info($subtype, $conf, $contexts) {
  if (!empty($conf)) {
    $block = new stdClass;
    $block->title = $conf['override_title_text']; // THIS TITLE GETS RENDERED ON THE ADMIN EDIT SCREEN
    return $block;
  }
}

/**
 * Implements hook_block_info().
 */
function hobsons_interest_block_info() {
  $blocks = array();

  $blocks['hobsons_interest'] = array(
    'info' => t('Hobsons Interest Form'),
    'cache' => DRUPAL_NO_CACHE,
  );

  return $blocks;
}

My guess is that using drupal_get_form() is somehow to blame, but it's just a guess. Thank you!


texts: I'm getting a page not found error when trying to visit my custom form

texts:
This is the form that I created using Drupal 8:

namespace \Drupal\lookup\Form\lookupForm;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class lookupform extends FormBase
{
    /**
     * {@inheritdoc}
     */
    public function getFormId()
    {
        return 'lookup_form';
    }

    /**
     * {@inheritdoc}
     */
    public function buildForm(array $form, FormStateInterface $form_state)
    {
        $form['Username'] = [
            '#type' => 'textfield',
            '#title' => t('ULM Username'),
        ];

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

        return $form;
    }

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

    }

}

Routing file:

user.form:
 path: '/lookupForm'
 defaults:
   _title: 'Lookup User Autocomplete'
   _form: '\Drupal\lookup\Form\lookupForm'
 requirements:
   _permission: 'access content'

Info file:

name: Form
description: This is a form.
core: 8.x
package: Custom
type: module

I am getting a page not found error. What could be the issue?


texts:
I have two sets of taxonomy lists

Engine Codes
Vehicle Make and model

Now I'd like to link the two taxonomy terms from different lists/vocabs e.g.

Nissan Skyline R33 GTR (Vehicle make and model)  - - - > RB26DETT (engine code)
RB26DETT (engine code) --> Nissan Skyline R33 GTR (Vehicle make and model)

I'd like to do this without having to manually input it twice. In some cases the same vehicle may have different engine codes, and visa versa.

So If I look at the Taxonomy term page for Nissan Skyline R33 GTR, it lists the RB26DETT and visa - versa.

I'm not sure (i) which module to use, and (ii) whether I should use term reference, or entity reference.

I'm new to this and learning so appreciate any help/advice!

Thanks
Shah


texts: Alter the conditions in a DatabaseCondition object

texts:
Would there happen to be a way to alter the conditions in a DatabaseCondition object? Say I have this:

DatabaseCondition Object
(
    [conditions:protected] => Array
        (
            [#conjunction] => AND
            [0] => Array
                (
                    [field] => search_index.type
                    [value] => node
                    [operator] => =
                )

            [1] => Array
                (
                    [field] => DatabaseCondition Object
                        (
                            [conditions:protected] => Array
                                (
                                    [#conjunction] => OR
                                    [0] => Array
                                        (
                                            [field] => search_index.word
                                            [value] => foo
                                            [operator] => =
                                        )

                                    [1] => Array
                                        (
                                            [field] => search_index.word
                                            [value] => bar
                                            [operator] => =
                                        )

                                )

                            [arguments:protected] => Array
                                (
                                )

                            [changed:protected] => 1
                            [queryPlaceholderIdentifier:protected] =>
                        )

                    [value] =>
                    [operator] => IS NULL
                )

        )

    [arguments:protected] => Array
        (
        )

    [changed:protected] => 1
    [queryPlaceholderIdentifier:protected] =>
)

I would like to make changes on the conditions. Any ideas?


texts: Translating interface - same word duplication

texts:
I have "problem" i want to do one word translation e.g. 'Location' (same case) I use that word with t() function in (menu, module, template tpl, taxonomy) when I go to translate interface it show me same string: 4x"Built-in interface", 2x"taxonomy", 1x"fields". I have 4 languages and I have repeat everything for same word. Is it possible to do one translation and Drupal apply on all exact strings.

Thanks


texts: How to right align text in custom form textfield in Drupal 7?

texts:
I have a custom form with a textfield that takes numeric values (temperature). I want to right-align the text typed in textfield. Should I use CSS or is there a Drupal attribute to do this?

Here's the present code:

$form['temperature'] = array(
            '#type' => 'textfield',
            '#title' => 'Answer',
            '#description' => 'Enter temperature in &deg; Fahrenheit',
            '#required' => TRUE,
            '#size' => 6,
            '#maxlength' => 6,
            '#field_suffix' => '&deg; Fahrenheit',
            '#element_validate' => array('_myform_temperature_validate'),
        );


texts: Syntax for referenced variables in hook_commerce_physical_order_weight_alter?

texts:
I'm trying to add a fixed weight to all cart order for shipping. I know I need to implement hook_commerce_physical_order_weight_alter() but I'm unsure of how to implement the function in a custom module. I have been testing this code in the devel php exectute window

global $user;
$order = commerce_cart_order_load($user->uid);
$weight = commerce_physical_order_weight($order, $unit = 'oz');
function commerce_physical_order_weight_alter(&$weight, $order, $unit){
if ($weight['weight'] >0)
{$weight = $weight + 6;}
}
dpm($weight);

Where I am confused, is passing the variable by reference. From what I understand, this should be enough to increment the weight but it returns the unadjusted weight

I can grab all of the stuff I need outside the function, but I'm unclear about passing the variable by reference and how to use that syntax for my purpose. I know that this means that the function returns a modified variable. It doesn't look like the function is called since I've tried to put the dpm in a condition inside the _alter function and it doesn't run.

Thanks the help so far, and I appreciate the earlier answers.


texts: Use 'Search Api Attachments' file extractor in my own custom 'Search Api' processor plugin

texts:
I'm writing a custom processor for search api that will search body content of nodes for links to pdfs and extract the content from them to be indexed. It's meant to be able to do the same thing search api attachments can do, it just searches for links inside bodies instead of just grabbing what's in an entity reference or file field.
I'm using the drupal 7 search api attachments bf plugin as an example, but with Drupal 8 it's handled a bit differently

I currently have this file in a custom module located in /src/search_api/processor/BodyFieldAttachments.php

<?php

namespace Drupal\search_api_attachments_bf\Plugin\search_api\processor;

use Drupal\search_api\Datasource\DatasourceInterface;
use Drupal\search_api\Item\ItemInterface;
use Drupal\search_api\Processor\ProcessorPluginBase;
use Drupal\search_api\Processor\ProcessorProperty;

/**
 * @SearchApiProcessor(
 *     id = "bodyfield_attachments"
 *  label = @Translation("Body Field Attachments")
 *  description = @Translation("Allows file links inside body fields to be indexed")
 * )
 */
class BodyFieldAttachments extends ProcessorPluginBase{
    /**
     * {@inheritdoc}
     */
    public function getPropertyDefinitions(DatasourceInterface $datasource = NULL){
        $properties = [];

        return $properties;
    }

    /**
     *  {@inheritdoc}
     */
    public function addFieldValues(ItemInterface $item){
        $node = $this->getNode($item->getOriginalObject());
        $body = $node->body->value;
        $files = $this->getFilesFromBody($body);

    }

    protected function getFilesFromBody($text){
        $files = array();
        if (isset($text) && !empty($text)) {
            global $base_url;
            // Parse href attributes in <a> links.
            preg_match_all('/href=[\'"]([^\>\'"]*)[\'"]/', $text, $matches, PREG_SET_ORDER);
            foreach ($matches as $match) {
                // Determine if the file is local. Absolute URL could be local.
                // Beginning double slashes is implicit for the current page's protocol
                // but just apply http.
                if (substr($match[1], 0, 2) == '//') {
                    $url = 'http:' . $match[1];
                }
                elseif (substr($match[1], 0, 1) == '/') {
                    $url = $base_url . $match[1];
                }
                else {
                    $url = $match[1];
                }

                $parse = parse_url($url);
                // Get absolute URL to the file location.
                $path_files = file_create_url('public://');
                if (isset($parse['host']) and $parse['host'] == $_SERVER['HTTP_HOST']) {
                    $uri = 'public://' . str_replace($path_files, '', $url);
                    // Convert back things (such as %20 back to a space).
                    $uri = urldecode($uri);

                    if (file_exists($uri)) {
                        $files_load = file_load_multiple(array(), array('uri' => $uri));
                        $file = reset($files_load);
                        if ($file) {
                            $files[] = (array) $file;
                        }
                    }
                }
            }
        }
        return $files;
    }
}

I have search api attachments installed and I do see that it has FilesExtractor class that handles file extraction but I'm not sure how to call upon it from my plugin and get it to use the config that's in place for Search Api attachments. Would I just create an instance of the FilesExtractor class and use one of its methods? Or is there some proper way to tap into it?


texts: Any way to add an associated url redirect to a content view?

texts:
I want to display the url redirect by which a user entered my site on the commerce orders view so that we can easily see if certain redirects we have set up for direct mails, magazine ads etc have been successful in generating an order. I can't seem to find a way to do this - I'm not a developer so would needs something that can be achieved through the cms.

I know I could do something similar with google analytics/campaigns but I can't use that for this.

Thanks.


texts:
I have a multilingual site that has a different domain for each language (.eu, .com, .nl and. de). everything was functioning well untill today. The site shows an acces denied message when I try to reach an image on www.example.com/sites/default/files/styles/sliderfront/public/exampleimg.jpg?itok=i2WjbtxU and the images show up as broken image icons. however this doesn't happen whenever I reach the same file through www.example.eu/sites/...

Another thing is that this only happens with newly added content. All the files and maps within and including files/styles have permissions 755

The site is hosted on a shared hosting and its main domain is the  .eu domain.
Does it have something to do with symlinks?


texts: Form value not submitting for a function called from ajax

texts:
I have created a form for creating some beaches. In that I have to give the value of continents,country ,name of beaches. Names of the countries and continent are stored in the taxonomy table. so if the user selects the continets, by using ajax it displays the list of countries belonging to the continent. my code look like..

function iks_beaches_create($node, &$form_state) {

drupal_set_breadcrumb(array(
    l('beaches', 'beaches'),
    'Add New Beaches'
));
    $form['iks_beaches_continents'] = array(
    '#title' => 'Continents',
    '#description' => 'Taxonomy vocabulary defining Continents',
    '#type' => 'select',
    '#options' => iks_beaches_getTerms(variable_get(IKITESURF_BEACHES_CONTINENT, '')),
    '#required' => true,
    '#ajax' => array(
    'callback' => 'countryDisplay',
    'wrapper' => 'countryDisplay',
    'event' => 'change',
     ),
     );
    $form['countryDisplay']['iks_beaches_country']= array(
     '#type' => 'select',
     '#options' =>iks_beaches_getTerms(variable_get(IKITESURF_BEACHES_REGIONS, '')),
     '#title' => 'Country',
     '#required' => true,
     '#description' => 'Taxonomy vocabulary defining Country',
     );
     $form['regionDisplay']['iks_beaches_regions'] = array(
     '#title' => 'Regions',
     '#description' => 'Taxonomy vocabulary defining Regions',
     '#type' => 'select',
     '#options' => iks_beaches_getTerms(variable_get(IKITESURF_BEACHES_REGIONS, '')),
     '#required' => true,
     );

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

the corresponding ajax function is

 function countryDisplay($form, &$form_state){
    $city = isset($form_state['values']['iks_beaches_continents']) ?        $form_state['values']['iks_beaches_continents'] : 'default';
    $query = new EntityFieldQuery();
    $entities = $query->entityCondition('entity_type', 'taxonomy_term')
                      ->propertyCondition('vid', variable_get('iks_beaches_countries'))
                      ->fieldCondition('field_continent', 'tid', $city)
                      ->execute();
    if(isset($entities['taxonomy_term']) && count($entities['taxonomy_term'])) {
    $countries = taxonomy_term_load_multiple(array_keys($entities['taxonomy_term']));
    foreach($countries as $coutry){
   $options[$coutry->tid]=$coutry->name;
   }
    }
    $form['countryDisplay']['iks_beaches_country'] = array(
         '#type' => 'select',
         '#options' => $options,
         '#title' => 'Country',
         '#required' => true,
         '#description' => 'Taxonomy vocabulary defining Country',
        );
return  $form['countryDisplay'];
}

But countries value is not displaying on form submit

function iks_beaches_create_submit($form, &$form_state) {
echo "
";print_r($form_state['values']);echo "
";exit; }

Array
(
    [iks_beaches_continents] => 673
    [iks_beaches_regions] => 783
    [location_name] => hdnffgh
    [description_location] => fgdh fgh fg hrt yry bnmbv mbcsd rty
    [travelling_details] => fh ty vcrsw t ytrywswe5
    [location_facilities] => ry  yuf d sdaf sa warewe svbvcber
    [tags] => e
    [longtitude] => 23.536343
    [latitude] => 45
    [images0] => 13803
    [images1] => 0
    [images2] => 0
    [images3] => 0
    [images4] => 0
    [images5] => 0
    [images6] => 0
    [images7] => 0
    [images8] => 0
    [images9] => 0
    [submit] => Publish Beach
    [form_build_id] => form-ZpuHlTPwSjJ2ElN_nPlSTsmHdQC6mmvSyKQOfMy4xvM
    [form_token] => n6vBuvZLJJNdcjdYERIsOm2REge8JoJMOSMmEuzpom8
    [form_id] => iks_beaches_create
    [op] => Publish Beach
)


texts: How close the admin overlay on submit for a drupal form shown within the admin overlay

texts:
I'm currently showing a drupal form via the admin overlay. I'm using jQuery to perform the processing of the form.

The problem I have is how do I close the overlay on submit? right now the only way to close the overlay is by pressing the X at the top right (well based on the default theme), which is just a .

Now I'm presuming that I could somehow change the form to add the "overlay-close" to the submit button, but I'm not sure how to do this.

Is there a way to add a class to a button on a form in drupal?

Cheers,

James


texts: List of template suggestion used for a node

texts:
I'm building a module that return you an HTML styled node via ajax but I have a question.
I want to add a node suggestion only for this module. How?

So drupal have to check:
Exist [in active theme] ajaxnode.tpl? And ajaxnode--nodetype.tpl? If they don't exist choice the normal drupal suggestion template and render the node.

How can i do this correctly?


texts:
Is there a way to create multiple displays for an existing entity?

The node has already Full content, Teaser, RSS, Search index, Search result display types. I was wondering if I can add more to these or to any other entity.

Thanks :)


texts: Insert data from sql file when call hook_schema on drupal 7

texts:
I developed a module in drupal 7 that need a database table like "example_table". And i create "example_table" table using example_schema() function. Now I need to insert some default data.

Here, I can use drupal_write_record('example_table', $data); function to insert data into example_install() function.

But, I want to insert data from example_db.sql file.

How can I do it? Any Suggestions?


texts: How can I implement the most basic route in Drupal 8? What files do I have to write, and which classes do I need to implement?


texts: Is it possible to run 2 different sites in Acquia Dev Desktop on the same computer?

texts:
I'm running Acquia Dev Desktop and I'm wondering if it's possible to clone 2 different sites with different Drupal versions.

I tried cloning both sites, but when I cloned the second one and tried to view it, I got the following message.

Is there a way I can use both in the same computer?


texts: How to list different terms with their nodes in one view?

texts:
Now I had a question, is it possible to build a view which can display different terms with multiple content on drupal 8?

For example,

Term 1

node 1
node 2
node 3

Term 2

node 2
node 4
node 6

Term 3

node 5
node 7
node 8

Can someone help me out?

I appreciate your help!


texts: what permission is need to access to content page?

texts: I have created a role and a user assigned to it. I want to give access to  '?q=admin/content/node' to this role to see all the contents of the site. what permission should I set for this role? I am using Drupal 6.26.


texts: Passing PHP objects and methods as strings to FormAPI

texts:
When working with objects, how do you pass a method to the FormAPI's ['#after_build'] feature?

For example, how can I pass $myObject->_my_after_build_function to ['#after_build']?

Non-OOP exampe of what I would like to accomplish:

$form['#after_build'][] = '_my_after_build_function';


texts: How and where to use/place database queries when a webform is submitted?

texts:
Let's say that I already created a webform with fields Customer Name, Customer Surname and Customer Address.

When the webform is submitted, I want to insert those values captured in a custom table "Customer" created in the database that Drupal is using.

How do I achieve this? Do I have to use a specific module to insert those values?

Is it feasible to do this by using the Rules module? If yes, can you give me a simple example on how to do this?


texts: {{ content.field_test }} doesn't work in node.html.twig

texts:
I created a field whose machine name is field_test. I want to show this field in node.html.twig, but when I use {{ content.field_test }}, {{ content.field_test.value }}, or {{ content.field_test[0] }} the field is not printed.

How can I achieve this in Drupal 8.3.5?


texts: How to output every second grouping in views?

texts:
I have a view that outputs a list of nodes and their taxonomy terms. I use taxonomy field as grouping field. So I get:

Tax1 (article1, article2, article3 )
Tax2 (article4, article5, article6 )
Tax3 (article7, article8, article9 )

etc.

View makes markup for each group like this:

Question:

How is it possible to output every second grouping?

I would like to have 2 columns with 2 views, first view would output every second grouping and second view would show other groupings.

I'm using Views 3.


texts: How can I get the currently submitted form state in a block on the same page?

texts:
How can I retrieve the currently submitted and validated form state?

Please assume the following scenario.

A page has a form on it created using the form API.
The data in the submitted form is transient. In other words it is not saved or stored in any way.

The form is created by a module I do not control and therefore I should not alter the codebase.

On the same page as the form is a block (mine) which displays data based on the form submission.

I want to get access to the validated data from the anonymous user submitted form from within the block plugin code.

The form does all the necessary validation of the user submitted data. I do not want to replicate this validation so I need to get access to the validated form_state so I can extracted the submitted values.

I cannot see a way to retrieve the form_state object from the current request.

How can this be done?


texts: Media Module Bulk Upload for Image Field

texts: Using Media 7.x-2.x-version I am trying to use the integrated Bulk Upload Module. I have activated Media Bulk Upload sub module as part of Media. Now if I use a image field with media selector I can still upload only one image at a time. Only if I go to "file/add" I have the multiple file upload option. Is this by design or is there a possibilty to use multiple file upload directly when adding content via Image field.


texts:
I've got a problem with Clean URLs. I had a look around and my problem doesn't look like any thing else on this site or anywhere on the internet.

I have a .htaccess file. It's there and it's working. I know because I've set it to remove www. and it is.

I go to Configuration->Search and Meta->Clean URLs (some people don't pass the clean URLs test but I do, it doesn't even come up) I have the option to turn on Clean URLS:

I tick the box and click Save configuration. But this happens:

NO! I ticked you!

So if I go to a clean URL (/contact) it works. But in the menu it comes up as (/?q=contact).

I thought I'd hack the database and turn it on.

But it was on the whole time...
<hold flashlight under chin and look scary>

Does anyone know how to remedy this situation so it stays ticked and comes up clean in the menu?


texts: Implementing an age check using InboundPathProcessorInterface

texts:
I'm trying to create an age checker for a Drupal 8 site.

I've created a custom module which has a form where the user enters their DOB and my form submit saves a cookie so I know they have passed the age check. Code is as follows:

public function submitForm(array &$form, FormStateInterface $form_state) {
  $day = $form_state->getValue('day');
  $month = $form_state->getValue('month');
  $year = $form_state->getValue('year');

  $timezone = new \DateTimeZone('Africa/Johannesburg');
  $age =
    \DateTime::createFromFormat('d/m/Y', $day . '/' . $month . '/' . $year,
      $timezone)->diff(new \DateTime('now', $timezone))->y;

  if ($age < '18') {
    // if less than 18 display the age_check.fail route
    $url = Url::fromRoute('age_check.fail');
    $form_state->setRedirectUrl($url);
  } else {
    // set cookie so we know this user has passed the age check
    setcookie('age_checked', 1, time()+3600, '/');

    $original_path = $_COOKIE['age_checked_prev_path'];

    if (!empty($original_path) && $original_path != '/') {
      $redirect_url = Url::fromUserInput($original_path);
      // Add a redirect to requested page. Using $form_state built in redirects.
      $form_state->setRedirectUrl($redirect_url);
    } else {
      // For everything else, redirect to homepage.
      $form_state->setRedirect('<front>');
    }
  }

}

Cool that is working fine i get redirected to a age-check-fail page if under 18. If over 18 I should be redirected back to the page I originally wanted to go to. Now I've tried to implement this using a Path Processor.

   /**
   * Path processor for age_check.
   */
class AgeCheckPathProcessor implements InboundPathProcessorInterface {

/**
 * {@inheritdoc}
 *
 */
public function processInbound($path, Request $request) {
  $alias_manager = \Drupal::service('path.alias_manager');
  $request_alias = $alias_manager->getAliasByPath($request->getRequestUri());
  // set cookie with original request path
  setcookie('age_checked_prev_path',$request_alias, time()+3600, '/');

  //get all cookies
  $cookies = $request->cookies->all();

  if(!array_key_exists('age_checked', $cookies) && empty($cookies['age_checked'])){

      // paths to skip age check
      $skip_path = [
        0 => '/admin',
        1 => '/user',
        2 => '/user/login',
        3 => '/age-check',
        4 => '/age-check/fail'
      ];

      // loop through each skip path and if match to current request return it
      foreach ($skip_path as $key => $path) {
        $url = trim($path);
        $url_alias = $alias_manager->getAliasByPath($url);

        if ($url == $request_alias || $url_alias == $request_alias) {
          // Leave $path intact.
          return $request_alias;
        }
      }

    // show the age check page.
    return '/age-check';
  }
  return $request_alias;
}

This isn't working as intended. One main problem is that coming from the home page, submitting the age check form correctly it still redirects me back to the age check form, if i then enter the url to an article I am allowed access to the site as intended, but trying to go back to the home page still shows the age checker form.

Am I using the Inbound Path Processor class correctly?


texts: How to update custom module without uninstalling?

texts:
We have an existing custom module for our Drupal 8 application that created a content type and a view. The "news" module is in our production environment running fine; many pieces of content have been created using it.

Now enhancements have been requested: 2 new fields and a change to the view. I have made the changes using the admin UI in our dev environment, but I will need to put these changes into the module's code for version control so that in new site instances, one need not remember to make UI changes after installing the module.

The fields:
field_show_on_page, Field Type: List (text)
field_news_dateline, Field Type: Date
View:
The change in the view is on what field the sorting is done.

It would be simple to export the fields and view configurations and add them to the module>config >install folder, but for the change to be picked up, that requires uninstalling and reinstalling the module, which can't be done without needing to delete news content, which is not acceptable.

I understand the changes can be done in hook_update_N in the news.install file. But I cannot find examples for this function that is close enough for this need. I understand the function should be written as:

news_update_8001() {}

But what would go in the body to add the two fields and update the view?


texts: 7 Views $variables/$views/$fields crashing browser

texts:
Any of following codes in views-view-fields--MYVIEW.tpl.php make my browser unresponsive:

<?php kpr( $variables ); ?>

<?php kpr( $fields ); ?>

<?php kpr( $view ); ?>

I get the FireFox message:

  A webpage is slowing down your browser. What would you like to do? Stop it. Wait.

If I select wait in hangs indefinitely but if I select stop I can see the output though I have to scan through the source-code. I can use other variables kpr($row) works for example.

I had similar results in Chrome.

How do I troubleshoot this?


texts: How to display a create node form together with a referenced node of a different type

texts:
I'm using a content type for Clients and another content type for Tasks. Each client has many tasks and each task belongs to one client. Both types are connected by a reference field defined for the Task content type that points to a Client node.

I know how to display a Client's information together with a list of all Tasks for that client. I'm using a view in a block that is parameterized with the Client node ID. That was easy.

However, in order to create a new Task for a Client, I need to display the Client's information together with the create new task form.

Is there any way I can do that in Drupal 7?


texts: Show 2 content types in a view that share same field value

texts:
Hi i have 2 content types:

Agent
Organisation

they both have fields for id:

ID ( agent content type)
Org ID ( Organisation content type)

Now i need to create a view that will list fields from both of the content types, and only relation between them is same value in fields ( field_id and field_org_id ).

Since content is already there and there are more than 200 nodes in each content type, i need to work with what i have. That means i cant add new fields ( like node reference ).

Is there a way to make a view that will list fields from two content types that share same value in 2 fields with different name? And in each row to have mix of fields from both content type with relation of this ID.


texts: Captcha on the user_login_form and user_pass form?

texts:
just checked on my site and it seems that certain login forms do not have captcha. specifically the form named:

user-login-form
user-pass

I put in user_login_form in the captcha page to make it show up, but it doesnt seem like that is working. am i grabbing the correct form id from the NAME attribute in the form tag?


texts:
I got a question regarding the loading of a view within a preprocess function of Drupal 8.

The only working solution I found is this one here:

$_block_level_1 = \Drupal::entityManager()->getStorage('block')->load('views_block__myview_ov_block_1');

So by using the entity manager.

The view is expecting parameters. How do I send them?


texts: StackExchange-style "related tags" block using drupal views?

texts:
StackExchange sites, and various other site around the 'net, have a nice tag drill-down feature: You can go to a tag page, like https://drupal.stackexchange.com/questions/tagged/views, and then you can select tags from the "related tags" block, and you are sent to a page that filters contents on the union of the two tags. You can do this as many times as you want, and you end up with only content that has all of the tags you've selected. The tags in the "related tags" block are sorted by popularity, and list the number of items tagged.

Is it possible to do this in drupal? How would one go about this? I'm imagining something like a content-view for the tag page, filtered by tags; and then a taxonomy-view for the block, filtered by relationships with contents in the first view. Seems like a bit of a complex mission. Is there a simpler way?


texts: How to render the content in which the user is mentioned in?

texts:
I render the Views page on the user profile page to show the content this user created.
Now the scenario changed and I have to render the content in which this user has been mentioned using Entity Reference fields. For just one field there is no problem, since I did it using Contextual Filter ... but when I'm trying to do so using multiple different fields (for different content types), then I do not get any results.

Is it possible to achieve this using UI or is it possible to put a custom query somewhere to get results and benefit from the Views fields?

Thank you all in advance!


texts: Print selected fields in page tpl Drupal 7

texts:
For some reasons, I have to customize the display of the content node programmaticaly, mixing content from other sources.

Instead of making a print(render($page['content'] which outputs all the content, I need to access to selected parts of the content (for instance, value of a text field, url of a PDF file, etc.). I am using this approach:

print render( $page['content']['system_main']['nodes'][$nid]['body']['#object']->field_subtitle_product["und"][0]["value"]);

Would it be correct or is there a more straighforward method? ( I don't want to low to node.tpl.php anyway).

Thanks!!


texts:
I noticed that the UID of users is exposed in the HTML code of a page on my site that authenticated users can access.

Is it a problem if authenticated users with "view user profiles" permission are able to find the UID of any non-disabled user account?


texts: I cannot upload XML files through managed_file

texts:
When i try to upload a .blm file in the admin upload page on /file/add, the file is uploaded to the temporary folder, but no file entity is created. Instead, I get this error.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "entity:file:undefined" plugin does not exist. Valid plugin IDs for Drupal\Core\TypedData\TypedDataManager:...

I added the .blm extension to the allowed extension, but I still get the same error, even with XML files. If I change the extension of the same file to "txt", everything works fine.
Do you have any advice?


texts: How to add a CSS class to field label and items div?

texts:
I want to add a class in the field label and field items, the HTML I want is the following:

Price:&nbsp;

100

I've tried field_formatter_class, the module allow me to add a "row" class into the container, but not in field-label and field-items. I want to add col-md-2 class for such two divs

How to do that without writing a module to do that?


texts:
How can I make CSS classes that can be added to content in a WYSIWYG style in the edit view?

I've added the following 'CSS classes' and I've used my site's normal CSS to float them left and right respectively and give them a width of 51%:

Left=div.posLeft
Right=div.posRight

When I save the node this works fine. However in the editor the styles are not shown. How can I make them show up?


texts:
The output from the below code is printing HTML. How can I make the "p" tags disappear?

answer 1

{% block paragraph %}

    {% block content %}

{{ content.field_accordion_title.0}}

      {% for grid_item in paragraph.field_accordion %}
        <button class="accordion">{{ grid_item.entity.field_accordion_list_item_headin.value }}</button>

        {{ grid_item.entity.field_accordion_list_item_text.value }}

      {% endfor %}
    {% endblock %}

{% endblock paragraph %}

Note:  I don't want to trim the HTML tags but actually render them. Perhaps drupal_entity() will help to render the output of {{ grid_item.entity.field_accordion_list_item_text.value }}. How can this be done?
Note: I don't want to trim the HTML tags but actually render them. Perhaps drupal_entity() will help to render the output of {{ grid_item.entity.field_accordion_list_item_text.value }}. How can this be done?


texts:
Where can I find a list of the available tokens, so I can write things like {{ node.title }} in my templates?

The documentation says the best way to find a list of them is to use this: https://www.drupal.org/docs/8/modules/d8-rules-essentials/data-selection

Can anyone provide something more useful?


texts:
I have two footers in a view page with the sum results from View Aggregate Plus (VAP). The last row is the sum result.

  footer A:    var A
      10
      20
      30 (sum result from VAP)

  footer B:   var B
      25
      30
      55 (sum result from VAP)

I would like to sum the results of footer A and footer B (Total =20 + 30), using global php (module view php).

The available variables below:

What is the output code to get the total summation result ?


texts: How can I include a dropdown in menu_local_tasks tabs?

texts:
I am trying to include a Bootstrap style dropdown in the local_tasks tabs on a section of my website. I thought I might be able to accomplish this with the 'theme callback' option of 'HOOK_MENU', but it doesn't run the custom callback. Any ideas on a good way to accomplish this?
Menu:
    $items['module/submenu/tab'] = array(
    'title' => 'Title',
    'page callback' => 'mymodule_menu_callback',
    'access arguments' => array('access content'),
    'theme callback' => 'mymodule_menu_local_task_dropdown',
    'type' => MENU_LOCAL_TASK,
);

Callback:
function mymodule_menu_local_task_dropdown($variables) {
 $link = $variables['element']['#link'];
 $link_text = $link['title'];
 $classes = array();

 if (!empty($variables['element']['#active'])) {
 // Add text to indicate active tab for non-visual users.
 $active = '' . t('(active tab)') . '';

 // If the link does not contain HTML already, check_plain() it now.
 // After we set 'html'=TRUE the link will not be sanitized by l().
 if (empty($link['localized_options']['html'])) {
  $link['title'] = check_plain($link['title']);
 }
 $link['localized_options']['html'] = TRUE;
 $link_text = t('!local-task-title!active', array('!local-task-title' => $link['title'], '!active' => $active));

 $classes[] = 'active';
}

$classes[] = 'dropdown';

//haven't written this part yet
$dropdown = 'build dropdown';

return '
' . l($link_text, $link['href'], $link['localized_options']) . $dropdown . "
\n";
}

What I'm looking for:


texts: Display only the terms in the filter set using Views

texts:
I have got a view where I am displaying a view in a block.  Basically, I want to display a list of nodes that have a few specific terms associated with it.  So, for example, I want to show all nodes that have one of the following terms (red, blue, green, white).  So, my block should display two fields with the following criteria:

Fields
Content: Title (Title)
Content: Tags (Tags)

Filter criteria
Content: Published (Yes)
Content: Has taxonomy term (or Black, Blue, ...)

Sort criteria
Content revision: Updated date (desc)

My problem is, the result is looking fine, where it is displaying a list of all the nodes that fit the filters.  However, I would only like to display the term in the result set and not all the terms that the node is associated with.  So, right now, this is the what the block looks like:

|Title        |  Tags

|Node 3     |  red, horses, yellow, dogs
|Node 5     | black, white, green, cats, rain, purple

|Node 6     | camel, case, blue

I would like the block to look like this:

|Title        |  Tags

|Node 3     |  red
|Node 5     | white, green

|Node 6     | blue

So, in essence, display only those terms that are part of the result set.  How can I accomplish this with Views?  Any help would be greatly appreciated.

I have played around with the configurations in Views, like @Mohammed Shammem said, and I have gotten it to display only the colors I want.  It is however, still displaying in separate lines despite selecting Group by Title under the Format settings option.  So, now it looks like this:

Tags    Title
White   Node 1
Blue    Node 1
Black   Node 1
Red     Node 1
Green   Node 1

I am close enough, but would appreciate more help on getting the tags in one row.

The relevant screen shots:


texts: In Panels, how are the 2 given arguments in System's node_view created?

texts:
In the Panel pages for System node_view (Node template) and term_view (Taxonomy term template), there is a variant that is already defined. This variant has 2 arguments, "Node being viewed" and "Depth". How are these arguments created?

thanks,

Eric J.


texts:
I have created an endless loop within Rules that will evaluate nodes after they are created and reschedule itself as shown here:

I would like the loop to close after three emails have been sent.  A counter could be added to the action set under "Send Email" then the conditions could include a Data Comparison to see if the counter is less than 3.

I have tried creating fields within the content type that would have the Rule Component increase the counter field by one every time the email section was executed then have a data comparison between the counter field and a Email Max field that had a default value of 3.  I wasn't able to get this to work because the counter would not be increased.

Could this be done with an "Execute Custom PHP Code" action?


texts: How do I restrict the date popup to 12 months from start date?

texts:
I have a custom module where I set two date pop-ups.

$form['set_start_date'] = array(
  '#type' => 'date',
  '#title' => t('set start date'),
  '#required' => TRUE,
);

$form['set_end_date'] = array(
  '#type' => 'date',
  '#title' => t('set end date'),
  '#required' => TRUE,
);

If I select 2017-04-12 as start date, the accepted end date should not be after 2018-04-12.

How can I achieve this?


texts: Hide a region from a specific node? (Without CSS)

texts: I can hide a region from a specific node via CSS but this is problematic since the Display: none attribute doesn't really clear the space... Any other way to do so?


texts: Theming custom block in twig file and render variables

texts:
I created a custom block and I'm trying to render it in twig file. The file gets used, as I can see its output, but my variable 'my_variable' defined in the block is not rendered:

in CustomBlock.php

public function build() {
    $build = [];

    $build['custom_block'] = [
      '#my_variable' => 'abcdef',
      '#theme' => 'custom_block',
    ];

    return $build;
}

in my_module.module:

function my_module_theme() {
  return [
    'custom_block' => [
      'template' => 'custom-block',
    ],

  ];
}

in custom-block.twig.html:

<div>{{ my_variable }}</div>

-> The twig file gets used and the div is shown, but the variable is empty/is not rendered.


texts: Weird problem in calculating sum of two computed field values as another sum

texts:
I have created one content type having fields like A,B,C,D,E,F,G. I have used computed filed module to compute these fields like the following. (Used filed group module to group some A&B in first group, C&D in second group , E,F,G are in third group.
Here are the computations

A*C=E

B*D=F

E+F=G WHERE E,F AND G are computed fields .

The problem is when I submit the content type first time I am able to get E and F values but not G and if I edit the node and submit the result of G(E+F) is displaying correctly.

Here is the code snippet used to computed fields

$entity_field[0]['value'] = $entity->field_a['und'][0]['value'] * $entity->field_c['und'][0]['value'];

$entity_field[0]['value'] = $entity->field_b['und'][0]['value'] * $entity->field_d['und'][0]['value'];

$entity_field[0]['value'] = $entity->field_e['und'][0]['value']+ $entity->field_f['und'][0]['value'];

Display Output

$display_output= $entity_field_item['value'];

We tested the same scenario in Articles content type with field groups which shows all the results at a time i.e E,F and G.

I am getting errors on first submit.

Notice: Undefined property: stdClass::$field_e in eval()

Notice: Undefined property: stdClass::$field_f in eval()

What would be the problem?


texts:
For various reasons, I can not use the Drupal 7 menu system and have to hardcode a special menu. I am trying to add an active class basing on the URL. I was looking at this page and trying the following.

<a href="/search" title="" class="<?php if ( ($path == $_GET['q'] || ($path == '/search') ) ) : print ('active');endif;?>">Search

sports

news

entertainment


texts: Values of checkboxes field are always empty

texts:
in Drupal 8, I try to create a form with a checkboxes field.

public function buildForm(array $form, FormStateInterface $form_state) {
      $config = $this->config('communication_annuaire.settings');
      $form['fields_to export_to_annuaire'] = array(
       '#title' => $this->t('Fields to export to annuaire'),
       '#type' => 'checkboxes',
       '#options' => $this->getFieldOptions(),
       '#default_value' => $config->get('fields_to export_to_annuaire'),
    );

    return parent::buildForm($form, $form_state);
}

public function submitForm(array &$form, FormStateInterface $form_state) {
      parent::submitForm($form, $form_state);
      \Drupal::configFactory()
         ->getEditable('communication_annuaire.settings')
    // Set the submitted configuration setting
     ->set('fields_to export_to_annuaire', $form_state->getValue('fields_to export_to_annuaire'))
    ->save();
}

public function getFieldOptions() {
    $fields = array();
    foreach (\Drupal::entityManager()->getFieldDefinitions('node', 'structure') as $field_name => $field_definition) {
       if (!empty($field_definition->getTargetBundle())) {
         $fields[$field_name] = $field_definition->getLabel();
       }
     }
    return $fields;
}

The problem is that even if I check one or several checkboxes, data for the field is always empty in submitForm function: Array(   [body] => 0  [field_contact] => 0    [field_infos] => 0    [field_logo] => 0    [field_site] => 0    [field_structure] => 0)

I tried with array_filter($form_state->getValue('fields_to export_to_annuaire')), but it is not better.

How can I solve this problem ?

Thanks


texts: Select nodes based on entity reference value

texts:
I have a content type student, and it has an Entity Reference field named as field_offline_course_reference and a email field field_offline_course_student_ema

I need a list of all emails of students based on field_offline_course_reference value.

How can I change the following code to achieve what I want to do?

$courseinfo = $theCourseId;
$query = db_select('node', 'n');

$query->join("field_data_field_offline_course_reference", "t", "t.entity_id = n.nid");
$query->fields("n", array("nid"))
    ->condition('n.type', 'students')
    ->condition('t.entity_id', $courseinfo);

$result = $query->execute();
    foreach ($result as $record) {
       var_dump($result);
}


texts: If there are so many modules in Drupal, are the hard-coded functions reserved only for contributed modules?

texts:
I read somewhere (cannot recall source) that a programmer was capable of doing extremely complex and tailor-suited web pages using Drupal without writing a single line of code (using hooks), just using the GUI of suitable contributed modules. Is this at all possible?

Are the Drupal 7 (and 8) functions thought as a way of extending capability via contributed modules, or is it good practice to tailor-suit your own functionality via hard-code modifications of SQL queries via hook_views_pre_view, hook_views_query_alter, hook_views_pre_render, theme_preprocess_page and all of these available functions?

I suspect that most of the time being ready to face a difficult project would need to be spent on trying dozens of different contributed modules, mutual compatibility, flexibility, etc., in order to reduce the custom code you would need.

I am not sure about this commentator being truly honest, but I find difficult not to create my own custom modules and modify queries, template.php, etc., in order to get the desired results, sometimes even by fixing long existing bugs in some contributed modules.


texts:
I have a content type with an image field. How do I update all my images to have the node title as the alt and title of the image?
I don't want to edit hundreds of nodes...

Thank you.
Daniel


texts: How do I get Search API to index rendered content including referenced nodes?

texts:
We are building av website in Drupal 8 where the content is divided into 3 content types;

Basic Page, the scaffold for all visual pages like "About, Features
etc."
Content Block 1, for a layout with one text field and one image
Content Block 2, for a layout with one text filed and two images

Nodes on Content Block 1 and 2 are referenced in on Basic Page nodes to enable different designs for each Page. This is done using a view block on Basic Pages.

Now, to the question:

Is there a way to set Search API to index only nodes on Basic Page, rendered with the content of referenced Content Block nodes?

I also need to exclude Content Block nodes from being indexed and showing up as nodes in the results, but that I have a grip on.

I hope my question is clear enough. Please comment otherwise and I will be happy to elaborate.

Thanks!


texts: How to add the search form in Bootstrap theme?

texts:
I am trying to set the search form with submit button in the Navbar as shown in the following image(Following image I have taken from the Bootstrap tutorial page).

Now, When we install the default Bootstrap theme from drupal.org it will be ended up like as shown in following image.

Now, if I simply move that block to the Navigation bar, it will end
up as shown in following image, which is not a solution for this.

So, I dig out on the bootstrap tutorial
page and found the
following code.

So, I can paste that code in the page.tpl.php and can achieve as
shown in following image, BUT it will not search anything, as it is
just a plain HTML code.

How can I achieve that? If CSS is the answer, for now I do not want to go with that. As IMHO, since this display of search form is described as a default on the bootstrap tutorial and in every theme demo display pages, So, there should be some way to enable that, or some way to place that.

Any suggestion or direction? Thanks.


texts: How to render fieldgroup programmatically?

texts: I have got the fieldgroup info from field_group_info_groups() , but how to attach this fieldgroup to a custom form I am building?


texts: Best way to migrate inline images in content fields to drupal 7

texts:
I am trying to create say "Articles" manually using scripts. Basically I am reading data from mysql table and creating nodes programmatically by looping the tables.

However in mysql content field which is the Body field of my Article content type has the data with inline embedded images and links.

 Some more dummy text.

What would be the best way to migrate images for such cases?


texts: How to make existing public files private?

texts:
Let's say I have a node type "Article" which has a field "File" which is set to handle public files. A lot of articles and files get added.

Now the specs suddenly change and the "Article" will move behind a login and therefore also the attached files must be changed to be not publicly accessible anymore.

I already found out how to change the file system for the file field from public to private pretty easily by reimporting the manually updated field.storage.node.field_file.yml config. But: this only affects new files that will be added after the switch. It doesn't work for existing files. They still are accessible publicly. Many thousand existing files would need to be manually reuploaded to also make them private.

Does anybody of you have solved that in D8 before? If so, then how?

As all I can think of right now is to programmatically query all "Article" nodes, then foreach through all nodes, get the files, temporarily store them somewhere else, empty the field out, then try to reupload the files programmatically (probably my next question) and then resave each node.

Does that sound reasonable? Or can you think of any other approach that might work here (in D8)?


texts: Views issue: How to pull content from two different taxonomy vocabularies on same page

texts:
I have two Content types:
Article1 with vocabulary1 with taxonomy terms: A, B, news;
Article2 with vocabulary2 with taxonomy terms: X, Y, news.

I need to create a /news view page that displays content from both Article1 and Article2 tagged with "news".

I tried to use Filter Criteria:
Has taxonomy term - vocabulary1 -> news
OR
Has taxonomy term - vocabulary2 -> news
Nothing shows.

Please note that I set up Pathauto to publish in /news/article_title both Article1 and Article2 tagged with "news".
Maybe a contextual filter could be used to pull all content from /news/*?

Thanks in advance,
Cosmin


texts: How can I upload 1000s of nodes per hour to a live drupal 7 site and avoid deadlocks?

texts:
Not too long ago I wrote about deadlock here: PDOException: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock;

Despite everything my development team tries to do, we still get errors like this:

  PDOException: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found   when trying to get lock; try restarting transaction: INSERT INTO     {location_instance} (nid, vid, uid, genid, lid) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => 1059 [:db_insert_placeholder_1] => 1059 [:db_insert_placeholder_2] => 0 [:db_insert_placeholder_3] => cck:field_item_location:1059 [:db_insert_placeholder_4] => 1000 ) in location_save_locations() (line 974 of /var/www/website.com/sites/all/modules/location/location.module).

Despite the specific table in that example, we get this error on other tables.

Here is my situation. I have taken a large University project. At any given time there are 50,000 campus residents who use the system daily.  In addition to that, I am migrating 100s of 1000s of items of content both manually and through custom module code (migration from the old university data) to this new Drupal 7 site.

This error is killing us, to the point where we are almost ready to scrap the last years worth of work and go with something else if Drupal cannot handle this type of load.

But that is more or less my question -  How can Drupal handle this type of load?  How can I organize my work flow to be able to handle this much activity? Is this a Drupal issue? A database issue?

Specifically, I am running Ubuntu, LAMP stack 16GB RAM. I am open to any suggestion whether it be Drupal related, database related, server config related, or a different work flow to work within Drupal's capabilities, so feel free to suggest anything if you have experience with this much activity.


texts: Menu link to the most recent article with a certain taxonomy term

texts:
I am using Drupal 7 and have been trying to figure out following:

How do I make a menu link to the latest article that has been classified with a certain taxonomy term? For example, I want to have a menu link called ‘Lifestyle’ and by clicking that I expect to get the most recent article classified with taxonomy term ‘Lifestyle’. For SEO purposes I prefer if the menu link would contain the title of the article.

I tried to do this using Views module with basic filters, but I have some issues with this approach:

As a result I do get a latest article with a certain taxonomy term, but the page title is displayed twice (the first one is a link to article itself). How do I remove this properly in a Drupal way (I don’t want to use CSS to hack it).
Also, as a result, Views generated URL that looks like this: http://www.mydrupalsite.com/articles/latest/1 (where 1 is a taxonomy term id). I would like it better if the URL would point directly to the node like this: http://www.mydrupalsite.com/articles/the-article-title-here

Any ideas?

Thanks.


texts:
I am new at Drupal , and I am using version 7.43. I have already installed Bootstrap, and now I am defining the menus. But to realize Multilevel submenus I need the folder of bootstrap_subtheme

I searched but I couldn't find that folder, I found just the Bootstrap folder.

Any hints?


texts: Layout of multiple items of the same field in Panels node template

texts:
My content type is a preview of a music album so the fields include mp3 file and text fields about the track (title etc). I am using a panels node template which looks like this

This works fine for one track and the result looks like this:

But if I add a second track it looks like this:

ie

All items in Field 1
All items in Field 2
All items in Field 3

How can I make it look like this:

ie

field 1 item 1
field 2 item 1
field 3 item 1
field 4, item 1

field 1 item 2
field 2 item 2
field 3 item 2
field 4, item 2

etc

I think I would have the same problem in Views.


texts:
My ISP updated PHP from 5.4 to 5.6 and my Drupal 7 site broke. Normal pages have mysql errors, and update.php says I need to install a PDO connector.

How do I fix this?


texts: Custom maintenance page breaks module install process

texts:
I followed the steps on this page: https://drupal.org/node/195435 to style drupal's maintenance page.

All well until the moment I try installing another module (doesn't matter which one) via an url. It does not install the module and it just shows me my maintenance-page--offline.tpl file (-which should only be shown when the database is offline).

The problem also shows up when installing a new theme.
I'm running the latest drupal version (7.23).

Anyone having the same problem? What could I be doing wrong here?


texts: Add another button for UI field set in admin

texts:
I feel like I must not have the correct terms when searching on this topic.  I am relatively new to Drupal.  What I need to create is a field set in admin which has an Add Another Foo button so any given node could have as many Foo field sets as desired.  These would be draggable to sort for the node and accessible for the public facing twig to display.

Can someone help me with the terminology for this and if there is a tutorial on implementing I would really appreciate a link!

Example gui:


texts:
I have several custom node modules and which are creating their own types.  When I perform a node_load and node_view locally, all the content of the node is there.  However, when moving to a development server the node markup is missing:

 (sorry so small)

VS.

local theme is default Bartik, and devel is a custom Zen based theme
data is present in the field_body tables for both
uid is 0 for both
full_html format for both

Viewing the node page on devel server has same missing text.  The only text being display/rendered is the node title and user/creation info. I checked all the modules installed that have a node_view hook but none appear to be preventing/causing the markup from being generated (book, comment, trigger, devel_node_access, and a custom one).

We are using ApacheSolr and obviously this is preventing the nodes/pages from being indexed correctly since there is no textual content being sent. The missing content is only on the custom module node types, not any manually created types.

Any ideas as to where/why this is happening?


texts:
I'm trying to use Views to randomly display an image(or node) from a content type. So everytime(or every 10secs) a user refresh their browser a new random image should display.

Here is my setting in Views. I added "Global: Random(asc)" in Sort Criteria, 1 item on Pager, and "Never Cache" Query results "10"seconds Rendered output on Caching setting.

However, the page does not render a new image after 10sec browser refresh for Anonymous user, but any login user.

====== Update June 22, 2015 at 12:26pm ======
optional solution:
* exclude cache on specific page by using CacheExclude module
* still looking for solution to exclude cache on specific views(and view block) for anonymous users. Update: Found a solution for Views by using Views Random. This module allow user to enables cached views results randomly.


texts: Multi instance Drupal on single server. Is SSO possible to be implemented?

texts: may I know if we can configure single sign on , on a single server that have 2 Drupal instance running in parallel?


texts: How to tell if content has been migrated

texts: I am using drupal2drupal migration. How can I indicate that some content has been migrated as opposed to being manually added.


texts:
I have a Drupal 8 form I want to show via JavaScript code to make it appear as a popup across multiple pages. The form is rendered through an AJAX response in a controller. I can see the response using $.ajax(). How can I invoke the AJAX response to display on the page?

The JavaScript code is the following one.

$(document).ready(function() {
  $.ajax({
    url: '/aao_additions/modal_form',
    // Data parameter is the ajax response data for the intersitial popup.
    success: function(data, status, jqxhr) {
      console.log(data);
      console.log(status);
      var popup = Drupal.ajax({
        url: "",
        base: false,
        element: false,
        progress: false,
      });
      // Simulate an AJAX response having arrived, and let the Ajax system handle it.
      popup.success(data, "success");
    },
    // Error function for if the modal form cannot be loaded.
    error: function(xhr, desc, err) {
      console.log(xhr);
      console.log("Desc: " + desc + "\nErr:" + err);
    },
  });
});

I receive an error on Drupal.ajax. I think it is preventing the response  rendering.


texts: node/[nid]/edit does nothing. how to troubleshoot?

texts: I'm trying to edit a node in Drupal 6. The edit tab is visible and clickable and everything, and directs to the proper path (/node/[nid]/edit) but... nothing happens. How do I troubleshoot this? I don't see any weird edit page templates in the theme or anything. I didn't develop this site or this theme but am now maintaining it. How do I begin troubleshooting something like this?


texts: Autopublish content from drupal to wordpress

texts: My question is that i am having a drupal blog and wordpress on different different domains. I am looking for a module so that whenever i publish some content in drupal it should also published in wordpress.


texts: How to Fix/Clean Lambda warnings/errors from Views PHP

texts:
I used views php to get the values from the field collection of the saved node in order to create a front end select list on views.

It does what I wanted it to do but there are a bunch of warnings and notice and I would like to clean it.

This is just a part of the warning and notice that appeared.

And this:

It's a repetition of errors for my different variables.

This is an example of my code:

<select class="number_of_person">

    <?php
    $wrapper = entity_metadata_wrapper('node', $row->nid);
    if (isset($wrapper->field_criteria)) {
    $prices_number_of_person= array();
    $min_and_max_number_of_person = array();
        foreach ($wrapper->field_criteria as $i){
              $price_loop1[] = $i->field_price->value();
              $min_and_max_loop1[] = $i->field_criteria_name->value();

        }
         $prices_number_of_person= implode(",", $price_loop1);
         $min_and_max_number_of_person = implode(",", $min_and_max_loop1 );

         $split_min_and_max_number_of_person = explode(",", $min_and_max_number_of_person );
         $split_prices_number_of_person = explode(",", $prices_number_of_person);

         $length_number_of_person = count($split_min_and_max_number_of_person);

        for ($number_of_person=0; $number_of_person < $length_number_of_person; $number_of_person++) {

        if($split_prices_number_of_person[$number_of_person] !="" ){
         echo '<option value="'.$split_prices_number_of_person[$number_of_person].'" class="options">'.$split_min_and_max_number_of_person[$number_of_person].'... + ₱ '.$split_prices_number_of_person[$number_of_person].'</option>';
        }

         else{
          echo '<option value="'.$split_prices_number_of_person[$number_of_person].'" class="options">'.$split_min_and_max_number_of_person[$number_of_person].'</option>';

              }
         }

     }
    ?>

    </select>

I was wondering if there is something that I need to add to my code to get rid of the warning and notice?

Thank you in advance!


texts: How to create a default image per taxonomy term?

texts:
I want to associate a different default image with each taxonomy term.

I saw this module - https://www.drupal.org/project/taxonomy_image - but it's in alpha.

Anyone got any recommendations how to do this?

Many thanks!


texts: Importing multiple images from Dropbox with Feeds

texts: As part of a product import, I am trying to import images from a link contained in a column of an Excel file.  Each link points to a Dropbox folder with 2 image sub-folders (named PRINT and WEB).  Is it possible to import multiple image files from a Dropbox folder using Feeds?


texts:
after performing a search using Views exposed filter,the filter is cached and even I change that I get the same as previously results.How can I solve that?
thanks