texts: How to display different page content to Anonymous user and to Authenticated User in drupal 7.x?

texts:
Am don't have much knowledge on drupal. Just starting my first drupal site. I created a "content" under a menu named "information". The menu "information" is given permission for both "anonymous user" and for "authenticated user" as well. As i click the menu "information" (as in anonymous user), the content i set was "please login as authenticated user, if you unable to login, please contact the administrator".

Then, i login as the "Authenticated user" and i click the menu "information", am getting the same content message as *"please login as authenticated user, if you unable to login, please contact the administrator."*Please, i don't need this content message, under "information" menu if i login as the "authenticated user".

I needs to "DISPLAY DIFFERENT PAGE CONTENT TO ANONYMOUS AND TO AUTHENTICATED USER"?
I don't know how to proceed this ? Can anybody please help me out the step by step procedure to do this task ?  Please help me out . Thanks in advance...


texts: If there is a basic page with the route '/about', how can I link it in a template file?


texts:
I am using apache solr 3.x .
Right now, I mixed the data from my two websites into one solr by mistake. I set one solr on the first website server and set another website's Apache Solr search to link to this server. I don't know they will mess up when I set this. But right now, the first website doesn't add any data into the solr, and all the data from the other website can add the data to the solr.

Is there anyway that I can retrieve each website data to make them show in the correct position?


texts:
How do I create a popup which can use the node variables after saving a new node?
For example, I want to show a popup with the social media share button. Should I use node_save()?


texts: How can I programatically select the node template to render a node in Drupal 7

texts:
I have a node--mynodetype.tpl.php, the problem that I have is that I have a module to show public contents.

In this module I need to render something completely different to what is in node--mynodetype.tpl.php.

So I was thinking to create a file named, for example, node--mynodetype-public.tpl.php but I was googling and I can't find a function to select one node template or other node tpl.

Is this any function to select wich node template to render?

Thanks in advance.


texts: Why does hook_menu() not show my items in menu?

texts:
Here's my code and I can't get why hook_menu doesn't work. My block menu doesn't showing in menu. As I understood this code (hook_menu()) should show link in which for will work drupal_post_form using function instance_export_form.

So I mean that when I follow admin/config/content/instances_export I get just content menu list, not a form which I need

    <?php

function instances_export_block_info()
{
    $blocks['instances_export'] = array(
        'info'  => t('Instance export'),
        'cache' => DRUPAL_CACHE_PER_ROLE,
    );

    return $blocks;
}

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

    $items['admin/config/content/instance_export/settings'] = array(
        'access arguments' => array('administer site configuration'),
        'title'            => 'Configure export',
        'description'      => 'Chose what you want to export and where',
        'page callback'    => 'drupal_get_form',
    );

    $items['admin/config/content/instances_export'] = array(
        'title'            => 'Form to export data',
        'page callback'    => 'drupal_post_form',
        'page arguments'   => array('instance_export_form'),
        'access arguments' => array('administer site configuration'),
    );

    return $items;
}

Here info file

 name = Instance export and import module
    description = Allow to export synchronize few instance of Drupal
    core = 7.x
    version = «7.x-1.0»
    configure = admin/config/content/instances_export
    files[]=instance_export.module


texts:
Possible Duplicate:
  Meta tags aren't saved with all content types

I'm using Meta Tags to control the meta data on my Drupal 7 site.  This module seems to give your nodes control over what your page descriptions display via the vertical menu at the bottom of the page you're editing.  This description doesn't show though.

The only thing I can think of is the global options which you can find by "configuring" the module itself.  If I set a global page description, it will show on all pages, and if I disable it, or leave it blank, there will be no description shown.

Why is the data set on individual nodes not overwriting this global quality?  There doesn't seem to be another module to help me with descriptions either.


texts: How to remove the click event on an Ajaxified form's submit buttons?

texts:
I've created several forms with Drupal 8 directly in admin or with Form API. I've added some client side validation with this jQuery plugin : jQuery Validation Plugin.

Everything works very well. Now my client asked me to open one of these form in a popin. So I've installed this 2 modules :
Contact Block (The Contact Block module provides contact forms in a block.) https://www.drupal.org/project/contact_block

I can open form in a popin and it works well but after validation, the page is reloaded and it is not UX friendly since we are in a popin.
So I've installed this module :
Contact ajax (implements ajax submission for core Contact form in Drupal 8.) https://www.drupal.org/project/contact_ajax

It works well but the submission is done before I can execute client side validation.

The problem seems to be the priority of execution.

I've tried to apply preventDefault on the submit button but it doesn't work.

$( "#form #submit-button" ).click(function( event ) {
  event.preventDefault();
  //validation code
});

I've found this topic but I donc know how to implement the code :
How to prevent an Ajax form from submitting

I've also found this topic :
https://www.drupal.org/project/clientside_validation

Can you help me to understand how I can  block the click event on an Ajaxified form's submit buttons ?

EDIT

I've tried this module : Clientside Validation and apply this patch 2952233-5.patch

It works, the Ajax submit button is disabled. The solution is based on that answer.

For now it has a bug : the form is validated but I don't see the confirmation message at the end.

Then, I've copied the code from this patch  in my project and it works.


texts:
I'm having problems saving my custom entity to the db. I created a custom entity called 'review' using hook_entity_info() with a custom controller. I have specified some parameters in the controller using:

      public function create(array $values = array()) {
      global $user;
      $values = array(
      'rid' => '',
      'uid' => $user->uid,
      'nid' => $_GET['nid'],
      'created' => REQUEST_TIME,
      'changed' => REQUEST_TIME,
      'published' => 1,
      'quality' => '',
      'design' => '',
      'versatility' => '',
      'design' => '',
   );
   return parent::create($values);
 }

Everything seems to be working just fine but when I try to submit my form to create a new entity not all fields are saved in the db.

I attached the value of the fields in the form using field_attach_form('review', $review, $form, $form_state); and in my submit function I have this:

$review_submission = (object) $form_state['values'];
field_attach_submit('review', $review_submission, $form, $form_state);
$review = entity_create('review', array('type' => 'review'));
$entity = entity_metadata_wrapper('review',  $review);
$entity->save($review_submission); //This saves info but not fields

This creates a new entity but the fields 'quality', 'design', 'versatility', 'relevance' are not saved. However if I use this instead in my submit function:

review_submission = (object) $form_state['values'];
field_attach_submit('review', $review_submission, $form, $form_state);
$review = entity_create('review', array('type' => 'review'));
$entity = entity_metadata_wrapper('review',  $review);
entity_get_controller('review')->save($review_submission); //This saves fields but not info

those fields are correctly saved BUT then 'rid', 'uid', 'nid', 'created', 'changed', 'published' are not saved.

What am I missing? How can I saved the entity info and the values from the form fields?


texts: Translated node overwrites other languages

texts:
I have a content type with a multivalue text field. Each time I add a translation, the translated node overwrites the source node. Also happens in opposite direction. It seems that whatever I do, the field always overwrites. The node title doesn't though.

I have synchronisation turned off on my content type. What could it be?


texts: Selenium IDE for testing Drupal 7 with Media and Paragraphs

texts:
I'm writing Selenium IDE tests for my Drupal 7 site and it's great. The issue is recording/writing tests for actions that aren't simple "clicks". I have instructions for using the RunScript action to enter text into a CKEditor box, but I've run into two more places where I can't figure out how to record a click:

browsing for a file using the media browser provided by the Media module
add a "paragraph" using the Paragraphs module

Has anyone made Selenium IDE tests that include either of these actions?

Thanks in advance!


texts: Page with Mix of Dynamic and Static content

texts:
I have to create a page that:

has a mix of dynamic and static content
can only be viewed by authenticated users

Currently, this is how I'm approaching it (but I know there is a much better way)

created a page
created Views blocks that are pulling in dynamic content and set permissions so that only authenticated users can view
created static blocks and set permissions so only authenticated users can see

Is there a way to create one Views page that pulls in a mix of other Views blocks and static blocks? Is this at all possible? If not, is there a way to set the permissions for a basic page so that I would only have to set permissions once instead of doing it for each Views and static block? I know there is TAC module and Content Access but I had uploaded and it wasn't working well with the current site.

Thank you for any guidance you can provide!


texts: PDOException "column not found" but does exist

texts:
This is on Drupal 7.39 with Domain Access and Ubercart

When pressing "checkout" button the site returns and error which shows in the dblog as:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'uc_payment_method_credit_checkout' in 'where clause': SELECT value FROM {variable} WHERE name =uc_payment_method_credit_checkout LIMIT 0, 1; Array ( ) in uc_domain_variable_get() (line 291 of /. . . /uc_domain.module).

Line 291 of the uc_domain_module is:

$result = db_query_range("SELECT value FROM {variable} WHERE name =" . $variable, 0, 1)->fetchField();

The column exists in the variable table and I triple checked it for an exact format match  (they all exist for the variable_set commands  I placed to be used in the install file)

This module is a Drupal 7 version module but is not an official project owned or maintained by anyone though it was originally written by the Drupal 6 project author and maintainer and released by him at https://www.drupal.org/node/946574.  I am working with that released file as modified by "henk" - but this section is unchanged by "henk" either

The equivalent command in the Drupal 6 version is near identical

D6 version starts . . .
  $result = db_result(db_query("SELECT value FROM {variable} WHERE name = '%s'", $variable));

D6 version ends . . .

I put a space in the => " . . . WHERE name = " . $variable . . ." to match the D6 version

But the error now simply reads  " . . .  WHERE name = uc_payment_method_credit_checkout . . . " with the space at "name = "

It seems to work -partly as it created an order entry in uc_domain_orders when i tries to test it - somehow - even though the jump to checkout failed.

This is not not like any other "column not found" issue I have searched here.

Anyone have any words of wisdom or ideas ???


texts: I am having rather strange issue. I have created custom CCK with image upload field. To browse a server folders I've installed a CCK Filefield and configured it to work with IMCE , however I can't see images (uploaded with FTP), unless I upload them through IMCE itself. The strange thing is that in Description field I have also IMCE file browser wich "see" correctly all images. What am I missing? Thanks


texts:
Drupal version: 7.14

Currently drupal save the downloaded filename as the last part of the URL, just like a file link "http://example.com/system/files/abc.txt", the default saved filename is "abc.txt".

I want to ask is how to change "abc.txt" to other filename such as "xyz.txt" while downloading.


texts: I am using module_invoke() many times in the front page to invoke lots of block. Does this effect the site performance? Thank you.


texts:
I have a site where a client wishes to sell products that have a lot of different variations (ie size, colour, length etc), but each of these will make a slight change to the price. I know about the ability to make variations of products so that the price changes when you pick different items in the drop downs, but these have to be manually entered. For my client, each time the variations are open to the end user, the price increase will always be the same.

Both have the size option available to user -the price will increase on top of the base price by the same increment based on the selection.

eg:
Small = no change
Medium = +£5
Large = +£10

Product A, starting price: £10
Product B, starting price: £20

So Product A with medium will be £15, Product B with large would be £30

I realise in this example it would be simple to add this in manually, but if she has 3 (or more) different options open to the end user, with upto 10 options within, multiplied by her entire product range, it would take forever to do.

What I had thought is if it was possible to add a price addition field to the product category listing, and then use a (rule/module?) to automate this price being added on. Is there anything already out there that does anything like this, or if not, how could I go about creating it.

Many thanks


texts:
I have embedded view in a node with following code:

<?php
 $view = views_get_view('articles');
 $view->set_items_per_page(1);
 $view->set_offset(2);
 print $view->preview('page');
 $view->destroy();
?>

I just need to display only one specific row (that's why I'm using offset). I couldn't find a way to retrieve one specific row with any other method.

This code is acceptable but it has pager because that view has more than one row.
Is there a way to remove pager like in Views UI? In Views there is a option to not use a pager but "Display a specified number of items".

I would like to remove it completely from code without CSS.


texts: How to use views to display a list of views pages?

texts:
I currently have a view that outputs all the current nodes on a site in a table format to display things like:

Title
Nid
Path
Metatag Title
Metatag Description
Metatag Keywords
Post Date
Updated Date
and an edit link.

We mainly use this view to review our SEO optimisation in terms of the meta tags and the path constructions for each "page" on the site.

It's a nice system, but it has one major failing - it does not include any views pages - things like event listings or news listing pages. These views pages are just as important for SEO optimisation but I cannot get them to be included in this review list.

The metatag information is provided by the D7 Metatag module. With that module, we can add tag information to views pages, which is great, but to complete this admin view, it would be good to be able to include the views pages on the site in the above list as well.

It would be fine for this to be displayed in a standalone output (ie not included in the full table page above) but I cannot for the life of me find a way to get this done.

Is there any way to create a view that will list all view pages on a site with their associated meta information?

Thanks!


texts: Get the paragraph fields of a content type in a loop in another page

texts:
I have added a paragraph in content type News.
I want the fields on this paragraph in my custom home page in a loop.
As The News Contents would be shown in a carousel in home page.
I am new to drupal. Can anyone help me?
I have tried using views. the content is rendered. but as the view has extra divs, the design breaks.
Drupal 9 using twig.
Using semantics view, i can modify or add classes to the div. but i needed to get rid of the outer two divs i.e. from container and views-view.html.twig. As the carousel is out of the view. and the view is acting like a single carousel entity.


texts: add arbitrary descriptions div in a node edit or add form

texts:
the need seems simple but I don't find anything about this.

I'd like to add descriptions (div class="description"), non related to specific cck fields. I though I could use these to compute informations inside it (to sum up some of the choices of tricky content types) or to show up an information when choosing a particular option (like, to show a "cck description" rather than a true cck widget when using conditionnal field).

template.php does not seems to be the right way : I got a lot of ccks, and a lot of content types, I just cant create a hook for each case I need this is not flexible enough. I suppose.

is there any 'dummy' cck field with just a description array and no widget I could use like a normal cck, and locate as any other cck in my forms ?
or : how could I write a 'cck description' module (I'm ok with php and drupal module simple setup)

Im using D6.x


texts: Drupal admin themeing and customizations

texts:
I am looking into how I might customize the backend, but re-themed is not the ultimate agenda. Say for instance, 'admin/content', where I have filter options for various content types. Below that I have a table of content sections.

I want to completely replace the table and render the list in the left region of my template and use the content area for a WYSIWYG editor -- this is a common UI for basic CMS and I figured would be a good advanced learning experience.

I started poking through the code and quickly discovered I have no idea what content/form/blocks are in which regions in the admin section.

I found the module that implements the menu for 'admin/content' but that wasn't very helpful.

My question is: In the admin portion of a drupal setup how would I position custom block module content in the right region of a template when using block admin seems only to affect the front-end of the site?


texts: not able to display the real name of the users

texts:
First of all, I am not a techie and have picked the codes mentioned below from various sources. I have added two new fields to the user profile - 'firstname' and 'surname'. I am using a custom theme and on one of the places (on a node), I need to display the real name (making some code changes) instead of the username.

I am replacing the existing code -

<?php print $node->name ?>

With this -

<?php
     $profile = user_load($node->uid);
     $profile = user_view($profile);
     $firstname = render($profile['field_firstname']);
     $surname = render($profile['field_surname']);
     print $firstname.' '.$surname; ?>

However, a strange thing is happening. I am able to print the surname correctly but the firstname is blank every time, even when I tried to print only the firstname (or the surname). Why is it that the firstname is not getting picked? What changes should I make?


texts: How to use drupal_http_request for send data?

texts:
I need some help in sending data in an array (POST) to a webservice (REST). I need some examples in how to use the function drupal_http_request().

Now, I'm using cURL with PHP but I need to replace it with drupal_http_request(). And I see that it's easier to use in Drupal.

If my first page is the login (http://[ip]/users/sign_in) and I'm using "User:Pass" to enter to main page(http://[ip]/event). Then, I select the menu for view the data that I send from my form in Drupal (http://[ip]/event/mobile/management).

How to do this with drupal_http_request()?

UPDATE:

function send_data_form_submit($form, &$form_state) {

    $name = $form_state['values']['name'];
    $email = $form_state['values']['email'];

    $attendee = array(
        'name' => urlencode($name),
        'email' => urlencode($email)
    );

    $attendee = http_build_query($attendee, '', '&');

    $url_login = 'http://[ip]/eventmobile/users/sign_in';
    $url_target = 'http://[ip]/eventmobile/attendee_management/attendee';

    $use  = array(
      'email' => 'root@root.com',
      'password' => '123456'
    );
    $user = http_build_query($use, '', '&');

    $headers = array('Content-Type' => 'application/x-www-form-urlencoded');

    $method = 'POST';

    $result_1 = drupal_http_request(url($url_login, array(absolute => true)), $headers, $method, $user); //I get a http_code = 200. OK
    $result_2 = drupal_http_request(url($url_target,array(absolute => true)), $headers, $method, $attendee); // I get a http_code = 500. Internal Server Error

}

UPDATE 2 (Using cURL):

$attendee = array(
        'name' => urlencode($name),
        'email' => urlencode($email)
);
$userpwd = "root@root.com:123456"
   $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url_target);
        curl_setopt($ch, CURLOPT_HEADER, TRUE);
        curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
        curl_setopt($ch, CURLOPT_TIMEOUT, 50);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $result = curl_exec($ch);
        $getinfo = curl_getinfo($ch, CURLINFO_HTTP_CODE); //I get http_code=200

        if(preg_match('#Location: (.*)#', $result, $r))
                $url_redirect = trim($r[1]); //The URL of LOGIN

        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        curl_setopt($ch, CURLOPT_URL, $url_redirect);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
        curl_setopt($ch, CURLOPT_USERPWD, $userpwd);
        curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $page = curl_exec($ch); // Return string: Evaluating...
        $getinfo = curl_getinfo($ch, CURLINFO_HTTP_CODE); //I get http_code=200

        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $attendee);
        curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_TIMEOUT, 50);
        $result = curl_exec($ch); // Return string: Evaluating...
        $getinfo = curl_getinfo($ch, CURLINFO_HTTP_CODE);// I get http_code=200

    curl_close($ch);


texts: How to implement date filters with operators like = in a JSON query string?

texts:
We use Drupal 7 and the Service (Version 3) module. First we created a view using a date with a "between operator" as a filter, which works fine. Then we added a service view as .json format inn which we try to pass that date operator in the query string of it, but we cannot get that to work.

The query string we are using looks similar to this example:

http://example.com/drupal/api(endpoint)/sampleview.json?field_invoice_date_value<='2013-12-31'&field_invoice_date_value>='2013-11-31'

To produce the output of the view in json format, we used the (amazing!) Services Views module. We added the service view path to the services resource. As mentioned above, the date filtering is working fine in the view (as confirmed by our testing of the view, without using JSON). But if we try using JSON then the between operator for the date is for unknown reasons not (yet) working.

Below are 5 screenshots to further explain what we're trying to implement (and what we got to work so far).

1. Service View

2. Date filter

3. View output

4. Adding service view as service resource

5. JSON query string variations

  http://web.com/drupal/api[endpoint name]/chart(view service pathname).json?field_invoice_date_value>=2013-11-01&field_invoice_date_value_1<=2013-12-31

The above string is NOT working, note the filter in it like so:

  "field_invoice_date_value>=2013-11-01&field_invoice_date_value_1<=2013-12-31"

Other filters are working correctly, like this one:

  http://web.com/drupal/api[endpoint name]/chart(view service pathname).json?facility_name_value='test'

Since we need the JSON output using that 'between date', we also tried this variation, which is NOT working either:

  http://web.com/drupal/api[endpoint name]/chart(view service pathname).json?field_invoice_date_value='20131210--20131213'

When testing with the string above, we received the following error message too:

"Cannot create references to/from string offsets nor overloaded objects in common.inc on line 6579"

My question: Please let me know how to implement the date between operator in a JSON query string, or any other ideas you have to further debug this issue.


texts: Can't access module settings (Devel module)

texts:
I have a module that's enabled and working, but the configuration options won't show.

The module in this case is Devel, which I've used on other sites with no problem.  In this site, whenever I click on 'configure' in the Devel module listing, it takes me to the configuration page, but without a Devel option.

I've cleared the cache and re-enabled multiple times. The module is definitely enabled because I can use functions like ddebug_backtrace().

What else can I try?

EDIT:

I've uninstalled and re-installed the module, and still have no luck. I need an advice on how to trouble-shoot this.


texts: nice menus - how can I keep all sub-menu expanded in my  page?

texts:
On my front page, I want to have my sub-menus expanded and have them to act as it should on other pages.

I'm using the Nice menus module.

How can I achieve it?


texts:
In my views-view--etc.tpl.php file I have

<div class="<?php print $classes; ?>">
<?php print render($title_prefix); ?>
<?php if ($title): ?>
<?php print $title; ?>
<?php endif; ?>

Which I have amended to

<div class="<?php print $classes; ?>">

My View Title

I want to use

<?php print views_embed_view('viewname', 'displayname', $node->field_fieldname['und']['0']['tid']); ?>

to embed the view but if the view returns zero results I still end up with and empty div and h2 title. Using module_invoke completely hides this, as does encapsulating the tpl file in  "if ($rows):", neither of which I want to do.

Can someone please tell me what the function is to use to completely hide the view div classes and title in the tpl file if no results?


texts: Drupal Commerce - product attribute price based on quantity

texts:
I'm here with a tricky question about Drupal Commerce.
Here's my need:

I have a group of products that have a variable price based on quantity.
Each product has specific (only for that product) attributes that can modify the price.
[The real problem] Each attribute price is variable based on the original product quantity.

A real example:
0-300 pieces -> 0.75€
300+ pieces -> 0.52€

OptionA 0-300 pieces -> 0.07€
OptionA 300+ pieces -> 0.05

So if I buy 400 pieces + OptionA i pay 0.52+0.05 each, but if I buy 200 pieces I pay 0.75+0.07.

Basically what I want to achieve is to have the attribute price dinamically changed depending on the quantity.

How could I achieve such result? I can't really find a way.
Thank you in advance!


texts:
I've already added the field, but it shows only when I edit an order; there is nothing in the checkout page.

I know there is a module, but only for Drupal 7.

How can I add a field on the checkout page?


texts: Filter view results by "created"/"authored on" date - shows all content regardless of post date

texts:
I've been throwing myself at this for a while, apologies if I've missed anything stupidly obvious.
I'm trying to create a table of statistics for content submitted by all users (using Views Aggregator Plus to do the number crunching) and for the most part, it works fine. If I only wanted to show results from all time, it would be perfect.
However, I would like to show the same table but only aggregating content from the past 30 days -- and this is where it gets tricky.
No matter how I configure the filter, if I'm using any of the default content fields (created, updated, etc) with the default date filter options of date in machine readable time or offset from current time, it returns all results.

I have the SQL query visible so I can see what's going on, and it doesn't appear to be adding the date filter to the query at all.
This is my basic query:
SELECT node_field_data.nid AS nid
FROM
{node_field_data} node_field_data
WHERE (node_field_data.status = '1') AND (node_field_data.type IN ('type1', 'type2'))

It doesn't change when I adjust the filter options above.
However, if I use the "Date in YYYY format", which is a filter from a contrib module, it shows in the query and filters like it should:
SELECT node_field_data.nid AS nid
FROM
{node_field_data} node_field_data
WHERE (node_field_data.status = '1') AND (node_field_data.type IN ('type1', 'type2')) AND ((YEAR(FROM_UNIXTIME(node_field_data.created)) >= 2021))

The issue doesn't seem to happen with custom date fields. I'm wondering if there's something kooky going on in how Views is handling the dates that are created by the system? When I look at the form display for the content, it shows them as using different "widgets".
Fields created by the system use "Datetime Timestamp", where custom date fields use "Date and Time".
It seeems odd that custom date fields filter beautifully, but default ones don't. And double weird that I would need a contrib module to make use of that information.
I'm running Drupal 8.9.1, everything is up to date. I've tried running from a clean install with the same results. If I run the content through Search API and include "authored on" as an indexed field, the date filtering works but the table aggregation doesn't sort properly.
How do I get Views to recognise and use that data so that I can filter my results down to content posted in X amount of days? Or failing that, what other steps could I take to try and work out where the issue is?
Thanks in advance!


texts: Drupal 7 and google maps v3. Which is the module to use ?

texts:
I need to store lat/lng into a content type for the obviously normal thing: display a google maps. But for the moment I have see that the better modules for google map integration using v2 that it is deprecated.

In my content type I request the others data (street, city, country, county) so I do not need a module that need to insert this data. This because I need to insert this data into a SOLR server.

So, which is the best module for Drupal that use google maps v3 ? Or I need to create one custom that use (for example) gmap3.net's js script ?

Thanks.

M.


texts: How do i implement symmetric relationship with node reference module in drupal 7?

texts: i have a content type with one node reference field to same content type and so i related that content type as like  A->B,B->C,C->D,D->E and so on.But i want to relate E to C,B and A along with D automatically and so i can list out all A,B,C & D in E node page as referenced nodes.Can you tell me how can i implement this type of references in Drupal 7?


texts: Field is required, but server side validation is not catching it

texts:
I have a multistep checkout form in my commerce module.  Inside Order Types i have added a field called Phone Number and set it to required.  And then I have a custom module which has a ContactInformation.php file under CheckoutPane which adds the field in buildPaneForm

    /**
 * Provides the contact information pane.
 *
 * @CommerceCheckoutPane(
 *   id = "contact_information",
 *   label = @Translation("
Contact information
"),
 *   default_step = "order_information",
 *   wrapper_element = "fieldset",
 * )
 */
class ContactInformation extends \Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\ContactInformation implements CheckoutPaneInterface {
  /**
   * {@inheritdoc}
   */
  public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
    $pane_form = parent::buildPaneForm($pane_form, $form_state, $complete_form);
    $form_builder = \Drupal::service('entity.form_builder');
    $order_form = $form_builder->getForm($this->order, 'default');
    $user_entry = $form_state->getUserInput();

    $pane_form['field_phone_number'] = $order_form['field_phone_number'];
    $pane_form['field_phone_number']['#weight'] = 99;

    if (isset($user_entry['field_phone_number'])) {
      $pane_form['field_phone_number']['widget'][0]['value']['#value'] = $user_entry['field_phone_number'][0]['value'];
    }

    return $pane_form;
  }

In my checkout form I am disabling HTML5 validation by setting $form['#attributes']['novalidate'] = 'novalidate';

Upon submitting the form without entering any data, the server side catches all the fields that are required but empty with a message saying the field is required (Email, First Name, Last Name, etc...).  All the fields except my Phone Number field.

In debug mode I see that the field has a key ['#required'] = true but the server side validation is not catching this field.

Any help would be appreciated.  Let me know if there's anything else you need that might help solve this issue.


texts: SQL query for phpMyAdmin to delete authenticated users

texts:
Question 1: I would like an sql statement to use in phpMyAdmin to delete the users with the role: authenticated user. Looks like rid = 2.

Related Question 2: I show thousands of users in admin/people but the query:
SELECT * FROM drup_users WHERE 1
only shows 30 users. Shouldn't they all be there?

Related Question 3: I created several roles but only the three standard roles appear using:
SELECT * FROM drup_role WHERE 1
Where are all the roles I created?

I think I'm having some gross conceptual error. I would appreciate any guidance :)  Thanks!


texts: How can I render out my main menu as entirely expanded? I am working on mobile navigation and need to have the entire tree rendered out in my code for this to work the way I want it to. I do not want to make admins go into the menu and select "expanded" every time they create a child item. Can this be done with a module or


texts: What is the correct way to organise and separate functions in a Controller into their own files?

texts:
Here is my test.routing.yml:

test.alpha:
  path: '/test/alpha'
  defaults:
    _controller: Drupal\test\Controller\TestController::testAlpha
    _title: 'Alpha'
  requirements:
    _permission: 'access content'

test.bravo:
  path: '/test/bravo'
  defaults:
    _controller: Drupal\test\Controller\TestController::testBravo
    _title: 'Bravo'
  requirements:
    _permission: 'access content'

sitelog.charlie:
  path: '/test/charlie'
  defaults:
    _controller: Drupal\test\Controller\TestController::testCharlie
    _title: 'Charlie'
  requirements:
    _permission: 'access content'

Here is my Controller: TestController.php:

namespace Drupal\test\Controller;

class TestController {
  public function testAlpha() {
    return array(
      '#type' => 'markup',
      '#markup' => 'Hello, World!',
    );
  }
  public function testBravo() {
    return array(
      '#type' => 'markup',
      '#markup' => 'Hello, World!',
    );
  }
  public function testCharlie() {
    return array(
      '#type' => 'markup',
      '#markup' => 'Hello, World!',
    );
  }
}

My Controller file is set to grow. I will be adding many more functions, and adding hundreds of lines of code to all of those functions.

What is the correct way of organising and separating out those functions into their own files, in a Drupal 8 project?

In Drupal 7 we used .inc files to keep files from getting too large. Sometimes a common.inc would be used to group reusable functions.

What I like about React is that functionality is broken up into separate components, into separate files. I prefer lots of files, containing a small amount of code, organised into folders.

I'd like to bring this same approach into my Drupal 8 projects, but follow the correct PHP standards/Drupal best practice. My goal being to improve: the readability of my code, ease of finding my code, and possibly, the organisation of reusable code.


texts: Drupal 6 : views Exposed Form : rename the label of a field : please how?

texts:
I need the checkboxes labels exposed in views search pages
to be different than the checkboxes labels displayed in the node/xx/edit forms.

I found the same documentation everywhere about the way to change the label of a submit button using a template.php function (works fine) :

function MYTHEME_preprocess_views_exposed_form(&$vars, $hook) {
  if ($vars['form']['#id'] == 'views-exposed-form-XXX') {
    $vars['form']['submit']['#value'] = 'gagarine' ;
    unset($vars['form']['submit']['#printed']);
    $vars['button'] = drupal_render($vars['form']['submit']);
  }
}

I can't find any accurate documentation to rename a cck field label when exposed in a search page.

edit² : cleaning the thread for relative readability since I got something working


texts: How to put a Slider widget into the Better Exposed Filters for Ubercart price and other product features?

texts:
How to put a Slider widget into the Better exposed filters and product search result view in Drupal 7 for Ubercart price and other product features?

I have developed an ecommerce shop, and need to a add slider widget to search products.


texts:
I'm trying to create a JSON API that will return an array of JSON results matching specific search criteria.  It will always be searching one specific content type, but will need to match custom fields for specific search terms.  I will be passing a term to match a given field, for example:

/api/my-content-type?first_name=bob&term_a=my+term&another_field=search+term+here

The response from this needs to be an array of JSON objects containing the fields for that given content type.

I've seen many modules for this, but don't seem to see any that allow searching by field.  Is this something I would need to implement custom?  If so, what is the best module and/or method to start from?

Im not sure if I should be using a Search API, Services, one of the many REST JSON API Modules, etc.


texts: A module for displaying the author and the title

texts:
I am quite new to coding and Drupal.
I need to create a module which should display the author name and the title in a tabular view. I am lacking my time to do this task.

Can anyone help me finding a solution?


texts: preprocess views send arguments to facets

texts:
I am trying to filter user ip on the template.theme file on Drupal 8 and the intention was to filter on user ip and based on the ip add in the correct arguments into the facets that is created in views page.

Is that possible in views? I can't find any reference to it.

Here is what I found:

function mtheme_preprocess_page(&$variables) {
    $languagecode = \Drupal::languageManager()->getCurrentLanguage()->getId();
    $client = @$_SERVER['HTTP_CLIENT_IP'];
    $ip = $client;
    $ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
    $ip_data->geoplugin_countryCode;
    if(isset($ip_data->geoplugin_countryCode)) {
        if($ip_data->geoplugin_countryCode == "CH") {
            $location = "suisse";
            $link = '?f[0]=localisation:3';
        } else if($ip_data->geoplugin_countryCode == "FR") {
            $location = "france";
            $link = '?f[0]=localisation:4';
        } else {
            $location = "international";
            $link = '?f[0]=localisation:5';
        }
    }
    $redirect = $link;
    $response = new Symfony\Component\HttpFoundation\RedirectResponse($redirect);
    print "
".$languagecode."
";
    print "
".$location."
";
    print "
".$link."
";
}

function mtheme_preprocess_views_view(&$variables) {
    $view = $variables['view'];
    $id = $view->storage->id();
    $variables['css_name'] = Html::cleanCssIdentifier($id);
    $variables['id'] = $id;
    $variables['display_id'] = $view->current_display;
}

Currently I have not managed to find out how to add in the arguments for the facets but I managed to get it working by setting in the preprocess page and add in some hack (div elements and let JavaScript do the work but it's not clean to load the page 1st then reload with arguments. Here is the JS for it:

function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
    });
    return vars;
}

$(document).ready(function(){
    var url = window.location.href;
    var arr = url.split('?');
    console.log(arr[1]);
    if($('body').hasClass('page-pro')) {
        if (!arr[1]) {
            if ($(".loc-check").text().length > 0) {
                window.location.href = '/projets'+$(".loc-link").html();
            }
        }
    }
});

Sorry if it's not efficient, the question is am I able to work directly on preprocess_views and just add in the preload arguments based on user ip rather than this hack?

Any references?


texts: Views, Display Suite - fatal error on allowed memory size - what could be happening?

texts:
I am setting up my guitar lessons site which has categories via taxonomy and then lesson and exercise content types. Exercises are in a lesson, via entity reference. I am using Views and Display Suite. When I try to add a taxonomy view so I can list the lessons (along with the exercises therein), I get this:

Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 64 bytes) in /home/user/dev.example.com/sites/all/modules/views/includes/base.inc on line 93

Here is what I did:

I created a view (content pane) for taxonomy terms of type lesson category. The goal is to have a display such as

Lesson 1
Lesson 1 Description
    Exercise 1 in Lesson
    Exercise 1 Description
Lesson 2
...

The view filters on taxonomy vocab (term Lessons), there is contextual filter on taxonomy id, and relationship Taxonomy term: Content using Category. I posted screen shot.

I chose view mode lessons_in_category.

Then I wasn't sure what to do in Display Suite. I went to taxonomy (Lesson) content manage display, and for the lessons_in_category view mode I put the lessons in category view in the content. Screen shot attached.

I keep getting the memory error. And seems to me it shouldn't actually be a memory problem. For instance, when I click on a category, it is not like that one category has so much content to generate a memory error. So I have a feeling there is some sort of infinite loop being generated somehow between views and display suite.

Ideas?


texts: Internationalization (i18n) + Translation Management - No interface for adding translator available

texts:
In the Translation Manager menu (http://<mysite>/admin/content/translation-management/manage-translator?from=en&to=hu), when I want to add a translator to a given page, I see the following error message: "No interface for adding translator available.".

What should I do?
I think I gave the right permissions to the administrator and another given user (I checked the following permissions in "ICanLocalize translator" checkbox: "submit content for translation", "can do translation jobs", "can view translation jobs", "translate content", and gave "ICanLocalize translator" role to the admin and the other mentioned user), i18n module is installed, so I don't know what is missing.

Here's a screenshot:


texts: How to create page and restrict it to authenticated users?

texts:
I'm using the empty_page module to create "myhome" page and show blocks with a user's own content. That page throws an error for authenticated users.

How can I create an empty page in code and throw a 403 error when a visitors tries to access it?


texts: How to add translation of terms to a search API index?

texts: I have some media in the site default language, it is tagged by terms and the terms are translated. The media is not. How could I add the translated terms to the search index so it's possible to find the media using the translated term?


texts: Changing the default selection of a dropdown option in the Search function

texts:
I'm new to Drupal and am stuck trying to fix the default option on a dropdown Taxonomy filter on my Custom Search box. See it in the sidebar at artnotapart.com

The Year taxonomy is defaulting to 2015 and I can't find a setting to change it. It doesn't default to 2015 when I use a checkbox to display the options.

I've been through a lot of the core files (not sure if I've been through the right ones) but can't see a hook_form_BASE_FORM_ID_alter() or hook_form_FORM_ID_alter() which I think are they ways one would implement this feature.

Very stuck at the moment, any suggestions?


texts: Specify the reason for the refusal of publication node

texts:
Please tell me whether it is possible to realize the functional moderation node using the Rules and Rules Link modules.

When you click the "Decline", moderation offers fill in the "Cause"?

3 day looking for a solution, shoveled a lot of information already.
Now implemented regular rulesov link "Decline" for no reason.


texts: Remove taxonomy terms by name, not ID with VBO

texts:
I am using a rules component with VBO to allow users to bulk remove taxonomy terms from entities. The rules takes in 2 parameters:

The entity type
The taxonomy term to be removed.

Number 2 is input by the user.  However, the taxonomy term parameter requires the id of the taxonomy term.  I need to allow the user to enter the actual taxonomy term since they will not know the id of the term.

Anyone know how to grab the taxonomy term text from the user and remove it from a list of taxonomy terms?

Thanks,
Mickey


texts: Uninstalling an entity "BaseFieldDefinition" on module uninstall

texts:
I'm attempting to create my first module, which doesn't do much. I'm looking to:

Add a couple of extra fields to a menu item.
Save them in to the menu_link_content_data table.
Access them within theme templates.
Remove the items from the menu_link_content_data table when the module is uninstalled.

I've managed (after A LOT of reading through the awful docs) to get 1-3 completed, but 4 is giving me issues.

Does anyone know how to do this?

I've tried the following in my_module.module file:

function detailed_menu_uninstall() {
  // Deletes the field storage for the 'detailed_menu_heading' base field.
  $definition = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions('menu_link_content')['detailed_menu_heading'];
  \Drupal::service('field_storage_definition.listener')->onFieldStorageDefinitionDelete($definition);
}

Where detailed_menu_heading is the name of the table that was added to the menu_link_content_data table (using HOOK_entity_base_field_info(), with $fields['detailed_menu_heading'] = BaseFieldDefinition::create()). But it doesn't seem to work.

If anyone could give some advice (while I still have a few homer-esque strands of hair left), that would be awesome!


texts: How to get list of all keys defined in the routing e.g path, defaults, options etc and how can we add new custom key?

texts:
route_with_two_nodes:
  path: '/foo/{node1}/{node2}'
  defaults:
    _controller: '\Drupal\example\Controller\ExampleController::foo'
  options:
    parameters:
      node1:
        type: entity:node
      node2:
        type: entity:node

I need to get list of all keys path, defaults, options etc, where is it defined in Drupal Core ? so that if I need to add custom key and extend it


texts: Which IPs/hosts does Drupal query for updates?

texts:
I recently migrated a Drupal 7 installation from my own development server to a hosted solution, which runs all nice and dandy, however Drupal now can't load the data anymore to check for available updates.

It says,

  Fehler beim Abrufen der Daten über verfügbare Aktualisierungen.

Or in English, I think the translation is:

  No available update data

I asked the technical support of the web hoster if they could remove any kind of firewall or filter that'd block Drupal's external requests, and they replied to me that they needed to know which URLs / IPs or hosts are called so they could whitelist them.

What are these URLs?


texts: How to to check if user has changed the password?

texts:
I wanted to send basic notification email to the user, after it has changed the password, to inform him of password change.

I am using Rules modules for that. But I am not finding any option there, to add condition if user has changed the password.

Is there any way I can check if user has changed his password using rules or pragmatically.

-- Many thanks for your time.


texts: Drupal 7: Display latest articles by an author with bio

texts:
I have a content type called "Author" and have an author field on other content types which has a reference to the "Author" CT. (e.g. News Article having an author field)

The "Author" CT has these fields:

Title (Author Name)
Image
Bio

I'm using Panels on Drupal to create pages and I want to display Author pages like /author/author-name with Views, Panels, etc to display the Author name as Title of the page, author image and bio on top and the latest nodes by that author below all that bio.

I've created a view called Author with a contextual filter Content: Author but I'm unsure about how to use this on a Panel.

How do I go around this process to embrace panel pages and views to create author pages?


texts: How to update all instances of field with a santitized copy of another field

texts:
I want have added an extra field to a table and want to use db_update in hook_update_N to populate it with a sanitized copy of a preexisting field.

Just copying a pre-existing field is trivial if one uses db_update().

db_update('my_table')
  ->expression('field_copyof_unsafe_value', 'field_unsafe_value')
  ->execute();

However, what I want to do something like this:

db_update('my_table')
  ->expression('field_plain_value', check_plain('field_unsafe_value'))
  ->execute();

I.e. pass the value of field_unsafe_value through some function before storing it in the new field.

For avoidance of misunderstanding: I know the code above will not work (and that it will throw an exception).  It is pseudo-code to illustrate what I want to achieve.

My question is: Is it possible to use a function call in db_update() to compute value to store, and if "yes": How to do it?


texts:
This seems strange to me, but everything worked fine before i made my site live. I set up all the content and made a backup. Uploaded everything to its server but now i can't change my images. When i remove the current image this comes up (see image) instead of being able to upload a new image

And console throws this error:

I have tried all the versions of jquery and my jquery_update in contrib is 7.x-2.7

Could it be something with the permissions? i have site/default/files-775


texts: How to make a single query with multiple records

texts:
How do I make this as a single query?

$result = db_query("SELECT replace(source, 'node/', '') as source FROM {url_alias}  where source like 'node/%' limit 11");
foreach ($result as $record) {
$result2 = db_query("SELECT fci.* FROM {node} AS fci LEFT JOIN {node_access} AS fdfp ON fci.nid = fdfp.nid where fci.nid = :item_id AND fdfp.nid IS NULL", array(':item_id' => $record->source));
  foreach ($result2 as $record2) {
    echo '<pre>';
    print_r($record2);
  }
}


texts: Google Store locator Store Phone and Store Web not visible

texts:
I am using Google Store locator module for my Drupal 7 website.

I have used version 7.x-1.1. But when I test my page the Phone number and website are not visible on the frontend?

If you can see there http://litebook.eu/store-locator/json in the browser you can see the data is added (store phone and store web).

Why are those fields not visible on the frontend?

Thanks


texts:
Node teasers are breaking my layout by not closing div and span tags.

The nodes are being written using WYSIWYG and CKEditor 3.4.2.6041.

An example of this broken layout is:
http://www.energyjustice.net/node?page=2


texts:
I'm currently trying to get a Views search page set up, but am running into a roadblock when using 2 different data sources.
My process for creating a working search page, starting after installing Search API and disabling the default core search module:

I go to /admin/config/search/search-api and click Add Index.
In the subsequent page I give it a name (Content Index) check off Content from data sources, and choose 'Database Server' from the Server list. I click 'Save and Add Fields'.
In the following 'Add Fields to index' page I add Title and click Done. I set Title's Type to Fulltext and click Save changes in the subsequent screen.
I then go to the View tab and click Index now to index all of the data.
I then go to /admin/structure/views and click Add view.
I give my new view a name (Content Search) and in the View Settings 'Show' dropdown I select 'Index Content Index'. I check off 'Create a page' and click Save and edit.
In the Edit View page, I add a filter, check off 'Fulltext search' and click 'Add and configure filter criteria'.
I check off 'Expose this filter to...' and in Searched fields I click Content >> Title and then click Apply. Then I save the entire view.

When I view this page and test it, everything works fine. Anything I search for returns whatever piece of content has the search term as it's title. When I set this up in the same way for Field Collections, it works perfectly.

When I set the index to account for two data sources in step 2, it seems to index all of the content I want, but the search results only return the content that contains the search term and not the field collections that have that term.

Is there a setting anywhere I need to adjust to account for both data sources?


texts: Views OOP approach - Let Views extend from Meta/Parent View

texts:
Hej.

On my Drupal Site I have several slider, all of them have the most in common but could differ in some way.

I'd like to have a View as Meta/Parent View so that if something is changed it will be changed in the Child Views as well. But every Child View could have their own attributes or adaptions.

I know there is the Display Section in the View but if I add a View or Display and change something, it effects every view even the Master Display.

Is there something like a View OOP approach in Drupal?


texts: How to Schedule a node "Promoted to front page"?

texts:
I am looking for a way to schedule "Promoted To home page" nodes to appear after a particular time.

When user creates a new node and checks "Promoted To home page", it should not appear immediately on publish on the homepage.

Then need a scheduler which set "Promoted To home page" nodes to appear on front page.

The node will published and visible if accessed directly or seen in other section.


texts:
I am working in Drupal 7 in Ubercart 3, and I am looking for a way to set a minimum on the number of items that a user can have before being able to start the checkout process.

Is there a module out there that handles this need?


texts: Display a field in a view using comma separated values

texts:
I have content type "test" which has fields title, uuid(text field with one value allowed)

In view I am using Unformatted List.

In view uuid values are displayed as below:

akjfkljdf
jkljljkjl
kdjsfljksdlf

But I want the uuid values to be displayed as below:

akjfkljdf, jkljljkjl, kdjsfljksdlf

I tried to use template file named "views-view-field--test--field-uuid.tpl" and kept this template file in sites/all/modules/views/theme/ folder, but its not working . Template file has code:

 <?php print implode(",",$output); ?>

Please let me know where I am going wrong.


texts: In view, $content is null when show: fields

texts:
I'm trying to customize the row style template for one of my views. The settings are

Format: HTML List
Show: Fields

With these settings, $content is null in my .tpl.php file. I know about $fields, and I can see my values in there when I var_dump. However, the values are buried SO DEEP in there that I'm having trouble getting at them. I'm sure I must be doing something wrong.

How do I access my fields in a custom tpl for a view?


texts: I am working drupal 8 site. In this site I create a contact form for contact page. I am able to translate field label but I want to translate my placeholder.I can't find any option for translate contact forms placehoder in drupal 8.


texts: EntityQuery get contents which were not modified

texts:
I'm writing a very basic query to get the count of contents which were not modified. The logic I'm applying here is simple too, just check if created = changed
The SQL query is pretty straightforward too.
SELECT COUNT(nid) FROM node_field_data WHERE type = 'my_content_type' AND created = changed

However getting this into EntityQuery syntax seems to be a bit difficult.
$query = \Drupal::entityQuery('node')
           ->condition('status', 1)
           ->condition('type', 'my_content_type')
           ->condition('created', 'changed', '='); //Need help here

$not_updated = $query->count()->execute();


texts: Injecting configuration into mock config object

texts:
I'm trying to set up a unit test based on UnitTestCase in Drupal 8 that uses some config variables. Unfortunately I was not able to find a way to insert those config variables into the system in the setup (searched Drupal documentation and any Drupal unit test example involving config), so the function being tested always works with null config and fails. I am trying to test individual functions in isolation, so a browser test is not really appropriate for this.

I have simplified the problem to the minimum code necessary to explain/reproduce the issue. Here are the three components. Where in the mock/setup do I insert the array('bucketName' => 'test_bucket') and other properties so that it can be read from the tested function?

Function:

public function example() {
    return \Drupal::config('my_module.job')->get('my_module.bucketName');
}

Test function:

public function testExample() {
    $myModuleHelper = new MyModuleHelper();
        $expected_config = array(
            'bucketName' => 'test_bucket',
        );

    $this->assertEquals($expected_config, $myModuleHelper->example());
}

Test setup:

public function setUp() {
    $this->config = $this->getMockBuilder('\Drupal\Core\Config\ImmutableConfig')
        ->disableOriginalConstructor()
        ->getMock();

    $this->configFactory = $this->getMockBuilder('\Drupal\Core\Config\ConfigFactory')
        ->disableOriginalConstructor()
        ->getMock();
    $this->configFactory->expects($this->any())
        ->method('get')
        ->with('my_module.job')
        ->willReturn($this->config);

    $this->container = new ContainerBuilder();
    $this->container->set('config.factory', $this->configFactory);
    \Drupal::setContainer($this->container);
}

Test response:

  null does not match expected type "array".


texts: How to display or hide a Views field based on it's length?

texts:
I have 2 fields in Views the first of which is always displayed, and the second I would like to display only if the first field has more than 70 characters. I have tried to do this using Views Conditional module but for some reason it does not work.

I have also tried this using Views PHP module by using drupal_strlen and replacement patterns, but this isn't working yet either. Below is the code that I am using:

<?php

if (drupal_strlen($row->comment_body) >= 70) {
  print $row->php;
} else {
  print $row->nothing_1;
}
?>

How can this be done?


texts:
I created a custom image field for a banner in one of my content type. I wish to display this banner in the page.tpl.php instead of node template. Here's my code in template.php:

function mytheme_preprocess_page(&$vars, $hook) {

     $vars['banner'] = '';
    if (!empty($vars['node'])) {
        $node = $vars['node'];

        if (isset($node->field_banner)) {
                // Render the image as a variable in the page template
           $vars['banner'] = theme_image_style(array('path' => $node->field_banner['und']['0']['uri'], 'style_name' => 'mybannerstyle', 'height' => '200', 'width' => '700'));
        }
    }

.....

and in the page.tpl.php, i coded:

    <?php if(!empty($banner)){print $banner;} ?>

. This work perfectly in the node that has banner uploaded. But for nodes which have no banner, the following undefined messaged turn up:

Notice: Undefined index: und in mytheme_preprocess_page() (line 33 of /home/xxxxx/themes/mytheme/template.php).

I wonder how to solve this. Please advise. Thanks.


texts:
I'm currently trying to import a large amount of data, including substantial amounts of html coded text into nodes in drupal. When I run the importer the view shows the contents of fields, but where the html tags are all visible with no formatting at all. Also when you go in to look at the node in edit the html fields are completely empty.

I'm not sure what would be causing this. Using Drupal 7.53 Feeds 7.x-2.0-beta Feeds extensible parser 7.x-1.0-alpha and feeds tamper.


texts: How to display parent records with its referenced entities(child reoord) in views table format

texts:
I am new to drupal and I require help from you guys.

My requirement is :

I have one custom content type : Architecture and for that custom content type I have different entity references associated with it such as Data Architecture, Technology Architecture, Market Architecture.

so I have Architecture 1 as Parent architecture and then I have
Data architecture 1.1, Data architecture 1.2 are associated with Architecture 1 as entity references. Similarly Technology Architecture 1.1, Technology Architecture 1.2 are associated with Architecture 1.

So I need to display those in views in following format (table):

Architecture 1 -- other fields
Data architecture 1.1 -- other fields
Data architecture 1.2 -- other fields
Technology Architecture 1.1 -- other fields
Technology Architecture 1.2 -- other fields

Architecture 2 -- other fields
Data architecture 2.1 -- other fields
Data architecture 2.2 -- other fields
Technology Architecture 2.1 -- other fields
Technology Architecture 2.2 -- other fields

I have tried with adding relationship but no luck.

Please help.

Thanks in advance


texts: When I change a node title and hit save, I get 'page not found'

texts:
I have a site which behaves strangely, whenever I change the node title, it give a page not found error.
I think it has to do with Drupal trying to find the node by path alias, but why?
It should find it by node ID?

I have even installed the module Global Redirect, but that does not help.

Suggestions are welcome!


texts: Call multiple hook inserts from different modules?

texts:
Is it possible for two modules that interact with one another to both call hook_insert()?

I have a node type that calls ModuleA_insert() when the user hits the 'save' button.
Module B is a custom comment-like module that gets injected into a form. In module B, I have a ModuleB_insert(), but it never runs.
I am trying to keep module A from having to deal with the inserts/updates from module B.

I can get module B to insert by using hook_nodeapi(), but it would be easier if I could get hook_insert() to work, meaning module A and module B's data and actions are separated from each other - not to mention the overhead cost of having hook_nodeapi() run and check every time.


texts: How can you filter an integer column by "Starts with"?

texts:
I have a view, and I want the users to be able to filter on an Integer field.  String fields allow for filtering by 'Starts with'.  I would like to do the same but with an integer.

If the user enters "10" it would match 100, 1010, etc, but not 210.


texts:
I´m getting data from web service in Drupal 8:

$uri = "http://localhost:8888/drupal8/tipo_receta.json";
 try {
    $response = \Drupal::httpClient()->get($uri, array('headers' => array('Accept' => 'application/json')));
    $data = (string) $response->getBody();
    if (empty($data)) {
      return FALSE;
    }else{
        print $data;
    }
  }
  catch (RequestException $e) {
      return FALSE;
  }

I have this JSON source:

{
    "document_type ": "receta",
    "recipe_doc_id ": 1,
    "recipe_title": "Título de la receta",
    "recipe_description": "Descripción con todos los pasos de una receta",
    "recipe_ingredients": [
        {
            "ingredient_doc_id": 33,
            "ingredient_doc_hid": "ing_pera",
            "ingredient_name": "pera",
            "ingredient_value": "2 peras"
        },
        {
            "ingredient_doc_id": 54,
            "ingredient_doc_hid": "ing_manzana",
            "ingredient_name": "manzana",
            "ingredient_value": "300 grs. De Manzana"
        }
    ]
}

This is my result on the page:

C:\wamp64\www\drupal8\core\themes\bartik\bartik.theme:142:string '{
    "document_type ": "receta",
    "recipe_doc_id ": 1,
    "recipe_title": "Título de la receta",
    "recipe_description": "Descripción con todos los pasos de una receta",
    "recipe_ingredients": [
        {
            "ingredient_doc_id": 33,
            "ingredient_doc_hid": "ing_pera",
            "ingredient_name": "pera",
            "ingredient_value": "2 peras"
        },
        {
            "ingredient_doc_id": 54,
            "ingredient_doc_hid": "ing_manzana",
         '...

How can i get an array so i could filter the data like this?

if($data['recipe_doc_id'] == "1"){
print $data['recipe_title'];
}


texts: Form problem : calendar pop up overriden by an autocomplete field

texts:
Drupal 7. I use a bootstrap theme with some customized css.
I have a node/edit form with a date field with calendar popup widget and an entityreference field with autocomplete widget.

When I click on the date field, a part of the calendar is missing : it is overriden by the autocomplete field.(see picture below)

If I change the widget for the entityreference field and choose select widget, the calendar is OK.

With the original bootstrap theme (without customized css), the calendar is OK.

Is there something I can change in CSS to prevent the calendar to be overridden by the autocomplete field ? (should I change the date css ? or the autocomplete css ?, which setting ?)


texts:
how we can upload file on media browser type field programmatically.

  Below are my code:

$temp_attachpath = MYFILEPATH;
        $attachpath = drupal_realpath($temp_attachpath);
        if(file_exists($attachpath)){

            $file = (object) array(
                'uid' => 1,
                'uri' => $attachpath,
                'filemime' => file_get_mimetype($attachpath),
                'status' => 1,
            );
            // We save the file to the root of the files directory.
            $file = file_copy($file, 'public://');
            $new_node->field_upload_file[$new_node->language][0] = (array)$file;
        }else{
            $new_node->field_upload_file[$new_node->language][0] = '';
        }
        node_submit($new_node);
        node_save($new_node);


texts:
I've been playing around with Drupal 8 since about a week. A couple days ago I tried to design the user login page to my needs but I couldn't quite do it. My problem is the following:

I want to customize the user login form (/user/login). I can edit the user login page (page--user--login.html.twig) but I can't find out what the name is of the user login form? How can I restructure the elements of the user login form? Or am I looking in the wrong place?

I appreciate any help you can give!


texts: I have a view of content type 'video' which shows a preview videos of particular author. I have passed content id as contextual filter. Now,I want to show a node (video) to the other users but not the node author.How can I hide it from only the node author in my view?


texts: How can I block users from registering with disposable email addresses?

texts:
I have a site where users send messages to one another using the Private Message module, and they are notified of messages by email.

On this site, there are a variety of spammers, scammers, and abusive users who attempt to register multiple accounts using disposable email addresses.

I know it's impossible to block every possible disposable email address domain, but is there anything in the Drupal world that can help me?

I considered white-listing valid domains, but my user base is too diverse for this.
The only project I could find on drupal.org has been abandoned.
There are third-party APIs such as this one.

At the moment, I'm blocking them manually using this code:

/**
 * Custom validation function from the Domain Registration module (1.0).
 *
 * Checks if the domain in the email address is on a list of blocked domains.
 * @param $form
 * @param $form_state
 */

function MYMODULE_domain_registration_user_register_validate(&$form, &$form_state) {
  $default_message = t('You are not allowed to register for an account on this site.  Contact support for more information.');
  $mail = explode('@', $form_state['values']['mail']);
  $exact_domains = array(
    'ad.drupaler.org',
    'drupaler.org',
  );
  $partial_domains = array(
    'pp.ua',
    'guerrilamail',
  );
  if (isset($mail[1]) && !empty($exact_domains)) {
    if (in_array($mail[1], $exact_domains) || MYMODULE_contactinfo_check_banned_words($mail[1], $partial_domains)) {
      form_set_error('account', variable_get('domain_registration_message', $default_message));
    }
  }
}


texts: Search API - give preference to content from particular node type

texts:
Using the Search API and Views, how do I give weighting such that nodes of a particular type will appear before others?

So for instance a Product description (of type product node) will appear above a forum post about that product?


texts:
I have webform in my site, so I need to do that there are 2 user approval field components in my webform so they both should be unique value, in my case its working like if my name is joy then I submit that form then it will display joy on both field's value.

I want to just display only one field joy and another field value get from another user. please let me know if anyone has solution for this.


texts: How to revert a feature in hook_update programatically?

texts:
I've created a feature to update a menu. Then in my deploy module, I did this:

function phoenix_deploy_update_7106() {
  $feature_list = array(
    'campus_dropdown',
  );
  features_revert($feature_list);
}

but then running drush updb -y on the staging site, doesn't enable my new menu items.

Have I gotten the commands right to revert the feature?


texts: Execute actions (actions module not rules module) programatically

texts: How can an action from the actions module be executed programatically? In D7 there was actions_do() but in D8 actions are plugins or configuration entities according to https://www.drupal.org/node/2020549.


texts: output different info in view depending on comment count

texts: I have a comment count at the bottom of each view item but if the comment count is 0, I would like to have a comment link suggesting the user post a comment instead. Is there a way to do this in Views UI?


texts: Where is the best place to insert additional logout functionality?

texts:
To insert additional logic when a user logs off one might look at function user_logout() in user.pages.inc.  This code being in a core module, you should not edit it, but works very well... for example by adding the following code to the top of the 'user_logout()' function...

$last_run = variable_get('cron_last', 0);
if(time() - $last_run > 86400) {
    include_once './includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    drupal_cron_run();
    drupal_flush_all_caches();
    watchdog('user', 'cron set to run and cache to be cleared on user logout', array('%name' => $user->name));
}

... I get the cache cleared and cron run if cron has not run in the last 24 hrs.  Okay, not ideal for cron but that's another issue.

Where is the best place to add this little snippet?  I could simply implement my own logout menu item... but I'm not keen on that solution.

Thanks in advance.


texts:
How can I create a customised add/node form in D7?

I am not talking about a form for gathering information that is not content for the site, like an event registration form. I'm talking about the node/add form where you create content for your site.

What I want to replicate is just some simple html tables, arranged together, and some css to make it look good. Lots of boxes in which to insert numbers, mainly, a few drop-downs and text fields too. Imagine you navigate to node/add/scorecard and something like this appears:

Thanks.

SOLUTION

This is the solution I have arrived at:

(1) Create a module (.INFO and .MODULE files).

(2) Implement hook_menu (in your new module) to create a url and page where the form is to reside.

(3) Add a function to render the HTML of the form using drupal_get_form.

(4) Add a form builder function and construct your form using an array called $form (see form API for details).

(5) Add a submit button at the end of your form.

(6) To make the form look the way you want it to there are several methods: (i) create a theme function to add to the elements of $form; (ii) use #prefix and #suffix properties to add additional HTML and CSS ids/classes to the rendered form; (iii) manipulate the many ids/classes, rendered by drupal_get_form, with CSS; (iv) use the #markup properties to add additional HTML and CSS ids/classes to the rendered form (not recommended). I used a combination of (ii) and (iii). I could not work out how to do (i) but it is probably the 'most correct' method.

(7) Add a validation function.

(8) Add a submit function using node_save (for nodes) and drupal_write_record (for fields) to insert your form values into the relevant database tables: node, field_data_field_my_field etc.


texts: Build an EntityFieldQuery that selects referenced entities

texts:
I am looking for the ID of the entity of type A and I know the ID of entity B that references A.

I found a few nice sources about EntityFieldQuery. I was amazed that i was getting results from .NET in google :) (is it a sign of Drupal's maturity ? :). But didnt manage to find this. Please help ...

Some of the sources :

How to on d.o
Discussion about building an example
An example module on github

This is what it looks like with entity loads - you will understand i need that query :) The wrapper is there for practice mainly. Note that it loads the target entity - quite a lot of queries.

  $b = entity_load('B', array($id));
  $bm = entity_metadata_wrapper('B', $sl[$id]);

  $tsl = $slm->field_sl_tpref->value();
  echo $tsl->id;


texts: How to add an attribute to CkEditor 4.x iframe tag

texts:
Does anyone know of a clean way to add an attribute to an iframe tag, or to add an equivalent parameter to the src attribute? Here is what I am trying to do:

I am using the iframe wysiwyg button in Ckeditor to allow users to paste in a video url from YouTube. The problem is, the mega menu dropdown shows up behind the video. To fix this, the iframe tag for the video either needs to have the attribute wmode="transparent added to it, or the actual src url needs to have the parameter &wmode=transparent appended.

Ideally, this would be enforced and not asked of the user. Has anyone dealt with this and implemented a solution? If so, please let me know what you did. Thanks!


texts:
I have strange behavior that when i visit www.mysite.com/taxonomy/term/516/sdfsdf

i get

  EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7788 of /../includes/common.inc).
      The website encountered an unexpected error. Please try again later.

while it should load content of

www.mysite.com/taxonomy/term/516

Can anyone help?


texts: Why has this "details" accordion appeared in this view?

texts:
I have a view that uses the table format and the "group by" setting.

I've just updated to the Drupal 8.9. Suddenly, each group has this empty Details accordion.

It wasn't there before.

Why did it appear? How can I get rid of it, other than removing it with CSS?


texts: Content Type Display different per theme

texts:
I'm using ThemeKey to switch my theme for mobile users. The problem i'm having is that i'm using image zoom for my products and on iphones it blocks the dropdown due to a hidden element. My question is, is it possible to change the way a content type is displayed per theme without disturbing the regular 'desktop' version of the site?

Clarification: What I'm referring to is when you go to Manage Display, how can you reposition content entities differently per theme.


texts:
I'm writing a simpletest for a module that posts XML directly to a URL (it's on a closed system so there's no user or auth or anything at this point).

I've manually tested getting the response code by using drupal_http_request() to POST the file, but since I'm now doing the same thing in an actual simpletest, I feel like I should use webTestCase->drupalPost().

The only problem is that drupalPost() seems to expect a save button value. I'm not POSTing via a form with a submit button, so can I still use drupalPost()? Or should I just use drupal_http_request() in my simpletest?


texts: How to set Target points to the User group?

texts:
There is a User Groups in our site (i used og)
Point system for posting nodes
(for this i used userpoints,userpoints_contrib,userpoints_nc)

Since its working fine, Now i need to set target points to the groups, so that the users of that particular groups needs to get the target points. They need to get the alert message like

  You have earned XX points, you need to get YY points to finish your target

How to do this? Is there any modules for this requirement? guide me...


texts:
How to render view in specific language?

$view = views_get_view("commerce_line_items_custom");
////Pass arguments
$view->set_arguments(array($data['commerce-order']->order_id));
$view->hide_admin_links = TRUE;
////Generate content
$content =  $view->execute_display('block');

I tried following overide, but it did nothing:

$view->set_display('block');
$view->display_handler->options['field_language'] = 'fr';
$view->display_handler->display->display_options['field_language'] = 'fr';
$view->display_handler->default_display->options['field_language'] = 'fr';
$view->display_handler->set_option('field_language', 'fr');


texts:
I am developing a Real Estate website for that i need EMI calculator Module.
From where i can get this.

Is there any module is developed for EMI Calculator


texts: Shared Drupal 7 core and shared contrib libraries & modules

texts:
I have a server and I run around 20 Drupal 7 websites. As I start to get more clients It's becoming increasingly more time consuming doing Drupal core and modules updates.

Is there any way to have a shared Drupal 7 core, libraries and modules (just the main ones that I use as standard like views, context, backup, libraries etc) so I can updated those once and it updates for ALL of my websites. Any site specific modules I would still like to keep seperate.

I'm running a linux server with WHM and cpanel for each account if that helps at all. I also have shell access to my sevrer.

note: that each website is running as a different account on the server so each is an individual vhost.

Any advice on how to manage this would be greatly appreciated


texts: how to delete the nodes having a specific entity reference but not the parent

texts:
I have a content type "students" and another "courses".
Student nodes are created with an entity reference to a course node.

I need to delete all students of "couses123" in a quick way.
How can I make a view which has a dropdown of all course names and when selected it shows list of all students.

From there, I can use the VBO to show a checkbox next to them for selection and deletion .

How can I achieve this?


texts: Group node from OG membership doesn't work

texts:
I want to create some views to display Group information on Group content pages. E.g. Display contact info from the group in a block/pane in the sidebar.

I did this before, by using the default OG Content view and add the relations.

I add the relationship OG membership: Group Node from OG membership, and sets its relation to (OG membership from node)
Set the contextual filter to provide a default value (Current OG group from context) and keep relation set to the default OG membership from Node.
Add fields and set their relation to Group node from OG Membership.

This isn't working though, it gives no results when viewing on Groupcontent-pages. It gives only results when viewing the Grouppage itself. I do not know why this is not working the way it should. As I recall I never had this problem before.

I used Organic Groups 7.x-2.7 with Panopoly 7.x-1.30. I have this on 2 separate installs (one on Acquia site, and one in my VM). The VM has only Panopoly and OG (and dependencys) installed as extra so it's almost vanilla.

I have enabled OG Context of course.

How can I solve this? Without these views it's a pain for the user to see in which groupcontext they are browsing.

EDIT:
I installed a vanilla drupal (Not Panopoly). Installed OG + dependencys.
Then I created an empty view and added the following:
1. Relationship: OG membership: OG membership from Node group (required)
2. Contextual: (OG membership from node group) OG membership: Og membership ID
and Current OG group from context

This works! However, this doesn't work in Panopoly... Is this the new way to work with OG and Groupinfo on groupcontent pages?

The SQL-querys views does are exactly the same. Though on Panopoly there are no results. On Vanilla Drupal there is.
How can I debug this?


texts:
Problem

I'm using jQuery toggle to make one block appear when another is clicked. The code works in jsfiddle but doesn't in Drupal.

Set-Up

I have a node with two blocks on it, applytoggle and tellafriend. Apply toggle:

    //*Other stuff*

Tellafriend:

In my template file I add the following script :

function mytheme_preprocess_page (&$vars) {
  drupal_add_js('sites/all/themes/tefltheme/toggle.js', 'file');

Which looks like this:

(function ($) {
    $('div.applytoggle').click(function() {
        $('.applytoggle_title, .block-tellafriend').toggle();
    });
})(jQuery);

This works great in jsfiddle - http://jsfiddle.net/dr9vG/, but doesn't in my actual page. The script is loaded successfully and I've got other jQuery scripts loaded and running the same way which work (not related, different objects). Why doesn't this work?


texts: Content display based on user preferences

texts:
I'm new to Drupal, so I don't know if what I want to do is even possible.
I want to create six checkboxes that represent different languages - let's call them A,B,C,D,E,F so that every user can check as many as he/she wants during registration and change it later (I already did that by adding field in account settings).
Moreover, on one page I'd like to have six blocks of text (one for each language) but only show the checked ones (so each user would see different content).
Finally, I want to enable users to create their own content which would be published after administrator's review - difficult part is that every administrator should have language/-es that he/she specializes in and be able to accept/edit content only in that language/-es.

If I am not being specific enough please let me know and I will try to elaborate.

Thanks for you help!
Dominik


texts: Block not showing up in Custom Blocks for Panel

texts:
I've made a simple text block and now want to display this on a panel. However, the block does not appear on the list of available blocks on the Custom Block page. I've tried clearing the cache, and making different blocks, but it appears that all new blocks aren't showing up in that menu.

I'm not sure what I'm missing. I found this disucssion, Block doesn't show up in blocks listing. But I don't really understand what their solution was (manually edit db entry?).


texts: Crumbs not adding home link to beginning

texts:
I have installed Crumbs on the site I am currently working on and for some reason I can't get it to display the "Home" link.

I have tried debugging some of the nodes and according to the results the home link should be displayed.

The home link is definitely enabled and there isn't any CSS or anything like that which may be interfering with it, am I missing something?


texts: How are better exposed filters - checkboxes value - assigned

texts:
I have been wrestling with this for a number of days. I apologize if this has been asked elsewhere, I am not able to find the fix, or maybe I am just not thinking in an incorrect way to make this work. One of my exposed filters searches using "Content:Has Taxonomy Term", I use the dropdown not autofill. With that created, I pull up my settings for better exposed filters. I expose my filter as checkboxes. the checkboxes that the Better Exposed Filters creates adds a number value to each of the checkboxes, not the taxonomy term name. Is there a way I can manipulate the output of the Better Exposed filter to show the name as the value, not id?

Here I create add a filter/filter criteria. you can see on the left I added a Content Has Taxonomy term (exposed)

Here you can see the criteria. I have clicked the "expose the filter to visitors" to allow the visitor to select how to filter. I click a couple options in the select list to show different predetermined options. and not shown, I select the option "limit list to selected items"

from the highlighted 1st image above, shows settings for Better Exposed Filters. I click the setting option, and for the display of that criteria, and for that filter, display filter as checkboxes.

After that, I can preview my checkboxes here.

If you inspect each of those checkboxes, you can see the value assigned to the checkboxes, is a number.

I believe it to be the Taxonomy Term ID?...

In this next screenshot, you can see the value from the checkbox represented as the same id.

This is where I get stuck... I want to show the term as the taxonomy term name, not id.
thanks in advance for your help!


texts: Image with cropping programmatically in a form

texts:
I created a custom module, and I need to add a new field: image with cropping programmatically into a form. I know how to add from the content type, but I need to do it programmatically. Is it posible to do it?

$form['group_anuncio'] = array(
  '#type' => 'fieldset',
  '#title' => t('2- Sube tu anuncio'),
  '#collapsible' => TRUE,   );

$form['group_anuncio']['titulo'] = array(
  '#type' => 'textfield',
  '#title' => t('Título'),
  '#required' => TRUE,
);

$form['group_anuncio']['image'] = array();

I need to insert the code in the third form.

I'm trying with this code, and it seems like it works for unloading. The problem is that I don't know how to crop the image.

$form['group_anuncio']['imagen'] = array(
        '#title' => t('Image'),
        '#type' => 'managed_file',
        '#upload_validators' => array('file_validate_extensions' => array('jpeg jpg png gif')),
        '#upload_location' => 'public://',
        '#progress_indicator' => 'throbber',
        '#status' => FILE_STATUS_PERMANENT,
        '#progress_message' => 'One moment while we save your file...',

  );


texts: Retrieving Entity Reference Fields programmatically

texts:
i am stuck retrieving an entity reference fields the correct way.
All i tried gave me an error or and empty array...

What you see here is my node object that holds the data (copied from the DSM output):

... (Object) stdClass
vid (String, 2 characters ) 64
uid (String, 1 characters ) 8
type (String, 6 characters ) people
    field_people_publications (Array, 1 element)
       und (Array, 3 elements)
          0 (Array, 1 element)
             target_id (String, 3 characters ) 839
          1 (Array, 1 element)
             target_id (String, 3 characters ) 840
          3 (Array, 1 element)
             target_id (String, 3 characters ) 841

Documentiontion on using entity reference fields programmatically seems very very rare. I have noch found much that helped me out.

Related to the DSM output above:

How do i retrieve the entity reference field 'field_people_publications' from the node-ID #64?

What are those 'target_id' about? Inside the HTML view these are checkboxes with 5 options available. This is quite confusing.

Can you give give me a helping hand?
What i wanted to do is to modify these options to some other values and save them again.


texts: We need to upload multiple files of different types, is there a module that will check for valid mime types and upload only the valid files, (based on site settings, eg: png, doc, jpg, txt) ?


texts: How to remove "READ MORE" in Marinelli theme at  frontpage?

texts:
Possible Duplicate:
  No 'read-more' to specific content type (eg page)

Hi i am using Marinelli theme for my website and i need to remove the READ MORE option at the front page, i created a front page with BASIC PAGE  content using VIEWS. What should i do to make it a full page ?


texts:
Ok, I'll try to describe the scenario I am facing since I can't narrow it down to sub-questions to see what feedback I can get.

Say I am constructing an e-commerce site that sells cakes (I love that example as it seems).

I have already created a view that shows all my cakes sorted alphabetically as thumbnails and also one view that shows all my cakes at a themed alphabetical 'catalogue' style (as this question shows) and both views link to eachother.

All nice and nifty.

Now what's come up is that the cakes are tagged with taxonomy terms that mark their... ehh.. flavor, their size, and say their... use (party - wedding - just a normal cake). I know the example is stupid but you get the idea.

The tricky part comes when I need a global (global as in available in all pages throughout the site) dropdown list menu that lists those taxonomy terms and upon selection takes the user to the first view (the thumbnail one) which is filtered only with the cakes that match the selected taxonomy.

I hear you mumbling that that's easy and that contextual filters is all I need. And I agree, and I've done that.

The tricky part comes now: If the user was lead to the view by this route and he clicks to go to the 'catalogue' view, the cakes that match, should be higlighted and if the user is in the 'catalogue' view and selects another taxonomy term from the menu he should remain in the current view and the appropriate cakes should be highlighted. Also if he should go back to the 'thumbnail' view, it should be also be filtered accordingly.

So, recap:

1) clicking a taxonomy term leads to a filtered 'thumbnail' view.
2) clicking the 'catalogue' view link while on the filtered 'thumbnail' view leads to a highlighted 'catalogue' view and vice versa.
3) clicking on taxonomy while on either 'thumbnail' or 'catalogue' view should perform the aforementioned mentioned actions.
4) if the user navigates away from either of the pages the whole process resets until a taxonomy is selected again.

P.S. on the 'catalogue' view the cakes' divs have their taxonomy tags as classes to make highlighting easier.

Thanks for your time in advance.

EDIT: I managed using arg(x) to make the links from one view to another dynamic, i.e:

if the user is in www.cakes.com/Cakes/AllCakes/[tid] and clicks the link to the 'catalogue' view, the link instead leads to www.cakes.com/Cakes/AllCakesList/[tid] which is filtered, which leads to the following question too:

5) is there a way to use contextual filters NOT for filtering but for other functions like adding a CSS class for instance?

EDIT #2: Marking with strikethrough the tasks already completed.

EDIT #3: First EDIT marked since filtering is (obviously) not the way to go. But since I have the [tid] on the URL and thus on arg(x) I could somehow use it to highlight the appropriate divs.

EDIT #4: Managed via inline javascript and using the arg(x) argument to highlight the cakes in the 'catalogue' view!


texts: How to add a language dropdown switcher to top panel?

texts:
I try to create a multilingual (3 languages, incl. English) website, and I’d like to create a language dropdown switcher (ideally in the top panel/menu). I tried to accomplish this using Flags, and Language Dropdown Switcher, but couldn’t display it though. It presume, I just don’t know how to add it in a block; although I could find the Language Dropdown Switcher in the block and add it there, but it did not show up. I could set the Flags up in the Configuration, but I did not find it in the blocks.

How do I install/enable/place a language dropdown switcher (preferably Flags, but this is not a condition)? It would be awesome (again: this is not necessary) if this switcher would be in the top panel and that it would contain country flags only (not the language as text).

Drupal 8.5.6 with configuration translation, content translation, interface translation and language enabled and the particular languages are already added in the configuration.


texts: Information added by Drupal.org on Distribution

texts:
Hi am trying to make a Drupal 8 Distribution, all is well, but when I download it from drupal.org I get on all modules this information.

I would like that all contrib modules to have their default information. What do I need to setup in order to remove the profile package from contrib modules?

In the image below Drupal.org comment out the module information and added profile information. I do not want to add the profile information on to the contrib modules.

# core: '8.x'
# Information added by Drupal.org packaging script on 2017-08-15
# version: '8.x-1.0'
# core: '8.x'
# project: 'ace_editor'
# datestamp: 1502816349

# Information added by Drupal.org packaging script on 2018-01-18
version: '8.x-1.x-dev'
core: '8.x'
project: 'myprofile'
datestamp: 1516303995

So it's not confusing I don't want to remove the information from Drupal.org. Somehow Drupal.org is packaging the modules as part of the profile, and the result is the image below

I want to be able to see it normally like the image below


texts: Creating config entities in a functional browser test

texts:
I am extending Drupal\Tests\BrowserTestBase to create a functional test which attempts to edit and save a config entity.

Creating this via MyEntity::create($data)->save(); has weird effects: They are not shown on the list-builder page:

$data = $this->randomEntityData();
MyEntity::create($data)->save();
$this->drupalGet('admin/structure/my-entity');
$this->assertSession()->pageTextContains('There is no Entity yet.'); // OK

But they can be edited by navigating to the edit form directly (which still leaves them unlisted in the list-builder.

$this->drupalGet("admin/structure/my-entity/{$data['id']}/edit");
$this->drupalPost(NULL, $data, 'Save');
$this->assertSession()->pageTextContains("The {$data['label']} Entity was saved."); // OK
$this->assertSession()->pageTextContains('There is no Entity yet.');

Creating the entity via a form submission doesn't cause this behavior.

Does the functional test setup have some kind of cache? I'd suspect that the local and remote use different config storage, but that is impossible because the edit form wouldn't be available at all.


texts: Create a field instance programmatically on a taxonomy vocabulary

texts:
I'm trying to create a module which creates a taxonomy vocabulary on installation of the module, and creates one text field on the taxonomy vocabulary/term. But I'm getting the following error when I enable my module:

  [error] FieldException: Attempt to create an instance of field field_flickr_photoset on forbidden entity type taxonomy_term. in field_create_instance() (line 468 of
  /var/www/www.example.com/htdocs/modules/field/field.crud.inc).

First of al, why a Forbidden entity type? Is it not possible to create a field on a taxonomy vocabulary through code? Or am I missing some parameters?

I used very similar code to create a node type and attach fields to it, which currently works without any problems. I didn't think that changing the entity type would cause such problems.

I tried searching on google and here on how to do this, but all I get is people who are asking how to attach a taxonomy term reference field to a node type, which is not what I'm asking. It's attaching a text field to a taxonomy term/vocabulary.


texts: Prevent access from files with direct url

texts:
In the Group module people can upload files if they're group manager. But the thing is, these files should be restricted to the group and everyone who isn't a member may not see this files.
The problem is they can see the files with the direct url: http://www.site.com/sites/default/.. I've tried the private folder and tweak some permissions with file_entity but without any result.
Does anyone know how to make files restricted to the group, even if someone access them with the direct url?


texts: Is there an example OAuth2 client module anywhere?

texts: Similar to this post and this request, I'm creating a OAuth client in Drupal 7 but using OAuth2.0. There's an OAuth2 module with an unpublished Drupal 7 version that I've toyed with, but it's geared pretty exclusively for servers or proxies, not clients. I've started writing a skeleton module for an OAuth2 client implementation, but before I go any further I wanted to make sure I'm not just spinning my wheels. Are there are any good modules that either implement a web services client using the OAuth2 standard, or a template module that I've missed?


texts: Generic field.html.twig template for a custom Entity

texts:
I have a custom Entity called custom_entity, along with a custom module which provides twig templates for my bundles and their fields.
How can I define a generic/base field template for all fields created under custom_entity?
For a specific field I could create the template:
field--custom-entity--field-my-field.html.twig

But I'm looking to do something more general, like:
field--custom-entity.twig

Where all my fields created on a custom_entity use this base template.
I don't want to modify field.html.twig in the theme. I want this template to only apply to my entity and its bundles.


texts:
I want to be able to create paths like this:

/guy1
/guy2
/guy3

It's easy enough if I want /profile/guy1 ... then I can just do this:

gg_profile.viewUserProfile:
  path: '/profile/{username}'
  defaults:
    _controller: '\Drupal\gg_profile\Controller\GGProfileController::viewUserProfile'

But I want it to work with the /profile bit. Changing it as follows doesn't work:

  path: '/{username}'

How do I make it work without having the extra /profile bit?